@mpxjs/api-proxy
Advanced tools
Comparing version 2.2.26 to 2.2.27
{ | ||
"name": "@mpxjs/api-proxy", | ||
"version": "2.2.26", | ||
"version": "2.2.27", | ||
"description": "convert miniprogram API at each end", | ||
@@ -30,3 +30,3 @@ "module": "src/index.js", | ||
"homepage": "https://github.com/didi/mpx#readme", | ||
"gitHead": "5ed3e9b2b894ac02837d5292cc118c348e4d4a9b" | ||
"gitHead": "e8ff5ca5befcafdf669f97643dd08e6707b93c13" | ||
} |
@@ -5,2 +5,10 @@ import { error, getEnvObj } from '../utils' | ||
function genFromMap (platforms = []) { | ||
const result = {} | ||
platforms.forEach((platform) => { | ||
result[`__mpx_src_mode_${platform}__`] = platform | ||
}) | ||
return result | ||
} | ||
function transformApi (target, options) { | ||
@@ -14,9 +22,3 @@ const wxToAliApi = getWxToAliApi({ optimize: options.optimize }) | ||
} | ||
const platforms = [ | ||
'__mpx_srcMode_wx', | ||
'__mpx_srcMode_ali', | ||
'__mpx_srcMode_swan', | ||
'__mpx_srcMode_qq', | ||
'__mpx_srcMode_tt' | ||
] | ||
const fromMap = genFromMap(['wx', 'ali', 'swan', 'qq', 'tt']) | ||
@@ -26,3 +28,3 @@ const envObj = getEnvObj() | ||
function joinName (from = '', to = '') { | ||
return `${from.replace(/^__mpx_srcMode_/, '')}_${to}` | ||
return `${fromMap[from]}_${to}` | ||
} | ||
@@ -45,3 +47,3 @@ | ||
if (typeof from !== 'string' || !~platforms.indexOf(from)) { | ||
if (typeof from !== 'string' || !fromMap[from]) { | ||
args.push(from) | ||
@@ -48,0 +50,0 @@ from = options.from |
@@ -7,3 +7,3 @@ import { getEnvObj } from './utils' | ||
const list = promisify(envObj, usePromise, whiteList) | ||
const platforms = ['wx', 'ali', 'swan', 'qq', 'tt'] | ||
const platforms = ['wx', 'ali', 'swan', 'qq', 'tt'].map(p => `__mpx_src_mode_${p}__`) | ||
@@ -10,0 +10,0 @@ Object.keys(list).forEach(api => { |
36620
771