From 0090392e9775b44098850d1634ecf9eca3572f14 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 15 Aug 2019 13:57:56 +0800 Subject: [PATCH] build runtime --- packages/uni-app-plus-nvue/dist/index.js | 61 ++++++++++++------- .../uni-app-plus-nvue/dist/index.legacy.js | 12 +++- packages/uni-app-plus/dist/index.js | 6 +- packages/uni-app-plus/package.json | 2 +- packages/uni-mp-alipay/dist/index.js | 6 +- packages/uni-mp-alipay/package.json | 2 +- packages/uni-mp-baidu/dist/index.js | 20 +++++- packages/uni-mp-baidu/package.json | 2 +- packages/uni-mp-qq/dist/index.js | 36 +++++------ packages/uni-mp-qq/package.json | 2 +- packages/uni-mp-toutiao/dist/index.js | 6 +- packages/uni-mp-toutiao/package.json | 2 +- packages/uni-mp-weixin/dist/index.js | 6 +- packages/uni-mp-weixin/package.json | 2 +- src/core/helpers/promise.js | 6 +- .../mp-baidu/runtime/api/protocols.js | 2 +- 16 files changed, 106 insertions(+), 67 deletions(-) diff --git a/packages/uni-app-plus-nvue/dist/index.js b/packages/uni-app-plus-nvue/dist/index.js index aff7aa6ae..783878ea5 100644 --- a/packages/uni-app-plus-nvue/dist/index.js +++ b/packages/uni-app-plus-nvue/dist/index.js @@ -1281,6 +1281,12 @@ var serviceContext = (function () { isConnected: networkType !== 'none', networkType }); + }); + + plus.globalEvent.addEventListener('KeyboardHeightChange', function (event) { + publish('onKeyboardHeightChange', { + height: event.height + }); }); } @@ -1506,7 +1512,8 @@ var serviceContext = (function () { ]; const keyboard = [ - 'hideKeyboard' + 'hideKeyboard', + 'onKeyboardHeightChange' ]; const ui = [ @@ -1819,7 +1826,7 @@ var serviceContext = (function () { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -1852,8 +1859,8 @@ var serviceContext = (function () { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } @@ -5856,9 +5863,6 @@ var serviceContext = (function () { return createDownloadTaskById(++downloadTaskId, args) } - const USER_AGENT = - 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13G36 MicroMessenger/6.5.1 NetType/WIFI Language/zh_CN'; - let requestTaskId = 0; const requestTasks = {}; @@ -5891,9 +5895,7 @@ var serviceContext = (function () { if (!hasContentType && method === 'POST') { headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; } - if (__uniConfig.crossDomain === true) { - headers['User-Agent'] = USER_AGENT; - } + const timeout = __uniConfig.networkTimeout.request; if (timeout) { abortTimeout = setTimeout(() => { @@ -5908,7 +5910,7 @@ var serviceContext = (function () { } const options = { method, - url, + url: url.trim(), // weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应 headers, type: 'text', @@ -8327,6 +8329,22 @@ var serviceContext = (function () { createAnimation: createAnimation }); + const callbacks$7 = []; + + onMethod('onKeyboardHeightChange', res => { + callbacks$7.forEach(callbackId => { + invoke(callbackId, res); + }); + }); + + function onKeyboardHeightChange (callbackId) { + callbacks$7.push(callbackId); + } + + var require_context_module_1_17 = /*#__PURE__*/Object.freeze({ + onKeyboardHeightChange: onKeyboardHeightChange + }); + function pageScrollTo$1 (args) { const pages = getCurrentPages(); if (pages.length) { @@ -8335,7 +8353,7 @@ var serviceContext = (function () { return {} } - var require_context_module_1_17 = /*#__PURE__*/Object.freeze({ + var require_context_module_1_18 = /*#__PURE__*/Object.freeze({ pageScrollTo: pageScrollTo$1 }); @@ -8359,29 +8377,29 @@ var serviceContext = (function () { const hideTabBarRedDot$1 = removeTabBarBadge$1; - var require_context_module_1_18 = /*#__PURE__*/Object.freeze({ + var require_context_module_1_19 = /*#__PURE__*/Object.freeze({ removeTabBarBadge: removeTabBarBadge$1, showTabBarRedDot: showTabBarRedDot$1, hideTabBarRedDot: hideTabBarRedDot$1 }); - const callbacks$7 = []; + const callbacks$8 = []; onMethod('onViewDidResize', res => { - callbacks$7.forEach(callbackId => { + callbacks$8.forEach(callbackId => { invoke(callbackId, res); }); }); function onWindowResize (callbackId) { - callbacks$7.push(callbackId); + callbacks$8.push(callbackId); } function offWindowResize (callbackId) { // 此处和微信平台一致查询不到去掉最后一个 - callbacks$7.splice(callbacks$7.indexOf(callbackId), 1); + callbacks$8.splice(callbacks$8.indexOf(callbackId), 1); } - var require_context_module_1_19 = /*#__PURE__*/Object.freeze({ + var require_context_module_1_20 = /*#__PURE__*/Object.freeze({ onWindowResize: onWindowResize, offWindowResize: offWindowResize }); @@ -8408,9 +8426,10 @@ var serviceContext = (function () { './network/upload-file.js': require_context_module_1_14, './storage/storage.js': require_context_module_1_15, './ui/create-animation.js': require_context_module_1_16, - './ui/page-scroll-to.js': require_context_module_1_17, - './ui/tab-bar.js': require_context_module_1_18, - './ui/window.js': require_context_module_1_19, + './ui/keyboard.js': require_context_module_1_17, + './ui/page-scroll-to.js': require_context_module_1_18, + './ui/tab-bar.js': require_context_module_1_19, + './ui/window.js': require_context_module_1_20, }; var req = function req(key) { diff --git a/packages/uni-app-plus-nvue/dist/index.legacy.js b/packages/uni-app-plus-nvue/dist/index.legacy.js index 0b605024c..6365db5cc 100644 --- a/packages/uni-app-plus-nvue/dist/index.legacy.js +++ b/packages/uni-app-plus-nvue/dist/index.legacy.js @@ -122,7 +122,7 @@ function invokeApi (method, api, options, ...params) { } const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -149,8 +149,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } @@ -695,6 +695,9 @@ function initUni (uni, nvue, plus, BroadcastChannel) { if (typeof Proxy !== 'undefined') { return new Proxy({}, { get (target, name) { + if (target[name]) { + return target[name] + } if (apis[name]) { return apis[name] } @@ -705,6 +708,9 @@ function initUni (uni, nvue, plus, BroadcastChannel) { return } return promisify(name, uni[name]) + }, + set (target, name, value) { + target[name] = value; } }) } diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index ac8b94efb..d84c34f42 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -258,8 +258,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index 4d0f38e63..4be32f029 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.251", + "version": "0.0.252", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index 0ea57d3e3..96723b57c 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -258,8 +258,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index 84f5306e9..c57f66e2d 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-alipay", - "version": "0.0.825", + "version": "0.0.826", "description": "uni-app mp-alipay", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index fbefbf7bc..42f42b5e1 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -258,8 +258,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } @@ -426,6 +426,16 @@ function createTodoMethod (contextName, methodName) { console.error(`百度小程序 ${contextName}暂不支持${methodName}`); } } + +function _handleEnvInfo (result) { + result.miniProgram = { + appId: result.appKey + }; + result.plugin = { + version: result.sdkVersion + }; +} + // 需要做转换的 API 列表 const protocols = { request: { @@ -479,6 +489,10 @@ const protocols = { }, showShareMenu: { name: 'openShare' + }, + getAccountInfoSync: { + name: 'getEnvInfoSync', + returnValue: _handleEnvInfo } }; diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index eb59f8820..b4bb3d991 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.855", + "version": "0.0.856", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js index 8a947891d..9b2c8477c 100644 --- a/packages/uni-mp-qq/dist/index.js +++ b/packages/uni-mp-qq/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -258,8 +258,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } @@ -402,23 +402,11 @@ const todos = [ 'canIUse', 'onMemoryWarning', 'onNetworkStatusChange', - 'onAccelerometerChange', - 'startAccelerometer', - 'stopAccelerometer', - 'onCompassChange', - 'startCompass', - 'scanCode', 'startBeaconDiscovery', 'stopBeaconDiscovery', 'getBeacons', 'onBeaconUpdate', 'onBeaconServiceChange', - 'setScreenBrightness', - 'getScreenBrightness', - 'setKeepScreenOn', - 'onUserCaptureScreen', - 'vibrateLong', - 'vibrateShort', 'addPhoneContact', 'getHCEState', 'startHCE', @@ -449,13 +437,25 @@ const todos = [ 'checkIsSupportSoterAuthentication', 'startSoterAuthentication', 'checkIsSoterEnrolledInDevice', - 'createWorker', 'reportMonitor', 'getLogManager', - 'onUserCaptureScreen', 'reportAnalytics' ]; -const canIUses = []; +const canIUses = [ + 'scanCode', + 'startAccelerometer', + 'stopAccelerometer', + 'onAccelerometerChange', + 'startCompass', + 'onCompassChange', + 'setScreenBrightness', + 'getScreenBrightness', + 'setKeepScreenOn', + 'onUserCaptureScreen', + 'vibrateLong', + 'vibrateShort', + 'createWorker' +]; const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; diff --git a/packages/uni-mp-qq/package.json b/packages/uni-mp-qq/package.json index 8b8feb73e..1122d964d 100644 --- a/packages/uni-mp-qq/package.json +++ b/packages/uni-mp-qq/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-qq", - "version": "0.0.109", + "version": "0.0.110", "description": "uni-app mp-qq", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index cb80851df..2d407f840 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -258,8 +258,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index f2aff6e8f..484c5531c 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.349", + "version": "0.0.350", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index 7fd50691d..6b0325020 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -231,7 +231,7 @@ const promiseInterceptor = { }; const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/; const CONTEXT_API_RE = /^create|Manager$/; @@ -258,8 +258,8 @@ function handlePromise (promise) { function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index 9536a4ac2..2e878aa6e 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.971", + "version": "0.0.972", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/helpers/promise.js b/src/core/helpers/promise.js index 3d035dba0..b4f72e0d6 100644 --- a/src/core/helpers/promise.js +++ b/src/core/helpers/promise.js @@ -8,7 +8,7 @@ import { } from './interceptor' const SYNC_API_RE = - /^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/ + /^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/ const CONTEXT_API_RE = /^create|Manager$/ @@ -41,8 +41,8 @@ function handlePromise (promise) { export function shouldPromise (name) { if ( isContextApi(name) || - isSyncApi(name) || - isCallbackApi(name) + isSyncApi(name) || + isCallbackApi(name) ) { return false } diff --git a/src/platforms/mp-baidu/runtime/api/protocols.js b/src/platforms/mp-baidu/runtime/api/protocols.js index 1cb56a7a0..93bfd1177 100644 --- a/src/platforms/mp-baidu/runtime/api/protocols.js +++ b/src/platforms/mp-baidu/runtime/api/protocols.js @@ -106,7 +106,7 @@ const protocols = { name: 'openShare' }, getAccountInfoSync: { - name: "getEnvInfoSync", + name: 'getEnvInfoSync', returnValue: _handleEnvInfo } } -- GitLab