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

build:runtime

上级 a2be5da5
......@@ -231,7 +231,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......
import { v4 } from 'uuid';
import Vue from 'vue';
const _toString = Object.prototype.toString;
......@@ -231,7 +232,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -493,6 +494,67 @@ var redirectTo = {
}
};
function setStorageSync (key, data) {
return my.setStorageSync({
key,
data
})
}
function getStorageSync (key) {
const result = my.getStorageSync({
key
});
// 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
return result.data !== null ? result.data : ''
}
function removeStorageSync (key) {
return my.removeStorageSync({
key
})
}
const UUID_KEY = '__DC_UUID';
let uuid;
function addUuid (result) {
uuid = uuid || getStorageSync(UUID_KEY);
if (!uuid) {
uuid = v4();
my.setStorage({
key: UUID_KEY,
data: uuid
});
}
result.uuid = uuid;
}
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
function normalizePlatform (result) {
let platform = result.platform ? result.platform.toLowerCase() : 'devtools';
if (!~['android', 'ios'].indexOf(platform)) {
platform = 'devtools';
}
result.platform = platform;
}
var getSystemInfo = {
returnValue: function (result) {
addUuid(result);
addSafeAreaInsets(result);
normalizePlatform(result);
}
};
// 不支持的 API 列表
const todos = [
'preloadPage',
......@@ -562,14 +624,6 @@ function _handleNetworkInfo (result) {
return {}
}
function _handleSystemInfo (result) {
let platform = result.platform ? result.platform.toLowerCase() : 'devtools';
if (!~['android', 'ios'].indexOf(platform)) {
platform = 'devtools';
}
result.platform = platform;
}
const protocols = { // 需要做转换的 API 列表
navigateTo,
redirectTo,
......@@ -915,12 +969,8 @@ const protocols = { // 需要做转换的 API 列表
stopGyroscope: {
name: 'offGyroscopeChange'
},
getSystemInfo: {
returnValue: _handleSystemInfo
},
getSystemInfoSync: {
returnValue: _handleSystemInfo
},
getSystemInfo: getSystemInfo,
getSystemInfoSync: getSystemInfo,
// 文档没提到,但是实测可用。
canvasToTempFilePath: {
returnValue (result) {
......@@ -1245,25 +1295,6 @@ function createMediaQueryObserver () {
return mediaQueryObserver
}
function setStorageSync (key, data) {
return my.setStorageSync({
key,
data
})
}
function getStorageSync (key) {
const result = my.getStorageSync({
key
});
// 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
return result.data !== null ? result.data : ''
}
function removeStorageSync (key) {
return my.removeStorageSync({
key
})
}
function startGyroscope (params) {
if (hasOwn(params, 'interval')) {
console.warn('支付宝小程序 startGyroscope暂不支持interval');
......@@ -1349,13 +1380,13 @@ function createIntersectionObserver (component, options) {
var api = /*#__PURE__*/Object.freeze({
__proto__: null,
setStorageSync: setStorageSync,
getStorageSync: getStorageSync,
removeStorageSync: removeStorageSync,
startGyroscope: startGyroscope,
createSelectorQuery: createSelectorQuery,
createIntersectionObserver: createIntersectionObserver,
createMediaQueryObserver: createMediaQueryObserver
createMediaQueryObserver: createMediaQueryObserver,
setStorageSync: setStorageSync,
getStorageSync: getStorageSync,
removeStorageSync: removeStorageSync
});
const PAGE_EVENT_HOOKS = [
......@@ -1518,25 +1549,9 @@ function initBehaviors (vueOptions, initBehavior) {
}
});
}
if (isPlainObject(vueExtends) && vueExtends.props) {
behaviors.push(
initBehavior({
properties: initProperties(vueExtends.props, true)
})
);
}
if (Array.isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
if (isPlainObject(vueMixin) && vueMixin.props) {
behaviors.push(
initBehavior({
properties: initProperties(vueMixin.props, true)
})
);
}
});
{ // alipay 重复定义props会报错,下边的代码对于其他平台也没有意义,保险起见,仅对alipay做处理
return
}
return behaviors
}
function parsePropType (key, type, defaultValue, file) {
......@@ -2069,20 +2084,6 @@ function initRefs () {
}
function initBehavior ({
properties
}) {
const props = {};
Object.keys(properties).forEach(key => {
props[key] = properties[key].value;
});
return {
props
}
}
function initRelation (detail) {
this.props.onVueInit(detail);
}
......@@ -2393,7 +2394,7 @@ function parsePage (vuePageOptions) {
const [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions);
const pageOptions = {
mixins: initBehaviors(vueOptions, initBehavior),
mixins: initBehaviors(vueOptions),
data: initData(vueOptions, Vue.prototype),
onLoad (query) {
const properties = this.props;
......@@ -2531,7 +2532,7 @@ function parseComponent (vueComponentOptions) {
});
const componentOptions = {
mixins: initBehaviors(vueOptions, initBehavior),
mixins: initBehaviors(vueOptions),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
......
import { v4 } from 'uuid';
import Vue from 'vue';
const _toString = Object.prototype.toString;
......@@ -231,7 +232,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -527,6 +528,39 @@ var previewImage = {
}
};
const UUID_KEY = '__DC_UUID';
let uuid;
function addUuid (result) {
uuid = uuid || swan.getStorageSync(UUID_KEY);
if (!uuid) {
uuid = v4();
swan.setStorage({
key: UUID_KEY,
data: uuid
});
}
result.uuid = uuid;
}
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
var getSystemInfo = {
returnValue: function (result) {
addUuid(result);
addSafeAreaInsets(result);
}
};
// 不支持的 API 列表
const todos = [
'preloadPage',
......@@ -611,6 +645,8 @@ const protocols = {
navigateTo,
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
getRecorderManager: {
returnValue (fromRet) {
fromRet.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded');
......@@ -1995,11 +2031,6 @@ function parsePage (vuePageOptions) {
initRelation
});
const onInit = (vuePageOptions.default || vuePageOptions).onInit;
if (onInit) {
pageOptions.methods.onInit = onInit;
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions.methods.onShow = function onShow () {
if (this.$vm && this.$vm.$mp.query) {
......
import { v4 } from 'uuid';
import Vue from 'vue';
const _toString = Object.prototype.toString;
......@@ -231,7 +232,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -527,10 +528,45 @@ var previewImage = {
}
};
const UUID_KEY = '__DC_UUID';
let uuid;
function addUuid (result) {
uuid = uuid || ks.getStorageSync(UUID_KEY);
if (!uuid) {
uuid = v4();
ks.setStorage({
key: UUID_KEY,
data: uuid
});
}
result.uuid = uuid;
}
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
var getSystemInfo = {
returnValue: function (result) {
addUuid(result);
addSafeAreaInsets(result);
}
};
const protocols = {
navigateTo,
redirectTo,
previewImage
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo
};
const todos = [
'vibrate'
......
......@@ -232,7 +232,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......
import { v4 } from 'uuid';
import Vue from 'vue';
const _toString = Object.prototype.toString;
......@@ -231,7 +232,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -527,6 +528,39 @@ var previewImage = {
}
};
const UUID_KEY = '__DC_UUID';
let uuid;
function addUuid (result) {
uuid = uuid || tt.getStorageSync(UUID_KEY);
if (!uuid) {
uuid = v4();
tt.setStorage({
key: UUID_KEY,
data: uuid
});
}
result.uuid = uuid;
}
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
var getSystemInfo = {
returnValue: function (result) {
addUuid(result);
addSafeAreaInsets(result);
}
};
// 不支持的 API 列表
const todos = [
'preloadPage',
......@@ -629,6 +663,8 @@ const protocols = {
navigateTo,
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
connectSocket: {
args: {
method: false
......
import { v4 } from 'uuid';
import Vue from 'vue';
const _toString = Object.prototype.toString;
......@@ -231,7 +232,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -422,29 +423,47 @@ var previewImage = {
}
};
const UUID_KEY = '__DC_UUID';
let uuid;
function addUuid (result) {
uuid = uuid || wx.getStorageSync(UUID_KEY);
if (!uuid) {
uuid = v4();
wx.setStorage({
key: UUID_KEY,
data: uuid
});
}
result.uuid = uuid;
}
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
var getSystemInfo = {
returnValue: function (result) {
addUuid(result);
addSafeAreaInsets(result);
}
};
// import navigateTo from 'uni-helpers/navigate-to'
function addSafeAreaInsets (result) {
if (result.safeArea) {
const safeArea = result.safeArea;
result.safeAreaInsets = {
top: safeArea.top,
left: safeArea.left,
right: result.windowWidth - safeArea.right,
bottom: result.windowHeight - safeArea.bottom
};
}
}
const protocols = {
redirectTo,
// navigateTo, // 由于在微信开发者工具的页面参数,会显示__id__参数,因此暂时关闭mp-weixin对于navigateTo的AOP
previewImage,
getSystemInfo: {
returnValue: addSafeAreaInsets
},
getSystemInfoSync: {
returnValue: addSafeAreaInsets
}
getSystemInfo,
getSystemInfoSync: getSystemInfo
};
const todos = [
'vibrate',
......
......@@ -231,7 +231,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|Window$|WindowStyle$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册