@x-edu/live-player 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +10 -10
- package/.eslintignore +8 -8
- package/.eslintrc.js +26 -26
- package/.gem-mine +11 -11
- package/.postcssrc.js +6 -6
- package/README.md +145 -145
- package/babel.config.js +33 -33
- package/doc/develop.md +23 -23
- package/gem-mine.config.js +86 -86
- package/jest.config.js +9 -9
- package/jsconfig.json +15 -15
- package/mock/helper.js +8 -8
- package/mock/index.js +34 -34
- package/package.json +99 -99
- package/public/3rd/ali-player/alipayercomponents-1.0.8.min.js +26 -26
- package/public/3rd/ali-player/aliplayer-hls-min.js +27 -27
- package/public/3rd/ali-player/aliplayer-min.js +1 -1
- package/public/3rd/im-web-push/index.umd.js +14 -14
- package/public/JsBridge.js +1602 -1602
- package/public/fish/editor/themes/default/css/ueditor.css +1905 -1905
- package/public/fish/editor/third-party/codemirror/codemirror.css +104 -104
- package/public/fish/editor/third-party/codemirror/codemirror.js +3581 -3581
- package/public/fish/editor/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
- package/public/fish/editor/ueditor.all.min.js +16 -16
- package/public/fish/editor/ueditor.config.js +467 -467
- package/public/fish/icon/umd-4.1.2.js +1 -1
- package/public/fish/video/videoplayer.min.css +6 -6
- package/public/fish/video/videoplayer.min.js +31 -31
- package/public/fish/video/zh-CN.js +82 -82
- package/public/icon/demo.css +539 -539
- package/public/icon/demo_index.html +2189 -2189
- package/public/icon/iconfont.css +363 -363
- package/public/icon/iconfont.json +618 -618
- package/public/index.html +50 -50
- package/script/image/readme.md +77 -77
- package/script/postcss.js +48 -48
- package/src/App.jsx +24 -24
- package/src/asset/img/course/playing.svg +21 -21
- package/src/asset/img/icon-course-white.svg +3 -3
- package/src/asset/img/icon-course.svg +3 -3
- package/src/asset/img/icon-eye-white.svg +4 -4
- package/src/asset/img/icon-eye.svg +4 -4
- package/src/asset/img/icon-school-white.svg +3 -3
- package/src/asset/img/icon-school.svg +3 -3
- package/src/asset/img/loading.svg +52 -52
- package/src/asset/img/video-play.svg +6 -6
- package/src/asset/style/background.less +19 -19
- package/src/asset/style/banner.less +36 -36
- package/src/asset/style/base.less +74 -74
- package/src/asset/style/index.less +114 -114
- package/src/asset/style/reset-theme.less +141 -141
- package/src/asset/style/theme/index.less +55 -55
- package/src/asset/style/theme/party/global.less +20 -20
- package/src/asset/style/theme/party/override.less +57 -57
- package/src/asset/style/theme/test/global.less +18 -18
- package/src/asset/style/theme/test/override.less +45 -45
- package/src/asset/style/variable.less +12 -12
- package/src/component/AliPlayer/index.jsx +49 -49
- package/src/component/Avatar/index.jsx +50 -50
- package/src/component/Empty/index.jsx +34 -34
- package/src/component/Empty/index.module.less +37 -37
- package/src/component/IMChatroom/component/status/403.jsx +13 -13
- package/src/component/IMChatroom/component/status/404.jsx +13 -13
- package/src/component/IMChatroom/component/status/Error.jsx +23 -23
- package/src/component/IMChatroom/component/status/Loading.jsx +5 -5
- package/src/component/IMChatroom/config/app/config.js +118 -118
- package/src/component/IMChatroom/config/app/index.js +60 -60
- package/src/component/IMChatroom/config/env.js +5 -5
- package/src/component/IMChatroom/config/index.js +3 -3
- package/src/component/IMChatroom/config/request/config/base.js +124 -124
- package/src/component/IMChatroom/config/request/config/chatroom.js +26 -26
- package/src/component/IMChatroom/config/request/config/imCoreApi.js +21 -21
- package/src/component/IMChatroom/config/request/index.js +21 -21
- package/src/component/IMChatroom/config/request/proxy.js +39 -39
- package/src/component/IMChatroom/config/url.js +7 -7
- package/src/component/IMChatroom/constants/errorCode.js +9 -9
- package/src/component/IMChatroom/constants/index.js +84 -84
- package/src/component/IMChatroom/constants/origin.js +27 -27
- package/src/component/IMChatroom/context/chatroom.js +154 -154
- package/src/component/IMChatroom/context/connect.js +28 -28
- package/src/component/IMChatroom/i18n/en/index.json +73 -73
- package/src/component/IMChatroom/i18n/index.jsx +14 -14
- package/src/component/IMChatroom/i18n/language.js +9 -9
- package/src/component/IMChatroom/i18n/zh-CN/index.json +73 -73
- package/src/component/IMChatroom/index.jsx +49 -49
- package/src/component/IMChatroom/page/chat/index.jsx +27 -27
- package/src/component/IMChatroom/page/chat/messageEditor/index.jsx +375 -375
- package/src/component/IMChatroom/page/chat/messageList/index.jsx +354 -354
- package/src/component/IMChatroom/page/chat/stickedMessage/index.jsx +59 -59
- package/src/component/IMChatroom/page/chat/stickedMessage/style/index.module.less +7 -7
- package/src/component/IMChatroom/page/chat/style/index.module.less +51 -51
- package/src/component/IMChatroom/page/home/connect/index.jsx +188 -188
- package/src/component/IMChatroom/page/home/connect/status.jsx +124 -124
- package/src/component/IMChatroom/page/home/context/cmd.jsx +37 -37
- package/src/component/IMChatroom/page/home/context/index.jsx +67 -67
- package/src/component/IMChatroom/page/home/index.jsx +164 -164
- package/src/component/IMChatroom/page/home/notice/index.jsx +123 -123
- package/src/component/IMChatroom/page/home/notice/style/index.module.less +49 -49
- package/src/component/IMChatroom/page/home/style/index.module.less +110 -110
- package/src/component/IMChatroom/page/member/index.jsx +15 -15
- package/src/component/IMChatroom/page/member/memberCount/index.jsx +44 -44
- package/src/component/IMChatroom/page/member/memberList/index.jsx +121 -121
- package/src/component/IMChatroom/page/member/style/index.module.less +2 -2
- package/src/component/IMChatroom/sdk/bridge.js +39 -39
- package/src/component/IMChatroom/sdk/cs/constants.js +20 -20
- package/src/component/IMChatroom/sdk/cs/index.js +101 -101
- package/src/component/IMChatroom/sdk/imChatroom.js +15 -15
- package/src/component/IMChatroom/sdk/imcore/constants.js +128 -128
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomDestroyed.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomInfoGetFail.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomKickedByAdmin.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomKickedBySelf.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomLoginFail.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomLoginSuccess.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomMemberLogin.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/chatroomMemberLogout.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/connectionConnected.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/connectionConnecting.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/connectionDisconnect.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/emitters/index.js +57 -57
- package/src/component/IMChatroom/sdk/imcore/emitters/messageReceive.js +36 -36
- package/src/component/IMChatroom/sdk/imcore/index.js +178 -178
- package/src/component/IMChatroom/sdk/imcore/interceptors/request.js +7 -7
- package/src/component/IMChatroom/sdk/imcore/interceptors/response.js +5 -5
- package/src/component/IMChatroom/sdk/imcore/plugins/getAuth.js +64 -64
- package/src/component/IMChatroom/sdk/imcore/plugins/getConversationId.js +20 -20
- package/src/component/IMChatroom/sdk/imcore/plugins/getExtInfo.js +10 -10
- package/src/component/IMChatroom/sdk/imcore/plugins/getLoginInfo.js +48 -48
- package/src/component/IMChatroom/sdk/imcore/plugins/getPlatformType.js +12 -12
- package/src/component/IMChatroom/sdk/imcore/plugins/index.js +22 -22
- package/src/component/IMChatroom/sdk/imcore/util/format.js +177 -177
- package/src/component/IMChatroom/sdk/imcore/util/parser.js +35 -35
- package/src/component/IMChatroom/sdk/oms.js +18 -18
- package/src/component/IMChatroom/sdk/uc.js +3 -3
- package/src/component/IMChatroom/subscription/channel/app.js +5 -5
- package/src/component/IMChatroom/subscription/channel/ctl.js +22 -22
- package/src/component/IMChatroom/subscription/channel/member.js +40 -40
- package/src/component/IMChatroom/subscription/channel/message.js +13 -13
- package/src/component/IMChatroom/subscription/channel/ntf.js +86 -86
- package/src/component/IMChatroom/subscription/channel/tel.js +5 -5
- package/src/component/IMChatroom/subscription/channel/websocket.js +5 -5
- package/src/component/IMChatroom/subscription/event.js +37 -37
- package/src/component/IMChatroom/subscription/index.js +19 -19
- package/src/component/IMChatroom/util/account.js +8 -8
- package/src/component/IMChatroom/util/chatroom.js +255 -255
- package/src/component/IMChatroom/util/jsonBigInt.js +5 -5
- package/src/component/IMChatroom/util/location.js +12 -12
- package/src/component/Icon/index.jsx +16 -16
- package/src/component/Icon/index.module.less +2 -2
- package/src/component/Pagination/LocalPagination.jsx +27 -27
- package/src/component/Pagination/RemotePagination.jsx +32 -32
- package/src/component/Pagination/index.jsx +32 -31
- package/src/component/Pagination/index.module.less +117 -110
- package/src/component/PlayerTip/index.jsx +34 -34
- package/src/component/VideoBase/index.jsx +242 -242
- package/src/component/VideoBase/style.less +65 -65
- package/src/component/VideoBase/utils.js +81 -81
- package/src/component/mixin.less +9 -9
- package/src/component/status/403.jsx +15 -15
- package/src/component/status/404/index.jsx +73 -73
- package/src/component/status/404/index.module.less +36 -36
- package/src/component/status/Error/error.module.less +13 -13
- package/src/component/status/Error/index.jsx +47 -47
- package/src/component/status/Loading/img/loading.svg +52 -52
- package/src/component/status/Loading/index.jsx +31 -31
- package/src/component/status/Loading/index.less +56 -56
- package/src/component/status/None/index.jsx +20 -20
- package/src/component/status/None/index.module.less +35 -35
- package/src/component/status/Status/index.jsx +26 -26
- package/src/component/status/Status/index.module.less +8 -8
- package/src/config/constant/commonUrl.js +2 -2
- package/src/config/constant/user.js +6 -6
- package/src/config/context/site-config.js +48 -48
- package/src/config/env/index.js +5 -5
- package/src/config/env/local/index.js +13 -13
- package/src/config/env/ncet-xedu/api.js +175 -175
- package/src/config/env/ncet-xedu/app.js +12 -12
- package/src/config/env/ncet-xedu/cs.js +8 -8
- package/src/config/env/ncet-xedu/index.js +14 -14
- package/src/config/env/ncet-xedu/push.js +5 -5
- package/src/config/env/preproduction/api.js +144 -144
- package/src/config/env/preproduction/app.js +12 -12
- package/src/config/env/preproduction/cs.js +8 -8
- package/src/config/env/preproduction/index.js +14 -14
- package/src/config/env/preproduction/push.js +5 -5
- package/src/config/env/product/api.js +113 -113
- package/src/config/env/product/app.js +12 -12
- package/src/config/env/product/cs.js +5 -5
- package/src/config/env/product/index.js +14 -14
- package/src/config/env/product/push.js +5 -5
- package/src/config/live.js +80 -80
- package/src/config/publicLive.js +53 -53
- package/src/config/request/assessments.js +24 -24
- package/src/config/request/config-center.js +8 -8
- package/src/config/request/helper.js +166 -166
- package/src/config/request/im-broadcasts.js +12 -12
- package/src/config/request/live-activity-gateway.js +8 -8
- package/src/config/request/live-activity.js +13 -13
- package/src/config/request/raw.js +6 -6
- package/src/config/request/x-cloud-web.js +13 -13
- package/src/config/request/x-proxy.js +34 -34
- package/src/demo/Detail.jsx +11 -11
- package/src/demo/List.jsx +66 -64
- package/src/demo/index.jsx +17 -17
- package/src/detail/LineSwitch/index.jsx +71 -71
- package/src/detail/LiveCountDown/index.jsx +44 -44
- package/src/detail/LiveCountDown/index.module.less +31 -31
- package/src/detail/LiveOnlineCount/img/icon.svg +15 -15
- package/src/detail/LiveOnlineCount/index.jsx +68 -68
- package/src/detail/LiveOnlineCount/index.module.less +34 -34
- package/src/detail/LiveOnlineCount/util.js +74 -74
- package/src/detail/LiveStatus/AnchorOnTheWay.jsx +88 -88
- package/src/detail/LiveStatus/index.jsx +202 -202
- package/src/detail/LiveStatus/index.module.less +192 -192
- package/src/detail/LiveVideo/config.js +37 -37
- package/src/detail/LiveVideo/index.jsx +188 -188
- package/src/detail/LiveVideo/index.module.less +41 -41
- package/src/detail/NotLoginChatroom/index.jsx +37 -37
- package/src/detail/NotLoginChatroom/index.module.less +46 -46
- package/src/detail/RecordVideo/index.jsx +150 -150
- package/src/detail/RecordVideo/index.module.less +31 -31
- package/src/detail/ReplayVideo/index.jsx +93 -93
- package/src/detail/ReplayVideo/index.module.less +65 -65
- package/src/detail/const.js +20 -20
- package/src/detail/hook/usePullSource.js +82 -82
- package/src/detail/hook/usePullState.js +51 -51
- package/src/detail/index.jsx +482 -482
- package/src/detail/index.module.less +188 -188
- package/src/hook/useAsync.js +84 -84
- package/src/hook/useGoToPage.js +83 -83
- package/src/hook/useInterval.js +28 -28
- package/src/hook/useIsMounted.js +17 -17
- package/src/hook/useModuleByRole.js +53 -53
- package/src/hook/usePageScrollable.js +52 -52
- package/src/hook/usePortal.js +83 -83
- package/src/hook/useScrollRestore/index.js +32 -32
- package/src/hook/useScrollRestore/scrollContext.js +20 -20
- package/src/hook/useTrackRef.js +11 -11
- package/src/hook/useWindowSize.js +28 -28
- package/src/hook/useZoom.js +47 -47
- package/src/index.js +10 -10
- package/src/lib/getLiveOnlineCount.js +10 -10
- package/src/lib/getServiceConfig.js +102 -102
- package/src/list/Empty/index.jsx +20 -20
- package/src/list/Empty/index.module.less +23 -23
- package/src/list/ListItem/Action/index.jsx +100 -98
- package/src/list/ListItem/Action/index.module.less +19 -21
- package/src/list/ListItem/img/play.svg +15 -15
- package/src/list/ListItem/img/video.svg +3 -0
- package/src/list/ListItem/index.jsx +46 -28
- package/src/list/ListItem/index.module.less +152 -146
- package/src/list/index.module.less +35 -35
- package/src/service/common.js +73 -73
- package/src/service/content-mgr.js +73 -73
- package/src/service/im-group.js +12 -12
- package/src/service/im.js +7 -7
- package/src/service/imBroadcasts.js +33 -33
- package/src/service/like.js +134 -134
- package/src/service/manageApi.js +7 -7
- package/src/service/managePortal.js +6 -6
- package/src/service/myStudyRecord.js +93 -93
- package/src/service/navigation.js +47 -47
- package/src/service/ndMeeting.js +10 -10
- package/src/service/ndr.js +122 -122
- package/src/service/news.js +93 -93
- package/src/service/personalCenter.js +270 -270
- package/src/service/qualityCourse.js +31 -31
- package/src/service/recommend.js +81 -81
- package/src/service/school.js +323 -323
- package/src/service/search.js +170 -170
- package/src/service/site-config.js +7 -7
- package/src/service/socialCensor.js +45 -45
- package/src/service/specialEdu.js +31 -31
- package/src/service/suggestion.js +85 -85
- package/src/service/syncClassroom.js +321 -321
- package/src/service/tCourse.js +204 -204
- package/src/service/tchTraining.js +37 -37
- package/src/service/uc.js +45 -45
- package/src/util/app.js +1 -1
- package/src/util/array.js +3 -3
- package/src/util/auth/func.js +57 -57
- package/src/util/date.js +53 -53
- package/src/util/env.js +9 -9
- package/src/util/getTimestamp.js +10 -10
- package/src/util/hof.js +105 -105
- package/src/util/live/index.js +42 -42
- package/src/util/netUrl.js +35 -35
- package/src/util/object.js +13 -13
- package/src/util/push/index.js +58 -58
- package/src/util/request.js +227 -227
- package/src/util/type.js +17 -17
- package/src/util/url.js +203 -203
- package/src/util/video.js +26 -26
- package/test/setup.js +21 -21
- package/test/unit/component/header/logo.spec.jsx +8 -8
- package/test/unit/helper.jsx +25 -25
- package/test/unit/util/date.spec.js +40 -40
- package/dist/XEduLivePlayer.common.js +0 -72605
- package/dist/XEduLivePlayerPre.common.js +0 -72625
package/public/JsBridge.js
CHANGED
|
@@ -1,1602 +1,1602 @@
|
|
|
1
|
-
! function (a) {
|
|
2
|
-
"use strict";
|
|
3
|
-
if ("function" == typeof bootstrap) bootstrap("promise", a);
|
|
4
|
-
else if ("object" == typeof exports && "object" == typeof module) module.exports = a();
|
|
5
|
-
else if ("function" == typeof define && define.amd) define(a);
|
|
6
|
-
else if ("undefined" != typeof ses) {
|
|
7
|
-
if (!ses.ok()) return;
|
|
8
|
-
ses.makeQ = a
|
|
9
|
-
} else {
|
|
10
|
-
if ("undefined" == typeof window && "undefined" == typeof self) throw new Error("This environment was not anticipated by Q. Please file a bug.");
|
|
11
|
-
var b = "undefined" != typeof window ? window : self,
|
|
12
|
-
c = b.Q;
|
|
13
|
-
b.Q = a(), b.Q.noConflict = function () {
|
|
14
|
-
return b.Q = c, this
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}(function () {
|
|
18
|
-
"use strict";
|
|
19
|
-
|
|
20
|
-
function a(a) {
|
|
21
|
-
return function () {
|
|
22
|
-
return W.apply(a, arguments)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function b(a) {
|
|
27
|
-
return a === Object(a)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function c(a) {
|
|
31
|
-
return "[object StopIteration]" === ca(a) || a instanceof S
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function d(a, b) {
|
|
35
|
-
if (P && b.stack && "object" == typeof a && null !== a && a.stack && -1 === a.stack.indexOf(da)) {
|
|
36
|
-
for (var c = [], d = b; d; d = d.source) d.stack && c.unshift(d.stack);
|
|
37
|
-
c.unshift(a.stack);
|
|
38
|
-
var f = c.join("\n" + da + "\n");
|
|
39
|
-
a.stack = e(f)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function e(a) {
|
|
44
|
-
for (var b = a.split("\n"), c = [], d = 0; d < b.length; ++d) {
|
|
45
|
-
var e = b[d];
|
|
46
|
-
h(e) || f(e) || !e || c.push(e)
|
|
47
|
-
}
|
|
48
|
-
return c.join("\n")
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function f(a) {
|
|
52
|
-
return -1 !== a.indexOf("(module.js:") || -1 !== a.indexOf("(node.js:")
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function g(a) {
|
|
56
|
-
var b = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);
|
|
57
|
-
if (b) return [b[1], Number(b[2])];
|
|
58
|
-
var c = /at ([^ ]+):(\d+):(?:\d+)$/.exec(a);
|
|
59
|
-
if (c) return [c[1], Number(c[2])];
|
|
60
|
-
var d = /.*@(.+):(\d+)$/.exec(a);
|
|
61
|
-
return d ? [d[1], Number(d[2])] : void 0
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function h(a) {
|
|
65
|
-
var b = g(a);
|
|
66
|
-
if (!b) return !1;
|
|
67
|
-
var c = b[0],
|
|
68
|
-
d = b[1];
|
|
69
|
-
return c === R && d >= T && ia >= d
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function i() {
|
|
73
|
-
if (P) try {
|
|
74
|
-
throw new Error
|
|
75
|
-
} catch (a) {
|
|
76
|
-
var b = a.stack.split("\n"),
|
|
77
|
-
c = b[0].indexOf("@") > 0 ? b[1] : b[2],
|
|
78
|
-
d = g(c);
|
|
79
|
-
if (!d) return;
|
|
80
|
-
return R = d[0], d[1]
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function j(a, b, c) {
|
|
85
|
-
return function () {
|
|
86
|
-
return "undefined" != typeof console && "function" == typeof console.warn && console.warn(b + " is deprecated, use " + c + " instead.", new Error("").stack), a.apply(a, arguments)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function k(a) {
|
|
91
|
-
return a instanceof o ? a : s(a) ? B(a) : A(a)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function l() {
|
|
95
|
-
function a(a) {
|
|
96
|
-
b = a, f.source = a, Y(c, function (b, c) {
|
|
97
|
-
k.nextTick(function () {
|
|
98
|
-
a.promiseDispatch.apply(a, c)
|
|
99
|
-
})
|
|
100
|
-
}, void 0), c = void 0, d = void 0
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
var b, c = [],
|
|
104
|
-
d = [],
|
|
105
|
-
e = _(l.prototype),
|
|
106
|
-
f = _(o.prototype);
|
|
107
|
-
if (f.promiseDispatch = function (a, e, f) {
|
|
108
|
-
var g = X(arguments);
|
|
109
|
-
c ? (c.push(g), "when" === e && f[1] && d.push(f[1])) : k.nextTick(function () {
|
|
110
|
-
b.promiseDispatch.apply(b, g)
|
|
111
|
-
})
|
|
112
|
-
}, f.valueOf = function () {
|
|
113
|
-
if (c) return f;
|
|
114
|
-
var a = q(b);
|
|
115
|
-
return r(a) && (b = a), a
|
|
116
|
-
}, f.inspect = function () {
|
|
117
|
-
return b ? b.inspect() : {
|
|
118
|
-
state: "pending"
|
|
119
|
-
}
|
|
120
|
-
}, k.longStackSupport && P) try {
|
|
121
|
-
throw new Error
|
|
122
|
-
} catch (g) {
|
|
123
|
-
f.stack = g.stack.substring(g.stack.indexOf("\n") + 1)
|
|
124
|
-
}
|
|
125
|
-
return e.promise = f, e.resolve = function (c) {
|
|
126
|
-
b || a(k(c))
|
|
127
|
-
}, e.fulfill = function (c) {
|
|
128
|
-
b || a(A(c))
|
|
129
|
-
}, e.reject = function (c) {
|
|
130
|
-
b || a(z(c))
|
|
131
|
-
}, e.notify = function (a) {
|
|
132
|
-
b || Y(d, function (b, c) {
|
|
133
|
-
k.nextTick(function () {
|
|
134
|
-
c(a)
|
|
135
|
-
})
|
|
136
|
-
}, void 0)
|
|
137
|
-
}, e
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function m(a) {
|
|
141
|
-
if ("function" != typeof a) throw new TypeError("resolver must be a function.");
|
|
142
|
-
var b = l();
|
|
143
|
-
try {
|
|
144
|
-
a(b.resolve, b.reject, b.notify)
|
|
145
|
-
} catch (c) {
|
|
146
|
-
b.reject(c)
|
|
147
|
-
}
|
|
148
|
-
return b.promise
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function n(a) {
|
|
152
|
-
return m(function (b, c) {
|
|
153
|
-
for (var d = 0, e = a.length; e > d; d++) k(a[d]).then(b, c)
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function o(a, b, c) {
|
|
158
|
-
void 0 === b && (b = function (a) {
|
|
159
|
-
return z(new Error("Promise does not support operation: " + a))
|
|
160
|
-
}), void 0 === c && (c = function () {
|
|
161
|
-
return {
|
|
162
|
-
state: "unknown"
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
var d = _(o.prototype);
|
|
166
|
-
if (d.promiseDispatch = function (c, e, f) {
|
|
167
|
-
var g;
|
|
168
|
-
try {
|
|
169
|
-
g = a[e] ? a[e].apply(d, f) : b.call(d, e, f)
|
|
170
|
-
} catch (h) {
|
|
171
|
-
g = z(h)
|
|
172
|
-
}
|
|
173
|
-
c && c(g)
|
|
174
|
-
}, d.inspect = c, c) {
|
|
175
|
-
var e = c();
|
|
176
|
-
"rejected" === e.state && (d.exception = e.reason), d.valueOf = function () {
|
|
177
|
-
var a = c();
|
|
178
|
-
return "pending" === a.state || "rejected" === a.state ? d : a.value
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return d
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function p(a, b, c, d) {
|
|
185
|
-
return k(a).then(b, c, d)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function q(a) {
|
|
189
|
-
if (r(a)) {
|
|
190
|
-
var b = a.inspect();
|
|
191
|
-
if ("fulfilled" === b.state) return b.value
|
|
192
|
-
}
|
|
193
|
-
return a
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function r(a) {
|
|
197
|
-
return a instanceof o
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function s(a) {
|
|
201
|
-
return b(a) && "function" == typeof a.then
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function t(a) {
|
|
205
|
-
return r(a) && "pending" === a.inspect().state
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function u(a) {
|
|
209
|
-
return !r(a) || "fulfilled" === a.inspect().state
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function v(a) {
|
|
213
|
-
return r(a) && "rejected" === a.inspect().state
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function w() {
|
|
217
|
-
ea.length = 0, fa.length = 0, ha || (ha = !0)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function x(a, b) {
|
|
221
|
-
ha && ("object" == typeof process && "function" == typeof process.emit && k.nextTick.runAfter(function () {
|
|
222
|
-
-1 !== Z(fa, a) && (process.emit("unhandledRejection", b, a), ga.push(a))
|
|
223
|
-
}), fa.push(a), b && "undefined" != typeof b.stack ? ea.push(b.stack) : ea.push("(no stack) " + b))
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function y(a) {
|
|
227
|
-
if (ha) {
|
|
228
|
-
var b = Z(fa, a); -
|
|
229
|
-
1 !== b && ("object" == typeof process && "function" == typeof process.emit && k.nextTick.runAfter(function () {
|
|
230
|
-
var c = Z(ga, a); -
|
|
231
|
-
1 !== c && (process.emit("rejectionHandled", ea[b], a), ga.splice(c, 1))
|
|
232
|
-
}), fa.splice(b, 1), ea.splice(b, 1))
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function z(a) {
|
|
237
|
-
var b = o({
|
|
238
|
-
when: function (b) {
|
|
239
|
-
return b && y(this), b ? b(a) : this
|
|
240
|
-
}
|
|
241
|
-
}, function () {
|
|
242
|
-
return this
|
|
243
|
-
}, function () {
|
|
244
|
-
return {
|
|
245
|
-
state: "rejected",
|
|
246
|
-
reason: a
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
return x(b, a), b
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function A(a) {
|
|
253
|
-
return o({
|
|
254
|
-
when: function () {
|
|
255
|
-
return a
|
|
256
|
-
},
|
|
257
|
-
get: function (b) {
|
|
258
|
-
return a[b]
|
|
259
|
-
},
|
|
260
|
-
set: function (b, c) {
|
|
261
|
-
a[b] = c
|
|
262
|
-
},
|
|
263
|
-
"delete": function (b) {
|
|
264
|
-
delete a[b]
|
|
265
|
-
},
|
|
266
|
-
post: function (b, c) {
|
|
267
|
-
return null === b || void 0 === b ? a.apply(void 0, c) : a[b].apply(a, c)
|
|
268
|
-
},
|
|
269
|
-
apply: function (b, c) {
|
|
270
|
-
return a.apply(b, c)
|
|
271
|
-
},
|
|
272
|
-
keys: function () {
|
|
273
|
-
return ba(a)
|
|
274
|
-
}
|
|
275
|
-
}, void 0, function () {
|
|
276
|
-
return {
|
|
277
|
-
state: "fulfilled",
|
|
278
|
-
value: a
|
|
279
|
-
}
|
|
280
|
-
})
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function B(a) {
|
|
284
|
-
var b = l();
|
|
285
|
-
return k.nextTick(function () {
|
|
286
|
-
try {
|
|
287
|
-
a.then(b.resolve, b.reject, b.notify)
|
|
288
|
-
} catch (c) {
|
|
289
|
-
b.reject(c)
|
|
290
|
-
}
|
|
291
|
-
}), b.promise
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function C(a) {
|
|
295
|
-
return o({
|
|
296
|
-
isDef: function () {}
|
|
297
|
-
}, function (b, c) {
|
|
298
|
-
return I(a, b, c)
|
|
299
|
-
}, function () {
|
|
300
|
-
return k(a).inspect()
|
|
301
|
-
})
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function D(a, b, c) {
|
|
305
|
-
return k(a).spread(b, c)
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function E(a) {
|
|
309
|
-
return function () {
|
|
310
|
-
function b(a, b) {
|
|
311
|
-
var g;
|
|
312
|
-
if ("undefined" == typeof StopIteration) {
|
|
313
|
-
try {
|
|
314
|
-
g = d[a](b)
|
|
315
|
-
} catch (h) {
|
|
316
|
-
return z(h)
|
|
317
|
-
}
|
|
318
|
-
return g.done ? k(g.value) : p(g.value, e, f)
|
|
319
|
-
}
|
|
320
|
-
try {
|
|
321
|
-
g = d[a](b)
|
|
322
|
-
} catch (h) {
|
|
323
|
-
return c(h) ? k(h.value) : z(h)
|
|
324
|
-
}
|
|
325
|
-
return p(g, e, f)
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
var d = a.apply(this, arguments),
|
|
329
|
-
e = b.bind(b, "next"),
|
|
330
|
-
f = b.bind(b, "throw");
|
|
331
|
-
return e()
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function F(a) {
|
|
336
|
-
k.done(k.async(a)())
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function G(a) {
|
|
340
|
-
throw new S(a)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function H(a) {
|
|
344
|
-
return function () {
|
|
345
|
-
return D([this, J(arguments)], function (b, c) {
|
|
346
|
-
return a.apply(b, c)
|
|
347
|
-
})
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function I(a, b, c) {
|
|
352
|
-
return k(a).dispatch(b, c)
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
function J(a) {
|
|
356
|
-
return p(a, function (a) {
|
|
357
|
-
var b = 0,
|
|
358
|
-
c = l();
|
|
359
|
-
return Y(a, function (d, e, f) {
|
|
360
|
-
var g;
|
|
361
|
-
r(e) && "fulfilled" === (g = e.inspect()).state ? a[f] = g.value : (++b, p(e, function (d) {
|
|
362
|
-
a[f] = d, 0 === --b && c.resolve(a)
|
|
363
|
-
}, c.reject, function (a) {
|
|
364
|
-
c.notify({
|
|
365
|
-
index: f,
|
|
366
|
-
value: a
|
|
367
|
-
})
|
|
368
|
-
}))
|
|
369
|
-
}, void 0), 0 === b && c.resolve(a), c.promise
|
|
370
|
-
})
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function K(a) {
|
|
374
|
-
if (0 === a.length) return k.resolve();
|
|
375
|
-
var b = k.defer(),
|
|
376
|
-
c = 0;
|
|
377
|
-
return Y(a, function (d, e, f) {
|
|
378
|
-
function g(a) {
|
|
379
|
-
b.resolve(a)
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function h(a) {
|
|
383
|
-
c--, 0 === c && (a.message = "Q can't get fulfillment value from any promise, all promises were rejected. Last error message: " + a.message, b.reject(a))
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function i(a) {
|
|
387
|
-
b.notify({
|
|
388
|
-
index: f,
|
|
389
|
-
value: a
|
|
390
|
-
})
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var j = a[f];
|
|
394
|
-
c++, p(j, g, h, i)
|
|
395
|
-
}, void 0), b.promise
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
function L(a) {
|
|
399
|
-
return p(a, function (a) {
|
|
400
|
-
return a = $(a, k), p(J($(a, function (a) {
|
|
401
|
-
return p(a, U, U)
|
|
402
|
-
})), function () {
|
|
403
|
-
return a
|
|
404
|
-
})
|
|
405
|
-
})
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function M(a) {
|
|
409
|
-
return k(a).allSettled()
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
function N(a, b) {
|
|
413
|
-
return k(a).then(void 0, void 0, b)
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function O(a, b) {
|
|
417
|
-
return k(a).nodeify(b)
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
var P = !1;
|
|
421
|
-
try {
|
|
422
|
-
throw new Error
|
|
423
|
-
} catch (Q) {
|
|
424
|
-
P = !!Q.stack
|
|
425
|
-
}
|
|
426
|
-
var R, S, T = i(),
|
|
427
|
-
U = function () {},
|
|
428
|
-
V = function () {
|
|
429
|
-
function a() {
|
|
430
|
-
for (var a, d; c.next;) c = c.next, a = c.task, c.task = void 0, d = c.domain, d && (c.domain = void 0, d.enter()), b(a, d);
|
|
431
|
-
for (; h.length;) a = h.pop(), b(a);
|
|
432
|
-
e = !1
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function b(b, c) {
|
|
436
|
-
try {
|
|
437
|
-
b()
|
|
438
|
-
} catch (d) {
|
|
439
|
-
if (g) throw c && c.exit(), setTimeout(a, 0), c && c.enter(), d;
|
|
440
|
-
setTimeout(function () {
|
|
441
|
-
throw d
|
|
442
|
-
}, 0)
|
|
443
|
-
}
|
|
444
|
-
c && c.exit()
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
var c = {
|
|
448
|
-
task: void 0,
|
|
449
|
-
next: null
|
|
450
|
-
},
|
|
451
|
-
d = c,
|
|
452
|
-
e = !1,
|
|
453
|
-
f = void 0,
|
|
454
|
-
g = !1,
|
|
455
|
-
h = [];
|
|
456
|
-
if (V = function (a) {
|
|
457
|
-
d = d.next = {
|
|
458
|
-
task: a,
|
|
459
|
-
domain: g && process.domain,
|
|
460
|
-
next: null
|
|
461
|
-
}, e || (e = !0, f())
|
|
462
|
-
}, "object" == typeof process && "[object process]" === process.toString() && process.nextTick) g = !0, f = function () {
|
|
463
|
-
process.nextTick(a)
|
|
464
|
-
};
|
|
465
|
-
else if ("function" == typeof setImmediate) f = "undefined" != typeof window ? setImmediate.bind(window, a) : function () {
|
|
466
|
-
setImmediate(a)
|
|
467
|
-
};
|
|
468
|
-
else if ("undefined" != typeof MessageChannel) {
|
|
469
|
-
var i = new MessageChannel;
|
|
470
|
-
i.port1.onmessage = function () {
|
|
471
|
-
f = j, i.port1.onmessage = a, a()
|
|
472
|
-
};
|
|
473
|
-
var j = function () {
|
|
474
|
-
i.port2.postMessage(0)
|
|
475
|
-
};
|
|
476
|
-
f = function () {
|
|
477
|
-
setTimeout(a, 0), j()
|
|
478
|
-
}
|
|
479
|
-
} else f = function () {
|
|
480
|
-
setTimeout(a, 0)
|
|
481
|
-
};
|
|
482
|
-
return V.runAfter = function (a) {
|
|
483
|
-
h.push(a), e || (e = !0, f())
|
|
484
|
-
}, V
|
|
485
|
-
}(),
|
|
486
|
-
W = Function.call,
|
|
487
|
-
X = a(Array.prototype.slice),
|
|
488
|
-
Y = a(Array.prototype.reduce || function (a, b) {
|
|
489
|
-
var c = 0,
|
|
490
|
-
d = this.length;
|
|
491
|
-
if (1 === arguments.length)
|
|
492
|
-
for (;;) {
|
|
493
|
-
if (c in this) {
|
|
494
|
-
b = this[c++];
|
|
495
|
-
break
|
|
496
|
-
}
|
|
497
|
-
if (++c >= d) throw new TypeError
|
|
498
|
-
}
|
|
499
|
-
for (; d > c; c++) c in this && (b = a(b, this[c], c));
|
|
500
|
-
return b
|
|
501
|
-
}),
|
|
502
|
-
Z = a(Array.prototype.indexOf || function (a) {
|
|
503
|
-
for (var b = 0; b < this.length; b++)
|
|
504
|
-
if (this[b] === a) return b;
|
|
505
|
-
return -1
|
|
506
|
-
}),
|
|
507
|
-
$ = a(Array.prototype.map || function (a, b) {
|
|
508
|
-
var c = this,
|
|
509
|
-
d = [];
|
|
510
|
-
return Y(c, function (e, f, g) {
|
|
511
|
-
d.push(a.call(b, f, g, c))
|
|
512
|
-
}, void 0), d
|
|
513
|
-
}),
|
|
514
|
-
_ = Object.create || function (a) {
|
|
515
|
-
function b() {}
|
|
516
|
-
|
|
517
|
-
return b.prototype = a, new b
|
|
518
|
-
},
|
|
519
|
-
aa = a(Object.prototype.hasOwnProperty),
|
|
520
|
-
ba = Object.keys || function (a) {
|
|
521
|
-
var b = [];
|
|
522
|
-
for (var c in a) aa(a, c) && b.push(c);
|
|
523
|
-
return b
|
|
524
|
-
},
|
|
525
|
-
ca = a(Object.prototype.toString);
|
|
526
|
-
S = "undefined" != typeof ReturnValue ? ReturnValue : function (a) {
|
|
527
|
-
this.value = a
|
|
528
|
-
};
|
|
529
|
-
var da = "From previous event:";
|
|
530
|
-
k.resolve = k, k.nextTick = V, k.longStackSupport = !1, "object" == typeof process && process && process.env && process.env.Q_DEBUG && (k.longStackSupport = !0), k.defer = l, l.prototype.makeNodeResolver = function () {
|
|
531
|
-
var a = this;
|
|
532
|
-
return function (b, c) {
|
|
533
|
-
b ? a.reject(b) : arguments.length > 2 ? a.resolve(X(arguments, 1)) : a.resolve(c)
|
|
534
|
-
}
|
|
535
|
-
}, k.Promise = m, k.promise = m, m.race = n, m.all = J, m.reject = z, m.resolve = k, k.passByCopy = function (a) {
|
|
536
|
-
return a
|
|
537
|
-
}, o.prototype.passByCopy = function () {
|
|
538
|
-
return this
|
|
539
|
-
}, k.join = function (a, b) {
|
|
540
|
-
return k(a).join(b)
|
|
541
|
-
}, o.prototype.join = function (a) {
|
|
542
|
-
return k([this, a]).spread(function (a, b) {
|
|
543
|
-
if (a === b) return a;
|
|
544
|
-
throw new Error("Q can't join: not the same: " + a + " " + b)
|
|
545
|
-
})
|
|
546
|
-
}, k.race = n, o.prototype.race = function () {
|
|
547
|
-
return this.then(k.race)
|
|
548
|
-
}, k.makePromise = o, o.prototype.toString = function () {
|
|
549
|
-
return "[object Promise]"
|
|
550
|
-
}, o.prototype.then = function (a, b, c) {
|
|
551
|
-
function e(b) {
|
|
552
|
-
try {
|
|
553
|
-
return "function" == typeof a ? a(b) : b
|
|
554
|
-
} catch (c) {
|
|
555
|
-
return z(c)
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function f(a) {
|
|
560
|
-
if ("function" == typeof b) {
|
|
561
|
-
d(a, h);
|
|
562
|
-
try {
|
|
563
|
-
return b(a)
|
|
564
|
-
} catch (c) {
|
|
565
|
-
return z(c)
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
return z(a)
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
function g(a) {
|
|
572
|
-
return "function" == typeof c ? c(a) : a
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
var h = this,
|
|
576
|
-
i = l(),
|
|
577
|
-
j = !1;
|
|
578
|
-
return k.nextTick(function () {
|
|
579
|
-
h.promiseDispatch(function (a) {
|
|
580
|
-
j || (j = !0, i.resolve(e(a)))
|
|
581
|
-
}, "when", [function (a) {
|
|
582
|
-
j || (j = !0, i.resolve(f(a)))
|
|
583
|
-
}])
|
|
584
|
-
}), h.promiseDispatch(void 0, "when", [void 0, function (a) {
|
|
585
|
-
var b, c = !1;
|
|
586
|
-
try {
|
|
587
|
-
b = g(a)
|
|
588
|
-
} catch (d) {
|
|
589
|
-
if (c = !0, !k.onerror) throw d;
|
|
590
|
-
k.onerror(d)
|
|
591
|
-
}
|
|
592
|
-
c || i.notify(b)
|
|
593
|
-
}]), i.promise
|
|
594
|
-
}, k.tap = function (a, b) {
|
|
595
|
-
return k(a).tap(b)
|
|
596
|
-
}, o.prototype.tap = function (a) {
|
|
597
|
-
return a = k(a), this.then(function (b) {
|
|
598
|
-
return a.fcall(b).thenResolve(b)
|
|
599
|
-
})
|
|
600
|
-
}, k.when = p, o.prototype.thenResolve = function (a) {
|
|
601
|
-
return this.then(function () {
|
|
602
|
-
return a
|
|
603
|
-
})
|
|
604
|
-
}, k.thenResolve = function (a, b) {
|
|
605
|
-
return k(a).thenResolve(b)
|
|
606
|
-
}, o.prototype.thenReject = function (a) {
|
|
607
|
-
return this.then(function () {
|
|
608
|
-
throw a
|
|
609
|
-
})
|
|
610
|
-
}, k.thenReject = function (a, b) {
|
|
611
|
-
return k(a).thenReject(b)
|
|
612
|
-
}, k.nearer = q, k.isPromise = r, k.isPromiseAlike = s, k.isPending = t, o.prototype.isPending = function () {
|
|
613
|
-
return "pending" === this.inspect().state
|
|
614
|
-
}, k.isFulfilled = u, o.prototype.isFulfilled = function () {
|
|
615
|
-
return "fulfilled" === this.inspect().state
|
|
616
|
-
}, k.isRejected = v, o.prototype.isRejected = function () {
|
|
617
|
-
return "rejected" === this.inspect().state
|
|
618
|
-
};
|
|
619
|
-
var ea = [],
|
|
620
|
-
fa = [],
|
|
621
|
-
ga = [],
|
|
622
|
-
ha = !0;
|
|
623
|
-
k.resetUnhandledRejections = w, k.getUnhandledReasons = function () {
|
|
624
|
-
return ea.slice()
|
|
625
|
-
}, k.stopUnhandledRejectionTracking = function () {
|
|
626
|
-
w(), ha = !1
|
|
627
|
-
}, w(), k.reject = z, k.fulfill = A, k.master = C, k.spread = D, o.prototype.spread = function (a, b) {
|
|
628
|
-
return this.all().then(function (b) {
|
|
629
|
-
return a.apply(void 0, b)
|
|
630
|
-
}, b)
|
|
631
|
-
}, k.async = E, k.spawn = F, k["return"] = G, k.promised = H, k.dispatch = I, o.prototype.dispatch = function (a, b) {
|
|
632
|
-
var c = this,
|
|
633
|
-
d = l();
|
|
634
|
-
return k.nextTick(function () {
|
|
635
|
-
c.promiseDispatch(d.resolve, a, b)
|
|
636
|
-
}), d.promise
|
|
637
|
-
}, k.get = function (a, b) {
|
|
638
|
-
return k(a).dispatch("get", [b])
|
|
639
|
-
}, o.prototype.get = function (a) {
|
|
640
|
-
return this.dispatch("get", [a])
|
|
641
|
-
}, k.set = function (a, b, c) {
|
|
642
|
-
return k(a).dispatch("set", [b, c])
|
|
643
|
-
}, o.prototype.set = function (a, b) {
|
|
644
|
-
return this.dispatch("set", [a, b])
|
|
645
|
-
}, k.del = k["delete"] = function (a, b) {
|
|
646
|
-
return k(a).dispatch("delete", [b])
|
|
647
|
-
}, o.prototype.del = o.prototype["delete"] = function (a) {
|
|
648
|
-
return this.dispatch("delete", [a])
|
|
649
|
-
}, k.mapply = k.post = function (a, b, c) {
|
|
650
|
-
return k(a).dispatch("post", [b, c])
|
|
651
|
-
}, o.prototype.mapply = o.prototype.post = function (a, b) {
|
|
652
|
-
return this.dispatch("post", [a, b])
|
|
653
|
-
}, k.send = k.mcall = k.invoke = function (a, b) {
|
|
654
|
-
return k(a).dispatch("post", [b, X(arguments, 2)])
|
|
655
|
-
}, o.prototype.send = o.prototype.mcall = o.prototype.invoke = function (a) {
|
|
656
|
-
return this.dispatch("post", [a, X(arguments, 1)])
|
|
657
|
-
}, k.fapply = function (a, b) {
|
|
658
|
-
return k(a).dispatch("apply", [void 0, b])
|
|
659
|
-
}, o.prototype.fapply = function (a) {
|
|
660
|
-
return this.dispatch("apply", [void 0, a])
|
|
661
|
-
}, k["try"] = k.fcall = function (a) {
|
|
662
|
-
return k(a).dispatch("apply", [void 0, X(arguments, 1)])
|
|
663
|
-
}, o.prototype.fcall = function () {
|
|
664
|
-
return this.dispatch("apply", [void 0, X(arguments)])
|
|
665
|
-
}, k.fbind = function (a) {
|
|
666
|
-
var b = k(a),
|
|
667
|
-
c = X(arguments, 1);
|
|
668
|
-
return function () {
|
|
669
|
-
return b.dispatch("apply", [this, c.concat(X(arguments))])
|
|
670
|
-
}
|
|
671
|
-
}, o.prototype.fbind = function () {
|
|
672
|
-
var a = this,
|
|
673
|
-
b = X(arguments);
|
|
674
|
-
return function () {
|
|
675
|
-
return a.dispatch("apply", [this, b.concat(X(arguments))])
|
|
676
|
-
}
|
|
677
|
-
}, k.keys = function (a) {
|
|
678
|
-
return k(a).dispatch("keys", [])
|
|
679
|
-
}, o.prototype.keys = function () {
|
|
680
|
-
return this.dispatch("keys", [])
|
|
681
|
-
}, k.all = J, o.prototype.all = function () {
|
|
682
|
-
return J(this)
|
|
683
|
-
}, k.any = K, o.prototype.any = function () {
|
|
684
|
-
return K(this)
|
|
685
|
-
}, k.allResolved = j(L, "allResolved", "allSettled"), o.prototype.allResolved = function () {
|
|
686
|
-
return L(this)
|
|
687
|
-
}, k.allSettled = M, o.prototype.allSettled = function () {
|
|
688
|
-
return this.then(function (a) {
|
|
689
|
-
return J($(a, function (a) {
|
|
690
|
-
function b() {
|
|
691
|
-
return a.inspect()
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
return a = k(a), a.then(b, b)
|
|
695
|
-
}))
|
|
696
|
-
})
|
|
697
|
-
}, k.fail = k["catch"] = function (a, b) {
|
|
698
|
-
return k(a).then(void 0, b)
|
|
699
|
-
}, o.prototype.fail = o.prototype["catch"] = function (a) {
|
|
700
|
-
return this.then(void 0, a)
|
|
701
|
-
}, k.progress = N, o.prototype.progress = function (a) {
|
|
702
|
-
return this.then(void 0, void 0, a)
|
|
703
|
-
}, k.fin = k["finally"] = function (a, b) {
|
|
704
|
-
return k(a)["finally"](b)
|
|
705
|
-
}, o.prototype.fin = o.prototype["finally"] = function (a) {
|
|
706
|
-
if (!a || "function" != typeof a.apply) throw new Error("Q can't apply finally callback");
|
|
707
|
-
return a = k(a), this.then(function (b) {
|
|
708
|
-
return a.fcall().then(function () {
|
|
709
|
-
return b
|
|
710
|
-
})
|
|
711
|
-
}, function (b) {
|
|
712
|
-
return a.fcall().then(function () {
|
|
713
|
-
throw b
|
|
714
|
-
})
|
|
715
|
-
})
|
|
716
|
-
}, k.done = function (a, b, c, d) {
|
|
717
|
-
return k(a).done(b, c, d)
|
|
718
|
-
}, o.prototype.done = function (a, b, c) {
|
|
719
|
-
var e = function (a) {
|
|
720
|
-
k.nextTick(function () {
|
|
721
|
-
if (d(a, f), !k.onerror) throw a;
|
|
722
|
-
k.onerror(a)
|
|
723
|
-
})
|
|
724
|
-
},
|
|
725
|
-
f = a || b || c ? this.then(a, b, c) : this;
|
|
726
|
-
"object" == typeof process && process && process.domain && (e = process.domain.bind(e)), f.then(void 0, e)
|
|
727
|
-
}, k.timeout = function (a, b, c) {
|
|
728
|
-
return k(a).timeout(b, c)
|
|
729
|
-
}, o.prototype.timeout = function (a, b) {
|
|
730
|
-
var c = l(),
|
|
731
|
-
d = setTimeout(function () {
|
|
732
|
-
b && "string" != typeof b || (b = new Error(b || "Timed out after " + a + " ms"), b.code = "ETIMEDOUT"), c.reject(b)
|
|
733
|
-
}, a);
|
|
734
|
-
return this.then(function (a) {
|
|
735
|
-
clearTimeout(d), c.resolve(a)
|
|
736
|
-
}, function (a) {
|
|
737
|
-
clearTimeout(d), c.reject(a)
|
|
738
|
-
}, c.notify), c.promise
|
|
739
|
-
}, k.delay = function (a, b) {
|
|
740
|
-
return void 0 === b && (b = a, a = void 0), k(a).delay(b)
|
|
741
|
-
}, o.prototype.delay = function (a) {
|
|
742
|
-
return this.then(function (b) {
|
|
743
|
-
var c = l();
|
|
744
|
-
return setTimeout(function () {
|
|
745
|
-
c.resolve(b)
|
|
746
|
-
}, a), c.promise
|
|
747
|
-
})
|
|
748
|
-
}, k.nfapply = function (a, b) {
|
|
749
|
-
return k(a).nfapply(b)
|
|
750
|
-
}, o.prototype.nfapply = function (a) {
|
|
751
|
-
var b = l(),
|
|
752
|
-
c = X(a);
|
|
753
|
-
return c.push(b.makeNodeResolver()), this.fapply(c).fail(b.reject), b.promise
|
|
754
|
-
}, k.nfcall = function (a) {
|
|
755
|
-
var b = X(arguments, 1);
|
|
756
|
-
return k(a).nfapply(b)
|
|
757
|
-
}, o.prototype.nfcall = function () {
|
|
758
|
-
var a = X(arguments),
|
|
759
|
-
b = l();
|
|
760
|
-
return a.push(b.makeNodeResolver()), this.fapply(a).fail(b.reject), b.promise
|
|
761
|
-
}, k.nfbind = k.denodeify = function (a) {
|
|
762
|
-
if (void 0 === a) throw new Error("Q can't wrap an undefined function");
|
|
763
|
-
var b = X(arguments, 1);
|
|
764
|
-
return function () {
|
|
765
|
-
var c = b.concat(X(arguments)),
|
|
766
|
-
d = l();
|
|
767
|
-
return c.push(d.makeNodeResolver()), k(a).fapply(c).fail(d.reject), d.promise
|
|
768
|
-
}
|
|
769
|
-
}, o.prototype.nfbind = o.prototype.denodeify = function () {
|
|
770
|
-
var a = X(arguments);
|
|
771
|
-
return a.unshift(this), k.denodeify.apply(void 0, a)
|
|
772
|
-
}, k.nbind = function (a, b) {
|
|
773
|
-
var c = X(arguments, 2);
|
|
774
|
-
return function () {
|
|
775
|
-
function d() {
|
|
776
|
-
return a.apply(b, arguments)
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
var e = c.concat(X(arguments)),
|
|
780
|
-
f = l();
|
|
781
|
-
return e.push(f.makeNodeResolver()), k(d).fapply(e).fail(f.reject), f.promise
|
|
782
|
-
}
|
|
783
|
-
}, o.prototype.nbind = function () {
|
|
784
|
-
var a = X(arguments, 0);
|
|
785
|
-
return a.unshift(this), k.nbind.apply(void 0, a)
|
|
786
|
-
}, k.nmapply = k.npost = function (a, b, c) {
|
|
787
|
-
return k(a).npost(b, c)
|
|
788
|
-
}, o.prototype.nmapply = o.prototype.npost = function (a, b) {
|
|
789
|
-
var c = X(b || []),
|
|
790
|
-
d = l();
|
|
791
|
-
return c.push(d.makeNodeResolver()), this.dispatch("post", [a, c]).fail(d.reject), d.promise
|
|
792
|
-
}, k.nsend = k.nmcall = k.ninvoke = function (a, b) {
|
|
793
|
-
var c = X(arguments, 2),
|
|
794
|
-
d = l();
|
|
795
|
-
return c.push(d.makeNodeResolver()), k(a).dispatch("post", [b, c]).fail(d.reject), d.promise
|
|
796
|
-
}, o.prototype.nsend = o.prototype.nmcall = o.prototype.ninvoke = function (a) {
|
|
797
|
-
var b = X(arguments, 1),
|
|
798
|
-
c = l();
|
|
799
|
-
return b.push(c.makeNodeResolver()), this.dispatch("post", [a, b]).fail(c.reject), c.promise
|
|
800
|
-
}, k.nodeify = O, o.prototype.nodeify = function (a) {
|
|
801
|
-
return a ? void this.then(function (b) {
|
|
802
|
-
k.nextTick(function () {
|
|
803
|
-
a(null, b)
|
|
804
|
-
})
|
|
805
|
-
}, function (b) {
|
|
806
|
-
k.nextTick(function () {
|
|
807
|
-
a(b)
|
|
808
|
-
})
|
|
809
|
-
}) : this
|
|
810
|
-
}, k.noConflict = function () {
|
|
811
|
-
throw new Error("Q.noConflict only works when Q is used as a global")
|
|
812
|
-
};
|
|
813
|
-
var ia = i();
|
|
814
|
-
return k
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
function NativeInterface() {
|
|
818
|
-
if (typeof AndroidInterface != 'undefined') {
|
|
819
|
-
return AndroidInterface;
|
|
820
|
-
} else if (typeof iOSInterface != 'undefined') {
|
|
821
|
-
return iOSInterface;
|
|
822
|
-
} else if (typeof PCInterface != 'undefined') {
|
|
823
|
-
return PCInterface;
|
|
824
|
-
} else if (typeof iOSWKInterface != 'undefined') {
|
|
825
|
-
return iOSWKInterface;
|
|
826
|
-
} else {
|
|
827
|
-
console.log("Native interface not found!");
|
|
828
|
-
return null;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
function loadJsBridge () {
|
|
833
|
-
var helper = {
|
|
834
|
-
init: function() {
|
|
835
|
-
// 添加监听
|
|
836
|
-
if (this.inIframe()) {
|
|
837
|
-
var self = this;
|
|
838
|
-
window.addEventListener("message", function (event) {
|
|
839
|
-
self.dealWindowEventMessage(event.data);
|
|
840
|
-
}, false);
|
|
841
|
-
}
|
|
842
|
-
},
|
|
843
|
-
|
|
844
|
-
dealWindowEventMessage: function(eventData) {
|
|
845
|
-
if (eventData.type === this.TYPE_EVENT_CALLBACK) {
|
|
846
|
-
// 处理事件回调
|
|
847
|
-
this.dealNativeEventCallback(eventData.payload);
|
|
848
|
-
} else if (eventData.type === this.TYPE_METHOD_CALLBACK) {
|
|
849
|
-
// 处理函数回调
|
|
850
|
-
this.dealNativeMethodCallback(eventData.payload);
|
|
851
|
-
} else if (eventData.type === this.TYPE_PAGE_LIFE_CYCLE_CALLBACK) {
|
|
852
|
-
// 处理页面声明周期回调
|
|
853
|
-
dealNativePageLifeCycleCallback(eventData.payload);
|
|
854
|
-
}
|
|
855
|
-
},
|
|
856
|
-
|
|
857
|
-
dealNativeEventCallback: function(payload) {
|
|
858
|
-
this.callCurrentWindowEventCallback(payload);
|
|
859
|
-
this.sendMessageToChildIFrame(this.TYPE_EVENT_CALLBACK, payload);
|
|
860
|
-
},
|
|
861
|
-
|
|
862
|
-
dealNativeMethodCallback: function(payload) {
|
|
863
|
-
this.callCurrentWindowMethodCallback(payload);
|
|
864
|
-
this.sendMessageToChildIFrame(this.TYPE_METHOD_CALLBACK, payload);
|
|
865
|
-
},
|
|
866
|
-
|
|
867
|
-
dealNativePageLifeCycleCallback: function(payload) {
|
|
868
|
-
this.callCurrentWindowLifeCycleCallback(payload);
|
|
869
|
-
this.sendMessageToChildIFrame(this.TYPE_PAGE_LIFE_CYCLE_CALLBACK, payload);
|
|
870
|
-
},
|
|
871
|
-
|
|
872
|
-
// 调用当前窗口的回调函数
|
|
873
|
-
callCurrentWindowEventCallback: function(payload) {
|
|
874
|
-
o.listenerInvokeFromNativeInWindow(payload.key, payload.param);
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
// 调用当前window的函数回调函数
|
|
878
|
-
callCurrentWindowMethodCallback: function(payload) {
|
|
879
|
-
o.doCurrentWindowCallback(payload.type, payload.callbackId, payload.args);
|
|
880
|
-
},
|
|
881
|
-
|
|
882
|
-
// 调用当前window的生命周期回调函数
|
|
883
|
-
callCurrentWindowLifeCycleCallback: function(payload) {
|
|
884
|
-
// TODO 这个下一期和原生一起改
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
// 将消息往下层iframe派发
|
|
888
|
-
sendMessageToChildIFrame: function(type, payload) {
|
|
889
|
-
var elements = document.getElementsByTagName('iframe');
|
|
890
|
-
Array.prototype.forEach.call(elements, function(element) {
|
|
891
|
-
element.contentWindow.postMessage({type: type, payload: payload}, '*');
|
|
892
|
-
});
|
|
893
|
-
},
|
|
894
|
-
|
|
895
|
-
inIframe: function() {
|
|
896
|
-
try {
|
|
897
|
-
return window.self !== window.top;
|
|
898
|
-
} catch (e) {
|
|
899
|
-
return true;
|
|
900
|
-
}
|
|
901
|
-
},
|
|
902
|
-
|
|
903
|
-
TYPE_EVENT_CALLBACK: 0,
|
|
904
|
-
TYPE_METHOD_CALLBACK: 1,
|
|
905
|
-
TYPE_PAGE_LIFE_CYCLE_CALLBACK: 2,
|
|
906
|
-
|
|
907
|
-
INVOKER_STATE_FULLFILLED: 0,
|
|
908
|
-
INVOKER_STATE_REJECTED: 1,
|
|
909
|
-
INVOKER_STATE_PROGRESSING: 2,
|
|
910
|
-
|
|
911
|
-
PAGE_LIFE_CYCLE_ON_RESUME: 0,
|
|
912
|
-
PAGE_LIFE_CYCLE_ON_PAUSE: 1,
|
|
913
|
-
};
|
|
914
|
-
|
|
915
|
-
var o = {
|
|
916
|
-
versions: function () {
|
|
917
|
-
var u = navigator.userAgent,
|
|
918
|
-
app = navigator.appVersion;
|
|
919
|
-
var sdkVersion = 'AndoidSDKVersion/';
|
|
920
|
-
return {
|
|
921
|
-
trident: u.indexOf('Trident') > -1,
|
|
922
|
-
presto: u.indexOf('Presto') > -1,
|
|
923
|
-
webKit: u.indexOf('AppleWebKit') > -1,
|
|
924
|
-
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,
|
|
925
|
-
mobile: !!u.match(/AppleWebKit.*Mobile.*/),
|
|
926
|
-
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
|
|
927
|
-
android: parseInt(u.substring(u.indexOf(sdkVersion) + sdkVersion.length, u.indexOf(sdkVersion) + sdkVersion.length + 2)) <= 17,
|
|
928
|
-
iPhone: u.indexOf('iPhone') > -1,
|
|
929
|
-
iPad: u.indexOf('iPad') > -1,
|
|
930
|
-
};
|
|
931
|
-
},
|
|
932
|
-
runOnAndroid41: function () {
|
|
933
|
-
return o.versions().android && (NativeInterface() == undefined || NativeInterface() == null);
|
|
934
|
-
},
|
|
935
|
-
useiOSWKWebView: function () {
|
|
936
|
-
return o.versions().ios && typeof iOSWKInterface != 'undefined' && NativeInterface() == iOSWKInterface
|
|
937
|
-
},
|
|
938
|
-
init: function () {
|
|
939
|
-
if (o.runOnAndroid41()) {
|
|
940
|
-
prompt(JSON.stringify({
|
|
941
|
-
type: 'injectSuccess'
|
|
942
|
-
}));
|
|
943
|
-
} else {
|
|
944
|
-
if (NativeInterface() != null) {
|
|
945
|
-
NativeInterface().onInjectSuccess();
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
if (NativeInterface() != null) {
|
|
950
|
-
var __args = o.__processArgs(null);
|
|
951
|
-
NativeInterface().onBridgeInjectSuccess(JSON.stringify(__args));
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
if (o.versions().ios) {
|
|
955
|
-
o.injectConsoleOutput()
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
helper.init();
|
|
959
|
-
o.onReadyPromise().then(function () {
|
|
960
|
-
console.log("on ready promise ===== ");
|
|
961
|
-
if (typeof window.bridgeReady === 'function') {
|
|
962
|
-
window.bridgeReady();
|
|
963
|
-
}
|
|
964
|
-
window.dispatchEvent(new Event('bridgeReady'));
|
|
965
|
-
})
|
|
966
|
-
},
|
|
967
|
-
injectConsoleOutput: function () {
|
|
968
|
-
if (NativeInterface() == undefined) {
|
|
969
|
-
return;
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
var origin_console_error = console.error;
|
|
973
|
-
var injectLog = function (type, old_log) {
|
|
974
|
-
return function (message) {
|
|
975
|
-
try {
|
|
976
|
-
var path = window.location.pathname;
|
|
977
|
-
NativeInterface().sendMessageToNative("console", JSON.stringify({
|
|
978
|
-
type: "console",
|
|
979
|
-
location: path,
|
|
980
|
-
method: type,
|
|
981
|
-
arguments: arguments
|
|
982
|
-
}));
|
|
983
|
-
} catch (e) {
|
|
984
|
-
origin_console_error('save to local fial:' + JSON.stringify(e));
|
|
985
|
-
}
|
|
986
|
-
old_log.apply(console, arguments)
|
|
987
|
-
}
|
|
988
|
-
};
|
|
989
|
-
|
|
990
|
-
console.error = (function (message) {
|
|
991
|
-
var log = console.error;
|
|
992
|
-
return injectLog('Error', log, arguments)
|
|
993
|
-
})();
|
|
994
|
-
|
|
995
|
-
console.info = (function (message) {
|
|
996
|
-
var log = console.info;
|
|
997
|
-
return injectLog('Info', log, arguments)
|
|
998
|
-
})();
|
|
999
|
-
|
|
1000
|
-
console.log = (function (message) {
|
|
1001
|
-
var log = console.log;
|
|
1002
|
-
return injectLog('Log', log, arguments)
|
|
1003
|
-
})();
|
|
1004
|
-
|
|
1005
|
-
console.trace = (function (message) {
|
|
1006
|
-
var log = console.trace;
|
|
1007
|
-
return injectLog('Trace', log, arguments)
|
|
1008
|
-
})();
|
|
1009
|
-
|
|
1010
|
-
console.warn = (function (message) {
|
|
1011
|
-
var log = console.warn;
|
|
1012
|
-
return injectLog('Warn', log, arguments)
|
|
1013
|
-
})();
|
|
1014
|
-
},
|
|
1015
|
-
onReadyPromise: function () {
|
|
1016
|
-
var deferred = Q.defer();
|
|
1017
|
-
var readyState = document.readyState;
|
|
1018
|
-
if (readyState == 'interactive' || readyState == 'complete') {
|
|
1019
|
-
deferred.resolve();
|
|
1020
|
-
} else {
|
|
1021
|
-
window.addEventListener('DOMContentLoaded', deferred.resolve);
|
|
1022
|
-
}
|
|
1023
|
-
return deferred.promise;
|
|
1024
|
-
},
|
|
1025
|
-
//内部方法,请勿直接调用。若此前有调用该方法,该改为使用 bridge 对象属性调用,具体调用方法如下:
|
|
1026
|
-
//http://reference.sdp.nd/appfactory/userguide/react/jssdk/
|
|
1027
|
-
callNative: function () {
|
|
1028
|
-
console.warn("callNative 即将屏蔽,请勿直接调用。");
|
|
1029
|
-
var number_of_params = arguments.length;
|
|
1030
|
-
var className = arguments[0];
|
|
1031
|
-
var methodName = arguments[1];
|
|
1032
|
-
var argLen = number_of_params - 2;
|
|
1033
|
-
switch (argLen) {
|
|
1034
|
-
case 0:
|
|
1035
|
-
return NativeInterface().invokeMethod(o.getEntryNameFromOldClassName(className), methodName);
|
|
1036
|
-
case 1:
|
|
1037
|
-
var args = arguments[2];
|
|
1038
|
-
NativeInterface().printLog('==IcPlayer Player callNative: ' + className + "." + methodName + " arg=" + JSON.stringify(args));
|
|
1039
|
-
args = o.__processArgs(args);
|
|
1040
|
-
var result = NativeInterface().invokeMethod(o.getEntryNameFromOldClassName(className), methodName, JSON.stringify(args));
|
|
1041
|
-
try {
|
|
1042
|
-
var resultObj = JSON.parse(result);
|
|
1043
|
-
return resultObj;
|
|
1044
|
-
} catch (e) {
|
|
1045
|
-
return {};
|
|
1046
|
-
}
|
|
1047
|
-
default:
|
|
1048
|
-
console.log("too mach arguments");
|
|
1049
|
-
break;
|
|
1050
|
-
}
|
|
1051
|
-
},
|
|
1052
|
-
//内部方法,请勿直接调用。若此前有调用该方法,改为使用 bridge 对象属性调用,具体调用方法如下:
|
|
1053
|
-
//http://reference.sdp.nd/appfactory/userguide/react/jssdk/
|
|
1054
|
-
callNativeAsync: function () {
|
|
1055
|
-
console.warn("callNativeAsync 即将屏蔽,请勿直接调用。");
|
|
1056
|
-
var number_of_params = arguments.length;
|
|
1057
|
-
var className = arguments[0];
|
|
1058
|
-
var methodName = arguments[1];
|
|
1059
|
-
var func = arguments[2];
|
|
1060
|
-
var callBack;
|
|
1061
|
-
if (typeof func == "function") {
|
|
1062
|
-
var callbackId = o.randomkey(5);
|
|
1063
|
-
o.callbackMap[callbackId] = {
|
|
1064
|
-
success: func,
|
|
1065
|
-
fail: func
|
|
1066
|
-
};
|
|
1067
|
-
return NativeInterface().invokeMethodAsync(o.getEntryNameFromOldClassName(className), methodName, callbackId);
|
|
1068
|
-
} else {
|
|
1069
|
-
var param = func;
|
|
1070
|
-
func = arguments[3];
|
|
1071
|
-
if (typeof func != "function") {
|
|
1072
|
-
o.log("invalid call back func")
|
|
1073
|
-
return;
|
|
1074
|
-
}
|
|
1075
|
-
var callbackId = o.randomkey(5);
|
|
1076
|
-
o.callbackMap[callbackId] = {
|
|
1077
|
-
success: func,
|
|
1078
|
-
fail: func
|
|
1079
|
-
};
|
|
1080
|
-
return NativeInterface().invokeMethodAsync(o.getEntryNameFromOldClassName(className), methodName, callbackId, JSON.stringify(o.__processArgs(param)));
|
|
1081
|
-
}
|
|
1082
|
-
},
|
|
1083
|
-
invokeCallExec: function (entry, method, args, callback, isPromise, sync, deferred, options) {
|
|
1084
|
-
o.__processDeprecated(entry, method);
|
|
1085
|
-
var __args = o.__processArgs(args);
|
|
1086
|
-
var __options = o.__processOptions(options);
|
|
1087
|
-
if (isPromise) {
|
|
1088
|
-
return o.callPromise(entry, method, __args, sync, deferred, __options);
|
|
1089
|
-
} else {
|
|
1090
|
-
return o.callExec(entry, method, __args, callback, sync, __options);
|
|
1091
|
-
}
|
|
1092
|
-
},
|
|
1093
|
-
callPromise: function (entry, method, args, sync, promise, options) {
|
|
1094
|
-
var deferred = promise == undefined ? Q.defer() : promise;
|
|
1095
|
-
if (sync && !o.useiOSWKWebView()) {
|
|
1096
|
-
var ret = o.exec(entry, method, args, options);
|
|
1097
|
-
deferred.resolve(ret);
|
|
1098
|
-
} else {
|
|
1099
|
-
o.execAsync(entry, method, args, deferred.resolve, deferred.reject, deferred.notify, options);
|
|
1100
|
-
}
|
|
1101
|
-
return deferred.promise;
|
|
1102
|
-
},
|
|
1103
|
-
callExec: function (entry, method, args, callback, sync, options) {
|
|
1104
|
-
if (sync && !o.useiOSWKWebView()) {
|
|
1105
|
-
return o.exec(entry, method, args, options);
|
|
1106
|
-
} else {
|
|
1107
|
-
if (!callback) {
|
|
1108
|
-
callback = {};
|
|
1109
|
-
}
|
|
1110
|
-
return o.execAsync(entry, method, args, callback.success, callback.fail, callback.listener, options);
|
|
1111
|
-
}
|
|
1112
|
-
},
|
|
1113
|
-
exec: function (entry, method, args, options) {
|
|
1114
|
-
console.log("exec");
|
|
1115
|
-
var result;
|
|
1116
|
-
o.log('==IcPlayer Player exec: ' + entry + "." + method + " arg=" + JSON.stringify(args));
|
|
1117
|
-
if (o.runOnAndroid41()) {
|
|
1118
|
-
result = prompt(JSON.stringify({
|
|
1119
|
-
type: 'exec',
|
|
1120
|
-
entry: entry,
|
|
1121
|
-
method: method,
|
|
1122
|
-
args: JSON.stringify(args)
|
|
1123
|
-
}));
|
|
1124
|
-
} else {
|
|
1125
|
-
result = NativeInterface().invokeMethod(entry, method, JSON.stringify(args));
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
var finalResult = o.__processResponseObject(result, options);
|
|
1129
|
-
o.log('JSSDK exec [' + entry + "." + method + "] response:" + finalResult);
|
|
1130
|
-
|
|
1131
|
-
return finalResult;
|
|
1132
|
-
},
|
|
1133
|
-
execAsync: function (entry, method, args, success, fail, listener, options) {
|
|
1134
|
-
var callbackId = o.randomkey(5);
|
|
1135
|
-
var result;
|
|
1136
|
-
if (success || fail || listener) {
|
|
1137
|
-
o.callbackMap[callbackId] = {
|
|
1138
|
-
success: success,
|
|
1139
|
-
fail: fail,
|
|
1140
|
-
listener: listener,
|
|
1141
|
-
options: options
|
|
1142
|
-
};
|
|
1143
|
-
}
|
|
1144
|
-
if (o.runOnAndroid41()) {
|
|
1145
|
-
result = prompt(JSON.stringify({
|
|
1146
|
-
type: 'exec',
|
|
1147
|
-
entry: entry,
|
|
1148
|
-
method: method,
|
|
1149
|
-
args: JSON.stringify(args),
|
|
1150
|
-
callback: callbackId
|
|
1151
|
-
}));
|
|
1152
|
-
} else {
|
|
1153
|
-
result = NativeInterface().invokeMethodAsync(entry, method, JSON.stringify(args), callbackId);
|
|
1154
|
-
}
|
|
1155
|
-
var finalResult = o.__processResponseObject(result, options);
|
|
1156
|
-
return finalResult;
|
|
1157
|
-
},
|
|
1158
|
-
trigger: function (eventCode, param) {
|
|
1159
|
-
if (o.runOnAndroid41()) {
|
|
1160
|
-
prompt(JSON.stringify({
|
|
1161
|
-
type: 'trigger_event',
|
|
1162
|
-
code: eventCode,
|
|
1163
|
-
param: JSON.stringify(param)
|
|
1164
|
-
}));
|
|
1165
|
-
} else {
|
|
1166
|
-
NativeInterface().triggerEvent(eventCode, JSON.stringify(param));
|
|
1167
|
-
}
|
|
1168
|
-
},
|
|
1169
|
-
registerListener: function (eventName, func) {
|
|
1170
|
-
console.warn("This function is deprecated. Please use Bridge.addListener() to instead.");
|
|
1171
|
-
var callBackStruct = o.addListenerFunc(eventName, func, false);
|
|
1172
|
-
if (o.runOnAndroid41()) {
|
|
1173
|
-
prompt(JSON.stringify({
|
|
1174
|
-
type: 'register_event',
|
|
1175
|
-
eventName: eventName,
|
|
1176
|
-
callback: callBackStruct.evalString
|
|
1177
|
-
}));
|
|
1178
|
-
} else {
|
|
1179
|
-
console.log("registerListener");
|
|
1180
|
-
o.log("register event for " + eventName);
|
|
1181
|
-
NativeInterface().registerListener(eventName, callBackStruct.evalString);
|
|
1182
|
-
}
|
|
1183
|
-
return callBackStruct.key;
|
|
1184
|
-
},
|
|
1185
|
-
unregisterListener: function (eventName, callback) {
|
|
1186
|
-
console.warn("This function is deprecated. Please use Bridge.removeListener() to instead.");
|
|
1187
|
-
if (o.runOnAndroid41()) {
|
|
1188
|
-
prompt(JSON.stringify({
|
|
1189
|
-
type: 'unregister_event',
|
|
1190
|
-
eventName: eventName,
|
|
1191
|
-
callback: callback
|
|
1192
|
-
}));
|
|
1193
|
-
} else {
|
|
1194
|
-
console.log("unregisterListener");
|
|
1195
|
-
o.log("unregister event for " + eventName);
|
|
1196
|
-
o.removeNativeListenerFunc(eventName, callback);
|
|
1197
|
-
}
|
|
1198
|
-
o.removeListenerFunc(callback);
|
|
1199
|
-
},
|
|
1200
|
-
addListener: function (eventName, func, scope) {
|
|
1201
|
-
var callBackStruct = o.addListenerFunc(eventName, func, true, scope);
|
|
1202
|
-
if (o.runOnAndroid41()) {
|
|
1203
|
-
prompt(JSON.stringify({
|
|
1204
|
-
type: 'register_event',
|
|
1205
|
-
eventName: eventName,
|
|
1206
|
-
callback: callBackStruct.evalString
|
|
1207
|
-
}));
|
|
1208
|
-
} else {
|
|
1209
|
-
console.log("addListener");
|
|
1210
|
-
o.log("add event for " + eventName);
|
|
1211
|
-
NativeInterface().registerListener(eventName, callBackStruct.evalString);
|
|
1212
|
-
}
|
|
1213
|
-
return callBackStruct.key;
|
|
1214
|
-
},
|
|
1215
|
-
removeListener: function (eventName, callback) {
|
|
1216
|
-
if (o.runOnAndroid41()) {
|
|
1217
|
-
prompt(JSON.stringify({
|
|
1218
|
-
type: 'unregister_event',
|
|
1219
|
-
eventName: eventName,
|
|
1220
|
-
callback: callback
|
|
1221
|
-
}));
|
|
1222
|
-
} else {
|
|
1223
|
-
console.log("removeListener");
|
|
1224
|
-
o.log("remove event for " + eventName);
|
|
1225
|
-
o.removeNativeListenerFunc(eventName, callback);
|
|
1226
|
-
}
|
|
1227
|
-
o.removeListenerFunc(callback);
|
|
1228
|
-
},
|
|
1229
|
-
removeNativeListenerFunc: function (eventName, callback) {
|
|
1230
|
-
var listenerEvalString = "Bridge.listenerInvokeFromNative('" + callback + "',==param==)";
|
|
1231
|
-
NativeInterface().unRegisterListener(eventName, listenerEvalString);
|
|
1232
|
-
//兼容registerListener对应的事件。
|
|
1233
|
-
var listenerEvalStringOld = "Bridge.listenerInvokeFromNative('" + callback + "','==param==')";
|
|
1234
|
-
NativeInterface().unRegisterListener(eventName, listenerEvalStringOld);
|
|
1235
|
-
},
|
|
1236
|
-
log: function (str) {
|
|
1237
|
-
if (o.runOnAndroid41()) {
|
|
1238
|
-
prompt(JSON.stringify({
|
|
1239
|
-
type: 'log',
|
|
1240
|
-
message: str
|
|
1241
|
-
}));
|
|
1242
|
-
} else {
|
|
1243
|
-
NativeInterface().printLog(str)
|
|
1244
|
-
}
|
|
1245
|
-
},
|
|
1246
|
-
takePhoto: function () {
|
|
1247
|
-
|
|
1248
|
-
},
|
|
1249
|
-
goPage: function (index) {},
|
|
1250
|
-
entry: {},
|
|
1251
|
-
classEntry: {},
|
|
1252
|
-
promiseEntry: {},
|
|
1253
|
-
lastInstanceID: null,
|
|
1254
|
-
funcMap: {},
|
|
1255
|
-
callbackMap: {},
|
|
1256
|
-
listenerMap: {},
|
|
1257
|
-
listenerMapByEvent: {},
|
|
1258
|
-
deprecatedMap: {},
|
|
1259
|
-
Options: {
|
|
1260
|
-
ConvertResponseObjectKey : "__maf_convert_response_object"
|
|
1261
|
-
},
|
|
1262
|
-
listenerInvokeFromNative: function (key, param) {
|
|
1263
|
-
helper.dealNativeEventCallback({
|
|
1264
|
-
key: key,
|
|
1265
|
-
param: param,
|
|
1266
|
-
});
|
|
1267
|
-
},
|
|
1268
|
-
listenerInvokeFromNativeInWindow: function(key, param) {
|
|
1269
|
-
o.log("param=" + param);
|
|
1270
|
-
var func = o.listenerMap[key];
|
|
1271
|
-
if (func == undefined) {
|
|
1272
|
-
o.log("call back func not found");
|
|
1273
|
-
o.listenerMap[key] = null;
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
func.callback(param);
|
|
1277
|
-
},
|
|
1278
|
-
callBackFromNative: function (key, param) {
|
|
1279
|
-
o.log("param=" + param);
|
|
1280
|
-
var callbackObject = o.funcMap[key];
|
|
1281
|
-
var func = callbackObject.callback;
|
|
1282
|
-
if (func == undefined) {
|
|
1283
|
-
o.log("call back func not found");
|
|
1284
|
-
o.funcMap[key] = null;
|
|
1285
|
-
return;
|
|
1286
|
-
}
|
|
1287
|
-
func.call(callbackObject.scope, param);
|
|
1288
|
-
o.funcMap[key] = null;
|
|
1289
|
-
},
|
|
1290
|
-
addListenerFunc: function (eventName, func, isNewInterface, scope) {
|
|
1291
|
-
var key = o.randomkey(10);
|
|
1292
|
-
var listenerEvalString = null;
|
|
1293
|
-
if (isNewInterface) {
|
|
1294
|
-
listenerEvalString = "Bridge.listenerInvokeFromNative('" + key + "',==param==)";
|
|
1295
|
-
} else {
|
|
1296
|
-
listenerEvalString = "Bridge.listenerInvokeFromNative('" + key + "','==param==')";
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
var object = {
|
|
1300
|
-
key: key,
|
|
1301
|
-
evalString: listenerEvalString,
|
|
1302
|
-
callback: func,
|
|
1303
|
-
scope: scope == undefined ? window : scope
|
|
1304
|
-
}
|
|
1305
|
-
o.listenerMap[key] = object;
|
|
1306
|
-
|
|
1307
|
-
return object;
|
|
1308
|
-
},
|
|
1309
|
-
removeListenerFunc: function (key) {
|
|
1310
|
-
if (null === key || typeof key == "undefined") {
|
|
1311
|
-
return;
|
|
1312
|
-
}
|
|
1313
|
-
var func = o.listenerMap[key];
|
|
1314
|
-
if (null !== func) {
|
|
1315
|
-
o.listenerMap[key] = null;
|
|
1316
|
-
delete o.listenerMap[key];
|
|
1317
|
-
}
|
|
1318
|
-
},
|
|
1319
|
-
randomkey: function (l) {
|
|
1320
|
-
var x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
|
|
1321
|
-
var tmp = "";
|
|
1322
|
-
var timestamp = new Date().getTime();
|
|
1323
|
-
for (var i = 0; i < l; i++) {
|
|
1324
|
-
tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
|
|
1325
|
-
}
|
|
1326
|
-
return timestamp + tmp;
|
|
1327
|
-
},
|
|
1328
|
-
getEntryNameFromOldClassName: function (className) {
|
|
1329
|
-
var classNameArray = className.split(".");
|
|
1330
|
-
if (classNameArray.length > 0) {
|
|
1331
|
-
return classNameArray[classNameArray.length - 1];
|
|
1332
|
-
} else {
|
|
1333
|
-
return className;
|
|
1334
|
-
}
|
|
1335
|
-
},
|
|
1336
|
-
callbackSuccess: function (callbackId, args) {
|
|
1337
|
-
o.log("call back success ====");
|
|
1338
|
-
o.doCallback(helper.INVOKER_STATE_FULLFILLED, callbackId, args);
|
|
1339
|
-
},
|
|
1340
|
-
callbackFail: function (callbackId, args) {
|
|
1341
|
-
o.log("call back fail ====");
|
|
1342
|
-
o.doCallback(helper.INVOKER_STATE_REJECTED, callbackId, args);
|
|
1343
|
-
},
|
|
1344
|
-
callbackListen: function (callbackId, args) {
|
|
1345
|
-
o.log("call back listen ====");
|
|
1346
|
-
o.doCallback(helper.INVOKER_STATE_PROGRESSING, callbackId, args);
|
|
1347
|
-
},
|
|
1348
|
-
|
|
1349
|
-
doCallback: function(type, callbackId, args) {
|
|
1350
|
-
helper.dealNativeMethodCallback({
|
|
1351
|
-
type: type,
|
|
1352
|
-
callbackId: callbackId,
|
|
1353
|
-
args: args,
|
|
1354
|
-
});
|
|
1355
|
-
},
|
|
1356
|
-
|
|
1357
|
-
doCurrentWindowCallback: function (type, callbackId, args) {
|
|
1358
|
-
var callBack = o.callbackMap[callbackId];
|
|
1359
|
-
if (callBack) {
|
|
1360
|
-
var result = o.__processResponseObject(args, callBack.options);
|
|
1361
|
-
if (type == helper.INVOKER_STATE_FULLFILLED) {
|
|
1362
|
-
callBack.success && callBack.success.call(null, result);
|
|
1363
|
-
o.callbackMap[callbackId] = null;
|
|
1364
|
-
} else if (type == helper.INVOKER_STATE_REJECTED) {
|
|
1365
|
-
callBack.fail && callBack.fail.call(null, result);
|
|
1366
|
-
o.callbackMap[callbackId] = null;
|
|
1367
|
-
} else if (type == helper.INVOKER_STATE_PROGRESSING) {
|
|
1368
|
-
callBack.listener && callBack.listener.call(null, result);
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
},
|
|
1372
|
-
loadNative: function (type, href) {
|
|
1373
|
-
o.exec('apkManager', 'loadApk', args);
|
|
1374
|
-
},
|
|
1375
|
-
import: function (entryName) {
|
|
1376
|
-
var success;
|
|
1377
|
-
if (o.runOnAndroid41()) {
|
|
1378
|
-
success = prompt(JSON.stringify({
|
|
1379
|
-
type: 'importJsSdk',
|
|
1380
|
-
entry: entryName
|
|
1381
|
-
}));
|
|
1382
|
-
} else {
|
|
1383
|
-
success = NativeInterface().importJsSdk(entryName);
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
if (success === 'false') {
|
|
1387
|
-
throw new Error('import failed : ' + entryName);
|
|
1388
|
-
}
|
|
1389
|
-
},
|
|
1390
|
-
//该 API 只提供 promise 用法
|
|
1391
|
-
apisAvailable: function (param) {
|
|
1392
|
-
var deferred = Q.defer();
|
|
1393
|
-
if (!param["entries"] || param["entries"].constructor != Array || param["entries"].length == 0) {
|
|
1394
|
-
throw new Error("apisAvailable check failed: entries is not available");
|
|
1395
|
-
}
|
|
1396
|
-
if (o.useiOSWKWebView()) {
|
|
1397
|
-
var asyncWrapper = new WKAsyncWrapper();
|
|
1398
|
-
asyncWrapper.returnStringCallBack = function (resString) {
|
|
1399
|
-
deferred.resolve(JSON.parse(resString));
|
|
1400
|
-
};
|
|
1401
|
-
asyncWrapper.apisAvailable(JSON.stringify(param));
|
|
1402
|
-
} else {
|
|
1403
|
-
var resString = NativeInterface().apisAvailable(JSON.stringify(param));
|
|
1404
|
-
deferred.resolve(JSON.parse(resString));
|
|
1405
|
-
}
|
|
1406
|
-
return deferred.promise;
|
|
1407
|
-
},
|
|
1408
|
-
require: function (entryName) {
|
|
1409
|
-
if (o.entry[entryName]) {
|
|
1410
|
-
return o.entry[entryName];
|
|
1411
|
-
} else if (o.classEntry[entryName]) {
|
|
1412
|
-
return o.classEntry[entryName];
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
if (o.useiOSWKWebView()) {
|
|
1416
|
-
var wrapper = new WKRequireWrapper()
|
|
1417
|
-
wrapper.requireName = entryName
|
|
1418
|
-
return wrapper
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
var jsEntry;
|
|
1422
|
-
if (o.runOnAndroid41()) {
|
|
1423
|
-
jsEntry = prompt(JSON.stringify({
|
|
1424
|
-
type: 'require',
|
|
1425
|
-
entry: entryName
|
|
1426
|
-
}));
|
|
1427
|
-
} else {
|
|
1428
|
-
jsEntry = NativeInterface().require(entryName);
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
if (jsEntry.length > 0) {
|
|
1432
|
-
eval(jsEntry);
|
|
1433
|
-
o.__processDeprecated(entryName);
|
|
1434
|
-
if (o.entry[entryName]) {
|
|
1435
|
-
return o.entry[entryName];
|
|
1436
|
-
} else if (o.classEntry[entryName]) {
|
|
1437
|
-
return o.classEntry[entryName];
|
|
1438
|
-
}
|
|
1439
|
-
} else {
|
|
1440
|
-
o.log(entryName + " not found !");
|
|
1441
|
-
}
|
|
1442
|
-
},
|
|
1443
|
-
newInstance: function (param) {
|
|
1444
|
-
var jsEntry;
|
|
1445
|
-
|
|
1446
|
-
if (o.runOnAndroid41()) {
|
|
1447
|
-
jsEntry = prompt(JSON.stringify({
|
|
1448
|
-
type: 'newInstance',
|
|
1449
|
-
params: JSON.stringify(param)
|
|
1450
|
-
}));
|
|
1451
|
-
} else if (o.useiOSWKWebView()) {
|
|
1452
|
-
var wrapper = new WKRequireWrapper()
|
|
1453
|
-
wrapper.isObject = false
|
|
1454
|
-
wrapper.classParam = param
|
|
1455
|
-
return wrapper
|
|
1456
|
-
} else {
|
|
1457
|
-
jsEntry = NativeInterface().newInstance(JSON.stringify(param));
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
eval(jsEntry);
|
|
1461
|
-
var lastInstanceID = Bridge.lastInstanceID;
|
|
1462
|
-
var object = Bridge.entry[lastInstanceID];
|
|
1463
|
-
Bridge.lastInstanceID = null;
|
|
1464
|
-
return object;
|
|
1465
|
-
},
|
|
1466
|
-
deleteInstance: function (entry) {
|
|
1467
|
-
var jsString;
|
|
1468
|
-
|
|
1469
|
-
if (o.runOnAndroid41()) {
|
|
1470
|
-
jsString = prompt(JSON.stringify({
|
|
1471
|
-
type: 'deleteInstance',
|
|
1472
|
-
entryName: entry
|
|
1473
|
-
}));
|
|
1474
|
-
} else {
|
|
1475
|
-
jsString = NativeInterface().deleteInstance(entry);
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
eval(jsString);
|
|
1479
|
-
},
|
|
1480
|
-
sendMessageToNative: function (bizCode, param) {
|
|
1481
|
-
var __args = o.__processArgs(param);
|
|
1482
|
-
console.log("NativeInterface sendMessageToNative: code = " + bizCode, +"param = " + param);
|
|
1483
|
-
if (o.runOnAndroid41()) {
|
|
1484
|
-
prompt(JSON.stringify({
|
|
1485
|
-
type: 'sendMessageToNative',
|
|
1486
|
-
eventName: bizCode,
|
|
1487
|
-
callback: JSON.stringify(__args)
|
|
1488
|
-
}));
|
|
1489
|
-
} else {
|
|
1490
|
-
console.log("addListener");
|
|
1491
|
-
NativeInterface().sendMessageToNative(bizCode, JSON.stringify(__args)); // Android Only: allow js send param to Native
|
|
1492
|
-
}
|
|
1493
|
-
},
|
|
1494
|
-
__processArgs: function (args) {
|
|
1495
|
-
|
|
1496
|
-
var __args = args;
|
|
1497
|
-
if (null === __args || typeof __args == "undefined") {
|
|
1498
|
-
__args = {};
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
if ("object" == typeof __args && !__args.hasOwnProperty("_maf_url")) {
|
|
1502
|
-
__args["_maf_url"] = window.location.href;
|
|
1503
|
-
}
|
|
1504
|
-
return __args;
|
|
1505
|
-
},
|
|
1506
|
-
__processDeprecated: function (entryName, method) {
|
|
1507
|
-
if (null === entryName || typeof entryName == "undefined") {
|
|
1508
|
-
return;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
var deprecated = o.deprecatedMap[entryName];
|
|
1512
|
-
if (null === deprecated || typeof deprecated == "undefined") {
|
|
1513
|
-
return;
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
var isClassDeprecated = true;
|
|
1517
|
-
var deprecatedObject = deprecated["*"];
|
|
1518
|
-
if (null === deprecatedObject || typeof deprecatedObject == "undefined") {
|
|
1519
|
-
deprecatedObject = deprecated[method];
|
|
1520
|
-
isClassDeprecated = false;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
if (null === deprecatedObject || typeof deprecatedObject == "undefined") {
|
|
1524
|
-
return;
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
var deprecatedVersion = deprecatedObject["version"];
|
|
1528
|
-
var deprecatedMessage = deprecatedObject["message"];
|
|
1529
|
-
|
|
1530
|
-
var warningString = (isClassDeprecated ? ("Class " + entryName) : ("Method " + entryName + ":" + method)) + " deprecated";
|
|
1531
|
-
if (deprecatedVersion) {
|
|
1532
|
-
warningString = warningString + " at " + deprecatedVersion;
|
|
1533
|
-
}
|
|
1534
|
-
if (deprecatedMessage) {
|
|
1535
|
-
warningString = warningString + ", " + deprecatedMessage;
|
|
1536
|
-
}
|
|
1537
|
-
o.log(warningString);
|
|
1538
|
-
console.warn(warningString);
|
|
1539
|
-
},
|
|
1540
|
-
__processOptions: function (origin) {
|
|
1541
|
-
var __options = origin
|
|
1542
|
-
if (null === __options || typeof __options == "undefined") {
|
|
1543
|
-
__options = {};
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
if ("object" == typeof __options && !__options.hasOwnProperty(o.Options.ConvertResponseObjectKey)) {
|
|
1547
|
-
__options[o.Options.ConvertResponseObjectKey] = true;
|
|
1548
|
-
}
|
|
1549
|
-
return __options;
|
|
1550
|
-
},
|
|
1551
|
-
__processResponseObject: function (origin, options) {
|
|
1552
|
-
var finalResult = origin;
|
|
1553
|
-
var convertResponseObjectValue = options[o.Options.ConvertResponseObjectKey]
|
|
1554
|
-
if (null !== convertResponseObjectValue && convertResponseObjectValue) {
|
|
1555
|
-
try {
|
|
1556
|
-
finalResult = JSON.parse(origin);
|
|
1557
|
-
} catch (e) {
|
|
1558
|
-
finalResult = origin;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
return finalResult;
|
|
1562
|
-
},
|
|
1563
|
-
//该方法提供给外面Override
|
|
1564
|
-
__isTakeKeyBack: function () {
|
|
1565
|
-
return false;
|
|
1566
|
-
},
|
|
1567
|
-
|
|
1568
|
-
//该方法给Webview使用,外面不要Override
|
|
1569
|
-
__isJsTakeKeyBack: function () {
|
|
1570
|
-
var isTake = o.__isTakeKeyBack();
|
|
1571
|
-
if (isTake) {
|
|
1572
|
-
console.warn("返回键现在由Js处理!");
|
|
1573
|
-
} else {
|
|
1574
|
-
console.log("返回键仍然由Webview处理!");
|
|
1575
|
-
}
|
|
1576
|
-
//传值回Webview
|
|
1577
|
-
var appFactory = o.require('sdp.appfactory');
|
|
1578
|
-
appFactory.isJsTakeKeyBack({
|
|
1579
|
-
"isJsTakeKeyBack": isTake
|
|
1580
|
-
});
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
return o;
|
|
1584
|
-
};
|
|
1585
|
-
|
|
1586
|
-
! function (a) {
|
|
1587
|
-
a();
|
|
1588
|
-
}(function() {
|
|
1589
|
-
console.warn("Use JsBridge by online! Please migrate to the new resolution. Visit: http://reference.doc.101.com/appfactory/design/design/client/jssdk-import-optmize-solution/jssdk-import-optmize-solution.html");
|
|
1590
|
-
var userAgent = navigator.userAgent;
|
|
1591
|
-
if (userAgent.indexOf('SmartCanWebView') < 0) {
|
|
1592
|
-
console.error("Not running on SmartCanWebView, it should not be right. A best practice can be referenced, visit: http://reference.doc.101.com/appfactory/userguide/light/h5/use-js-sdk.html");
|
|
1593
|
-
return;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
window.Bridge = loadJsBridge();
|
|
1597
|
-
window.Bridge.init();
|
|
1598
|
-
window.Bridge.require('webcontainer');
|
|
1599
|
-
window.Bridge.require('sdp.webcontainer');
|
|
1600
|
-
window.Bridge.require('sys');
|
|
1601
|
-
window.Bridge.require('sdp.sys');
|
|
1602
|
-
});
|
|
1
|
+
! function (a) {
|
|
2
|
+
"use strict";
|
|
3
|
+
if ("function" == typeof bootstrap) bootstrap("promise", a);
|
|
4
|
+
else if ("object" == typeof exports && "object" == typeof module) module.exports = a();
|
|
5
|
+
else if ("function" == typeof define && define.amd) define(a);
|
|
6
|
+
else if ("undefined" != typeof ses) {
|
|
7
|
+
if (!ses.ok()) return;
|
|
8
|
+
ses.makeQ = a
|
|
9
|
+
} else {
|
|
10
|
+
if ("undefined" == typeof window && "undefined" == typeof self) throw new Error("This environment was not anticipated by Q. Please file a bug.");
|
|
11
|
+
var b = "undefined" != typeof window ? window : self,
|
|
12
|
+
c = b.Q;
|
|
13
|
+
b.Q = a(), b.Q.noConflict = function () {
|
|
14
|
+
return b.Q = c, this
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}(function () {
|
|
18
|
+
"use strict";
|
|
19
|
+
|
|
20
|
+
function a(a) {
|
|
21
|
+
return function () {
|
|
22
|
+
return W.apply(a, arguments)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function b(a) {
|
|
27
|
+
return a === Object(a)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function c(a) {
|
|
31
|
+
return "[object StopIteration]" === ca(a) || a instanceof S
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function d(a, b) {
|
|
35
|
+
if (P && b.stack && "object" == typeof a && null !== a && a.stack && -1 === a.stack.indexOf(da)) {
|
|
36
|
+
for (var c = [], d = b; d; d = d.source) d.stack && c.unshift(d.stack);
|
|
37
|
+
c.unshift(a.stack);
|
|
38
|
+
var f = c.join("\n" + da + "\n");
|
|
39
|
+
a.stack = e(f)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function e(a) {
|
|
44
|
+
for (var b = a.split("\n"), c = [], d = 0; d < b.length; ++d) {
|
|
45
|
+
var e = b[d];
|
|
46
|
+
h(e) || f(e) || !e || c.push(e)
|
|
47
|
+
}
|
|
48
|
+
return c.join("\n")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function f(a) {
|
|
52
|
+
return -1 !== a.indexOf("(module.js:") || -1 !== a.indexOf("(node.js:")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function g(a) {
|
|
56
|
+
var b = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);
|
|
57
|
+
if (b) return [b[1], Number(b[2])];
|
|
58
|
+
var c = /at ([^ ]+):(\d+):(?:\d+)$/.exec(a);
|
|
59
|
+
if (c) return [c[1], Number(c[2])];
|
|
60
|
+
var d = /.*@(.+):(\d+)$/.exec(a);
|
|
61
|
+
return d ? [d[1], Number(d[2])] : void 0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function h(a) {
|
|
65
|
+
var b = g(a);
|
|
66
|
+
if (!b) return !1;
|
|
67
|
+
var c = b[0],
|
|
68
|
+
d = b[1];
|
|
69
|
+
return c === R && d >= T && ia >= d
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function i() {
|
|
73
|
+
if (P) try {
|
|
74
|
+
throw new Error
|
|
75
|
+
} catch (a) {
|
|
76
|
+
var b = a.stack.split("\n"),
|
|
77
|
+
c = b[0].indexOf("@") > 0 ? b[1] : b[2],
|
|
78
|
+
d = g(c);
|
|
79
|
+
if (!d) return;
|
|
80
|
+
return R = d[0], d[1]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function j(a, b, c) {
|
|
85
|
+
return function () {
|
|
86
|
+
return "undefined" != typeof console && "function" == typeof console.warn && console.warn(b + " is deprecated, use " + c + " instead.", new Error("").stack), a.apply(a, arguments)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function k(a) {
|
|
91
|
+
return a instanceof o ? a : s(a) ? B(a) : A(a)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function l() {
|
|
95
|
+
function a(a) {
|
|
96
|
+
b = a, f.source = a, Y(c, function (b, c) {
|
|
97
|
+
k.nextTick(function () {
|
|
98
|
+
a.promiseDispatch.apply(a, c)
|
|
99
|
+
})
|
|
100
|
+
}, void 0), c = void 0, d = void 0
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var b, c = [],
|
|
104
|
+
d = [],
|
|
105
|
+
e = _(l.prototype),
|
|
106
|
+
f = _(o.prototype);
|
|
107
|
+
if (f.promiseDispatch = function (a, e, f) {
|
|
108
|
+
var g = X(arguments);
|
|
109
|
+
c ? (c.push(g), "when" === e && f[1] && d.push(f[1])) : k.nextTick(function () {
|
|
110
|
+
b.promiseDispatch.apply(b, g)
|
|
111
|
+
})
|
|
112
|
+
}, f.valueOf = function () {
|
|
113
|
+
if (c) return f;
|
|
114
|
+
var a = q(b);
|
|
115
|
+
return r(a) && (b = a), a
|
|
116
|
+
}, f.inspect = function () {
|
|
117
|
+
return b ? b.inspect() : {
|
|
118
|
+
state: "pending"
|
|
119
|
+
}
|
|
120
|
+
}, k.longStackSupport && P) try {
|
|
121
|
+
throw new Error
|
|
122
|
+
} catch (g) {
|
|
123
|
+
f.stack = g.stack.substring(g.stack.indexOf("\n") + 1)
|
|
124
|
+
}
|
|
125
|
+
return e.promise = f, e.resolve = function (c) {
|
|
126
|
+
b || a(k(c))
|
|
127
|
+
}, e.fulfill = function (c) {
|
|
128
|
+
b || a(A(c))
|
|
129
|
+
}, e.reject = function (c) {
|
|
130
|
+
b || a(z(c))
|
|
131
|
+
}, e.notify = function (a) {
|
|
132
|
+
b || Y(d, function (b, c) {
|
|
133
|
+
k.nextTick(function () {
|
|
134
|
+
c(a)
|
|
135
|
+
})
|
|
136
|
+
}, void 0)
|
|
137
|
+
}, e
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function m(a) {
|
|
141
|
+
if ("function" != typeof a) throw new TypeError("resolver must be a function.");
|
|
142
|
+
var b = l();
|
|
143
|
+
try {
|
|
144
|
+
a(b.resolve, b.reject, b.notify)
|
|
145
|
+
} catch (c) {
|
|
146
|
+
b.reject(c)
|
|
147
|
+
}
|
|
148
|
+
return b.promise
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function n(a) {
|
|
152
|
+
return m(function (b, c) {
|
|
153
|
+
for (var d = 0, e = a.length; e > d; d++) k(a[d]).then(b, c)
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function o(a, b, c) {
|
|
158
|
+
void 0 === b && (b = function (a) {
|
|
159
|
+
return z(new Error("Promise does not support operation: " + a))
|
|
160
|
+
}), void 0 === c && (c = function () {
|
|
161
|
+
return {
|
|
162
|
+
state: "unknown"
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
var d = _(o.prototype);
|
|
166
|
+
if (d.promiseDispatch = function (c, e, f) {
|
|
167
|
+
var g;
|
|
168
|
+
try {
|
|
169
|
+
g = a[e] ? a[e].apply(d, f) : b.call(d, e, f)
|
|
170
|
+
} catch (h) {
|
|
171
|
+
g = z(h)
|
|
172
|
+
}
|
|
173
|
+
c && c(g)
|
|
174
|
+
}, d.inspect = c, c) {
|
|
175
|
+
var e = c();
|
|
176
|
+
"rejected" === e.state && (d.exception = e.reason), d.valueOf = function () {
|
|
177
|
+
var a = c();
|
|
178
|
+
return "pending" === a.state || "rejected" === a.state ? d : a.value
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return d
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function p(a, b, c, d) {
|
|
185
|
+
return k(a).then(b, c, d)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function q(a) {
|
|
189
|
+
if (r(a)) {
|
|
190
|
+
var b = a.inspect();
|
|
191
|
+
if ("fulfilled" === b.state) return b.value
|
|
192
|
+
}
|
|
193
|
+
return a
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function r(a) {
|
|
197
|
+
return a instanceof o
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function s(a) {
|
|
201
|
+
return b(a) && "function" == typeof a.then
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function t(a) {
|
|
205
|
+
return r(a) && "pending" === a.inspect().state
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function u(a) {
|
|
209
|
+
return !r(a) || "fulfilled" === a.inspect().state
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function v(a) {
|
|
213
|
+
return r(a) && "rejected" === a.inspect().state
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function w() {
|
|
217
|
+
ea.length = 0, fa.length = 0, ha || (ha = !0)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function x(a, b) {
|
|
221
|
+
ha && ("object" == typeof process && "function" == typeof process.emit && k.nextTick.runAfter(function () {
|
|
222
|
+
-1 !== Z(fa, a) && (process.emit("unhandledRejection", b, a), ga.push(a))
|
|
223
|
+
}), fa.push(a), b && "undefined" != typeof b.stack ? ea.push(b.stack) : ea.push("(no stack) " + b))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function y(a) {
|
|
227
|
+
if (ha) {
|
|
228
|
+
var b = Z(fa, a); -
|
|
229
|
+
1 !== b && ("object" == typeof process && "function" == typeof process.emit && k.nextTick.runAfter(function () {
|
|
230
|
+
var c = Z(ga, a); -
|
|
231
|
+
1 !== c && (process.emit("rejectionHandled", ea[b], a), ga.splice(c, 1))
|
|
232
|
+
}), fa.splice(b, 1), ea.splice(b, 1))
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function z(a) {
|
|
237
|
+
var b = o({
|
|
238
|
+
when: function (b) {
|
|
239
|
+
return b && y(this), b ? b(a) : this
|
|
240
|
+
}
|
|
241
|
+
}, function () {
|
|
242
|
+
return this
|
|
243
|
+
}, function () {
|
|
244
|
+
return {
|
|
245
|
+
state: "rejected",
|
|
246
|
+
reason: a
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
return x(b, a), b
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function A(a) {
|
|
253
|
+
return o({
|
|
254
|
+
when: function () {
|
|
255
|
+
return a
|
|
256
|
+
},
|
|
257
|
+
get: function (b) {
|
|
258
|
+
return a[b]
|
|
259
|
+
},
|
|
260
|
+
set: function (b, c) {
|
|
261
|
+
a[b] = c
|
|
262
|
+
},
|
|
263
|
+
"delete": function (b) {
|
|
264
|
+
delete a[b]
|
|
265
|
+
},
|
|
266
|
+
post: function (b, c) {
|
|
267
|
+
return null === b || void 0 === b ? a.apply(void 0, c) : a[b].apply(a, c)
|
|
268
|
+
},
|
|
269
|
+
apply: function (b, c) {
|
|
270
|
+
return a.apply(b, c)
|
|
271
|
+
},
|
|
272
|
+
keys: function () {
|
|
273
|
+
return ba(a)
|
|
274
|
+
}
|
|
275
|
+
}, void 0, function () {
|
|
276
|
+
return {
|
|
277
|
+
state: "fulfilled",
|
|
278
|
+
value: a
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function B(a) {
|
|
284
|
+
var b = l();
|
|
285
|
+
return k.nextTick(function () {
|
|
286
|
+
try {
|
|
287
|
+
a.then(b.resolve, b.reject, b.notify)
|
|
288
|
+
} catch (c) {
|
|
289
|
+
b.reject(c)
|
|
290
|
+
}
|
|
291
|
+
}), b.promise
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function C(a) {
|
|
295
|
+
return o({
|
|
296
|
+
isDef: function () {}
|
|
297
|
+
}, function (b, c) {
|
|
298
|
+
return I(a, b, c)
|
|
299
|
+
}, function () {
|
|
300
|
+
return k(a).inspect()
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function D(a, b, c) {
|
|
305
|
+
return k(a).spread(b, c)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function E(a) {
|
|
309
|
+
return function () {
|
|
310
|
+
function b(a, b) {
|
|
311
|
+
var g;
|
|
312
|
+
if ("undefined" == typeof StopIteration) {
|
|
313
|
+
try {
|
|
314
|
+
g = d[a](b)
|
|
315
|
+
} catch (h) {
|
|
316
|
+
return z(h)
|
|
317
|
+
}
|
|
318
|
+
return g.done ? k(g.value) : p(g.value, e, f)
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
g = d[a](b)
|
|
322
|
+
} catch (h) {
|
|
323
|
+
return c(h) ? k(h.value) : z(h)
|
|
324
|
+
}
|
|
325
|
+
return p(g, e, f)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
var d = a.apply(this, arguments),
|
|
329
|
+
e = b.bind(b, "next"),
|
|
330
|
+
f = b.bind(b, "throw");
|
|
331
|
+
return e()
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function F(a) {
|
|
336
|
+
k.done(k.async(a)())
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function G(a) {
|
|
340
|
+
throw new S(a)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function H(a) {
|
|
344
|
+
return function () {
|
|
345
|
+
return D([this, J(arguments)], function (b, c) {
|
|
346
|
+
return a.apply(b, c)
|
|
347
|
+
})
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function I(a, b, c) {
|
|
352
|
+
return k(a).dispatch(b, c)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function J(a) {
|
|
356
|
+
return p(a, function (a) {
|
|
357
|
+
var b = 0,
|
|
358
|
+
c = l();
|
|
359
|
+
return Y(a, function (d, e, f) {
|
|
360
|
+
var g;
|
|
361
|
+
r(e) && "fulfilled" === (g = e.inspect()).state ? a[f] = g.value : (++b, p(e, function (d) {
|
|
362
|
+
a[f] = d, 0 === --b && c.resolve(a)
|
|
363
|
+
}, c.reject, function (a) {
|
|
364
|
+
c.notify({
|
|
365
|
+
index: f,
|
|
366
|
+
value: a
|
|
367
|
+
})
|
|
368
|
+
}))
|
|
369
|
+
}, void 0), 0 === b && c.resolve(a), c.promise
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function K(a) {
|
|
374
|
+
if (0 === a.length) return k.resolve();
|
|
375
|
+
var b = k.defer(),
|
|
376
|
+
c = 0;
|
|
377
|
+
return Y(a, function (d, e, f) {
|
|
378
|
+
function g(a) {
|
|
379
|
+
b.resolve(a)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function h(a) {
|
|
383
|
+
c--, 0 === c && (a.message = "Q can't get fulfillment value from any promise, all promises were rejected. Last error message: " + a.message, b.reject(a))
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function i(a) {
|
|
387
|
+
b.notify({
|
|
388
|
+
index: f,
|
|
389
|
+
value: a
|
|
390
|
+
})
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var j = a[f];
|
|
394
|
+
c++, p(j, g, h, i)
|
|
395
|
+
}, void 0), b.promise
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function L(a) {
|
|
399
|
+
return p(a, function (a) {
|
|
400
|
+
return a = $(a, k), p(J($(a, function (a) {
|
|
401
|
+
return p(a, U, U)
|
|
402
|
+
})), function () {
|
|
403
|
+
return a
|
|
404
|
+
})
|
|
405
|
+
})
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function M(a) {
|
|
409
|
+
return k(a).allSettled()
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function N(a, b) {
|
|
413
|
+
return k(a).then(void 0, void 0, b)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function O(a, b) {
|
|
417
|
+
return k(a).nodeify(b)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
var P = !1;
|
|
421
|
+
try {
|
|
422
|
+
throw new Error
|
|
423
|
+
} catch (Q) {
|
|
424
|
+
P = !!Q.stack
|
|
425
|
+
}
|
|
426
|
+
var R, S, T = i(),
|
|
427
|
+
U = function () {},
|
|
428
|
+
V = function () {
|
|
429
|
+
function a() {
|
|
430
|
+
for (var a, d; c.next;) c = c.next, a = c.task, c.task = void 0, d = c.domain, d && (c.domain = void 0, d.enter()), b(a, d);
|
|
431
|
+
for (; h.length;) a = h.pop(), b(a);
|
|
432
|
+
e = !1
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function b(b, c) {
|
|
436
|
+
try {
|
|
437
|
+
b()
|
|
438
|
+
} catch (d) {
|
|
439
|
+
if (g) throw c && c.exit(), setTimeout(a, 0), c && c.enter(), d;
|
|
440
|
+
setTimeout(function () {
|
|
441
|
+
throw d
|
|
442
|
+
}, 0)
|
|
443
|
+
}
|
|
444
|
+
c && c.exit()
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
var c = {
|
|
448
|
+
task: void 0,
|
|
449
|
+
next: null
|
|
450
|
+
},
|
|
451
|
+
d = c,
|
|
452
|
+
e = !1,
|
|
453
|
+
f = void 0,
|
|
454
|
+
g = !1,
|
|
455
|
+
h = [];
|
|
456
|
+
if (V = function (a) {
|
|
457
|
+
d = d.next = {
|
|
458
|
+
task: a,
|
|
459
|
+
domain: g && process.domain,
|
|
460
|
+
next: null
|
|
461
|
+
}, e || (e = !0, f())
|
|
462
|
+
}, "object" == typeof process && "[object process]" === process.toString() && process.nextTick) g = !0, f = function () {
|
|
463
|
+
process.nextTick(a)
|
|
464
|
+
};
|
|
465
|
+
else if ("function" == typeof setImmediate) f = "undefined" != typeof window ? setImmediate.bind(window, a) : function () {
|
|
466
|
+
setImmediate(a)
|
|
467
|
+
};
|
|
468
|
+
else if ("undefined" != typeof MessageChannel) {
|
|
469
|
+
var i = new MessageChannel;
|
|
470
|
+
i.port1.onmessage = function () {
|
|
471
|
+
f = j, i.port1.onmessage = a, a()
|
|
472
|
+
};
|
|
473
|
+
var j = function () {
|
|
474
|
+
i.port2.postMessage(0)
|
|
475
|
+
};
|
|
476
|
+
f = function () {
|
|
477
|
+
setTimeout(a, 0), j()
|
|
478
|
+
}
|
|
479
|
+
} else f = function () {
|
|
480
|
+
setTimeout(a, 0)
|
|
481
|
+
};
|
|
482
|
+
return V.runAfter = function (a) {
|
|
483
|
+
h.push(a), e || (e = !0, f())
|
|
484
|
+
}, V
|
|
485
|
+
}(),
|
|
486
|
+
W = Function.call,
|
|
487
|
+
X = a(Array.prototype.slice),
|
|
488
|
+
Y = a(Array.prototype.reduce || function (a, b) {
|
|
489
|
+
var c = 0,
|
|
490
|
+
d = this.length;
|
|
491
|
+
if (1 === arguments.length)
|
|
492
|
+
for (;;) {
|
|
493
|
+
if (c in this) {
|
|
494
|
+
b = this[c++];
|
|
495
|
+
break
|
|
496
|
+
}
|
|
497
|
+
if (++c >= d) throw new TypeError
|
|
498
|
+
}
|
|
499
|
+
for (; d > c; c++) c in this && (b = a(b, this[c], c));
|
|
500
|
+
return b
|
|
501
|
+
}),
|
|
502
|
+
Z = a(Array.prototype.indexOf || function (a) {
|
|
503
|
+
for (var b = 0; b < this.length; b++)
|
|
504
|
+
if (this[b] === a) return b;
|
|
505
|
+
return -1
|
|
506
|
+
}),
|
|
507
|
+
$ = a(Array.prototype.map || function (a, b) {
|
|
508
|
+
var c = this,
|
|
509
|
+
d = [];
|
|
510
|
+
return Y(c, function (e, f, g) {
|
|
511
|
+
d.push(a.call(b, f, g, c))
|
|
512
|
+
}, void 0), d
|
|
513
|
+
}),
|
|
514
|
+
_ = Object.create || function (a) {
|
|
515
|
+
function b() {}
|
|
516
|
+
|
|
517
|
+
return b.prototype = a, new b
|
|
518
|
+
},
|
|
519
|
+
aa = a(Object.prototype.hasOwnProperty),
|
|
520
|
+
ba = Object.keys || function (a) {
|
|
521
|
+
var b = [];
|
|
522
|
+
for (var c in a) aa(a, c) && b.push(c);
|
|
523
|
+
return b
|
|
524
|
+
},
|
|
525
|
+
ca = a(Object.prototype.toString);
|
|
526
|
+
S = "undefined" != typeof ReturnValue ? ReturnValue : function (a) {
|
|
527
|
+
this.value = a
|
|
528
|
+
};
|
|
529
|
+
var da = "From previous event:";
|
|
530
|
+
k.resolve = k, k.nextTick = V, k.longStackSupport = !1, "object" == typeof process && process && process.env && process.env.Q_DEBUG && (k.longStackSupport = !0), k.defer = l, l.prototype.makeNodeResolver = function () {
|
|
531
|
+
var a = this;
|
|
532
|
+
return function (b, c) {
|
|
533
|
+
b ? a.reject(b) : arguments.length > 2 ? a.resolve(X(arguments, 1)) : a.resolve(c)
|
|
534
|
+
}
|
|
535
|
+
}, k.Promise = m, k.promise = m, m.race = n, m.all = J, m.reject = z, m.resolve = k, k.passByCopy = function (a) {
|
|
536
|
+
return a
|
|
537
|
+
}, o.prototype.passByCopy = function () {
|
|
538
|
+
return this
|
|
539
|
+
}, k.join = function (a, b) {
|
|
540
|
+
return k(a).join(b)
|
|
541
|
+
}, o.prototype.join = function (a) {
|
|
542
|
+
return k([this, a]).spread(function (a, b) {
|
|
543
|
+
if (a === b) return a;
|
|
544
|
+
throw new Error("Q can't join: not the same: " + a + " " + b)
|
|
545
|
+
})
|
|
546
|
+
}, k.race = n, o.prototype.race = function () {
|
|
547
|
+
return this.then(k.race)
|
|
548
|
+
}, k.makePromise = o, o.prototype.toString = function () {
|
|
549
|
+
return "[object Promise]"
|
|
550
|
+
}, o.prototype.then = function (a, b, c) {
|
|
551
|
+
function e(b) {
|
|
552
|
+
try {
|
|
553
|
+
return "function" == typeof a ? a(b) : b
|
|
554
|
+
} catch (c) {
|
|
555
|
+
return z(c)
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function f(a) {
|
|
560
|
+
if ("function" == typeof b) {
|
|
561
|
+
d(a, h);
|
|
562
|
+
try {
|
|
563
|
+
return b(a)
|
|
564
|
+
} catch (c) {
|
|
565
|
+
return z(c)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return z(a)
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function g(a) {
|
|
572
|
+
return "function" == typeof c ? c(a) : a
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
var h = this,
|
|
576
|
+
i = l(),
|
|
577
|
+
j = !1;
|
|
578
|
+
return k.nextTick(function () {
|
|
579
|
+
h.promiseDispatch(function (a) {
|
|
580
|
+
j || (j = !0, i.resolve(e(a)))
|
|
581
|
+
}, "when", [function (a) {
|
|
582
|
+
j || (j = !0, i.resolve(f(a)))
|
|
583
|
+
}])
|
|
584
|
+
}), h.promiseDispatch(void 0, "when", [void 0, function (a) {
|
|
585
|
+
var b, c = !1;
|
|
586
|
+
try {
|
|
587
|
+
b = g(a)
|
|
588
|
+
} catch (d) {
|
|
589
|
+
if (c = !0, !k.onerror) throw d;
|
|
590
|
+
k.onerror(d)
|
|
591
|
+
}
|
|
592
|
+
c || i.notify(b)
|
|
593
|
+
}]), i.promise
|
|
594
|
+
}, k.tap = function (a, b) {
|
|
595
|
+
return k(a).tap(b)
|
|
596
|
+
}, o.prototype.tap = function (a) {
|
|
597
|
+
return a = k(a), this.then(function (b) {
|
|
598
|
+
return a.fcall(b).thenResolve(b)
|
|
599
|
+
})
|
|
600
|
+
}, k.when = p, o.prototype.thenResolve = function (a) {
|
|
601
|
+
return this.then(function () {
|
|
602
|
+
return a
|
|
603
|
+
})
|
|
604
|
+
}, k.thenResolve = function (a, b) {
|
|
605
|
+
return k(a).thenResolve(b)
|
|
606
|
+
}, o.prototype.thenReject = function (a) {
|
|
607
|
+
return this.then(function () {
|
|
608
|
+
throw a
|
|
609
|
+
})
|
|
610
|
+
}, k.thenReject = function (a, b) {
|
|
611
|
+
return k(a).thenReject(b)
|
|
612
|
+
}, k.nearer = q, k.isPromise = r, k.isPromiseAlike = s, k.isPending = t, o.prototype.isPending = function () {
|
|
613
|
+
return "pending" === this.inspect().state
|
|
614
|
+
}, k.isFulfilled = u, o.prototype.isFulfilled = function () {
|
|
615
|
+
return "fulfilled" === this.inspect().state
|
|
616
|
+
}, k.isRejected = v, o.prototype.isRejected = function () {
|
|
617
|
+
return "rejected" === this.inspect().state
|
|
618
|
+
};
|
|
619
|
+
var ea = [],
|
|
620
|
+
fa = [],
|
|
621
|
+
ga = [],
|
|
622
|
+
ha = !0;
|
|
623
|
+
k.resetUnhandledRejections = w, k.getUnhandledReasons = function () {
|
|
624
|
+
return ea.slice()
|
|
625
|
+
}, k.stopUnhandledRejectionTracking = function () {
|
|
626
|
+
w(), ha = !1
|
|
627
|
+
}, w(), k.reject = z, k.fulfill = A, k.master = C, k.spread = D, o.prototype.spread = function (a, b) {
|
|
628
|
+
return this.all().then(function (b) {
|
|
629
|
+
return a.apply(void 0, b)
|
|
630
|
+
}, b)
|
|
631
|
+
}, k.async = E, k.spawn = F, k["return"] = G, k.promised = H, k.dispatch = I, o.prototype.dispatch = function (a, b) {
|
|
632
|
+
var c = this,
|
|
633
|
+
d = l();
|
|
634
|
+
return k.nextTick(function () {
|
|
635
|
+
c.promiseDispatch(d.resolve, a, b)
|
|
636
|
+
}), d.promise
|
|
637
|
+
}, k.get = function (a, b) {
|
|
638
|
+
return k(a).dispatch("get", [b])
|
|
639
|
+
}, o.prototype.get = function (a) {
|
|
640
|
+
return this.dispatch("get", [a])
|
|
641
|
+
}, k.set = function (a, b, c) {
|
|
642
|
+
return k(a).dispatch("set", [b, c])
|
|
643
|
+
}, o.prototype.set = function (a, b) {
|
|
644
|
+
return this.dispatch("set", [a, b])
|
|
645
|
+
}, k.del = k["delete"] = function (a, b) {
|
|
646
|
+
return k(a).dispatch("delete", [b])
|
|
647
|
+
}, o.prototype.del = o.prototype["delete"] = function (a) {
|
|
648
|
+
return this.dispatch("delete", [a])
|
|
649
|
+
}, k.mapply = k.post = function (a, b, c) {
|
|
650
|
+
return k(a).dispatch("post", [b, c])
|
|
651
|
+
}, o.prototype.mapply = o.prototype.post = function (a, b) {
|
|
652
|
+
return this.dispatch("post", [a, b])
|
|
653
|
+
}, k.send = k.mcall = k.invoke = function (a, b) {
|
|
654
|
+
return k(a).dispatch("post", [b, X(arguments, 2)])
|
|
655
|
+
}, o.prototype.send = o.prototype.mcall = o.prototype.invoke = function (a) {
|
|
656
|
+
return this.dispatch("post", [a, X(arguments, 1)])
|
|
657
|
+
}, k.fapply = function (a, b) {
|
|
658
|
+
return k(a).dispatch("apply", [void 0, b])
|
|
659
|
+
}, o.prototype.fapply = function (a) {
|
|
660
|
+
return this.dispatch("apply", [void 0, a])
|
|
661
|
+
}, k["try"] = k.fcall = function (a) {
|
|
662
|
+
return k(a).dispatch("apply", [void 0, X(arguments, 1)])
|
|
663
|
+
}, o.prototype.fcall = function () {
|
|
664
|
+
return this.dispatch("apply", [void 0, X(arguments)])
|
|
665
|
+
}, k.fbind = function (a) {
|
|
666
|
+
var b = k(a),
|
|
667
|
+
c = X(arguments, 1);
|
|
668
|
+
return function () {
|
|
669
|
+
return b.dispatch("apply", [this, c.concat(X(arguments))])
|
|
670
|
+
}
|
|
671
|
+
}, o.prototype.fbind = function () {
|
|
672
|
+
var a = this,
|
|
673
|
+
b = X(arguments);
|
|
674
|
+
return function () {
|
|
675
|
+
return a.dispatch("apply", [this, b.concat(X(arguments))])
|
|
676
|
+
}
|
|
677
|
+
}, k.keys = function (a) {
|
|
678
|
+
return k(a).dispatch("keys", [])
|
|
679
|
+
}, o.prototype.keys = function () {
|
|
680
|
+
return this.dispatch("keys", [])
|
|
681
|
+
}, k.all = J, o.prototype.all = function () {
|
|
682
|
+
return J(this)
|
|
683
|
+
}, k.any = K, o.prototype.any = function () {
|
|
684
|
+
return K(this)
|
|
685
|
+
}, k.allResolved = j(L, "allResolved", "allSettled"), o.prototype.allResolved = function () {
|
|
686
|
+
return L(this)
|
|
687
|
+
}, k.allSettled = M, o.prototype.allSettled = function () {
|
|
688
|
+
return this.then(function (a) {
|
|
689
|
+
return J($(a, function (a) {
|
|
690
|
+
function b() {
|
|
691
|
+
return a.inspect()
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return a = k(a), a.then(b, b)
|
|
695
|
+
}))
|
|
696
|
+
})
|
|
697
|
+
}, k.fail = k["catch"] = function (a, b) {
|
|
698
|
+
return k(a).then(void 0, b)
|
|
699
|
+
}, o.prototype.fail = o.prototype["catch"] = function (a) {
|
|
700
|
+
return this.then(void 0, a)
|
|
701
|
+
}, k.progress = N, o.prototype.progress = function (a) {
|
|
702
|
+
return this.then(void 0, void 0, a)
|
|
703
|
+
}, k.fin = k["finally"] = function (a, b) {
|
|
704
|
+
return k(a)["finally"](b)
|
|
705
|
+
}, o.prototype.fin = o.prototype["finally"] = function (a) {
|
|
706
|
+
if (!a || "function" != typeof a.apply) throw new Error("Q can't apply finally callback");
|
|
707
|
+
return a = k(a), this.then(function (b) {
|
|
708
|
+
return a.fcall().then(function () {
|
|
709
|
+
return b
|
|
710
|
+
})
|
|
711
|
+
}, function (b) {
|
|
712
|
+
return a.fcall().then(function () {
|
|
713
|
+
throw b
|
|
714
|
+
})
|
|
715
|
+
})
|
|
716
|
+
}, k.done = function (a, b, c, d) {
|
|
717
|
+
return k(a).done(b, c, d)
|
|
718
|
+
}, o.prototype.done = function (a, b, c) {
|
|
719
|
+
var e = function (a) {
|
|
720
|
+
k.nextTick(function () {
|
|
721
|
+
if (d(a, f), !k.onerror) throw a;
|
|
722
|
+
k.onerror(a)
|
|
723
|
+
})
|
|
724
|
+
},
|
|
725
|
+
f = a || b || c ? this.then(a, b, c) : this;
|
|
726
|
+
"object" == typeof process && process && process.domain && (e = process.domain.bind(e)), f.then(void 0, e)
|
|
727
|
+
}, k.timeout = function (a, b, c) {
|
|
728
|
+
return k(a).timeout(b, c)
|
|
729
|
+
}, o.prototype.timeout = function (a, b) {
|
|
730
|
+
var c = l(),
|
|
731
|
+
d = setTimeout(function () {
|
|
732
|
+
b && "string" != typeof b || (b = new Error(b || "Timed out after " + a + " ms"), b.code = "ETIMEDOUT"), c.reject(b)
|
|
733
|
+
}, a);
|
|
734
|
+
return this.then(function (a) {
|
|
735
|
+
clearTimeout(d), c.resolve(a)
|
|
736
|
+
}, function (a) {
|
|
737
|
+
clearTimeout(d), c.reject(a)
|
|
738
|
+
}, c.notify), c.promise
|
|
739
|
+
}, k.delay = function (a, b) {
|
|
740
|
+
return void 0 === b && (b = a, a = void 0), k(a).delay(b)
|
|
741
|
+
}, o.prototype.delay = function (a) {
|
|
742
|
+
return this.then(function (b) {
|
|
743
|
+
var c = l();
|
|
744
|
+
return setTimeout(function () {
|
|
745
|
+
c.resolve(b)
|
|
746
|
+
}, a), c.promise
|
|
747
|
+
})
|
|
748
|
+
}, k.nfapply = function (a, b) {
|
|
749
|
+
return k(a).nfapply(b)
|
|
750
|
+
}, o.prototype.nfapply = function (a) {
|
|
751
|
+
var b = l(),
|
|
752
|
+
c = X(a);
|
|
753
|
+
return c.push(b.makeNodeResolver()), this.fapply(c).fail(b.reject), b.promise
|
|
754
|
+
}, k.nfcall = function (a) {
|
|
755
|
+
var b = X(arguments, 1);
|
|
756
|
+
return k(a).nfapply(b)
|
|
757
|
+
}, o.prototype.nfcall = function () {
|
|
758
|
+
var a = X(arguments),
|
|
759
|
+
b = l();
|
|
760
|
+
return a.push(b.makeNodeResolver()), this.fapply(a).fail(b.reject), b.promise
|
|
761
|
+
}, k.nfbind = k.denodeify = function (a) {
|
|
762
|
+
if (void 0 === a) throw new Error("Q can't wrap an undefined function");
|
|
763
|
+
var b = X(arguments, 1);
|
|
764
|
+
return function () {
|
|
765
|
+
var c = b.concat(X(arguments)),
|
|
766
|
+
d = l();
|
|
767
|
+
return c.push(d.makeNodeResolver()), k(a).fapply(c).fail(d.reject), d.promise
|
|
768
|
+
}
|
|
769
|
+
}, o.prototype.nfbind = o.prototype.denodeify = function () {
|
|
770
|
+
var a = X(arguments);
|
|
771
|
+
return a.unshift(this), k.denodeify.apply(void 0, a)
|
|
772
|
+
}, k.nbind = function (a, b) {
|
|
773
|
+
var c = X(arguments, 2);
|
|
774
|
+
return function () {
|
|
775
|
+
function d() {
|
|
776
|
+
return a.apply(b, arguments)
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
var e = c.concat(X(arguments)),
|
|
780
|
+
f = l();
|
|
781
|
+
return e.push(f.makeNodeResolver()), k(d).fapply(e).fail(f.reject), f.promise
|
|
782
|
+
}
|
|
783
|
+
}, o.prototype.nbind = function () {
|
|
784
|
+
var a = X(arguments, 0);
|
|
785
|
+
return a.unshift(this), k.nbind.apply(void 0, a)
|
|
786
|
+
}, k.nmapply = k.npost = function (a, b, c) {
|
|
787
|
+
return k(a).npost(b, c)
|
|
788
|
+
}, o.prototype.nmapply = o.prototype.npost = function (a, b) {
|
|
789
|
+
var c = X(b || []),
|
|
790
|
+
d = l();
|
|
791
|
+
return c.push(d.makeNodeResolver()), this.dispatch("post", [a, c]).fail(d.reject), d.promise
|
|
792
|
+
}, k.nsend = k.nmcall = k.ninvoke = function (a, b) {
|
|
793
|
+
var c = X(arguments, 2),
|
|
794
|
+
d = l();
|
|
795
|
+
return c.push(d.makeNodeResolver()), k(a).dispatch("post", [b, c]).fail(d.reject), d.promise
|
|
796
|
+
}, o.prototype.nsend = o.prototype.nmcall = o.prototype.ninvoke = function (a) {
|
|
797
|
+
var b = X(arguments, 1),
|
|
798
|
+
c = l();
|
|
799
|
+
return b.push(c.makeNodeResolver()), this.dispatch("post", [a, b]).fail(c.reject), c.promise
|
|
800
|
+
}, k.nodeify = O, o.prototype.nodeify = function (a) {
|
|
801
|
+
return a ? void this.then(function (b) {
|
|
802
|
+
k.nextTick(function () {
|
|
803
|
+
a(null, b)
|
|
804
|
+
})
|
|
805
|
+
}, function (b) {
|
|
806
|
+
k.nextTick(function () {
|
|
807
|
+
a(b)
|
|
808
|
+
})
|
|
809
|
+
}) : this
|
|
810
|
+
}, k.noConflict = function () {
|
|
811
|
+
throw new Error("Q.noConflict only works when Q is used as a global")
|
|
812
|
+
};
|
|
813
|
+
var ia = i();
|
|
814
|
+
return k
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
function NativeInterface() {
|
|
818
|
+
if (typeof AndroidInterface != 'undefined') {
|
|
819
|
+
return AndroidInterface;
|
|
820
|
+
} else if (typeof iOSInterface != 'undefined') {
|
|
821
|
+
return iOSInterface;
|
|
822
|
+
} else if (typeof PCInterface != 'undefined') {
|
|
823
|
+
return PCInterface;
|
|
824
|
+
} else if (typeof iOSWKInterface != 'undefined') {
|
|
825
|
+
return iOSWKInterface;
|
|
826
|
+
} else {
|
|
827
|
+
console.log("Native interface not found!");
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function loadJsBridge () {
|
|
833
|
+
var helper = {
|
|
834
|
+
init: function() {
|
|
835
|
+
// 添加监听
|
|
836
|
+
if (this.inIframe()) {
|
|
837
|
+
var self = this;
|
|
838
|
+
window.addEventListener("message", function (event) {
|
|
839
|
+
self.dealWindowEventMessage(event.data);
|
|
840
|
+
}, false);
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
|
|
844
|
+
dealWindowEventMessage: function(eventData) {
|
|
845
|
+
if (eventData.type === this.TYPE_EVENT_CALLBACK) {
|
|
846
|
+
// 处理事件回调
|
|
847
|
+
this.dealNativeEventCallback(eventData.payload);
|
|
848
|
+
} else if (eventData.type === this.TYPE_METHOD_CALLBACK) {
|
|
849
|
+
// 处理函数回调
|
|
850
|
+
this.dealNativeMethodCallback(eventData.payload);
|
|
851
|
+
} else if (eventData.type === this.TYPE_PAGE_LIFE_CYCLE_CALLBACK) {
|
|
852
|
+
// 处理页面声明周期回调
|
|
853
|
+
dealNativePageLifeCycleCallback(eventData.payload);
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
|
|
857
|
+
dealNativeEventCallback: function(payload) {
|
|
858
|
+
this.callCurrentWindowEventCallback(payload);
|
|
859
|
+
this.sendMessageToChildIFrame(this.TYPE_EVENT_CALLBACK, payload);
|
|
860
|
+
},
|
|
861
|
+
|
|
862
|
+
dealNativeMethodCallback: function(payload) {
|
|
863
|
+
this.callCurrentWindowMethodCallback(payload);
|
|
864
|
+
this.sendMessageToChildIFrame(this.TYPE_METHOD_CALLBACK, payload);
|
|
865
|
+
},
|
|
866
|
+
|
|
867
|
+
dealNativePageLifeCycleCallback: function(payload) {
|
|
868
|
+
this.callCurrentWindowLifeCycleCallback(payload);
|
|
869
|
+
this.sendMessageToChildIFrame(this.TYPE_PAGE_LIFE_CYCLE_CALLBACK, payload);
|
|
870
|
+
},
|
|
871
|
+
|
|
872
|
+
// 调用当前窗口的回调函数
|
|
873
|
+
callCurrentWindowEventCallback: function(payload) {
|
|
874
|
+
o.listenerInvokeFromNativeInWindow(payload.key, payload.param);
|
|
875
|
+
},
|
|
876
|
+
|
|
877
|
+
// 调用当前window的函数回调函数
|
|
878
|
+
callCurrentWindowMethodCallback: function(payload) {
|
|
879
|
+
o.doCurrentWindowCallback(payload.type, payload.callbackId, payload.args);
|
|
880
|
+
},
|
|
881
|
+
|
|
882
|
+
// 调用当前window的生命周期回调函数
|
|
883
|
+
callCurrentWindowLifeCycleCallback: function(payload) {
|
|
884
|
+
// TODO 这个下一期和原生一起改
|
|
885
|
+
},
|
|
886
|
+
|
|
887
|
+
// 将消息往下层iframe派发
|
|
888
|
+
sendMessageToChildIFrame: function(type, payload) {
|
|
889
|
+
var elements = document.getElementsByTagName('iframe');
|
|
890
|
+
Array.prototype.forEach.call(elements, function(element) {
|
|
891
|
+
element.contentWindow.postMessage({type: type, payload: payload}, '*');
|
|
892
|
+
});
|
|
893
|
+
},
|
|
894
|
+
|
|
895
|
+
inIframe: function() {
|
|
896
|
+
try {
|
|
897
|
+
return window.self !== window.top;
|
|
898
|
+
} catch (e) {
|
|
899
|
+
return true;
|
|
900
|
+
}
|
|
901
|
+
},
|
|
902
|
+
|
|
903
|
+
TYPE_EVENT_CALLBACK: 0,
|
|
904
|
+
TYPE_METHOD_CALLBACK: 1,
|
|
905
|
+
TYPE_PAGE_LIFE_CYCLE_CALLBACK: 2,
|
|
906
|
+
|
|
907
|
+
INVOKER_STATE_FULLFILLED: 0,
|
|
908
|
+
INVOKER_STATE_REJECTED: 1,
|
|
909
|
+
INVOKER_STATE_PROGRESSING: 2,
|
|
910
|
+
|
|
911
|
+
PAGE_LIFE_CYCLE_ON_RESUME: 0,
|
|
912
|
+
PAGE_LIFE_CYCLE_ON_PAUSE: 1,
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
var o = {
|
|
916
|
+
versions: function () {
|
|
917
|
+
var u = navigator.userAgent,
|
|
918
|
+
app = navigator.appVersion;
|
|
919
|
+
var sdkVersion = 'AndoidSDKVersion/';
|
|
920
|
+
return {
|
|
921
|
+
trident: u.indexOf('Trident') > -1,
|
|
922
|
+
presto: u.indexOf('Presto') > -1,
|
|
923
|
+
webKit: u.indexOf('AppleWebKit') > -1,
|
|
924
|
+
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,
|
|
925
|
+
mobile: !!u.match(/AppleWebKit.*Mobile.*/),
|
|
926
|
+
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
|
|
927
|
+
android: parseInt(u.substring(u.indexOf(sdkVersion) + sdkVersion.length, u.indexOf(sdkVersion) + sdkVersion.length + 2)) <= 17,
|
|
928
|
+
iPhone: u.indexOf('iPhone') > -1,
|
|
929
|
+
iPad: u.indexOf('iPad') > -1,
|
|
930
|
+
};
|
|
931
|
+
},
|
|
932
|
+
runOnAndroid41: function () {
|
|
933
|
+
return o.versions().android && (NativeInterface() == undefined || NativeInterface() == null);
|
|
934
|
+
},
|
|
935
|
+
useiOSWKWebView: function () {
|
|
936
|
+
return o.versions().ios && typeof iOSWKInterface != 'undefined' && NativeInterface() == iOSWKInterface
|
|
937
|
+
},
|
|
938
|
+
init: function () {
|
|
939
|
+
if (o.runOnAndroid41()) {
|
|
940
|
+
prompt(JSON.stringify({
|
|
941
|
+
type: 'injectSuccess'
|
|
942
|
+
}));
|
|
943
|
+
} else {
|
|
944
|
+
if (NativeInterface() != null) {
|
|
945
|
+
NativeInterface().onInjectSuccess();
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
if (NativeInterface() != null) {
|
|
950
|
+
var __args = o.__processArgs(null);
|
|
951
|
+
NativeInterface().onBridgeInjectSuccess(JSON.stringify(__args));
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if (o.versions().ios) {
|
|
955
|
+
o.injectConsoleOutput()
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
helper.init();
|
|
959
|
+
o.onReadyPromise().then(function () {
|
|
960
|
+
console.log("on ready promise ===== ");
|
|
961
|
+
if (typeof window.bridgeReady === 'function') {
|
|
962
|
+
window.bridgeReady();
|
|
963
|
+
}
|
|
964
|
+
window.dispatchEvent(new Event('bridgeReady'));
|
|
965
|
+
})
|
|
966
|
+
},
|
|
967
|
+
injectConsoleOutput: function () {
|
|
968
|
+
if (NativeInterface() == undefined) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
var origin_console_error = console.error;
|
|
973
|
+
var injectLog = function (type, old_log) {
|
|
974
|
+
return function (message) {
|
|
975
|
+
try {
|
|
976
|
+
var path = window.location.pathname;
|
|
977
|
+
NativeInterface().sendMessageToNative("console", JSON.stringify({
|
|
978
|
+
type: "console",
|
|
979
|
+
location: path,
|
|
980
|
+
method: type,
|
|
981
|
+
arguments: arguments
|
|
982
|
+
}));
|
|
983
|
+
} catch (e) {
|
|
984
|
+
origin_console_error('save to local fial:' + JSON.stringify(e));
|
|
985
|
+
}
|
|
986
|
+
old_log.apply(console, arguments)
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
console.error = (function (message) {
|
|
991
|
+
var log = console.error;
|
|
992
|
+
return injectLog('Error', log, arguments)
|
|
993
|
+
})();
|
|
994
|
+
|
|
995
|
+
console.info = (function (message) {
|
|
996
|
+
var log = console.info;
|
|
997
|
+
return injectLog('Info', log, arguments)
|
|
998
|
+
})();
|
|
999
|
+
|
|
1000
|
+
console.log = (function (message) {
|
|
1001
|
+
var log = console.log;
|
|
1002
|
+
return injectLog('Log', log, arguments)
|
|
1003
|
+
})();
|
|
1004
|
+
|
|
1005
|
+
console.trace = (function (message) {
|
|
1006
|
+
var log = console.trace;
|
|
1007
|
+
return injectLog('Trace', log, arguments)
|
|
1008
|
+
})();
|
|
1009
|
+
|
|
1010
|
+
console.warn = (function (message) {
|
|
1011
|
+
var log = console.warn;
|
|
1012
|
+
return injectLog('Warn', log, arguments)
|
|
1013
|
+
})();
|
|
1014
|
+
},
|
|
1015
|
+
onReadyPromise: function () {
|
|
1016
|
+
var deferred = Q.defer();
|
|
1017
|
+
var readyState = document.readyState;
|
|
1018
|
+
if (readyState == 'interactive' || readyState == 'complete') {
|
|
1019
|
+
deferred.resolve();
|
|
1020
|
+
} else {
|
|
1021
|
+
window.addEventListener('DOMContentLoaded', deferred.resolve);
|
|
1022
|
+
}
|
|
1023
|
+
return deferred.promise;
|
|
1024
|
+
},
|
|
1025
|
+
//内部方法,请勿直接调用。若此前有调用该方法,该改为使用 bridge 对象属性调用,具体调用方法如下:
|
|
1026
|
+
//http://reference.sdp.nd/appfactory/userguide/react/jssdk/
|
|
1027
|
+
callNative: function () {
|
|
1028
|
+
console.warn("callNative 即将屏蔽,请勿直接调用。");
|
|
1029
|
+
var number_of_params = arguments.length;
|
|
1030
|
+
var className = arguments[0];
|
|
1031
|
+
var methodName = arguments[1];
|
|
1032
|
+
var argLen = number_of_params - 2;
|
|
1033
|
+
switch (argLen) {
|
|
1034
|
+
case 0:
|
|
1035
|
+
return NativeInterface().invokeMethod(o.getEntryNameFromOldClassName(className), methodName);
|
|
1036
|
+
case 1:
|
|
1037
|
+
var args = arguments[2];
|
|
1038
|
+
NativeInterface().printLog('==IcPlayer Player callNative: ' + className + "." + methodName + " arg=" + JSON.stringify(args));
|
|
1039
|
+
args = o.__processArgs(args);
|
|
1040
|
+
var result = NativeInterface().invokeMethod(o.getEntryNameFromOldClassName(className), methodName, JSON.stringify(args));
|
|
1041
|
+
try {
|
|
1042
|
+
var resultObj = JSON.parse(result);
|
|
1043
|
+
return resultObj;
|
|
1044
|
+
} catch (e) {
|
|
1045
|
+
return {};
|
|
1046
|
+
}
|
|
1047
|
+
default:
|
|
1048
|
+
console.log("too mach arguments");
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
//内部方法,请勿直接调用。若此前有调用该方法,改为使用 bridge 对象属性调用,具体调用方法如下:
|
|
1053
|
+
//http://reference.sdp.nd/appfactory/userguide/react/jssdk/
|
|
1054
|
+
callNativeAsync: function () {
|
|
1055
|
+
console.warn("callNativeAsync 即将屏蔽,请勿直接调用。");
|
|
1056
|
+
var number_of_params = arguments.length;
|
|
1057
|
+
var className = arguments[0];
|
|
1058
|
+
var methodName = arguments[1];
|
|
1059
|
+
var func = arguments[2];
|
|
1060
|
+
var callBack;
|
|
1061
|
+
if (typeof func == "function") {
|
|
1062
|
+
var callbackId = o.randomkey(5);
|
|
1063
|
+
o.callbackMap[callbackId] = {
|
|
1064
|
+
success: func,
|
|
1065
|
+
fail: func
|
|
1066
|
+
};
|
|
1067
|
+
return NativeInterface().invokeMethodAsync(o.getEntryNameFromOldClassName(className), methodName, callbackId);
|
|
1068
|
+
} else {
|
|
1069
|
+
var param = func;
|
|
1070
|
+
func = arguments[3];
|
|
1071
|
+
if (typeof func != "function") {
|
|
1072
|
+
o.log("invalid call back func")
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
var callbackId = o.randomkey(5);
|
|
1076
|
+
o.callbackMap[callbackId] = {
|
|
1077
|
+
success: func,
|
|
1078
|
+
fail: func
|
|
1079
|
+
};
|
|
1080
|
+
return NativeInterface().invokeMethodAsync(o.getEntryNameFromOldClassName(className), methodName, callbackId, JSON.stringify(o.__processArgs(param)));
|
|
1081
|
+
}
|
|
1082
|
+
},
|
|
1083
|
+
invokeCallExec: function (entry, method, args, callback, isPromise, sync, deferred, options) {
|
|
1084
|
+
o.__processDeprecated(entry, method);
|
|
1085
|
+
var __args = o.__processArgs(args);
|
|
1086
|
+
var __options = o.__processOptions(options);
|
|
1087
|
+
if (isPromise) {
|
|
1088
|
+
return o.callPromise(entry, method, __args, sync, deferred, __options);
|
|
1089
|
+
} else {
|
|
1090
|
+
return o.callExec(entry, method, __args, callback, sync, __options);
|
|
1091
|
+
}
|
|
1092
|
+
},
|
|
1093
|
+
callPromise: function (entry, method, args, sync, promise, options) {
|
|
1094
|
+
var deferred = promise == undefined ? Q.defer() : promise;
|
|
1095
|
+
if (sync && !o.useiOSWKWebView()) {
|
|
1096
|
+
var ret = o.exec(entry, method, args, options);
|
|
1097
|
+
deferred.resolve(ret);
|
|
1098
|
+
} else {
|
|
1099
|
+
o.execAsync(entry, method, args, deferred.resolve, deferred.reject, deferred.notify, options);
|
|
1100
|
+
}
|
|
1101
|
+
return deferred.promise;
|
|
1102
|
+
},
|
|
1103
|
+
callExec: function (entry, method, args, callback, sync, options) {
|
|
1104
|
+
if (sync && !o.useiOSWKWebView()) {
|
|
1105
|
+
return o.exec(entry, method, args, options);
|
|
1106
|
+
} else {
|
|
1107
|
+
if (!callback) {
|
|
1108
|
+
callback = {};
|
|
1109
|
+
}
|
|
1110
|
+
return o.execAsync(entry, method, args, callback.success, callback.fail, callback.listener, options);
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
exec: function (entry, method, args, options) {
|
|
1114
|
+
console.log("exec");
|
|
1115
|
+
var result;
|
|
1116
|
+
o.log('==IcPlayer Player exec: ' + entry + "." + method + " arg=" + JSON.stringify(args));
|
|
1117
|
+
if (o.runOnAndroid41()) {
|
|
1118
|
+
result = prompt(JSON.stringify({
|
|
1119
|
+
type: 'exec',
|
|
1120
|
+
entry: entry,
|
|
1121
|
+
method: method,
|
|
1122
|
+
args: JSON.stringify(args)
|
|
1123
|
+
}));
|
|
1124
|
+
} else {
|
|
1125
|
+
result = NativeInterface().invokeMethod(entry, method, JSON.stringify(args));
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
var finalResult = o.__processResponseObject(result, options);
|
|
1129
|
+
o.log('JSSDK exec [' + entry + "." + method + "] response:" + finalResult);
|
|
1130
|
+
|
|
1131
|
+
return finalResult;
|
|
1132
|
+
},
|
|
1133
|
+
execAsync: function (entry, method, args, success, fail, listener, options) {
|
|
1134
|
+
var callbackId = o.randomkey(5);
|
|
1135
|
+
var result;
|
|
1136
|
+
if (success || fail || listener) {
|
|
1137
|
+
o.callbackMap[callbackId] = {
|
|
1138
|
+
success: success,
|
|
1139
|
+
fail: fail,
|
|
1140
|
+
listener: listener,
|
|
1141
|
+
options: options
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
if (o.runOnAndroid41()) {
|
|
1145
|
+
result = prompt(JSON.stringify({
|
|
1146
|
+
type: 'exec',
|
|
1147
|
+
entry: entry,
|
|
1148
|
+
method: method,
|
|
1149
|
+
args: JSON.stringify(args),
|
|
1150
|
+
callback: callbackId
|
|
1151
|
+
}));
|
|
1152
|
+
} else {
|
|
1153
|
+
result = NativeInterface().invokeMethodAsync(entry, method, JSON.stringify(args), callbackId);
|
|
1154
|
+
}
|
|
1155
|
+
var finalResult = o.__processResponseObject(result, options);
|
|
1156
|
+
return finalResult;
|
|
1157
|
+
},
|
|
1158
|
+
trigger: function (eventCode, param) {
|
|
1159
|
+
if (o.runOnAndroid41()) {
|
|
1160
|
+
prompt(JSON.stringify({
|
|
1161
|
+
type: 'trigger_event',
|
|
1162
|
+
code: eventCode,
|
|
1163
|
+
param: JSON.stringify(param)
|
|
1164
|
+
}));
|
|
1165
|
+
} else {
|
|
1166
|
+
NativeInterface().triggerEvent(eventCode, JSON.stringify(param));
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
registerListener: function (eventName, func) {
|
|
1170
|
+
console.warn("This function is deprecated. Please use Bridge.addListener() to instead.");
|
|
1171
|
+
var callBackStruct = o.addListenerFunc(eventName, func, false);
|
|
1172
|
+
if (o.runOnAndroid41()) {
|
|
1173
|
+
prompt(JSON.stringify({
|
|
1174
|
+
type: 'register_event',
|
|
1175
|
+
eventName: eventName,
|
|
1176
|
+
callback: callBackStruct.evalString
|
|
1177
|
+
}));
|
|
1178
|
+
} else {
|
|
1179
|
+
console.log("registerListener");
|
|
1180
|
+
o.log("register event for " + eventName);
|
|
1181
|
+
NativeInterface().registerListener(eventName, callBackStruct.evalString);
|
|
1182
|
+
}
|
|
1183
|
+
return callBackStruct.key;
|
|
1184
|
+
},
|
|
1185
|
+
unregisterListener: function (eventName, callback) {
|
|
1186
|
+
console.warn("This function is deprecated. Please use Bridge.removeListener() to instead.");
|
|
1187
|
+
if (o.runOnAndroid41()) {
|
|
1188
|
+
prompt(JSON.stringify({
|
|
1189
|
+
type: 'unregister_event',
|
|
1190
|
+
eventName: eventName,
|
|
1191
|
+
callback: callback
|
|
1192
|
+
}));
|
|
1193
|
+
} else {
|
|
1194
|
+
console.log("unregisterListener");
|
|
1195
|
+
o.log("unregister event for " + eventName);
|
|
1196
|
+
o.removeNativeListenerFunc(eventName, callback);
|
|
1197
|
+
}
|
|
1198
|
+
o.removeListenerFunc(callback);
|
|
1199
|
+
},
|
|
1200
|
+
addListener: function (eventName, func, scope) {
|
|
1201
|
+
var callBackStruct = o.addListenerFunc(eventName, func, true, scope);
|
|
1202
|
+
if (o.runOnAndroid41()) {
|
|
1203
|
+
prompt(JSON.stringify({
|
|
1204
|
+
type: 'register_event',
|
|
1205
|
+
eventName: eventName,
|
|
1206
|
+
callback: callBackStruct.evalString
|
|
1207
|
+
}));
|
|
1208
|
+
} else {
|
|
1209
|
+
console.log("addListener");
|
|
1210
|
+
o.log("add event for " + eventName);
|
|
1211
|
+
NativeInterface().registerListener(eventName, callBackStruct.evalString);
|
|
1212
|
+
}
|
|
1213
|
+
return callBackStruct.key;
|
|
1214
|
+
},
|
|
1215
|
+
removeListener: function (eventName, callback) {
|
|
1216
|
+
if (o.runOnAndroid41()) {
|
|
1217
|
+
prompt(JSON.stringify({
|
|
1218
|
+
type: 'unregister_event',
|
|
1219
|
+
eventName: eventName,
|
|
1220
|
+
callback: callback
|
|
1221
|
+
}));
|
|
1222
|
+
} else {
|
|
1223
|
+
console.log("removeListener");
|
|
1224
|
+
o.log("remove event for " + eventName);
|
|
1225
|
+
o.removeNativeListenerFunc(eventName, callback);
|
|
1226
|
+
}
|
|
1227
|
+
o.removeListenerFunc(callback);
|
|
1228
|
+
},
|
|
1229
|
+
removeNativeListenerFunc: function (eventName, callback) {
|
|
1230
|
+
var listenerEvalString = "Bridge.listenerInvokeFromNative('" + callback + "',==param==)";
|
|
1231
|
+
NativeInterface().unRegisterListener(eventName, listenerEvalString);
|
|
1232
|
+
//兼容registerListener对应的事件。
|
|
1233
|
+
var listenerEvalStringOld = "Bridge.listenerInvokeFromNative('" + callback + "','==param==')";
|
|
1234
|
+
NativeInterface().unRegisterListener(eventName, listenerEvalStringOld);
|
|
1235
|
+
},
|
|
1236
|
+
log: function (str) {
|
|
1237
|
+
if (o.runOnAndroid41()) {
|
|
1238
|
+
prompt(JSON.stringify({
|
|
1239
|
+
type: 'log',
|
|
1240
|
+
message: str
|
|
1241
|
+
}));
|
|
1242
|
+
} else {
|
|
1243
|
+
NativeInterface().printLog(str)
|
|
1244
|
+
}
|
|
1245
|
+
},
|
|
1246
|
+
takePhoto: function () {
|
|
1247
|
+
|
|
1248
|
+
},
|
|
1249
|
+
goPage: function (index) {},
|
|
1250
|
+
entry: {},
|
|
1251
|
+
classEntry: {},
|
|
1252
|
+
promiseEntry: {},
|
|
1253
|
+
lastInstanceID: null,
|
|
1254
|
+
funcMap: {},
|
|
1255
|
+
callbackMap: {},
|
|
1256
|
+
listenerMap: {},
|
|
1257
|
+
listenerMapByEvent: {},
|
|
1258
|
+
deprecatedMap: {},
|
|
1259
|
+
Options: {
|
|
1260
|
+
ConvertResponseObjectKey : "__maf_convert_response_object"
|
|
1261
|
+
},
|
|
1262
|
+
listenerInvokeFromNative: function (key, param) {
|
|
1263
|
+
helper.dealNativeEventCallback({
|
|
1264
|
+
key: key,
|
|
1265
|
+
param: param,
|
|
1266
|
+
});
|
|
1267
|
+
},
|
|
1268
|
+
listenerInvokeFromNativeInWindow: function(key, param) {
|
|
1269
|
+
o.log("param=" + param);
|
|
1270
|
+
var func = o.listenerMap[key];
|
|
1271
|
+
if (func == undefined) {
|
|
1272
|
+
o.log("call back func not found");
|
|
1273
|
+
o.listenerMap[key] = null;
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
func.callback(param);
|
|
1277
|
+
},
|
|
1278
|
+
callBackFromNative: function (key, param) {
|
|
1279
|
+
o.log("param=" + param);
|
|
1280
|
+
var callbackObject = o.funcMap[key];
|
|
1281
|
+
var func = callbackObject.callback;
|
|
1282
|
+
if (func == undefined) {
|
|
1283
|
+
o.log("call back func not found");
|
|
1284
|
+
o.funcMap[key] = null;
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
func.call(callbackObject.scope, param);
|
|
1288
|
+
o.funcMap[key] = null;
|
|
1289
|
+
},
|
|
1290
|
+
addListenerFunc: function (eventName, func, isNewInterface, scope) {
|
|
1291
|
+
var key = o.randomkey(10);
|
|
1292
|
+
var listenerEvalString = null;
|
|
1293
|
+
if (isNewInterface) {
|
|
1294
|
+
listenerEvalString = "Bridge.listenerInvokeFromNative('" + key + "',==param==)";
|
|
1295
|
+
} else {
|
|
1296
|
+
listenerEvalString = "Bridge.listenerInvokeFromNative('" + key + "','==param==')";
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
var object = {
|
|
1300
|
+
key: key,
|
|
1301
|
+
evalString: listenerEvalString,
|
|
1302
|
+
callback: func,
|
|
1303
|
+
scope: scope == undefined ? window : scope
|
|
1304
|
+
}
|
|
1305
|
+
o.listenerMap[key] = object;
|
|
1306
|
+
|
|
1307
|
+
return object;
|
|
1308
|
+
},
|
|
1309
|
+
removeListenerFunc: function (key) {
|
|
1310
|
+
if (null === key || typeof key == "undefined") {
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
var func = o.listenerMap[key];
|
|
1314
|
+
if (null !== func) {
|
|
1315
|
+
o.listenerMap[key] = null;
|
|
1316
|
+
delete o.listenerMap[key];
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
randomkey: function (l) {
|
|
1320
|
+
var x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
|
|
1321
|
+
var tmp = "";
|
|
1322
|
+
var timestamp = new Date().getTime();
|
|
1323
|
+
for (var i = 0; i < l; i++) {
|
|
1324
|
+
tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
|
|
1325
|
+
}
|
|
1326
|
+
return timestamp + tmp;
|
|
1327
|
+
},
|
|
1328
|
+
getEntryNameFromOldClassName: function (className) {
|
|
1329
|
+
var classNameArray = className.split(".");
|
|
1330
|
+
if (classNameArray.length > 0) {
|
|
1331
|
+
return classNameArray[classNameArray.length - 1];
|
|
1332
|
+
} else {
|
|
1333
|
+
return className;
|
|
1334
|
+
}
|
|
1335
|
+
},
|
|
1336
|
+
callbackSuccess: function (callbackId, args) {
|
|
1337
|
+
o.log("call back success ====");
|
|
1338
|
+
o.doCallback(helper.INVOKER_STATE_FULLFILLED, callbackId, args);
|
|
1339
|
+
},
|
|
1340
|
+
callbackFail: function (callbackId, args) {
|
|
1341
|
+
o.log("call back fail ====");
|
|
1342
|
+
o.doCallback(helper.INVOKER_STATE_REJECTED, callbackId, args);
|
|
1343
|
+
},
|
|
1344
|
+
callbackListen: function (callbackId, args) {
|
|
1345
|
+
o.log("call back listen ====");
|
|
1346
|
+
o.doCallback(helper.INVOKER_STATE_PROGRESSING, callbackId, args);
|
|
1347
|
+
},
|
|
1348
|
+
|
|
1349
|
+
doCallback: function(type, callbackId, args) {
|
|
1350
|
+
helper.dealNativeMethodCallback({
|
|
1351
|
+
type: type,
|
|
1352
|
+
callbackId: callbackId,
|
|
1353
|
+
args: args,
|
|
1354
|
+
});
|
|
1355
|
+
},
|
|
1356
|
+
|
|
1357
|
+
doCurrentWindowCallback: function (type, callbackId, args) {
|
|
1358
|
+
var callBack = o.callbackMap[callbackId];
|
|
1359
|
+
if (callBack) {
|
|
1360
|
+
var result = o.__processResponseObject(args, callBack.options);
|
|
1361
|
+
if (type == helper.INVOKER_STATE_FULLFILLED) {
|
|
1362
|
+
callBack.success && callBack.success.call(null, result);
|
|
1363
|
+
o.callbackMap[callbackId] = null;
|
|
1364
|
+
} else if (type == helper.INVOKER_STATE_REJECTED) {
|
|
1365
|
+
callBack.fail && callBack.fail.call(null, result);
|
|
1366
|
+
o.callbackMap[callbackId] = null;
|
|
1367
|
+
} else if (type == helper.INVOKER_STATE_PROGRESSING) {
|
|
1368
|
+
callBack.listener && callBack.listener.call(null, result);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
},
|
|
1372
|
+
loadNative: function (type, href) {
|
|
1373
|
+
o.exec('apkManager', 'loadApk', args);
|
|
1374
|
+
},
|
|
1375
|
+
import: function (entryName) {
|
|
1376
|
+
var success;
|
|
1377
|
+
if (o.runOnAndroid41()) {
|
|
1378
|
+
success = prompt(JSON.stringify({
|
|
1379
|
+
type: 'importJsSdk',
|
|
1380
|
+
entry: entryName
|
|
1381
|
+
}));
|
|
1382
|
+
} else {
|
|
1383
|
+
success = NativeInterface().importJsSdk(entryName);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
if (success === 'false') {
|
|
1387
|
+
throw new Error('import failed : ' + entryName);
|
|
1388
|
+
}
|
|
1389
|
+
},
|
|
1390
|
+
//该 API 只提供 promise 用法
|
|
1391
|
+
apisAvailable: function (param) {
|
|
1392
|
+
var deferred = Q.defer();
|
|
1393
|
+
if (!param["entries"] || param["entries"].constructor != Array || param["entries"].length == 0) {
|
|
1394
|
+
throw new Error("apisAvailable check failed: entries is not available");
|
|
1395
|
+
}
|
|
1396
|
+
if (o.useiOSWKWebView()) {
|
|
1397
|
+
var asyncWrapper = new WKAsyncWrapper();
|
|
1398
|
+
asyncWrapper.returnStringCallBack = function (resString) {
|
|
1399
|
+
deferred.resolve(JSON.parse(resString));
|
|
1400
|
+
};
|
|
1401
|
+
asyncWrapper.apisAvailable(JSON.stringify(param));
|
|
1402
|
+
} else {
|
|
1403
|
+
var resString = NativeInterface().apisAvailable(JSON.stringify(param));
|
|
1404
|
+
deferred.resolve(JSON.parse(resString));
|
|
1405
|
+
}
|
|
1406
|
+
return deferred.promise;
|
|
1407
|
+
},
|
|
1408
|
+
require: function (entryName) {
|
|
1409
|
+
if (o.entry[entryName]) {
|
|
1410
|
+
return o.entry[entryName];
|
|
1411
|
+
} else if (o.classEntry[entryName]) {
|
|
1412
|
+
return o.classEntry[entryName];
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
if (o.useiOSWKWebView()) {
|
|
1416
|
+
var wrapper = new WKRequireWrapper()
|
|
1417
|
+
wrapper.requireName = entryName
|
|
1418
|
+
return wrapper
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
var jsEntry;
|
|
1422
|
+
if (o.runOnAndroid41()) {
|
|
1423
|
+
jsEntry = prompt(JSON.stringify({
|
|
1424
|
+
type: 'require',
|
|
1425
|
+
entry: entryName
|
|
1426
|
+
}));
|
|
1427
|
+
} else {
|
|
1428
|
+
jsEntry = NativeInterface().require(entryName);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
if (jsEntry.length > 0) {
|
|
1432
|
+
eval(jsEntry);
|
|
1433
|
+
o.__processDeprecated(entryName);
|
|
1434
|
+
if (o.entry[entryName]) {
|
|
1435
|
+
return o.entry[entryName];
|
|
1436
|
+
} else if (o.classEntry[entryName]) {
|
|
1437
|
+
return o.classEntry[entryName];
|
|
1438
|
+
}
|
|
1439
|
+
} else {
|
|
1440
|
+
o.log(entryName + " not found !");
|
|
1441
|
+
}
|
|
1442
|
+
},
|
|
1443
|
+
newInstance: function (param) {
|
|
1444
|
+
var jsEntry;
|
|
1445
|
+
|
|
1446
|
+
if (o.runOnAndroid41()) {
|
|
1447
|
+
jsEntry = prompt(JSON.stringify({
|
|
1448
|
+
type: 'newInstance',
|
|
1449
|
+
params: JSON.stringify(param)
|
|
1450
|
+
}));
|
|
1451
|
+
} else if (o.useiOSWKWebView()) {
|
|
1452
|
+
var wrapper = new WKRequireWrapper()
|
|
1453
|
+
wrapper.isObject = false
|
|
1454
|
+
wrapper.classParam = param
|
|
1455
|
+
return wrapper
|
|
1456
|
+
} else {
|
|
1457
|
+
jsEntry = NativeInterface().newInstance(JSON.stringify(param));
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
eval(jsEntry);
|
|
1461
|
+
var lastInstanceID = Bridge.lastInstanceID;
|
|
1462
|
+
var object = Bridge.entry[lastInstanceID];
|
|
1463
|
+
Bridge.lastInstanceID = null;
|
|
1464
|
+
return object;
|
|
1465
|
+
},
|
|
1466
|
+
deleteInstance: function (entry) {
|
|
1467
|
+
var jsString;
|
|
1468
|
+
|
|
1469
|
+
if (o.runOnAndroid41()) {
|
|
1470
|
+
jsString = prompt(JSON.stringify({
|
|
1471
|
+
type: 'deleteInstance',
|
|
1472
|
+
entryName: entry
|
|
1473
|
+
}));
|
|
1474
|
+
} else {
|
|
1475
|
+
jsString = NativeInterface().deleteInstance(entry);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
eval(jsString);
|
|
1479
|
+
},
|
|
1480
|
+
sendMessageToNative: function (bizCode, param) {
|
|
1481
|
+
var __args = o.__processArgs(param);
|
|
1482
|
+
console.log("NativeInterface sendMessageToNative: code = " + bizCode, +"param = " + param);
|
|
1483
|
+
if (o.runOnAndroid41()) {
|
|
1484
|
+
prompt(JSON.stringify({
|
|
1485
|
+
type: 'sendMessageToNative',
|
|
1486
|
+
eventName: bizCode,
|
|
1487
|
+
callback: JSON.stringify(__args)
|
|
1488
|
+
}));
|
|
1489
|
+
} else {
|
|
1490
|
+
console.log("addListener");
|
|
1491
|
+
NativeInterface().sendMessageToNative(bizCode, JSON.stringify(__args)); // Android Only: allow js send param to Native
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
__processArgs: function (args) {
|
|
1495
|
+
|
|
1496
|
+
var __args = args;
|
|
1497
|
+
if (null === __args || typeof __args == "undefined") {
|
|
1498
|
+
__args = {};
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
if ("object" == typeof __args && !__args.hasOwnProperty("_maf_url")) {
|
|
1502
|
+
__args["_maf_url"] = window.location.href;
|
|
1503
|
+
}
|
|
1504
|
+
return __args;
|
|
1505
|
+
},
|
|
1506
|
+
__processDeprecated: function (entryName, method) {
|
|
1507
|
+
if (null === entryName || typeof entryName == "undefined") {
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
var deprecated = o.deprecatedMap[entryName];
|
|
1512
|
+
if (null === deprecated || typeof deprecated == "undefined") {
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
var isClassDeprecated = true;
|
|
1517
|
+
var deprecatedObject = deprecated["*"];
|
|
1518
|
+
if (null === deprecatedObject || typeof deprecatedObject == "undefined") {
|
|
1519
|
+
deprecatedObject = deprecated[method];
|
|
1520
|
+
isClassDeprecated = false;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
if (null === deprecatedObject || typeof deprecatedObject == "undefined") {
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
var deprecatedVersion = deprecatedObject["version"];
|
|
1528
|
+
var deprecatedMessage = deprecatedObject["message"];
|
|
1529
|
+
|
|
1530
|
+
var warningString = (isClassDeprecated ? ("Class " + entryName) : ("Method " + entryName + ":" + method)) + " deprecated";
|
|
1531
|
+
if (deprecatedVersion) {
|
|
1532
|
+
warningString = warningString + " at " + deprecatedVersion;
|
|
1533
|
+
}
|
|
1534
|
+
if (deprecatedMessage) {
|
|
1535
|
+
warningString = warningString + ", " + deprecatedMessage;
|
|
1536
|
+
}
|
|
1537
|
+
o.log(warningString);
|
|
1538
|
+
console.warn(warningString);
|
|
1539
|
+
},
|
|
1540
|
+
__processOptions: function (origin) {
|
|
1541
|
+
var __options = origin
|
|
1542
|
+
if (null === __options || typeof __options == "undefined") {
|
|
1543
|
+
__options = {};
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
if ("object" == typeof __options && !__options.hasOwnProperty(o.Options.ConvertResponseObjectKey)) {
|
|
1547
|
+
__options[o.Options.ConvertResponseObjectKey] = true;
|
|
1548
|
+
}
|
|
1549
|
+
return __options;
|
|
1550
|
+
},
|
|
1551
|
+
__processResponseObject: function (origin, options) {
|
|
1552
|
+
var finalResult = origin;
|
|
1553
|
+
var convertResponseObjectValue = options[o.Options.ConvertResponseObjectKey]
|
|
1554
|
+
if (null !== convertResponseObjectValue && convertResponseObjectValue) {
|
|
1555
|
+
try {
|
|
1556
|
+
finalResult = JSON.parse(origin);
|
|
1557
|
+
} catch (e) {
|
|
1558
|
+
finalResult = origin;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return finalResult;
|
|
1562
|
+
},
|
|
1563
|
+
//该方法提供给外面Override
|
|
1564
|
+
__isTakeKeyBack: function () {
|
|
1565
|
+
return false;
|
|
1566
|
+
},
|
|
1567
|
+
|
|
1568
|
+
//该方法给Webview使用,外面不要Override
|
|
1569
|
+
__isJsTakeKeyBack: function () {
|
|
1570
|
+
var isTake = o.__isTakeKeyBack();
|
|
1571
|
+
if (isTake) {
|
|
1572
|
+
console.warn("返回键现在由Js处理!");
|
|
1573
|
+
} else {
|
|
1574
|
+
console.log("返回键仍然由Webview处理!");
|
|
1575
|
+
}
|
|
1576
|
+
//传值回Webview
|
|
1577
|
+
var appFactory = o.require('sdp.appfactory');
|
|
1578
|
+
appFactory.isJsTakeKeyBack({
|
|
1579
|
+
"isJsTakeKeyBack": isTake
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
return o;
|
|
1584
|
+
};
|
|
1585
|
+
|
|
1586
|
+
! function (a) {
|
|
1587
|
+
a();
|
|
1588
|
+
}(function() {
|
|
1589
|
+
console.warn("Use JsBridge by online! Please migrate to the new resolution. Visit: http://reference.doc.101.com/appfactory/design/design/client/jssdk-import-optmize-solution/jssdk-import-optmize-solution.html");
|
|
1590
|
+
var userAgent = navigator.userAgent;
|
|
1591
|
+
if (userAgent.indexOf('SmartCanWebView') < 0) {
|
|
1592
|
+
console.error("Not running on SmartCanWebView, it should not be right. A best practice can be referenced, visit: http://reference.doc.101.com/appfactory/userguide/light/h5/use-js-sdk.html");
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
window.Bridge = loadJsBridge();
|
|
1597
|
+
window.Bridge.init();
|
|
1598
|
+
window.Bridge.require('webcontainer');
|
|
1599
|
+
window.Bridge.require('sdp.webcontainer');
|
|
1600
|
+
window.Bridge.require('sys');
|
|
1601
|
+
window.Bridge.require('sdp.sys');
|
|
1602
|
+
});
|