提交 94b234c9 编写于 作者: Q qiang

Merge branch 'dev'

......@@ -6,7 +6,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
......
src/core/helpers/html-parser.js
\ No newline at end of file
src/core/helpers/html-parser.js
src/platforms/app-plus-nvue/runtime
build/rollup-plugin-require-context
packages/*/packages
node_modules/
.project
unpackage/
.vscode/
\ No newline at end of file
.vscode/
.DS_Store
module.exports = {
ignore: [
"./packages",
],
presets: [
["@vue/app", {
useBuiltIns: "entry"
}]
]
const config = {
ignore: [
"./packages",
],
presets: [
["@vue/app", {
useBuiltIns: "entry"
}]
],
plugins: [require('./lib/babel-plugin-uni-api/index.js')]
}
if (process.env.NODE_ENV === 'test') {
delete config.ignore
}
module.exports = config
......@@ -9,9 +9,15 @@ const copy = require('copy')
const path = require('path')
const jsonfile = require('jsonfile')
const {
generateApiManifest
} = require('./manifest')
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd(), {
inlineOptions: require('./vue.config.js')
})
// 删除 cache 目录
del.sync(['node_modules/.cache'])
service.run('build', {
name: 'index',
......@@ -19,6 +25,11 @@ service.run('build', {
target: 'lib',
formats: process.env.UNI_WATCH === 'true' ? 'umd' : 'umd-min',
entry: './lib/' + process.env.UNI_PLATFORM + '/main.js'
}).then(function () {
generateApiManifest(
JSON.parse(JSON.stringify(process.UNI_SERVICE_API_MANIFEST)),
JSON.parse(JSON.stringify(process.UNI_SERVICE_API_PROTOCOL))
)
}).catch(err => {
error(err)
process.exit(1)
......@@ -44,9 +55,11 @@ if (process.env.UNI_WATCH === 'false') {
})
})
.then(obj => {
return jsonfile.writeFile(packageJsonPath, obj, { spaces: 2 })
return jsonfile.writeFile(packageJsonPath, obj, {
spaces: 2
})
})
.catch(err => {
throw err
})
}
}
const fs = require('fs')
const path = require('path')
const apis = require('../lib/apis')
const AUTO_LOADS = [
'upx2px',
'canIUse',
'getSystemInfo',
'getSystemInfoSync',
'navigateTo',
'redirectTo',
'switchTab',
'reLaunch',
'navigateBack'
]
const TOAST_DEPS = [
['/platforms/h5/components/app/popup/toast.vue', 'Toast'],
['/platforms/h5/components/app/popup/mixins/toast.js', 'ToastMixin']
]
// TODO 暂不考虑 head,tabBar 的动态拆分
const DEPS = {
'chooseLocation': [
['/platforms/h5/components/system-routes/choose-location/index.vue', 'ChooseLocation']
],
'openLocation': [
['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation']
],
'previewImage': [
['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage']
],
'showToast': TOAST_DEPS,
'hideToast': TOAST_DEPS,
'showLoading': TOAST_DEPS,
'hideLoading': TOAST_DEPS,
'showModal': [
['/platforms/h5/components/app/popup/modal.vue', 'Modal'],
['/platforms/h5/components/app/popup/mixins/modal.js', 'ModalMixin']
],
'showActionSheet': [
['/platforms/h5/components/app/popup/actionSheet.vue', 'ActionSheet'],
['/platforms/h5/components/app/popup/mixins/action-sheet.js', 'ActionSheetMixin']
],
'createSelectorQuery': [
['/core/view/bridge/subscribe/api/request-component-info.js', 'requestComponentInfo']
],
'createIntersectionObserver': [
['/core/view/bridge/subscribe/api/request-component-observer.js', 'requestComponentObserver'],
['/core/view/bridge/subscribe/api/request-component-observer.js', 'destroyComponentObserver']
]
}
// 检查依赖文件是否存在
Object.keys(DEPS).reduce(function (depFiles, name) {
DEPS[name].forEach(function (dep) {
depFiles.add(dep[0])
})
return depFiles
}, new Set()).forEach(file => {
if (!fs.existsSync(path.join(__dirname, '../src', file))) {
console.error(file + ' 不存在')
process.exit(0)
}
})
function parseApiManifestDeps (manifest, protocol) {
// 解析 platform 依赖
Object.keys(manifest).forEach(name => {
const deps = manifest[name][1]
if (deps.length) {
deps.forEach(dep => {
if (manifest[dep[1]]) {
dep[0] = manifest[dep[1]][0]
} else {
console.error(`依赖模块[${dep[1]}]不存在,删除 ${name} 接口\n`)
delete manifest[name]
}
})
}
})
// 解析 protocol 依赖
Object.keys(manifest).forEach(name => {
const deps = manifest[name][1]
if (protocol[name]) {
deps.push([protocol[name], name])
} else {
console.warn(`${name} 缺少 protocol`)
}
})
// 追加默认依赖
Object.keys(DEPS).forEach(name => {
if (manifest[name]) {
manifest[name][1].push(...DEPS[name])
} else {
console.error(`缺少 ${name}`)
}
})
// 设置自动加载标记
AUTO_LOADS.forEach(name => {
if (manifest[name]) {
manifest[name][2] = true
} else {
console.error(`缺少 ${name}`)
}
})
}
module.exports = {
generateApiManifest (manifest, protocol) {
if (!Object.keys(manifest).length) {
throw new Error('api manifest.json 生成失败')
}
parseApiManifestDeps(manifest, protocol)
const manifestJson = Object.create(null)
const todoApis = []
apis.forEach(name => {
if (manifest[name]) {
manifestJson[name] = manifest[name]
} else {
todoApis.push(name)
}
})
if (todoApis.length) {
console.log('\n')
console.warn(`${process.env.UNI_PLATFORM} 平台缺少以下 API 实现(共 ${todoApis.length} 个)`)
todoApis.forEach(name => {
console.warn(name)
})
}
fs.writeFileSync(path.resolve(__dirname, '../packages/uni-' + process.env.UNI_PLATFORM + '/manifest.json'),
JSON.stringify(manifestJson, null, 4)
)
}
}
const path = require('path')
const alias = require('rollup-plugin-alias')
const replace = require('rollup-plugin-replace')
const nodeResolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const requireContext = require('../lib/rollup-plugin-require-context')
let input = 'src/platforms/app-plus/service/framework/create-instance-context.js'
const output = {
file: 'packages/uni-app-plus-nvue/dist/index.js',
format: 'es'
}
const external = []
if (process.env.UNI_SERVICE === 'legacy') {
input = 'src/platforms/app-plus-nvue/services/index.legacy.js'
output.file = 'packages/uni-app-plus-nvue/dist/index.legacy.js'
} else {
input = 'src/platforms/app-plus/service/index.js'
output.file = 'packages/uni-app-plus-nvue/dist/index.js'
output.format = 'iife'
output.name = 'serviceContext'
output.banner =
`export function createServiceContext(Vue, weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge,instanceContext){
var localStorage = plus.storage
var setTimeout = instanceContext.setTimeout
var clearTimeout = instanceContext.clearTimeout
var setInterval = instanceContext.setInterval
var clearInterval = instanceContext.clearInterval
`
output.footer =
`
var uni = serviceContext.uni
var getApp = serviceContext.getApp
var getCurrentPages = serviceContext.getCurrentPages
var __registerPage = serviceContext.__registerPage
return serviceContext \n}
`
}
const resolve = dir => path.resolve(__dirname, '../', dir)
module.exports = {
input,
output,
plugins: [
nodeResolve(),
commonjs(),
requireContext(),
alias({
'uni-core': resolve('src/core'),
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM),
'uni-platforms': resolve('src/platforms'),
'uni-shared': resolve('src/shared/index.js'),
'uni-helpers': resolve('src/core/helpers'),
'uni-invoke-api': resolve('src/platforms/app-plus/service/api'),
'uni-service-api': resolve('src/core/service/platform-api'),
'uni-api-protocol': resolve('src/core/helpers/protocol')
}),
replace({
__GLOBAL__: 'getGlobalUni()',
__PLATFORM__: JSON.stringify('app-plus'),
__PLATFORM_TITLE__: 'app-plus-nvue'
})
],
external
}
......@@ -6,10 +6,10 @@ const PLATFORMS = {
'mp-weixin': {
prefix: 'wx',
title: '微信小程序'
},
'mp-qq': {
prefix: 'wx',
title: 'QQ小程序'
},
'mp-qq': {
prefix: 'wx',
title: 'QQ小程序'
},
'mp-alipay': {
prefix: 'my',
......@@ -40,8 +40,8 @@ module.exports = {
plugins: [
alias({
'uni-shared': path.resolve(__dirname, '../src/shared/util.js'),
'uni-platform': path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM),
'uni-wrapper': path.resolve(__dirname, '../src/core/runtime/wrapper'),
'uni-platform': path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM),
'uni-wrapper': path.resolve(__dirname, '../src/core/runtime/wrapper'),
'uni-helpers': path.resolve(__dirname, '../src/core/helpers')
}),
replace({
......
const path = require('path')
const alias = require('rollup-plugin-alias')
const replace = require('rollup-plugin-replace')
module.exports = {
input: 'src/platforms/app-plus-nvue/services/index.legacy.js',
output: {
file: `packages/uni-app-plus-nvue/dist/service.legacy.js`,
format: 'es'
},
plugins: [
alias({
'uni-core': path.resolve(__dirname, '../src/core'),
'uni-shared': path.resolve(__dirname, '../src/shared/util.js')
}),
replace({
__GLOBAL__: 'getGlobalUni()',
__PLATFORM_TITLE__: 'app-plus-nvue'
})
]
}
module.exports = {
input: 'packages/uni-stat/src/index.js',
output: {
file: 'packages/uni-stat/dist/index.js',
format: 'es'
},
external: ['vue', '../package.json'],
plugins: []
}
......@@ -29,7 +29,16 @@ module.exports = {
'uni-mixins': resolve('src/core/view/mixins'),
'uni-helpers': resolve('src/core/helpers'),
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM),
'uni-components': resolve('src/core/view/components')
// tree shaking
'uni-components': resolve('src/core/view/components'),
'uni-invoke-api': resolve('src/platforms/' + process.env.UNI_PLATFORM + '/service/api'),
'uni-service-api': resolve('src/core/service/platform-api'),
'uni-api-protocol': resolve('src/core/helpers/protocol'),
'uni-api-subscribe': resolve('src/core/view/bridge/subscribe/api/index'),
// h5 components
'uni-h5-app-components': resolve('src/platforms/h5/components/app/popup/index'),
'uni-h5-app-mixins': resolve('src/platforms/h5/components/app/popup/mixins/index'),
'uni-h5-system-routes': resolve('src/platforms/h5/components/system-routes/index')
}
},
module: {
......@@ -42,8 +51,8 @@ module.exports = {
}),
new webpack.ProvidePlugin({
'console': [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge')],
'UniServiceJSBridge': [resolve('src/core/service/bridge')]
'UniViewJSBridge': [resolve('src/core/view/bridge/index')],
'UniServiceJSBridge': [resolve('src/core/service/bridge/index')]
})
]
}
......@@ -23,7 +23,16 @@ config.resolve.alias = {
'uni-mixins': resolve('src/core/view/mixins'),
'uni-helpers': resolve('src/core/helpers'),
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM),
'uni-components': resolve('src/core/view/components')
// tree shaking
'uni-components': resolve('src/core/view/components'),
'uni-invoke-api': resolve('src/platforms/' + process.env.UNI_PLATFORM + '/service/api'),
'uni-service-api': resolve('src/core/service/platform-api'),
'uni-api-protocol': resolve('src/core/helpers/protocol'),
'uni-api-subscribe': resolve('src/core/view/bridge/subscribe/api/index'),
// h5 components
'uni-h5-app-components': resolve('src/platforms/h5/components/app/popup/index'),
'uni-h5-app-mixins': resolve('src/platforms/h5/components/app/popup/mixins/index'),
'uni-h5-system-routes': resolve('src/platforms/h5/components/system-routes/index')
}
const isEslintLoader = config.module.rules[config.module.rules.length - 1].enforce
......@@ -41,8 +50,8 @@ config.plugins = config.plugins.concat([
}),
new webpack.ProvidePlugin({
'console': [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge')],
'UniServiceJSBridge': [resolve('src/core/service/bridge')]
'UniViewJSBridge': [resolve('src/core/view/bridge/index')],
'UniServiceJSBridge': [resolve('src/core/service/bridge/index')]
})
])
module.exports = config
#### uni.hideKeyboard()
隐藏软键盘
#### uni.hideKeyboard()
隐藏软键盘
隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。
**平台差异说明**
|5+App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|
|√|√|√|√|x|√|
|5+App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|√|√|√|√|x|√|√|
隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。
#### uni.onKeyboardHeightChange(CALLBACK)
监听键盘高度变化
**平台差异说明**
|5+App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|HBuilderX 2.2.2+|x|基础库2.7+|x|x|x|√|
**CALLBACK 返回参数**
|参数|类型|说明|
|:-|:-|:-|
|height|Number|键盘高度|
**示例代码**
```js
uni.onKeyboardHeightChange(res => {
console.log(res.height)
})
```
......@@ -4,9 +4,11 @@
**平台差异说明**
|5+App|H5|微信小程序|支付宝小程序|百度小程序|
|:-:|:-:|:-:|:-:|:-:|
|√|x|√|√|√|
|5+App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|√|√|√|√|√|√|√|
**Tips**
* 由于 icon 组件各端表现存在差异,可以通过使用 [字体图标](/frame?id=字体图标) 的方式来弥补各端差异。
......@@ -22,8 +24,7 @@
|平台|type 有效值|
|:-:|:-:|
|5+App|success, success_no_circle, info, warn, waiting, cancel, download, search, clear|
|微信小程序|success, success_no_circle, info, warn, waiting, cancel, download, search, clear|
|5+App、H5、微信小程序、QQ小程序|success, success_no_circle, info, warn, waiting, cancel, download, search, clear|
|支付宝小程序|info, warn, waiting, cancel, download, search, clear, success, success_no_circle,loading|
|百度小程序|success, info, warn, waiting, success_no_circle, clear, search, personal, setting, top, close, cancel, download, checkboxSelected, radioSelected, radioUnselect|
......
module.exports = {
globals: {
__DEV__: true
},
coverageDirectory: 'coverage',
coverageReporters: ['html', 'lcov', 'text'],
collectCoverageFrom: ['packages/*/src/**/*.js'],
moduleFileExtensions: ['js', 'json'],
moduleNameMapper: {
'^@dcloudio/(.*?)$': '<rootDir>/packages/$1/src'
},
rootDir: __dirname,
testMatch: ['<rootDir>/packages/**/__tests__/**/*spec.(t|j)s']
}
{
"npmClient": "yarn",
"useWorkspaces": false,
"packages": [
"packages/*"
],
"publishConfig": {
"access": "public"
},
"command": {
"publish": {
"message": "chore(release): publish %s"
}
},
"version": "1.0.0-alpha-22120190814002"
}
const base = [
'base64ToArrayBuffer',
'arrayBufferToBase64',
'addInterceptor',
'removeInterceptor'
]
const network = [
'request',
'uploadFile',
'downloadFile',
'connectSocket',
'onSocketOpen',
'onSocketError',
'sendSocketMessage',
'onSocketMessage',
'closeSocket',
'onSocketClose'
]
const route = [
'navigateTo',
'redirectTo',
'reLaunch',
'switchTab',
'navigateBack'
]
const storage = [
'setStorage',
'setStorageSync',
'getStorage',
'getStorageSync',
'getStorageInfo',
'getStorageInfoSync',
'removeStorage',
'removeStorageSync',
'clearStorage',
'clearStorageSync'
]
const location = [
'getLocation',
'chooseLocation',
'openLocation',
'createMapContext'
]
const media = [
'chooseImage',
'previewImage',
'getImageInfo',
'saveImageToPhotosAlbum',
'compressImage',
'getRecorderManager',
'getBackgroundAudioManager',
'createInnerAudioContext',
'chooseVideo',
'saveVideoToPhotosAlbum',
'createVideoContext',
'createCameraContext',
'createLivePlayerContext'
]
const device = [
'getSystemInfo',
'getSystemInfoSync',
'canIUse',
'onMemoryWarning',
'getNetworkType',
'onNetworkStatusChange',
'onAccelerometerChange',
'startAccelerometer',
'stopAccelerometer',
'onCompassChange',
'startCompass',
'stopCompass',
'onGyroscopeChange',
'startGyroscope',
'stopGyroscope',
'makePhoneCall',
'scanCode',
'setClipboardData',
'getClipboardData',
'setScreenBrightness',
'getScreenBrightness',
'setKeepScreenOn',
'onUserCaptureScreen',
'vibrateLong',
'vibrateShort',
'addPhoneContact',
'openBluetoothAdapter',
'startBluetoothDevicesDiscovery',
'onBluetoothDeviceFound',
'stopBluetoothDevicesDiscovery',
'onBluetoothAdapterStateChange',
'getConnectedBluetoothDevices',
'getBluetoothDevices',
'getBluetoothAdapterState',
'closeBluetoothAdapter',
'writeBLECharacteristicValue',
'readBLECharacteristicValue',
'onBLEConnectionStateChange',
'onBLECharacteristicValueChange',
'notifyBLECharacteristicValueChange',
'getBLEDeviceServices',
'getBLEDeviceCharacteristics',
'createBLEConnection',
'closeBLEConnection',
'onBeaconServiceChange',
'onBeaconUpdate',
'getBeacons',
'startBeaconDiscovery',
'stopBeaconDiscovery'
]
const keyboard = [
'hideKeyboard',
'onKeyboardHeightChange'
]
const ui = [
'showToast',
'hideToast',
'showLoading',
'hideLoading',
'showModal',
'showActionSheet',
'setNavigationBarTitle',
'setNavigationBarColor',
'showNavigationBarLoading',
'hideNavigationBarLoading',
'setTabBarItem',
'setTabBarStyle',
'hideTabBar',
'showTabBar',
'setTabBarBadge',
'removeTabBarBadge',
'showTabBarRedDot',
'hideTabBarRedDot',
'setBackgroundColor',
'setBackgroundTextStyle',
'createAnimation',
'pageScrollTo',
'onWindowResize',
'offWindowResize',
'loadFontFace',
'startPullDownRefresh',
'stopPullDownRefresh',
'createSelectorQuery',
'createIntersectionObserver'
]
const event = [
'$emit',
'$on',
'$once',
'$off'
]
const file = [
'saveFile',
'getSavedFileList',
'getSavedFileInfo',
'removeSavedFile',
'getFileInfo',
'openDocument',
'getFileSystemManager'
]
const canvas = [
'createOffscreenCanvas',
'createCanvasContext',
'canvasToTempFilePath',
'canvasPutImageData',
'canvasGetImageData'
]
const third = [
'getProvider',
'login',
'checkSession',
'getUserInfo',
'share',
'showShareMenu',
'hideShareMenu',
'requestPayment',
'subscribePush',
'unsubscribePush',
'onPush',
'offPush',
'requireNativePlugin',
'upx2px'
]
const apis = [
...base,
...network,
...route,
...storage,
...location,
...media,
...device,
...keyboard,
...ui,
...event,
...file,
...canvas,
...third
]
module.exports = apis
const path = require('path')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
function resolve(...args) {
return normalizePath(path.resolve.apply(path, [__dirname, ...args]))
}
const srcPath = resolve('../../src/')
const protocolPath = resolve('../../src/core/helpers/protocol')
const coreApiPath = resolve('../../src/core/service/api')
const platformApiPath = resolve('../../src/platforms/' + process.env.UNI_PLATFORM + '/service/api')
const apis = require('../apis')
process.UNI_SERVICE_API_MANIFEST = Object.create(null)
process.UNI_SERVICE_API_PROTOCOL = Object.create(null)
function parseProtocolExport({
file,
exports
}) {
const filepath = file.replace(srcPath, '')
exports.forEach(exportName => {
if (process.UNI_SERVICE_API_PROTOCOL[exportName]) {
console.warn(`API[${exportName}] 冲突:`)
console.warn(process.UNI_SERVICE_API_PROTOCOL[exportName])
console.warn(filepath)
} else {
process.UNI_SERVICE_API_PROTOCOL[exportName] = filepath
}
})
}
function parseApiExport({
file,
methods,
exports,
isPlatform
}) {
const deps = []
methods && methods.forEach(method => {
deps.push(['', method])
})
const filepath = file.replace(srcPath, '')
exports.forEach(exportName => {
if (process.UNI_SERVICE_API_MANIFEST[exportName]) {
console.warn('\n')
console.warn(`API[${exportName}] 冲突:`)
console.warn(process.UNI_SERVICE_API_MANIFEST[exportName][0])
console.warn(filepath)
if (isPlatform) { // 优先使用 platform
process.UNI_SERVICE_API_MANIFEST[exportName] = [filepath, deps]
console.warn(`优先使用` + filepath)
}
} else {
process.UNI_SERVICE_API_MANIFEST[exportName] = [filepath, deps]
}
})
}
function parseExports(node, t, file) {
if (t.isFunctionDeclaration(node)) {
return [node.id.name]
} else if (
t.isVariableDeclaration(node) &&
node.declarations.length === 1
) {
return [node.declarations[0].id.name]
} else if (Array.isArray(node) && node.length) {
return node.map(specifier => {
return specifier.exported.name
})
} else {
console.warn('\n')
console.warn(`${file} 解析 export 失败`, node)
}
}
module.exports = function({
types: t
}) {
return {
visitor: {
Program: {
enter(path, state) {
state.file.opts.file = normalizePath(state.file.opts.filename)
state.file.opts.isCore = state.file.opts.file.indexOf(coreApiPath) === 0
state.file.opts.isPlatform = state.file.opts.file.indexOf(platformApiPath) === 0
state.file.opts.isProtocol = state.file.opts.file.indexOf(protocolPath) === 0
},
exit(path, state) {
const {
exports,
isProtocol
} = state.file.opts
if (exports && exports.length) {
if (isProtocol) {
parseProtocolExport(state.file.opts)
} else {
parseApiExport(state.file.opts)
}
}
}
},
ExportNamedDeclaration(path, state) {
const {
file,
isCore,
isPlatform,
isProtocol
} = state.file.opts
if (isCore || isPlatform || isProtocol) {
const exports = parseExports(path.node.declaration || path.node.specifiers, t, file)
if (Array.isArray(exports)) {
(state.file.opts.exports || (state.file.opts.exports = [])).push(...exports)
}
}
},
CallExpression(path, state) {
const {
file,
isCore,
isPlatform
} = state.file.opts
if (
isCore &&
path.node.callee.name === 'invokeMethod'
) {
(state.file.opts.methods || (state.file.opts.methods = new Set())).add(path.node.arguments[0].value)
}
}
}
}
}
......@@ -17,7 +17,7 @@ const {
default: uni,
getApp,
getCurrentPages
} = require('uni-service')
} = require('uni-platform/service/index')
global.uni = uni
......
[{
"name": "base",
"title": "基础",
"apiList": {
"uni.getSystemInfo": true,
"uni.getSystemInfoSync": true,
"uni.canIUse": true,
"uni.upx2px": true,
"uni.navigateTo": true,
"uni.redirectTo": true,
"uni.switchTab": true,
"uni.reLaunch": true,
"uni.navigateBack": true
}
}, {
"name": "network",
"title": "网络",
"apiList": {
"uni.request": true,
"uni.connectSocket": true,
"uni.sendSocketMessage": true,
"uni.closeSocket": true,
"uni.onSocketOpen": true,
"uni.onSocketError": true,
"uni.onSocketMessage": true,
"uni.onSocketClose": true,
"uni.downloadFile": true,
"uni.uploadFile": true
}
}, {
"name": "storage",
"title": "数据缓存",
"apiList": {
"uni.setStorage": true,
"uni.setStorageSync": true,
"uni.getStorage": true,
"uni.getStorageSync": true,
"uni.removeStorage": true,
"uni.removeStorageSync": true,
"uni.clearStorage": true,
"uni.clearStorageSync": true,
"uni.getStorageInfo": true,
"uni.getStorageInfoSync": true
}
}, {
"name": "location",
"title": "位置",
"apiList": {
"uni.getLocation": true,
"uni.openLocation": true,
"uni.chooseLocation": true
}
}, {
"name": "media",
"title": "媒体",
"apiList": {
"uni.chooseImage": true,
"uni.previewImage": true,
"uni.getImageInfo": true,
"uni.saveImageToPhotosAlbum": true,
"uni.compressImage": true,
"uni.getRecorderManager": true,
"uni.getBackgroundAudioManager": true,
"uni.createInnerAudioContext": true,
"uni.chooseVideo": true,
"uni.saveVideoToPhotosAlbum": true,
"uni.createVideoContext": true,
"uni.createCameraContext": true,
"uni.createLivePlayerContext": true
}
}, {
"name": "device",
"title": "设备",
"apiList": {
"uni.onMemoryWarning": true,
"uni.getNetworkType": true,
"uni.onNetworkStatusChange": true,
"uni.onAccelerometerChange": true,
"uni.startAccelerometer": true,
"uni.stopAccelerometer": true,
"uni.onCompassChange": true,
"uni.startCompass": true,
"uni.stopCompass": true,
"uni.onGyroscopeChange": true,
"uni.startGyroscope": true,
"uni.stopGyroscope": true,
"uni.makePhoneCall": true,
"uni.scanCode": true,
"uni.setClipboardData": true,
"uni.getClipboardData": true,
"uni.setScreenBrightness": true,
"uni.getScreenBrightness": true,
"uni.setKeepScreenOn": true,
"uni.onUserCaptureScreen": true,
"uni.vibrateLong": true,
"uni.vibrateShort": true,
"uni.addPhoneContact": true,
"uni.openBluetoothAdapter": true,
"uni.startBluetoothDevicesDiscovery": true,
"uni.onBluetoothDeviceFound": true,
"uni.stopBluetoothDevicesDiscovery": true,
"uni.onBluetoothAdapterStateChange": true,
"uni.getConnectedBluetoothDevices": true,
"uni.getBluetoothDevices": true,
"uni.getBluetoothAdapterState": true,
"uni.closeBluetoothAdapter": true,
"uni.writeBLECharacteristicValue": true,
"uni.readBLECharacteristicValue": true,
"uni.onBLEConnectionStateChange": true,
"uni.onBLECharacteristicValueChange": true,
"uni.notifyBLECharacteristicValueChange": true,
"uni.getBLEDeviceServices": true,
"uni.getBLEDeviceCharacteristics": true,
"uni.createBLEConnection": true,
"uni.closeBLEConnection": true,
"uni.onBeaconServiceChange": true,
"uni.onBeaconUpdate": true,
"uni.getBeacons": true,
"uni.startBeaconDiscovery": true,
"uni.stopBeaconDiscovery": true
}
}, {
"name": "ui",
"title": "界面",
"apiList": {
"uni.showToast": true,
"uni.hideToast": true,
"uni.showLoading": true,
"uni.hideLoading": true,
"uni.showModal": true,
"uni.showActionSheet": true,
"uni.setNavigationBarTitle": true,
"uni.setNavigationBarColor": true,
"uni.showNavigationBarLoading": true,
"uni.hideNavigationBarLoading": true,
"uni.setTabBarItem": true,
"uni.setTabBarStyle": true,
"uni.hideTabBar": true,
"uni.showTabBar": true,
"uni.setTabBarBadge": true,
"uni.removeTabBarBadge": true,
"uni.showTabBarRedDot": true,
"uni.hideTabBarRedDot": true,
"uni.setBackgroundColor": true,
"uni.setBackgroundTextStyle": true,
"uni.createAnimation": true,
"uni.pageScrollTo": true,
"uni.onWindowResize": true,
"uni.offWindowResize": true,
"uni.loadFontFace": true,
"uni.startPullDownRefresh": true,
"uni.stopPullDownRefresh": true,
"uni.createSelectorQuery": true,
"uni.createIntersectionObserver": true,
"uni.hideKeyboard": true,
"uni.onKeyboardHeightChange": true
}
}, {
"name": "event",
"title": "页面通讯",
"apiList": {
"uni.$emit": true,
"uni.$on": true,
"uni.$once": true,
"uni.$off": true
}
}, {
"name": "file",
"title": "文件",
"apiList": {
"uni.saveFile": true,
"uni.getSavedFileList": true,
"uni.getSavedFileInfo": true,
"uni.removeSavedFile": true,
"uni.getFileInfo": true,
"uni.openDocument": true,
"uni.getFileSystemManager": true
}
}, {
"name": "canvas",
"title": "绘画",
"apiList": {
"uni.createOffscreenCanvas": true,
"uni.createCanvasContext": true,
"uni.canvasToTempFilePath": true,
"uni.canvasPutImageData": true,
"uni.canvasGetImageData": true
}
}, {
"name": "third",
"title": "第三方服务",
"apiList": {
"uni.getProvider": true,
"uni.login": true,
"uni.checkSession": true,
"uni.getUserInfo": true,
"uni.share": true,
"uni.showShareMenu": true,
"uni.hideShareMenu": true,
"uni.requestPayment": true,
"uni.subscribePush": true,
"uni.unsubscribePush": true,
"uni.onPush": true,
"uni.offPush": true,
"uni.requireNativePlugin": true,
"uni.base64ToArrayBuffer": true,
"uni.arrayBufferToBase64": true
}
}]
# rollup-plugin-require-context
rollup plugin for resovling webpack require-context.
## usage
```javascript
import requireContext from 'rollup-plugin-require-context';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife'
},
plugins: [
requireContext()
]
};
```
{
"name": "rollup-plugin-require-context",
"version": "1.0.0",
"description": "rollup-plugin for webpack requrie-context",
"main": "src/index.js",
"scripts": {
"brk": "node --inspect-brk example/run.js",
"example": "rollup -c example/rollup.config.js",
"test:dev": "jest --watchAll"
},
"repository": {
"type": "git",
"url": "git+https://github.com/elcarim5efil/rollup-plugin-require-context.git"
},
"keywords": [
"rollup",
"plugin",
"require-context",
"webpack-context"
],
"author": "elcarim5efil",
"license": "MIT",
"bugs": {
"url": "https://github.com/elcarim5efil/rollup-plugin-require-context/issues"
},
"homepage": "https://github.com/elcarim5efil/rollup-plugin-require-context#readme",
"dependencies": {
"acorn": "^6.1.1",
"acorn-dynamic-import": "^4.0.0",
"acorn-walk": "^6.1.1",
"rollup-pluginutils": "^2.5.0"
},
"devDependencies": {
"jest": "^24.5.0",
"rollup": "^1.7.4",
"rollup-plugin-virtual": "^1.0.1"
}
}
const Path = require('path')
const { parse } = require('acorn')
const walk = require('acorn-walk')
function stripHeadAndTailChar (str) {
return str.substring(1, str.length - 1)
}
function extract (code) {
return new Promise((resolve, reject) => {
const ast = parse(code, {
sourceType: 'module'
})
const res = []
walk.simple(ast, {
CallExpression (node) {
const {
start,
end,
callee,
arguments: argNodes
} = node
let args = []
if (
callee.type === 'MemberExpression' &&
callee.object.name === 'require' &&
callee.property.name === 'context'
) {
args = argNodes.map(a => a.value)
res.push({
start,
end,
args
})
}
}
})
resolve(res)
})
}
module.exports = async function extractArgs (code, baseDirname) {
const data = await extract(code)
return data.map(r => {
const { start, end, args } = r
const [
rawDirname = '',
rawRecursive,
rawRegexp
] = args
const dirname = Path.join(baseDirname, rawDirname)
const recursive = rawRecursive
const regexp = rawRegexp
return {
dirname,
recursive,
regexp,
start,
end
}
})
}
const Path = require('path')
const extractArgs = require('./extract-args')
const resolveRequireModules = require('./resolve-reqquire-modules')
const resolveRequireCode = require('./resolve-require-code')
module.exports = async function gernerateRequireContextCode (id, code) {
const currentCodeDirname = Path.dirname(id)
const data = await extractArgs(code, currentCodeDirname)
let head = ''
const body = data.reduceRight((res, r) => {
const {
start, end,
dirname, recursive, regexp
} = r
const modules = resolveRequireModules(dirname, recursive, regexp)
const moduleCode = resolveRequireCode(dirname, modules)
const {
importCode,
requireFnCode
} = moduleCode
head += importCode
res = [
res.slice(0, start),
requireFnCode,
res.slice(end)
].join('')
return res
}, code)
return [
head,
body
].join('\n')
}
module.exports = function hasRequireContext (code) {
return /require\.context/g.test(code)
}
const fs = require('fs')
const Path = require('path')
function readDirRecursive (dir) {
return fs.statSync(dir).isDirectory()
? Array.prototype.concat(
...fs.readdirSync(dir).map(f => readDirRecursive(Path.join(dir, f)))
)
: dir
}
function readDir (dir, recursive) {
const isDirectory = fs.statSync(dir).isDirectory()
if (recursive) {
return readDirRecursive(dir)
} else if (isDirectory) {
const files = fs.readdirSync(dir)
if (files) {
return files.map(file => Path.resolve(dir, file))
}
} else {
return [ dir ]
}
}
module.exports = function resolveRequireModules (baseDirname = './', recursive = false, regexp = /^\.\//) {
let files = readDir(baseDirname, recursive)
if (!Array.isArray(files)) {
files = [files]
}
files = files.map(file => {
const fileAbsolutePath = `./${Path.relative(baseDirname, file)}`
return fileAbsolutePath
})
return files.filter(file => regexp.test(file.replace(/\\/g, '/')))
}
const Path = require('path')
let uid = 0
function getUID () {
return uid++
}
function genImportCode (name, path) {
return `import * as ${name} from '${path}';\n`
}
function genPropsCode (key, value) {
return `'${key}': ${value},\n`
}
module.exports = function genRequireCode (baseDirname, modules) {
const uid = getUID()
let importCode = ''
let moduleProps = ''
modules.forEach((file, index) => {
const moduleName = `require_context_module_${uid}_${index}`
const moduleAbsolutePath = Path.resolve(baseDirname, file).replace(/\\/g, '/')
importCode += genImportCode(moduleName, moduleAbsolutePath)
moduleProps += genPropsCode(file, moduleName)
})
const requireFnCode = (`
(function() {
var map = {
${moduleProps}
};
var req = function req(key) {
return map[key] || (function() { throw new Error("Cannot find module '" + key + "'.") }());
}
req.keys = function() {
return Object.keys(map);
}
return req;
})()
`)
return {
importCode,
requireFnCode
}
}
const _ = require('rollup-pluginutils')
const hasRequireContext = require('./helper/has-require-context')
const gernerateRequireContextCode = require('./helper/generate-require-context-code')
module.exports = function plugin (options = {}) {
const filter = _.createFilter(options.include || ['**/*.js'], options.exclude || 'node_modules/**')
return {
name: 'require_content',
async transform (code, id) {
if (!filter(id) || !hasRequireContext(code)) {
return
}
code = await gernerateRequireContextCode(id, code)
return code
}
}
}
{
"name": "uniapp-js-framework",
"version": "0.0.1",
"scripts": {
"lint": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore build src",
"dev:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js",
"build:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js",
"build:app-plus": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.js",
"build:service:legacy": "npm run lint && rollup -c build/rollup.config.service.js",
"build:mp-qq": "cross-env UNI_PLATFORM=mp-qq rollup -c build/rollup.config.js",
"build:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin rollup -c build/rollup.config.js",
"build:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu rollup -c build/rollup.config.js",
"build:mp-alipay": "cross-env UNI_PLATFORM=mp-alipay rollup -c build/rollup.config.js",
"build:mp-toutiao": "cross-env UNI_PLATFORM=mp-toutiao rollup -c build/rollup.config.js",
"build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:app-plus",
"test:unit": "cross-env NODE_ENV=test UNI_PLATFORM=h5 mocha-webpack --require tests/unit/setup.js --webpack-config build/webpack.config.test.js tests/unit/**/*.spec.js"
"name": "uniapp-js-framework",
"version": "0.0.1",
"scripts": {
"lint": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore build src",
"lint:cli": "eslint --fix --config package.json --ignore-path .eslintignore packages/uni-cli-shared packages/uni-template-compiler \"packages/vue-cli-*/**/*.js\" \"packages/webpack-uni-*/**/*.js\"",
"dev:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js",
"build:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js",
"build:app-plus": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.mp.js",
"build:app:all": "npm run lint && npm run build:app:nvue && npm run build:app:legacy",
"build:app:nvue": "cross-env UNI_PLATFORM=app-plus-nvue rollup -c build/rollup.config.app.js",
"build:app:legacy": "cross-env UNI_PLATFORM=app-plus-nvue UNI_SERVICE=legacy rollup -c build/rollup.config.app.js",
"build:mp-qq": "cross-env UNI_PLATFORM=mp-qq rollup -c build/rollup.config.mp.js",
"build:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin rollup -c build/rollup.config.mp.js",
"build:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu rollup -c build/rollup.config.mp.js",
"build:mp-alipay": "cross-env UNI_PLATFORM=mp-alipay rollup -c build/rollup.config.mp.js",
"build:mp-toutiao": "cross-env UNI_PLATFORM=mp-toutiao rollup -c build/rollup.config.mp.js",
"build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:app-plus",
"build:stat": "npm run lint && rollup -c build/rollup.config.stat.js",
"test:cli": "cross-env NODE_ENV=test jest",
"test:unit": "cross-env NODE_ENV=test UNI_PLATFORM=h5 mocha-webpack --require tests/unit/setup.js --webpack-config build/webpack.config.test.js tests/unit/**/*.spec.js",
"release": "npm run lint:cli && lerna publish --force-publish=*",
"release:alpha": "npm run lint:cli && lerna publish --force-publish=* --npm-tag=alpha"
},
"dependencies": {
"base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0"
},
"private": true,
"devDependencies": {
"@types/html5plus": "^1.0.0",
"@vue/cli-plugin-babel": "^3.4.1",
"@vue/cli-plugin-eslint": "^3.4.1",
"@vue/cli-plugin-unit-mocha": "^3.4.1",
"@vue/cli-service": "^3.4.1",
"@vue/test-utils": "^1.0.0-beta.25",
"babel-eslint": "^10.0.1",
"babylon": "^6.18.0",
"browserslist": "^4.4.2",
"caniuse-lite": "^1.0.30000940",
"chai": "^4.1.2",
"copy": "^0.3.2",
"cross-env": "^5.2.0",
"del": "^5.0.0",
"eslint": "^5.5.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^2.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^4.7.1",
"jest": "^24.9.0",
"jsdom": "^13.0.0",
"jsdom-global": "^3.0.2",
"jsonfile": "^5.0.0",
"rollup": "^1.17.0",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.1.0",
"strip-json-comments": "^2.0.1",
"vue": "^2.6.8",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.6.8",
"webpack": "^4.18.0",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-virtual-modules": "^0.1.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"dependencies": {
"base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0"
},
"private": true,
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.1",
"@vue/cli-plugin-eslint": "^3.4.1",
"@vue/cli-plugin-unit-mocha": "^3.4.1",
"@vue/cli-service": "^3.4.1",
"@vue/test-utils": "^1.0.0-beta.25",
"babel-eslint": "^10.0.1",
"babylon": "^6.18.0",
"browserslist": "^4.4.2",
"caniuse-lite": "^1.0.30000940",
"chai": "^4.1.2",
"copy": "^0.3.2",
"cross-env": "^5.2.0",
"del": "^5.0.0",
"eslint": "^5.5.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^2.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^4.7.1",
"jsdom": "^13.0.0",
"jsdom-global": "^3.0.2",
"jsonfile": "^5.0.0",
"rollup": "^0.67.4",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-replace": "^2.1.0",
"strip-json-comments": "^2.0.1",
"vue": "^2.6.8",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.6.8",
"webpack": "^4.18.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-virtual-modules": "^0.1.10"
"extends": [
"plugin:vue/recommended",
"standard"
],
"globals": {
"App": true,
"Page": true,
"Component": true,
"Behavior": true,
"getApp": true,
"getCurrentPages": true,
"plus": true,
"uni": true,
"Vue": true,
"wx": true,
"my": true,
"swan": true,
"weex": true,
"__id__": true,
"__uniConfig": true,
"__uniRoutes": true,
"__registerPage": true,
"UniViewJSBridge": true,
"UniServiceJSBridge": true,
"__PLATFORM__": true,
"__VERSION__": true,
"__GLOBAL__": true,
"__PLATFORM_TITLE__": true,
"__PLATFORM_PREFIX__": true,
"it": true,
"describe": true,
"expect": true
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/recommended",
"standard"
],
"globals": {
"App": true,
"Page": true,
"Component": true,
"Behavior": true,
"getApp": true,
"getCurrentPages": true,
"plus": true,
"uni": true,
"Vue": true,
"wx": true,
"my": true,
"swan": true,
"__uniConfig": true,
"__uniRoutes": true,
"UniViewJSBridge": true,
"UniServiceJSBridge": true,
"__PLATFORM__": true,
"__VERSION__": true,
"__GLOBAL__": true,
"__PLATFORM_TITLE__": true,
"__PLATFORM_PREFIX__": true
},
"rules": {
"no-tabs": 0,
"standard/no-callback-literal": 0
},
"parserOptions": {
"parser": "babel-eslint"
}
"rules": {
"no-tabs": 0,
"standard/no-callback-literal": 0
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
],
"license": "Apache-2.0",
"main": "index.js",
"description": "",
"author": ""
"parserOptions": {
"parser": "babel-eslint"
}
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
],
"license": "Apache-2.0",
"main": "index.js",
"description": "",
"author": ""
}
let supportsPassive = false;
try {
const opts = {};
Object.defineProperty(opts, 'passive', ({
get () {
/* istanbul ignore next */
supportsPassive = true;
}
})); // https://github.com/facebook/flow/issues/285
window.addEventListener('test-passive', null, opts);
} catch (e) {}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function isFn (fn) {
......@@ -8,7 +20,109 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
const SYNC_API_RE = /^\$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const globalInterceptors = {};
const scopedInterceptors = {};
function wrapperHook (hook) {
return function (data) {
return hook(data) || data
}
}
function isPromise (obj) {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'
}
function queue (hooks, data) {
let promise = false;
for (let i = 0; i < hooks.length; i++) {
const hook = hooks[i];
if (promise) {
promise = Promise.then(wrapperHook(hook));
} else {
const res = hook(data);
if (isPromise(res)) {
promise = Promise.resolve(res);
}
if (res === false) {
return {
then () {}
}
}
}
}
return promise || {
then (callback) {
return callback(data)
}
}
}
function wrapperOptions (interceptor, options = {}) {
['success', 'fail', 'complete'].forEach(name => {
if (Array.isArray(interceptor[name])) {
const oldCallback = options[name];
options[name] = function callbackInterceptor (res) {
queue(interceptor[name], res).then((res) => {
/* eslint-disable no-mixed-operators */
return isFn(oldCallback) && oldCallback(res) || res
});
};
}
});
return options
}
function wrapperReturnValue (method, returnValue) {
const returnValueHooks = [];
if (Array.isArray(globalInterceptors.returnValue)) {
returnValueHooks.push(...globalInterceptors.returnValue);
}
const interceptor = scopedInterceptors[method];
if (interceptor && Array.isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue
}
function getApiInterceptorHooks (method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
});
}
return interceptor
}
function invokeApi (method, api, options, ...params) {
const interceptor = getApiInterceptorHooks(method);
if (interceptor && Object.keys(interceptor).length) {
if (Array.isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params)
})
} else {
return api(wrapperOptions(interceptor, options), ...params)
}
}
return api(options, ...params)
}
const SYNC_API_RE =
/^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -35,8 +149,8 @@ function handlePromise (promise) {
function shouldPromise (name) {
if (
isContextApi(name) ||
isSyncApi(name) ||
isCallbackApi(name)
isSyncApi(name) ||
isCallbackApi(name)
) {
return false
}
......@@ -49,10 +163,10 @@ function promisify (name, api) {
}
return function promiseApi (options = {}, ...params) {
if (isFn(options.success) || isFn(options.fail) || isFn(options.complete)) {
return api(options, ...params)
return wrapperReturnValue(name, invokeApi(name, api, options, ...params))
}
return handlePromise(new Promise((resolve, reject) => {
api(Object.assign({}, options, {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
}), ...params);
......@@ -68,132 +182,27 @@ function promisify (name, api) {
)
};
}
}))
})))
}
}
const SUCCESS = 'success';
const FAIL = 'fail';
const COMPLETE = 'complete';
const CALLBACKS = [SUCCESS, FAIL, COMPLETE];
const UNIAPP_SERVICE_NVUE_ID = '__uniapp__service';
function noop$1 () {
}
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function invokeVmMethodWithoutArgs (vm, method, args, extras) {
if (!vm) {
return
}
if (typeof args === 'undefined') {
return vm[method]()
}
const [, callbacks] = normalizeArgs(args, extras);
if (!Object.keys(callbacks).length) {
return vm[method]()
}
return vm[method](normalizeCallback(method, callbacks))
}
/**
* 调用两个参数(第一个入参为普通参数,第二个入参为 callback) API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function invokeVmMethod (vm, method, args, extras) {
if (!vm) {
return
}
const [pureArgs, callbacks] = normalizeArgs(args, extras);
if (!Object.keys(callbacks).length) {
return vm[method](pureArgs)
}
return vm[method](pureArgs, normalizeCallback(method, callbacks))
}
function findRefById (id, vm) {
return findRefByVNode(id, vm._vnode)
}
function findRefByVNode (id, vnode) {
if (!id || !vnode) {
return
}
if (vnode.data &&
vnode.data.ref &&
vnode.data.attrs &&
vnode.data.attrs.id === id) {
return vnode.data.ref
}
const children = vnode.children;
if (!children) {
return
}
for (let i = 0, len = children.length; i < len; i++) {
const ref = findRefByVNode(id, children[i]);
if (ref) {
return ref
function initPostMessage (nvue) {
const plus = nvue.requireModule('plus');
return {
postMessage (data) {
plus.postMessage(data, UNIAPP_SERVICE_NVUE_ID);
}
}
}
function normalizeArgs (args = {}, extras) {
const callbacks = Object.create(null);
const iterator = function iterator (name) {
const callback = args[name];
if (isFn(callback)) {
callbacks[name] = callback;
delete args[name];
}
};
CALLBACKS.forEach(iterator);
extras && extras.forEach(iterator);
return [args, callbacks]
}
function normalizeCallback (method, callbacks) {
return function weexCallback (ret) {
const type = ret.type;
delete ret.type;
const callback = callbacks[type];
if (type === SUCCESS) {
ret.errMsg = `${method}:ok`;
} else if (type === FAIL) {
ret.errMsg = method + ':fail' + (ret.msg ? (' ' + ret.msg) : '');
}
delete ret.code;
delete ret.msg;
isFn(callback) && callback(ret);
if (type === SUCCESS || type === FAIL) {
const complete = callbacks['complete'];
isFn(complete) && complete(ret);
}
}
}
function initSubNVue (nvue, plus, BroadcastChannel) {
function initSubNVue (nvue, plus, BroadcastChannel) {
let origin;
const onMessageCallbacks = [];
const postMessage = nvue.requireModule('plus').postMessage;
const postMessage = nvue.requireModule('plus').postMessage;
const onSubNVueMessage = function onSubNVueMessage (data) {
onMessageCallbacks.forEach(callback => callback({
......@@ -278,14 +287,14 @@ function initSubNVue (nvue, plus, BroadcastChannel) {
closeMask();
return oldClose.apply(webview, args)
};
};
const getSubNVueById = function getSubNVueById (id) {
const webview = plus.webview.getWebviewById(id);
if (webview && !webview.$processed) {
wrapper(webview);
}
return webview
};
const getSubNVueById = function getSubNVueById (id) {
const webview = plus.webview.getWebviewById(id);
if (webview && !webview.$processed) {
wrapper(webview);
}
return webview
};
return {
......@@ -296,21 +305,14 @@ function initSubNVue (nvue, plus, BroadcastChannel) {
}
}
function initPostMessage (nvue) {
const plus = nvue.requireModule('plus');
return {
postMessage (data) {
plus.postMessage(data, UNIAPP_SERVICE_NVUE_ID);
}
}
}
function noop () {}
function initTitleNView (nvue) {
const eventMaps = {
onNavigationBarButtonTap: noop$1,
onNavigationBarSearchInputChanged: noop$1,
onNavigationBarSearchInputConfirmed: noop$1,
onNavigationBarSearchInputClicked: noop$1
onNavigationBarButtonTap: noop,
onNavigationBarSearchInputChanged: noop,
onNavigationBarSearchInputConfirmed: noop,
onNavigationBarSearchInputClicked: noop
};
nvue.requireModule('globalEvent').addEventListener('plusMessage', e => {
if (eventMaps[e.data.type]) {
......@@ -383,6 +385,114 @@ function initEventBus (getGlobalEmitter) {
getEmitter = getGlobalEmitter;
}
const SUCCESS = 'success';
const FAIL = 'fail';
const COMPLETE = 'complete';
const CALLBACKS = [SUCCESS, FAIL, COMPLETE];
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function invokeVmMethodWithoutArgs (vm, method, args, extras) {
if (!vm) {
return
}
if (typeof args === 'undefined') {
return vm[method]()
}
const [, callbacks] = normalizeArgs(args, extras);
if (!Object.keys(callbacks).length) {
return vm[method]()
}
return vm[method](normalizeCallback(method, callbacks))
}
/**
* 调用两个参数(第一个入参为普通参数,第二个入参为 callback) API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function invokeVmMethod (vm, method, args, extras) {
if (!vm) {
return
}
const [pureArgs, callbacks] = normalizeArgs(args, extras);
if (!Object.keys(callbacks).length) {
return vm[method](pureArgs)
}
return vm[method](pureArgs, normalizeCallback(method, callbacks))
}
function findElmById (id, vm) {
return findRefByElm(id, vm.$el)
}
function findRefByElm (id, elm) {
if (!id || !elm) {
return
}
if (elm.attr.id === id) {
return elm
}
const children = elm.children;
if (!children) {
return
}
for (let i = 0, len = children.length; i < len; i++) {
const elm = findRefByElm(id, children[i]);
if (elm) {
return elm
}
}
}
function normalizeArgs (args = {}, extras) {
const callbacks = Object.create(null);
const iterator = function iterator (name) {
const callback = args[name];
if (isFn(callback)) {
callbacks[name] = callback;
delete args[name];
}
};
CALLBACKS.forEach(iterator);
extras && extras.forEach(iterator);
return [args, callbacks]
}
function normalizeCallback (method, callbacks) {
return function weexCallback (ret) {
const type = ret.type;
delete ret.type;
const callback = callbacks[type];
if (type === SUCCESS) {
ret.errMsg = `${method}:ok`;
} else if (type === FAIL) {
ret.errMsg = method + ':fail' + (ret.msg ? (' ' + ret.msg) : '');
}
delete ret.code;
delete ret.msg;
isFn(callback) && callback(ret);
if (type === SUCCESS || type === FAIL) {
const complete = callbacks['complete'];
isFn(complete) && complete(ret);
}
}
}
class MapContext {
constructor (id, ctx) {
this.id = id;
......@@ -415,66 +525,72 @@ class MapContext {
}
function createMapContext (id, vm) {
const ref = findRefById(id, vm);
if (!ref) {
global.nativeLog('Can not find `' + id + '`', '__WARN');
if (!vm) {
return console.warn('uni.createMapContext 必须传入第二个参数,即当前 vm 对象(this)')
}
return new MapContext(id, vm.$refs[ref])
}
class VideoContext {
constructor (id, ctx) {
this.id = id;
this.ctx = ctx;
}
play () {
return invokeVmMethodWithoutArgs(this.ctx, 'play')
}
pause () {
return invokeVmMethodWithoutArgs(this.ctx, 'pause')
}
seek (args) {
return invokeVmMethod(this.ctx, 'seek', args)
}
stop () {
return invokeVmMethodWithoutArgs(this.ctx, 'stop')
}
sendDanmu (args) {
return invokeVmMethod(this.ctx, 'sendDanmu', args)
}
playbackRate (args) {
return invokeVmMethod(this.ctx, 'playbackRate', args)
}
requestFullScreen (args) {
return invokeVmMethod(this.ctx, 'requestFullScreen', args)
}
exitFullScreen () {
return invokeVmMethodWithoutArgs(this.ctx, 'exitFullScreen')
}
showStatusBar () {
return invokeVmMethodWithoutArgs(this.ctx, 'showStatusBar')
}
hideStatusBar () {
return invokeVmMethodWithoutArgs(this.ctx, 'hideStatusBar')
}
const elm = findElmById(id, vm);
if (!elm) {
return console.warn('Can not find `' + id + '`')
}
return new MapContext(id, elm)
}
function createVideoContext (id, vm) {
const ref = findRefById(id, vm);
if (!ref) {
global.nativeLog('Can not find `' + id + '`', '__WARN');
}
return new VideoContext(id, vm.$refs[ref])
class VideoContext {
constructor (id, ctx) {
this.id = id;
this.ctx = ctx;
}
play () {
return invokeVmMethodWithoutArgs(this.ctx, 'play')
}
pause () {
return invokeVmMethodWithoutArgs(this.ctx, 'pause')
}
seek (args) {
return invokeVmMethod(this.ctx, 'seek', args)
}
stop () {
return invokeVmMethodWithoutArgs(this.ctx, 'stop')
}
sendDanmu (args) {
return invokeVmMethod(this.ctx, 'sendDanmu', args)
}
playbackRate (args) {
return invokeVmMethod(this.ctx, 'playbackRate', args)
}
requestFullScreen (args) {
return invokeVmMethod(this.ctx, 'requestFullScreen', args)
}
exitFullScreen () {
return invokeVmMethodWithoutArgs(this.ctx, 'exitFullScreen')
}
showStatusBar () {
return invokeVmMethodWithoutArgs(this.ctx, 'showStatusBar')
}
hideStatusBar () {
return invokeVmMethodWithoutArgs(this.ctx, 'hideStatusBar')
}
}
function createVideoContext (id, vm) {
if (!vm) {
return console.warn('uni.createVideoContext 必须传入第二个参数,即当前 vm 对象(this)')
}
const elm = findElmById(id, vm);
if (!elm) {
return console.warn('Can not find `' + id + '`')
}
return new VideoContext(id, elm)
}
class LivePusherContext {
......@@ -493,10 +609,10 @@ class LivePusherContext {
pause (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'pause', cbs)
}
resume (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'resume', cbs)
}
resume (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'resume', cbs)
}
switchCamera (cbs) {
......@@ -510,42 +626,45 @@ class LivePusherContext {
toggleTorch (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'toggleTorch', cbs)
}
playBGM (args) {
return invokeVmMethod(this.ctx, 'playBGM', args)
}
stopBGM (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'stopBGM', cbs)
}
pauseBGM (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'pauseBGM', cbs)
}
resumeBGM (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'resumeBGM', cbs)
}
setBGMVolume (cbs) {
return invokeVmMethod(this.ctx, 'setBGMVolume', cbs)
}
startPreview (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'startPreview', cbs)
playBGM (args) {
return invokeVmMethod(this.ctx, 'playBGM', args)
}
stopBGM (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'stopBGM', cbs)
}
pauseBGM (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'pauseBGM', cbs)
}
resumeBGM (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'resumeBGM', cbs)
}
setBGMVolume (cbs) {
return invokeVmMethod(this.ctx, 'setBGMVolume', cbs)
}
startPreview (cbs) {
return invokeVmMethodWithoutArgs(this.ctx, 'startPreview', cbs)
}
stopPreview (args) {
return invokeVmMethodWithoutArgs(this.ctx, 'stopPreview', args)
}
}
}
function createLivePusherContext (id, vm) {
const ref = findRefById(id, vm);
if (!ref) {
global.nativeLog('Can not find `' + id + '`', '__WARN');
if (!vm) {
return console.warn('uni.createLivePusherContext 必须传入第二个参数,即当前 vm 对象(this)')
}
return new LivePusherContext(id, vm.$refs[ref])
const elm = findElmById(id, vm);
if (!elm) {
return console.warn('Can not find `' + id + '`')
}
return new LivePusherContext(id, elm)
}
......@@ -576,6 +695,9 @@ function initUni (uni, nvue, plus, BroadcastChannel) {
if (typeof Proxy !== 'undefined') {
return new Proxy({}, {
get (target, name) {
if (target[name]) {
return target[name]
}
if (apis[name]) {
return apis[name]
}
......@@ -586,6 +708,9 @@ function initUni (uni, nvue, plus, BroadcastChannel) {
return
}
return promisify(name, uni[name])
},
set (target, name, value) {
target[name] = value;
}
})
}
......@@ -609,48 +734,36 @@ let getGlobalApp;
let getGlobalUniEmitter;
let getGlobalCurrentPages;
var index_legacy = {
create (id, env, config) {
return {
initUniApp ({
nvue,
getUni,
getApp,
getUniEmitter,
getCurrentPages
}) {
getGlobalUni = getUni;
getGlobalApp = getApp;
getGlobalUniEmitter = getUniEmitter;
getGlobalCurrentPages = getCurrentPages;
initUpx2px(nvue);
initEventBus(getUniEmitter);
},
instance: {
getUni (nvue, plus, BroadcastChannel) {
return initUni(getGlobalUni(), nvue, plus, BroadcastChannel)
},
getApp () {
return getGlobalApp()
},
getUniEmitter () {
return getGlobalUniEmitter()
},
getCurrentPages () {
return getGlobalCurrentPages()
}
}
function createInstanceContext () {
return {
initUniApp ({
nvue,
getUni,
getApp,
getUniEmitter,
getCurrentPages
}) {
getGlobalUni = getUni;
getGlobalApp = getApp;
getGlobalUniEmitter = getUniEmitter;
getGlobalCurrentPages = getCurrentPages;
initUpx2px(nvue);
initEventBus(getUniEmitter);
},
getUni (nvue, plus, BroadcastChannel) {
return initUni(getGlobalUni(), nvue, plus, BroadcastChannel)
},
getApp () {
return getGlobalApp()
},
getUniEmitter () {
return getGlobalUniEmitter()
},
getCurrentPages () {
return getGlobalCurrentPages()
}
},
refresh: function (id, env, config) {
},
destroy: function (id, env) {
}
};
}
export default index_legacy;
export { createInstanceContext };
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "0.0.1",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0"
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "1.0.0-alpha-22120190814002",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
......@@ -231,7 +231,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -258,8 +258,8 @@ function handlePromise (promise) {
function shouldPromise (name) {
if (
isContextApi(name) ||
isSyncApi(name) ||
isCallbackApi(name)
isSyncApi(name) ||
isCallbackApi(name)
) {
return false
}
......@@ -491,8 +491,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -653,8 +651,8 @@ function hasHook (hook, vueOptions) {
return true
}
if (vueOptions.super &&
vueOptions.super.options &&
Array.isArray(vueOptions.super.options[hook])) {
vueOptions.super.options &&
Array.isArray(vueOptions.super.options[hook])) {
return true
}
return false
......@@ -679,14 +677,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -853,7 +851,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -861,7 +859,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -936,16 +934,16 @@ function processEventExtra (vm, extra, event) {
if (Array.isArray(extra) && extra.length) {
/**
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*'test'
*/
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*'test'
*/
extra.forEach((dataPath, index) => {
if (typeof dataPath === 'string') {
if (!dataPath) { // model,prop.sync
......@@ -981,8 +979,8 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
let isCustomMPEvent = false; // wxcomponent 组件,传递原始 event 对象
if (isCustom) { // 自定义事件
isCustomMPEvent = event.currentTarget &&
event.currentTarget.dataset &&
event.currentTarget.dataset.comType === 'wx';
event.currentTarget.dataset &&
event.currentTarget.dataset.comType === 'wx';
if (!args.length) { // 无参数,直接传入 event 或 detail 数组
if (isCustomMPEvent) {
return [event]
......@@ -1024,30 +1022,33 @@ const CUSTOM = '^';
function isMatchEventType (eventType, optType) {
return (eventType === optType) ||
(
optType === 'regionchange' &&
(
eventType === 'begin' ||
eventType === 'end'
)
)
(
optType === 'regionchange' &&
(
eventType === 'begin' ||
eventType === 'end'
)
)
}
function handleEvent (event) {
event = wrapper$2(event);
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
}
const eventOpts = dataset.eventOpts || dataset['event-opts'];// 支付宝 web-view 组件 dataset 非驼峰
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
const eventType = event.type;
const ret = [];
eventOpts.forEach(eventOpt => {
let type = eventOpt[0];
const eventsArray = eventOpt[1];
......@@ -1064,8 +1065,8 @@ function handleEvent (event) {
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
......@@ -1079,18 +1080,26 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(handlerCtx, processEventArgs(
ret.push(handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
)));
}
});
}
});
if (
eventType === 'input' &&
ret.length === 1 &&
typeof ret[0] !== 'undefined'
) {
return ret[0]
}
}
const hooks = [
......@@ -1257,8 +1266,8 @@ function createApp (vm) {
}
function parseBaseComponent (vueComponentOptions, {
isPage: isPage$$1,
initRelation: initRelation$$1
isPage,
initRelation
} = {}) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
......@@ -1275,7 +1284,7 @@ function parseBaseComponent (vueComponentOptions, {
const properties = this.properties;
const options = {
mpType: isPage$$1.call(this) ? 'page' : 'component',
mpType: isPage.call(this) ? 'page' : 'component',
mpInstance: this,
propsData: properties
};
......@@ -1283,7 +1292,7 @@ function parseBaseComponent (vueComponentOptions, {
initVueIds(properties.vueId, this);
// 处理父子关系
initRelation$$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1327,7 +1336,7 @@ function parseBaseComponent (vueComponentOptions, {
}
};
if (isPage$$1) {
if (isPage) {
return componentOptions
}
return [componentOptions, VueComponent]
......@@ -1361,10 +1370,7 @@ function parseBasePage (vuePageOptions, {
isPage,
initRelation
}) {
const pageOptions = parseComponent$1(vuePageOptions, {
isPage,
initRelation
});
const pageOptions = parseComponent$1(vuePageOptions);
initHooks(pageOptions.methods, hooks$2, vuePageOptions);
......@@ -1428,6 +1434,9 @@ let uni = {};
if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
uni = new Proxy({}, {
get (target, name) {
if (target[name]) {
return target[name]
}
if (baseApi[name]) {
return baseApi[name]
}
......@@ -1441,9 +1450,13 @@ if (typeof Proxy !== 'undefined' && "app-plus" !== 'app-plus') {
return
}
return promisify(name, wrapper(name, wx[name]))
},
set (target, name, value) {
target[name] = value;
return true
}
});
} else {
} else {
Object.keys(baseApi).forEach(name => {
uni[name] = baseApi[name];
});
......@@ -1477,4 +1490,4 @@ wx.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
{
"name": "@dcloudio/uni-app-plus",
"version": "0.0.248",
"description": "uni-app app-plus",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0"
{
"name": "@dcloudio/uni-app-plus",
"version": "1.0.0-alpha-22120190814002",
"description": "uni-app app-plus",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
const {
updateAppJson,
updatePageJson,
updateUsingComponents,
getChangedJsonFileMap
} = require('../lib/cache')
describe('shared:cache', () => {
it('generate app.json', () => {
const name = 'app'
const appJson = {
debug: true
}
updateAppJson(name, appJson)
let appJsonStr = getChangedJsonFileMap().get(name + '.json')
expect(appJsonStr).toBe(JSON.stringify(appJson, null, 2))
expect(0).toBe(getChangedJsonFileMap().size)
appJson.resizable = true
updateAppJson(name, appJson)
appJsonStr = getChangedJsonFileMap().get(name + '.json')
expect(appJsonStr).toBe(JSON.stringify(appJson, null, 2))
expect(0).toBe(getChangedJsonFileMap().size)
const usingComponents = {
'my-component': '/components/component-tag-name'
}
updateUsingComponents('app', usingComponents)
appJsonStr = getChangedJsonFileMap().get(name + '.json')
appJson.usingComponents = usingComponents
expect(appJsonStr).toBe(JSON.stringify(appJson, null, 2))
})
it('generate page.json', () => {
const name = 'page/index/index'
const pageJson = {
navigationBarBackgroundColor: '#ffffff'
}
updatePageJson(name, pageJson)
let pageJsonStr = getChangedJsonFileMap().get(name + '.json')
expect(pageJsonStr).toBe(JSON.stringify(pageJson, null, 2))
expect(0).toBe(getChangedJsonFileMap().size)
pageJson.navigationBarTextStyle = 'black'
updatePageJson(name, pageJson)
pageJsonStr = getChangedJsonFileMap().get(name + '.json')
expect(pageJsonStr).toBe(JSON.stringify(pageJson, null, 2))
expect(0).toBe(getChangedJsonFileMap().size)
const usingComponents = {
'my-component1': '/components/component-tag-name1'
}
updateUsingComponents(name, usingComponents)
pageJsonStr = getChangedJsonFileMap().get(name + '.json')
pageJson.usingComponents = usingComponents
expect(pageJsonStr).toBe(JSON.stringify(pageJson, null, 2))
})
it('generate component.json', () => {
const name = 'components/component-tag-name'
let usingComponents = {
'my-component': '/components/component-tag-name'
}
updateUsingComponents(name, usingComponents, 'Component')
let componentJsonStr = getChangedJsonFileMap().get(name + '.json')
expect(componentJsonStr).toBe(JSON.stringify({
usingComponents,
component: true
}, null, 2))
expect(0).toBe(getChangedJsonFileMap().size)
usingComponents = {}
updateUsingComponents(name, usingComponents, 'Component')
componentJsonStr = getChangedJsonFileMap().get(name + '.json')
expect(componentJsonStr).toBe(JSON.stringify({
usingComponents,
component: true
}, null, 2))
expect(0).toBe(getChangedJsonFileMap().size)
})
})
function parseApis (modules, test) {
return modules.reduce(function (apis, module) {
const apiList = module.apiList
apiList && Object.keys(apiList).forEach(name => {
if (test(name, apiList[name])) {
apis.add(name.replace('uni.', ''))
}
})
return apis
}, new Set())
}
module.exports = {
parseUserApis (configModules = [], allModules = []) {
const blackboxApis = parseApis(configModules, function (name, value) {
return value === false
})
const allApis = parseApis(allModules, function () {
return true
})
return [...allApis].filter(name => !blackboxApis.has(name))
}
}
/**
* 1.page-loader 缓存基础的 app.json page.json project.config.json
* 2.main-loader 缓存 app.json 中的 usingComponents 节点
* 3.script-loader 修改缓存 usingComponents 节点
* 5.webpack plugin 中获取被修改的 page.json,component.json 并 emitFile
*/
const jsonFileMap = new Map()
const changedJsonFileSet = new Set()
const componentSet = new Set()
const pageSet = new Set()
let globalUsingComponents = Object.create(null)
let appJsonUsingComponents = Object.create(null)
let componentSpecialMethods = Object.create(null)
function getPagesJson () {
if (process.env.UNI_PLATFORM === 'h5') {
return process.UNI_H5_PAGES_JSON
}
const pagesJson = {
pages: {}
}
for (let name of pageSet.values()) {
const style = JSON.parse(getJsonFile(name) || '{}')
delete style.customUsingComponents
pagesJson.pages[name] = style
}
const appJson = JSON.parse(getJsonFile('app') || '{}')
pagesJson.globalStyle = appJson['window'] || {}
return pagesJson
}
function updateJsonFile (name, jsonStr) {
changedJsonFileSet.add(name)
if (typeof jsonStr !== 'string') {
jsonStr = JSON.stringify(jsonStr, null, 2)
}
jsonFileMap.set(name, jsonStr)
}
function getJsonFile (name) {
return jsonFileMap.get(name)
}
function getChangedJsonFileMap (clear = true) {
const changedJsonFileMap = new Map()
for (let name of changedJsonFileSet.values()) {
changedJsonFileMap.set(name + '.json', jsonFileMap.get(name))
}
clear && changedJsonFileSet.clear()
return changedJsonFileMap
}
function updateAppJson (name, jsonObj) {
updateComponentJson(name, jsonObj)
}
function updatePageJson (name, jsonObj) {
pageSet.add(name)
updateComponentJson(name, jsonObj)
}
function updateProjectJson (name, jsonObj) {
updateComponentJson(name, jsonObj, false)
}
const supportGlobalUsingComponents = process.env.UNI_PLATFORM === 'mp-weixin' || process.env.UNI_PLATFORM === 'mp-qq'
function updateComponentJson (name, jsonObj, usingComponents = true) {
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) { // update
if (usingComponents) { // merge usingComponents
jsonObj.usingComponents = JSON.parse(oldJsonStr).usingComponents || {}
}
const newJsonStr = JSON.stringify(jsonObj, null, 2)
if (newJsonStr !== oldJsonStr) {
updateJsonFile(name, newJsonStr)
}
} else { // add
updateJsonFile(name, jsonObj)
}
}
function updateUsingGlobalComponents (name, usingGlobalComponents) {
if (supportGlobalUsingComponents) {
return
}
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) { // update
const jsonObj = JSON.parse(oldJsonStr)
jsonObj.usingGlobalComponents = usingGlobalComponents
const newJsonStr = JSON.stringify(jsonObj, null, 2)
if (newJsonStr !== oldJsonStr) {
updateJsonFile(name, newJsonStr)
}
} else { // add
const jsonObj = {
usingGlobalComponents
}
updateJsonFile(name, jsonObj)
}
}
function updateUsingComponents (name, usingComponents, type) {
if (type === 'Component') {
componentSet.add(name)
}
if (type === 'App') { // 记录全局组件
globalUsingComponents = usingComponents
}
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) { // update
const jsonObj = JSON.parse(oldJsonStr)
if (type === 'Component') {
jsonObj.component = true
} else if (type === 'Page') {
if (process.env.UNI_PLATFORM === 'mp-baidu') {
jsonObj.component = true
}
}
jsonObj.usingComponents = usingComponents
const newJsonStr = JSON.stringify(jsonObj, null, 2)
if (newJsonStr !== oldJsonStr) {
updateJsonFile(name, newJsonStr)
}
} else { // add
const jsonObj = {
usingComponents
}
if (type === 'Component') {
jsonObj.component = true
} else if (type === 'Page') {
if (process.env.UNI_PLATFORM === 'mp-baidu') {
jsonObj.component = true
}
}
updateJsonFile(name, jsonObj)
}
}
function updateComponentGenerics (name, componentGenerics) {
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) { // update
const jsonObj = JSON.parse(oldJsonStr)
jsonObj.componentGenerics = componentGenerics
const newJsonStr = JSON.stringify(jsonObj, null, 2)
if (newJsonStr !== oldJsonStr) {
updateJsonFile(name, newJsonStr)
}
} else { // add
const jsonObj = {
componentGenerics
}
updateJsonFile(name, jsonObj)
}
}
function updateGenericComponents (name, genericComponents) {
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) { // update
const jsonObj = JSON.parse(oldJsonStr)
jsonObj.genericComponents = genericComponents
const newJsonStr = JSON.stringify(jsonObj, null, 2)
if (newJsonStr !== oldJsonStr) {
updateJsonFile(name, newJsonStr)
}
} else { // add
const jsonObj = {
genericComponents
}
updateJsonFile(name, jsonObj)
}
}
function updateAppJsonUsingComponents (usingComponents) {
appJsonUsingComponents = usingComponents
}
function getComponentSet () {
return componentSet
}
function getGlobalUsingComponents () {
// 合并 app.json ,main.js 全局组件
return Object.assign({}, appJsonUsingComponents, globalUsingComponents)
}
function getWXComponents (name) {
const oldJsonStr = getJsonFile(name)
if (oldJsonStr) {
const jsonObj = JSON.parse(oldJsonStr)
if (jsonObj.customUsingComponents) {
return Object.assign({}, appJsonUsingComponents, jsonObj.customUsingComponents)
}
}
return Object.assign({}, appJsonUsingComponents)
}
function updateSpecialMethods (name, specialMethods) {
if (specialMethods.length) {
componentSpecialMethods[name] = specialMethods
} else {
delete componentSpecialMethods[name]
}
}
function getSpecialMethods (name) {
if (!name) {
return componentSpecialMethods
}
return componentSpecialMethods[name] || []
}
module.exports = {
getPageSet () {
return pageSet
},
getJsonFileMap () {
return jsonFileMap
},
getJsonFile,
getPagesJson,
getComponentSet,
getWXComponents,
getGlobalUsingComponents,
updateAppJson,
updatePageJson,
updateProjectJson,
updateComponentJson,
updateSpecialMethods,
updateUsingComponents,
updateUsingGlobalComponents,
updateAppJsonUsingComponents,
updateComponentGenerics,
updateGenericComponents,
getChangedJsonFileMap,
getSpecialMethods
}
const tags = require('./tags')
const {
getJson,
parseJson
} = require('./json')
const {
getH5Options,
getManifestJson,
getNetworkTimeout,
parseManifestJson
} = require('./manifest.js')
const {
getMainEntry,
getNVueMainEntry,
parseEntry,
parsePages,
getPagesJson,
parsePagesJson
} = require('./pages')
const {
md5,
hasModule,
hashify,
camelize,
hyphenate,
removeExt,
normalizePath,
getComponentName,
convertStaticStyle
} = require('./util')
const {
getFlexDirection,
getPlatformProject,
isSupportSubPackages,
getPlatforms,
getPlatformGlobal,
getPlatformScss,
getPlatformSass,
runByHBuilderX,
isInHBuilderX,
isInHBuilderXAlpha,
getPlatformExts,
getPlatformTarget,
getPlatformVue,
getPlatformCompiler,
getShadowCss,
getPlatformCssVars,
getPlatformCssnano,
getShadowTemplate,
jsPreprocessOptions,
cssPreprocessOptions,
htmlPreprocessOptions,
nvueJsPreprocessOptions,
nvueCssPreprocessOptions,
nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate
} = require('./platform')
module.exports = {
md5,
tags,
getJson,
parseJson,
hashify,
hasModule,
camelize,
hyphenate,
removeExt,
normalizePath,
parseEntry,
parsePages,
getH5Options,
getMainEntry,
getNVueMainEntry,
getPagesJson,
getManifestJson,
getNetworkTimeout,
runByHBuilderX,
isInHBuilderX,
isInHBuilderXAlpha,
isSupportSubPackages,
getPlatforms,
getFlexDirection,
getPlatformScss,
getPlatformSass,
getPlatformExts,
getPlatformTarget,
getPlatformProject,
getPlatformVue,
getPlatformGlobal,
getShadowCss,
getPlatformCssVars,
getPlatformCssnano,
getPlatformCompiler,
getShadowTemplate,
parsePagesJson,
parseManifestJson,
getComponentName,
convertStaticStyle,
jsPreprocessOptions,
cssPreprocessOptions,
htmlPreprocessOptions,
nvueJsPreprocessOptions,
nvueCssPreprocessOptions,
nvueHtmlPreprocessOptions,
devtoolModuleFilenameTemplate
}
const fs = require('fs')
const path = require('path')
const stripJsonComments = require('strip-json-comments')
const preprocessor = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/preprocess')
const {
jsPreprocessOptions
} = require('./platform')
function parseJson (content, preprocess = false) {
if (typeof content === 'string') {
if (preprocess) {
content = preprocessor.preprocess(content, jsPreprocessOptions.context, {
type: jsPreprocessOptions.type
})
}
content = JSON.parse(stripJsonComments(content))
}
content = JSON.stringify(content)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029')
return JSON.parse(content)
}
function getJson (jsonFileName, preprocess = false) {
const jsonFilePath = path.resolve(process.env.UNI_INPUT_DIR, jsonFileName)
if (!fs.existsSync(jsonFilePath)) {
throw new Error(jsonFilePath + ' 不存在')
}
try {
return parseJson(fs.readFileSync(jsonFilePath, 'utf8'), preprocess)
} catch (e) {
console.error(jsonFileName + ' 解析失败')
}
}
module.exports = {
getJson,
parseJson
}
const path = require('path')
const {
getJson,
parseJson
} = require('./json')
const defaultRouter = {
mode: 'hash',
base: '/'
}
const defaultAsync = {
loading: 'AsyncLoading',
error: 'AsyncError',
delay: 200,
timeout: 3000
}
const networkTimeout = {
request: 6000,
connectSocket: 6000,
uploadFile: 6000,
downloadFile: 6000
}
function getManifestJson () {
return getJson('manifest.json')
}
function parseManifestJson (content) {
return parseJson(content)
}
function getNetworkTimeout (manifestJson) {
if (!manifestJson) {
manifestJson = getManifestJson()
}
return Object.assign({}, networkTimeout, manifestJson.networkTimeout || {})
}
function getH5Options (manifestJson) {
if (!manifestJson) {
manifestJson = getManifestJson()
}
const h5 = manifestJson.h5 || {}
h5.appid = (manifestJson.appid || '').replace('__UNI__', '')
h5.title = h5.title || manifestJson.name || ''
h5.router = Object.assign({}, defaultRouter, h5.router || {})
h5['async'] = Object.assign({}, defaultAsync, h5['async'] || {})
let base = h5.router.base
if (base.indexOf('/') !== 0) {
base = '/' + base
}
if (base.substr(-1) !== '/') {
base = base + '/'
}
h5.router.base = base
if (process.env.NODE_ENV === 'production') { // 生产模式,启用 publicPath
h5.publicPath = h5.publicPath || base
if (h5.publicPath.substr(-1) !== '/') {
h5.publicPath = h5.publicPath + '/'
}
} else { // 其他模式,启用 base
h5.publicPath = base
}
/* eslint-disable no-mixed-operators */
h5.template = h5.template && path.resolve(process.env.UNI_INPUT_DIR, h5.template) || path.resolve(__dirname,
'../../../../public/index.html')
h5.devServer = h5.devServer || {}
return h5
}
module.exports = {
getManifestJson,
parseManifestJson,
getNetworkTimeout,
getH5Options
}
const PLATFORMS = [
'h5',
'app-plus',
'mp-weixin',
'mp-qq',
'mp-baidu',
'mp-alipay',
'mp-toutiao'
]
module.exports = {
initCustomScript (name, pkgPath) {
const pkg = require(pkgPath)
const uniAppOptions = pkg['uni-app']
let scriptOptions = false
if (uniAppOptions && uniAppOptions['scripts']) {
scriptOptions = uniAppOptions['scripts'][name]
}
if (!scriptOptions) {
console.error(`package.json->uni-app->scripts->${name} 不存在`)
process.exit(0)
}
if (!scriptOptions.env || !scriptOptions.env.UNI_PLATFORM) {
console.error(`package.json->uni-app->scripts->${name}->env 不存在,必须配置 env->UNI_PLATFORM 基础平台`)
process.exit(0)
}
if (PLATFORMS.indexOf(scriptOptions.env.UNI_PLATFORM) === -1) {
console.error(`UNI_PLATFORM 支持一下平台 ${JSON.stringify(PLATFORMS)}`)
process.exit(0)
}
process.env.UNI_PLATFORM = scriptOptions.env.UNI_PLATFORM
process.UNI_SCRIPT_ENV = scriptOptions.env || {}
process.UNI_SCRIPT_DEFINE = scriptOptions.define || {}
return scriptOptions
}
}
const fs = require('fs')
const path = require('path')
const {
removeExt,
normalizePath
} = require('./util')
const {
getJson,
parseJson
} = require('./json')
let mainEntry = ''
let nvueMainEntry = ''
function getMainEntry () {
if (!mainEntry) {
mainEntry = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'main.ts')) ? 'main.ts' : 'main.js'
}
return mainEntry
}
function getNVueMainEntry () {
if (!nvueMainEntry) {
nvueMainEntry = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'main.js')) ? 'main.js' : '.main.js'
if (nvueMainEntry === '.main.js') {
fs.writeFileSync(path.resolve(process.env.UNI_INPUT_DIR, '.main.js'), '')
}
}
return nvueMainEntry
}
function getPagesJson () {
return processPagesJson(getJson('pages.json', true))
}
function parsePagesJson (content) {
return processPagesJson(parseJson(content, true))
}
function filterPages (pages = [], root) {
for (let i = pages.length - 1; i >= 0; i--) {
const page = pages[i]
if (!isValidPage(page, root)) {
pages.splice(i, 1)
}
}
}
function processPagesJson (pagesJson) {
let uniNVueEntryPagePath
if (pagesJson.pages && pagesJson.pages.length) { // 如果首页是 nvue
if (isNVuePage(pagesJson.pages[0])) {
uniNVueEntryPagePath = pagesJson.pages[0].path
}
}
// pages
filterPages(pagesJson.pages)
// subPackages
if (Array.isArray(pagesJson.subPackages) && pagesJson.subPackages.length) {
pagesJson.subPackages.forEach(subPackage => {
filterPages(subPackage.pages, subPackage.root)
})
}
if (Object.keys(uniNVuePages).length) { // 直接挂在 pagesJson 上
pagesJson.nvue = {
pages: uniNVuePages
}
if (uniNVueEntryPagePath) {
pagesJson.nvue.entryPagePath = uniNVueEntryPagePath
}
}
return pagesJson
}
function isNVuePage (page, root = '') {
if (process.env.UNI_PLATFORM === 'app-plus') {
const pagePath = path.join(root, page.path)
if (fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))) { // cache一下结果?如果文件被删除,cache 就会出现错误
return true
}
}
return false
}
function isValidPage (page, root = '') {
if (typeof page === 'string') { // 不合法的配置
console.warn(`${page} 配置错误, 已被忽略, 查看文档: https://uniapp.dcloud.io/collocation/pages?id=pages`)
return false
}
let pagePath = page.path
if (pagePath.indexOf('platforms') === 0) { // 平台相关
if (pagePath.indexOf('platforms/' + process.env.UNI_PLATFORM) === -1) { // 非本平台
return false
}
}
if (
process.env.UNI_PLATFORM === 'app-plus' &&
page.style
) {
const subNVues = page.style.subNVues || (page.style['app-plus'] && page.style['app-plus']['subNVues'])
if (Array.isArray(subNVues)) {
subNVues.forEach(subNVue => {
let subNVuePath = subNVue.path
if (subNVuePath) {
subNVuePath = subNVue.path.split('?')[0]
const subNVuePagePath = removeExt(path.join(root, subNVuePath))
// if (process.env.UNI_USING_NVUE_COMPILER) {
process.UNI_NVUE_ENTRY[subNVuePagePath] = getNVueMainJsPath(subNVuePagePath)
// } else {
// process.UNI_NVUE_ENTRY[subNVuePagePath] = path.resolve(process.env.UNI_INPUT_DIR,
// subNVuePagePath +
// '.nvue') + '?entry'
// }
}
})
}
} else {
page.style && (delete page.style.subNVues)
}
if (isNVuePage(page, root)) {
// 存储 nvue 相关信息
pagePath = normalizePath(path.join(root, pagePath))
// if (process.env.UNI_USING_NVUE_COMPILER) {
process.UNI_NVUE_ENTRY[pagePath] = getNVueMainJsPath(pagePath)
// } else {
// process.UNI_NVUE_ENTRY[pagePath] = path.resolve(process.env.UNI_INPUT_DIR, pagePath + '.nvue') + '?entry'
// }
uniNVuePages[pagePath + '.html'] = {
'window': page.style || {}
}
return false
}
return true
}
function getMainJsPath (page) {
return path.resolve(process.env.UNI_INPUT_DIR, getMainEntry() + '?' + JSON.stringify({
page: encodeURIComponent(page)
}))
}
function getNVueMainJsPath (page) {
return path.resolve(process.env.UNI_INPUT_DIR, getNVueMainEntry() + '?' + JSON.stringify({
page: encodeURIComponent(page)
}))
}
process.UNI_ENTRY = {}
process.UNI_NVUE_ENTRY = {}
let uniNVuePages = {}
function parsePages (pagesJson, pageCallback, subPageCallback) {
if (!pagesJson) {
pagesJson = getPagesJson()
}
// pages
pagesJson.pages.forEach(page => {
pageCallback && pageCallback(page)
})
// subPackages
if (Array.isArray(pagesJson.subPackages) && pagesJson.subPackages.length) {
pagesJson.subPackages.forEach((subPackage) => {
const {
root,
pages
} = subPackage
pages.forEach(page => {
root && subPageCallback && subPageCallback(root, page, subPackage)
})
})
}
}
function parseEntry (pagesJson) {
process.UNI_ENTRY = {
'common/main': path.resolve(process.env.UNI_INPUT_DIR, getMainEntry())
}
process.UNI_SUB_PACKAGES_ROOT = {}
process.UNI_NVUE_ENTRY = {}
if (process.env.UNI_USING_NATIVE) {
// TODO 考虑 pages.json.js
process.UNI_NVUE_ENTRY['app-config'] = path.resolve(process.env.UNI_INPUT_DIR, 'pages.json')
process.UNI_NVUE_ENTRY['app-service'] = path.resolve(process.env.UNI_INPUT_DIR, getMainEntry())
}
uniNVuePages = {}
if (!pagesJson) {
pagesJson = getPagesJson() // 会检测修改 nvue entry
}
// pages
pagesJson.pages.forEach(page => {
process.UNI_ENTRY[page.path] = getMainJsPath(page.path)
})
// subPackages
if (Array.isArray(pagesJson.subPackages) && pagesJson.subPackages.length) {
pagesJson.subPackages.forEach(({
root,
pages
}) => {
Array.isArray(pages) && pages.forEach(page => {
if (root) {
const pagePath = normalizePath(path.join(root, page.path))
process.UNI_ENTRY[pagePath] = getMainJsPath(pagePath)
process.UNI_SUB_PACKAGES_ROOT[pagePath] = root
}
})
})
}
}
module.exports = {
getMainEntry,
getNVueMainEntry,
parsePages,
parseEntry,
getPagesJson,
parsePagesJson
}
const fs = require('fs')
const path = require('path')
const {
normalizePath
} = require('./util')
const {
SCSS,
SASS
} = require('./scss')
const uniRuntime = '@dcloudio/vue-cli-plugin-uni/packages/mp-vue'
const mpvueRuntime = '@dcloudio/vue-cli-plugin-uni/packages/mpvue'
const megaloRuntime = '@dcloudio/vue-cli-plugin-uni/packages/megalo'
const uniCompiler = '@dcloudio/uni-template-compiler'
const mpvueCompiler = '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler'
const megaloCompiler = '@megalo/template-compiler'
function getShadowCss () {
let tagName = 'page'
if (process.env.UNI_PLATFORM === 'h5') {
tagName = 'body'
}
return `${tagName}::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}`
}
function getCopyOption (file, options) {
const from = path.resolve(process.env.UNI_INPUT_DIR, file)
if (fs.existsSync(from)) {
return Object.assign({
from,
to: path.resolve(process.env.UNI_OUTPUT_DIR, file)
}, options)
}
}
function getCopyOptions (files, options = {}, subPackages = true) {
const copyOptions = []
files.forEach(file => {
// 主包
const copyOption = getCopyOption(file, options)
if (copyOption) {
copyOptions.push(copyOption)
}
if (subPackages) {
// 分包
Object.keys(process.UNI_SUBPACKAGES).forEach(root => { // 分包静态资源
const subCopyOption = getCopyOption(path.join(root, file), options)
if (subCopyOption) {
copyOptions.push(subCopyOption)
}
})
}
})
return copyOptions
}
function getStaticCopyOptions (assetsDir) {
const ignore = []
Object.keys(PLATFORMS).forEach(platform => {
if (process.env.UNI_PLATFORM !== platform) {
ignore.push(platform + '/**/*')
}
})
return getCopyOptions(
[assetsDir], {
ignore
}
)
}
const PLATFORMS = {
'h5': {
global: '',
exts: false,
vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue',
compiler: false,
megalo: false,
subPackages: false,
cssVars: {
'--status-bar-height': '0px'
},
copyWebpackOptions ({
assetsDir
}) {
return [
...getStaticCopyOptions(assetsDir),
{
from: require.resolve('@dcloudio/uni-h5/dist/index.css'),
to: assetsDir,
transform (content) {
if (process.env.NODE_ENV === 'production') {
return content + getShadowCss()
}
return content
}
},
...getCopyOptions(['hybrid/html'])
]
}
},
'app-plus': {
global: 'wx',
exts: {
style: '.wxss',
template: '.wxml',
filter: '.wxs'
},
vue: mpvueRuntime,
compiler: mpvueCompiler,
megalo: false,
filterTag: 'wxs',
subPackages: false,
cssVars: {
'--window-top': '0px',
'--window-bottom': '0px'
},
copyWebpackOptions ({
assetsDir
}) {
const files = ['hybrid/html']
if (!process.env.UNI_USING_NATIVE) {
files.push('wxcomponents')
}
return [
...getStaticCopyOptions(assetsDir),
...getCopyOptions(files)
]
}
},
'mp-qq': {
global: 'wx',
exts: {
style: '.qss',
template: '.qml',
filter: '.wxs'
},
vue: mpvueRuntime,
compiler: mpvueCompiler,
megalo: false,
filterTag: 'wxs',
subPackages: true,
cssVars: {
'--status-bar-height': '25px',
'--window-top': '0px',
'--window-bottom': '0px'
},
project: 'project.config.json',
copyWebpackOptions ({
assetsDir
}) {
return [
...getStaticCopyOptions(assetsDir),
...getCopyOptions(['wxcomponents'])
]
}
},
'mp-weixin': {
global: 'wx',
exts: {
style: '.wxss',
template: '.wxml',
filter: '.wxs'
},
vue: mpvueRuntime,
compiler: mpvueCompiler,
megalo: false,
filterTag: 'wxs',
subPackages: true,
cssVars: {
'--status-bar-height': '25px',
'--window-top': '0px',
'--window-bottom': '0px'
},
project: 'project.config.json',
copyWebpackOptions ({
assetsDir,
manifestPlatformOptions
}) {
const files = [
'sitemap.json',
'ext.json',
'custom-tab-bar'
]
if (manifestPlatformOptions.workers) {
files.push(manifestPlatformOptions.workers)
}
return [
...getStaticCopyOptions(assetsDir),
...getCopyOptions(['wxcomponents']),
...getCopyOptions(files, {}, false)
]
}
},
'mp-baidu': {
global: 'swan',
exts: {
style: '.css',
template: '.swan',
filter: '.filter.js'
},
vue: megaloRuntime,
compiler: megaloCompiler,
megalo: 'swan',
filterTag: 'filter',
subPackages: true,
cssVars: {
'--status-bar-height': '25px',
'--window-top': '0px',
'--window-bottom': '0px'
},
project: 'project.swan.json',
copyWebpackOptions ({
assetsDir
}) {
return [
...getStaticCopyOptions(assetsDir),
...getCopyOptions(['swancomponents'])
]
}
},
'mp-alipay': {
global: 'my',
exts: {
style: '.acss',
template: '.axml',
filter: '.sjs'
},
vue: megaloRuntime,
compiler: megaloCompiler,
megalo: 'alipay',
filterTag: 'import-sjs',
subPackages: true,
cssVars: {
'--status-bar-height': '25px',
'--window-top': '0px',
'--window-bottom': '0px'
},
copyWebpackOptions ({
assetsDir
}) {
return [
...getStaticCopyOptions(assetsDir),
...getCopyOptions(['mycomponents'])
]
}
},
'mp-toutiao': {
global: 'tt',
exts: {
style: '.ttss',
template: '.ttml'
},
vue: megaloRuntime,
compiler: megaloCompiler,
megalo: 'tt',
subPackages: false,
cssVars: {
'--status-bar-height': '25px',
'--window-top': '0px',
'--window-bottom': '0px'
},
project: 'project.tt.json',
copyWebpackOptions ({
assetsDir
}) {
return [
...getStaticCopyOptions(assetsDir),
...getCopyOptions(['ttcomponents'])
]
}
}
}
// 解决 vue-cli-service lint 时 UNI_PLATFORM 不存在
process.env.UNI_PLATFORM = process.env.UNI_PLATFORM || 'h5'
const platform = PLATFORMS[process.env.UNI_PLATFORM]
const preprocessContext = {}
Object.keys(PLATFORMS).forEach(platform => {
preprocessContext[platform.toUpperCase()] = false
})
preprocessContext[process.env.UNI_PLATFORM.toUpperCase()] = true
preprocessContext['MP'] = false
preprocessContext['APP'] = false
preprocessContext['APP-PLUS-NVUE'] = false
preprocessContext['APP_PLUS_NVUE'] = false
preprocessContext['APP-VUE'] = false
preprocessContext['APP_VUE'] = false
preprocessContext['APP-NVUE'] = false
preprocessContext['APP_NVUE'] = false
if (process.env.UNI_PLATFORM === 'app-plus') {
preprocessContext['APP-VUE'] = true
preprocessContext['APP_VUE'] = true
}
if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) {
preprocessContext['MP'] = true
}
if (process.env.UNI_PLATFORM.indexOf('app-') === 0) {
preprocessContext['APP'] = true
}
if (process.UNI_SCRIPT_DEFINE && Object.keys(process.UNI_SCRIPT_DEFINE).length) {
Object.keys(process.UNI_SCRIPT_DEFINE).forEach(name => {
preprocessContext[name] = process.UNI_SCRIPT_DEFINE[name]
})
}
Object.keys(preprocessContext).forEach(platform => {
if (platform.indexOf('-') !== -1) {
preprocessContext[platform.replace(/-/g, '_')] = preprocessContext[platform]
}
})
const nvuePreprocessContext = Object.assign({}, preprocessContext, {
'APP-VUE': false,
'APP_VUE': false,
'APP-NVUE': true,
'APP_NVUE': true,
'APP-PLUS-NVUE': true,
'APP_PLUS_NVUE': true
})
const isInHBuilderX = fs.existsSync(path.resolve(process.env.UNI_CLI_CONTEXT, 'bin/uniapp-cli.js'))
let isInHBuilderXAlpha = false
if (isInHBuilderX) {
try {
if (require(path.resolve(process.env.UNI_CLI_CONTEXT, '../about/package.json')).alpha) {
isInHBuilderXAlpha = true
}
} catch (e) {
}
}
let sourceRoot = false
function devtoolModuleFilenameTemplate (info) {
if (!sourceRoot) {
if (isInHBuilderX) {
sourceRoot = normalizePath(process.env.UNI_INPUT_DIR)
} else {
sourceRoot = normalizePath(process.env.UNI_CLI_CONTEXT)
}
}
let filePath = false
const absoluteResourcePath = normalizePath(info.absoluteResourcePath)
if (
absoluteResourcePath.indexOf(sourceRoot) !== -1 &&
(
absoluteResourcePath.endsWith('.js') ||
absoluteResourcePath.endsWith('.ts')
)
) {
filePath = normalizePath(path.relative(sourceRoot, absoluteResourcePath))
if (
filePath.indexOf('node_modules/@dcloudio') === 0 ||
filePath.indexOf('node_modules/vue-loader') === 0 ||
filePath.indexOf('node_modules/webpack') === 0
) {
filePath = false
}
} else if (
!info.moduleId &&
(
absoluteResourcePath.endsWith('.vue') ||
absoluteResourcePath.endsWith('.nvue')
)
) {
if (
absoluteResourcePath.indexOf('src') !== 0 &&
absoluteResourcePath.indexOf('node-modules') !== 0
) {
filePath = normalizePath(path.relative(sourceRoot, absoluteResourcePath))
} else {
filePath = absoluteResourcePath
}
}
if (
filePath &&
filePath !== 'main.js' &&
filePath !== 'main.ts' &&
filePath !== 'src/main.js' &&
filePath !== 'src/main.ts'
) {
return `uni-app:///${filePath}`
}
}
module.exports = {
isInHBuilderX,
isInHBuilderXAlpha,
runByHBuilderX: isInHBuilderX || !!process.env.UNI_HBUILDERX_PLUGINS,
devtoolModuleFilenameTemplate,
getFlexDirection (json) {
let flexDir = 'column'
if (json && json['nvue'] && json['nvue']['flex-direction']) {
flexDir = json['nvue']['flex-direction']
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse']
if (flexDirs.indexOf(flexDir) === -1) {
flexDir = 'column'
}
}
return flexDir
},
jsPreprocessOptions: {
type: 'js',
context: preprocessContext
},
cssPreprocessOptions: {
type: 'css',
context: preprocessContext
},
htmlPreprocessOptions: {
type: 'html',
context: preprocessContext
},
nvueCssPreprocessOptions: {
type: 'css',
context: nvuePreprocessContext
},
nvueJsPreprocessOptions: {
type: 'js',
context: nvuePreprocessContext
},
nvueHtmlPreprocessOptions: {
type: 'html',
context: nvuePreprocessContext
},
isSupportSubPackages () {
return platform.subPackages
},
getPlatforms () {
return Object.keys(PLATFORMS)
},
getPlatformCopy () {
return platform.copyWebpackOptions
},
getPlatformGlobal () {
return platform.global
},
getPlatformExts () {
return platform.exts
},
getPlatformTarget () {
return platform.megalo
},
getPlatformProject () {
return platform.project
},
getPlatformFilterTag () {
return platform.filterTag
},
getPlatformVue () {
if (process.env.UNI_USING_COMPONENTS) {
return uniRuntime
}
return platform.vue
},
getPlatformCompiler () {
if (process.env.UNI_USING_COMPONENTS || process.env.UNI_PLATFORM === 'h5') {
return require(uniCompiler)
}
return require(platform.compiler)
},
getPlatformCssVars () {
return platform.cssVars
},
getPlatformCssnano () {
return {
calc: false,
orderedValues: false,
mergeLonghand: false,
mergeRules: false,
cssDeclarationSorter: false,
discardComments: false,
discardDuplicates: false // 条件编译会导致重复
}
},
getShadowCss,
getShadowTemplate (colorType = 'grey') {
let tagName = 'cover-image'
if (process.env.UNI_PLATFORM === 'mp-toutiao') {
tagName = 'image'
}
return `<${tagName} src="https://cdn.dcloud.net.cn/img/shadow-${colorType}.png" style="z-index:998;position:fixed;left:0;top:0;width:100%;height:3px;"/>`
},
getPlatformScss () {
return SCSS
},
getPlatformSass () {
return SASS
}
}
const SCSS =
`
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
$uni-text-color: #333;//基本色
$uni-text-color-inverse: #fff;//反色
$uni-text-color-grey: #999;//辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable: #c0c0c0;
$uni-bg-color: #ffffff;
$uni-bg-color-grey: #f8f8f8;
$uni-bg-color-hover: #f1f1f1;//点击状态颜色
$uni-bg-color-mask: rgba(0, 0, 0, 0.4);//遮罩颜色
$uni-border-color: #c8c7cc;
$uni-font-size-sm: 24rpx;
$uni-font-size-base: 28rpx;
$uni-font-size-lg: 32rpx;
$uni-img-size-sm: 40rpx;
$uni-img-size-base: 52rpx;
$uni-img-size-lg: 80rpx;
$uni-border-radius-sm: 4rpx;
$uni-border-radius-base: 6rpx;
$uni-border-radius-lg: 12rpx;
$uni-border-radius-circle: 50%;
$uni-spacing-row-sm: 10px;
$uni-spacing-row-base: 20rpx;
$uni-spacing-row-lg: 30rpx;
$uni-spacing-col-sm: 8rpx;
$uni-spacing-col-base: 16rpx;
$uni-spacing-col-lg: 24rpx;
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title: 40rpx;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle: 36rpx;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph: 30rpx;
`
const SASS =
`
$uni-color-primary: #007aff
$uni-color-success: #4cd964
$uni-color-warning: #f0ad4e
$uni-color-error: #dd524d
$uni-text-color: #333//基本色
$uni-text-color-inverse: #fff//反色
$uni-text-color-grey: #999//辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080
$uni-text-color-disable: #c0c0c0
$uni-bg-color: #ffffff
$uni-bg-color-grey: #f8f8f8
$uni-bg-color-hover: #f1f1f1//点击状态颜色
$uni-bg-color-mask: rgba(0, 0, 0, 0.4)//遮罩颜色
$uni-border-color: #c8c7cc
$uni-font-size-sm: 24rpx
$uni-font-size-base: 28rpx
$uni-font-size-lg: 32rpx
$uni-img-size-sm: 40rpx
$uni-img-size-base: 52rpx
$uni-img-size-lg: 80rpx
$uni-border-radius-sm: 4rpx
$uni-border-radius-base: 6rpx
$uni-border-radius-lg: 12rpx
$uni-border-radius-circle: 50%
$uni-spacing-row-sm: 10px
$uni-spacing-row-base: 20rpx
$uni-spacing-row-lg: 30rpx
$uni-spacing-col-sm: 8rpx
$uni-spacing-col-base: 16rpx
$uni-spacing-col-lg: 24rpx
$uni-opacity-disabled: 0.3 // 组件禁用态的透明度
$uni-color-title: #2C405A // 文章标题颜色
$uni-font-size-title: 40rpx
$uni-color-subtitle: #555555 // 二级标题颜色
$uni-font-size-subtitle: 36rpx
$uni-color-paragraph: #3F536E // 文章段落颜色
$uni-font-size-paragraph: 30rpx
`
module.exports = {
SCSS,
SASS
}
module.exports = {
'resize-sensor': ['h5'],
'ad': ['mp-weixin'],
'audio': ['app-plus', 'mp-weixin', 'h5'],
'button': ['app-plus', 'mp-weixin', 'h5'],
'camera': ['mp-weixin'],
'canvas': ['app-plus', 'mp-weixin'],
'checkbox': ['app-plus', 'mp-weixin', 'h5'],
'checkbox-group': ['app-plus', 'mp-weixin', 'h5'],
'cover-image': ['app-plus', 'mp-weixin'],
'cover-view': ['app-plus', 'mp-weixin'],
'form': ['app-plus', 'mp-weixin', 'h5'],
'functional-page-navigator': ['mp-weixin'],
'icon': ['app-plus', 'mp-weixin'],
'image': ['app-plus', 'mp-weixin', 'h5'],
'input': ['app-plus', 'mp-weixin', 'h5'],
'label': ['app-plus', 'mp-weixin', 'h5'],
'live-player': ['mp-weixin'],
'live-pusher': ['mp-weixin'],
'map': ['app-plus', 'mp-weixin', 'h5'],
'movable-area': ['app-plus', 'mp-weixin'],
'movable-view': ['app-plus', 'mp-weixin'],
'navigator': ['app-plus', 'mp-weixin', 'h5'],
'official-account': ['mp-weixin'],
'open-data': ['mp-weixin'],
'picker': ['app-plus', 'mp-weixin', 'h5'],
'picker-view': ['app-plus', 'mp-weixin', 'h5'],
'picker-view-column': ['app-plus', 'mp-weixin', 'h5'],
'progress': ['app-plus', 'mp-weixin', 'h5'],
'radio': ['app-plus', 'mp-weixin', 'h5'],
'radio-group': ['app-plus', 'mp-weixin', 'h5'],
'rich-text': ['app-plus', 'mp-weixin', 'h5'],
'scroll-view': ['app-plus', 'mp-weixin', 'h5'],
'slider': ['app-plus', 'mp-weixin', 'h5'],
'swiper': ['app-plus', 'mp-weixin', 'h5'],
'swiper-item': ['app-plus', 'mp-weixin', 'h5'],
'switch': ['app-plus', 'mp-weixin', 'h5'],
'text': ['app-plus', 'mp-weixin', 'h5'],
'textarea': ['app-plus', 'mp-weixin', 'h5'],
'video': ['app-plus', 'mp-weixin', 'h5'],
'view': ['app-plus', 'mp-weixin', 'h5'],
'web-view': ['app-plus', 'mp-weixin']
}
const path = require('path')
const hash = require('hash-sum')
const crypto = require('crypto')
const PLATFORMS = [
'h5',
'app-plus',
'mp-qq',
'mp-weixin',
'mp-baidu',
'mp-alipay',
'mp-toutiao',
'quickapp'
]
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
function removeExt (str, ext) {
if (ext) {
const reg = new RegExp(ext.replace(/\./, '\\.') + '$')
return normalizePath(str.replace(reg, ''))
}
return normalizePath(str.replace(/\.\w+$/g, ''))
}
function hashify (filepath) {
const relativePath = removeExt(path.relative(process.env.UNI_INPUT_DIR, filepath))
return hash(relativePath)
}
function md5 (str) {
const hash = crypto.createHash('md5')
hash.update(str)
return hash.digest('hex')
}
function cached (fn) {
const cache = Object.create(null)
return function cachedFn (str) {
const hit = cache[str]
return hit || (cache[str] = fn(str))
}
}
const camelizeRE = /-(\w)/g
const camelize = cached((str) => {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
})
const hyphenateRE = /\B([A-Z])/g
const hyphenate = cached((str) => {
return str.replace(hyphenateRE, '-$1').toLowerCase()
})
const REGEX_PX = /(:|\s|\(|\/)[+-]?\d+(\.\d+)?u?px/g
const REGEX_UPX = /(:|\s|\(|\/)[+-]?\d+(\.\d+)?upx/g
function convertStaticStyle (styleStr) {
if (typeof styleStr === 'string') {
let matches = styleStr.match(REGEX_UPX)
if (matches && matches.length) {
matches.forEach(function (match) {
styleStr = styleStr.replace(match, match.substr(0, match.length - 3) + 'rpx')
})
}
// TODO 不应该再支持 px 转 rpx
if (process.UNI_TRANSFORM_PX) { // 需要转换 px
matches = styleStr.match(REGEX_PX)
if (matches && matches.length) {
matches.forEach(function (match) {
styleStr = styleStr.replace(match, match.substr(0, match.length - 2) + 'rpx')
})
}
}
}
return styleStr
}
function hasModule (name) {
try {
return !!require.resolve(name)
} catch (e) {}
return false
}
module.exports = {
md5,
hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
},
hasModule,
parseStyle (style = {}) {
Object.keys(style).forEach(name => {
if (PLATFORMS.includes(name)) {
if (name === process.env.UNI_PLATFORM) {
Object.assign(style, style[name] || {})
}
delete style[name]
}
})
return style
},
hashify,
removeExt,
camelize,
hyphenate,
normalizePath,
convertStaticStyle,
getComponentName: cached((str) => {
if (str.indexOf('wx-') === 0) {
return str.replace('wx-', 'weixin-')
}
return str
})
}
{
"name": "@dcloudio/uni-cli-shared",
"version": "0.2.989",
"description": "uni-cli-shared",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"hash-sum": "^1.0.2",
"strip-json-comments": "^2.0.1"
},
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-h5",
"version": "0.7.3",
"version": "0.9.0",
"description": "uni-app h5",
"main": "dist/index.umd.min.js",
"scripts": {
......@@ -11,5 +11,6 @@
"dependencies": {
"base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0"
}
},
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
......@@ -231,7 +231,7 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -258,8 +258,8 @@ function handlePromise (promise) {
function shouldPromise (name) {
if (
isContextApi(name) ||
isSyncApi(name) ||
isCallbackApi(name)
isSyncApi(name) ||
isCallbackApi(name)
) {
return false
}
......@@ -356,8 +356,6 @@ const todos = [
'getRecorderManager',
'getBackgroundAudioManager',
'createInnerAudioContext',
'chooseVideo',
'saveVideoToPhotosAlbum',
'createVideoContext',
'createCameraContext',
'createLivePlayerContext',
......@@ -366,12 +364,7 @@ const todos = [
'startAccelerometer',
'startCompass',
'addPhoneContact',
'setBackgroundColor',
'setBackgroundTextStyle',
'createIntersectionObserver',
'authorize',
'openSetting',
'getSetting',
'chooseAddress',
'chooseInvoiceTitle',
'addTemplate',
......@@ -380,12 +373,12 @@ const todos = [
'getTemplateLibraryList',
'getTemplateList',
'sendTemplateMessage',
'getUpdateManager',
'setEnableDebug',
'getExtConfig',
'getExtConfigSync',
'onWindowResize',
'offWindowResize'
'offWindowResize',
'saveVideoToPhotosAlbum'
];
// 存在兼容性的 API 列表
......@@ -398,7 +391,13 @@ const canIUses = [
'setTabBarBadge',
'removeTabBarBadge',
'showTabBarRedDot',
'hideTabBarRedDot'
'hideTabBarRedDot',
'openSetting',
'getSetting',
'createIntersectionObserver',
'getUpdateManager',
'setBackgroundColor',
'setBackgroundTextStyle'
];
function _handleNetworkInfo (result) {
......@@ -551,6 +550,12 @@ const protocols = { // 需要做转换的 API 列表
returnValue: {
apFilePath: 'tempFilePath'
}
},
chooseVideo: {
// 支付宝小程序文档中未找到(仅在getSetting处提及),但实际可用
returnValue: {
apFilePath: 'tempFilePath'
}
},
connectSocket: {
args: {
......@@ -686,6 +691,18 @@ const protocols = { // 需要做转换的 API 列表
item.uuid = item.serviceId;
});
}
},
createBLEConnection: {
name: 'connectBLEDevice',
args: {
timeout: false
}
},
closeBLEConnection: {
name: 'disconnectBLEDevice'
},
onBLEConnectionStateChange: {
name: 'onBLEConnectionStateChanged'
},
makePhoneCall: {
args: {
......@@ -717,6 +734,9 @@ const protocols = { // 需要做转换的 API 列表
returnValue: {
brightness: 'value'
}
},
showShareMenu: {
name: 'showSharePanel'
}
};
......@@ -891,8 +911,6 @@ function $emit () {
return apply(getEmitter(), '$emit', [...arguments])
}
var eventApi = /*#__PURE__*/Object.freeze({
$on: $on,
$off: $off,
......@@ -938,7 +956,9 @@ function createExecCallback (execCallback) {
callback(res[index]);
});
});
execCallback(res);
if (isFn(execCallback)) {
execCallback(res);
}
}
}
......@@ -1028,8 +1048,8 @@ function hasHook (hook, vueOptions) {
return true
}
if (vueOptions.super &&
vueOptions.super.options &&
Array.isArray(vueOptions.super.options[hook])) {
vueOptions.super.options &&
Array.isArray(vueOptions.super.options[hook])) {
return true
}
return false
......@@ -1054,14 +1074,14 @@ function initHooks (mpOptions, hooks, vueOptions) {
});
}
function initVueComponent (Vue$$1, vueOptions) {
function initVueComponent (Vue, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue$$1.extend(vueOptions);
VueComponent = Vue.extend(vueOptions);
}
return [VueComponent, vueOptions]
}
......@@ -1218,7 +1238,7 @@ function initProperties (props, isBehavior = false, file = '') {
value = value();
}
opts.type = parsePropType(key, opts.type, value, file);
opts.type = parsePropType(key, opts.type);
properties[key] = {
type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null,
......@@ -1226,7 +1246,7 @@ function initProperties (props, isBehavior = false, file = '') {
observer: createObserver(key)
};
} else { // content:String
const type = parsePropType(key, opts, null, file);
const type = parsePropType(key, opts);
properties[key] = {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
observer: createObserver(key)
......@@ -1301,16 +1321,16 @@ function processEventExtra (vm, extra, event) {
if (Array.isArray(extra) && extra.length) {
/**
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*'test'
*/
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*[
* ['data.items', 'data.id', item.data.id],
* ['metas', 'id', meta.id]
*],
*'test'
*/
extra.forEach((dataPath, index) => {
if (typeof dataPath === 'string') {
if (!dataPath) { // model,prop.sync
......@@ -1346,8 +1366,8 @@ function processEventArgs (vm, event, args = [], extra = [], isCustom, methodNam
let isCustomMPEvent = false; // wxcomponent 组件,传递原始 event 对象
if (isCustom) { // 自定义事件
isCustomMPEvent = event.currentTarget &&
event.currentTarget.dataset &&
event.currentTarget.dataset.comType === 'wx';
event.currentTarget.dataset &&
event.currentTarget.dataset.comType === 'wx';
if (!args.length) { // 无参数,直接传入 event 或 detail 数组
if (isCustomMPEvent) {
return [event]
......@@ -1389,30 +1409,33 @@ const CUSTOM = '^';
function isMatchEventType (eventType, optType) {
return (eventType === optType) ||
(
optType === 'regionchange' &&
(
eventType === 'begin' ||
eventType === 'end'
)
)
(
optType === 'regionchange' &&
(
eventType === 'begin' ||
eventType === 'end'
)
)
}
function handleEvent (event) {
event = wrapper$1(event);
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
// [['tap',[['handle',[1,2,a]],['handle1',[1,2,a]]]]]
const dataset = (event.currentTarget || event.target).dataset;
if (!dataset) {
return console.warn(`事件信息不存在`)
}
const eventOpts = dataset.eventOpts || dataset['event-opts'];// 支付宝 web-view 组件 dataset 非驼峰
const eventOpts = dataset.eventOpts || dataset['event-opts']; // 支付宝 web-view 组件 dataset 非驼峰
if (!eventOpts) {
return console.warn(`事件信息不存在`)
}
// [['handle',[1,2,a]],['handle1',[1,2,a]]]
const eventType = event.type;
const ret = [];
eventOpts.forEach(eventOpt => {
let type = eventOpt[0];
const eventsArray = eventOpt[1];
......@@ -1429,8 +1452,8 @@ function handleEvent (event) {
let handlerCtx = this.$vm;
if (
handlerCtx.$options.generic &&
handlerCtx.$parent &&
handlerCtx.$parent.$parent
handlerCtx.$parent &&
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
......@@ -1444,18 +1467,26 @@ function handleEvent (event) {
}
handler.once = true;
}
handler.apply(handlerCtx, processEventArgs(
ret.push(handler.apply(handlerCtx, processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
)));
}
});
}
});
if (
eventType === 'input' &&
ret.length === 1 &&
typeof ret[0] !== 'undefined'
) {
return ret[0]
}
}
const hooks = [
......@@ -1617,13 +1648,13 @@ const customize = cached((str) => {
const isComponent2 = my.canIUse('component2');
const mocks$1 = ['$id'];
const mocks = ['$id'];
function initRefs$1 () {
function initRefs () {
}
function initBehavior$1 ({
function initBehavior ({
properties
}) {
const props = {};
......@@ -1637,7 +1668,7 @@ function initBehavior$1 ({
}
}
function initRelation$1 (detail) {
function initRelation (detail) {
this.props.onVueInit(detail);
}
......@@ -1760,13 +1791,13 @@ function createObserver$1 (isDidUpdate) {
const handleLink$1 = (function () {
if (isComponent2) {
return function handleLink$$1 (detail) {
return function handleLink$1 (detail) {
return handleLink.call(this, {
detail
})
}
}
return function handleLink$$1 (detail) {
return function handleLink$1 (detail) {
if (this.$vm && this.$vm._isMounted) { // 父已初始化
return handleLink.call(this, {
detail: {
......@@ -1799,8 +1830,8 @@ function parseApp (vm) {
});
return parseBaseApp(vm, {
mocks: mocks$1,
initRefs: initRefs$1
mocks,
initRefs
})
}
......@@ -1825,7 +1856,7 @@ function parsePage (vuePageOptions) {
let [VueComponent, vueOptions] = initVueComponent(Vue, vuePageOptions);
const pageOptions = {
mixins: initBehaviors(vueOptions, initBehavior$1),
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
onLoad (args) {
const properties = this.props;
......@@ -1889,7 +1920,7 @@ function initVm (VueComponent) {
if (isComponent2) {
// 处理父子关系
initRelation$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options
});
......@@ -1901,7 +1932,7 @@ function initVm (VueComponent) {
this.$vm.$mount();
} else {
// 处理父子关系
initRelation$1.call(this, {
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options,
VueComponent,
......@@ -1940,7 +1971,7 @@ function parseComponent (vueComponentOptions) {
});
const componentOptions = {
mixins: initBehaviors(vueOptions, initBehavior$1),
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
......@@ -2000,6 +2031,9 @@ let uni = {};
if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
uni = new Proxy({}, {
get (target, name) {
if (target[name]) {
return target[name]
}
if (baseApi[name]) {
return baseApi[name]
}
......@@ -2021,9 +2055,13 @@ if (typeof Proxy !== 'undefined' && "mp-alipay" !== 'app-plus') {
return
}
return promisify(name, wrapper(name, my[name]))
},
set (target, name, value) {
target[name] = value;
return true
}
});
} else {
} else {
Object.keys(baseApi).forEach(name => {
uni[name] = baseApi[name];
});
......@@ -2059,4 +2097,4 @@ my.createComponent = createComponent;
var uni$1 = uni;
export default uni$1;
export { createApp, createPage, createComponent };
export { createApp, createComponent, createPage };
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.822",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0"
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.827",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
此差异已折叠。
{
"name": "@dcloudio/uni-mp-baidu",
"version": "0.0.852",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0"
{
"name": "@dcloudio/uni-mp-baidu",
"version": "1.0.0-alpha-22120190814002",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
此差异已折叠。
{
"name": "@dcloudio/uni-mp-qq",
"version": "0.0.106",
"description": "uni-app mp-qq",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0"
{
"name": "@dcloudio/uni-mp-qq",
"version": "0.0.111",
"description": "uni-app mp-qq",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "0.0.346",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0"
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "0.0.351",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "08ea04b669e93f0db3acb2dfa38138298edd5789"
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
const mpWeixin = require('./mp-weixin')
module.exports = Object.assign({}, mpWeixin, {
prefix: 'tt:'
// ref: 'vue-ref'
})
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册