提交 544d0ae3 编写于 作者: Q qiang

Merge branch 'alpha'

......@@ -19,17 +19,25 @@ const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd(), {
// 删除 cache 目录
del.sync(['node_modules/.cache'])
let entry = './lib/' + process.env.UNI_PLATFORM + '/main.js'
if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_UI === 'true') {
entry = './lib/' + process.env.UNI_PLATFORM + '/ui.js'
}
service.run('build', {
name: 'index',
watch: process.env.UNI_WATCH === 'true',
target: 'lib',
formats: process.env.UNI_WATCH === 'true' ? 'umd' : 'umd-min',
entry: './lib/' + process.env.UNI_PLATFORM + '/main.js'
entry
}).then(function () {
generateApiManifest(
JSON.parse(JSON.stringify(process.UNI_SERVICE_API_MANIFEST)),
JSON.parse(JSON.stringify(process.UNI_SERVICE_API_PROTOCOL))
)
if (process.env.UNI_UI !== 'true') {
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)
......
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.old.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'),
'uni-helpers': path.resolve(__dirname, '../src/core/helpers')
}),
replace({
__GLOBAL__: 'getGlobalUni()',
__PLATFORM_TITLE__: 'app-plus-nvue'
})
]
}
......@@ -6,9 +6,15 @@ const pkgPath = resolve('package.json')
const webpackConfig = require('./webpack.config.js')
let outputDir = resolve('./packages/uni-' + process.env.UNI_PLATFORM + '/dist')
if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_UI === 'true') {
outputDir = resolve('./packages/uni-' + process.env.UNI_PLATFORM + '-ui/dist')
}
module.exports = {
publicPath: '/',
outputDir: resolve('./packages/uni-' + process.env.UNI_PLATFORM + '/dist'),
outputDir,
lintOnSave: true, // or error
runtimeCompiler: false,
transpileDependencies: [],
......
......@@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-alpha-22420190823022"
"version": "2.0.0-23020190919001"
}
import {
canIUse
} from 'uni-core/service/api/base/can-i-use'
import {
upx2px
} from 'uni-core/service/api/base/upx2px'
import {
getLocation
} from 'uni-platform/service/api/location/get-location'
import {
onCompassChange,
stopCompass
} from 'uni-platform/service/api/device/compass'
import {
getSystemInfoSync
} from 'uni-platform/service/api/device/get-system-info'
// TODO route
export default {
canIUse,
upx2px,
getLocation,
onCompassChange,
stopCompass,
getSystemInfoSync
}
import Vue from 'vue'
// 使用白名单过滤(前期有一批自定义组件使用了 uni-)
import tags from 'uni-helpers/tags'
import 'uni-core/view/index.css'
import uni from './ui-api.js'
import {
processEvent
} from 'uni-core/view/plugins/events'
const oldIsReservedTag = Vue.config.isReservedTag
global.uni = uni
Vue.config.isReservedTag = function (tag) {
return tags.indexOf(tag) !== -1 || oldIsReservedTag(tag)
}
Vue.config.ignoredElements = tags
const oldGetTagNamespace = Vue.config.getTagNamespace
const conflictTags = ['switch', 'image', 'text', 'view']
Vue.config.getTagNamespace = function (tag) {
if (~conflictTags.indexOf(tag)) { // svg 部分标签名称与 uni 标签冲突
return false
}
return oldGetTagNamespace(tag) || false
}
const findUniTarget = function ($event, $el) {
let target = $event.target
for (; target && target !== $el; target = target.parentNode) {
if (target.tagName && target.tagName.indexOf('UNI-') === 0) {
break
}
}
return target
}
Vue.prototype.$handleEvent = function ($event) {
if ($event instanceof Event) { // 未处理的 event 对象 需要对 target 校正及包装
// 查找 uniTarget
const target = findUniTarget($event, this.$el)
$event = processEvent.call(this, $event.type, $event, {}, target || $event.target, $event.currentTarget)
}
return $event
}
require('uni-components')
{
"name": "uniapp-js-framework",
"version": "0.0.1",
"scripts": {
"scripts": {
"build:service:legacy": "npm run lint && rollup -c build/rollup.config.service.js",
"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:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js",
"build:h5:ui": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 UNI_UI=true 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",
......@@ -20,7 +22,8 @@
"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"
"release:alpha": "npm run lint:cli && lerna publish --force-publish=* --npm-tag=alpha",
"release:next": "npm run lint:cli && lerna publish --force-publish=* --npm-tag=next"
},
"dependencies": {
"base64-arraybuffer": "^0.2.0",
......
......@@ -161,7 +161,7 @@ var serviceContext = (function () {
return false
}
return page.$page.meta.isTabBar
}
}
const route = __uniRoutes.find(route => route.path.slice(1) === path);
return route && route.meta.isTabBar
} catch (e) {
......@@ -174,6 +174,10 @@ var serviceContext = (function () {
function base64ToArrayBuffer (data) {
return base64Arraybuffer_2(data)
}
function arrayBufferToBase64 (data) {
return base64Arraybuffer_1(data)
}
function callApiSync (api, args, name, alias) {
......@@ -327,7 +331,11 @@ var serviceContext = (function () {
let webview;
function setPullDownRefreshPageId (pullDownRefreshWebview) {
webview = pullDownRefreshWebview;
if (typeof pullDownRefreshWebview === 'number') {
webview = plus.webview.getWebviewById(String(pullDownRefreshWebview));
} else {
webview = pullDownRefreshWebview;
}
}
function startPullDownRefresh () {
......@@ -2021,7 +2029,7 @@ var serviceContext = (function () {
required: true
}];
const arrayBufferToBase64 = [{
const arrayBufferToBase64$1 = [{
name: 'arrayBuffer',
type: [ArrayBuffer, Uint8Array],
required: true
......@@ -2029,7 +2037,7 @@ var serviceContext = (function () {
var require_context_module_0_0 = /*#__PURE__*/Object.freeze({
base64ToArrayBuffer: base64ToArrayBuffer$1,
arrayBufferToBase64: arrayBufferToBase64
arrayBufferToBase64: arrayBufferToBase64$1
});
const canIUse = [{
......@@ -3709,13 +3717,13 @@ var serviceContext = (function () {
return base64Arraybuffer_2(str)
}
function arrayBufferToBase64$1 (buffer) {
function arrayBufferToBase64$2 (buffer) {
return base64Arraybuffer_1(buffer)
}
var require_context_module_1_0 = /*#__PURE__*/Object.freeze({
base64ToArrayBuffer: base64ToArrayBuffer$2,
arrayBufferToBase64: arrayBufferToBase64$1
arrayBufferToBase64: arrayBufferToBase64$2
});
var platformSchema = {};
......@@ -6075,53 +6083,64 @@ var serviceContext = (function () {
}
}
let socketTaskId = 0;
const socketTasks = {};
const publishStateChange$2 = (res) => {
publish('onSocketTaskStateChange', res);
};
const createSocketTaskById = function (socketTaskId, {
url,
data,
header,
method,
protocols
} = {}) {
// fixed by hxy 需要测试是否支持 arraybuffer
const socket = requireNativePlugin('webSocket');
socket.WebSocket(url, Array.isArray(protocols) ? protocols.join(',') : protocols);
// socket.binaryType = 'arraybuffer'
socketTasks[socketTaskId] = socket;
let socket;
function getSocket () {
if (socket) {
return socket
}
socket = requireNativePlugin('uni-webSocket');
socket.onopen(function (e) {
publishStateChange$2({
socketTaskId,
socketTaskId: e.id,
state: 'open'
});
});
socket.onmessage(function (e) {
const data = e.data;
publishStateChange$2({
socketTaskId,
socketTaskId: e.id,
state: 'message',
data: e.data
data: typeof data === 'object' ? base64ToArrayBuffer(data.base64) : data
});
});
socket.onerror(function (e) {
publishStateChange$2({
socketTaskId,
socketTaskId: e.id,
state: 'error',
errMsg: e.message
errMsg: e.data
});
});
socket.onclose(function (e) {
const socketTaskId = e.id;
delete socketTasks[socketTaskId];
publishStateChange$2({
socketTaskId,
state: 'close'
});
});
return socket
}
const createSocketTaskById = function (socketTaskId, {
url,
data,
header,
method,
protocols
} = {}) {
const socket = getSocket();
socket.WebSocket({
id: socketTaskId,
url,
protocol: Array.isArray(protocols) ? protocols.join(',') : protocols
});
socketTasks[socketTaskId] = socket;
return {
socketTaskId,
errMsg: 'createSocketTask:ok'
......@@ -6129,13 +6148,14 @@ var serviceContext = (function () {
};
function createSocketTask (args) {
return createSocketTaskById(++socketTaskId, args)
return createSocketTaskById(String(Date.now()), args)
}
function operateSocketTask (args) {
const {
operationType,
code,
reason,
data,
socketTaskId
} = unpack(args);
......@@ -6148,13 +6168,23 @@ var serviceContext = (function () {
switch (operationType) {
case 'send':
if (data) {
socket.send(data);
socket.send({
id: socketTaskId,
data: typeof data === 'object' ? {
'@type': 'binary',
base64: arrayBufferToBase64(data)
} : data
});
}
return {
errMsg: 'operateSocketTask:ok'
}
case 'close':
socket.close(code);
socket.close({
id: socketTaskId,
code,
reason
});
delete socketTasks[socketTaskId];
return {
errMsg: 'operateSocketTask:ok'
......
......@@ -10,19 +10,100 @@ try {
window.addEventListener('test-passive', null, opts);
} catch (e) {}
const _toString = Object.prototype.toString;
const hasOwnProperty = Object.prototype.hasOwnProperty;
function isFn (fn) {
return typeof fn === 'function'
}
function isPlainObject (obj) {
return _toString.call(obj) === '[object Object]'
}
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
const HOOKS = [
'invoke',
'success',
'fail',
'complete',
'returnValue'
];
const globalInterceptors = {};
const scopedInterceptors = {};
function mergeHook (parentVal, childVal) {
const res = childVal
? parentVal
? parentVal.concat(childVal)
: Array.isArray(childVal)
? childVal : [childVal]
: parentVal;
return res
? dedupeHooks(res)
: res
}
function dedupeHooks (hooks) {
const res = [];
for (let i = 0; i < hooks.length; i++) {
if (res.indexOf(hooks[i]) === -1) {
res.push(hooks[i]);
}
}
return res
}
function removeHook (hooks, hook) {
const index = hooks.indexOf(hook);
if (index !== -1) {
hooks.splice(index, 1);
}
}
function mergeInterceptorHook (interceptor, option) {
Object.keys(option).forEach(hook => {
if (HOOKS.indexOf(hook) !== -1 && isFn(option[hook])) {
interceptor[hook] = mergeHook(interceptor[hook], option[hook]);
}
});
}
function removeInterceptorHook (interceptor, option) {
if (!interceptor || !option) {
return
}
Object.keys(option).forEach(hook => {
if (HOOKS.indexOf(hook) !== -1 && isFn(option[hook])) {
removeHook(interceptor[hook], option[hook]);
}
});
}
function addInterceptor (method, option) {
if (typeof method === 'string' && isPlainObject(option)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), option);
} else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor (method, option) {
if (typeof method === 'string') {
if (isPlainObject(option)) {
removeInterceptorHook(scopedInterceptors[method], option);
} else {
delete scopedInterceptors[method];
}
} else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
function wrapperHook (hook) {
return function (data) {
return hook(data) || data
......@@ -119,7 +200,20 @@ function invokeApi (method, api, options, ...params) {
}
}
return api(options, ...params)
}
}
const promiseInterceptor = {
returnValue (res) {
if (!isPromise(res)) {
return res
}
return res.then(res => {
return res[1]
}).catch(res => {
return res[0]
})
}
};
const SYNC_API_RE =
/^\$|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
......@@ -667,6 +761,10 @@ function createLivePusherContext (id, vm) {
return new LivePusherContext(id, elm)
}
const interceptors = {
promiseInterceptor
};
var apis = /*#__PURE__*/Object.freeze({
......@@ -677,7 +775,10 @@ var apis = /*#__PURE__*/Object.freeze({
$emit: $emit,
createMapContext: createMapContext,
createVideoContext: createVideoContext,
createLivePusherContext: createLivePusherContext
createLivePusherContext: createLivePusherContext,
interceptors: interceptors,
addInterceptor: addInterceptor,
removeInterceptor: removeInterceptor
});
function initUni (uni, nvue, plus, BroadcastChannel) {
......@@ -710,7 +811,8 @@ function initUni (uni, nvue, plus, BroadcastChannel) {
return promisify(name, uni[name])
},
set (target, name, value) {
target[name] = value;
target[name] = value;
return true
}
})
}
......@@ -760,8 +862,8 @@ function createInstanceContext () {
getUniEmitter () {
return getGlobalUniEmitter()
},
getCurrentPages () {
return getGlobalCurrentPages()
getCurrentPages (returnAll) {
return getGlobalCurrentPages(returnAll)
}
}
}
......
此差异已折叠。
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-23020190919001",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-app-plus-nvue"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
{
"name": "@dcloudio/uni-app-plus",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-app-plus",
"version": "2.0.0-23020190919001",
"description": "uni-app app-plus",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-app-plus"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
const semver = require('semver')
let sassLoaderVersion
try {
sassLoaderVersion = semver.major(require('sass-loader/package.json').version)
} catch (e) {}
const SCSS =
`
$uni-color-primary: #007aff;
......@@ -100,7 +107,9 @@ $uni-font-size-subtitle: 36rpx
$uni-color-paragraph: #3F536E // 文章段落颜色
$uni-font-size-paragraph: 30rpx
`
module.exports = {
SCSS,
SASS
SASS,
sassLoaderVersion
}
{
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-23020190919001",
"description": "uni-cli-shared",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-cli-shared"
},
"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": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
{
"name": "@dcloudio/uni-h5-ui",
"version": "2.0.0-23020190919001",
"description": "uni-app h5 ui",
"main": "dist/index.umd.min.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-h5-ui"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
此差异已折叠。
{
"name": "@dcloudio/uni-h5",
"version": "2.0.0-alpha-22420190823022",
"version": "2.0.0-23020190919001",
"description": "uni-app h5",
"main": "dist/index.umd.min.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-h5"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
......@@ -13,5 +18,5 @@
"intersection-observer": "^0.7.0",
"safe-area-insets": "^1.4.1"
},
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
{
"name": "@dcloudio/uni-mp-alipay",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-mp-alipay",
"version": "2.0.0-23020190919001",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-alipay"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
{
"name": "@dcloudio/uni-mp-baidu",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-mp-baidu",
"version": "2.0.0-23020190919001",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-baidu"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
{
"name": "@dcloudio/uni-mp-qq",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-mp-qq",
"version": "2.0.0-23020190919001",
"description": "uni-app mp-qq",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-qq"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "2.0.0-alpha-22420190823022",
"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": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-mp-toutiao",
"version": "2.0.0-23020190919001",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-toutiao"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
{
"name": "@dcloudio/uni-mp-weixin",
"version": "2.0.0-alpha-22420190823022",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-mp-weixin",
"version": "2.0.0-23020190919001",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-mp-weixin"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
import { version } from '../package.json';
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.net.cn/uni/stat';
const STAT_H5_URL = 'https://tongji.dcloud.net.cn/uni/stat.gif';
const PAGE_PVER_TIME = 1800;
const APP_PVER_TIME = 300;
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif';
const PAGE_PVER_TIME = 1800;
const APP_PVER_TIME = 300;
const OPERATING_TIME = 10;
const UUID_KEY = '__DC_STAT_UUID';
......@@ -647,8 +647,8 @@ class Util {
// },
data: optionsData,
success: () => {
// if (process.env.NODE_ENV === 'development') {
// console.log('stat request success');
// if (process.env.NODE_ENV === 'development') {
// console.log('stat request success');
// }
},
fail: (e) => {
......@@ -863,10 +863,14 @@ const lifecycle = {
function main() {
const Vue = require('vue');
(Vue.default || Vue).mixin(lifecycle);
uni.report = function(type, options) {
stat.sendEvent(type, options);
};
if (process.env.NODE_ENV === 'development') {
uni.report = function(type, options) {};
}else{
(Vue.default || Vue).mixin(lifecycle);
uni.report = function(type, options) {
stat.sendEvent(type, options);
};
}
}
main();
{
"name": "@dcloudio/uni-stat",
"version": "2.0.0-alpha-22420190823022",
"version": "2.0.0-23020190919001",
"description": "",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-stat"
},
"scripts": {
"dev": "NODE_ENV=development rollup -w -c rollup.config.js",
"build": "NODE_ENV=production rollup -c rollup.config.js"
......@@ -29,5 +34,5 @@
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2"
},
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
import {
version
} from '../package.json'
export const STAT_VERSION = version
export const STAT_URL = 'https://tongji.dcloud.net.cn/uni/stat'
export const STAT_H5_URL = 'https://tongji.dcloud.net.cn/uni/stat.gif'
export const STAT_KEY = 'qkTHEIegZGcL5iy3'
export const PAGE_PVER_TIME = 1800
export const APP_PVER_TIME = 300
export const OPERATING_TIME = 10
export const STAT_VERSION = version
export const STAT_URL = 'https://tongji.dcloud.io/uni/stat'
export const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif'
export const STAT_KEY = 'qkTHEIegZGcL5iy3'
export const PAGE_PVER_TIME = 1800
export const APP_PVER_TIME = 300
export const OPERATING_TIME = 10
......@@ -36,10 +36,14 @@ const lifecycle = {
function main() {
const Vue = require('vue');
(Vue.default || Vue).mixin(lifecycle);
uni.report = function(type, options) {
stat.sendEvent(type, options);
};
if (process.env.NODE_ENV === 'development') {
uni.report = function(type, options) {};
}else{
(Vue.default || Vue).mixin(lifecycle);
uni.report = function(type, options) {
stat.sendEvent(type, options);
};
}
}
main();
......@@ -382,8 +382,8 @@ class Util {
// },
data: optionsData,
success: () => {
// if (process.env.NODE_ENV === 'development') {
// console.log('stat request success');
// if (process.env.NODE_ENV === 'development') {
// console.log('stat request success');
// }
},
fail: (e) => {
......
{
"name": "@dcloudio/uni-template-compiler",
"version": "2.0.0-alpha-22420190823022",
"description": "uni-template-compiler",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"@babel/parser": "^7.3.3",
"@babel/traverse": "^7.3.3",
"@babel/types": "^7.3.3",
"vue-template-compiler": "^2.6.10"
},
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/uni-template-compiler",
"version": "2.0.0-23020190919001",
"description": "uni-template-compiler",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-template-compiler"
},
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"@babel/parser": "^7.3.3",
"@babel/traverse": "^7.3.3",
"@babel/types": "^7.3.3",
"vue-template-compiler": "^2.6.10"
},
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
const fs = require('fs')
const path = require('path')
const {
// jsPreprocessOptions,
getPlatformScss,
getPlatformSass,
nvueCssPreprocessOptions
// htmlPreprocessOptions
} = require('@dcloudio/uni-cli-shared')
const {
sassLoaderVersion
} = require('@dcloudio/uni-cli-shared/lib/scss')
const nvueStyleLoader = {
loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style'
}
......@@ -17,19 +24,49 @@ const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: false,
parser: require('postcss-comment'),
plugins: [
require('postcss-import'),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
parser: require('postcss-comment'),
plugins: [
require('postcss-import'),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
}
}
// sass 全局变量
const isSass = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'uni.sass'))
const isScss = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'uni.scss'))
let sassData = isSass ? getPlatformSass() : getPlatformScss()
if (isSass) {
sassData = `@import "@/uni.sass"`
} else if (isScss) {
sassData = `${sassData}
@import "@/uni.scss";`
}
const scssLoader = {
loader: 'sass-loader',
options: {
sourceMap: false
}
}
const sassLoader = {
loader: 'sass-loader',
options: {
sourceMap: false,
data: ''
sourceMap: false
}
}
if (sassLoaderVersion < 8) {
scssLoader.options.data = sassData
sassLoader.options.data = sassData
sassLoader.options.indentedSyntax = true
} else {
scssLoader.options.prependData = sassData
sassLoader.options.prependData = sassData
sassLoader.options.sassOptions = {
indentedSyntax: true
}
}
......@@ -48,11 +85,11 @@ const stylusLoader = {
}
}
function createOneOf (preLoader) {
function createOneOf (preLoader) {
const use = [
nvueStyleLoader,
preprocessLoader
]
]
use.push(postcssLoader)
if (preLoader) {
use.push(preLoader)
......@@ -74,7 +111,7 @@ module.exports = [{
oneOf: createOneOf()
}, {
test: /\.scss$/,
oneOf: createOneOf(sassLoader)
oneOf: createOneOf(scssLoader)
}, {
test: /\.sass$/,
oneOf: createOneOf(sassLoader)
......
function resolve (module) {
try {
return require.resolve(module)
} catch (e) {}
return module
}
exports.cssLoaders = function (options) {
options = options || {}
const cssLoader = {
loader: resolve('css-loader'),
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: resolve('postcss-loader'),
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
const generateLoaders = (loader, loaderOptions) => {
let loaders = options.useVue ? [cssLoader] : []
if (options.usePostCSS) {
loaders.push(postcssLoader)
}
if (loader) {
loaders.push({
loader: resolve(loader + '-loader'),
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
if (options.useVue) {
return [resolve('vue-style-loader')].concat(loaders)
} else {
return loaders
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
less: generateLoaders('less'),
sass: generateLoaders('sass', {
indentedSyntax: true
}),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
......@@ -15,6 +15,7 @@ const WebpackErrorsPlugin = require('@dcloudio/vue-cli-plugin-uni/packages/webpa
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new')
const onErrors = require('@dcloudio/vue-cli-plugin-uni/util/on-errors')
const onWarnings = require('@dcloudio/vue-cli-plugin-uni/util/on-warnings')
const cssLoaders = require('./css-loader.conf')
const vueLoaderOptions = require('./vue-loader.conf')
......@@ -65,7 +66,8 @@ const plugins = [
}),
new webpack.ProvidePlugin(provide),
new WebpackErrorsPlugin({
onErrors
onErrors,
onWarnings
}),
new WebpackAppPlusNVuePlugin()
]
......@@ -100,7 +102,7 @@ const rules = [{
{
test: /\.nvue(\?[^?]+)?$/,
use: [{
loader: 'vue-loader',
loader: path.resolve(__dirname, '../packages/vue-loader'),
options: vueLoaderOptions
}],
exclude: excludeModuleReg
......@@ -108,7 +110,7 @@ const rules = [{
{
test: /\.vue(\?[^?]+)?$/,
use: [{
loader: 'vue-loader',
loader: path.resolve(__dirname, '../packages/vue-loader'),
options: vueLoaderOptions
}],
exclude: excludeModuleReg
......@@ -146,6 +148,15 @@ if (process.env.UNI_USING_NVUE_COMPILER) {
}]
})
}
rules.unshift({
resourceQuery: function (query) {
return query.indexOf('vue&type=template') !== -1 && query.indexOf('mpType=page') === -1
},
use: [{
loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle'
}]
})
if (process.env.UNI_USING_NATIVE) {
plugins.push(new WebpackUniMPPlugin())
plugins.push(new CopyWebpackPlugin([{
......@@ -184,6 +195,9 @@ module.exports = function () {
externals: {
'vue': 'Vue'
},
performance: {
hints: false
},
optimization: {
namedModules: false
},
......@@ -198,6 +212,9 @@ module.exports = function () {
'@': process.env.UNI_INPUT_DIR,
'uni-pages': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
'@dcloudio/uni-stat': require.resolve('@dcloudio/uni-stat'),
'uni-app-style': path.resolve(process.env.UNI_INPUT_DIR, getNVueMainEntry()) + '?' + JSON.stringify({
type: 'appStyle'
}),
'uni-stat-config': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json') +
'?' +
JSON.stringify({
......@@ -205,7 +222,7 @@ module.exports = function () {
})
},
modules: [
'node_modules',
'node_modules',
path.resolve(process.env.UNI_CLI_CONTEXT, 'node_modules'),
path.resolve(process.env.UNI_INPUT_DIR, 'node_modules')
]
......
......@@ -9,9 +9,16 @@ const {
// override
moduleAlias.addAlias('weex-styler', path.resolve(__dirname, 'packages/weex-styler'))
moduleAlias.addAlias('weex-template-compiler', path.resolve(__dirname, 'packages/weex-template-compiler'))
moduleAlias.addAlias('./compileTemplate', path.resolve(__dirname,
'packages/webpack-uni-nvue-loader/lib/compileTemplate'))
moduleAlias.addAlias('./codegen/styleInjection', path.resolve(__dirname,
'packages/webpack-uni-nvue-loader/lib/styleInjection'))
moduleAlias.addAlias('./templateLoader', (fromPath, request, alias) => {
if (fromPath.indexOf('vue-loader') !== -1) {
return path.resolve(__dirname, 'packages/webpack-uni-nvue-loader/lib/templateLoader')
}
return request
})
if (isInHBuilderX) {
moduleAlias.addAlias('typescript', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
'compile-typescript/node_modules/typescript'))
......
{
"name": "@dcloudio/vue-cli-plugin-hbuilderx",
"version": "2.0.0-alpha-22420190823022",
"description": "HBuilderX plugin for vue-cli 3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"acorn": "^5.2.1",
"css": "~2.2.1",
"escodegen": "^1.8.1"
},
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/vue-cli-plugin-hbuilderx",
"version": "2.0.0-23020190919001",
"description": "HBuilderX plugin for vue-cli 3",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/vue-cli-plugin-hbuilderx"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"acorn": "^5.2.1",
"css": "~2.2.1",
"escodegen": "^1.8.1"
},
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
const path = require('path')
const hash = require('hash-sum')
const qs = require('querystring')
const plugin = require('vue-loader/lib/plugin')
const selectBlock = require('vue-loader/lib/select')
const loaderUtils = require('loader-utils')
const { attrsToQuery } = require('vue-loader/lib/codegen/utils')
const { parse } = require('@vue/component-compiler-utils')
const genStylesCode = require('../webpack-uni-nvue-loader/lib/styleInjection')
const { genHotReloadCode } = require('vue-loader/lib/codegen/hotReload')
const genCustomBlocksCode = require('vue-loader/lib/codegen/customBlocks')
const componentNormalizerPath = require.resolve('vue-loader/lib/runtime/componentNormalizer')
const { NS } = require('vue-loader/lib/plugin')
let errorEmitted = false
function loadTemplateCompiler (loaderContext) {
try {
return require('vue-template-compiler')
} catch (e) {
if (/version mismatch/.test(e.toString())) {
loaderContext.emitError(e)
} else {
loaderContext.emitError(new Error(
`[vue-loader] vue-template-compiler must be installed as a peer dependency, ` +
`or a compatible compiler implementation must be passed via options.`
))
}
}
}
function hasRecyclable (template) {
return !!(template && template.attrs && template.attrs.recyclable)
}
module.exports = function (source) {
const loaderContext = this
if (!errorEmitted && !loaderContext['thread-loader'] && !loaderContext[NS]) {
loaderContext.emitError(new Error(
`vue-loader was used without the corresponding plugin. ` +
`Make sure to include VueLoaderPlugin in your webpack config.`
))
errorEmitted = true
}
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
const {
target,
request,
minimize,
sourceMap,
rootContext,
resourcePath,
resourceQuery
} = loaderContext
const rawQuery = resourceQuery.slice(1)
const inheritQuery = `&${rawQuery}`
const incomingQuery = qs.parse(rawQuery)
const options = loaderUtils.getOptions(loaderContext) || {}
const isServer = target === 'node'
const isShadow = !!options.shadowMode
const isProduction = options.productionMode || minimize || process.env.NODE_ENV === 'production'
const filename = path.basename(resourcePath)
const context = rootContext || process.cwd()
const sourceRoot = path.dirname(path.relative(context, resourcePath))
const descriptor = parse({
source,
compiler: options.compiler || loadTemplateCompiler(loaderContext),
filename,
sourceRoot,
needMap: sourceMap
})
// if the query has a type field, this is a language block request
// e.g. foo.vue?type=template&id=xxxxx
// and we will return early
if (incomingQuery.type) {
return selectBlock(
descriptor,
loaderContext,
incomingQuery,
!!options.appendExtension
)
}
// module id for scoped CSS & hot-reload
const rawShortFilePath = path
.relative(context, resourcePath)
.replace(/^(\.\.[\/\\])+/, '')
const shortFilePath = rawShortFilePath.replace(/\\/g, '/') + resourceQuery
const id = hash(
isProduction
? (shortFilePath + '\n' + source)
: shortFilePath
)
// feature information
const hasScoped = descriptor.styles.some(s => s.scoped)
const hasFunctional = descriptor.template && descriptor.template.attrs.functional
const needsHotReload = (
!isServer &&
!isProduction &&
(descriptor.script || descriptor.template) &&
options.hotReload !== false
)
// template
let templateImport = `var render, staticRenderFns`
let templateRequest
const recyclable = hasRecyclable(descriptor.template) // fixed by xxxxxx
if (descriptor.template) {
const src = descriptor.template.src || resourcePath
const idQuery = `&id=${id}`
const scopedQuery = hasScoped ? `&scoped=true` : ``
const attrsQuery = attrsToQuery(descriptor.template.attrs)
const query = `?vue&type=template${idQuery}${scopedQuery}${attrsQuery}${inheritQuery}`
const request = templateRequest = stringifyRequest(src + query)
if(recyclable){ // fixed by xxxxxx
templateImport = `import { render, staticRenderFns, recyclableRender } from ${request}`
} else {
templateImport = `import { render, staticRenderFns } from ${request}`
}
}
// script
let scriptImport = `var script = {}`
if (descriptor.script) {
const src = descriptor.script.src || resourcePath
const attrsQuery = attrsToQuery(descriptor.script.attrs, 'js')
const query = `?vue&type=script${attrsQuery}${inheritQuery}`
const request = stringifyRequest(src + query)
scriptImport = (
`import script from ${request}\n` +
`export * from ${request}` // support named exports
)
}
// styles
let stylesCode = ``
if (descriptor.styles.length) {
stylesCode = genStylesCode(
loaderContext,
descriptor.styles,
id,
resourcePath,
stringifyRequest,
needsHotReload,
isServer || isShadow // needs explicit injection?
)
}
let code = `
${templateImport}
${scriptImport}
${stylesCode}
/* normalize component */
import normalizer from ${stringifyRequest(`!${componentNormalizerPath}`)}
var component = normalizer(
script,
render,
staticRenderFns,
${hasFunctional ? `true` : `false`},
${`null`},
${hasScoped ? JSON.stringify(id) : `null`},
${isServer ? JSON.stringify(hash(request)) : `null`}
${isShadow ? `,true` : ``}
)
`.trim() + `\n`
if (descriptor.customBlocks && descriptor.customBlocks.length) {
code += genCustomBlocksCode(
descriptor.customBlocks,
resourcePath,
resourceQuery,
stringifyRequest
)
}
if (needsHotReload) {
code += `\n` + genHotReloadCode(id, hasFunctional, templateRequest)
}
if(/injectStyles/.test(stylesCode)){// fixed by xxxxxx
code +=`\ninjectStyles.call(component)`
}
// Expose filename. This is used by the devtools and Vue runtime warnings.
if (!isProduction) {
// Expose the file's full path in development, so that it can be opened
// from the devtools.
code += `\ncomponent.options.__file = ${JSON.stringify(rawShortFilePath.replace(/\\/g, '/'))}`
} else if (options.exposeFilename) {
// Libraies can opt-in to expose their components' filenames in production builds.
// For security reasons, only expose the file's basename in production.
code += `\ncomponent.options.__file = ${JSON.stringify(filename)}`
}
if(recyclable){
code += `\nrecyclableRender && (component.options["@render"] = recyclableRender)` // fixed by xxxxxx
}
code += `\nexport default component.exports`
// console.log(code)
return code
}
module.exports.VueLoaderPlugin = plugin
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assetUrl_1 = __importDefault(require("@vue/component-compiler-utils/dist/templateCompilerModules/assetUrl"));
const srcset_1 = __importDefault(require("@vue/component-compiler-utils/dist/templateCompilerModules/srcset"));
const consolidate = require('consolidate');
const transpile = require('vue-template-es2015-compiler');
function compileTemplate(options) {
const { preprocessLang } = options;
const preprocessor = preprocessLang && consolidate[preprocessLang];
if (preprocessor) {
return actuallyCompile(Object.assign({}, options, {
source: preprocess(options, preprocessor)
}));
}
else if (preprocessLang) {
return {
code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
source: options.source,
tips: [
`Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
],
errors: [
`Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
]
};
}
else {
return actuallyCompile(options);
}
}
exports.compileTemplate = compileTemplate;
function preprocess(options, preprocessor) {
const { source, filename, preprocessOptions } = options;
const finalPreprocessOptions = Object.assign({
filename
}, preprocessOptions);
// Consolidate exposes a callback based API, but the callback is in fact
// called synchronously for most templating engines. In our case, we have to
// expose a synchronous API so that it is usable in Jest transforms (which
// have to be sync because they are applied via Node.js require hooks)
let res, err;
preprocessor.render(source, finalPreprocessOptions, (_err, _res) => {
if (_err)
err = _err;
res = _res;
});
if (err)
throw err;
return res;
}
function actuallyCompile(options) {
const { source, compiler, compilerOptions = {}, transpileOptions = {}, transformAssetUrls, isProduction = process.env.NODE_ENV === 'production', isFunctional = false, optimizeSSR = false, prettify = true } = options;
const compile = optimizeSSR && compiler.ssrCompile ? compiler.ssrCompile : compiler.compile;
let finalCompilerOptions = compilerOptions;
if (transformAssetUrls) {
const builtInModules = [
transformAssetUrls === true
? assetUrl_1.default()
: assetUrl_1.default(transformAssetUrls),
srcset_1.default()
];
finalCompilerOptions = Object.assign({}, compilerOptions, {
modules: [...builtInModules, ...(compilerOptions.modules || [])]
});
}
const { render, staticRenderFns, tips, errors, '@render': recyclableRender } = compile(source, finalCompilerOptions);
if (errors && errors.length) {
return {
code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
source,
tips,
errors
};
}
else {
const finalTranspileOptions = Object.assign({}, transpileOptions, {
transforms: Object.assign({}, transpileOptions.transforms, {
stripWithFunctional: isFunctional
})
});
const toFunction = (code) => {
return `function (${isFunctional ? `_h,_vm` : ``}) {${code}}`;
};
// transpile code with vue-template-es2015-compiler, which is a forked
// version of Buble that applies ES2015 transforms + stripping `with` usage
let code = transpile(`var __render__ = ${toFunction(render)}\n` +
(recyclableRender ? (`var __recyclableRender__ = ${toFunction(recyclableRender)}\n`) : '') +
`var __staticRenderFns__ = [${staticRenderFns.map(toFunction)}]`, finalTranspileOptions) + `\n`;
// #23 we use __render__ to avoid `render` not being prefixed by the
// transpiler when stripping with, but revert it back to `render` to
// maintain backwards compat
code = code.replace(/\s__(render|recyclableRender|staticRenderFns)__\s/g, ' $1 ');
if (!isProduction) {
// mark with stripped (this enables Vue to use correct runtime proxy
// detection)
code += `render._withStripped = true`;
if (prettify) {
code = require('prettier').format(code, {
semi: false,
parser: 'babel'
});
}
}
return {
code,
source,
tips,
errors
};
}
}
......@@ -28,7 +28,7 @@ function getAppStyleCode(stringifyRequest) {
if (!process.env.UNI_USING_NVUE_COMPILER) {
return ''
}
let code = 'App.appStyle = {}\n'
let code = 'Vue.prototype.__$appStyle__ = {}\n'
let styles = []
try {
if (fs.existsSync(appVuePath)) {
......@@ -37,7 +37,7 @@ function getAppStyleCode(stringifyRequest) {
} catch (e) {}
styles.forEach((style, index) => {
code = code +
`Vue.prototype.__merge_style(require(${genStyleRequest(style,index,stringifyRequest)}).default,App.appStyle)\n`
`Vue.prototype.__merge_style && Vue.prototype.__merge_style(require(${genStyleRequest(style,index,stringifyRequest)}).default,Vue.prototype.__$appStyle__)\n`
})
return code
}
......@@ -51,22 +51,25 @@ module.exports = function(content) {
if (this.resourceQuery) {
const params = loaderUtils.parseQuery(this.resourceQuery)
if (params && params.page) {
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
params.page = decodeURIComponent(params.page)
// import Vue from 'vue'是为了触发 vendor 合并
return `
${statCode}
import App from './${normalizePath(params.page)}.nvue?mpType=page'
App.mpType = 'page'
App.route = '${params.page}'
App.el = '#root'
${getAppStyleCode(stringifyRequest)}
new Vue(App)
`
if (params) {
if (params.page) {
params.page = decodeURIComponent(params.page)
// import Vue from 'vue'是为了触发 vendor 合并
return `
${statCode}
import 'uni-app-style'
import App from './${normalizePath(params.page)}.nvue?mpType=page'
App.mpType = 'page'
App.route = '${params.page}'
App.el = '#root'
new Vue(App)
`
} else if (params.type === 'appStyle') {
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
return `${getAppStyleCode(stringifyRequest)}`
}
}
}
return statCode + content
}
......@@ -86,21 +86,21 @@ module.exports = function genStyleInjectionCode (
}
})
} else {
styleInjectionCode = `if(!this.$options.style){
this.$options.style = {}
styleInjectionCode = `if(!this.options.style){
this.options.style = {}
}
if(this.__merge_style && this.$root && this.$root.$options.appStyle){
this.__merge_style(this.$root.$options.appStyle)
if(Vue.prototype.__merge_style && Vue.prototype.__$appStyle__){
Vue.prototype.__merge_style(Vue.prototype.__$appStyle__, this.options.style)
}
`
styles.forEach((style, i) => {
if (isNotEmptyStyle(style)) {
const request = genStyleRequest(style, i)
styleInjectionCode += (
`if(this.__merge_style){
this.__merge_style(require(${request}).default)
`if(Vue.prototype.__merge_style){
Vue.prototype.__merge_style(require(${request}).default, this.options.style)
}else{
Object.assign(this.$options.style,require(${request}).default)
Object.assign(this.options.style,require(${request}).default)
}\n`//fixed by xxxxxx 简单处理,与 weex-vue-loader 保持一致
//`var style${i} = require(${request})\n` +
//`if (style${i}.__inject__) style${i}.__inject__(context)\n`
......@@ -119,8 +119,7 @@ ${styleImportsCode}
${hasCSSModules && needsHotReload ? `var cssModules = {}` : ``}
${needsHotReload ? `var disposed = false` : ``}
function injectStyles (context) {
${needsHotReload ? `if (disposed) return` : ``}
function injectStyles () {
${styleInjectionCode}
}
......
module.exports = function(content) {
this.cacheable && this.cacheable()
this.cacheable && this.cacheable()
if (content.indexOf('recycle-list') === -1) {
return `<scroll-view :scroll-y="true" :enableBackToTop="true" bubble="true" style="flex-direction:column">${content}</scroll-view>`
}
return content
}
const loaderUtils = require('loader-utils')
module.exports = function(content) {
this.cacheable && this.cacheable()
const vueLoaderOptions = this.loaders[0]
if (vueLoaderOptions.ident === 'vue-loader-options') {
const params = loaderUtils.parseQuery(this.resourceQuery)
if (params.recyclable) {
Object.assign(vueLoaderOptions.options.compilerOptions, {
recyclable: true
})
}
} else {
throw new Error('vue-loader-options parse error')
}
return content
}
const qs = require('querystring')
const loaderUtils = require('loader-utils')
const { compileTemplate } = require('@vue/component-compiler-utils')
// Loader that compiles raw template into JavaScript functions.
// This is injected by the global pitcher (../pitch) for template
// selection requests initiated from vue files.
module.exports = function (source) {
const loaderContext = this
const query = qs.parse(this.resourceQuery.slice(1))
// although this is not the main vue-loader, we can get access to the same
// vue-loader options because we've set an ident in the plugin and used that
// ident to create the request for this loader in the pitcher.
const options = loaderUtils.getOptions(loaderContext) || {}
const { id } = query
const isServer = loaderContext.target === 'node'
const isProduction = options.productionMode || loaderContext.minimize || process.env.NODE_ENV === 'production'
const isFunctional = query.functional
// allow using custom compiler via options
const compiler = options.compiler || require('vue-template-compiler')
const compilerOptions = Object.assign({
outputSourceRange: true
}, options.compilerOptions, {
scopeId: query.scoped ? `data-v-${id}` : null,
comments: query.comments
})
// for vue-component-compiler
const finalOptions = {
source,
filename: this.resourcePath,
compiler,
compilerOptions,
// allow customizing behavior of vue-template-es2015-compiler
transpileOptions: options.transpileOptions,
transformAssetUrls: options.transformAssetUrls || true,
isProduction,
isFunctional,
optimizeSSR: isServer && options.optimizeSSR !== false,
prettify: options.prettify
}
const compiled = compileTemplate(finalOptions)
// tips
if (compiled.tips && compiled.tips.length) {
compiled.tips.forEach(tip => {
loaderContext.emitWarning(typeof tip === 'object' ? tip.msg : tip)
})
}
// errors
if (compiled.errors && compiled.errors.length) {
// 2.6 compiler outputs errors as objects with range
if (compiler.generateCodeFrame && finalOptions.compilerOptions.outputSourceRange) {
// TODO account for line offset in case template isn't placed at top
// of the file
loaderContext.emitError(
`\n\n Errors compiling template:\n\n` +
compiled.errors.map(({ msg, start, end }) => {
const frame = compiler.generateCodeFrame(source, start, end)
return ` ${msg}\n\n${pad(frame)}`
}).join(`\n\n`) +
'\n'
)
} else {
loaderContext.emitError(
`\n Error compiling template:\n${pad(compiled.source)}\n` +
compiled.errors.map(e => ` - ${e}`).join('\n') +
'\n'
)
}
}
const { code } = compiled
if(query.recyclable) {// fixed by xxxxxx
return code + `\nexport { render, recyclableRender, staticRenderFns }`
}
// finish with ESM exports
return code + `\nexport { render, staticRenderFns }`
}
function pad (source) {
return source
.split(/\r?\n/)
.map(line => ` ${line}`)
.join('\n')
}
......@@ -613,7 +613,7 @@ function parseComponent (
return cumulated
}, {})
};// fixed by xxxxxx
if (isSpecialTag(tag) && !isCustomBlock(currentBlock.attrs.lang || '')) {
if (isSpecialTag(tag) && !isCustomBlock(String(currentBlock.attrs.lang || ''))) {
checkAttrs(currentBlock, attrs);
if (tag === 'style') {
sfc.styles.push(currentBlock);
......@@ -671,7 +671,7 @@ function parseComponent (
} else {
var offset = content.slice(0, block.start).split(splitRE).length;
var lang = block.attrs && block.attrs.lang; // fixed by xxxxxx
var padChar = block.type === 'script' && !block.lang && !isCustomBlock(lang || '')
var padChar = block.type === 'script' && !block.lang && !isCustomBlock(String(lang || ''))
? '//\n'
: '\n';
return Array(offset).join(padChar)
......@@ -2386,67 +2386,146 @@ function isDirectChildOfTemplateFor (node) {
/* */
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// import { warn } from 'core/util/index'
// KeyboardEvent.keyCode aliases
var keyCodes = {
esc: 27,
tab: 9,
enter: 13,
space: 32,
up: 38,
left: 37,
right: 39,
down: 40,
'delete': [8, 46]
};
// this will be preserved during build
// $flow-disable-line
var acorn = require('acorn'); // $flow-disable-line
var walk = require('acorn/dist/walk'); // $flow-disable-line
var escodegen = require('escodegen');
// KeyboardEvent.key aliases
var keyNames = {
// #7880: IE11 and Edge use `Esc` for Escape key name.
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
// #9112: IE11 uses `Spacebar` for Space key name.
space: [' ', 'Spacebar'],
// #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
// #9112: IE11 uses `Del` for Delete key name.
'delete': ['Backspace', 'Delete', 'Del']
};
var functionCallRE = /^\s*([A-Za-z_$0-9\['\."\]]+)*\s*\(\s*(([A-Za-z_$0-9\['\."\]]+)?(\s*,\s*([A-Za-z_$0-9\['\."\]]+))*)\s*\)$/;
// #4868: modifiers that prevent the execution of the listener
// need to explicitly return null so that we can determine whether to remove
// the listener for .once
var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
var modifierCode = {
stop: '$event.stopPropagation();',
prevent: '$event.preventDefault();',
self: genGuard("$event.target !== $event.currentTarget"),
ctrl: genGuard("!$event.ctrlKey"),
shift: genGuard("!$event.shiftKey"),
alt: genGuard("!$event.altKey"),
meta: genGuard("!$event.metaKey"),
left: genGuard("'button' in $event && $event.button !== 0"),
middle: genGuard("'button' in $event && $event.button !== 1"),
right: genGuard("'button' in $event && $event.button !== 2")
};
function nodeToBinding (node) {
switch (node.type) {
case 'Literal': return node.value
case 'Identifier':
case 'UnaryExpression':
case 'BinaryExpression':
case 'LogicalExpression':
case 'ConditionalExpression':
case 'MemberExpression': return { '@binding': escodegen.generate(node) }
case 'ArrayExpression': return node.elements.map(function (_) { return nodeToBinding(_); })
case 'ObjectExpression': {
var object = {};
node.properties.forEach(function (prop) {
if (!prop.key || prop.key.type !== 'Identifier') {
return
}
var key = escodegen.generate(prop.key);
var value = nodeToBinding(prop.value);
if (key && value) {
object[key] = value;
}
});
return object
}
default: {
// warn(`Not support ${node.type}: "${escodegen.generate(node)}"`)
return ''
}
}
}
function generateBinding (exp) {
if (exp && typeof exp === 'string') {
var ast = null;
try {
ast = acorn.parse(("(" + exp + ")"));
} catch (e) {
// warn(`Failed to parse the expression: "${exp}"`)
return ''
}
var output = '';
walk.simple(ast, {
Expression: function Expression (node) {
output = nodeToBinding(node);
}
});
return output
}
}
/* */
// this will be preserved during build
// $flow-disable-line
var transpile = require('vue-template-es2015-compiler');
// Generate handler code with binding params for Weex platform
/* istanbul ignore next */
function genWeexHandlerWithParams (handlerCode) {
var match = functionCallRE.exec(handlerCode);
if (!match) {
return ''
}
var handlerExp = match[1];
var params = match[2].split(/\s*,\s*/);
var exps = params.filter(function (exp) { return simplePathRE.test(exp) && exp !== '$event'; });
var bindings = exps.map(function (exp) { return generateBinding(exp); });
var args = exps.map(function (exp, index) {
var key = "$$_" + (index + 1);
for (var i = 0; i < params.length; ++i) {
if (params[i] === exp) {
params[i] = key;
}
}
return key
});
args.push('$event');
return ("{\n handler: function (" + (args.join(',')) + ") {\n " + handlerExp + "(" + (params.join(',')) + ");\n },\n params:" + (JSON.stringify(bindings)) + "\n }")
}
function genWeexHandler (handler, options) {
var code = handler.value;
var isMethodPath = simplePathRE.test(code);
var isFunctionExpression = fnExpRE.test(code);
var isFunctionCall = functionCallRE.test(code);
// TODO: binding this to recyclable event handlers
if (options.recyclable) {
if (isMethodPath) {
return ("function($event){this." + code + "()}")
}
if (isFunctionExpression && options.warn) {
options.warn(("Function expression is not supported in recyclable components: " + code + "."));
}
if (isFunctionCall) {
return ("function($event){this." + code + "}")
}
// inline statement
code = transpile(("with(this){" + code + "}"), {
transforms: { stripWith: true }
});
}
if (isMethodPath || isFunctionExpression) {
return code
}
/* istanbul ignore if */
if (handler.params) {
return genWeexHandlerWithParams(handler.value)
}
// inline statement
return ("function($event){" + code + "}")
}
/* */
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
function genHandlers (
events,
isNative
isNative,
options
) {
var prefix = isNative ? 'nativeOn:' : 'on:';
var staticHandlers = "";
var dynamicHandlers = "";
for (var name in events) {
var handlerCode = genHandler(events[name]);
var handlerCode = genHandler(events[name], options);
if (events[name] && events[name].dynamic) {
dynamicHandlers += name + "," + handlerCode + ",";
} else {
......@@ -2461,116 +2540,23 @@ function genHandlers (
}
}
// Generate handler code with binding params on Weex
/* istanbul ignore next */
function genWeexHandler (params, handlerCode) {
var innerHandlerCode = handlerCode;
var exps = params.filter(function (exp) { return simplePathRE.test(exp) && exp !== '$event'; });
var bindings = exps.map(function (exp) { return ({ '@binding': exp }); });
var args = exps.map(function (exp, i) {
var key = "$_" + (i + 1);
innerHandlerCode = innerHandlerCode.replace(exp, key);
return key
});
args.push('$event');
return '{\n' +
"handler:function(" + (args.join(',')) + "){" + innerHandlerCode + "},\n" +
"params:" + (JSON.stringify(bindings)) + "\n" +
'}'
}
function genHandler (handler) {
function genHandler (handler, options) {
if (!handler) {
return 'function(){}'
}
if (Array.isArray(handler)) {
return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
return ("[" + (handler.map(function (handler) { return genHandler(handler, options); }).join(',')) + "]")
}
var isMethodPath = simplePathRE.test(handler.value);
var isFunctionExpression = fnExpRE.test(handler.value);
var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
return handler.value
}
/* istanbul ignore if */
if (handler.params) {
return genWeexHandler(handler.params, handler.value)
}
return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
} else {
var code = '';
var genModifierCode = '';
var keys = [];
for (var key in handler.modifiers) {
if (modifierCode[key]) {
genModifierCode += modifierCode[key];
// left/right
if (keyCodes[key]) {
keys.push(key);
}
} else if (key === 'exact') {
var modifiers = (handler.modifiers);
genModifierCode += genGuard(
['ctrl', 'shift', 'alt', 'meta']
.filter(function (keyModifier) { return !modifiers[keyModifier]; })
.map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
.join('||')
);
} else {
keys.push(key);
}
}
if (keys.length) {
code += genKeyFilter(keys);
}
// Make sure modifiers like prevent and stop get executed after key filtering
if (genModifierCode) {
code += genModifierCode;
}
var handlerCode = isMethodPath
? ("return " + (handler.value) + "($event)")
: isFunctionExpression
? ("return (" + (handler.value) + ")($event)")
: isFunctionInvocation
? ("return " + (handler.value))
: handler.value;
/* istanbul ignore if */
if (handler.params) {
return genWeexHandler(handler.params, code + handlerCode)
// Weex does not support modifiers
{
return genWeexHandler(handler, options)
}
return ("function($event){" + code + handlerCode + "}")
}
}
function genKeyFilter (keys) {
return (
// make sure the key filters only apply to KeyboardEvents
// #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
// key events that do not have keyCode property...
"if(!$event.type.indexOf('key')&&" +
(keys.map(genFilterCode).join('&&')) + ")return null;"
)
}
function genFilterCode (key) {
var keyVal = parseInt(key, 10);
if (keyVal) {
return ("$event.keyCode!==" + keyVal)
}
var keyCode = keyCodes[key];
var keyName = keyNames[key];
return (
"_k($event.keyCode," +
(JSON.stringify(key)) + "," +
(JSON.stringify(keyCode)) + "," +
"$event.key," +
"" + (JSON.stringify(keyName)) +
")"
)
}
var ASSET_TYPES = [
......@@ -2846,6 +2832,11 @@ var VNode = function VNode (
componentOptions,
asyncFactory
) {
{// fixed by xxxxxx 后续优化
if(data && Array.isArray(data.class)){
data.class = data.class.slice(0);
}
}
this.tag = tag;
this.data = data;
this.children = children;
......@@ -3700,10 +3691,10 @@ function genData (el, state) {
}
// event handlers
if (el.events) {
data += (genHandlers(el.events, false)) + ",";
data += (genHandlers(el.events, false, state.options)) + ",";
}
if (el.nativeEvents) {
data += (genHandlers(el.nativeEvents, true)) + ",";
data += (genHandlers(el.nativeEvents, true, state.options)) + ",";
}
// slot target
// only for non-scoped slots
......@@ -4692,6 +4683,15 @@ function postTransformComponentRoot (el) {
/* */
function postTransformRef (el) {
if (el.ref) {
addAttr(el, 'ref', el.ref);
delete el.ref;
}
}
/* */
function genText$1 (node) {
var value = node.type === 3
? node.text
......@@ -4714,67 +4714,6 @@ function postTransformText (el) {
/* */
// import { warn } from 'core/util/index'
// this will be preserved during build
// $flow-disable-line
var acorn = require('acorn'); // $flow-disable-line
var walk = require('acorn/dist/walk'); // $flow-disable-line
var escodegen = require('escodegen');
function nodeToBinding (node) {
switch (node.type) {
case 'Literal': return node.value
case 'Identifier':
case 'UnaryExpression':
case 'BinaryExpression':
case 'LogicalExpression':
case 'ConditionalExpression':
case 'MemberExpression': return { '@binding': escodegen.generate(node) }
case 'ArrayExpression': return node.elements.map(function (_) { return nodeToBinding(_); })
case 'ObjectExpression': {
var object = {};
node.properties.forEach(function (prop) {
if (!prop.key || prop.key.type !== 'Identifier') {
return
}
var key = escodegen.generate(prop.key);
var value = nodeToBinding(prop.value);
if (key && value) {
object[key] = value;
}
});
return object
}
default: {
// warn(`Not support ${node.type}: "${escodegen.generate(node)}"`)
return ''
}
}
}
function generateBinding (exp) {
if (exp && typeof exp === 'string') {
var ast = null;
try {
ast = acorn.parse(("(" + exp + ")"));
} catch (e) {
// warn(`Failed to parse the expression: "${exp}"`)
return ''
}
var output = '';
walk.simple(ast, {
Expression: function Expression (node) {
output = nodeToBinding(node);
}
});
return output
}
}
/* */
function parseAttrName (name) {
return camelize(name.replace(bindRE, ''))
}
......@@ -4884,10 +4823,8 @@ function preTransformVFor (el, options) {
/* */
var inlineStatementRE = /^\s*([A-Za-z_$0-9\['\."\]]+)*\s*\(\s*(([A-Za-z_$0-9\['\."\]]+)?(\s*,\s*([A-Za-z_$0-9\['\."\]]+))*)\s*\)$/;
function parseHandlerParams (handler) {
var res = inlineStatementRE.exec(handler.value);
var res = functionCallRE.exec(handler.value);
if (res && res[2]) {
handler.params = res[2].split(/\s*,\s*/);
}
......@@ -4941,10 +4878,10 @@ function preTransformNode$1 (el, options) {
currentRecycleList = el;
}
if (shouldCompile(el, options)) {
preTransformVBind(el);
preTransformVBind(el, options);
preTransformVIf(el, options); // also v-else-if and v-else
preTransformVFor(el, options);
preTransformVOnce(el);
preTransformVOnce(el, options);
}
}
......@@ -4957,12 +4894,13 @@ function postTransformNode (el, options) {
// mark child component in parent template
postTransformComponent(el, options);
// mark root in child component template
postTransformComponentRoot(el);
postTransformComponentRoot(el, options);
// <text>: transform children text into value attr
if (el.tag === 'text') {
postTransformText(el);
if (el.tag === 'text' || el.tag === 'u-text') {
postTransformText(el, options);
}
postTransformVOn(el);
postTransformVOn(el, options);
postTransformRef(el, options);
}
if (el === currentRecycleList) {
currentRecycleList = null;
......@@ -5033,7 +4971,7 @@ var directives = {
var isReservedTag = makeMap(
'template,script,style,element,content,slot,link,meta,svg,view,' +
'a,div,img,image,text,span,input,textarea,spinner,select,' +
'a,div,img,image,text,u-text,span,input,textarea,spinner,select,' +
'slider,slider-neighbor,indicator,canvas,' +
'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
......@@ -5049,7 +4987,7 @@ var canBeLeftOpenTag$1 = makeMap(
);
var isRuntimeComponent = makeMap(
'richtext,transition,transition-group',
'richtext,transition,transition-group,recycle-list',
true
);
......
{
"name": "@dcloudio/vue-cli-plugin-uni-optimize",
"version": "2.0.0-alpha-22420190823022",
"description": "uni-app optimize plugin for vue-cli 3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/vue-cli-plugin-uni-optimize",
"version": "2.0.0-23020190919001",
"description": "uni-app optimize plugin for vue-cli 3",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/vue-cli-plugin-uni-optimize"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
......@@ -54,9 +54,11 @@ async function build (args, api, options) {
stopSpinner
} = require('@vue/cli-shared-utils')
const runByAliIde = process.env.BUILD_ENV === 'ali-ide'
log()
if (!runByHBuilderX) {
if (!runByHBuilderX && !runByAliIde) {
logWithSpinner(`开始编译当前项目至 ${process.env.UNI_PLATFORM} 平台...`)
}
......@@ -107,7 +109,7 @@ async function build (args, api, options) {
return new Promise((resolve, reject) => {
webpack(webpackConfigs, (err, stats) => {
if (!runByHBuilderX) {
if (!runByHBuilderX && !runByAliIde) {
stopSpinner(false)
}
if (err) {
......
......@@ -50,7 +50,7 @@ module.exports = (api, options, rootOptions) => {
'babel-plugin-import': '^1.11.0'
},
browserslist: [
'Android >= 4.4',
'Android >= 4',
'ios >= 8'
]
}
......
const path = require('path')
const {
sassLoaderVersion
} = require('@dcloudio/uni-cli-shared/lib/scss')
function resolve (dir) {
return path.resolve(__dirname, '..', dir)
}
......@@ -10,7 +14,7 @@ module.exports = function chainWebpack (platformOptions) {
cssPreprocessOptions
} = require('@dcloudio/uni-cli-shared')
return function (webpackConfig) {
return function (webpackConfig) {
// 处理静态资源 limit
webpackConfig.module
.rule('images')
......@@ -59,6 +63,22 @@ module.exports = function chainWebpack (platformOptions) {
})
})
if (sassLoaderVersion >= 8) { // check indentedSyntax
// vue cli 3 and sass-loader 8
cssTypes.forEach(type => {
webpackConfig.module.rule('sass').oneOf(type).use('sass-loader').tap(options => {
if (options.indentedSyntax) {
if (!options.sassOptions) {
options.sassOptions = {}
}
options.sassOptions.indentedSyntax = true
delete options.indentedSyntax
}
return options
})
})
}
platformOptions.chainWebpack(webpackConfig)
// define
webpackConfig
......@@ -70,6 +90,9 @@ module.exports = function chainWebpack (platformOptions) {
if (runByHBuilderX) { // 由 HBuilderX 运行时,移除进度,错误
webpackConfig.plugins.delete('progress')
webpackConfig.plugins.delete('friendly-errors')
}
}
if (process.env.BUILD_ENV === 'ali-ide') {
webpackConfig.plugins.delete('progress')
}
}
}
......@@ -190,9 +190,10 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
if (runByHBuilderX) { // 使用 HBuilderX 中运行时,调整错误日志输出
const WebpackErrorsPlugin = require('../packages/webpack-errors-plugin')
const onErrors = require('../util/on-errors')
const onWarnings = require('../util/on-warnings')
plugins.push(new WebpackErrorsPlugin({
onErrors,
onWarnings: onErrors
onWarnings
}))
}
......
......@@ -29,7 +29,7 @@ process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
const {
isSupportSubPackages,
runByHBuilderX,
isInHBuilderXAlpha,
// isInHBuilderXAlpha,
getPagesJson,
getManifestJson
} = require('@dcloudio/uni-cli-shared')
......@@ -65,12 +65,12 @@ process.UNI_STAT_CONFIG = {
appid: manifestJsonObj.appid
}
// fixed by hxy alpha 版默认启用新的框架
if (isInHBuilderXAlpha) {
if (!platformOptions.hasOwnProperty('usingComponents')) {
platformOptions.usingComponents = true
}
// 默认启用 自定义组件模式
// if (isInHBuilderXAlpha) {
if (!platformOptions.hasOwnProperty('usingComponents')) {
platformOptions.usingComponents = true
}
// }
if (process.env.UNI_PLATFORM === 'h5') {
const optimization = platformOptions.optimization
......@@ -148,16 +148,9 @@ if (
platformOptions.uniStatistics || {}
)
if (
uniStatistics.enable !== false &&
(
process.env.NODE_ENV === 'production' ||
uniStatistics.enable === 'development'
)
) {
if (process.UNI_STAT_CONFIG.appid) {
process.env.UNI_USING_STAT = true
} else {
if (uniStatistics.enable !== false) {
process.env.UNI_USING_STAT = true
if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') {
console.log()
console.warn(`当前应用未配置Appid,无法使用uni统计,详情参考:https://ask.dcloud.net.cn/article/36303`)
console.log()
......@@ -177,6 +170,7 @@ if (process.env.UNI_USING_COMPONENTS) { // 是否启用分包优化
}
}
const warningMsg = `uni-app将于2019年11月1日起停止支持非自定义组件模式 [详情](https://ask.dcloud.net.cn/article/36385)`
// 输出编译器版本等信息
if (process.env.UNI_PLATFORM !== 'h5') {
try {
......@@ -196,14 +190,22 @@ if (process.env.UNI_PLATFORM !== 'h5') {
}).length) {
console.log(info)
console.log(modeText)
if (!platformOptions.usingComponents) {
console.log(warningMsg)
}
console.log('当前nvue编译模式:' + (isNVueCompiler ? 'uni-app' : 'weex') +
' 。编译模式差异见:https://ask.dcloud.net.cn/article/36074')
} else {
console.log(info + '' + modeText)
if (!platformOptions.usingComponents) {
console.log(warningMsg)
}
}
} else {
console.log(modeText)
if (!platformOptions.usingComponents) {
console.log(warningMsg)
}
}
} catch (e) {}
}
......
......@@ -104,6 +104,9 @@ module.exports = {
chunkFilename: '[id].js',
globalObject: process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'global',
sourceMapFilename: '../.sourcemap/' + process.env.UNI_PLATFORM + '/[name].js.map'
},
performance: {
hints: false
},
resolve: {
extensions: ['.nvue'],
......
const fs = require('fs')
const path = require('path')
const {
sassLoaderVersion
} = require('@dcloudio/uni-cli-shared/lib/scss')
module.exports = function initOptions (options) {
const {
getPlatformScss,
......@@ -13,7 +17,7 @@ module.exports = function initOptions (options) {
// 增加 src/node_modules 解析
options.transpileDependencies.push(path.resolve(process.env.UNI_INPUT_DIR, 'node_modules'))
options.transpileDependencies.push('@dcloudio/uni-' + process.env.UNI_PLATFORM)
options.transpileDependencies.push('@dcloudio/uni-' + process.env.UNI_PLATFORM)
options.transpileDependencies.push('@dcloudio/uni-stat')
if (process.env.UNI_PLATFORM === 'app-plus') {
......@@ -55,14 +59,17 @@ module.exports = function initOptions (options) {
let sassData = isSass ? getPlatformSass() : getPlatformScss()
if (isSass) {
sassData = `${sassData}
@import "@/uni.sass"`
sassData = `@import "@/uni.sass"`
} else if (isScss) {
sassData = `${sassData}
@import "@/uni.scss";`
}
options.css.loaderOptions.sass.data = sassData
if (sassLoaderVersion < 8) {
options.css.loaderOptions.sass.data = sassData
} else {
options.css.loaderOptions.sass.prependData = sassData
}
let userPostcssConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'postcss.config.js')
if (fs.existsSync(userPostcssConfigPath)) {
......
{
"name": "@dcloudio/vue-cli-plugin-uni",
"version": "2.0.0-alpha-22420190823022",
"version": "2.0.0-23020190919001",
"description": "uni-app plugin for vue-cli 3",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/vue-cli-plugin-uni"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
......@@ -12,7 +17,7 @@
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"@dcloudio/uni-stat": "^2.0.0-alpha-22420190823022",
"@dcloudio/uni-stat": "^2.0.0-23020190919001",
"copy-webpack-plugin": "^4.6.0",
"cross-env": "^5.2.0",
"envinfo": "^6.0.1",
......@@ -29,5 +34,5 @@
"wrap-loader": "^0.2.0",
"xregexp": "4.0.0"
},
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
......@@ -655,7 +655,7 @@
return cumulated
}, {})
};// fixed by xxxxxx
if (isSpecialTag(tag) && !isCustomBlock(currentBlock.attrs.lang || '')) {
if (isSpecialTag(tag) && !isCustomBlock(String(currentBlock.attrs.lang || ''))) {
checkAttrs(currentBlock, attrs);
if (tag === 'style') {
sfc.styles.push(currentBlock);
......@@ -713,7 +713,7 @@
} else {
var offset = content.slice(0, block.start).split(splitRE$1).length;
var lang = block.attrs && block.attrs.lang; // fixed by xxxxxx
var padChar = block.type === 'script' && !block.lang && !isCustomBlock(lang || '')
var padChar = block.type === 'script' && !block.lang && !isCustomBlock(String(lang || ''))
? '//\n'
: '\n';
return Array(offset).join(padChar)
......
......@@ -613,7 +613,7 @@ function parseComponent (
return cumulated
}, {})
};// fixed by xxxxxx
if (isSpecialTag(tag) && !isCustomBlock(currentBlock.attrs.lang || '')) {
if (isSpecialTag(tag) && !isCustomBlock(String(currentBlock.attrs.lang || ''))) {
checkAttrs(currentBlock, attrs);
if (tag === 'style') {
sfc.styles.push(currentBlock);
......@@ -671,7 +671,7 @@ function parseComponent (
} else {
var offset = content.slice(0, block.start).split(splitRE).length;
var lang = block.attrs && block.attrs.lang; // fixed by xxxxxx
var padChar = block.type === 'script' && !block.lang && !isCustomBlock(lang || '')
var padChar = block.type === 'script' && !block.lang && !isCustomBlock(String(lang || ''))
? '//\n'
: '\n';
return Array(offset).join(padChar)
......
const path = require('path')
const formatErrors = require('./format-errors')
const stringify = require('./stringify')
module.exports = function (errors) {
console.error(
Array.from(
new Set(
errors.map(err => {
const formatError = formatErrors[err.name]
if (formatError) {
const result = formatError(err)
if (result) {
if (typeof result === 'string') {
return result
} else {
const file = path.relative(process.env.UNI_INPUT_DIR, err.module.resource).split('?')[0]
if (file === 'pages.json') {
result.line = 1
}
return `${result.message} at ${file}:${result.line || 1}`
}
} else if (result === false) {
return '' // skip
}
}
return err.message
})
)
)
.filter(msg => !!msg)
.join('\n')
)
console.error(stringify(errors))
}
const stringify = require('./stringify')
module.exports = function (errors) {
const {
runByHBuilderX
} = require('@dcloudio/uni-cli-shared')
if (runByHBuilderX) {
console.log('WARNING: ' + stringify(errors))
} else {
console.warn(stringify(errors))
}
}
const path = require('path')
const formatErrors = require('./format-errors')
module.exports = function stringify (errors) {
return (Array.from(
new Set(
errors.map(err => {
const formatError = formatErrors[err.name]
if (formatError) {
const result = formatError(err)
if (result) {
if (typeof result === 'string') {
return result
} else {
const file = path.relative(process.env.UNI_INPUT_DIR, err.module.resource).split('?')[0]
if (file === 'pages.json') {
result.line = 1
}
return `${result.message} at ${file}:${result.line || 1}`
}
} else if (result === false) {
return '' // skip
}
}
return err.message
})
)
)
.filter(msg => !!msg)
.join('\n'))
}
{
"name": "@dcloudio/webpack-uni-mp-loader",
"version": "2.0.0-alpha-22420190823022",
"description": "webpack-uni-mp-loader",
"main": "index.js",
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/webpack-uni-mp-loader",
"version": "2.0.0-23020190919001",
"description": "webpack-uni-mp-loader",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/webpack-uni-mp-loader"
},
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
......@@ -177,9 +177,19 @@ module.exports = function (pagesJson, userManifestJson) {
// 允许内联播放视频
manifestJson.plus.allowsInlineMediaPlayback = true
// 安全区配置
const addRenderAlways = function () {
// "render": "always"
if (!manifestJson.plus.launchwebview) {
manifestJson.plus.launchwebview = {
'render': 'always'
}
} else if (!manifestJson.plus.launchwebview.render) {
manifestJson.plus.launchwebview.render = 'always'
}
}
if (appJson.tabBar && appJson.tabBar.list && appJson.tabBar.list.length) {
// 仅包含 tabBar 的时候才配置
// 安全区配置 仅包含 tabBar 的时候才配置
if (!manifestJson.plus.safearea) {
manifestJson.plus.safearea = {
background: appJson.tabBar.backgroundColor || '#FFFFFF',
......@@ -188,6 +198,11 @@ module.exports = function (pagesJson, userManifestJson) {
}
}
}
if (!process.env.UNI_USING_COMPONENTS) { // 非自定义组件模式下,仍旧添加 render always
addRenderAlways()
}
} else {
addRenderAlways()
}
let flexDir = false
......
......@@ -30,8 +30,6 @@
"alwaysShowBeforeRender":true
},
"popGesture": "close",
"launchwebview": {
"render": "always"
}
"launchwebview": {}
}
}
......@@ -37,7 +37,10 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function parseStyle (style = {}, root = '') {
function parseStyle (style = {}, root = '') {
// TODO pages.json 触发了两次,需要排查
style = JSON.parse(JSON.stringify(style))
let platformStyle = {}
Object.keys(style).forEach(name => {
......
{
"name": "@dcloudio/webpack-uni-pages-loader",
"version": "2.0.0-alpha-22420190823022",
"description": "uni-app pages.json loader",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"merge": "^1.2.1",
"strip-json-comments": "^2.0.1"
},
"uni-app": {
"compilerVersion": "2.2.4"
},
"gitHead": "32373adfb15ee0be1abb5b84ee6f0e3908d502fc"
"name": "@dcloudio/webpack-uni-pages-loader",
"version": "2.0.0-23020190919001",
"description": "uni-app pages.json loader",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/webpack-uni-pages-loader"
},
"files": [
"lib"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"merge": "^1.2.1",
"strip-json-comments": "^2.0.1"
},
"uni-app": {
"compilerVersion": "2.3.0"
},
"gitHead": "0fac47b62d100213ce48c29dd9d0a335f8a00264"
}
......@@ -27,7 +27,7 @@ const passiveOptions = supportsPassive ? {
function updateCssVar (vm) {
if (uni.canIUse('css.var')) {
const pageVm = vm.$parent.$parent
const windowTop = pageVm.showNavigationBar && pageVm.navigationBar.type !== 'transparent' ? (NAVBAR_HEIGHT +
const windowTop = pageVm.showNavigationBar && pageVm.navigationBar.type !== 'transparent' && pageVm.navigationBar.type !== 'float' ? (NAVBAR_HEIGHT +
'px')
: '0px'
const windowBottom = getApp().$children[0].showTabBar ? (TABBAR_HEIGHT + 'px') : '0px'
......@@ -74,8 +74,8 @@ export default function initSubscribe (subscribe) {
const enablePageReachBottom = hasLifecycleHook(vm.$options, 'onReachBottom')
const onReachBottomDistance = pageVm.onReachBottomDistance
const enableTransparentTitleNView = isPlainObject(pageVm.titleNView) && pageVm.titleNView.type ===
'transparent'
const enableTransparentTitleNView = (isPlainObject(pageVm.titleNView) && pageVm.titleNView.type ===
'transparent') || (isPlainObject(pageVm.navigationBar) && pageVm.navigationBar.type === 'transparent')
if (scrollListener) {
document.removeEventListener('scroll', scrollListener)
......
......@@ -308,7 +308,8 @@ uni-input[hidden] {
height: 100%;
background: none;
color: inherit;
opacity: inherit;
opacity: 1;
-webkit-text-fill-color: currentcolor;
font: inherit;
line-height: inherit;
letter-spacing: inherit;
......
......@@ -55,7 +55,7 @@ const CHARS = {
'nbsp': ' ',
'quot': '"',
'apos': "'"
}
}
function decodeEntities (htmlString) {
return htmlString.replace(/&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi, function (match, stage) {
......@@ -95,9 +95,11 @@ export default function parseNodes (nodes, parentNode) {
if (isPlainObject(attrs)) {
const tagAttrs = TAGS[tagName] || []
Object.keys(attrs).forEach(function (name) {
const value = attrs[name]
let value = attrs[name]
switch (name) {
case 'class':
/* eslint-disable no-fallthrough */
Array.isArray(value) && (value = value.join(' '))
case 'style':
elem.setAttribute(name, value)
break
......
......@@ -340,7 +340,8 @@ uni-textarea[auto-height] .uni-textarea-textarea {
resize: none;
background: none;
color: inherit;
opacity: inherit;
opacity: 1;
-webkit-text-fill-color: currentcolor;
font: inherit;
line-height: inherit;
letter-spacing: inherit;
......
......@@ -14,3 +14,4 @@ export {
export * from '../../../service/api/context/map'
export * from '../../../service/api/context/video'
export * from '../../../service/api/context/live-pusher'
export * from 'uni-core/service/api/base/interceptor'
......@@ -47,7 +47,8 @@ export default function initUni (uni, nvue, plus, BroadcastChannel) {
return promisify(name, uni[name])
},
set (target, name, value) {
target[name] = value
target[name] = value
return true
}
})
}
......
......@@ -33,8 +33,8 @@ export function createInstanceContext () {
getUniEmitter () {
return getGlobalUniEmitter()
},
getCurrentPages () {
return getGlobalCurrentPages()
getCurrentPages (returnAll) {
return getGlobalCurrentPages(returnAll)
}
}
}
import initUni from './api/legacy/index'
import initUpx2px from './api/upx2px'
import initEventBus from './api/event-bus'
let getGlobalUni
let getGlobalApp
let getGlobalUniEmitter
let getGlobalCurrentPages
export default {
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 (returnAll) {
return getGlobalCurrentPages(returnAll)
}
}
}
},
refresh: function (id, env, config) {
},
destroy: function (id, env) {
}
}
import {
unpack,
publish,
requireNativePlugin
requireNativePlugin,
base64ToArrayBuffer,
arrayBufferToBase64
} from '../../bridge'
let socketTaskId = 0
const socketTasks = {}
const publishStateChange = (res) => {
publish('onSocketTaskStateChange', res)
}
const createSocketTaskById = function (socketTaskId, {
url,
data,
header,
method,
protocols
} = {}) {
// fixed by hxy 需要测试是否支持 arraybuffer
const socket = requireNativePlugin('webSocket')
socket.WebSocket(url, Array.isArray(protocols) ? protocols.join(',') : protocols)
// socket.binaryType = 'arraybuffer'
socketTasks[socketTaskId] = socket
let socket
function getSocket () {
if (socket) {
return socket
}
socket = requireNativePlugin('uni-webSocket')
socket.onopen(function (e) {
publishStateChange({
socketTaskId,
socketTaskId: e.id,
state: 'open'
})
})
socket.onmessage(function (e) {
const data = e.data
publishStateChange({
socketTaskId,
socketTaskId: e.id,
state: 'message',
data: e.data
data: typeof data === 'object' ? base64ToArrayBuffer(data.base64) : data
})
})
socket.onerror(function (e) {
publishStateChange({
socketTaskId,
socketTaskId: e.id,
state: 'error',
errMsg: e.message
errMsg: e.data
})
})
socket.onclose(function (e) {
const socketTaskId = e.id
delete socketTasks[socketTaskId]
publishStateChange({
socketTaskId,
state: 'close'
})
})
return socket
}
const createSocketTaskById = function (socketTaskId, {
url,
data,
header,
method,
protocols
} = {}) {
const socket = getSocket()
socket.WebSocket({
id: socketTaskId,
url,
protocol: Array.isArray(protocols) ? protocols.join(',') : protocols
})
socketTasks[socketTaskId] = socket
return {
socketTaskId,
errMsg: 'createSocketTask:ok'
......@@ -58,13 +71,14 @@ const createSocketTaskById = function (socketTaskId, {
}
export function createSocketTask (args) {
return createSocketTaskById(++socketTaskId, args)
return createSocketTaskById(String(Date.now()), args)
}
export function operateSocketTask (args) {
const {
operationType,
code,
reason,
data,
socketTaskId
} = unpack(args)
......@@ -77,13 +91,23 @@ export function operateSocketTask (args) {
switch (operationType) {
case 'send':
if (data) {
socket.send(data)
socket.send({
id: socketTaskId,
data: typeof data === 'object' ? {
'@type': 'binary',
base64: arrayBufferToBase64(data)
} : data
})
}
return {
errMsg: 'operateSocketTask:ok'
}
case 'close':
socket.close(code)
socket.close({
id: socketTaskId,
code,
reason
})
delete socketTasks[socketTaskId]
return {
errMsg: 'operateSocketTask:ok'
......@@ -92,4 +116,4 @@ export function operateSocketTask (args) {
return {
errMsg: 'operateSocketTask:fail'
}
}
}
......@@ -5,7 +5,11 @@ import {
let webview
export function setPullDownRefreshPageId (pullDownRefreshWebview) {
webview = pullDownRefreshWebview
if (typeof pullDownRefreshWebview === 'number') {
webview = plus.webview.getWebviewById(String(pullDownRefreshWebview))
} else {
webview = pullDownRefreshWebview
}
}
export function startPullDownRefresh () {
......
import {
decode
decode,
encode
} from 'base64-arraybuffer'
export {
......@@ -56,7 +57,7 @@ export function isTabBarPage (path = '') {
return false
}
return page.$page.meta.isTabBar
}
}
const route = __uniRoutes.find(route => route.path.slice(1) === path)
return route && route.meta.isTabBar
} catch (e) {
......@@ -70,3 +71,7 @@ export function isTabBarPage (path = '') {
export function base64ToArrayBuffer (data) {
return decode(data)
}
export function arrayBufferToBase64 (data) {
return encode(data)
}
......@@ -136,9 +136,28 @@ export default {
titleImage: {
type: String,
default: ''
},
transparentTitle: {
type: String,
default: 'none'
},
titlePenetrate: {
type: String,
default: 'NO'
}
},
data () {
data () {
const titleNViewTypeList = {
'none': 'default',
'auto': 'transparent',
'always': 'float'
}
const yesNoParseList = {
'YES': true,
'NO': false
}
const navigationBar = mergeTitleNView({
loading: false,
backButton: !this.isQuit && !this.$route.meta.isQuit, // redirectTo,reLaunch时可能动态修改 meta.isQuit
......@@ -147,7 +166,10 @@ export default {
titleText: this.navigationBarTitleText,
titleImage: this.titleImage,
duration: '0',
timingFunc: ''
timingFunc: '',
type: titleNViewTypeList[this.transparentTitle],
transparentTitle: this.transparentTitle,
titlePenetrate: yesNoParseList[this.titlePenetrate]
}, this.titleNView)
const showNavigationBar = this.navigationStyle === 'default' && this.titleNView
......
......@@ -2,7 +2,7 @@
<uni-page-head :uni-page-head-type="type">
<div
:style="{transitionDuration:duration,transitionTimingFunction:timingFunc,backgroundColor:bgColor,color:textColor}"
:class="{'uni-page-head-transparent':type==='transparent'}"
:class="{'uni-page-head-transparent':type==='transparent','uni-page-head-titlePenetrate': titlePenetrate}"
class="uni-page-head"
>
<div class="uni-page-head-hd">
......@@ -36,7 +36,7 @@
v-if="!searchInput"
class="uni-page-head-bd">
<div
:style="{fontSize:titleSize,opacity:type==='transparent'?0:1}"
:style="{fontSize:titleSize}"
class="uni-page-head__title"
>
<i
......@@ -95,8 +95,9 @@
</template>
</div>
</div>
<div
v-if="type!=='transparent'"
<div
v-if="type!=='transparent'&&type!=='float'"
:class="{'uni-placeholder-titlePenetrate': titlePenetrate}"
class="uni-placeholder"/>
</uni-page-head>
</template>
......@@ -120,6 +121,16 @@ uni-page-head .uni-page-head {
color: #fff;
background-color: #000;
transition-property: all;
}
uni-page-head .uni-page-head-titlePenetrate,
uni-page-head .uni-page-head-titlePenetrate .uni-page-head-bd,
uni-page-head .uni-page-head-titlePenetrate .uni-page-head-bd * {
pointer-events: none;
}
uni-page-head .uni-page-head-titlePenetrate *{
pointer-events: auto;
}
uni-page-head .uni-page-head.uni-page-head-transparent .uni-page-head-ft > div {
......@@ -129,6 +140,10 @@ uni-page-head .uni-page-head.uni-page-head-transparent .uni-page-head-ft > div {
uni-page-head .uni-page-head ~ .uni-placeholder {
width: 100%;
height: 44px;
}
uni-page-head .uni-placeholder-titlePenetrate{
pointer-events: none;
}
uni-page-head .uni-page-head * {
......@@ -277,7 +292,7 @@ uni-page-head .uni-page-head__title .uni-loading {
uni-page-head .uni-page-head__title .uni-page-head__title_image {
width: auto;
height: 20px;
height: 26px;
vertical-align: middle;
}
</style>
......@@ -335,7 +350,7 @@ export default {
type: {
default: 'default',
validator (value) {
return ['default', 'transparent'].indexOf(value) !== -1
return ['default', 'transparent', 'float'].indexOf(value) !== -1
}
},
coverage: {
......@@ -357,6 +372,16 @@ export default {
titleImage: {
type: String,
default: ''
},
transparentTitle: {
default: 'none',
validator (value) {
return ['none', 'auto', 'always'].indexOf(value) !== -1
}
},
titlePenetrate: {
type: Boolean,
default: false
}
},
data () {
......
......@@ -6,7 +6,7 @@ export default {
mounted () {
if (this.type === 'transparent') {
const transparentElemStyle = this.$el.querySelector('.uni-page-head-transparent').style
const titleElem = this.$el.querySelector('.uni-page-head__title')
// const titleElem = this.$el.querySelector('.uni-page-head__title')
const iconElems = this.$el.querySelectorAll('.uni-btn-icon')
const iconElemsStyles = []
const textColor = this.textColor
......@@ -40,9 +40,10 @@ export default {
}
this._A = alpha
// TODO 暂时仅处理背景色
if (titleElem) {
titleElem.style.opacity = alpha
}
// 对齐支付宝小程序,标题不透明渐变
// if (titleElem) {
// titleElem.style.opacity = alpha
// }
transparentElemStyle.backgroundColor = `rgba(${this._R},${this._G},${this._B},${alpha})`
borderRadiusElemsStyles.forEach(function (borderRadiusElemStyle, index) {
let oldColor = oldColors[index]
......@@ -52,17 +53,31 @@ export default {
borderRadiusElemStyle.backgroundColor = `rgba(${rgba})`
})
})
} else if (this.transparentTitle === 'always') {
const iconElems = this.$el.querySelectorAll('.uni-btn-icon')
const iconElemsStyles = []
for (let i = 0; i < iconElems.length; i++) {
iconElemsStyles.push(iconElems[i].style)
}
const borderRadiusElems = this.$el.querySelectorAll('.uni-page-head-btn')
const oldColors = []
const borderRadiusElemsStyles = []
for (let i = 0; i < borderRadiusElems.length; i++) {
let borderRadiusElem = borderRadiusElems[i]
oldColors.push(getComputedStyle(borderRadiusElem).backgroundColor)
borderRadiusElemsStyles.push(borderRadiusElem.style)
}
}
},
computed: {
color () {
return this.type === 'transparent' ? '#fff' : this.textColor
return this.type === 'transparent' || this.transparentTitle === 'always' ? '#fff' : this.textColor
},
offset () {
return parseInt(this.coverage)
},
bgColor () {
if (this.type === 'transparent') {
if (this.type === 'transparent' || this.transparentTitle === 'always') {
const {
r,
g,
......
......@@ -33,9 +33,9 @@ export default {
const {
latitude,
longitude,
scale,
name,
address
scale = 18,
name = '',
address = ''
} = this.$route.query
return {
latitude,
......
......@@ -17,7 +17,7 @@ export default function getWindowOffset () {
const pages = getCurrentPages()
if (pages.length) {
const pageVm = pages[pages.length - 1].$parent.$parent
top = pageVm.showNavigationBar && pageVm.navigationBar.type !== 'transparent' ? NAVBAR_HEIGHT : 0
top = pageVm.showNavigationBar && (pageVm.navigationBar.type !== 'transparent' || pageVm.navigationBar.type !== 'float') ? NAVBAR_HEIGHT : 0
}
const app = getApp()
if (app) {
......
......@@ -7,8 +7,12 @@ export function hexToRgba (hex) {
r = hex.substring(0, 2)
g = hex.substring(2, 4)
b = hex.substring(4, 6)
} else {
return false
} else if (hex.length === 3) {
r = hex.substring(0, 1)
g = hex.substring(1, 2)
b = hex.substring(2, 3)
} else {
return false
}
if (r.length === 1) {
r += r
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册