提交 8690a6b6 编写于 作者: fxy060608's avatar fxy060608

build uni runtime(caniuse)

上级 60146762
...@@ -40,7 +40,7 @@ const camelize = cached((str) => { ...@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
}); });
const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/;
const CONTEXT_API_RE = /^create|Manager$/; const CONTEXT_API_RE = /^create|Manager$/;
...@@ -145,7 +145,7 @@ function upx2px (number, newDeviceWidth) { ...@@ -145,7 +145,7 @@ function upx2px (number, newDeviceWidth) {
} }
// 不支持的 API 列表 // 不支持的 API 列表
const TODOS = [ const todos = [
'saveImageToPhotosAlbum', 'saveImageToPhotosAlbum',
'getRecorderManager', 'getRecorderManager',
'getBackgroundAudioManager', 'getBackgroundAudioManager',
...@@ -170,7 +170,6 @@ const TODOS = [ ...@@ -170,7 +170,6 @@ const TODOS = [
'hideTabBarRedDot', 'hideTabBarRedDot',
'setBackgroundColor', 'setBackgroundColor',
'setBackgroundTextStyle', 'setBackgroundTextStyle',
'startPullDownRefresh',
'createIntersectionObserver', 'createIntersectionObserver',
'authorize', 'authorize',
'openSetting', 'openSetting',
...@@ -191,6 +190,11 @@ const TODOS = [ ...@@ -191,6 +190,11 @@ const TODOS = [
'offWindowResize' 'offWindowResize'
]; ];
// 存在兼容性的 API 列表
const canIUses = [
'startPullDownRefresh'
];
function _handleNetworkInfo (result) { function _handleNetworkInfo (result) {
switch (result.networkType) { switch (result.networkType) {
case 'NOTREACHABLE': case 'NOTREACHABLE':
...@@ -462,7 +466,7 @@ const protocols = { // 需要做转换的 API 列表 ...@@ -462,7 +466,7 @@ const protocols = { // 需要做转换的 API 列表
requestPayment: { requestPayment: {
name: 'tradePay', name: 'tradePay',
args: { args: {
orderInfo: 'orderStr' orderInfo: 'tradeNO'
} }
}, },
getBLEDeviceServices: { getBLEDeviceServices: {
...@@ -505,10 +509,6 @@ const protocols = { // 需要做转换的 API 列表 ...@@ -505,10 +509,6 @@ const protocols = { // 需要做转换的 API 列表
} }
}; };
TODOS.forEach(todoApi => {
protocols[todoApi] = false;
});
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; const CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
function processCallback (methodName, method, returnValue) { function processCallback (methodName, method, returnValue) {
...@@ -586,7 +586,7 @@ function wrapper (methodName, method) { ...@@ -586,7 +586,7 @@ function wrapper (methodName, method) {
const todoApis = Object.create(null); const todoApis = Object.create(null);
const TODOS$1 = [ const TODOS = [
'subscribePush', 'subscribePush',
'unsubscribePush', 'unsubscribePush',
'onPush', 'onPush',
...@@ -607,7 +607,7 @@ function createTodoApi (name) { ...@@ -607,7 +607,7 @@ function createTodoApi (name) {
} }
} }
TODOS$1.forEach(function (name) { TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name); todoApis[name] = createTodoApi(name);
}); });
...@@ -655,12 +655,8 @@ function getStorageSync (key) { ...@@ -655,12 +655,8 @@ function getStorageSync (key) {
const result = my.getStorageSync({ const result = my.getStorageSync({
key key
}); });
// 不知道会不会出现 success 为 false 情况,暂时这样处理下。 // 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
if (result.success) { return result.data !== null ? result.data : ''
return result.data || ''
} else {
return ''
}
} }
function removeStorageSync (key) { function removeStorageSync (key) {
return my.removeStorageSync({ return my.removeStorageSync({
...@@ -1547,6 +1543,17 @@ function createComponent (vueOptions) { ...@@ -1547,6 +1543,17 @@ function createComponent (vueOptions) {
return initComponent(componentOptions, vueOptions) return initComponent(componentOptions, vueOptions)
} }
todos.forEach(todoApi => {
protocols[todoApi] = false;
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
if (!my.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
});
let uni = {}; let uni = {};
if (typeof Proxy !== 'undefined') { if (typeof Proxy !== 'undefined') {
......
{ {
"name": "@dcloudio/uni-mp-alipay", "name": "@dcloudio/uni-mp-alipay",
"version": "0.0.801", "version": "0.0.802",
"description": "uni-app mp-alipay", "description": "uni-app mp-alipay",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
...@@ -40,7 +40,7 @@ const camelize = cached((str) => { ...@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
}); });
const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/;
const CONTEXT_API_RE = /^create|Manager$/; const CONTEXT_API_RE = /^create|Manager$/;
...@@ -145,7 +145,7 @@ function upx2px (number, newDeviceWidth) { ...@@ -145,7 +145,7 @@ function upx2px (number, newDeviceWidth) {
} }
// 不支持的 API 列表 // 不支持的 API 列表
const TODOS = [ const todos = [
'hideKeyboard', 'hideKeyboard',
'onGyroscopeChange', 'onGyroscopeChange',
'startGyroscope', 'startGyroscope',
...@@ -178,6 +178,9 @@ const TODOS = [ ...@@ -178,6 +178,9 @@ const TODOS = [
'offWindowResize' 'offWindowResize'
]; ];
// 存在兼容性的 API 列表
const canIUses = [];
function createTodoMethod (contextName, methodName) { function createTodoMethod (contextName, methodName) {
return function unsupported () { return function unsupported () {
console.error(`百度小程序 ${contextName}暂不支持${methodName}`); console.error(`百度小程序 ${contextName}暂不支持${methodName}`);
...@@ -239,10 +242,6 @@ const protocols = { ...@@ -239,10 +242,6 @@ const protocols = {
} }
}; };
TODOS.forEach(todoApi => {
protocols[todoApi] = false;
});
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; const CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
function processCallback (methodName, method, returnValue) { function processCallback (methodName, method, returnValue) {
...@@ -320,7 +319,7 @@ function wrapper (methodName, method) { ...@@ -320,7 +319,7 @@ function wrapper (methodName, method) {
const todoApis = Object.create(null); const todoApis = Object.create(null);
const TODOS$1 = [ const TODOS = [
'subscribePush', 'subscribePush',
'unsubscribePush', 'unsubscribePush',
'onPush', 'onPush',
...@@ -341,7 +340,7 @@ function createTodoApi (name) { ...@@ -341,7 +340,7 @@ function createTodoApi (name) {
} }
} }
TODOS$1.forEach(function (name) { TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name); todoApis[name] = createTodoApi(name);
}); });
...@@ -1159,6 +1158,17 @@ function createComponent (vueOptions) { ...@@ -1159,6 +1158,17 @@ function createComponent (vueOptions) {
return initComponent$1(componentOptions, vueOptions) return initComponent$1(componentOptions, vueOptions)
} }
todos.forEach(todoApi => {
protocols[todoApi] = false;
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
if (!swan.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
});
let uni = {}; let uni = {};
if (typeof Proxy !== 'undefined') { if (typeof Proxy !== 'undefined') {
......
{ {
"name": "@dcloudio/uni-mp-baidu", "name": "@dcloudio/uni-mp-baidu",
"version": "0.0.827", "version": "0.0.828",
"description": "uni-app mp-baidu", "description": "uni-app mp-baidu",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
...@@ -40,7 +40,7 @@ const camelize = cached((str) => { ...@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
}); });
const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/;
const CONTEXT_API_RE = /^create|Manager$/; const CONTEXT_API_RE = /^create|Manager$/;
...@@ -145,7 +145,7 @@ function upx2px (number, newDeviceWidth) { ...@@ -145,7 +145,7 @@ function upx2px (number, newDeviceWidth) {
} }
// 不支持的 API 列表 // 不支持的 API 列表
const TODOS = [ const todos = [
'hideKeyboard', 'hideKeyboard',
'onSocketOpen', 'onSocketOpen',
'onSocketError', 'onSocketError',
...@@ -227,6 +227,9 @@ const TODOS = [ ...@@ -227,6 +227,9 @@ const TODOS = [
'offWindowResize' 'offWindowResize'
]; ];
// 存在兼容性的 API 列表
const canIUses = [];
// 需要做转换的 API 列表 // 需要做转换的 API 列表
const protocols = { const protocols = {
chooseImage: { chooseImage: {
...@@ -300,10 +303,6 @@ const protocols = { ...@@ -300,10 +303,6 @@ const protocols = {
} }
}; };
TODOS.forEach(todoApi => {
protocols[todoApi] = false;
});
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; const CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
function processCallback (methodName, method, returnValue) { function processCallback (methodName, method, returnValue) {
...@@ -381,7 +380,7 @@ function wrapper (methodName, method) { ...@@ -381,7 +380,7 @@ function wrapper (methodName, method) {
const todoApis = Object.create(null); const todoApis = Object.create(null);
const TODOS$1 = [ const TODOS = [
'subscribePush', 'subscribePush',
'unsubscribePush', 'unsubscribePush',
'onPush', 'onPush',
...@@ -402,7 +401,7 @@ function createTodoApi (name) { ...@@ -402,7 +401,7 @@ function createTodoApi (name) {
} }
} }
TODOS$1.forEach(function (name) { TODOS.forEach(function (name) {
todoApis[name] = createTodoApi(name); todoApis[name] = createTodoApi(name);
}); });
...@@ -1166,6 +1165,17 @@ function createComponent (vueOptions) { ...@@ -1166,6 +1165,17 @@ function createComponent (vueOptions) {
return initComponent$1(componentOptions, vueOptions) return initComponent$1(componentOptions, vueOptions)
} }
todos.forEach(todoApi => {
protocols[todoApi] = false;
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
if (!tt.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
});
let uni = {}; let uni = {};
if (typeof Proxy !== 'undefined') { if (typeof Proxy !== 'undefined') {
......
{ {
"name": "@dcloudio/uni-mp-toutiao", "name": "@dcloudio/uni-mp-toutiao",
"version": "0.0.325", "version": "0.0.326",
"description": "uni-app mp-toutiao", "description": "uni-app mp-toutiao",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
...@@ -40,7 +40,7 @@ const camelize = cached((str) => { ...@@ -40,7 +40,7 @@ const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
}); });
const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/; const SYNC_API_RE = /subNVue|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$/;
const CONTEXT_API_RE = /^create|Manager$/; const CONTEXT_API_RE = /^create|Manager$/;
...@@ -144,7 +144,9 @@ function upx2px (number, newDeviceWidth) { ...@@ -144,7 +144,9 @@ function upx2px (number, newDeviceWidth) {
return number < 0 ? -result : result return number < 0 ? -result : result
} }
var protocols = {}; const protocols = {};
const todos = [];
const canIUses = [];
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']; const CALLBACKS = ['success', 'fail', 'cancel', 'complete'];
...@@ -1004,6 +1006,17 @@ function createComponent (vueOptions) { ...@@ -1004,6 +1006,17 @@ function createComponent (vueOptions) {
return initComponent(componentOptions, vueOptions) return initComponent(componentOptions, vueOptions)
} }
todos.forEach(todoApi => {
protocols[todoApi] = false;
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
if (!wx.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
});
let uni = {}; let uni = {};
if (typeof Proxy !== 'undefined') { if (typeof Proxy !== 'undefined') {
......
{ {
"name": "@dcloudio/uni-mp-weixin", "name": "@dcloudio/uni-mp-weixin",
"version": "0.0.949", "version": "0.0.950",
"description": "uni-app mp-weixin", "description": "uni-app mp-weixin",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册