提交 f22f865a 编写于 作者: Q qiang

Merge branch 'dev' into feat-native-tab-bar

......@@ -24,7 +24,7 @@ module.exports = function genRequireCode (baseDirname, modules) {
const moduleAbsolutePath = Path.resolve(baseDirname, file).replace(/\\/g, '/')
importCode += genImportCode(moduleName, moduleAbsolutePath)
moduleProps += genPropsCode(file, moduleName)
moduleProps += genPropsCode(file.replace(/\\/g, '/'), moduleName)
})
const requireFnCode = (`
(function() {
......
......@@ -5984,7 +5984,8 @@ var serviceContext = (function () {
data,
header,
method = 'GET',
responseType
responseType,
sslVerify = true
} = {}) {
const stream = requireNativePlugin('stream');
const headers = {};
......@@ -6024,7 +6025,9 @@ var serviceContext = (function () {
headers,
type: responseType === 'arraybuffer' ? 'base64' : 'text',
// weex 官方文档未说明实际支持 timeout,单位:ms
timeout: timeout || 6e5
timeout: timeout || 6e5,
// 配置和weex模块内相反
sslVerify: !sslVerify
};
if (method !== 'GET') {
options.body = data;
......
......@@ -71,7 +71,11 @@ function updateComponentJson (name, jsonObj, usingComponents = true) {
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) { // update
if (usingComponents) { // merge usingComponents
jsonObj.usingComponents = JSON.parse(oldJsonStr).usingComponents || {}
const oldJsonObj = JSON.parse(oldJsonStr)
jsonObj.usingComponents = oldJsonObj.usingComponents || {}
if (oldJsonObj.usingGlobalComponents) { // 复制 global components(针对不支持全局 usingComponents 的平台)
jsonObj.usingGlobalComponents = oldJsonObj.usingGlobalComponents
}
}
const newJsonStr = JSON.stringify(jsonObj, null, 2)
if (newJsonStr !== oldJsonStr) {
......
......@@ -480,7 +480,10 @@ module.exports = {
getPlatformFilterTag () {
return platform.filterTag
},
getPlatformVue () {
getPlatformVue (vueOptions) {
if (process.env.UNI_PLATFORM === 'h5' && vueOptions && vueOptions.runtimeCompiler) {
return '@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.esm.js'
}
if (process.env.UNI_USING_COMPONENTS) {
return uniRuntime
}
......
......@@ -82,9 +82,12 @@ const getPlatformName = () => {
};
const getPackName = () => {
let packName = '';
if (getPlatformName() === 'wx' || getPlatformName() === 'qq') {
packName = uni.getAccountInfoSync().miniProgram.appId || '';
let packName = '';
if (getPlatformName() === 'wx' || getPlatformName() === 'qq') {
// 兼容微信小程序低版本基础库
if(uni.canIUse('getAccountInfoSync')){
packName = uni.getAccountInfoSync().miniProgram.appId || '';
}
}
return packName
};
......
......@@ -78,9 +78,12 @@ export const getPlatformName = () => {
}
export const getPackName = () => {
let packName = ''
if (getPlatformName() === 'wx' || getPlatformName() === 'qq') {
packName = uni.getAccountInfoSync().miniProgram.appId || ''
let packName = ''
if (getPlatformName() === 'wx' || getPlatformName() === 'qq') {
// 兼容微信小程序低版本基础库
if(uni.canIUse('getAccountInfoSync')){
packName = uni.getAccountInfoSync().miniProgram.appId || '';
}
}
return packName
}
......
......@@ -90,7 +90,7 @@ module.exports = function traverse (ast, state) {
const blockStatementBody = []
const objectPropertyArray = []
const initExpressionStatementArray = []
// TODO 待重构,至少 filter,method 等实现方式要调整
babelTraverse(ast, visitor, undefined, {
scoped: [],
context: VAR_ROOT,
......
......@@ -25,7 +25,7 @@ module.exports = (api, options) => {
require('./lib/options')(options)
api.configureWebpack(require('./lib/configure-webpack')(platformOptions, manifestPlatformOptions))
api.configureWebpack(require('./lib/configure-webpack')(platformOptions, manifestPlatformOptions, options))
api.chainWebpack(require('./lib/chain-webpack')(platformOptions))
}
......
......@@ -14,7 +14,7 @@ function resolveModule (dir) {
return path.resolve(__dirname, '../../..', dir)
}
module.exports = function configureWebpack (platformOptions, manifestPlatformOptions) {
module.exports = function configureWebpack (platformOptions, manifestPlatformOptions, vueOptions) {
const {
runByHBuilderX, // 使用 HBuilderX 运行
isInHBuilderX, // 在 HBuilderX 的插件中
......@@ -261,7 +261,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
resolve: {
alias: {
'@': path.resolve(process.env.UNI_INPUT_DIR),
'vue$': getPlatformVue(),
'vue$': getPlatformVue(vueOptions),
'uni-pages': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
'@dcloudio/uni-stat': require.resolve('@dcloudio/uni-stat'),
'uni-stat-config': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json') +
......
/*!
* vue-router v3.0.1
* (c) 2018 Evan You
* (c) 2019 Evan You
* @license MIT
*/
'use strict';
......@@ -1671,19 +1671,19 @@ function scrollToPosition (shouldScroll, position) {
/* */
var supportsPushState = inBrowser && (function() {
var ua = window.navigator.userAgent;
var supportsPushState = inBrowser && (function () {
var ua = window.navigator.userAgent;
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
ua.indexOf('Mobile Safari') !== -1 &&
ua.indexOf('Chrome') === -1 &&
ua.indexOf('Windows Phone') === -1
) {
return false
}
) {
return false
}
return window.history && 'pushState' in window.history
return window.history && 'pushState' in window.history
})();
// use User Timing api (if present) for more accurate key precision
......@@ -1697,39 +1697,39 @@ function genKey () {
return Time.now().toFixed(3)
}
function getStateKey() {
return _key
function getStateKey () {
return _key
}
function setStateKey(key) {
_key = key;
function setStateKey (key) {
_key = key;
}
function pushState(url , id , replace ) {
saveScrollPosition();
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history;
try {
if (replace) {
history.replaceState({
function pushState (url , id , replace ) {
saveScrollPosition();
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history;
try {
if (replace) {
history.replaceState({
id: id,
key: _key
}, '', url);
} else {
_key = genKey();
history.pushState({
key: _key
}, '', url);
} else {
_key = genKey();
history.pushState({
id: id,
key: _key
}, '', url);
}
} catch (e) {
window.location[replace ? 'replace' : 'assign'](url);
}
key: _key
}, '', url);
}
} catch (e) {
window.location[replace ? 'replace' : 'assign'](url);
}
}
function replaceState(url , id ) {
pushState(url, id, true);
function replaceState (url , id ) {
pushState(url, id, true);
}
/* */
......@@ -2776,8 +2776,8 @@ function createHref (base, fullPath, mode) {
VueRouter.install = install;
VueRouter.version = '3.0.1';
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
}
// if (inBrowser && window.Vue) {
// window.Vue.use(VueRouter)
// }
module.exports = VueRouter;
/*!
* vue-router v3.0.1
* (c) 2018 Evan You
* (c) 2019 Evan You
* @license MIT
*/
/* */
......@@ -1669,19 +1669,19 @@ function scrollToPosition (shouldScroll, position) {
/* */
var supportsPushState = inBrowser && (function() {
var ua = window.navigator.userAgent;
var supportsPushState = inBrowser && (function () {
var ua = window.navigator.userAgent;
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
ua.indexOf('Mobile Safari') !== -1 &&
ua.indexOf('Chrome') === -1 &&
ua.indexOf('Windows Phone') === -1
) {
return false
}
) {
return false
}
return window.history && 'pushState' in window.history
return window.history && 'pushState' in window.history
})();
// use User Timing api (if present) for more accurate key precision
......@@ -1695,39 +1695,39 @@ function genKey () {
return Time.now().toFixed(3)
}
function getStateKey() {
return _key
function getStateKey () {
return _key
}
function setStateKey(key) {
_key = key;
function setStateKey (key) {
_key = key;
}
function pushState(url , id , replace ) {
saveScrollPosition();
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history;
try {
if (replace) {
history.replaceState({
function pushState (url , id , replace ) {
saveScrollPosition();
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history;
try {
if (replace) {
history.replaceState({
id: id,
key: _key
}, '', url);
} else {
_key = genKey();
history.pushState({
key: _key
}, '', url);
} else {
_key = genKey();
history.pushState({
id: id,
key: _key
}, '', url);
}
} catch (e) {
window.location[replace ? 'replace' : 'assign'](url);
}
key: _key
}, '', url);
}
} catch (e) {
window.location[replace ? 'replace' : 'assign'](url);
}
}
function replaceState(url , id ) {
pushState(url, id, true);
function replaceState (url , id ) {
pushState(url, id, true);
}
/* */
......@@ -2774,8 +2774,8 @@ function createHref (base, fullPath, mode) {
VueRouter.install = install;
VueRouter.version = '3.0.1';
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
}
// if (inBrowser && window.Vue) {
// window.Vue.use(VueRouter)
// }
export default VueRouter;
/*!
* vue-router v3.0.1
* (c) 2018 Evan You
* (c) 2019 Evan You
* @license MIT
*/
(function (global, factory) {
......@@ -1675,19 +1675,19 @@ function scrollToPosition (shouldScroll, position) {
/* */
var supportsPushState = inBrowser && (function() {
var ua = window.navigator.userAgent;
var supportsPushState = inBrowser && (function () {
var ua = window.navigator.userAgent;
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
if (
(ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) &&
ua.indexOf('Mobile Safari') !== -1 &&
ua.indexOf('Chrome') === -1 &&
ua.indexOf('Windows Phone') === -1
) {
return false
}
) {
return false
}
return window.history && 'pushState' in window.history
return window.history && 'pushState' in window.history
})();
// use User Timing api (if present) for more accurate key precision
......@@ -1701,39 +1701,39 @@ function genKey () {
return Time.now().toFixed(3)
}
function getStateKey() {
return _key
function getStateKey () {
return _key
}
function setStateKey(key) {
_key = key;
function setStateKey (key) {
_key = key;
}
function pushState(url , id , replace ) {
saveScrollPosition();
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history;
try {
if (replace) {
history.replaceState({
function pushState (url , id , replace ) {
saveScrollPosition();
// try...catch the pushState call to get around Safari
// DOM Exception 18 where it limits to 100 pushState calls
var history = window.history;
try {
if (replace) {
history.replaceState({
id: id,
key: _key
}, '', url);
} else {
_key = genKey();
history.pushState({
key: _key
}, '', url);
} else {
_key = genKey();
history.pushState({
id: id,
key: _key
}, '', url);
}
} catch (e) {
window.location[replace ? 'replace' : 'assign'](url);
}
key: _key
}, '', url);
}
} catch (e) {
window.location[replace ? 'replace' : 'assign'](url);
}
}
function replaceState(url , id ) {
pushState(url, id, true);
function replaceState (url , id ) {
pushState(url, id, true);
}
/* */
......@@ -2780,9 +2780,9 @@ function createHref (base, fullPath, mode) {
VueRouter.install = install;
VueRouter.version = '3.0.1';
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
}
// if (inBrowser && window.Vue) {
// window.Vue.use(VueRouter)
// }
return VueRouter;
......
......@@ -9196,36 +9196,6 @@ if (inBrowser) {
}, 0);
}
/* */
function transformNode(el) {
var list = el.attrsList;
for (var i = list.length - 1; i >= 0; i--) {
var name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
var nameArr = name.split(':');
var wxsProp = nameArr[nameArr.length - 1];
var wxsPropBinding = getBindingAttr(el, wxsProp, false);
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData(el) {
var data = '';
if (el.wxsPropBindings) {
data += "wxsProps:" + (JSON.stringify(el.wxsPropBindings)) + ",";
}
return data
}
var wxs$1 = {
transformNode: transformNode,
genData: genData
};
/* */
var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
......@@ -9276,7 +9246,7 @@ function parseText (
/* */
function transformNode$1 (el, options) {
function transformNode (el, options) {
var warn = options.warn || baseWarn;
var staticClass = getAndRemoveAttr(el, 'class');
if (staticClass) {
......@@ -9300,7 +9270,7 @@ function transformNode$1 (el, options) {
}
}
function genData$1 (el) {
function genData (el) {
var data = '';
if (el.staticClass) {
data += "staticClass:" + (el.staticClass) + ",";
......@@ -9313,13 +9283,13 @@ function genData$1 (el) {
var klass$1 = {
staticKeys: ['staticClass'],
transformNode: transformNode$1,
genData: genData$1
transformNode: transformNode,
genData: genData
};
/* */
function transformNode$2 (el, options) {
function transformNode$1 (el, options) {
var warn = options.warn || baseWarn;
var staticStyle = getAndRemoveAttr(el, 'style');
if (staticStyle) {
......@@ -9345,7 +9315,7 @@ function transformNode$2 (el, options) {
}
}
function genData$2 (el) {
function genData$1 (el) {
var data = '';
if (el.staticStyle) {
data += "staticStyle:" + (el.staticStyle) + ",";
......@@ -9358,8 +9328,8 @@ function genData$2 (el) {
var style$1 = {
staticKeys: ['staticStyle'],
transformNode: transformNode$2,
genData: genData$2
transformNode: transformNode$1,
genData: genData$1
};
/* */
......@@ -9376,8 +9346,8 @@ var he = {
/* */
var isUnaryTag = makeMap(
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
var isUnaryTag = makeMap(// fixed by xxxxxx add image
'image,area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
'link,meta,param,source,track,wbr'
);
......@@ -10711,16 +10681,353 @@ var model$1 = {
preTransformNode: preTransformNode
};
/* */
function transformNode$2(el) {
var list = el.attrsList;
for (var i = list.length - 1; i >= 0; i--) {
var name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
var nameArr = name.split(':');
var wxsProp = nameArr[nameArr.length - 1];
var wxsPropBinding = el.attrsMap[':' + wxsProp] || el.attrsMap['v-bind:' + wxsProp];
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData$2(el) {
var data = '';
if (el.wxsPropBindings) {
data += "wxsProps:" + (JSON.stringify(el.wxsPropBindings)) + ",";
}
return data
}
var wxs$1 = {
transformNode: transformNode$2,
genData: genData$2
};
var TAGS = [
'resize-sensor',
'ad',
'audio',
'button',
'camera',
'canvas',
'checkbox',
'checkbox-group',
'cover-image',
'cover-view',
'form',
'functional-page-navigator',
'icon',
'image',
'input',
'label',
'live-player',
'live-pusher',
'map',
'movable-area',
'movable-view',
'navigator',
'official-account',
'open-data',
'picker',
'picker-view',
'picker-view-column',
'progress',
'radio',
'radio-group',
'rich-text',
'scroll-view',
'slider',
'swiper',
'swiper-item',
'switch',
'text',
'textarea',
'video',
'view',
'web-view'
];
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
function processEvent(expr, filterModules) {
var isMethodPath = simplePathRE.test(expr);
if (isMethodPath) {
if (filterModules.find(function (name) { return expr.indexOf(name + '.') === 0; })) {
return ("\n$event = $handleWxsEvent($event);\n" + expr + "($event, $getComponentDescriptor())\n")
} else {
expr = expr + '($event)';
}
}
return ("\n$event = $handleEvent($event);\n" + expr + "\n")
}
var deprecated = {
events: {
'tap': 'click',
'longtap': 'longpress'
}
};
var tag = {
preTransformNode: function preTransformNode(el) {
if (TAGS.indexOf(el.tag) !== -1) {
el.tag = 'v-uni-' + el.tag;
}
},
postTransformNode: function postTransformNode(el, ref) {
var filterModules = ref.filterModules;
if (el.tag === 'block') {
el.tag = 'template';
var vForKey = el.key;
if (vForKey) {
delete el.key;
el.children.forEach(function (childEl, index) {
var childVForKey = childEl.key;
if (childVForKey) {
childEl.key = childVForKey + "+'_'+" + vForKey + "+'_" + index + "'";
} else {
childEl.key = vForKey + "+'_" + index + "'";
}
});
}
}
if (el.events) {
filterModules = filterModules || [];
var eventsMap = deprecated.events;
// const warnLogs = new Set()
Object.keys(el.events).forEach(function (name) {
// 过时事件类型转换
if (eventsMap[name]) {
el.events[eventsMap[name]] = el.events[name];
delete el.events[name];
// warnLogs.add(`警告:事件${name}已过时,推荐使用${eventsMap[name]}代替`)
name = eventsMap[name];
}
var handlers = el.events[name];
if (Array.isArray(handlers)) {
handlers.forEach(function (handler) {
handler.value = processEvent(handler.value, filterModules);
});
} else {
handlers.value = processEvent(handlers.value, filterModules);
}
});
}
}
};
// TODO 待优化
var validDivisionCharRE$1 = /[\w).+\-_$\]]/;
function parseFilters$1(exp) {
var inSingle = false;
var inDouble = false;
var inTemplateString = false;
var inRegex = false;
var curly = 0;
var square = 0;
var paren = 0;
var lastFilterIndex = 0;
var c, prev, i, expression, filters;
for (i = 0; i < exp.length; i++) {
prev = c;
c = exp.charCodeAt(i);
if (inSingle) {
if (c === 0x27 && prev !== 0x5C) {
inSingle = false;
}
} else if (inDouble) {
if (c === 0x22 && prev !== 0x5C) {
inDouble = false;
}
} else if (inTemplateString) {
if (c === 0x60 && prev !== 0x5C) {
inTemplateString = false;
}
} else if (inRegex) {
if (c === 0x2f && prev !== 0x5C) {
inRegex = false;
}
} else if (
c === 0x7C && // pipe
exp.charCodeAt(i + 1) !== 0x7C &&
exp.charCodeAt(i - 1) !== 0x7C &&
!curly && !square && !paren
) {
if (expression === undefined) {
// first filter, end of expression
lastFilterIndex = i + 1;
expression = exp.slice(0, i).trim();
} else {
pushFilter();
}
} else {
switch (c) {
case 0x22:
inDouble = true;
break // "
case 0x27:
inSingle = true;
break // '
case 0x60:
inTemplateString = true;
break // `
case 0x28:
paren++;
break // (
case 0x29:
paren--;
break // )
case 0x5B:
square++;
break // [
case 0x5D:
square--;
break // ]
case 0x7B:
curly++;
break // {
case 0x7D:
curly--;
break // }
}
if (c === 0x2f) { // /
var j = i - 1;
var p = (void 0);
// find first non-whitespace prev char
for (; j >= 0; j--) {
p = exp.charAt(j);
if (p !== ' ') {
break
}
}
if (!p || !validDivisionCharRE$1.test(p)) {
inRegex = true;
}
}
}
}
if (expression === undefined) {
expression = exp.slice(0, i).trim();
} else if (lastFilterIndex !== 0) {
pushFilter();
}
function pushFilter() {
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
lastFilterIndex = i + 1;
}
if (filters) {
for (i = 0; i < filters.length; i++) {
expression = wrapFilter$1(expression, filters[i]);
}
}
return expression
}
function wrapFilter$1(exp, filter) {
var i = filter.indexOf('(');
if (i < 0) {
// _f: resolveFilter
return ('_f("' + filter + '")(' + exp + ')')
} else {
var name = filter.slice(0, i);
var args = filter.slice(i + 1);
return ('_f("' + name + '")(' + exp + (args !== ')' ? ',' + args : args))
}
}
var defaultTagRE$1 = /\{\{((?:.|\n)+?)\}\}/g;
function parseText$1(
text
) {
var tokens = [];
var rawTokens = [];
var lastIndex = defaultTagRE$1.lastIndex = 0;
var match, index, tokenValue;
while ((match = defaultTagRE$1.exec(text))) {
index = match.index;
// push text token
if (index > lastIndex) {
rawTokens.push(tokenValue = text.slice(lastIndex, index));
tokens.push(JSON.stringify(tokenValue));
}
// tag token
var exp = parseFilters$1(match[1].trim());
tokens.push(('_s(' + exp + ')'));
rawTokens.push({
'@binding': exp
});
lastIndex = index + match[0].length;
}
if (lastIndex < text.length) {
rawTokens.push(tokenValue = text.slice(lastIndex));
tokens.push(JSON.stringify(tokenValue));
}
return {
expression: tokens.join('+'),
tokens: rawTokens
}
}
var text = {
postTransformNode: function postTransformNode(el) { // 重新格式化 text 节点,应该使用postTransformNode,但 mpvue 使用的 template-compiler 较老,导致 postTransformNode 时机不对
var children = el.children;
if (children && children.length) {
children.forEach(function (childEl) {
if (childEl.text) {
var text = childEl.text.trim();
if (childEl.type === 2) {
try {
var ref = parseText$1(text);
var expression = ref.expression;
var tokens = ref.tokens;
childEl.expression = expression;
childEl.tokens = tokens;
childEl.text = text;
} catch (e) {
console.log(e);
}
} else {
childEl.text = text;
}
}
});
}
return ''
}
};
var modules$1 = [
wxs$1,
text,// fixed by xxxxxx
wxs$1,// fixed by xxxxxx
klass$1,
style$1,
model$1
];
model$1,
tag ];
/* */
function text (el, dir) {
function text$1 (el, dir) {
if (dir.value) {
addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
}
......@@ -10736,7 +11043,7 @@ function html (el, dir) {
var directives$1 = {
model: model,
text: text,
text: text$1,
html: html
};
......@@ -10886,7 +11193,7 @@ function isDirectChildOfTemplateFor (node) {
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
var simplePathRE$1 = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// KeyboardEvent.keyCode aliases
var keyCodes = {
......@@ -10968,9 +11275,9 @@ function genHandler (handler) {
return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
}
var isMethodPath = simplePathRE.test(handler.value);
var isMethodPath = simplePathRE$1.test(handler.value);
var isFunctionExpression = fnExpRE.test(handler.value);
var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
var isFunctionInvocation = simplePathRE$1.test(handler.value.replace(fnInvokeRE, ''));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
......
......@@ -9213,36 +9213,6 @@ if (inBrowser) {
}, 0);
}
/* */
function transformNode(el) {
const list = el.attrsList;
for (let i = list.length - 1; i >= 0; i--) {
const name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
const nameArr = name.split(':');
const wxsProp = nameArr[nameArr.length - 1];
const wxsPropBinding = getBindingAttr(el, wxsProp, false);
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData(el) {
let data = '';
if (el.wxsPropBindings) {
data += `wxsProps:${JSON.stringify(el.wxsPropBindings)},`;
}
return data
}
var wxs$1 = {
transformNode,
genData
};
/* */
const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
......@@ -9293,7 +9263,7 @@ function parseText (
/* */
function transformNode$1 (el, options) {
function transformNode (el, options) {
const warn = options.warn || baseWarn;
const staticClass = getAndRemoveAttr(el, 'class');
if (staticClass) {
......@@ -9317,7 +9287,7 @@ function transformNode$1 (el, options) {
}
}
function genData$1 (el) {
function genData (el) {
let data = '';
if (el.staticClass) {
data += `staticClass:${el.staticClass},`;
......@@ -9330,13 +9300,13 @@ function genData$1 (el) {
var klass$1 = {
staticKeys: ['staticClass'],
transformNode: transformNode$1,
genData: genData$1
transformNode,
genData
};
/* */
function transformNode$2 (el, options) {
function transformNode$1 (el, options) {
const warn = options.warn || baseWarn;
const staticStyle = getAndRemoveAttr(el, 'style');
if (staticStyle) {
......@@ -9362,7 +9332,7 @@ function transformNode$2 (el, options) {
}
}
function genData$2 (el) {
function genData$1 (el) {
let data = '';
if (el.staticStyle) {
data += `staticStyle:${el.staticStyle},`;
......@@ -9375,8 +9345,8 @@ function genData$2 (el) {
var style$1 = {
staticKeys: ['staticStyle'],
transformNode: transformNode$2,
genData: genData$2
transformNode: transformNode$1,
genData: genData$1
};
/* */
......@@ -9393,8 +9363,8 @@ var he = {
/* */
const isUnaryTag = makeMap(
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
const isUnaryTag = makeMap(// fixed by xxxxxx add image
'image,area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
'link,meta,param,source,track,wbr'
);
......@@ -10724,16 +10694,363 @@ var model$1 = {
preTransformNode
};
/* */
function transformNode$2(el) {
const list = el.attrsList;
for (let i = list.length - 1; i >= 0; i--) {
const name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
const nameArr = name.split(':');
const wxsProp = nameArr[nameArr.length - 1];
const wxsPropBinding = el.attrsMap[':' + wxsProp] || el.attrsMap['v-bind:' + wxsProp];
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData$2(el) {
let data = '';
if (el.wxsPropBindings) {
data += `wxsProps:${JSON.stringify(el.wxsPropBindings)},`;
}
return data
}
var wxs$1 = {
transformNode: transformNode$2,
genData: genData$2
};
const TAGS = [
'resize-sensor',
'ad',
'audio',
'button',
'camera',
'canvas',
'checkbox',
'checkbox-group',
'cover-image',
'cover-view',
'form',
'functional-page-navigator',
'icon',
'image',
'input',
'label',
'live-player',
'live-pusher',
'map',
'movable-area',
'movable-view',
'navigator',
'official-account',
'open-data',
'picker',
'picker-view',
'picker-view-column',
'progress',
'radio',
'radio-group',
'rich-text',
'scroll-view',
'slider',
'swiper',
'swiper-item',
'switch',
'text',
'textarea',
'video',
'view',
'web-view'
];
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
function processEvent(expr, filterModules) {
const isMethodPath = simplePathRE.test(expr);
if (isMethodPath) {
if (filterModules.find(name => expr.indexOf(name + '.') === 0)) {
return `
$event = $handleWxsEvent($event);
${expr}($event, $getComponentDescriptor())
`
} else {
expr = expr + '($event)';
}
}
return `
$event = $handleEvent($event);
${expr}
`
}
const deprecated = {
events: {
'tap': 'click',
'longtap': 'longpress'
}
};
var tag = {
preTransformNode(el) {
if (TAGS.indexOf(el.tag) !== -1) {
el.tag = 'v-uni-' + el.tag;
}
},
postTransformNode(el, {
filterModules
}) {
if (el.tag === 'block') {
el.tag = 'template';
const vForKey = el.key;
if (vForKey) {
delete el.key;
el.children.forEach((childEl, index) => {
const childVForKey = childEl.key;
if (childVForKey) {
childEl.key = `${childVForKey}+'_'+${vForKey}+'_${index}'`;
} else {
childEl.key = `${vForKey}+'_${index}'`;
}
});
}
}
if (el.events) {
filterModules = filterModules || [];
const {
events: eventsMap
} = deprecated;
// const warnLogs = new Set()
Object.keys(el.events).forEach(name => {
// 过时事件类型转换
if (eventsMap[name]) {
el.events[eventsMap[name]] = el.events[name];
delete el.events[name];
// warnLogs.add(`警告:事件${name}已过时,推荐使用${eventsMap[name]}代替`)
name = eventsMap[name];
}
const handlers = el.events[name];
if (Array.isArray(handlers)) {
handlers.forEach(handler => {
handler.value = processEvent(handler.value, filterModules);
});
} else {
handlers.value = processEvent(handlers.value, filterModules);
}
});
}
}
};
// TODO 待优化
var validDivisionCharRE$1 = /[\w).+\-_$\]]/;
function parseFilters$1(exp) {
var inSingle = false;
var inDouble = false;
var inTemplateString = false;
var inRegex = false;
var curly = 0;
var square = 0;
var paren = 0;
var lastFilterIndex = 0;
var c, prev, i, expression, filters;
for (i = 0; i < exp.length; i++) {
prev = c;
c = exp.charCodeAt(i);
if (inSingle) {
if (c === 0x27 && prev !== 0x5C) {
inSingle = false;
}
} else if (inDouble) {
if (c === 0x22 && prev !== 0x5C) {
inDouble = false;
}
} else if (inTemplateString) {
if (c === 0x60 && prev !== 0x5C) {
inTemplateString = false;
}
} else if (inRegex) {
if (c === 0x2f && prev !== 0x5C) {
inRegex = false;
}
} else if (
c === 0x7C && // pipe
exp.charCodeAt(i + 1) !== 0x7C &&
exp.charCodeAt(i - 1) !== 0x7C &&
!curly && !square && !paren
) {
if (expression === undefined) {
// first filter, end of expression
lastFilterIndex = i + 1;
expression = exp.slice(0, i).trim();
} else {
pushFilter();
}
} else {
switch (c) {
case 0x22:
inDouble = true;
break // "
case 0x27:
inSingle = true;
break // '
case 0x60:
inTemplateString = true;
break // `
case 0x28:
paren++;
break // (
case 0x29:
paren--;
break // )
case 0x5B:
square++;
break // [
case 0x5D:
square--;
break // ]
case 0x7B:
curly++;
break // {
case 0x7D:
curly--;
break // }
}
if (c === 0x2f) { // /
var j = i - 1;
var p = (void 0);
// find first non-whitespace prev char
for (; j >= 0; j--) {
p = exp.charAt(j);
if (p !== ' ') {
break
}
}
if (!p || !validDivisionCharRE$1.test(p)) {
inRegex = true;
}
}
}
}
if (expression === undefined) {
expression = exp.slice(0, i).trim();
} else if (lastFilterIndex !== 0) {
pushFilter();
}
function pushFilter() {
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
lastFilterIndex = i + 1;
}
if (filters) {
for (i = 0; i < filters.length; i++) {
expression = wrapFilter$1(expression, filters[i]);
}
}
return expression
}
function wrapFilter$1(exp, filter) {
var i = filter.indexOf('(');
if (i < 0) {
// _f: resolveFilter
return ('_f("' + filter + '")(' + exp + ')')
} else {
var name = filter.slice(0, i);
var args = filter.slice(i + 1);
return ('_f("' + name + '")(' + exp + (args !== ')' ? ',' + args : args))
}
}
const defaultTagRE$1 = /\{\{((?:.|\n)+?)\}\}/g;
function parseText$1(
text
) {
const tokens = [];
const rawTokens = [];
let lastIndex = defaultTagRE$1.lastIndex = 0;
let match, index, tokenValue;
while ((match = defaultTagRE$1.exec(text))) {
index = match.index;
// push text token
if (index > lastIndex) {
rawTokens.push(tokenValue = text.slice(lastIndex, index));
tokens.push(JSON.stringify(tokenValue));
}
// tag token
var exp = parseFilters$1(match[1].trim());
tokens.push(('_s(' + exp + ')'));
rawTokens.push({
'@binding': exp
});
lastIndex = index + match[0].length;
}
if (lastIndex < text.length) {
rawTokens.push(tokenValue = text.slice(lastIndex));
tokens.push(JSON.stringify(tokenValue));
}
return {
expression: tokens.join('+'),
tokens: rawTokens
}
}
var text = {
postTransformNode(el) { // 重新格式化 text 节点,应该使用postTransformNode,但 mpvue 使用的 template-compiler 较老,导致 postTransformNode 时机不对
const children = el.children;
if (children && children.length) {
children.forEach(childEl => {
if (childEl.text) {
const text = childEl.text.trim();
if (childEl.type === 2) {
try {
const {
expression,
tokens
} = parseText$1(text);
childEl.expression = expression;
childEl.tokens = tokens;
childEl.text = text;
} catch (e) {
console.log(e);
}
} else {
childEl.text = text;
}
}
});
}
return ''
}
};
var modules$1 = [
wxs$1,
text,// fixed by xxxxxx
wxs$1,// fixed by xxxxxx
klass$1,
style$1,
model$1
model$1,
tag,// fixed by xxxxxx
];
/* */
function text (el, dir) {
function text$1 (el, dir) {
if (dir.value) {
addProp(el, 'textContent', `_s(${dir.value})`, dir);
}
......@@ -10749,7 +11066,7 @@ function html (el, dir) {
var directives$1 = {
model,
text,
text: text$1,
html
};
......@@ -10899,7 +11216,7 @@ function isDirectChildOfTemplateFor (node) {
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
const fnInvokeRE = /\([^)]*?\);*$/;
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
const simplePathRE$1 = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// KeyboardEvent.keyCode aliases
const keyCodes = {
......@@ -10981,9 +11298,9 @@ function genHandler (handler) {
return `[${handler.map(handler => genHandler(handler)).join(',')}]`
}
const isMethodPath = simplePathRE.test(handler.value);
const isMethodPath = simplePathRE$1.test(handler.value);
const isFunctionExpression = fnExpRE.test(handler.value);
const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
const isFunctionInvocation = simplePathRE$1.test(handler.value.replace(fnInvokeRE, ''));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
......
......@@ -9224,36 +9224,6 @@ if (inBrowser) {
}, 0);
}
/* */
function transformNode(el) {
var list = el.attrsList;
for (var i = list.length - 1; i >= 0; i--) {
var name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
var nameArr = name.split(':');
var wxsProp = nameArr[nameArr.length - 1];
var wxsPropBinding = getBindingAttr(el, wxsProp, false);
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData(el) {
var data = '';
if (el.wxsPropBindings) {
data += "wxsProps:" + (JSON.stringify(el.wxsPropBindings)) + ",";
}
return data
}
var wxs$1 = {
transformNode: transformNode,
genData: genData
};
/* */
var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
......@@ -9304,7 +9274,7 @@ function parseText (
/* */
function transformNode$1 (el, options) {
function transformNode (el, options) {
var warn = options.warn || baseWarn;
var staticClass = getAndRemoveAttr(el, 'class');
if (process.env.NODE_ENV !== 'production' && staticClass) {
......@@ -9328,7 +9298,7 @@ function transformNode$1 (el, options) {
}
}
function genData$1 (el) {
function genData (el) {
var data = '';
if (el.staticClass) {
data += "staticClass:" + (el.staticClass) + ",";
......@@ -9341,13 +9311,13 @@ function genData$1 (el) {
var klass$1 = {
staticKeys: ['staticClass'],
transformNode: transformNode$1,
genData: genData$1
transformNode: transformNode,
genData: genData
};
/* */
function transformNode$2 (el, options) {
function transformNode$1 (el, options) {
var warn = options.warn || baseWarn;
var staticStyle = getAndRemoveAttr(el, 'style');
if (staticStyle) {
......@@ -9373,7 +9343,7 @@ function transformNode$2 (el, options) {
}
}
function genData$2 (el) {
function genData$1 (el) {
var data = '';
if (el.staticStyle) {
data += "staticStyle:" + (el.staticStyle) + ",";
......@@ -9386,8 +9356,8 @@ function genData$2 (el) {
var style$1 = {
staticKeys: ['staticStyle'],
transformNode: transformNode$2,
genData: genData$2
transformNode: transformNode$1,
genData: genData$1
};
/* */
......@@ -9404,8 +9374,8 @@ var he = {
/* */
var isUnaryTag = makeMap(
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
var isUnaryTag = makeMap(// fixed by xxxxxx add image
'image,area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
'link,meta,param,source,track,wbr'
);
......@@ -10742,16 +10712,353 @@ var model$1 = {
preTransformNode: preTransformNode
};
/* */
function transformNode$2(el) {
var list = el.attrsList;
for (var i = list.length - 1; i >= 0; i--) {
var name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
var nameArr = name.split(':');
var wxsProp = nameArr[nameArr.length - 1];
var wxsPropBinding = el.attrsMap[':' + wxsProp] || el.attrsMap['v-bind:' + wxsProp];
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData$2(el) {
var data = '';
if (el.wxsPropBindings) {
data += "wxsProps:" + (JSON.stringify(el.wxsPropBindings)) + ",";
}
return data
}
var wxs$1 = {
transformNode: transformNode$2,
genData: genData$2
};
var TAGS = [
'resize-sensor',
'ad',
'audio',
'button',
'camera',
'canvas',
'checkbox',
'checkbox-group',
'cover-image',
'cover-view',
'form',
'functional-page-navigator',
'icon',
'image',
'input',
'label',
'live-player',
'live-pusher',
'map',
'movable-area',
'movable-view',
'navigator',
'official-account',
'open-data',
'picker',
'picker-view',
'picker-view-column',
'progress',
'radio',
'radio-group',
'rich-text',
'scroll-view',
'slider',
'swiper',
'swiper-item',
'switch',
'text',
'textarea',
'video',
'view',
'web-view'
];
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
function processEvent(expr, filterModules) {
var isMethodPath = simplePathRE.test(expr);
if (isMethodPath) {
if (filterModules.find(function (name) { return expr.indexOf(name + '.') === 0; })) {
return ("\n$event = $handleWxsEvent($event);\n" + expr + "($event, $getComponentDescriptor())\n")
} else {
expr = expr + '($event)';
}
}
return ("\n$event = $handleEvent($event);\n" + expr + "\n")
}
var deprecated = {
events: {
'tap': 'click',
'longtap': 'longpress'
}
};
var tag = {
preTransformNode: function preTransformNode(el) {
if (TAGS.indexOf(el.tag) !== -1) {
el.tag = 'v-uni-' + el.tag;
}
},
postTransformNode: function postTransformNode(el, ref) {
var filterModules = ref.filterModules;
if (el.tag === 'block') {
el.tag = 'template';
var vForKey = el.key;
if (vForKey) {
delete el.key;
el.children.forEach(function (childEl, index) {
var childVForKey = childEl.key;
if (childVForKey) {
childEl.key = childVForKey + "+'_'+" + vForKey + "+'_" + index + "'";
} else {
childEl.key = vForKey + "+'_" + index + "'";
}
});
}
}
if (el.events) {
filterModules = filterModules || [];
var eventsMap = deprecated.events;
// const warnLogs = new Set()
Object.keys(el.events).forEach(function (name) {
// 过时事件类型转换
if (eventsMap[name]) {
el.events[eventsMap[name]] = el.events[name];
delete el.events[name];
// warnLogs.add(`警告:事件${name}已过时,推荐使用${eventsMap[name]}代替`)
name = eventsMap[name];
}
var handlers = el.events[name];
if (Array.isArray(handlers)) {
handlers.forEach(function (handler) {
handler.value = processEvent(handler.value, filterModules);
});
} else {
handlers.value = processEvent(handlers.value, filterModules);
}
});
}
}
};
// TODO 待优化
var validDivisionCharRE$1 = /[\w).+\-_$\]]/;
function parseFilters$1(exp) {
var inSingle = false;
var inDouble = false;
var inTemplateString = false;
var inRegex = false;
var curly = 0;
var square = 0;
var paren = 0;
var lastFilterIndex = 0;
var c, prev, i, expression, filters;
for (i = 0; i < exp.length; i++) {
prev = c;
c = exp.charCodeAt(i);
if (inSingle) {
if (c === 0x27 && prev !== 0x5C) {
inSingle = false;
}
} else if (inDouble) {
if (c === 0x22 && prev !== 0x5C) {
inDouble = false;
}
} else if (inTemplateString) {
if (c === 0x60 && prev !== 0x5C) {
inTemplateString = false;
}
} else if (inRegex) {
if (c === 0x2f && prev !== 0x5C) {
inRegex = false;
}
} else if (
c === 0x7C && // pipe
exp.charCodeAt(i + 1) !== 0x7C &&
exp.charCodeAt(i - 1) !== 0x7C &&
!curly && !square && !paren
) {
if (expression === undefined) {
// first filter, end of expression
lastFilterIndex = i + 1;
expression = exp.slice(0, i).trim();
} else {
pushFilter();
}
} else {
switch (c) {
case 0x22:
inDouble = true;
break // "
case 0x27:
inSingle = true;
break // '
case 0x60:
inTemplateString = true;
break // `
case 0x28:
paren++;
break // (
case 0x29:
paren--;
break // )
case 0x5B:
square++;
break // [
case 0x5D:
square--;
break // ]
case 0x7B:
curly++;
break // {
case 0x7D:
curly--;
break // }
}
if (c === 0x2f) { // /
var j = i - 1;
var p = (void 0);
// find first non-whitespace prev char
for (; j >= 0; j--) {
p = exp.charAt(j);
if (p !== ' ') {
break
}
}
if (!p || !validDivisionCharRE$1.test(p)) {
inRegex = true;
}
}
}
}
if (expression === undefined) {
expression = exp.slice(0, i).trim();
} else if (lastFilterIndex !== 0) {
pushFilter();
}
function pushFilter() {
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
lastFilterIndex = i + 1;
}
if (filters) {
for (i = 0; i < filters.length; i++) {
expression = wrapFilter$1(expression, filters[i]);
}
}
return expression
}
function wrapFilter$1(exp, filter) {
var i = filter.indexOf('(');
if (i < 0) {
// _f: resolveFilter
return ('_f("' + filter + '")(' + exp + ')')
} else {
var name = filter.slice(0, i);
var args = filter.slice(i + 1);
return ('_f("' + name + '")(' + exp + (args !== ')' ? ',' + args : args))
}
}
var defaultTagRE$1 = /\{\{((?:.|\n)+?)\}\}/g;
function parseText$1(
text
) {
var tokens = [];
var rawTokens = [];
var lastIndex = defaultTagRE$1.lastIndex = 0;
var match, index, tokenValue;
while ((match = defaultTagRE$1.exec(text))) {
index = match.index;
// push text token
if (index > lastIndex) {
rawTokens.push(tokenValue = text.slice(lastIndex, index));
tokens.push(JSON.stringify(tokenValue));
}
// tag token
var exp = parseFilters$1(match[1].trim());
tokens.push(('_s(' + exp + ')'));
rawTokens.push({
'@binding': exp
});
lastIndex = index + match[0].length;
}
if (lastIndex < text.length) {
rawTokens.push(tokenValue = text.slice(lastIndex));
tokens.push(JSON.stringify(tokenValue));
}
return {
expression: tokens.join('+'),
tokens: rawTokens
}
}
var text = {
postTransformNode: function postTransformNode(el) { // 重新格式化 text 节点,应该使用postTransformNode,但 mpvue 使用的 template-compiler 较老,导致 postTransformNode 时机不对
var children = el.children;
if (children && children.length) {
children.forEach(function (childEl) {
if (childEl.text) {
var text = childEl.text.trim();
if (childEl.type === 2) {
try {
var ref = parseText$1(text);
var expression = ref.expression;
var tokens = ref.tokens;
childEl.expression = expression;
childEl.tokens = tokens;
childEl.text = text;
} catch (e) {
console.log(e);
}
} else {
childEl.text = text;
}
}
});
}
return ''
}
};
var modules$1 = [
wxs$1,
text,// fixed by xxxxxx
wxs$1,// fixed by xxxxxx
klass$1,
style$1,
model$1
];
model$1,
tag ];
/* */
function text (el, dir) {
function text$1 (el, dir) {
if (dir.value) {
addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
}
......@@ -10767,7 +11074,7 @@ function html (el, dir) {
var directives$1 = {
model: model,
text: text,
text: text$1,
html: html
};
......@@ -10917,7 +11224,7 @@ function isDirectChildOfTemplateFor (node) {
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
var simplePathRE$1 = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// KeyboardEvent.keyCode aliases
var keyCodes = {
......@@ -10999,9 +11306,9 @@ function genHandler (handler) {
return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
}
var isMethodPath = simplePathRE.test(handler.value);
var isMethodPath = simplePathRE$1.test(handler.value);
var isFunctionExpression = fnExpRE.test(handler.value);
var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
var isFunctionInvocation = simplePathRE$1.test(handler.value.replace(fnInvokeRE, ''));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
......
......@@ -9200,36 +9200,6 @@
}, 0);
}
/* */
function transformNode(el) {
var list = el.attrsList;
for (var i = list.length - 1; i >= 0; i--) {
var name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
var nameArr = name.split(':');
var wxsProp = nameArr[nameArr.length - 1];
var wxsPropBinding = getBindingAttr(el, wxsProp, false);
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData(el) {
var data = '';
if (el.wxsPropBindings) {
data += "wxsProps:" + (JSON.stringify(el.wxsPropBindings)) + ",";
}
return data
}
var wxs$1 = {
transformNode: transformNode,
genData: genData
};
/* */
var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
......@@ -9280,7 +9250,7 @@
/* */
function transformNode$1 (el, options) {
function transformNode (el, options) {
var warn = options.warn || baseWarn;
var staticClass = getAndRemoveAttr(el, 'class');
if (staticClass) {
......@@ -9304,7 +9274,7 @@
}
}
function genData$1 (el) {
function genData (el) {
var data = '';
if (el.staticClass) {
data += "staticClass:" + (el.staticClass) + ",";
......@@ -9317,13 +9287,13 @@
var klass$1 = {
staticKeys: ['staticClass'],
transformNode: transformNode$1,
genData: genData$1
transformNode: transformNode,
genData: genData
};
/* */
function transformNode$2 (el, options) {
function transformNode$1 (el, options) {
var warn = options.warn || baseWarn;
var staticStyle = getAndRemoveAttr(el, 'style');
if (staticStyle) {
......@@ -9349,7 +9319,7 @@
}
}
function genData$2 (el) {
function genData$1 (el) {
var data = '';
if (el.staticStyle) {
data += "staticStyle:" + (el.staticStyle) + ",";
......@@ -9362,8 +9332,8 @@
var style$1 = {
staticKeys: ['staticStyle'],
transformNode: transformNode$2,
genData: genData$2
transformNode: transformNode$1,
genData: genData$1
};
/* */
......@@ -9380,8 +9350,8 @@
/* */
var isUnaryTag = makeMap(
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
var isUnaryTag = makeMap(// fixed by xxxxxx add image
'image,area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
'link,meta,param,source,track,wbr'
);
......@@ -10715,16 +10685,353 @@
preTransformNode: preTransformNode
};
/* */
function transformNode$2(el) {
var list = el.attrsList;
for (var i = list.length - 1; i >= 0; i--) {
var name = list[i].name;
if (name.indexOf(':change:') === 0 || name.indexOf('v-bind:change:') === 0) {
var nameArr = name.split(':');
var wxsProp = nameArr[nameArr.length - 1];
var wxsPropBinding = el.attrsMap[':' + wxsProp] || el.attrsMap['v-bind:' + wxsProp];
if (wxsPropBinding) {
(el.wxsPropBindings || (el.wxsPropBindings = {}))['change:' + wxsProp] = wxsPropBinding;
}
}
}
}
function genData$2(el) {
var data = '';
if (el.wxsPropBindings) {
data += "wxsProps:" + (JSON.stringify(el.wxsPropBindings)) + ",";
}
return data
}
var wxs$1 = {
transformNode: transformNode$2,
genData: genData$2
};
var TAGS = [
'resize-sensor',
'ad',
'audio',
'button',
'camera',
'canvas',
'checkbox',
'checkbox-group',
'cover-image',
'cover-view',
'form',
'functional-page-navigator',
'icon',
'image',
'input',
'label',
'live-player',
'live-pusher',
'map',
'movable-area',
'movable-view',
'navigator',
'official-account',
'open-data',
'picker',
'picker-view',
'picker-view-column',
'progress',
'radio',
'radio-group',
'rich-text',
'scroll-view',
'slider',
'swiper',
'swiper-item',
'switch',
'text',
'textarea',
'video',
'view',
'web-view'
];
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
function processEvent(expr, filterModules) {
var isMethodPath = simplePathRE.test(expr);
if (isMethodPath) {
if (filterModules.find(function (name) { return expr.indexOf(name + '.') === 0; })) {
return ("\n$event = $handleWxsEvent($event);\n" + expr + "($event, $getComponentDescriptor())\n")
} else {
expr = expr + '($event)';
}
}
return ("\n$event = $handleEvent($event);\n" + expr + "\n")
}
var deprecated = {
events: {
'tap': 'click',
'longtap': 'longpress'
}
};
var tag = {
preTransformNode: function preTransformNode(el) {
if (TAGS.indexOf(el.tag) !== -1) {
el.tag = 'v-uni-' + el.tag;
}
},
postTransformNode: function postTransformNode(el, ref) {
var filterModules = ref.filterModules;
if (el.tag === 'block') {
el.tag = 'template';
var vForKey = el.key;
if (vForKey) {
delete el.key;
el.children.forEach(function (childEl, index) {
var childVForKey = childEl.key;
if (childVForKey) {
childEl.key = childVForKey + "+'_'+" + vForKey + "+'_" + index + "'";
} else {
childEl.key = vForKey + "+'_" + index + "'";
}
});
}
}
if (el.events) {
filterModules = filterModules || [];
var eventsMap = deprecated.events;
// const warnLogs = new Set()
Object.keys(el.events).forEach(function (name) {
// 过时事件类型转换
if (eventsMap[name]) {
el.events[eventsMap[name]] = el.events[name];
delete el.events[name];
// warnLogs.add(`警告:事件${name}已过时,推荐使用${eventsMap[name]}代替`)
name = eventsMap[name];
}
var handlers = el.events[name];
if (Array.isArray(handlers)) {
handlers.forEach(function (handler) {
handler.value = processEvent(handler.value, filterModules);
});
} else {
handlers.value = processEvent(handlers.value, filterModules);
}
});
}
}
};
// TODO 待优化
var validDivisionCharRE$1 = /[\w).+\-_$\]]/;
function parseFilters$1(exp) {
var inSingle = false;
var inDouble = false;
var inTemplateString = false;
var inRegex = false;
var curly = 0;
var square = 0;
var paren = 0;
var lastFilterIndex = 0;
var c, prev, i, expression, filters;
for (i = 0; i < exp.length; i++) {
prev = c;
c = exp.charCodeAt(i);
if (inSingle) {
if (c === 0x27 && prev !== 0x5C) {
inSingle = false;
}
} else if (inDouble) {
if (c === 0x22 && prev !== 0x5C) {
inDouble = false;
}
} else if (inTemplateString) {
if (c === 0x60 && prev !== 0x5C) {
inTemplateString = false;
}
} else if (inRegex) {
if (c === 0x2f && prev !== 0x5C) {
inRegex = false;
}
} else if (
c === 0x7C && // pipe
exp.charCodeAt(i + 1) !== 0x7C &&
exp.charCodeAt(i - 1) !== 0x7C &&
!curly && !square && !paren
) {
if (expression === undefined) {
// first filter, end of expression
lastFilterIndex = i + 1;
expression = exp.slice(0, i).trim();
} else {
pushFilter();
}
} else {
switch (c) {
case 0x22:
inDouble = true;
break // "
case 0x27:
inSingle = true;
break // '
case 0x60:
inTemplateString = true;
break // `
case 0x28:
paren++;
break // (
case 0x29:
paren--;
break // )
case 0x5B:
square++;
break // [
case 0x5D:
square--;
break // ]
case 0x7B:
curly++;
break // {
case 0x7D:
curly--;
break // }
}
if (c === 0x2f) { // /
var j = i - 1;
var p = (void 0);
// find first non-whitespace prev char
for (; j >= 0; j--) {
p = exp.charAt(j);
if (p !== ' ') {
break
}
}
if (!p || !validDivisionCharRE$1.test(p)) {
inRegex = true;
}
}
}
}
if (expression === undefined) {
expression = exp.slice(0, i).trim();
} else if (lastFilterIndex !== 0) {
pushFilter();
}
function pushFilter() {
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
lastFilterIndex = i + 1;
}
if (filters) {
for (i = 0; i < filters.length; i++) {
expression = wrapFilter$1(expression, filters[i]);
}
}
return expression
}
function wrapFilter$1(exp, filter) {
var i = filter.indexOf('(');
if (i < 0) {
// _f: resolveFilter
return ('_f("' + filter + '")(' + exp + ')')
} else {
var name = filter.slice(0, i);
var args = filter.slice(i + 1);
return ('_f("' + name + '")(' + exp + (args !== ')' ? ',' + args : args))
}
}
var defaultTagRE$1 = /\{\{((?:.|\n)+?)\}\}/g;
function parseText$1(
text
) {
var tokens = [];
var rawTokens = [];
var lastIndex = defaultTagRE$1.lastIndex = 0;
var match, index, tokenValue;
while ((match = defaultTagRE$1.exec(text))) {
index = match.index;
// push text token
if (index > lastIndex) {
rawTokens.push(tokenValue = text.slice(lastIndex, index));
tokens.push(JSON.stringify(tokenValue));
}
// tag token
var exp = parseFilters$1(match[1].trim());
tokens.push(('_s(' + exp + ')'));
rawTokens.push({
'@binding': exp
});
lastIndex = index + match[0].length;
}
if (lastIndex < text.length) {
rawTokens.push(tokenValue = text.slice(lastIndex));
tokens.push(JSON.stringify(tokenValue));
}
return {
expression: tokens.join('+'),
tokens: rawTokens
}
}
var text = {
postTransformNode: function postTransformNode(el) { // 重新格式化 text 节点,应该使用postTransformNode,但 mpvue 使用的 template-compiler 较老,导致 postTransformNode 时机不对
var children = el.children;
if (children && children.length) {
children.forEach(function (childEl) {
if (childEl.text) {
var text = childEl.text.trim();
if (childEl.type === 2) {
try {
var ref = parseText$1(text);
var expression = ref.expression;
var tokens = ref.tokens;
childEl.expression = expression;
childEl.tokens = tokens;
childEl.text = text;
} catch (e) {
console.log(e);
}
} else {
childEl.text = text;
}
}
});
}
return ''
}
};
var modules$1 = [
text,// fixed by xxxxxx
wxs$1,// fixed by xxxxxx
klass$1,
style$1,
model$1
];
model$1,
tag ];
/* */
function text (el, dir) {
function text$1 (el, dir) {
if (dir.value) {
addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
}
......@@ -10740,7 +11047,7 @@
var directives$1 = {
model: model,
text: text,
text: text$1,
html: html
};
......@@ -10890,7 +11197,7 @@
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
var simplePathRE$1 = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// KeyboardEvent.keyCode aliases
var keyCodes = {
......@@ -10972,9 +11279,9 @@
return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
}
var isMethodPath = simplePathRE.test(handler.value);
var isMethodPath = simplePathRE$1.test(handler.value);
var isFunctionExpression = fnExpRE.test(handler.value);
var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
var isFunctionInvocation = simplePathRE$1.test(handler.value.replace(fnInvokeRE, ''));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
......
......@@ -158,9 +158,7 @@ if (pixelRatio !== 1) {
}
export function wrapper (canvas) {
canvas.style.height = canvas.height + 'px'
canvas.style.width = canvas.width + 'px'
canvas.width *= pixelRatio
canvas.height *= pixelRatio
canvas.width = canvas.offsetWidth * pixelRatio
canvas.height = canvas.offsetHeight * pixelRatio
canvas.getContext('2d').__hidpi__ = true
}
import {
hasOwn
} from 'uni-shared'
export default function createPage (pageVm) {
const $route = pageVm.$route
pageVm.route = $route.meta.pagePath
const id = hasOwn($route.params, '__id__') ? $route.params.__id__ : $route.meta.id
pageVm.__page__ = {
id: $route.params.__id__,
id,
path: $route.path,
route: $route.meta.pagePath,
meta: Object.assign({}, $route.meta)
}
// 兼容 mpvue
pageVm.$vm = pageVm
pageVm.$root = pageVm
pageVm.$root = pageVm
pageVm.$holder = pageVm.$parent.$parent
// 补充 mp 相关属性
pageVm.$mp = {
......@@ -19,4 +25,4 @@ export default function createPage (pageVm) {
// 暂不支持
status: ''
}
}
}
......@@ -21,6 +21,7 @@ import {
} from 'uni-mixins'
import {
pixelRatio,
wrapper
} from 'uni-helpers/hidpi'
......@@ -106,16 +107,8 @@ export default {
method(data)
}
},
_resize ({
width,
height
}) {
var canvas = this.$refs.canvas
if (canvas.style.width !== (width + 'px') || canvas.style.height !== (height + 'px')) {
canvas.width = width
canvas.height = height
wrapper(canvas)
}
_resize () {
wrapper(this.$refs.canvas)
},
_touchmove (event) {
event.preventDefault()
......@@ -381,22 +374,44 @@ export default {
}
},
getImageData ({
x,
y,
x = 0,
y = 0,
width,
height,
destWidth,
destHeight,
hidpi = true,
callbackId
}) {
var imgData
var canvas = this.$refs.canvas
if (!width) {
width = canvas.width
width = canvas.offsetWidth - x
}
if (!height) {
height = canvas.height
height = canvas.offsetHeight - y
}
try {
imgData = canvas.getContext('2d').getImageData(x, y, width, height)
const newCanvas = document.createElement('canvas')
if (!hidpi) {
if (!destWidth && !destHeight) {
destWidth = Math.round(width * pixelRatio)
destHeight = Math.round(height * pixelRatio)
} else if (!destWidth) {
destWidth = Math.round(width / height * destHeight)
} else if (!destHeight) {
destHeight = Math.round(height / width * destWidth)
}
} else {
destWidth = width
destHeight = height
}
newCanvas.width = destWidth
newCanvas.height = destHeight
const context = newCanvas.getContext('2d')
context.__hidpi__ = true
context.drawImageByCanvas(canvas, x, y, width, height, 0, 0, destWidth, destHeight, false)
imgData = context.getImageData(0, 0, destWidth, destHeight)
} catch (error) {
UniViewJSBridge.publishHandler('onCanvasMethodCallback', {
callbackId,
......@@ -411,8 +426,8 @@ export default {
data: {
errMsg: 'canvasGetImageData:ok',
data: [...imgData.data],
width,
height
width: destWidth,
height: destHeight
}
}, this.$page.id)
},
......@@ -428,8 +443,12 @@ export default {
if (!height) {
height = Math.round(data.length / 4 / width)
}
this.$refs.canvas.getContext('2d').putImageData(new ImageData(new Uint8ClampedArray(data), width,
height), x, y)
const canvas = document.createElement('canvas')
canvas.width = width
canvas.height = height
const context = canvas.getContext('2d')
context.putImageData(new ImageData(new Uint8ClampedArray(data), width, height), 0, 0)
this.$refs.canvas.getContext('2d').drawImage(canvas, x, y, width, height)
} catch (error) {
UniViewJSBridge.publishHandler('onCanvasMethodCallback', {
callbackId,
......
......@@ -2,10 +2,12 @@ export * from './context/live-pusher'
export * from './context/map'
export * from './context/video'
export * from './ui/create-selector-query'
export * from './plugin/require-native-plugin'
export * from './route/navigate-back'
export * from './route/navigate-to'
export * from './route/re-launch'
export * from './route/redirect-to'
export * from './route/switch-tab'
export * from './route/switch-tab'
import {
isFn
} from 'uni-shared'
class NodesRef {
constructor (selectorQuery, component, selector, single) {
this._selectorQuery = selectorQuery
this._component = component
this._selector = selector
this._single = single
}
boundingClientRect (callback) {
this._selectorQuery._push(
this._selector,
this._component,
this._single, {
id: true,
dataset: true,
rect: true,
size: true
},
callback)
return this._selectorQuery
}
fields (fields, callback) {
this._selectorQuery._push(
this._selector,
this._component,
this._single,
fields,
callback
)
return this._selectorQuery
}
scrollOffset (callback) {
this._selectorQuery._push(
this._selector,
this._component,
this._single, {
id: true,
dataset: true,
scrollOffset: true
},
callback
)
return this._selectorQuery
}
}
function processDataset (attr) {
const dataset = {}
Object.keys(attr || {}).forEach(key => {
if (key.indexOf('data') === 0) {
let str = key.replace('data', '')
str = str.charAt(0).toLowerCase() + str.slice(1)
dataset[str] = attr[key]
}
})
return dataset
}
function findAttrs (ids, elm, result) {
let nodes = elm.children
if (!Array.isArray(nodes)) {
return false
}
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i]
if (node.attr) {
let index = ids.indexOf(node.attr.id)
if (index >= 0) {
result[index] = {
id: ids[index],
ref: node.ref,
dataset: processDataset(node.attr)
}
if (ids.length === 1) {
break
}
}
}
if (node.children) {
findAttrs(ids, node, result)
}
}
}
function getSelectors (queue) {
let ids = []
for (let i = 0; i < queue.length; i++) {
const selector = queue[i].selector
if (selector.indexOf('#') === 0) {
ids.push(selector.substring(1))
}
}
return ids
}
function getComponentRectAll (dom, attrs, index, result, callback) {
const attr = attrs[index]
dom.getComponentRect(attr.ref, option => {
option.size.id = attr.id
option.size.dataset = attr.dataset
result.push(option.size)
index += 1
if (index < attrs.length) {
getComponentRectAll(dom, attrs, index, result, callback)
} else {
callback(result)
}
})
}
function requestComponentInfo (dom, component, queue, callback) {
const selectors = getSelectors(queue)
let outAttrs = new Array(selectors.length)
findAttrs(selectors, component.$el, outAttrs)
getComponentRectAll(dom, outAttrs, 0, [], (result) => {
callback(result)
})
}
class SelectorQuery {
constructor (pageId) {
this.pageId = pageId
this._queue = []
this._queueCb = []
}
exec (callback) {
if (!this._component) {
return
}
this._dom = this._component._$weex.requireModule('dom')
requestComponentInfo(this._dom, this._component, this._queue, res => {
const queueCbs = this._queueCb
res.forEach((result, index) => {
const queueCb = queueCbs[index]
if (isFn(queueCb)) {
queueCb.call(this, result)
}
})
isFn(callback) && callback.call(this, res)
})
}
['in'] (component) {
if (!component) {
return console.warn('uni.createSelectorQuery 必须传入当前 vm 对象(this)')
}
this._component = component
return this
}
select (selector) {
return new NodesRef(this, this._component, selector, true)
}
selectAll (selector) {
return new NodesRef(this, this._component, selector, false)
}
selectViewport () {
return new NodesRef(this, 0, '', true)
}
_push (selector, component, single, fields, callback) {
this._queue.push({
component,
selector,
single,
fields
})
this._queueCb.push(callback)
}
}
export function createSelectorQuery () {
return new SelectorQuery()
}
......@@ -13,5 +13,6 @@ export {
export * from '../../../service/api/context/map'
export * from '../../../service/api/context/video'
export * from '../../../service/api/context/live-pusher'
export * from 'uni-core/service/api/base/interceptor'
export * from '../../../service/api/context/live-pusher'
export * from '../../../service/api/ui/create-selector-query'
export * from 'uni-core/service/api/base/interceptor'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册