提交 57303484 编写于 作者: Q qiang

build v3

上级 247b5d60
......@@ -66,6 +66,7 @@ var serviceContext = (function () {
'compressImage',
'getRecorderManager',
'getBackgroundAudioManager',
'createAudioContext',
'createInnerAudioContext',
'chooseVideo',
'saveVideoToPhotosAlbum',
......@@ -217,8 +218,8 @@ var serviceContext = (function () {
'setPageMeta',
'onNativeEventReceive',
'sendNativeEvent',
'preloadPage',
'unPreloadPage',
'preloadPage',
'unPreloadPage',
'loadSubPackage'
];
......@@ -2891,6 +2892,58 @@ var serviceContext = (function () {
upx2px: upx2px$1
});
function operateAudioPlayer (audioId, pageId, type, data) {
UniServiceJSBridge.publishHandler(pageId + '-audio-' + audioId, {
audioId,
type,
data
}, pageId);
}
class AudioContext {
constructor (id, pageId) {
this.id = id;
this.pageId = pageId;
}
setSrc (src) {
operateAudioPlayer(this.id, this.pageId, 'setSrc', {
src
});
}
play () {
operateAudioPlayer(this.id, this.pageId, 'play');
}
pause () {
operateAudioPlayer(this.id, this.pageId, 'pause');
}
seek (position) {
operateAudioPlayer(this.id, this.pageId, 'seek', {
position
});
}
}
function createAudioContext$1 (id, context) {
if (context) {
return new AudioContext(id, context.$page.id)
}
const app = getApp();
if (app.$route && app.$route.params.__id__) {
return new AudioContext(id, app.$route.params.__id__)
} else {
UniServiceJSBridge.emit('onError', 'createAudioContext:fail');
}
}
var require_context_module_1_4 = /*#__PURE__*/Object.freeze({
__proto__: null,
createAudioContext: createAudioContext$1
});
const Emitter = new Vue();
function apply (ctx, method, args) {
......@@ -6528,7 +6581,8 @@ var serviceContext = (function () {
header,
method = 'GET',
responseType,
sslVerify = true
sslVerify = true,
firstIpv4 = false
} = {}) {
const stream = requireNativePlugin('stream');
const headers = {};
......@@ -6581,7 +6635,8 @@ var serviceContext = (function () {
// weex 官方文档未说明实际支持 timeout,单位:ms
timeout: timeout || 6e5,
// 配置和weex模块内相反
sslVerify: !sslVerify
sslVerify: !sslVerify,
firstIpv4: firstIpv4
};
if (method !== 'GET') {
options.body = typeof data === 'string' ? data : JSON.stringify(data);
......@@ -10013,196 +10068,6 @@ var serviceContext = (function () {
}
const eventNames$1 = [
'canplay',
'play',
'pause',
'stop',
'ended',
'timeUpdate',
'error',
'waiting',
'seeking',
'seeked'
];
const props = [
{
name: 'src',
cache: true
},
{
name: 'startTime',
default: 0,
cache: true
},
{
name: 'autoplay',
default: false,
cache: true
},
{
name: 'loop',
default: false,
cache: true
},
{
name: 'obeyMuteSwitch',
default: true,
readonly: true,
cache: true
},
{
name: 'duration',
readonly: true
},
{
name: 'currentTime',
readonly: true
},
{
name: 'paused',
readonly: true
},
{
name: 'buffered',
readonly: true
},
{
name: 'volume'
}
];
class InnerAudioContext {
constructor (id) {
this.id = id;
this._callbacks = {};
this._options = {};
eventNames$1.forEach(name => {
this._callbacks[name.toLowerCase()] = [];
});
props.forEach(item => {
const name = item.name;
const data = {
get () {
const result = item.cache ? this._options : invokeMethod('getAudioState', {
audioId: this.id
});
const value = name in result ? result[name] : item.default;
return typeof value === 'number' && name !== 'volume' ? value / 1e3 : value
}
};
if (!item.readonly) {
data.set = function (value) {
this._options[name] = value;
invokeMethod('setAudioState', Object.assign({}, this._options, {
audioId: this.id
}));
};
}
Object.defineProperty(this, name, data);
});
}
play () {
this._operate('play');
}
pause () {
this._operate('pause');
}
stop () {
this._operate('stop');
}
seek (position) {
this._operate('seek', {
currentTime: position * 1e3
});
}
destroy () {
clearInterval(this.__timing);
invokeMethod('destroyAudioInstance', {
audioId: this.id
});
delete innerAudioContexts[this.id];
}
_operate (type, options) {
invokeMethod('operateAudio', Object.assign({}, options, {
audioId: this.id,
operationType: type
}));
}
}
eventNames$1.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1);
item = item.toLowerCase();
InnerAudioContext.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback);
};
InnerAudioContext.prototype[`off${name}`] = function (callback) {
const callbacks = this._callbacks[item];
const index = callbacks.indexOf(callback);
if (index >= 0) {
callbacks.splice(index, 1);
}
};
});
function emit (audio, state, errMsg, errCode) {
audio._callbacks[state].forEach(callback => {
if (typeof callback === 'function') {
callback(state === 'error' ? {
errMsg,
errCode
} : {});
}
});
}
onMethod('onAudioStateChange', ({
state,
audioId,
errMsg,
errCode
}) => {
const audio = innerAudioContexts[audioId];
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);
function createInnerAudioContext () {
const {
audioId
} = invokeMethod('createAudioInstance');
const innerAudioContext = new InnerAudioContext(audioId);
innerAudioContexts[audioId] = innerAudioContext;
return innerAudioContext
}
var require_context_module_1_4 = /*#__PURE__*/Object.freeze({
__proto__: null,
createInnerAudioContext: createInnerAudioContext
});
const eventNames$2 = [
'canplay',
'play',
'pause',
......@@ -10215,11 +10080,11 @@ var serviceContext = (function () {
'waiting'
];
const callbacks$5 = {};
eventNames$2.forEach(name => {
eventNames$1.forEach(name => {
callbacks$5[name] = [];
});
const props$1 = [
const props = [
{
name: 'duration',
readonly: true
......@@ -10289,7 +10154,7 @@ var serviceContext = (function () {
}
});
});
props$1.forEach(item => {
props.forEach(item => {
const name = item.name;
const data = {
get () {
......@@ -10334,7 +10199,7 @@ var serviceContext = (function () {
}
}
eventNames$2.forEach(item => {
eventNames$1.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1);
BackgroundAudioManager.prototype[`on${name}`] = function (callback) {
callbacks$5[item].push(callback);
......@@ -11427,6 +11292,196 @@ var serviceContext = (function () {
EditorContext: EditorContext
});
const eventNames$2 = [
'canplay',
'play',
'pause',
'stop',
'ended',
'timeUpdate',
'error',
'waiting',
'seeking',
'seeked'
];
const props$1 = [
{
name: 'src',
cache: true
},
{
name: 'startTime',
default: 0,
cache: true
},
{
name: 'autoplay',
default: false,
cache: true
},
{
name: 'loop',
default: false,
cache: true
},
{
name: 'obeyMuteSwitch',
default: true,
readonly: true,
cache: true
},
{
name: 'duration',
readonly: true
},
{
name: 'currentTime',
readonly: true
},
{
name: 'paused',
readonly: true
},
{
name: 'buffered',
readonly: true
},
{
name: 'volume'
}
];
class InnerAudioContext {
constructor (id) {
this.id = id;
this._callbacks = {};
this._options = {};
eventNames$2.forEach(name => {
this._callbacks[name.toLowerCase()] = [];
});
props$1.forEach(item => {
const name = item.name;
const data = {
get () {
const result = item.cache ? this._options : invokeMethod('getAudioState', {
audioId: this.id
});
const value = name in result ? result[name] : item.default;
return typeof value === 'number' && name !== 'volume' ? value / 1e3 : value
}
};
if (!item.readonly) {
data.set = function (value) {
this._options[name] = value;
invokeMethod('setAudioState', Object.assign({}, this._options, {
audioId: this.id
}));
};
}
Object.defineProperty(this, name, data);
});
}
play () {
this._operate('play');
}
pause () {
this._operate('pause');
}
stop () {
this._operate('stop');
}
seek (position) {
this._operate('seek', {
currentTime: position * 1e3
});
}
destroy () {
clearInterval(this.__timing);
invokeMethod('destroyAudioInstance', {
audioId: this.id
});
delete innerAudioContexts[this.id];
}
_operate (type, options) {
invokeMethod('operateAudio', Object.assign({}, options, {
audioId: this.id,
operationType: type
}));
}
}
eventNames$2.forEach(item => {
const name = item[0].toUpperCase() + item.substr(1);
item = item.toLowerCase();
InnerAudioContext.prototype[`on${name}`] = function (callback) {
this._callbacks[item].push(callback);
};
InnerAudioContext.prototype[`off${name}`] = function (callback) {
const callbacks = this._callbacks[item];
const index = callbacks.indexOf(callback);
if (index >= 0) {
callbacks.splice(index, 1);
}
};
});
function emit (audio, state, errMsg, errCode) {
audio._callbacks[state].forEach(callback => {
if (typeof callback === 'function') {
callback(state === 'error' ? {
errMsg,
errCode
} : {});
}
});
}
onMethod('onAudioStateChange', ({
state,
audioId,
errMsg,
errCode
}) => {
const audio = innerAudioContexts[audioId];
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);
function createInnerAudioContext () {
const {
audioId
} = invokeMethod('createAudioInstance');
const innerAudioContext = new InnerAudioContext(audioId);
innerAudioContexts[audioId] = innerAudioContext;
return innerAudioContext
}
var require_context_module_1_10 = /*#__PURE__*/Object.freeze({
__proto__: null,
createInnerAudioContext: createInnerAudioContext
});
const callbacks$6 = [];
onMethod('onAccelerometerChange', function (res) {
......@@ -11467,7 +11522,7 @@ var serviceContext = (function () {
})
}
var require_context_module_1_10 = /*#__PURE__*/Object.freeze({
var require_context_module_1_11 = /*#__PURE__*/Object.freeze({
__proto__: null,
onAccelerometerChange: onAccelerometerChange,
startAccelerometer: startAccelerometer,
......@@ -11491,7 +11546,7 @@ var serviceContext = (function () {
const onBLEConnectionStateChange$1 = on('onBLEConnectionStateChange');
const onBLECharacteristicValueChange$1 = on('onBLECharacteristicValueChange');
var require_context_module_1_11 = /*#__PURE__*/Object.freeze({
var require_context_module_1_12 = /*#__PURE__*/Object.freeze({
__proto__: null,
onBluetoothDeviceFound: onBluetoothDeviceFound$1,
onBluetoothAdapterStateChange: onBluetoothAdapterStateChange$1,
......@@ -11539,7 +11594,7 @@ var serviceContext = (function () {
})
}
var require_context_module_1_12 = /*#__PURE__*/Object.freeze({
var require_context_module_1_13 = /*#__PURE__*/Object.freeze({
__proto__: null,
onCompassChange: onCompassChange,
startCompass: startCompass,
......@@ -11558,7 +11613,7 @@ var serviceContext = (function () {
callbacks$8.push(callbackId);
}
var require_context_module_1_13 = /*#__PURE__*/Object.freeze({
var require_context_module_1_14 = /*#__PURE__*/Object.freeze({
__proto__: null,
onNetworkStatusChange: onNetworkStatusChange
});
......@@ -11575,7 +11630,7 @@ var serviceContext = (function () {
callbacks$9.push(callbackId);
}
var require_context_module_1_14 = /*#__PURE__*/Object.freeze({
var require_context_module_1_15 = /*#__PURE__*/Object.freeze({
__proto__: null,
onUIStyleChange: onUIStyleChange
});
......@@ -11603,7 +11658,7 @@ var serviceContext = (function () {
return invokeMethod('previewImagePlus', args)
}
var require_context_module_1_15 = /*#__PURE__*/Object.freeze({
var require_context_module_1_16 = /*#__PURE__*/Object.freeze({
__proto__: null,
previewImage: previewImage$1
});
......@@ -11691,7 +11746,7 @@ var serviceContext = (function () {
return recorderManager || (recorderManager = new RecorderManager())
}
var require_context_module_1_16 = /*#__PURE__*/Object.freeze({
var require_context_module_1_17 = /*#__PURE__*/Object.freeze({
__proto__: null,
getRecorderManager: getRecorderManager
});
......@@ -11785,7 +11840,7 @@ var serviceContext = (function () {
return task
}
var require_context_module_1_17 = /*#__PURE__*/Object.freeze({
var require_context_module_1_18 = /*#__PURE__*/Object.freeze({
__proto__: null,
downloadFile: downloadFile$1
});
......@@ -11901,7 +11956,7 @@ var serviceContext = (function () {
return new RequestTask(requestTaskId)
}
var require_context_module_1_18 = /*#__PURE__*/Object.freeze({
var require_context_module_1_19 = /*#__PURE__*/Object.freeze({
__proto__: null,
request: request$1
});
......@@ -12083,7 +12138,7 @@ var serviceContext = (function () {
callbacks$b.close = callbackId;
}
var require_context_module_1_19 = /*#__PURE__*/Object.freeze({
var require_context_module_1_20 = /*#__PURE__*/Object.freeze({
__proto__: null,
connectSocket: connectSocket$1,
sendSocketMessage: sendSocketMessage$1,
......@@ -12118,7 +12173,7 @@ var serviceContext = (function () {
return updateManager || (updateManager = new UpdateManager())
}
var require_context_module_1_20 = /*#__PURE__*/Object.freeze({
var require_context_module_1_21 = /*#__PURE__*/Object.freeze({
__proto__: null,
getUpdateManager: getUpdateManager
});
......@@ -12212,7 +12267,7 @@ var serviceContext = (function () {
return task
}
var require_context_module_1_21 = /*#__PURE__*/Object.freeze({
var require_context_module_1_22 = /*#__PURE__*/Object.freeze({
__proto__: null,
uploadFile: uploadFile$1
});
......@@ -12301,7 +12356,7 @@ var serviceContext = (function () {
return new MPAnimation(option)
}
var require_context_module_1_22 = /*#__PURE__*/Object.freeze({
var require_context_module_1_23 = /*#__PURE__*/Object.freeze({
__proto__: null,
createAnimation: createAnimation
});
......@@ -12371,7 +12426,7 @@ var serviceContext = (function () {
return new ServiceIntersectionObserver(getCurrentPageVm('createIntersectionObserver'), options)
}
var require_context_module_1_23 = /*#__PURE__*/Object.freeze({
var require_context_module_1_24 = /*#__PURE__*/Object.freeze({
__proto__: null,
createIntersectionObserver: createIntersectionObserver
});
......@@ -12512,7 +12567,7 @@ var serviceContext = (function () {
return new SelectorQuery(getCurrentPageVm('createSelectorQuery'))
}
var require_context_module_1_24 = /*#__PURE__*/Object.freeze({
var require_context_module_1_25 = /*#__PURE__*/Object.freeze({
__proto__: null,
createSelectorQuery: createSelectorQuery
});
......@@ -12529,7 +12584,7 @@ var serviceContext = (function () {
callback$1 = callbackId;
}
var require_context_module_1_25 = /*#__PURE__*/Object.freeze({
var require_context_module_1_26 = /*#__PURE__*/Object.freeze({
__proto__: null,
onKeyboardHeightChange: onKeyboardHeightChange
});
......@@ -12554,7 +12609,7 @@ var serviceContext = (function () {
}, pageId);
}
var require_context_module_1_26 = /*#__PURE__*/Object.freeze({
var require_context_module_1_27 = /*#__PURE__*/Object.freeze({
__proto__: null,
loadFontFace: loadFontFace$1
});
......@@ -12567,7 +12622,7 @@ var serviceContext = (function () {
return {}
}
var require_context_module_1_27 = /*#__PURE__*/Object.freeze({
var require_context_module_1_28 = /*#__PURE__*/Object.freeze({
__proto__: null,
pageScrollTo: pageScrollTo$1
});
......@@ -12580,7 +12635,7 @@ var serviceContext = (function () {
return {}
}
var require_context_module_1_28 = /*#__PURE__*/Object.freeze({
var require_context_module_1_29 = /*#__PURE__*/Object.freeze({
__proto__: null,
setPageMeta: setPageMeta
});
......@@ -12617,7 +12672,7 @@ var serviceContext = (function () {
callbacks$c.push(callbackId);
}
var require_context_module_1_29 = /*#__PURE__*/Object.freeze({
var require_context_module_1_30 = /*#__PURE__*/Object.freeze({
__proto__: null,
removeTabBarBadge: removeTabBarBadge$1,
showTabBarRedDot: showTabBarRedDot$1,
......@@ -12643,7 +12698,7 @@ var serviceContext = (function () {
callbacks$d.splice(callbacks$d.indexOf(callbackId), 1);
}
var require_context_module_1_30 = /*#__PURE__*/Object.freeze({
var require_context_module_1_31 = /*#__PURE__*/Object.freeze({
__proto__: null,
onWindowResize: onWindowResize,
offWindowResize: offWindowResize
......@@ -12664,27 +12719,28 @@ var serviceContext = (function () {
'./context/create-map-context.js': require_context_module_1_7,
'./context/create-video-context.js': require_context_module_1_8,
'./context/editor.js': require_context_module_1_9,
'./device/accelerometer.js': require_context_module_1_10,
'./device/bluetooth.js': require_context_module_1_11,
'./device/compass.js': require_context_module_1_12,
'./device/network.js': require_context_module_1_13,
'./device/theme.js': require_context_module_1_14,
'./media/preview-image.js': require_context_module_1_15,
'./media/recorder.js': require_context_module_1_16,
'./network/download-file.js': require_context_module_1_17,
'./network/request.js': require_context_module_1_18,
'./network/socket.js': require_context_module_1_19,
'./network/update.js': require_context_module_1_20,
'./network/upload-file.js': require_context_module_1_21,
'./ui/create-animation.js': require_context_module_1_22,
'./ui/create-intersection-observer.js': require_context_module_1_23,
'./ui/create-selector-query.js': require_context_module_1_24,
'./ui/keyboard.js': require_context_module_1_25,
'./ui/load-font-face.js': require_context_module_1_26,
'./ui/page-scroll-to.js': require_context_module_1_27,
'./ui/set-page-meta.js': require_context_module_1_28,
'./ui/tab-bar.js': require_context_module_1_29,
'./ui/window.js': require_context_module_1_30,
'./context/inner-audio.js': require_context_module_1_10,
'./device/accelerometer.js': require_context_module_1_11,
'./device/bluetooth.js': require_context_module_1_12,
'./device/compass.js': require_context_module_1_13,
'./device/network.js': require_context_module_1_14,
'./device/theme.js': require_context_module_1_15,
'./media/preview-image.js': require_context_module_1_16,
'./media/recorder.js': require_context_module_1_17,
'./network/download-file.js': require_context_module_1_18,
'./network/request.js': require_context_module_1_19,
'./network/socket.js': require_context_module_1_20,
'./network/update.js': require_context_module_1_21,
'./network/upload-file.js': require_context_module_1_22,
'./ui/create-animation.js': require_context_module_1_23,
'./ui/create-intersection-observer.js': require_context_module_1_24,
'./ui/create-selector-query.js': require_context_module_1_25,
'./ui/keyboard.js': require_context_module_1_26,
'./ui/load-font-face.js': require_context_module_1_27,
'./ui/page-scroll-to.js': require_context_module_1_28,
'./ui/set-page-meta.js': require_context_module_1_29,
'./ui/tab-bar.js': require_context_module_1_30,
'./ui/window.js': require_context_module_1_31,
};
var req = function req(key) {
......@@ -14007,7 +14063,8 @@ var serviceContext = (function () {
'onUniNViewMessage',
'onPageNotFound',
'onThemeChange',
'onError',
'onError',
'onUnhandledRejection',
// Page
'onLoad',
// 'onShow',
......@@ -14016,7 +14073,9 @@ var serviceContext = (function () {
'onUnload',
'onPullDownRefresh',
'onReachBottom',
'onTabItemTap',
'onTabItemTap',
'onAddToFavorites',
'onShareTimeline',
'onShareAppMessage',
'onResize',
'onPageScroll',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册