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

Merge branch 'dev' of https://github.com/dcloudio/uni-app into alpha

......@@ -8962,14 +8962,14 @@ var serviceContext = (function () {
'pause',
'stop',
'ended',
'timeupdate',
'timeUpdate',
'error',
'waiting',
'seeking',
'seeked'
];
const props = [
const props = [
{
name: 'src',
cache: true
......@@ -9022,7 +9022,7 @@ var serviceContext = (function () {
this._callbacks = {};
this._options = {};
eventNames.forEach(name => {
this._callbacks[name] = [];
this._callbacks[name.toLowerCase()] = [];
});
props.forEach(item => {
const name = item.name;
......@@ -9056,11 +9056,12 @@ var serviceContext = (function () {
this._operate('stop');
}
seek (position) {
this._operate('play', {
currentTime: position
this._operate('seek', {
currentTime: position * 1e3
});
}
destroy () {
clearInterval(this.__timing);
invokeMethod('destroyAudioInstance', {
audioId: this.id
});
......@@ -9076,6 +9077,7 @@ var serviceContext = (function () {
eventNames.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1);
item = item.toLowerCase();
InnerAudioContext.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback);
};
......@@ -9088,6 +9090,17 @@ var serviceContext = (function () {
};
});
function emit (audio, state, errMsg, errCode) {
audio._callbacks[state].forEach(callback => {
if (typeof callback === 'function') {
callback(state === 'error' ? {
errMsg,
errCode
} : {});
}
});
}
onMethod('onAudioStateChange', ({
state,
audioId,
......@@ -9095,14 +9108,20 @@ var serviceContext = (function () {
errCode
}) => {
const audio = innerAudioContexts[audioId];
audio && audio._callbacks[state].forEach(callback => {
if (typeof callback === 'function') {
callback(state === 'error' ? {
errMsg,
errCode
} : {});
if (audio) {
emit(audio, state, errMsg, errCode);
if (state === 'play') {
const oldCurrentTime = audio.currentTime;
audio.__timing = setInterval(() => {
const currentTime = audio.currentTime;
if (currentTime !== oldCurrentTime) {
emit(audio, 'timeupdate');
}
}, 200);
} else if (state === 'pause' || state === 'stop' || state === 'error') {
clearInterval(audio.__timing);
}
});
}
});
const innerAudioContexts = Object.create(null);
......
......@@ -6642,6 +6642,53 @@ var baseModules = [
directives
];
/* */
function updateWxsProps(oldVnode, vnode) {
if (
isUndef(oldVnode.data.wxsProps) &&
isUndef(vnode.data.wxsProps)
) {
return
}
var oldWxsWatches = oldVnode.$wxsWatches;
var wxsPropsKey = Object.keys(vnode.data.wxsProps);
if (!oldWxsWatches && !wxsPropsKey.length) {
return
}
if (!oldWxsWatches) {
oldWxsWatches = {};
}
var wxsProps = vnode.data.wxsProps;
vnode.$wxsWatches = {};
Object.keys(wxsProps).forEach(function (prop) {
var watchProp = wxsProps[prop];
vnode.$wxsWatches[prop] = oldWxsWatches[prop] || vnode.context.$watch(watchProp, function() {
this.$forceUpdate();
}, {
deep: true
});
});
Object.keys(oldWxsWatches).forEach(function (oldName) {
if (!vnode.$wxsWatches[oldName]) {
oldWxsWatches[oldName]();
delete oldWxsWatches[oldName];
}
});
}
var wxs = {
create: updateWxsProps,
update: updateWxsProps
};
function parseDataset(attrs) {
var dataset = Object.create(null);
Object.keys(attrs).forEach(function (name) {
......@@ -6765,6 +6812,7 @@ var events = {
};
var platformModules = [
wxs,
attrs,
events
];
......
......@@ -334,7 +334,7 @@ let uniAutoImportComponents = []
let uniAutoImportScanComponents = []
function initAutoImportScanComponents () {
function initAutoImportScanComponents () {
const componentsPath = path.resolve(process.env.UNI_INPUT_DIR, 'components')
const components = {}
try {
......@@ -347,12 +347,22 @@ function initAutoImportScanComponents () {
})
} catch (e) {}
uniAutoImportScanComponents = parseUsingAutoImportComponents(components)
uniAutoImportScanComponents = parseUsingAutoImportComponents(components)
refreshAutoComponentMap()
}
function initAutoImportComponents (usingAutoImportComponents = {}) {
const _toString = Object.prototype.toString
function isPlainObject (obj) {
return _toString.call(obj) === '[object Object]'
}
function initAutoImportComponents (easycom = {}) {
let usingAutoImportComponents = easycom.custom || easycom || {}
if (!isPlainObject(usingAutoImportComponents)) {
usingAutoImportComponents = {}
}
// 目前仅 mp-weixin 内置支持 page-meta 等组件
if (process.env.UNI_PLATFORM !== 'mp-weixin') {
if (!usingAutoImportComponents['^page-meta$']) {
......@@ -415,10 +425,13 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
const autoImportComponents = []
if (usingAutoImportComponents) {
Object.keys(usingAutoImportComponents).forEach(pattern => {
autoImportComponents.push({
pattern: new RegExp(pattern),
replacement: usingAutoImportComponents[pattern]
})
const replacement = usingAutoImportComponents[pattern]
if (replacement && typeof replacement === 'string') {
autoImportComponents.push({
pattern: new RegExp(pattern),
replacement: replacement
})
}
})
}
return autoImportComponents
......@@ -432,7 +445,7 @@ module.exports = {
parsePagesJson,
pagesJsonJsFileName,
getAutoComponents,
initAutoImportComponents,
initAutoImportComponents,
initAutoImportScanComponents,
addPageUsingComponents,
getUsingComponentsCode,
......
......@@ -312,12 +312,15 @@ if (
}
const {
initAutoImportComponents,
initAutoImportComponents,
initAutoImportScanComponents
} = require('@dcloudio/uni-cli-shared/lib/pages')
initAutoImportScanComponents()
initAutoImportComponents(pagesJsonObj.easycom)
} = require('@dcloudio/uni-cli-shared/lib/pages')
process.UNI_AUTO_SCAN_COMPONENTS = !(pagesJsonObj.easycom && pagesJsonObj.easycom.autoscan === false)
initAutoImportComponents(pagesJsonObj.easycom)
if (process.UNI_AUTO_SCAN_COMPONENTS) {
initAutoImportScanComponents()
}
runByHBuilderX && console.log(`正在编译中...`)
......
/*!
* vue-router v3.0.1
* (c) 2019 Evan You
* (c) 2020 Evan You
* @license MIT
*/
'use strict';
......@@ -1325,7 +1325,6 @@ function normalizeLocation (
/* */
function createMatcher (
routes,
router
......@@ -1495,7 +1494,7 @@ function createMatcher (
if (record.meta.id) {
record.components.default.name = record.meta.name + '-' + location.params.__id__;
} else {
record = Object.assign({}, record);
record = extend({}, record);
record.components = {
'default': {
name: record.meta.name + '-' + location.params.__id__,
......
/*!
* vue-router v3.0.1
* (c) 2019 Evan You
* (c) 2020 Evan You
* @license MIT
*/
/* */
......@@ -1323,7 +1323,6 @@ function normalizeLocation (
/* */
function createMatcher (
routes,
router
......@@ -1493,7 +1492,7 @@ function createMatcher (
if (record.meta.id) {
record.components.default.name = record.meta.name + '-' + location.params.__id__;
} else {
record = Object.assign({}, record);
record = extend({}, record);
record.components = {
'default': {
name: record.meta.name + '-' + location.params.__id__,
......
/*!
* vue-router v3.0.1
* (c) 2019 Evan You
* (c) 2020 Evan You
* @license MIT
*/
(function (global, factory) {
......@@ -1329,7 +1329,6 @@ function normalizeLocation (
/* */
function createMatcher (
routes,
router
......@@ -1499,7 +1498,7 @@ function createMatcher (
if (record.meta.id) {
record.components.default.name = record.meta.name + '-' + location.params.__id__;
} else {
record = Object.assign({}, record);
record = extend({}, record);
record.components = {
'default': {
name: record.meta.name + '-' + location.params.__id__,
......
......@@ -13,7 +13,9 @@ class WebpackUniAppPlugin {
compiler.hooks.invalid.tap('webpack-uni-app-invalid', (fileName, changeTime) => {
if (fileName && typeof fileName === 'string') {
if (fileName.indexOf('.vue') !== -1 || fileName.indexOf('.nvue') !== -1) {
initAutoImportScanComponents()
if (process.UNI_AUTO_SCAN_COMPONENTS) {
initAutoImportScanComponents()
}
}
}
})
......
......@@ -56,6 +56,7 @@ module.exports = function (content) {
})
// 组件自动导入配置
process.UNI_AUTO_SCAN_COMPONENTS = !(pagesJson.easycom && pagesJson.easycom.autoscan === false)
initAutoImportComponents(pagesJson.easycom)
// TODO 与 usingComponents 放在一块读取设置
......@@ -128,4 +129,4 @@ module.exports = function (content) {
}
return ''
}
}
......@@ -36,9 +36,9 @@ const ratioArgs = {
'createLinearGradient': 'all',
'setTransform': [4, 5]
}
if (pixelRatio !== 1) {
const proto = CanvasRenderingContext2D.prototype
const proto = CanvasRenderingContext2D.prototype
if (pixelRatio !== 1) {
forEach(ratioArgs, function (value, key) {
proto[key] = (function (_super) {
return function () {
......@@ -129,23 +129,6 @@ if (pixelRatio !== 1) {
}
})(proto.strokeText)
proto.drawImageByCanvas = (function (_super) {
return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
srcx *= pixelRatio
srcy *= pixelRatio
srcw *= pixelRatio
srch *= pixelRatio
desx *= pixelRatio
desy *= pixelRatio
desw = isScale ? desw * pixelRatio : desw
desh = isScale ? desh * pixelRatio : desh
_super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh)
}
})(proto.drawImage)
proto.drawImage = (function (_super) {
return function () {
if (!this.__hidpi__) {
......@@ -158,6 +141,23 @@ if (pixelRatio !== 1) {
})(proto.drawImage)
}
proto.drawImageByCanvas = (function (_super) {
return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) {
if (!this.__hidpi__) {
return _super.apply(this, arguments)
}
srcx *= pixelRatio
srcy *= pixelRatio
srcw *= pixelRatio
srch *= pixelRatio
desx *= pixelRatio
desy *= pixelRatio
desw = isScale ? desw * pixelRatio : desw
desh = isScale ? desh * pixelRatio : desh
_super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh)
}
})(proto.drawImage)
export function wrapper (canvas) {
canvas.width = canvas.offsetWidth * pixelRatio
canvas.height = canvas.offsetHeight * pixelRatio
......
......@@ -9,14 +9,14 @@ const eventNames = [
'pause',
'stop',
'ended',
'timeupdate',
'timeUpdate',
'error',
'waiting',
'seeking',
'seeked'
]
const props = [
const props = [
{
name: 'src',
cache: true
......@@ -69,7 +69,7 @@ class InnerAudioContext {
this._callbacks = {}
this._options = {}
eventNames.forEach(name => {
this._callbacks[name] = []
this._callbacks[name.toLowerCase()] = []
})
props.forEach(item => {
const name = item.name
......@@ -103,11 +103,12 @@ class InnerAudioContext {
this._operate('stop')
}
seek (position) {
this._operate('play', {
currentTime: position
this._operate('seek', {
currentTime: position * 1e3
})
}
destroy () {
clearInterval(this.__timing)
invokeMethod('destroyAudioInstance', {
audioId: this.id
})
......@@ -123,6 +124,7 @@ class InnerAudioContext {
eventNames.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1)
item = item.toLowerCase()
InnerAudioContext.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback)
}
......@@ -135,6 +137,17 @@ eventNames.forEach(item => {
}
})
function emit (audio, state, errMsg, errCode) {
audio._callbacks[state].forEach(callback => {
if (typeof callback === 'function') {
callback(state === 'error' ? {
errMsg,
errCode
} : {})
}
})
}
onMethod('onAudioStateChange', ({
state,
audioId,
......@@ -142,14 +155,20 @@ onMethod('onAudioStateChange', ({
errCode
}) => {
const audio = innerAudioContexts[audioId]
audio && audio._callbacks[state].forEach(callback => {
if (typeof callback === 'function') {
callback(state === 'error' ? {
errMsg,
errCode
} : {})
if (audio) {
emit(audio, state, errMsg, errCode)
if (state === 'play') {
const oldCurrentTime = audio.currentTime
audio.__timing = setInterval(() => {
const currentTime = audio.currentTime
if (currentTime !== oldCurrentTime) {
emit(audio, 'timeupdate')
}
}, 200)
} else if (state === 'pause' || state === 'stop' || state === 'error') {
clearInterval(audio.__timing)
}
})
}
})
const innerAudioContexts = Object.create(null)
......@@ -161,4 +180,4 @@ export function createInnerAudioContext () {
const innerAudioContext = new InnerAudioContext(audioId)
innerAudioContexts[audioId] = innerAudioContext
return innerAudioContext
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册