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

build uni runtime

上级 b0805960
......@@ -214,8 +214,12 @@ function wrapper (methodName, method) {
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
const returnValue = wx[options.name || methodName](arg1, arg2);
const args = [arg1];
if (typeof arg2 !== 'undefined') {
args.push(arg2);
}
const returnValue = wx[options.name || methodName].apply(wx, args);
if (isSyncApi(methodName)) { // 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName))
}
......@@ -757,7 +761,15 @@ function handleEvent (event) {
eventsArray.forEach(eventArray => {
const methodName = eventArray[0];
if (methodName) {
const handler = this.$vm[methodName];
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
throw new Error(` _vm.${methodName} is not a function`)
}
......@@ -767,7 +779,7 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(this.$vm, processEventArgs(
handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
......@@ -1101,7 +1113,8 @@ todos.forEach(todoApi => {
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name
: canIUseApi;
if (!wx.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
......@@ -1117,7 +1130,7 @@ if (typeof Proxy !== 'undefined') {
}
if (api[name]) {
return promisify(name, api[name])
}
}
if (!hasOwn(wx, name) && !hasOwn(protocols, name)) {
return
}
......@@ -1138,6 +1151,10 @@ if (typeof Proxy !== 'undefined') {
});
}
wx.createApp = createApp;
wx.createPage = createPage;
wx.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
......
{
"name": "@dcloudio/uni-app-plus",
"version": "0.0.235",
"version": "0.0.236",
"description": "uni-app app-plus",
"main": "dist/index.js",
"scripts": {
......
......@@ -580,8 +580,12 @@ function wrapper (methodName, method) {
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
const returnValue = my[options.name || methodName](arg1, arg2);
const args = [arg1];
if (typeof arg2 !== 'undefined') {
args.push(arg2);
}
const returnValue = my[options.name || methodName].apply(my, args);
if (isSyncApi(methodName)) { // 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName))
}
......@@ -1067,7 +1071,15 @@ function handleEvent (event) {
eventsArray.forEach(eventArray => {
const methodName = eventArray[0];
if (methodName) {
const handler = this.$vm[methodName];
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
throw new Error(` _vm.${methodName} is not a function`)
}
......@@ -1077,7 +1089,7 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(this.$vm, processEventArgs(
handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
......@@ -1464,7 +1476,11 @@ function parsePage (vuePageOptions) {
__l: handleLink$1
};
initHooks(pageOptions, hooks$1);
initHooks(pageOptions, hooks$1);
if (vueOptions.methods && vueOptions.methods.formReset) {
pageOptions.formReset = vueOptions.methods.formReset;
}
return pageOptions
}
......@@ -1590,7 +1606,8 @@ todos.forEach(todoApi => {
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name
: canIUseApi;
if (!my.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
......@@ -1606,14 +1623,14 @@ if (typeof Proxy !== 'undefined') {
}
if (api[name]) {
return promisify(name, api[name])
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
if (!hasOwn(my, name) && !hasOwn(protocols, name)) {
return
......@@ -1624,13 +1641,13 @@ if (typeof Proxy !== 'undefined') {
} else {
uni.upx2px = upx2px;
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
}
Object.keys(api).forEach(name => {
......@@ -1644,6 +1661,10 @@ if (typeof Proxy !== 'undefined') {
});
}
my.createApp = createApp;
my.createPage = createPage;
my.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
......
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.805",
"version": "0.0.806",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
......
......@@ -337,8 +337,12 @@ function wrapper (methodName, method) {
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
const returnValue = swan[options.name || methodName](arg1, arg2);
const args = [arg1];
if (typeof arg2 !== 'undefined') {
args.push(arg2);
}
const returnValue = swan[options.name || methodName].apply(swan, args);
if (isSyncApi(methodName)) { // 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName))
}
......@@ -884,7 +888,15 @@ function handleEvent (event) {
eventsArray.forEach(eventArray => {
const methodName = eventArray[0];
if (methodName) {
const handler = this.$vm[methodName];
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
throw new Error(` _vm.${methodName} is not a function`)
}
......@@ -894,7 +906,7 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(this.$vm, processEventArgs(
handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
......@@ -1237,7 +1249,8 @@ todos.forEach(todoApi => {
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name
: canIUseApi;
if (!swan.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
......@@ -1253,14 +1266,14 @@ if (typeof Proxy !== 'undefined') {
}
if (api[name]) {
return promisify(name, api[name])
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
if (!hasOwn(swan, name) && !hasOwn(protocols, name)) {
return
......@@ -1271,13 +1284,13 @@ if (typeof Proxy !== 'undefined') {
} else {
uni.upx2px = upx2px;
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
}
Object.keys(api).forEach(name => {
......@@ -1291,6 +1304,10 @@ if (typeof Proxy !== 'undefined') {
});
}
swan.createApp = createApp;
swan.createPage = createPage;
swan.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
......
{
"name": "@dcloudio/uni-mp-baidu",
"version": "0.0.833",
"version": "0.0.834",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
......
......@@ -398,8 +398,12 @@ function wrapper (methodName, method) {
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
const returnValue = tt[options.name || methodName](arg1, arg2);
const args = [arg1];
if (typeof arg2 !== 'undefined') {
args.push(arg2);
}
const returnValue = tt[options.name || methodName].apply(tt, args);
if (isSyncApi(methodName)) { // 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName))
}
......@@ -903,7 +907,15 @@ function handleEvent (event) {
eventsArray.forEach(eventArray => {
const methodName = eventArray[0];
if (methodName) {
const handler = this.$vm[methodName];
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
throw new Error(` _vm.${methodName} is not a function`)
}
......@@ -913,7 +925,7 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(this.$vm, processEventArgs(
handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
......@@ -1312,7 +1324,8 @@ todos.forEach(todoApi => {
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name
: canIUseApi;
if (!tt.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
......@@ -1328,14 +1341,14 @@ if (typeof Proxy !== 'undefined') {
}
if (api[name]) {
return promisify(name, api[name])
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
if (!hasOwn(tt, name) && !hasOwn(protocols, name)) {
return
......@@ -1346,13 +1359,13 @@ if (typeof Proxy !== 'undefined') {
} else {
uni.upx2px = upx2px;
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
}
Object.keys(api).forEach(name => {
......@@ -1366,6 +1379,10 @@ if (typeof Proxy !== 'undefined') {
});
}
tt.createApp = createApp;
tt.createPage = createPage;
tt.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
......
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "0.0.333",
"version": "0.0.334",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"scripts": {
......
......@@ -250,8 +250,12 @@ function wrapper (methodName, method) {
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
const returnValue = wx[options.name || methodName](arg1, arg2);
const args = [arg1];
if (typeof arg2 !== 'undefined') {
args.push(arg2);
}
const returnValue = wx[options.name || methodName].apply(wx, args);
if (isSyncApi(methodName)) { // 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName))
}
......@@ -760,7 +764,15 @@ function handleEvent (event) {
eventsArray.forEach(eventArray => {
const methodName = eventArray[0];
if (methodName) {
const handler = this.$vm[methodName];
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
throw new Error(` _vm.${methodName} is not a function`)
}
......@@ -770,7 +782,7 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(this.$vm, processEventArgs(
handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
......@@ -1072,7 +1084,8 @@ todos.forEach(todoApi => {
});
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi;
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name
: canIUseApi;
if (!wx.canIUse(apiName)) {
protocols[canIUseApi] = false;
}
......@@ -1088,14 +1101,14 @@ if (typeof Proxy !== 'undefined') {
}
if (api[name]) {
return promisify(name, api[name])
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
{
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApis[name]) {
return promisify(name, todoApis[name])
}
}
if (!hasOwn(wx, name) && !hasOwn(protocols, name)) {
return
......@@ -1106,13 +1119,13 @@ if (typeof Proxy !== 'undefined') {
} else {
uni.upx2px = upx2px;
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
{
Object.keys(todoApis).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
});
}
Object.keys(api).forEach(name => {
......@@ -1126,6 +1139,10 @@ if (typeof Proxy !== 'undefined') {
});
}
wx.createApp = createApp;
wx.createPage = createPage;
wx.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
......
{
"name": "@dcloudio/uni-mp-weixin",
"version": "0.0.955",
"version": "0.0.956",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
......
......@@ -13,19 +13,28 @@ import {
import wrapper from './wrapper'
import todoApi from './todo'
import * as extraApi from './extra'
import * as extraApi from './extra'
import * as api from 'uni-platform/service/api/index.js'
import { protocols, todos, canIUses } from 'uni-platform/service/api/protocols'
import {
protocols,
todos,
canIUses
} from 'uni-platform/service/api/protocols'
import createApp from './wrapper/create-app'
import createPage from './wrapper/create-page'
import createComponent from './wrapper/create-component'
todos.forEach(todoApi => {
protocols[todoApi] = false
})
canIUses.forEach(canIUseApi => {
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi
const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name
: canIUseApi
if (!__GLOBAL__.canIUse(apiName)) {
protocols[canIUseApi] = false
}
......@@ -41,14 +50,14 @@ if (typeof Proxy !== 'undefined') {
}
if (api[name]) {
return promisify(name, api[name])
}
if (__PLATFORM__ !== 'app-plus') {
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApi[name]) {
return promisify(name, todoApi[name])
}
}
if (__PLATFORM__ !== 'app-plus') {
if (extraApi[name]) {
return promisify(name, extraApi[name])
}
if (todoApi[name]) {
return promisify(name, todoApi[name])
}
}
if (!hasOwn(__GLOBAL__, name) && !hasOwn(protocols, name)) {
return
......@@ -59,13 +68,13 @@ if (typeof Proxy !== 'undefined') {
} else {
uni.upx2px = upx2px
if (__PLATFORM__ !== 'app-plus') {
Object.keys(todoApi).forEach(name => {
uni[name] = promisify(name, todoApi[name])
})
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApi[name])
})
if (__PLATFORM__ !== 'app-plus') {
Object.keys(todoApi).forEach(name => {
uni[name] = promisify(name, todoApi[name])
})
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApi[name])
})
}
Object.keys(api).forEach(name => {
......@@ -79,8 +88,14 @@ if (typeof Proxy !== 'undefined') {
})
}
export * from './wrapper/create-app'
export * from './wrapper/create-page'
export * from './wrapper/create-component'
__GLOBAL__.createApp = createApp
__GLOBAL__.createPage = createPage
__GLOBAL__.createComponent = createComponent
export {
createApp,
createPage,
createComponent
}
export default uni
......@@ -76,8 +76,12 @@ export default function wrapper (methodName, method) {
}
arg1 = processArgs(methodName, arg1, options.args, options.returnValue)
const returnValue = __GLOBAL__[options.name || methodName](arg1, arg2)
const args = [arg1]
if (typeof arg2 !== 'undefined') {
args.push(arg2)
}
const returnValue = __GLOBAL__[options.name || methodName].apply(__GLOBAL__, args)
if (isSyncApi(methodName)) { // 同步 api
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName))
}
......
......@@ -2,7 +2,7 @@ import 'uni-platform/runtime/index'
import parseApp from 'uni-platform/runtime/wrapper/app-parser'
export function createApp (vm) {
export default function createApp (vm) {
App(parseApp(vm))
return vm
}
import parseComponent from 'uni-platform/runtime/wrapper/component-parser'
export function createComponent (vueOptions) {
export default function createComponent (vueOptions) {
if (__PLATFORM__ === 'mp-alipay') {
return my.createComponent(parseComponent(vueOptions))
} else {
......
import parsePage from 'uni-platform/runtime/wrapper/page-parser'
export function createPage (vuePageOptions) {
export default function createPage (vuePageOptions) {
if (__PLATFORM__ === 'mp-alipay') {
return Page(parsePage(vuePageOptions))
} else {
......
......@@ -418,7 +418,15 @@ export function handleEvent (event) {
eventsArray.forEach(eventArray => {
const methodName = eventArray[0]
if (methodName) {
const handler = this.$vm[methodName]
let handlerCtx = this.$vm
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent
}
const handler = handlerCtx[methodName]
if (!isFn(handler)) {
throw new Error(` _vm.${methodName} is not a function`)
}
......@@ -428,7 +436,7 @@ export function handleEvent (event) {
}
handler.once = true
}
handler.apply(this.$vm, processEventArgs(
handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
......
......@@ -67,7 +67,11 @@ export default function parsePage (vuePageOptions) {
__l: handleLink
}
initHooks(pageOptions, hooks)
initHooks(pageOptions, hooks)
if (vueOptions.methods && vueOptions.methods.formReset) {
pageOptions.formReset = vueOptions.methods.formReset
}
return pageOptions
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册