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

refactor runtime

上级 37a14950
......@@ -491,8 +491,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -679,14 +677,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -853,7 +851,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -861,7 +859,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -1257,8 +1255,8 @@ function createApp (vm) {
}
function parseBaseComponent (vueComponentOptions, {
isPage: isPage$$1,
initRelation: initRelation$$1
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
......@@ -1275,7 +1273,7 @@ function parseBaseComponent (vueComponentOptions, {
const properties = this.properties;
const options = {
mpType: isPage$$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1283,7 +1281,7 @@ function parseBaseComponent (vueComponentOptions, {
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation$$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1327,7 +1325,7 @@ function parseBaseComponent (vueComponentOptions, {
}
};
if (isPage$$1) {
if (isPage) {
return componentOptions
}
return [componentOptions, VueComponent]
......@@ -1361,10 +1359,7 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent$1(vuePageOptions, {
isPage,
initRelation
});
const pageOptions = parseComponent$1(vuePageOptions);
initHooks(pageOptions.methods, hooks$2, vuePageOptions);
......@@ -1477,4 +1472,4 @@ wx.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
......@@ -891,8 +891,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -1054,14 +1052,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -1218,7 +1216,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -1226,7 +1224,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -1617,13 +1615,13 @@ const customize = cached((str) => {
const isComponent2 = my.canIUse('component2');
const mocks$1 = ['$id'];
const mocks = ['$id'];
function initRefs$1 () {
function initRefs () {
}
function initBehavior$1 ({
function initBehavior ({
properties
}) {
const props = {};
......@@ -1637,7 +1635,7 @@ function initBehavior$1 ({
}
}
function initRelation$1 (detail) {
function initRelation (detail) {
this.props.onVueInit(detail);
}
......@@ -1760,13 +1758,13 @@ function createObserver$1 (isDidUpdate) {
const handleLink$1 = (function () {
if (isComponent2) {
return function handleLink$$1 (detail) {
return function handleLink$1 (detail) {
return handleLink.call(this, {
detail
})
}
}
return function handleLink$$1 (detail) {
return function handleLink$1 (detail) {
if (this.$vm && this.$vm._isMounted) { // 父已初始化
return handleLink.call(this, {
detail: {
......@@ -1799,8 +1797,8 @@ function parseApp (vm) {
});
return parseBaseApp(vm, {
mocks: mocks$1,
initRefs: initRefs$1
mocks,
initRefs
})
}
......@@ -1825,7 +1823,7 @@ function parsePage (vuePageOptions) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions);
const pageOptions = {
mixins: initBehaviors(vueOptions, initBehavior$1),
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
onLoad (args) {
const properties = this.props;
......@@ -1889,7 +1887,7 @@ function initVm (VueComponent) {
if (isComponent2) {
// 处理父子关系
initRelation$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1901,7 +1899,7 @@ function initVm (VueComponent) {
this.$vm.$mount();
} else {
// 处理父子关系
initRelation$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options,
VueComponent,
......@@ -1940,7 +1938,7 @@ function parseComponent (vueComponentOptions) {
});
const componentOptions = {
mixins: initBehaviors(vueOptions, initBehavior$1),
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
......@@ -2059,4 +2057,4 @@ my.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
......@@ -653,8 +653,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -784,14 +782,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -1353,20 +1351,20 @@ function handleLink (event) {
vueOptions.parent = parentVm;
}
const mocks$1 = ['nodeId', 'componentName'];
const mocks = ['nodeId', 'componentName'];
function isPage$1 () {
function isPage () {
return !this.ownerId
}
function initRelation$1 (detail) {
function initRelation (detail) {
this.dispatch('__l', detail);
}
function parseApp (vm) {
// 百度 onShow 竟然会在 onLaunch 之前
const appOptions = parseBaseApp(vm, {
mocks: mocks$1,
mocks,
initRefs
});
appOptions.onShow = function onShow (args) {
......@@ -1384,8 +1382,8 @@ function createApp (vm) {
}
function parseBaseComponent (vueComponentOptions, {
isPage: isPage$$1,
initRelation: initRelation$$1
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
......@@ -1402,7 +1400,7 @@ function parseBaseComponent (vueComponentOptions, {
const properties = this.properties;
const options = {
mpType: isPage$$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1410,7 +1408,7 @@ function parseBaseComponent (vueComponentOptions, {
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation$$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1454,7 +1452,7 @@ function parseBaseComponent (vueComponentOptions, {
}
};
if (isPage$$1) {
if (isPage) {
return componentOptions
}
return [componentOptions, VueComponent]
......@@ -1462,15 +1460,15 @@ function parseBaseComponent (vueComponentOptions, {
function parseComponent (vueOptions) {
const componentOptions = parseBaseComponent(vueOptions, {
isPage: isPage$1,
initRelation: initRelation$1
isPage,
initRelation
});
const oldAttached = componentOptions.lifetimes.attached;
componentOptions.lifetimes.attached = function attached () {
oldAttached.call(this);
if (isPage$1.call(this)) { // 百度 onLoad 在 attached 之前触发
if (isPage.call(this)) { // 百度 onLoad 在 attached 之前触发
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this.pageinstance.$vm = this.$vm;
......@@ -1504,10 +1502,7 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent(vuePageOptions, {
isPage,
initRelation
});
const pageOptions = parseComponent(vuePageOptions);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);
......@@ -1535,8 +1530,8 @@ function onPageUnload ($vm) {
function parsePage (vuePageOptions) {
const pageOptions = parseBasePage(vuePageOptions, {
isPage: isPage$1,
initRelation: initRelation$1
isPage,
initRelation
});
pageOptions.methods.onLoad = function onLoad (args) {
......@@ -1645,4 +1640,4 @@ swan.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
......@@ -628,8 +628,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -743,14 +741,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -917,7 +915,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -925,7 +923,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -1313,8 +1311,8 @@ function createApp (vm) {
}
function parseBaseComponent (vueComponentOptions, {
isPage: isPage$$1,
initRelation: initRelation$$1
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
......@@ -1331,7 +1329,7 @@ function parseBaseComponent (vueComponentOptions, {
const properties = this.properties;
const options = {
mpType: isPage$$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1339,7 +1337,7 @@ function parseBaseComponent (vueComponentOptions, {
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation$$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1383,7 +1381,7 @@ function parseBaseComponent (vueComponentOptions, {
}
};
if (isPage$$1) {
if (isPage) {
return componentOptions
}
return [componentOptions, VueComponent]
......@@ -1412,10 +1410,7 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent$1(vuePageOptions, {
isPage,
initRelation
});
const pageOptions = parseComponent$1(vuePageOptions);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);
......@@ -1526,4 +1521,4 @@ wx.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
......@@ -709,8 +709,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -824,14 +822,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -998,7 +996,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -1006,7 +1004,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -1344,13 +1342,13 @@ function handleLink (event) {
vueOptions.parent = parentVm;
}
const mocks$1 = ['__route__', '__webviewId__', '__nodeid__', '__nodeId__'];
const mocks = ['__route__', '__webviewId__', '__nodeid__', '__nodeId__'];
function isPage$1 () {
function isPage () {
return this.__nodeid__ === 0 || this.__nodeId__ === 0
}
function initRefs$1 (vm) {
function initRefs (vm) {
const mpInstance = vm.$scope;
mpInstance.selectAllComponents('.vue-ref', (components) => {
components.forEach(component => {
......@@ -1371,7 +1369,7 @@ function initRefs$1 (vm) {
const instances = Object.create(null);
function initRelation$1 ({
function initRelation ({
vuePid,
mpInstance
}) {
......@@ -1435,7 +1433,7 @@ function parseApp (vm) {
this.$scope.route = this.$scope.__route__;
}
initRefs$1(this);
initRefs(this);
this.__init_injections(this);
this.__init_provide(this);
......@@ -1444,7 +1442,7 @@ function parseApp (vm) {
});
return parseBaseApp(vm, {
mocks: mocks$1,
mocks,
initRefs: function () {} // attached 时,可能查询不到
})
}
......@@ -1455,8 +1453,8 @@ function createApp (vm) {
}
function parseBaseComponent (vueComponentOptions, {
isPage: isPage$$1,
initRelation: initRelation$$1
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
......@@ -1473,7 +1471,7 @@ function parseBaseComponent (vueComponentOptions, {
const properties = this.properties;
const options = {
mpType: isPage$$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1481,7 +1479,7 @@ function parseBaseComponent (vueComponentOptions, {
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation$$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1525,7 +1523,7 @@ function parseBaseComponent (vueComponentOptions, {
}
};
if (isPage$$1) {
if (isPage) {
return componentOptions
}
return [componentOptions, VueComponent]
......@@ -1538,7 +1536,7 @@ function parseComponent (vueOptions) {
const properties = this.properties;
const options = {
mpType: isPage$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1552,7 +1550,7 @@ function parseComponent (vueOptions) {
initSlots(this.$vm, properties.vueSlots);
// 处理父子关系
initRelation$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
mpInstance: this
});
......@@ -1581,10 +1579,7 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent(vuePageOptions, {
isPage,
initRelation
});
const pageOptions = parseComponent(vuePageOptions);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);
......@@ -1598,8 +1593,8 @@ function parseBasePage (vuePageOptions, {
function parsePage (vuePageOptions) {
const pageOptions = parseBasePage(vuePageOptions, {
isPage: isPage$1,
initRelation: initRelation$1
isPage,
initRelation
});
// 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
pageOptions.lifetimes.ready = function ready () {
......@@ -1705,4 +1700,4 @@ tt.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
......@@ -561,8 +561,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -681,14 +679,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -855,7 +853,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -863,7 +861,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -1252,8 +1250,8 @@ function createApp (vm) {
}
function parseBaseComponent (vueComponentOptions, {
isPage: isPage$$1,
initRelation: initRelation$$1
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
......@@ -1270,7 +1268,7 @@ function parseBaseComponent (vueComponentOptions, {
const properties = this.properties;
const options = {
mpType: isPage$$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1278,7 +1276,7 @@ function parseBaseComponent (vueComponentOptions, {
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation$$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1322,7 +1320,7 @@ function parseBaseComponent (vueComponentOptions, {
}
};
if (isPage$$1) {
if (isPage) {
return componentOptions
}
return [componentOptions, VueComponent]
......@@ -1347,10 +1345,7 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent(vuePageOptions, {
isPage,
initRelation
});
const pageOptions = parseComponent(vuePageOptions);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);
......@@ -1457,4 +1452,4 @@ wx.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
......@@ -2,7 +2,7 @@ import {
isFn
} from 'uni-shared'
import providers from 'uni-platform/service/api/providers'
import providers from 'uni-platform/runtime/api/providers'
export function getProvider ({
service,
......
......@@ -10,7 +10,7 @@ import {
isContextApi
} from '../helpers/promise'
import { protocols } from 'uni-platform/service/api/protocols'
import { protocols } from 'uni-platform/runtime/api/protocols'
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册