提交 072967ba 编写于 作者: Q qiang

build runtime

上级 dcf421ac
......@@ -1167,6 +1167,98 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
function createMediaQueryObserver () {
const mediaQueryObserver = {};
const {
windowWidth,
windowHeight
} = my.getSystemInfoSync();
const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape';
mediaQueryObserver.observe = (options, callback) => {
let matches = false;
for (const item in options) {
const itemValue = item === 'orientation' ? options[item] : Number(options[item]);
if (options[item] !== '') {
if (item === 'width') {
if (itemValue === windowWidth) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minWidth') {
if (windowWidth >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxWidth') {
if (windowWidth <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'height') {
if (itemValue === windowHeight) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minHeight') {
if (windowHeight >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxHeight') {
if (windowHeight <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'orientation') {
if (options[item] === orientation) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
}
}
callback(matches);
return matches
};
mediaQueryObserver.disconnect = () => {
};
return mediaQueryObserver
}
function setStorageSync (key, data) {
return my.setStorageSync({
key,
......@@ -1276,7 +1368,8 @@ var api = /*#__PURE__*/Object.freeze({
removeStorageSync: removeStorageSync,
startGyroscope: startGyroscope,
createSelectorQuery: createSelectorQuery,
createIntersectionObserver: createIntersectionObserver
createIntersectionObserver: createIntersectionObserver,
createMediaQueryObserver: createMediaQueryObserver
});
const PAGE_EVENT_HOOKS = [
......
......@@ -845,6 +845,98 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
function createMediaQueryObserver () {
const mediaQueryObserver = {};
const {
windowWidth,
windowHeight
} = swan.getSystemInfoSync();
const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape';
mediaQueryObserver.observe = (options, callback) => {
let matches = false;
for (const item in options) {
const itemValue = item === 'orientation' ? options[item] : Number(options[item]);
if (options[item] !== '') {
if (item === 'width') {
if (itemValue === windowWidth) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minWidth') {
if (windowWidth >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxWidth') {
if (windowWidth <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'height') {
if (itemValue === windowHeight) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minHeight') {
if (windowHeight >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxHeight') {
if (windowHeight <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'orientation') {
if (options[item] === orientation) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
}
}
callback(matches);
return matches
};
mediaQueryObserver.disconnect = () => {
};
return mediaQueryObserver
}
function requestPayment (params) {
let parseError = false;
if (typeof params.orderInfo === 'string') {
......@@ -865,7 +957,8 @@ function requestPayment (params) {
var api = /*#__PURE__*/Object.freeze({
__proto__: null,
requestPayment: requestPayment
requestPayment: requestPayment,
createMediaQueryObserver: createMediaQueryObserver
});
const MPPage = Page;
......
......@@ -1317,7 +1317,9 @@ const hooks = [
'onShow',
'onHide',
'onError',
'onPageNotFound'
'onPageNotFound',
'onThemeChange',
'onUnhandledRejection'
];
function parseBaseApp (vm, {
......@@ -1393,17 +1395,19 @@ function parseBaseApp (vm, {
return appOptions
}
/* 快手也使用__wxExparserNodeId__和__wxWebviewId__ */
const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'];
function findVmByVueId (vm, vuePid) {
const $children = vm.$children;
// 优先查找直属
let parentVm = $children.find(childVm => childVm.$scope._$vueId === vuePid);
if (parentVm) {
return parentVm
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
for (let i = $children.length - 1; i >= 0; i--) {
const childVm = $children[i];
if (childVm.$scope._$vueId === vuePid) {
return childVm
}
}
// 反向递归查找
let parentVm;
for (let i = $children.length - 1; i >= 0; i--) {
parentVm = findVmByVueId($children[i], vuePid);
if (parentVm) {
......@@ -1473,6 +1477,10 @@ function parseApp (vm) {
})
}
function parseApp$1 (vm) {
return parseApp(vm)
}
function createApp (vm) {
Vue.prototype.getOpenerEventChannel = function () {
if (!this.__eventChannel__) {
......@@ -1488,10 +1496,53 @@ function createApp (vm) {
}
return callHook.call(this, hook, args)
};
App(parseApp(vm));
App(parseApp$1(vm));
return vm
}
const encodeReserveRE = /[!'()*]/g;
const encodeReserveReplacer = c => '%' + c.charCodeAt(0).toString(16);
const commaRE = /%2C/g;
// fixed encodeURIComponent which is more conformant to RFC3986:
// - escapes [!'()*]
// - preserve commas
const encode = str => encodeURIComponent(str)
.replace(encodeReserveRE, encodeReserveReplacer)
.replace(commaRE, ',');
function stringifyQuery (obj, encodeStr = encode) {
const res = obj ? Object.keys(obj).map(key => {
const val = obj[key];
if (val === undefined) {
return ''
}
if (val === null) {
return encodeStr(key)
}
if (Array.isArray(val)) {
const result = [];
val.forEach(val2 => {
if (val2 === undefined) {
return
}
if (val2 === null) {
result.push(encodeStr(key));
} else {
result.push(encodeStr(key) + '=' + encodeStr(val2));
}
});
return result.join('&')
}
return encodeStr(key) + '=' + encodeStr(val)
}).filter(x => x.length > 0).join('&') : null;
return res ? `?${res}` : ''
}
function parseBaseComponent (vueComponentOptions, {
isPage,
initRelation
......@@ -1500,7 +1551,8 @@ function parseBaseComponent (vueComponentOptions, {
const options = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
...(vueOptions.options || {})
};
const componentOptions = {
......@@ -1545,7 +1597,7 @@ function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
this.$vm.$destroy();
this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
......@@ -1564,6 +1616,10 @@ function parseBaseComponent (vueComponentOptions, {
__e: handleEvent
}
};
// externalClasses
if (vueOptions.externalClasses) {
componentOptions.externalClasses = vueOptions.externalClasses;
}
if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
......@@ -1586,6 +1642,10 @@ function parseComponent (vueComponentOptions) {
})
}
function parseComponent$1 (vueComponentOptions) {
return parseComponent(vueComponentOptions)
}
const hooks$1 = [
'onShow',
'onHide',
......@@ -1598,13 +1658,19 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent(vuePageOptions);
const pageOptions = parseComponent$1(vuePageOptions);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);
pageOptions.methods.onLoad = function (args) {
this.$vm.$mp.query = args; // 兼容 mpvue
this.$vm.__call_hook('onLoad', args);
pageOptions.methods.onLoad = function (query) {
this.options = query;
const copyQuery = Object.assign({}, query);
delete copyQuery.__id__;
this.$page = {
fullPath: '/' + (this.route || this.is) + stringifyQuery(copyQuery)
};
this.$vm.$mp.query = query; // 兼容 mpvue
this.$vm.__call_hook('onLoad', query);
};
return pageOptions
......@@ -1617,15 +1683,19 @@ function parsePage (vuePageOptions) {
})
}
function parsePage$1 (vuePageOptions) {
return parsePage(vuePageOptions)
}
function createPage (vuePageOptions) {
{
return Component(parsePage(vuePageOptions))
return Component(parsePage$1(vuePageOptions))
}
}
function createComponent (vueOptions) {
{
return Component(parseComponent(vueOptions))
return Component(parseComponent$1(vueOptions))
}
}
......
......@@ -803,8 +803,101 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
function createMediaQueryObserver () {
const mediaQueryObserver = {};
const {
windowWidth,
windowHeight
} = wx.getSystemInfoSync();
const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape';
mediaQueryObserver.observe = (options, callback) => {
let matches = false;
for (const item in options) {
const itemValue = item === 'orientation' ? options[item] : Number(options[item]);
if (options[item] !== '') {
if (item === 'width') {
if (itemValue === windowWidth) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minWidth') {
if (windowWidth >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxWidth') {
if (windowWidth <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'height') {
if (itemValue === windowHeight) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minHeight') {
if (windowHeight >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxHeight') {
if (windowHeight <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'orientation') {
if (options[item] === orientation) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
}
}
callback(matches);
return matches
};
mediaQueryObserver.disconnect = () => {
};
return mediaQueryObserver
}
var api = /*#__PURE__*/Object.freeze({
__proto__: null
__proto__: null,
createMediaQueryObserver: createMediaQueryObserver
});
const MPPage = Page;
......
......@@ -895,8 +895,101 @@ var eventApi = /*#__PURE__*/Object.freeze({
$emit: $emit
});
function createMediaQueryObserver () {
const mediaQueryObserver = {};
const {
windowWidth,
windowHeight
} = tt.getSystemInfoSync();
const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape';
mediaQueryObserver.observe = (options, callback) => {
let matches = false;
for (const item in options) {
const itemValue = item === 'orientation' ? options[item] : Number(options[item]);
if (options[item] !== '') {
if (item === 'width') {
if (itemValue === windowWidth) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minWidth') {
if (windowWidth >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxWidth') {
if (windowWidth <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'height') {
if (itemValue === windowHeight) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'minHeight') {
if (windowHeight >= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'maxHeight') {
if (windowHeight <= itemValue) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
if (item === 'orientation') {
if (options[item] === orientation) {
matches = true;
} else {
matches = false;
callback(matches);
return matches
}
}
}
}
callback(matches);
return matches
};
mediaQueryObserver.disconnect = () => {
};
return mediaQueryObserver
}
var api = /*#__PURE__*/Object.freeze({
__proto__: null
__proto__: null,
createMediaQueryObserver: createMediaQueryObserver
});
const MPPage = Page;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册