windmill-module-api
Advanced tools
Comparing version 0.3.0 to 0.3.1
401
index.js
@@ -1,2 +0,2 @@ | ||
/* windmill-module-api (0.3.0), build at 2019-01-14 14:07. */ | ||
/* windmill-module-api (0.3.1), build at 2019-01-22 10:46. */ | ||
@@ -251,15 +251,13 @@ (function (global, factory) { | ||
if (sync && typeof runtime.$callSync === 'function') { | ||
return function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return function (params, context, modifier) { | ||
if ( modifier === void 0 ) modifier = {}; | ||
return runtime.$callSync.apply(runtime, [ methodPath ].concat( args )); | ||
return runtime.$callSync(methodPath, params, context, modifier); | ||
}; | ||
} | ||
else if (!sync && typeof runtime.$call === 'function') { | ||
return function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return function (params, success, fail, context, modifier) { | ||
if ( modifier === void 0 ) modifier = {}; | ||
return runtime.$call.apply(runtime, [ methodPath ].concat( args )); | ||
return runtime.$call(methodPath, params, success, fail, context, modifier); | ||
}; | ||
@@ -313,5 +311,5 @@ } | ||
} | ||
var modifier = {}; | ||
/** | ||
* 真实调用原生模块(异步) | ||
* @param host 模块调用的环境,仅在插件环境中有意义 | ||
* @param methodPath 模块调用的字符串,形如 "modal.toast" | ||
@@ -323,3 +321,3 @@ * @param rawOptions 三方 API 对外透出的 options | ||
*/ | ||
function callModule(methodPath, rawOptions, options, onSuccess, onFail) { | ||
function callModule(host, methodPath, rawOptions, options, onSuccess, onFail) { | ||
if ( rawOptions === void 0 ) rawOptions = {}; | ||
@@ -331,2 +329,4 @@ if ( options === void 0 ) options = rawOptions; | ||
var method = getMethod(methodPath); | ||
var context = host && typeof host.getContext === 'function' ? host.getContext() : {}; | ||
var modifier = host && typeof host.getModifier === 'function' ? host.getModifier() : {}; | ||
var isComplete = false; | ||
@@ -347,22 +347,25 @@ return method(omitMethod(options), function (result) { | ||
} | ||
}, modifier); | ||
}, context, modifier); | ||
} | ||
/** | ||
* 真实调用原生模块(同步) | ||
* @param host 模块调用的环境,仅在插件环境中有意义 | ||
* @param methodPath 模块调用的字符串,形如 "modal.toast" | ||
* @param options 传递给原生模块的 options | ||
*/ | ||
function callModuleSync(methodPath, options) { | ||
function callModuleSync(host, methodPath, options) { | ||
if ( options === void 0 ) options = {}; | ||
var method = getMethod(methodPath, true); | ||
return method(omitMethod(options), modifier); | ||
var context = host && typeof host.getContext === 'function' ? host.getContext() : {}; | ||
var modifier = host && typeof host.getModifier === 'function' ? host.getModifier() : {}; | ||
return method(omitMethod(options), context, modifier); | ||
} | ||
function showActionSheet(options) { | ||
callModule('actionSheet.showActionSheet', options); | ||
callModule(this, 'actionSheet.showActionSheet', options); | ||
} | ||
function chooseAddress(options) { | ||
callModule('address.choose', options); | ||
callModule(this, 'address.choose', options); | ||
} | ||
@@ -374,3 +377,3 @@ | ||
options = preprocess('tradePay', options); | ||
callModule('alipay.tradePay', options); | ||
callModule(this, 'alipay.tradePay', options); | ||
} | ||
@@ -432,6 +435,7 @@ | ||
var InnerAudioConext = function InnerAudioConext(options) { | ||
var InnerAudioConext = function InnerAudioConext(host, options) { | ||
if ( options === void 0 ) options = {}; | ||
this._instanceId = uniqueId(); | ||
this._host = host; | ||
this._emitter = new EventEmitter(); | ||
@@ -443,3 +447,3 @@ this.src = options.src; | ||
callModule('audioPlayer.playVoice', options, { | ||
callModule(this._host, 'audioPlayer.playVoice', options, { | ||
src: this.src, | ||
@@ -465,3 +469,3 @@ instanceId: this._instanceId | ||
callModule('audioPlayer.pauseVoice', options, { | ||
callModule(this._host, 'audioPlayer.pauseVoice', options, { | ||
instanceId: this._instanceId | ||
@@ -479,3 +483,3 @@ }, function (res) { | ||
callModule('audioPlayer.stopVoice', options, { | ||
callModule(this._host, 'audioPlayer.stopVoice', options, { | ||
instanceId: this._instanceId | ||
@@ -516,7 +520,8 @@ }, function (res) { | ||
function createInnerAudioContext(options) { | ||
return new InnerAudioConext(options); | ||
return new InnerAudioConext(this, options); | ||
} | ||
var defaultExport = function defaultExport() { | ||
var defaultExport = function defaultExport(host) { | ||
this._startEmitted = false; // 开始回调,Native 会调多次,封装后只调一次 | ||
this._host = host; | ||
this._emitter = new EventEmitter(); | ||
@@ -529,3 +534,3 @@ }; | ||
this._startEmitted = false; | ||
callModule('audioRecord.startRecord', options, { | ||
callModule(this._host, 'audioRecord.startRecord', options, { | ||
maxDuration: options.duration / 1000, | ||
@@ -558,3 +563,3 @@ minDuration: 1 // 对前端隐藏这个入参,传一个默认值 | ||
callModule('audioRecord.stopRecord', options, options, function (res) { | ||
callModule(this._host, 'audioRecord.stopRecord', options, options, function (res) { | ||
this$1._emitter.emit('stop', { | ||
@@ -572,3 +577,3 @@ tempFilePath: res.apFilePath, | ||
// cancel (options: PlainObject = {}) { | ||
// callModule('audioRecord.cancelRecord', options, options, res => { | ||
// callModule(this._host, 'audioRecord.cancelRecord', options, options, res => { | ||
// this._emitter.emit('cancel', res) | ||
@@ -607,3 +612,3 @@ // return res | ||
if (!recordManger) { | ||
recordManger = new defaultExport(); | ||
recordManger = new defaultExport(this); | ||
} | ||
@@ -652,7 +657,7 @@ return recordManger; | ||
function openChat(options) { | ||
callModule('chat.open', options); | ||
callModule(this, 'chat.open', options); | ||
} | ||
function getClipboard(options) { | ||
callModule('clipboard.readText', options); | ||
callModule(this, 'clipboard.readText', options); | ||
} | ||
@@ -662,3 +667,3 @@ function setClipboard(options) { | ||
callModule('clipboard.writeText', options, { | ||
callModule(this, 'clipboard.writeText', options, { | ||
text: options.text | ||
@@ -670,3 +675,3 @@ }); | ||
options = preprocess('getNetworkType', options); | ||
callModule('connection.getType', options, {}, function (res) { | ||
callModule(this, 'connection.getType', options, {}, function (res) { | ||
var type = res.type || ''; | ||
@@ -696,3 +701,3 @@ return { | ||
options = preprocess('choosePhoneContact', options); | ||
callModule('contact.choosePhoneContact', options, {}, function (res) { | ||
callModule(this, 'contact.choosePhoneContact', options, {}, function (res) { | ||
return { | ||
@@ -706,3 +711,3 @@ name: res.name, | ||
function watchShake(options) { | ||
callModule('device.onShake', options, { | ||
callModule(this, 'device.onShake', options, { | ||
on: true | ||
@@ -712,9 +717,9 @@ }); | ||
function vibrate(options) { | ||
callModule('device.vibrate', options); | ||
callModule(this, 'device.vibrate', options); | ||
} | ||
function vibrateShort(options) { | ||
callModule('device.vibrateShort', options); | ||
callModule(this, 'device.vibrateShort', options); | ||
} | ||
function onUserCaptureScreen(callback) { | ||
callModule('device.onUserCaptureScreen', { | ||
callModule(this, 'device.onUserCaptureScreen', { | ||
success: callback | ||
@@ -724,6 +729,6 @@ }); | ||
function offUserCaptureScreen() { | ||
callModule('device.offUserCaptureScreen'); | ||
callModule(this, 'device.offUserCaptureScreen'); | ||
} | ||
function scan(options) { | ||
callModule('device.scan', options); | ||
callModule(this, 'device.scan', options); | ||
} | ||
@@ -741,3 +746,3 @@ | ||
function saveFile(options) { | ||
return callModule('file.saveFile', options, { | ||
return callModule(this, 'file.saveFile', options, { | ||
filePath: getPath(options) | ||
@@ -749,3 +754,3 @@ }, function (result) { return ({ | ||
function getFileInfo(options) { | ||
return callModule('file.getFileInfo', options, { | ||
return callModule(this, 'file.getFileInfo', options, { | ||
filePath: getPath(options) | ||
@@ -757,3 +762,3 @@ }, function (result) { return ({ | ||
function getSavedFileInfo(options) { | ||
return callModule('file.getFileInfo', options, { | ||
return callModule(this, 'file.getFileInfo', options, { | ||
filePath: getPath(options) | ||
@@ -763,3 +768,3 @@ }); | ||
function getSavedFileList(options) { | ||
return callModule('file.getFileList', options, {}, function (result) { | ||
return callModule(this, 'file.getFileList', options, {}, function (result) { | ||
var fileList = []; | ||
@@ -777,3 +782,3 @@ if (isArray(result.fileList)) { | ||
function removeSavedFile(options) { | ||
return callModule('file.removeFile', options, { | ||
return callModule(this, 'file.removeFile', options, { | ||
filePath: getPath(options) | ||
@@ -784,19 +789,19 @@ }); | ||
function chooseImage(options) { | ||
callModule('image.chooseImage', options); | ||
callModule(this, 'image.chooseImage', options); | ||
} | ||
function compressImage(options) { | ||
callModule('image.compressImage', options); | ||
callModule(this, 'image.compressImage', options); | ||
} | ||
function previewImage(options) { | ||
callModule('image.previewImage', options); | ||
callModule(this, 'image.previewImage', options); | ||
} | ||
function saveImage(options) { | ||
callModule('image.saveImage', options); | ||
callModule(this, 'image.saveImage', options); | ||
} | ||
function getImageInfo(options) { | ||
callModule('image.getImageInfo', options); | ||
callModule(this, 'image.getImageInfo', options); | ||
} | ||
function hideKeyboard() { | ||
callModule('keyboard.hideKeyboard'); | ||
callModule(this, 'keyboard.hideKeyboard'); | ||
} | ||
@@ -806,3 +811,3 @@ | ||
var type = options.type; | ||
callModule('location.getLocation', options, options, function (res) { | ||
callModule(this, 'location.getLocation', options, options, function (res) { | ||
var result = { | ||
@@ -866,6 +871,6 @@ longitude: res.coords.longitude, | ||
function setBackgroundImage(options) { | ||
callModule('miniApp.setWebViewBackgroundImage', options); | ||
callModule(this, 'miniApp.setWebViewBackgroundImage', options); | ||
} | ||
function removeBackgroundImage(options) { | ||
callModule('miniApp.setWebViewBackgroundImage', options, { | ||
callModule(this, 'miniApp.setWebViewBackgroundImage', options, { | ||
color: '', | ||
@@ -876,6 +881,6 @@ imgUrl: '' | ||
function setViewTop(options) { | ||
callModule('miniApp.setWebViewTop', options); | ||
callModule(this, 'miniApp.setWebViewTop', options); | ||
} | ||
function setCanPullDown(options) { | ||
callModule('miniApp.setWebViewParams', options); | ||
callModule(this, 'miniApp.setWebViewParams', options); | ||
} | ||
@@ -889,3 +894,3 @@ function setShareAppMessage(options) { | ||
var extraParams = options.extraParams; | ||
callModule('miniApp.setAppShareInfo', options, { | ||
callModule(this, 'miniApp.setAppShareInfo', options, { | ||
title: title, | ||
@@ -898,15 +903,15 @@ description: desc, | ||
function startPullDownRefresh(options) { | ||
callModule('miniApp.startPullDownRefresh', options); | ||
callModule(this, 'miniApp.startPullDownRefresh', options); | ||
} | ||
function stopPullDownRefresh(options) { | ||
callModule('miniApp.stopPullDownRefresh', options); | ||
callModule(this, 'miniApp.stopPullDownRefresh', options); | ||
} | ||
function setBackgroundTextStyle(options) { | ||
callModule('miniApp.setBackgroundTextStyle', options); | ||
callModule(this, 'miniApp.setBackgroundTextStyle', options); | ||
} | ||
function setBackgroundColor(options) { | ||
callModule('miniApp.setBackgroundColor', options); | ||
callModule(this, 'miniApp.setBackgroundColor', options); | ||
} | ||
function reLaunch(options) { | ||
callModule('miniApp.reLaunch', options); | ||
callModule(this, 'miniApp.reLaunch', options); | ||
} | ||
@@ -925,3 +930,3 @@ | ||
callModule('modal.alert', options, { | ||
callModule(this, 'modal.alert', options, { | ||
title: options.title, | ||
@@ -937,3 +942,3 @@ message: options.content, | ||
var cancelButtonText = options.cancelButtonText || '取消'; | ||
callModule('modal.confirm', options, { | ||
callModule(this, 'modal.confirm', options, { | ||
title: options.title, | ||
@@ -955,3 +960,3 @@ message: options.content, | ||
} | ||
callModule('modal.toast', options, { | ||
callModule(this, 'modal.toast', options, { | ||
message: options.content, | ||
@@ -962,16 +967,16 @@ duration: options.duration / 1000 | ||
function hideToast(options) { | ||
callModule('modal.hideToast', options); | ||
callModule(this, 'modal.hideToast', options); | ||
} | ||
function prompt(options) { | ||
callModule('modal.prompt', options); | ||
callModule(this, 'modal.prompt', options); | ||
} | ||
function showLoading(options) { | ||
callModule('modal.showLoading', options); | ||
callModule(this, 'modal.showLoading', options); | ||
} | ||
function hideLoading(options) { | ||
callModule('modal.hideLoading', options); | ||
callModule(this, 'modal.hideLoading', options); | ||
} | ||
function sendMtop(options) { | ||
callModule('sendMtop.request', preprocess('sendMtop', options)); | ||
callModule(this, 'sendMtop.request', preprocess('sendMtop', options)); | ||
} | ||
@@ -1061,3 +1066,3 @@ | ||
var url = resolvePathname(options.url, basePath) || ''; | ||
callModule('navigator.push', options, { | ||
callModule(this, 'navigator.push', options, { | ||
url: formatPath(url) | ||
@@ -1067,3 +1072,3 @@ }); | ||
function navigateBack(options) { | ||
callModule('navigator.pop', preprocess('navigateBack', options)); | ||
callModule(this, 'navigator.pop', preprocess('navigateBack', options)); | ||
} | ||
@@ -1074,3 +1079,3 @@ function redirectTo(options) { | ||
options = preprocess('redirectTo', options); | ||
callModule('navigator.redirectTo', options, { | ||
callModule(this, 'navigator.redirectTo', options, { | ||
url: formatPath(options.url) | ||
@@ -1083,3 +1088,3 @@ }); | ||
options = preprocess('switchTab', options); | ||
callModule('navigator.switchTab', options, { | ||
callModule(this, 'navigator.switchTab', options, { | ||
url: formatPath(options.url) | ||
@@ -1089,10 +1094,10 @@ }); | ||
function navigateToMiniProgram(options) { | ||
callModule('navigator.navigateToMiniProgram', options); | ||
callModule(this, 'navigator.navigateToMiniProgram', options); | ||
} | ||
function navigateBackMiniProgram(options) { | ||
callModule('navigator.navigateBackMiniProgram', options); | ||
callModule(this, 'navigator.navigateBackMiniProgram', options); | ||
} | ||
// only for PC | ||
function onPageNotify(callback) { | ||
callModule('navigator.pc_onPageNotify', { | ||
callModule(this, 'navigator.pc_onPageNotify', { | ||
success: callback | ||
@@ -1103,20 +1108,20 @@ }); | ||
function offPageNotify() { | ||
callModule('navigator.pc_offPageNotify'); | ||
callModule(this, 'navigator.pc_offPageNotify'); | ||
} | ||
// only for PC | ||
function setPageNotifyConfig(options) { | ||
callModule('navigator.pc_setPageNotifyConfig', options); | ||
callModule(this, 'navigator.pc_setPageNotifyConfig', options); | ||
} | ||
function getBackStack(options) { | ||
callModule('navigator.getBackStack', options); | ||
callModule(this, 'navigator.getBackStack', options); | ||
} | ||
function popToHome(options) { | ||
callModule('navigator.popToHome', options); | ||
callModule(this, 'navigator.popToHome', options); | ||
} | ||
function setNavigationBar(options) { | ||
callModule('navigatorBar.setNavigationBar', options); | ||
callModule(this, 'navigatorBar.setNavigationBar', options); | ||
} | ||
function getStatusBarHeight(options) { | ||
callModule('navigatorBar.getStatusBarHeight', options, options, function (res) { | ||
callModule(this, 'navigatorBar.getStatusBarHeight', options, options, function (res) { | ||
return { | ||
@@ -1128,3 +1133,3 @@ height: parseInt(res.data) | ||
function getNavigationBarHeight(options) { | ||
callModule('navigatorBar.getHeight', options, options, function (res) { | ||
callModule(this, 'navigatorBar.getHeight', options, options, function (res) { | ||
return { | ||
@@ -1136,18 +1141,18 @@ height: parseInt(res.data) | ||
function showNavigationBarLoading(options) { | ||
callModule('navigatorBar.showNavigationBarLoading', options); | ||
callModule(this, 'navigatorBar.showNavigationBarLoading', options); | ||
} | ||
function hideNavigationBarLoading(options) { | ||
callModule('navigatorBar.hideNavigationBarLoading', options); | ||
callModule(this, 'navigatorBar.hideNavigationBarLoading', options); | ||
} | ||
function setNavigationBarDrawer(options) { | ||
callModule('navigatorBar.setDrawer', options); | ||
callModule(this, 'navigatorBar.setDrawer', options); | ||
} | ||
function openNavigationBarDrawer(options) { | ||
callModule('navigatorBar.openDrawer', options); | ||
callModule(this, 'navigatorBar.openDrawer', options); | ||
} | ||
function closeNavigationBarDrawer(options) { | ||
callModule('navigatorBar.closeDrawer', options); | ||
callModule(this, 'navigatorBar.closeDrawer', options); | ||
} | ||
function setNavigationBarSheet(options) { | ||
callModule('navigatorBar.setActionSheet', options); | ||
callModule(this, 'navigatorBar.setActionSheet', options); | ||
} | ||
@@ -1176,3 +1181,3 @@ | ||
} | ||
callModule('network.request', options, { | ||
callModule(this, 'network.request', options, { | ||
method: method, | ||
@@ -1192,6 +1197,6 @@ url: options.url, | ||
function uploadFile(options) { | ||
callModule('network.uploadFile', options); | ||
callModule(this, 'network.uploadFile', options); | ||
} | ||
function downloadFile(options) { | ||
callModule('network.downloadFile', options); | ||
callModule(this, 'network.downloadFile', options); | ||
} | ||
@@ -1202,3 +1207,3 @@ | ||
callModule('phone.makePhoneCall', options, { | ||
callModule(this, 'phone.makePhoneCall', options, { | ||
phoneNumber: options.number | ||
@@ -1229,3 +1234,3 @@ }); | ||
} | ||
callModule('picker.chooseCity', options, options, function (res) { | ||
callModule(this, 'picker.chooseCity', options, options, function (res) { | ||
return { | ||
@@ -1240,3 +1245,3 @@ city: res.cityName, | ||
callModule('picker.pickDate', options, { | ||
callModule(this, 'picker.pickDate', options, { | ||
format: options.format, | ||
@@ -1254,3 +1259,3 @@ value: options.currentDate, | ||
callModule('screen.setBrightness', options, { | ||
callModule(this, 'screen.setBrightness', options, { | ||
brightness: options.brightness | ||
@@ -1260,3 +1265,3 @@ }); | ||
function getScreenBrightness(options) { | ||
callModule('screen.getScreenBrightness', options, options, function (res) { | ||
callModule(this, 'screen.getScreenBrightness', options, options, function (res) { | ||
return { | ||
@@ -1270,3 +1275,3 @@ brightness: res.value | ||
callModule('screen.setAlwaysOn', options, { | ||
callModule(this, 'screen.setAlwaysOn', options, { | ||
on: options.keepScreenOn | ||
@@ -1277,10 +1282,10 @@ }); | ||
function shareTinyAppMsg(options) { | ||
callModule('share.doShare', options); | ||
callModule(this, 'share.doShare', options); | ||
} | ||
function showSku(options) { | ||
callModule('sku.show', options); | ||
callModule(this, 'sku.show', options); | ||
} | ||
function hideSku(options) { | ||
callModule('sku.hide', options); | ||
callModule(this, 'sku.hide', options); | ||
} | ||
@@ -1294,3 +1299,3 @@ | ||
callModule('storage.setItem', options, { | ||
callModule(this, 'storage.setItem', options, { | ||
key: options.key, | ||
@@ -1301,3 +1306,3 @@ value: proccessSetStorageValue(options) | ||
function setStorageSync(options) { | ||
return callModuleSync('storage.setItemSync', { | ||
return callModuleSync(this, 'storage.setItemSync', { | ||
key: options.key, | ||
@@ -1320,6 +1325,6 @@ value: proccessSetStorageValue(options) | ||
callModule('storage.getItem', options, options, proccessGetStorageRes); | ||
callModule(this, 'storage.getItem', options, options, proccessGetStorageRes); | ||
} | ||
function getStorageSync(options) { | ||
return proccessGetStorageRes(callModuleSync('storage.getItemSync', options)); | ||
return proccessGetStorageRes(callModuleSync(this, 'storage.getItemSync', options)); | ||
} | ||
@@ -1329,3 +1334,3 @@ function removeStorage(options) { | ||
callModule('storage.removeItem', options); | ||
callModule(this, 'storage.removeItem', options); | ||
} | ||
@@ -1335,15 +1340,15 @@ function removeStorageSync(options) { | ||
return callModuleSync('storage.removeItemSync', options); | ||
return callModuleSync(this, 'storage.removeItemSync', options); | ||
} | ||
function clearStorage(options) { | ||
callModule('storage.clearStorage', options); | ||
callModule(this, 'storage.clearStorage', options); | ||
} | ||
function clearStorageSync(options) { | ||
return callModuleSync('storage.clearStorageSync', options); | ||
return callModuleSync(this, 'storage.clearStorageSync', options); | ||
} | ||
function getStorageInfo(options) { | ||
callModule('storage.getStorageInfo', options); | ||
callModule(this, 'storage.getStorageInfo', options); | ||
} | ||
function getStorageInfoSync(options) { | ||
return callModuleSync('storage.getStorageInfoSync', options); | ||
return callModuleSync(this, 'storage.getStorageInfoSync', options); | ||
} | ||
@@ -1404,34 +1409,34 @@ | ||
function showTabBar(options) { | ||
callModule('tabBar.show', options); | ||
callModule(this, 'tabBar.show', options); | ||
} | ||
function hideTabBar(options) { | ||
callModule('tabBar.hide', options); | ||
callModule(this, 'tabBar.hide', options); | ||
} | ||
function setTabBarStyle(options) { | ||
callModule('tabBar.setTabBarStyle', options); | ||
callModule(this, 'tabBar.setTabBarStyle', options); | ||
} | ||
function setTabBarItem(options) { | ||
callModule('tabBar.setTabBarItem', options); | ||
callModule(this, 'tabBar.setTabBarItem', options); | ||
} | ||
function setTabBarBadge(options) { | ||
callModule('tabBar.setTabBarBadge', options); | ||
callModule(this, 'tabBar.setTabBarBadge', options); | ||
} | ||
function removeTabBarBadge(options) { | ||
callModule('tabBar.removeTabBarBadge', options); | ||
callModule(this, 'tabBar.removeTabBarBadge', options); | ||
} | ||
function showTabBarRedDot(options) { | ||
callModule('tabBar.showTabBarRedDot', options); | ||
callModule(this, 'tabBar.showTabBarRedDot', options); | ||
} | ||
function hideTabBarRedDot(options) { | ||
callModule('tabBar.hideTabBarRedDot', options); | ||
callModule(this, 'tabBar.hideTabBarRedDot', options); | ||
} | ||
function uccBind(options) { | ||
callModule('ucc.uccBind', options); | ||
callModule(this, 'ucc.uccBind', options); | ||
} | ||
function uccTrustLogin(options) { | ||
callModule('ucc.uccTrustLogin', options); | ||
callModule(this, 'ucc.uccTrustLogin', options); | ||
} | ||
function uccUnbind(options) { | ||
callModule('ucc.uccUnbind', options); | ||
callModule(this, 'ucc.uccUnbind', options); | ||
} | ||
@@ -1442,4 +1447,3 @@ | ||
if (eventName == 'click' || eventName == 'enter' || eventName == 'expose') { | ||
var commitut = getMethod('userTrack.commitut'); | ||
commitut({ | ||
callModule(this, 'userTrack.commitut', { | ||
type: eventName, | ||
@@ -1456,4 +1460,3 @@ eventId: data.eventId, | ||
else { | ||
var customAdvance = getMethod('userTrack.customAdvance'); | ||
customAdvance({ | ||
callModule(this, 'userTrack.customAdvance', { | ||
eventId: data.eventId, | ||
@@ -1491,3 +1494,3 @@ name: data.name, | ||
function chooseVideo(opitons) { | ||
callModule('video.chooseVideo', opitons, opitons, function (res) { | ||
callModule(this, 'video.chooseVideo', opitons, opitons, function (res) { | ||
if (res.apFilePath) { | ||
@@ -1501,7 +1504,7 @@ res.tempFilePath = res.apFilePath; | ||
function saveVideoToPhotosAlbum(opitons) { | ||
callModule('video.saveVideoToPhotosAlbum', opitons); | ||
callModule(this, 'video.saveVideoToPhotosAlbum', opitons); | ||
} | ||
function getAuthUserInfo(options) { | ||
callModule('sendMtop.request', options, { | ||
callModule(this, 'sendMtop.request', options, { | ||
api: 'mtop.taobao.openlink.openinfo.user.get', | ||
@@ -1525,3 +1528,3 @@ v: '1.0', | ||
function getTBCode(options) { | ||
callModule('sendMtop.request', options, { | ||
callModule(this, 'sendMtop.request', options, { | ||
api: 'mtop.taobao.openlink.basic.login.auth.code', | ||
@@ -1537,3 +1540,3 @@ v: '1.0', | ||
function getTBSessionInfo(options) { | ||
callModule('wopc.getSessionKey', options, options, function (res) { | ||
callModule(this, 'wopc.getSessionKey', options, options, function (res) { | ||
return { | ||
@@ -1547,3 +1550,3 @@ data: res | ||
callModule('wopc.setSessionKey', options, options.sessionInfo, function (res) { | ||
callModule(this, 'wopc.setSessionKey', options, options.sessionInfo, function (res) { | ||
return { | ||
@@ -1555,9 +1558,9 @@ success: true | ||
function getSetting(options) { | ||
callModule('wopc.getSetting', options); | ||
callModule(this, 'wopc.getSetting', options); | ||
} | ||
function openSetting(options) { | ||
callModule('wopc.openSetting', options); | ||
callModule(this, 'wopc.openSetting', options); | ||
} | ||
function authorize(options) { | ||
callModule('wopc.authorize', options); | ||
callModule(this, 'wopc.authorize', options); | ||
} | ||
@@ -1570,10 +1573,11 @@ | ||
function connectSocket(options) { | ||
var this$1 = this; | ||
if ( options === void 0 ) options = {}; | ||
if (opened) { | ||
callModule('webSocket.close', { instanceId: instanceId }); | ||
callModule(this, 'webSocket.close', { instanceId: instanceId }); | ||
opened = false; | ||
instanceId++; | ||
} | ||
callModule('webSocket.webSocket', options, { | ||
callModule(this, 'webSocket.webSocket', options, { | ||
instanceId: instanceId, | ||
@@ -1587,3 +1591,3 @@ url: options.url, | ||
events.forEach(function (event) { | ||
callModule(("webSocket." + event), { | ||
callModule(this$1, ("webSocket." + event), { | ||
instanceId: instanceId, | ||
@@ -1599,3 +1603,3 @@ success: function success(res) { | ||
callModule('webSocket.send', options, { | ||
callModule(this, 'webSocket.send', options, { | ||
instanceId: instanceId, | ||
@@ -1606,3 +1610,3 @@ data: options.data | ||
function closeSocket(options) { | ||
callModule('webSocket.close', options, { instanceId: instanceId }, function (res) { | ||
callModule(this, 'webSocket.close', options, { instanceId: instanceId }, function (res) { | ||
opened = false; | ||
@@ -1644,3 +1648,3 @@ instanceId++; | ||
var moduleApi = /*#__PURE__*/Object.freeze({ | ||
var moduleAPIs = /*#__PURE__*/Object.freeze({ | ||
showActionSheet: showActionSheet, | ||
@@ -1778,4 +1782,18 @@ chooseAddress: chooseAddress, | ||
// 动态注册 API 到 my.scope 下 | ||
function registerModuleApi(my) { | ||
var APIFactory = function APIFactory(options) { | ||
var this$1 = this; | ||
this._name = "my"; | ||
this._moduleAPIs = {}; | ||
this._modifier = {}; | ||
if (isPlainObject(options)) { | ||
this._options = options; | ||
this._name = options.defaultName; | ||
this._context = options.context; | ||
this._modifier.origin = options.label; | ||
} | ||
this._host = { | ||
getContext: function () { return this$1._context; }, | ||
getModifier: function () { return this$1._modifier; } | ||
}; | ||
var runtime = getRuntime(); | ||
@@ -1785,45 +1803,64 @@ runtime && runtime.$on('registerModuleAPI', function (ref) { | ||
var scope = data.scope; | ||
if (!scope) { | ||
console.error('"data.scope" is undefined on "registerModuleAPI" event.'); | ||
return; | ||
this$1.registerScopedAPIs(data); | ||
}); | ||
}; | ||
APIFactory.prototype.canIUse = function canIUse (name) { | ||
if (typeof name === 'string') { | ||
return name in this._moduleAPIs; | ||
} | ||
return false; | ||
}; | ||
// 获取接口的 API | ||
APIFactory.prototype.getAPIs = function getAPIs () { | ||
var this$1 = this; | ||
var obj; | ||
var apis = {}; | ||
for (var key in this._moduleAPIs) { | ||
apis[key] = this._moduleAPIs[key]; | ||
if (typeof apis[key] === 'function') { | ||
apis[key].bind(this._host); | ||
} | ||
if (!isArray(data.map)) { | ||
console.error('"data.map" is undefined or not a array on "registerModuleAPI" event.'); | ||
return; | ||
} | ||
apis.canIUse = function (name) { return this$1.canIUse(name); }; | ||
return ( obj = {}, obj[this._name] = apis, obj ); | ||
}; | ||
APIFactory.prototype.registerModuleAPIs = function registerModuleAPIs (apis) { | ||
if (isPlainObject(apis)) { | ||
for (var key in apis) { | ||
this._moduleAPIs[key] = apis[key]; | ||
} | ||
// 如果存在并且不是对象,一般来说是提前定义的函数,不允许覆盖 | ||
if (my[scope] && !isPlainObject(my[scope])) { | ||
console.error(("\"my." + scope + "\" is already existed and can't be overridded.")); | ||
return; | ||
} | ||
}; | ||
// 动态注册二级接口 my.scope.xxx | ||
APIFactory.prototype.registerScopedAPIs = function registerScopedAPIs (data) { | ||
var this$1 = this; | ||
if ( data === void 0 ) data = {}; | ||
var scope = data.scope; | ||
var map = data.map; | ||
if (!scope) { | ||
return console.error('"data.scope" is undefined on "registerModuleAPI" event.'); | ||
} | ||
if (!isArray(map)) { | ||
return console.error('"data.map" is undefined or not a array on "registerModuleAPI" event.'); | ||
} | ||
// 如果属性已经存在并且不是对象,一般来说是提前定义的函数,不允许覆盖 | ||
if (this._moduleAPIs[scope] && !isPlainObject(this._moduleAPIs[scope])) { | ||
return console.error(("\"" + (this._name) + "." + scope + "\" is already exist and can't be overridden.")); | ||
} | ||
// 将接口添加到子对象中 | ||
var scopedAPIs = this._moduleAPIs[scope] = this._moduleAPIs[scope] || {}; | ||
map.forEach(function (desc) { | ||
// 允许覆盖已有 API | ||
if (scopedAPIs[desc.apiName]) { | ||
console.warn(((this$1._name) + "." + scope + "." + (desc.apiName) + " is already exist and will be overridden!")); | ||
} | ||
var myScope = my[scope] = my[scope] || {}; | ||
data.map.forEach(function (map) { | ||
// 允许合并 API | ||
if (myScope[map.apiName]) { | ||
console.warn(("my." + scope + "." + (map.apiName) + " is already existed and will be overridded.")); | ||
} | ||
myScope[map.apiName] = function (options) { | ||
if (map.isSync) { | ||
return callModuleSync(map.moduleMethod, options); | ||
} | ||
else { | ||
return callModule(map.moduleMethod, options); | ||
} | ||
}; | ||
}); | ||
scopedAPIs[desc.apiName] = desc.isSync | ||
? function (options) { return callModule(this$1._host, desc.moduleMethod, options); } | ||
: function (options) { return callModuleSync(this$1._host, desc.moduleMethod, options); }; | ||
}); | ||
} | ||
}; | ||
function getAPIs(options) { | ||
var obj; | ||
var apiName = 'my'; | ||
if (options && options.defaultName) { | ||
apiName = options.defaultName; | ||
} | ||
if (options && options.label) { | ||
modifier.origin = options.label; | ||
} | ||
var my = Object.assign({}, moduleApi, { canIUse: function (x) { return x in moduleApi; } }); | ||
registerModuleApi(my); | ||
listenModuleAPIEvent(); | ||
@@ -1836,3 +1873,5 @@ if (options && options.preprocessor) { | ||
} | ||
return ( obj = {}, obj[apiName] = my, obj ); | ||
var factory = new APIFactory(options); | ||
factory.registerModuleAPIs(moduleAPIs); | ||
return factory.getAPIs(); | ||
} | ||
@@ -1839,0 +1878,0 @@ setGlobalAPI('__WINDMILL_MODULE_API__', { getAPIs: getAPIs }); |
@@ -1,2 +0,2 @@ | ||
/* windmill-module-api (0.3.0), build at 2019-01-14 14:07. */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t["windmill-module-api"]=e()}(this,function(){"use strict";var e="__WINDMILL_WORKER_RUNTIME_APIS__",n="[[JSON]]",o=/^\[\[JSON\]\].*/;function i(){return"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:new Function("return this")()}var r="__WINDMILL_MODULE_GETTER__";function c(t){var e=i();return e&&"function"==typeof e[r]?e[r](t):e&&"function"==typeof e.require?e.require("@core/"+t):(console.error('Can\'t find available "require" function.'),e&&e&&"function"==typeof e.requireModule?e.requireModule(t):e&&e.weex&&"function"==typeof e.weex.requireModule?e.weex.requireModule("@windmill/"+t):void 0)}var a="[[EVENT_MAP]]";function u(t,e){var n=t[a];return Array.isArray(n[e])||(n[e]=[]),n[e]}var s,f=function(){Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:{}})};function l(t){return Object.prototype.toString.call(t).slice(8,-1)}function d(t){return"Object"===l(t)}function p(t){return"Array"===l(t)}function g(){return"object"==typeof __windmill_environment__?__windmill_environment__:"object"==typeof wmlEnv?wmlEnv:"object"==typeof windmillEnv?windmillEnv:{}}function m(){if(!s){var t=i();s=t[e]}return s}function h(){return m().$getCurrentActivePageId()}f.prototype.on=function(t,e){return u(this,t).push({listener:e,once:!1,callCount:0}),this},f.prototype.once=function(t,e){return u(this,t).push({listener:e,once:!0,callCount:0}),this},f.prototype.off=function(t,e){var n=this[a];if(e){var o=n[t];if(Array.isArray(o)){var i=o.findIndex(function(t){return t.listener===e});-1!==i&&o.splice(i,1)}}else delete n[t];return this},f.prototype.emit=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];var o=this[a],i=o[t];return Array.isArray(i)&&(o[t]=i.filter(function(t){try{t.listener.apply(null,e),t.callCount+=1}catch(t){return!0}return!t.once})),this};var v={};function y(t,e){var n=v[t];return"function"==typeof n&&d(e)?n(e):e}var S,w=(S=1e5,function(){var t=String(S);return S+=1,t});function b(t,e){var n=h(),o="[[ModuleAPIEvent]]@"+n;m().$emit(o,{type:t,data:e},n)}var I=new f;var T=["success","fail","complete"];function k(t){var e={};for(var n in t)-1===T.indexOf(n)&&(e[n]=t[n]);return e}function _(n,t){var o=m();if(o){if(t&&"function"==typeof o.$callSync)return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return o.$callSync.apply(o,[n].concat(t))};if(!t&&"function"==typeof o.$call)return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return o.$call.apply(o,[n].concat(t))}}var e=n.split(/\s*\.\s*/i),i=e[0],r=e[1];if(i&&r){var a=c(i);if(a&&"function"==typeof a[r])return a[r]}return function(){}}function B(t,e){if("function"==typeof t)try{return t.apply(null,e)}catch(t){console.error("Failed to execute internal method: "+t.toString())}}var P=function(t,e){console.error('Failed to execute callback of "'+t+'": '+e.toString())};function C(e,t,n){if("function"==typeof t)try{return t.apply(null,n)}catch(t){P(e,t)}}var A={};function N(n,o,t,i,r){void 0===o&&(o={}),void 0===t&&(t=o),void 0===i&&(i=function(t){return t}),void 0===r&&(r=function(t){return t});var e=_(n),a=!1;return e(k(t),function(t){var e=B(i,[t]);C(n,o.success,[e]),a||(C(n,o.complete,[e]),a=!0)},function(t){var e=B(r,[t]);C(n,o.fail,[e]),a||(C(n,o.complete,[e]),a=!0)},A)}function x(t,e){return void 0===e&&(e={}),_(t,!0)(k(e),A)}var t=["opacity","backgroundColor","width","height","top","left","bottom","right","rotate","rotateX","rotateY","rotateZ","rotate3d","skew","skewX","skewY","scale","scaleX","scaleY","scaleZ","scale3d","translate","translateX","translateY","translateZ","translate3d","matrix","matrix3d"],E=function(){var o=this;this.animations=[],this.currentAnimation=[],this.config={},t.forEach(function(n){o[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return o.currentAnimation.push([n,t]),o}})};E.prototype.step=function(t){return this.animations.push({config:Object.assign({},this.config,t),animation:this.currentAnimation}),this.currentAnimation=[],this},E.prototype.export=function(){var t=this.animations;return this.animations=[],t};var D=function(e){function t(t){e.call(this),this.config=Object.assign({transformOrigin:"50% 50% 0",duration:400,timeFunction:"linear",delay:0},t)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(E);var M=function(t){void 0===t&&(t={}),this._instanceId=w(),this._emitter=new f,this.src=t.src};M.prototype.play=function(t){var e=this;N("audioPlayer.playVoice",t,{src:this.src,instanceId:this._instanceId},function(t){return 1===t.isComplete?e._emitter.emit("stop"):(e.duration=t.duration,e._emitter.emit("play")),t},function(t){return e._emitter.emit("error",t),t})},M.prototype.pause=function(t){var e=this;N("audioPlayer.pauseVoice",t,{instanceId:this._instanceId},function(t){return e._emitter.emit("pause"),t},function(t){return e._emitter.emit("error",t),t})},M.prototype.stop=function(t){var e=this;N("audioPlayer.stopVoice",t,{instanceId:this._instanceId},function(t){return e._emitter.emit("stop"),t},function(t){return e._emitter.emit("error",t),t})},M.prototype.onPlay=function(t){this._emitter.on("play",t)},M.prototype.onPause=function(t){this._emitter.on("pause",t)},M.prototype.onStop=function(t){this._emitter.on("stop",t)},M.prototype.onError=function(t){this._emitter.on("error",t)},M.prototype.offPlay=function(t){this._emitter.off("play",t)},M.prototype.offPause=function(t){this._emitter.off("pause",t)},M.prototype.offStop=function(t){this._emitter.off("stop",t)},M.prototype.offError=function(t){this._emitter.off("error",t)};var F,L=function(){this._startEmitted=!1,this._emitter=new f};L.prototype.start=function(t){var e=this;void 0===t&&(t={}),this._startEmitted=!1,N("audioRecord.startRecord",t,{maxDuration:t.duration/1e3,minDuration:1},function(t){return t.averagePower&&!e._startEmitted&&(e._emitter.emit("start",{}),e._startEmitted=!0),t.apFilePath&&e._emitter.emit("stop",{tempFilePath:t.apFilePath,duration:t.duration}),t},function(t){return e._emitter.emit("error",t),t})},L.prototype.stop=function(t){var e=this;void 0===t&&(t={}),N("audioRecord.stopRecord",t,t,function(t){return e._emitter.emit("stop",{tempFilePath:t.apFilePath,duration:t.duration}),t},function(t){return e._emitter.emit("error",t),t})},L.prototype.onStart=function(t){this._emitter.on("start",t)},L.prototype.onStop=function(t){this._emitter.on("stop",t)},L.prototype.onError=function(t){this._emitter.on("error",t)},L.prototype.offStart=function(t){this._emitter.off("start",t)},L.prototype.offStop=function(t){this._emitter.off("stop",t)},L.prototype.offError=function(t){this._emitter.off("error",t)};var O,R=["setTextAlign","setTextBaseline","setFillStyle","setStrokeStyle","setShadow","createLinearGradient","createCircularGradient","addColorStop","setLineWidth","setLineCap","setLineJoin","setMiterLimit","rect","fillRect","strokeRect","clearRect","fill","stroke","beginPath","closePath","moveTo","lineTo","arc","bezierCurveTo","clip","quadraticCurveTo","scale","rotate","translate","setFontSize","fillText","drawImage","setGlobalAlpha","setLineDash","transform","setTransform","getImageData","p\u200butImageData","save","restore","measureText"],V=function(t){var o=this;this._canvasId=t,this._actions=[],R.forEach(function(n){o[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];o._actions.push({method:n,args:t})}})};function j(t){return d(t)?t.apFilePath||t.filePath:""}V.prototype.draw=function(){b("canvas",{canvasId:this._canvasId,actions:this._actions}),this._actions=[]};var U=["play","stop","pause","setSpeed","goToAndStop","goToAndPlay","getDuration","setDirection","playSegments","destroy"],q=["onAnimationEnd","onAnimationRepeat","onDataReady","onDataFailed","onAnimationStart","onAnimationCancel"],W=function(o){var i=this;U.forEach(function(n){i[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];b("lottie",{lottieId:o,action:{method:n,args:t}})}}),q.forEach(function(t){i[t]=function(n){I.on("lottie."+t,function(t){var e=[];t.event&&t.event.args&&(e=t.event.args),t.lottieId===o&&n.apply(i,e)})}})};function H(t){return"/"===t.charAt(0)}function z(t,e){for(var n=e,o=n+1,i=t.length;o<i;n+=1,o+=1)t[n]=t[o];t.pop()}function $(t){return void 0===t&&(t=""),"/"===t[0]?t.slice(1):t}function G(t){return n+JSON.stringify(t.data)}function K(t){return{data:o.test(t.value)?JSON.parse(t.value.substr(n.length)):t.value}}function J(){var t=g();return{model:t.model,pixelRatio:t.pixelRatio,windowWidth:t.screenWidth,windowHeight:t.screenHeight,language:t.language,version:t.appVersion,storage:null,currentBattery:null,system:t.systemVersion,platform:t.platform,screenWidth:t.screenWidth,screenHeight:t.screenHeight,brand:t.brand,fontSizeSetting:14,app:t.appName,SDKVersion:t.version,frameworkType:t.frameworkType,frameworkVersion:t.frameworkVersion,userAgent:t.userAgent,screenDensity:t.screenDensity}}var X=g().version||"";var Y=["play","pause","stop","requestFullScreen","exitFullScreen","showControls","hideControls","enableLoop","disableLoop"],Z=function(r){var t=this;Y.forEach(function(i){t[i]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=h(),o="[[VideoContextAction]]@"+n;m().$emit(o,{action:i,id:r,args:t},n)}})};var Q=new f,tt=["onOpen","onError","onMessage","onClose"],et=0,nt=!1;var ot=Object.freeze({showActionSheet:function(t){N("actionSheet.showActionSheet",t)},chooseAddress:function(t){N("address.choose",t)},tradePay:function(t){void 0===t&&(t={}),N("alipay.tradePay",t=y("tradePay",t))},createAnimation:function(t){return new D(t)},createInnerAudioContext:function(t){return new M(t)},getRecorderManager:function(t){return F||(F=new L),F},createCanvasContext:function(t){return new V(t)},openChat:function(t){N("chat.open",t)},getClipboard:function(t){N("clipboard.readText",t)},setClipboard:function(t){void 0===t&&(t={}),N("clipboard.writeText",t,{text:t.text})},getNetworkType:function(t){N("connection.getType",t=y("getNetworkType",t),{},function(t){return{networkType:(t.type||"").toUpperCase()}})},onNetworkStatusChange:function(t){O||(O=new f,c("connection").onChange({},function(t){var e=t.type||"";O.emit("networkStatusChange",{networkType:e.toUpperCase()})})),O.on("networkStatusChange",t)},offNetworkStatusChange:function(){O.off("networkStatusChange")},choosePhoneContact:function(t){N("contact.choosePhoneContact",t=y("choosePhoneContact",t),{},function(t){return{name:t.name,mobile:t.phone}})},watchShake:function(t){N("device.onShake",t,{on:!0})},vibrate:function(t){N("device.vibrate",t)},vibrateShort:function(t){N("device.vibrateShort",t)},onUserCaptureScreen:function(t){N("device.onUserCaptureScreen",{success:t})},offUserCaptureScreen:function(){N("device.offUserCaptureScreen")},scan:function(t){N("device.scan",t)},saveFile:function(t){return N("file.saveFile",t,{filePath:j(t)},function(t){return{apFilePath:t.savedFilePath}})},getFileInfo:function(t){return N("file.getFileInfo",t,{filePath:j(t)},function(t){return{size:t.size}})},getSavedFileInfo:function(t){return N("file.getFileInfo",t,{filePath:j(t)})},getSavedFileList:function(t){return N("file.getFileList",t,{},function(t){var e=[];return p(t.fileList)&&(e=t.fileList.map(function(t){return{size:t.size,createTime:t.createTime,apFilePath:t.filePath}})),{fileList:e}})},removeSavedFile:function(t){return N("file.removeFile",t,{filePath:j(t)})},chooseImage:function(t){N("image.chooseImage",t)},compressImage:function(t){N("image.compressImage",t)},previewImage:function(t){N("image.previewImage",t)},saveImage:function(t){N("image.saveImage",t)},getImageInfo:function(t){N("image.getImageInfo",t)},hideKeyboard:function(){N("keyboard.hideKeyboard")},getLocation:function(t){var n=t.type;N("location.getLocation",t,t,function(t){var e={longitude:t.coords.longitude,latitude:t.coords.latitude,accuracy:t.coords.accuracy};return 0<n&&t.address&&(e.country=t.address.country,e.province=t.address.province,e.city=t.address.city,e.cityAdcode=t.address.cityCode,e.district=t.address.area,e.districtAdcode=t.address.areaCode),e})},createLottieContext:function(t){return new W(t)},setBackgroundImage:function(t){N("miniApp.setWebViewBackgroundImage",t)},removeBackgroundImage:function(t){N("miniApp.setWebViewBackgroundImage",t,{color:"",imgUrl:""})},setViewTop:function(t){N("miniApp.setWebViewTop",t)},setCanPullDown:function(t){N("miniApp.setWebViewParams",t)},setShareAppMessage:function(t){void 0===t&&(t={}),N("miniApp.setAppShareInfo",t,{title:t.title,description:t.desc,imageUrl:t.imageUrl,extraParams:t.extraParams})},startPullDownRefresh:function(t){N("miniApp.startPullDownRefresh",t)},stopPullDownRefresh:function(t){N("miniApp.stopPullDownRefresh",t)},setBackgroundTextStyle:function(t){N("miniApp.setBackgroundTextStyle",t)},setBackgroundColor:function(t){N("miniApp.setBackgroundColor",t)},reLaunch:function(t){N("miniApp.reLaunch",t)},pageScrollTo:function(t){void 0===t&&(t={}),b("pageScrollTo",{scrollTop:t.scrollTop})},alert:function(t){void 0===t&&(t={}),N("modal.alert",t,{title:t.title,message:t.content,okTitle:t.buttonText})},confirm:function(t){void 0===t&&(t={});var e=t.confirmButtonText||"\u786e\u5b9a",n=t.cancelButtonText||"\u53d6\u6d88";N("modal.confirm",t,{title:t.title,message:t.content,okTitle:e,cancelTitle:n},function(t){return{confirm:t.data===e}})},showToast:function(t){void 0===t&&(t={}),t.duration||(t.duration=2e3),N("modal.toast",t,{message:t.content,duration:t.duration/1e3})},hideToast:function(t){N("modal.hideToast",t)},prompt:function(t){N("modal.prompt",t)},showLoading:function(t){N("modal.showLoading",t)},hideLoading:function(t){N("modal.hideLoading",t)},sendMtop:function(t){N("sendMtop.request",y("sendMtop",t))},navigateTo:function(t,e){void 0===t&&(t={}),void 0===e&&(e=""),N("navigator.push",t=y("navigateTo",t),{url:$(function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=t&&t.split("/")||[],o=e&&e.split("/")||[],i=t&&H(t),r=e&&H(e),a=i||r;if(t&&H(t)?o=n:n.length&&(o.pop(),o=o.concat(n)),!o.length)return"/";var c=void 0;if(o.length){var u=o[o.length-1];c="."===u||".."===u||""===u}else c=!1;for(var s=0,f=o.length;0<=f;f--){var l=o[f];"."===l?z(o,f):".."===l?(z(o,f),s++):s&&(z(o,f),s--)}if(!a)for(;s--;s)o.unshift("..");!a||""===o[0]||o[0]&&H(o[0])||o.unshift("");var d=o.join("/");return c&&"/"!==d.substr(-1)&&(d+="/"),d}(t.url,e)||"")})},navigateBack:function(t){N("navigator.pop",y("navigateBack",t))},redirectTo:function(t){void 0===t&&(t={}),N("navigator.redirectTo",t=y("redirectTo",t),{url:$(t.url)})},switchTab:function(t){void 0===t&&(t={}),N("navigator.switchTab",t=y("switchTab",t),{url:$(t.url)})},navigateToMiniProgram:function(t){N("navigator.navigateToMiniProgram",t)},navigateBackMiniProgram:function(t){N("navigator.navigateBackMiniProgram",t)},onPageNotify:function(t){N("navigator.pc_onPageNotify",{success:t})},offPageNotify:function(){N("navigator.pc_offPageNotify")},setPageNotifyConfig:function(t){N("navigator.pc_setPageNotifyConfig",t)},getBackStack:function(t){N("navigator.getBackStack",t)},popToHome:function(t){N("navigator.popToHome",t)},setNavigationBar:function(t){N("navigatorBar.setNavigationBar",t)},getStatusBarHeight:function(t){N("navigatorBar.getStatusBarHeight",t,t,function(t){return{height:parseInt(t.data)}})},getNavigationBarHeight:function(t){N("navigatorBar.getHeight",t,t,function(t){return{height:parseInt(t.data)}})},showNavigationBarLoading:function(t){N("navigatorBar.showNavigationBarLoading",t)},hideNavigationBarLoading:function(t){N("navigatorBar.hideNavigationBarLoading",t)},setNavigationBarDrawer:function(t){N("navigatorBar.setDrawer",t)},openNavigationBarDrawer:function(t){N("navigatorBar.openDrawer",t)},closeNavigationBarDrawer:function(t){N("navigatorBar.closeDrawer",t)},setNavigationBarSheet:function(t){N("navigatorBar.setActionSheet",t)},httpRequest:function(o){void 0===o&&(o={});var t=(o=y("httpRequest",o)).method||"GET";if("GET"===t&&d(o.data)){var i=[];Object.keys(o.data).forEach(function(t){var e=o.data[t],n="object"==typeof e?JSON.stringify(e):e;i.push(t+"="+encodeURIComponent(n))});var e=i.join("&");0<=o.url.indexOf("?")?o.url+=e:o.url+="?"+e}N("network.request",o,{method:t,url:o.url,headers:o.headers||{"Content-Type":"application/x-www-form-urlencoded"},dataType:o.dataType||"json",body:o.data},function(t){return{data:t.data,status:t.status,headers:t.headers}})},uploadFile:function(t){N("network.uploadFile",t)},downloadFile:function(t){N("network.downloadFile",t)},makePhoneCall:function(t){void 0===t&&(t={}),N("phone.makePhoneCall",t,{phoneNumber:t.number})},chooseCity:function(t){void 0===t&&(t={}),t.cities&&Array.isArray(t.cities)&&(t.cities=t.cities.map(function(t){return{cityName:t.city,cityCode:t.adCode,spell:t.spell}})),t.hotCities&&Array.isArray(t.hotCities)&&(t.hotCities=t.hotCities.map(function(t){return{cityName:t.city,cityCode:t.adCode,spell:t.spell}})),N("picker.chooseCity",t,t,function(t){return{city:t.cityName,adCode:t.cityCode}})},datePicker:function(t){void 0===t&&(t={}),N("picker.pickDate",t,{format:t.format,value:t.currentDate,min:t.startDate,max:t.endDate},function(t){return{date:t.data}})},setScreenBrightness:function(t){void 0===t&&(t={}),N("screen.setBrightness",t,{brightness:t.brightness})},getScreenBrightness:function(t){N("screen.getScreenBrightness",t,t,function(t){return{brightness:t.value}})},setKeepScreenOn:function(t){void 0===t&&(t={}),N("screen.setAlwaysOn",t,{on:t.keepScreenOn})},shareTinyAppMsg:function(t){N("share.doShare",t)},showSku:function(t){N("sku.show",t)},hideSku:function(t){N("sku.hide",t)},setStorage:function(t){void 0===t&&(t={}),N("storage.setItem",t,{key:t.key,value:G(t)})},setStorageSync:function(t){return x("storage.setItemSync",{key:t.key,value:G(t)})},getStorage:function(t){void 0===t&&(t={}),N("storage.getItem",t,t,K)},getStorageSync:function(t){return K(x("storage.getItemSync",t))},removeStorage:function(t){void 0===t&&(t={}),N("storage.removeItem",t)},removeStorageSync:function(t){return void 0===t&&(t={}),x("storage.removeItemSync",t)},clearStorage:function(t){N("storage.clearStorage",t)},clearStorageSync:function(t){return x("storage.clearStorageSync",t)},getStorageInfo:function(t){N("storage.getStorageInfo",t)},getStorageInfoSync:function(t){return x("storage.getStorageInfoSync",t)},getSystemInfoSync:J,getSystemInfo:function(e){void 0===e&&(e={});try{"function"==typeof e.success&&e.success.call(this,J())}catch(t){"function"==typeof e.fail&&e.fail.call(this,t)}finally{"function"==typeof e.complete&&e.complete.call(this)}},SDKVersion:X,showTabBar:function(t){N("tabBar.show",t)},hideTabBar:function(t){N("tabBar.hide",t)},setTabBarStyle:function(t){N("tabBar.setTabBarStyle",t)},setTabBarItem:function(t){N("tabBar.setTabBarItem",t)},setTabBarBadge:function(t){N("tabBar.setTabBarBadge",t)},removeTabBarBadge:function(t){N("tabBar.removeTabBarBadge",t)},showTabBarRedDot:function(t){N("tabBar.showTabBarRedDot",t)},hideTabBarRedDot:function(t){N("tabBar.hideTabBarRedDot",t)},uccBind:function(t){N("ucc.uccBind",t)},uccTrustLogin:function(t){N("ucc.uccTrustLogin",t)},uccUnbind:function(t){N("ucc.uccUnbind",t)},reportAnalytics:function(t,e){void 0===e&&(e={}),"click"==t||"enter"==t||"expose"==t?_("userTrack.commitut")({type:t,eventId:e.eventId,name:e.name,comName:e.comName,arg1:e.arg1,arg2:e.arg2,arg3:e.arg3,param:e.param}):_("userTrack.customAdvance")({eventId:e.eventId,name:e.name,comName:e.comName,arg1:e.arg1,arg2:e.arg2,arg3:e.arg3,param:e.param})},createVideoContext:function(t){return new Z(t)},chooseVideo:function(t){N("video.chooseVideo",t,t,function(t){return t.apFilePath&&(t.tempFilePath=t.apFilePath,delete t.apFilePath),t})},saveVideoToPhotosAlbum:function(t){N("video.saveVideoToPhotosAlbum",t)},getAuthUserInfo:function(t){N("sendMtop.request",t,{api:"mtop.taobao.openlink.openinfo.user.get",v:"1.0",type:"GET"},function(t){var e={nickName:t.data.mixNick,userId:t.data.openId};return t.data.avatar&&(e.avatar=t.data.avatar),t.data.unionId&&(e.unionId=t.data.unionId),e})},getTBCode:function(t){N("sendMtop.request",t,{api:"mtop.taobao.openlink.basic.login.auth.code",v:"1.0",type:"GET"},function(t){return{code:t.data.result}})},getTBSessionInfo:function(t){N("wopc.getSessionKey",t,t,function(t){return{data:t}})},setTBSessionInfo:function(t){void 0===t&&(t={}),N("wopc.setSessionKey",t,t.sessionInfo,function(t){return{success:!0}})},getSetting:function(t){N("wopc.getSetting",t)},openSetting:function(t){N("wopc.openSetting",t)},authorize:function(t){N("wopc.authorize",t)},connectSocket:function(t){void 0===t&&(t={}),nt&&(N("webSocket.close",{instanceId:et}),nt=!1,et++),N("webSocket.webSocket",t,{instanceId:et,url:t.url,protocol:""},function(t){return nt=!0,t}),tt.forEach(function(e){N("webSocket."+e,{instanceId:et,success:function(t){Q.emit(e,t)}})})},sendSocketMessage:function(t){void 0===t&&(t={}),N("webSocket.send",t,{instanceId:et,data:t.data})},closeSocket:function(t){N("webSocket.close",t,{instanceId:et},function(t){return nt=!1,et++,t})},onSocketOpen:function(t){Q.on("onOpen",t)},offSocketOpen:function(t){Q.off("onOpen",t)},onSocketError:function(t){Q.on("onError",t)},offSocketError:function(t){Q.off("onError",t)},onSocketMessage:function(e){Q.on("onMessage",function(t){e&&e({data:t,isBuffer:!1})})},offSocketMessage:function(t){Q.off("onMessage",t)},onSocketClose:function(t){Q.on("onClose",t)},offSocketClose:function(t){Q.off("onClose",t)}});function it(t){var e,n="my";t&&t.defaultName&&(n=t.defaultName),t&&t.label&&(A.origin=t.label);var i,o,r,a=Object.assign({},ot,{canIUse:function(t){return t in ot}});return i=a,(o=m())&&o.$on("registerModuleAPI",function(t){var e=t.data,n=e.scope;if(n)if(p(e.map))if(!i[n]||d(i[n])){var o=i[n]=i[n]||{};e.map.forEach(function(e){o[e.apiName]&&console.warn("my."+n+"."+e.apiName+" is already existed and will be overridded."),o[e.apiName]=function(t){return e.isSync?x(e.moduleMethod,t):N(e.moduleMethod,t)}})}else console.error('"my.'+n+"\" is already existed and can't be overridded.");else console.error('"data.map" is undefined or not a array on "registerModuleAPI" event.');else console.error('"data.scope" is undefined on "registerModuleAPI" event.')}),m().$on("[[ModuleAPIEvent]]",function(t){var e=t.type;void 0===e&&(e="");var n=t.data;void 0===n&&(n={});var o=e;n.event&&n.event.name&&(o+="."+n.event.name),I.emit(o,n)}),t&&t.preprocessor&&function(t,e){if(d(t)&&d(e))for(var n in e)o=t,i=n,Object.prototype.hasOwnProperty.call(o,i)&&"function"==typeof e[n]&&(v[n]=e[n]);var o,i}(a,t.preprocessor),t&&t.errorHandler&&"function"==typeof(r=t.errorHandler)&&(P=r),(e={})[n]=a,e}return function(e,n,t){void 0===t&&(t=!0);var o=i();try{Object.defineProperty(o,e,{value:n,configurable:!0,enumerable:!0,writable:!t})}catch(t){o[e]=n}}("__WINDMILL_MODULE_API__",{getAPIs:it}),it}); | ||
/* windmill-module-api (0.3.1), build at 2019-01-22 10:46. */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t["windmill-module-api"]=e()}(this,function(){"use strict";var e="__WINDMILL_WORKER_RUNTIME_APIS__",n="[[JSON]]",o=/^\[\[JSON\]\].*/;function i(){return"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:new Function("return this")()}var r="__WINDMILL_MODULE_GETTER__";function s(t){var e=i();return e&&"function"==typeof e[r]?e[r](t):e&&"function"==typeof e.require?e.require("@core/"+t):(console.error('Can\'t find available "require" function.'),e&&e&&"function"==typeof e.requireModule?e.requireModule(t):e&&e.weex&&"function"==typeof e.weex.requireModule?e.weex.requireModule("@windmill/"+t):void 0)}var a="[[EVENT_MAP]]";function c(t,e){var n=t[a];return Array.isArray(n[e])||(n[e]=[]),n[e]}var u,f=function(){Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:{}})};function h(t){return Object.prototype.toString.call(t).slice(8,-1)}function d(t){return"Object"===h(t)}function l(t){return"Array"===h(t)}function p(){return"object"==typeof __windmill_environment__?__windmill_environment__:"object"==typeof wmlEnv?wmlEnv:"object"==typeof windmillEnv?windmillEnv:{}}function g(){if(!u){var t=i();u=t[e]}return u}function m(){return g().$getCurrentActivePageId()}f.prototype.on=function(t,e){return c(this,t).push({listener:e,once:!1,callCount:0}),this},f.prototype.once=function(t,e){return c(this,t).push({listener:e,once:!0,callCount:0}),this},f.prototype.off=function(t,e){var n=this[a];if(e){var o=n[t];if(Array.isArray(o)){var i=o.findIndex(function(t){return t.listener===e});-1!==i&&o.splice(i,1)}}else delete n[t];return this},f.prototype.emit=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];var o=this[a],i=o[t];return Array.isArray(i)&&(o[t]=i.filter(function(t){try{t.listener.apply(null,e),t.callCount+=1}catch(t){return!0}return!t.once})),this};var v={};function y(t,e){var n=v[t];return"function"==typeof n&&d(e)?n(e):e}var S,w=(S=1e5,function(){var t=String(S);return S+=1,t});function _(t,e){var n=m(),o="[[ModuleAPIEvent]]@"+n;g().$emit(o,{type:t,data:e},n)}var I=new f;var b=["success","fail","complete"];function P(t){var e={};for(var n in t)-1===b.indexOf(n)&&(e[n]=t[n]);return e}function T(r,t){var a=g();if(a){if(t&&"function"==typeof a.$callSync)return function(t,e,n){return void 0===n&&(n={}),a.$callSync(r,t,e,n)};if(!t&&"function"==typeof a.$call)return function(t,e,n,o,i){return void 0===i&&(i={}),a.$call(r,t,e,n,o,i)}}var e=r.split(/\s*\.\s*/i),n=e[0],o=e[1];if(n&&o){var i=s(n);if(i&&"function"==typeof i[o])return i[o]}return function(){}}function k(t,e){if("function"==typeof t)try{return t.apply(null,e)}catch(t){console.error("Failed to execute internal method: "+t.toString())}}var A=function(t,e){console.error('Failed to execute callback of "'+t+'": '+e.toString())};function B(e,t,n){if("function"==typeof t)try{return t.apply(null,n)}catch(t){A(e,t)}}function C(t,n,o,e,i,r){void 0===o&&(o={}),void 0===e&&(e=o),void 0===i&&(i=function(t){return t}),void 0===r&&(r=function(t){return t});var a=T(n),s=t&&"function"==typeof t.getContext?t.getContext():{},c=t&&"function"==typeof t.getModifier?t.getModifier():{},u=!1;return a(P(e),function(t){var e=k(i,[t]);B(n,o.success,[e]),u||(B(n,o.complete,[e]),u=!0)},function(t){var e=k(r,[t]);B(n,o.fail,[e]),u||(B(n,o.complete,[e]),u=!0)},s,c)}function x(t,e,n){void 0===n&&(n={});var o=T(e,!0),i=t&&"function"==typeof t.getContext?t.getContext():{},r=t&&"function"==typeof t.getModifier?t.getModifier():{};return o(P(n),i,r)}var t=["opacity","backgroundColor","width","height","top","left","bottom","right","rotate","rotateX","rotateY","rotateZ","rotate3d","skew","skewX","skewY","scale","scaleX","scaleY","scaleZ","scale3d","translate","translateX","translateY","translateZ","translate3d","matrix","matrix3d"],N=function(){var o=this;this.animations=[],this.currentAnimation=[],this.config={},t.forEach(function(n){o[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return o.currentAnimation.push([n,t]),o}})};N.prototype.step=function(t){return this.animations.push({config:Object.assign({},this.config,t),animation:this.currentAnimation}),this.currentAnimation=[],this},N.prototype.export=function(){var t=this.animations;return this.animations=[],t};var M=function(e){function t(t){e.call(this),this.config=Object.assign({transformOrigin:"50% 50% 0",duration:400,timeFunction:"linear",delay:0},t)}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(N);var E=function(t,e){void 0===e&&(e={}),this._instanceId=w(),this._host=t,this._emitter=new f,this.src=e.src};E.prototype.play=function(t){var e=this;C(this._host,"audioPlayer.playVoice",t,{src:this.src,instanceId:this._instanceId},function(t){return 1===t.isComplete?e._emitter.emit("stop"):(e.duration=t.duration,e._emitter.emit("play")),t},function(t){return e._emitter.emit("error",t),t})},E.prototype.pause=function(t){var e=this;C(this._host,"audioPlayer.pauseVoice",t,{instanceId:this._instanceId},function(t){return e._emitter.emit("pause"),t},function(t){return e._emitter.emit("error",t),t})},E.prototype.stop=function(t){var e=this;C(this._host,"audioPlayer.stopVoice",t,{instanceId:this._instanceId},function(t){return e._emitter.emit("stop"),t},function(t){return e._emitter.emit("error",t),t})},E.prototype.onPlay=function(t){this._emitter.on("play",t)},E.prototype.onPause=function(t){this._emitter.on("pause",t)},E.prototype.onStop=function(t){this._emitter.on("stop",t)},E.prototype.onError=function(t){this._emitter.on("error",t)},E.prototype.offPlay=function(t){this._emitter.off("play",t)},E.prototype.offPause=function(t){this._emitter.off("pause",t)},E.prototype.offStop=function(t){this._emitter.off("stop",t)},E.prototype.offError=function(t){this._emitter.off("error",t)};var D,F=function(t){this._startEmitted=!1,this._host=t,this._emitter=new f};F.prototype.start=function(t){var e=this;void 0===t&&(t={}),this._startEmitted=!1,C(this._host,"audioRecord.startRecord",t,{maxDuration:t.duration/1e3,minDuration:1},function(t){return t.averagePower&&!e._startEmitted&&(e._emitter.emit("start",{}),e._startEmitted=!0),t.apFilePath&&e._emitter.emit("stop",{tempFilePath:t.apFilePath,duration:t.duration}),t},function(t){return e._emitter.emit("error",t),t})},F.prototype.stop=function(t){var e=this;void 0===t&&(t={}),C(this._host,"audioRecord.stopRecord",t,t,function(t){return e._emitter.emit("stop",{tempFilePath:t.apFilePath,duration:t.duration}),t},function(t){return e._emitter.emit("error",t),t})},F.prototype.onStart=function(t){this._emitter.on("start",t)},F.prototype.onStop=function(t){this._emitter.on("stop",t)},F.prototype.onError=function(t){this._emitter.on("error",t)},F.prototype.offStart=function(t){this._emitter.off("start",t)},F.prototype.offStop=function(t){this._emitter.off("stop",t)},F.prototype.offError=function(t){this._emitter.off("error",t)};var L,O=["setTextAlign","setTextBaseline","setFillStyle","setStrokeStyle","setShadow","createLinearGradient","createCircularGradient","addColorStop","setLineWidth","setLineCap","setLineJoin","setMiterLimit","rect","fillRect","strokeRect","clearRect","fill","stroke","beginPath","closePath","moveTo","lineTo","arc","bezierCurveTo","clip","quadraticCurveTo","scale","rotate","translate","setFontSize","fillText","drawImage","setGlobalAlpha","setLineDash","transform","setTransform","getImageData","p\u200butImageData","save","restore","measureText"],R=function(t){var o=this;this._canvasId=t,this._actions=[],O.forEach(function(n){o[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];o._actions.push({method:n,args:t})}})};function V(t){return d(t)?t.apFilePath||t.filePath:""}R.prototype.draw=function(){_("canvas",{canvasId:this._canvasId,actions:this._actions}),this._actions=[]};var U=["play","stop","pause","setSpeed","goToAndStop","goToAndPlay","getDuration","setDirection","playSegments","destroy"],j=["onAnimationEnd","onAnimationRepeat","onDataReady","onDataFailed","onAnimationStart","onAnimationCancel"],q=function(o){var i=this;U.forEach(function(n){i[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];_("lottie",{lottieId:o,action:{method:n,args:t}})}}),j.forEach(function(t){i[t]=function(n){I.on("lottie."+t,function(t){var e=[];t.event&&t.event.args&&(e=t.event.args),t.lottieId===o&&n.apply(i,e)})}})};function W(t){return"/"===t.charAt(0)}function H(t,e){for(var n=e,o=n+1,i=t.length;o<i;n+=1,o+=1)t[n]=t[o];t.pop()}function z(t){return void 0===t&&(t=""),"/"===t[0]?t.slice(1):t}function $(t){return n+JSON.stringify(t.data)}function G(t){return{data:o.test(t.value)?JSON.parse(t.value.substr(n.length)):t.value}}function K(){var t=p();return{model:t.model,pixelRatio:t.pixelRatio,windowWidth:t.screenWidth,windowHeight:t.screenHeight,language:t.language,version:t.appVersion,storage:null,currentBattery:null,system:t.systemVersion,platform:t.platform,screenWidth:t.screenWidth,screenHeight:t.screenHeight,brand:t.brand,fontSizeSetting:14,app:t.appName,SDKVersion:t.version,frameworkType:t.frameworkType,frameworkVersion:t.frameworkVersion,userAgent:t.userAgent,screenDensity:t.screenDensity}}var J=p().version||"";var X=["play","pause","stop","requestFullScreen","exitFullScreen","showControls","hideControls","enableLoop","disableLoop"],Y=function(r){var t=this;X.forEach(function(i){t[i]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=m(),o="[[VideoContextAction]]@"+n;g().$emit(o,{action:i,id:r,args:t},n)}})};var Z=new f,Q=["onOpen","onError","onMessage","onClose"],tt=0,et=!1;var nt=Object.freeze({showActionSheet:function(t){C(this,"actionSheet.showActionSheet",t)},chooseAddress:function(t){C(this,"address.choose",t)},tradePay:function(t){void 0===t&&(t={}),C(this,"alipay.tradePay",t=y("tradePay",t))},createAnimation:function(t){return new M(t)},createInnerAudioContext:function(t){return new E(this,t)},getRecorderManager:function(t){return D||(D=new F(this)),D},createCanvasContext:function(t){return new R(t)},openChat:function(t){C(this,"chat.open",t)},getClipboard:function(t){C(this,"clipboard.readText",t)},setClipboard:function(t){void 0===t&&(t={}),C(this,"clipboard.writeText",t,{text:t.text})},getNetworkType:function(t){C(this,"connection.getType",t=y("getNetworkType",t),{},function(t){return{networkType:(t.type||"").toUpperCase()}})},onNetworkStatusChange:function(t){L||(L=new f,s("connection").onChange({},function(t){var e=t.type||"";L.emit("networkStatusChange",{networkType:e.toUpperCase()})})),L.on("networkStatusChange",t)},offNetworkStatusChange:function(){L.off("networkStatusChange")},choosePhoneContact:function(t){C(this,"contact.choosePhoneContact",t=y("choosePhoneContact",t),{},function(t){return{name:t.name,mobile:t.phone}})},watchShake:function(t){C(this,"device.onShake",t,{on:!0})},vibrate:function(t){C(this,"device.vibrate",t)},vibrateShort:function(t){C(this,"device.vibrateShort",t)},onUserCaptureScreen:function(t){C(this,"device.onUserCaptureScreen",{success:t})},offUserCaptureScreen:function(){C(this,"device.offUserCaptureScreen")},scan:function(t){C(this,"device.scan",t)},saveFile:function(t){return C(this,"file.saveFile",t,{filePath:V(t)},function(t){return{apFilePath:t.savedFilePath}})},getFileInfo:function(t){return C(this,"file.getFileInfo",t,{filePath:V(t)},function(t){return{size:t.size}})},getSavedFileInfo:function(t){return C(this,"file.getFileInfo",t,{filePath:V(t)})},getSavedFileList:function(t){return C(this,"file.getFileList",t,{},function(t){var e=[];return l(t.fileList)&&(e=t.fileList.map(function(t){return{size:t.size,createTime:t.createTime,apFilePath:t.filePath}})),{fileList:e}})},removeSavedFile:function(t){return C(this,"file.removeFile",t,{filePath:V(t)})},chooseImage:function(t){C(this,"image.chooseImage",t)},compressImage:function(t){C(this,"image.compressImage",t)},previewImage:function(t){C(this,"image.previewImage",t)},saveImage:function(t){C(this,"image.saveImage",t)},getImageInfo:function(t){C(this,"image.getImageInfo",t)},hideKeyboard:function(){C(this,"keyboard.hideKeyboard")},getLocation:function(t){var n=t.type;C(this,"location.getLocation",t,t,function(t){var e={longitude:t.coords.longitude,latitude:t.coords.latitude,accuracy:t.coords.accuracy};return 0<n&&t.address&&(e.country=t.address.country,e.province=t.address.province,e.city=t.address.city,e.cityAdcode=t.address.cityCode,e.district=t.address.area,e.districtAdcode=t.address.areaCode),e})},createLottieContext:function(t){return new q(t)},setBackgroundImage:function(t){C(this,"miniApp.setWebViewBackgroundImage",t)},removeBackgroundImage:function(t){C(this,"miniApp.setWebViewBackgroundImage",t,{color:"",imgUrl:""})},setViewTop:function(t){C(this,"miniApp.setWebViewTop",t)},setCanPullDown:function(t){C(this,"miniApp.setWebViewParams",t)},setShareAppMessage:function(t){void 0===t&&(t={}),C(this,"miniApp.setAppShareInfo",t,{title:t.title,description:t.desc,imageUrl:t.imageUrl,extraParams:t.extraParams})},startPullDownRefresh:function(t){C(this,"miniApp.startPullDownRefresh",t)},stopPullDownRefresh:function(t){C(this,"miniApp.stopPullDownRefresh",t)},setBackgroundTextStyle:function(t){C(this,"miniApp.setBackgroundTextStyle",t)},setBackgroundColor:function(t){C(this,"miniApp.setBackgroundColor",t)},reLaunch:function(t){C(this,"miniApp.reLaunch",t)},pageScrollTo:function(t){void 0===t&&(t={}),_("pageScrollTo",{scrollTop:t.scrollTop})},alert:function(t){void 0===t&&(t={}),C(this,"modal.alert",t,{title:t.title,message:t.content,okTitle:t.buttonText})},confirm:function(t){void 0===t&&(t={});var e=t.confirmButtonText||"\u786e\u5b9a",n=t.cancelButtonText||"\u53d6\u6d88";C(this,"modal.confirm",t,{title:t.title,message:t.content,okTitle:e,cancelTitle:n},function(t){return{confirm:t.data===e}})},showToast:function(t){void 0===t&&(t={}),t.duration||(t.duration=2e3),C(this,"modal.toast",t,{message:t.content,duration:t.duration/1e3})},hideToast:function(t){C(this,"modal.hideToast",t)},prompt:function(t){C(this,"modal.prompt",t)},showLoading:function(t){C(this,"modal.showLoading",t)},hideLoading:function(t){C(this,"modal.hideLoading",t)},sendMtop:function(t){C(this,"sendMtop.request",y("sendMtop",t))},navigateTo:function(t,e){void 0===t&&(t={}),void 0===e&&(e=""),C(this,"navigator.push",t=y("navigateTo",t),{url:z(function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=t&&t.split("/")||[],o=e&&e.split("/")||[],i=t&&W(t),r=e&&W(e),a=i||r;if(t&&W(t)?o=n:n.length&&(o.pop(),o=o.concat(n)),!o.length)return"/";var s=void 0;if(o.length){var c=o[o.length-1];s="."===c||".."===c||""===c}else s=!1;for(var u=0,f=o.length;0<=f;f--){var h=o[f];"."===h?H(o,f):".."===h?(H(o,f),u++):u&&(H(o,f),u--)}if(!a)for(;u--;u)o.unshift("..");!a||""===o[0]||o[0]&&W(o[0])||o.unshift("");var d=o.join("/");return s&&"/"!==d.substr(-1)&&(d+="/"),d}(t.url,e)||"")})},navigateBack:function(t){C(this,"navigator.pop",y("navigateBack",t))},redirectTo:function(t){void 0===t&&(t={}),C(this,"navigator.redirectTo",t=y("redirectTo",t),{url:z(t.url)})},switchTab:function(t){void 0===t&&(t={}),C(this,"navigator.switchTab",t=y("switchTab",t),{url:z(t.url)})},navigateToMiniProgram:function(t){C(this,"navigator.navigateToMiniProgram",t)},navigateBackMiniProgram:function(t){C(this,"navigator.navigateBackMiniProgram",t)},onPageNotify:function(t){C(this,"navigator.pc_onPageNotify",{success:t})},offPageNotify:function(){C(this,"navigator.pc_offPageNotify")},setPageNotifyConfig:function(t){C(this,"navigator.pc_setPageNotifyConfig",t)},getBackStack:function(t){C(this,"navigator.getBackStack",t)},popToHome:function(t){C(this,"navigator.popToHome",t)},setNavigationBar:function(t){C(this,"navigatorBar.setNavigationBar",t)},getStatusBarHeight:function(t){C(this,"navigatorBar.getStatusBarHeight",t,t,function(t){return{height:parseInt(t.data)}})},getNavigationBarHeight:function(t){C(this,"navigatorBar.getHeight",t,t,function(t){return{height:parseInt(t.data)}})},showNavigationBarLoading:function(t){C(this,"navigatorBar.showNavigationBarLoading",t)},hideNavigationBarLoading:function(t){C(this,"navigatorBar.hideNavigationBarLoading",t)},setNavigationBarDrawer:function(t){C(this,"navigatorBar.setDrawer",t)},openNavigationBarDrawer:function(t){C(this,"navigatorBar.openDrawer",t)},closeNavigationBarDrawer:function(t){C(this,"navigatorBar.closeDrawer",t)},setNavigationBarSheet:function(t){C(this,"navigatorBar.setActionSheet",t)},httpRequest:function(o){void 0===o&&(o={});var t=(o=y("httpRequest",o)).method||"GET";if("GET"===t&&d(o.data)){var i=[];Object.keys(o.data).forEach(function(t){var e=o.data[t],n="object"==typeof e?JSON.stringify(e):e;i.push(t+"="+encodeURIComponent(n))});var e=i.join("&");0<=o.url.indexOf("?")?o.url+=e:o.url+="?"+e}C(this,"network.request",o,{method:t,url:o.url,headers:o.headers||{"Content-Type":"application/x-www-form-urlencoded"},dataType:o.dataType||"json",body:o.data},function(t){return{data:t.data,status:t.status,headers:t.headers}})},uploadFile:function(t){C(this,"network.uploadFile",t)},downloadFile:function(t){C(this,"network.downloadFile",t)},makePhoneCall:function(t){void 0===t&&(t={}),C(this,"phone.makePhoneCall",t,{phoneNumber:t.number})},chooseCity:function(t){void 0===t&&(t={}),t.cities&&Array.isArray(t.cities)&&(t.cities=t.cities.map(function(t){return{cityName:t.city,cityCode:t.adCode,spell:t.spell}})),t.hotCities&&Array.isArray(t.hotCities)&&(t.hotCities=t.hotCities.map(function(t){return{cityName:t.city,cityCode:t.adCode,spell:t.spell}})),C(this,"picker.chooseCity",t,t,function(t){return{city:t.cityName,adCode:t.cityCode}})},datePicker:function(t){void 0===t&&(t={}),C(this,"picker.pickDate",t,{format:t.format,value:t.currentDate,min:t.startDate,max:t.endDate},function(t){return{date:t.data}})},setScreenBrightness:function(t){void 0===t&&(t={}),C(this,"screen.setBrightness",t,{brightness:t.brightness})},getScreenBrightness:function(t){C(this,"screen.getScreenBrightness",t,t,function(t){return{brightness:t.value}})},setKeepScreenOn:function(t){void 0===t&&(t={}),C(this,"screen.setAlwaysOn",t,{on:t.keepScreenOn})},shareTinyAppMsg:function(t){C(this,"share.doShare",t)},showSku:function(t){C(this,"sku.show",t)},hideSku:function(t){C(this,"sku.hide",t)},setStorage:function(t){void 0===t&&(t={}),C(this,"storage.setItem",t,{key:t.key,value:$(t)})},setStorageSync:function(t){return x(this,"storage.setItemSync",{key:t.key,value:$(t)})},getStorage:function(t){void 0===t&&(t={}),C(this,"storage.getItem",t,t,G)},getStorageSync:function(t){return G(x(this,"storage.getItemSync",t))},removeStorage:function(t){void 0===t&&(t={}),C(this,"storage.removeItem",t)},removeStorageSync:function(t){return void 0===t&&(t={}),x(this,"storage.removeItemSync",t)},clearStorage:function(t){C(this,"storage.clearStorage",t)},clearStorageSync:function(t){return x(this,"storage.clearStorageSync",t)},getStorageInfo:function(t){C(this,"storage.getStorageInfo",t)},getStorageInfoSync:function(t){return x(this,"storage.getStorageInfoSync",t)},getSystemInfoSync:K,getSystemInfo:function(e){void 0===e&&(e={});try{"function"==typeof e.success&&e.success.call(this,K())}catch(t){"function"==typeof e.fail&&e.fail.call(this,t)}finally{"function"==typeof e.complete&&e.complete.call(this)}},SDKVersion:J,showTabBar:function(t){C(this,"tabBar.show",t)},hideTabBar:function(t){C(this,"tabBar.hide",t)},setTabBarStyle:function(t){C(this,"tabBar.setTabBarStyle",t)},setTabBarItem:function(t){C(this,"tabBar.setTabBarItem",t)},setTabBarBadge:function(t){C(this,"tabBar.setTabBarBadge",t)},removeTabBarBadge:function(t){C(this,"tabBar.removeTabBarBadge",t)},showTabBarRedDot:function(t){C(this,"tabBar.showTabBarRedDot",t)},hideTabBarRedDot:function(t){C(this,"tabBar.hideTabBarRedDot",t)},uccBind:function(t){C(this,"ucc.uccBind",t)},uccTrustLogin:function(t){C(this,"ucc.uccTrustLogin",t)},uccUnbind:function(t){C(this,"ucc.uccUnbind",t)},reportAnalytics:function(t,e){void 0===e&&(e={}),"click"==t||"enter"==t||"expose"==t?C(this,"userTrack.commitut",{type:t,eventId:e.eventId,name:e.name,comName:e.comName,arg1:e.arg1,arg2:e.arg2,arg3:e.arg3,param:e.param}):C(this,"userTrack.customAdvance",{eventId:e.eventId,name:e.name,comName:e.comName,arg1:e.arg1,arg2:e.arg2,arg3:e.arg3,param:e.param})},createVideoContext:function(t){return new Y(t)},chooseVideo:function(t){C(this,"video.chooseVideo",t,t,function(t){return t.apFilePath&&(t.tempFilePath=t.apFilePath,delete t.apFilePath),t})},saveVideoToPhotosAlbum:function(t){C(this,"video.saveVideoToPhotosAlbum",t)},getAuthUserInfo:function(t){C(this,"sendMtop.request",t,{api:"mtop.taobao.openlink.openinfo.user.get",v:"1.0",type:"GET"},function(t){var e={nickName:t.data.mixNick,userId:t.data.openId};return t.data.avatar&&(e.avatar=t.data.avatar),t.data.unionId&&(e.unionId=t.data.unionId),e})},getTBCode:function(t){C(this,"sendMtop.request",t,{api:"mtop.taobao.openlink.basic.login.auth.code",v:"1.0",type:"GET"},function(t){return{code:t.data.result}})},getTBSessionInfo:function(t){C(this,"wopc.getSessionKey",t,t,function(t){return{data:t}})},setTBSessionInfo:function(t){void 0===t&&(t={}),C(this,"wopc.setSessionKey",t,t.sessionInfo,function(t){return{success:!0}})},getSetting:function(t){C(this,"wopc.getSetting",t)},openSetting:function(t){C(this,"wopc.openSetting",t)},authorize:function(t){C(this,"wopc.authorize",t)},connectSocket:function(t){var n=this;void 0===t&&(t={}),et&&(C(this,"webSocket.close",{instanceId:tt}),et=!1,tt++),C(this,"webSocket.webSocket",t,{instanceId:tt,url:t.url,protocol:""},function(t){return et=!0,t}),Q.forEach(function(e){C(n,"webSocket."+e,{instanceId:tt,success:function(t){Z.emit(e,t)}})})},sendSocketMessage:function(t){void 0===t&&(t={}),C(this,"webSocket.send",t,{instanceId:tt,data:t.data})},closeSocket:function(t){C(this,"webSocket.close",t,{instanceId:tt},function(t){return et=!1,tt++,t})},onSocketOpen:function(t){Z.on("onOpen",t)},offSocketOpen:function(t){Z.off("onOpen",t)},onSocketError:function(t){Z.on("onError",t)},offSocketError:function(t){Z.off("onError",t)},onSocketMessage:function(e){Z.on("onMessage",function(t){e&&e({data:t,isBuffer:!1})})},offSocketMessage:function(t){Z.off("onMessage",t)},onSocketClose:function(t){Z.on("onClose",t)},offSocketClose:function(t){Z.off("onClose",t)}}),ot=function(t){var n=this;this._name="my",this._moduleAPIs={},this._modifier={},d(t)&&(this._options=t,this._name=t.defaultName,this._context=t.context,this._modifier.origin=t.label),this._host={getContext:function(){return n._context},getModifier:function(){return n._modifier}};var e=g();e&&e.$on("registerModuleAPI",function(t){var e=t.data;n.registerScopedAPIs(e)})};function it(t){var e;g().$on("[[ModuleAPIEvent]]",function(t){var e=t.type;void 0===e&&(e="");var n=t.data;void 0===n&&(n={});var o=e;n.event&&n.event.name&&(o+="."+n.event.name),I.emit(o,n)}),t&&t.preprocessor&&function(t,e){if(d(t)&&d(e))for(var n in e)o=t,i=n,Object.prototype.hasOwnProperty.call(o,i)&&"function"==typeof e[n]&&(v[n]=e[n]);var o,i}(my,t.preprocessor),t&&t.errorHandler&&"function"==typeof(e=t.errorHandler)&&(A=e);var n=new ot(t);return n.registerModuleAPIs(nt),n.getAPIs()}return ot.prototype.canIUse=function(t){return"string"==typeof t&&t in this._moduleAPIs},ot.prototype.getAPIs=function(){var t,e=this,n={};for(var o in this._moduleAPIs)n[o]=this._moduleAPIs[o],"function"==typeof n[o]&&n[o].bind(this._host);return n.canIUse=function(t){return e.canIUse(t)},(t={})[this._name]=n,t},ot.prototype.registerModuleAPIs=function(t){if(d(t))for(var e in t)this._moduleAPIs[e]=t[e]},ot.prototype.registerScopedAPIs=function(t){var n=this;void 0===t&&(t={});var o=t.scope,e=t.map;if(!o)return console.error('"data.scope" is undefined on "registerModuleAPI" event.');if(!l(e))return console.error('"data.map" is undefined or not a array on "registerModuleAPI" event.');if(this._moduleAPIs[o]&&!d(this._moduleAPIs[o]))return console.error('"'+this._name+"."+o+"\" is already exist and can't be overridden.");var i=this._moduleAPIs[o]=this._moduleAPIs[o]||{};e.forEach(function(e){i[e.apiName]&&console.warn(n._name+"."+o+"."+e.apiName+" is already exist and will be overridden!"),i[e.apiName]=e.isSync?function(t){return C(n._host,e.moduleMethod,t)}:function(t){return x(n._host,e.moduleMethod,t)}})},function(e,n,t){void 0===t&&(t=!0);var o=i();try{Object.defineProperty(o,e,{value:n,configurable:!0,enumerable:!0,writable:!t})}catch(t){o[e]=n}}("__WINDMILL_MODULE_API__",{getAPIs:it}),it}); |
{ | ||
"name": "windmill-module-api", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Standard module APIs of windmill.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
87142
1686