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

refactor runtime

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