Comparing version 3.3.2 to 3.3.3
[English](./CHANGELOG.md) | 简体中文 | ||
#### V3.3.3 (2019-08-18) | ||
- 【特性】增加 `%c` 以支持自定义日志样式,详情见 [使用教程](./doc/tutorial_CN.md)。 | ||
- 【特性】增加 `VConsole.VConsoleLogPlugin` 等 `VConsole.VConsole*` 内置插件在 `VConsole` class 上的挂载。 | ||
- 【优化】在 `window DOMContentLoaded` 而不是 `window load` 时显示 vConsole。 | ||
- 【修复】修复当 cookie `path=/` 或设置了 `domain` 时删除失败的问题。(#264 by @qianxinfeng) | ||
- 【修复】修复若干小问题。(#267 by @Molunerfinn, #272 by @domom) | ||
#### V3.3.2 (2019-07-04) | ||
@@ -4,0 +13,0 @@ |
English | [简体中文](./CHANGELOG_CN.md) | ||
#### V3.3.3 (2019-08-18) | ||
- [FEATURE] Add `%c` log format to support custom log style, see [Tutorial](./doc/tutorial.md) for more details. | ||
- [FEATURE] Add `VConsole.VConsoleLogPlugin` (`VConsole.VConsole*` plugins etc.) to `VConsole` class. | ||
- [IMPROVE] Display vConsole on `window DOMContentLoaded` instead of `window load`. | ||
- [FIX] Fix remove cookie fail when it is set path=/ or top domain. (#264 by @qianxinfeng) | ||
- [FIX] Fix a few minor issues. (#267 by @Molunerfinn, #272 by @domom) | ||
#### V3.3.2 (2019-07-04) | ||
@@ -4,0 +13,0 @@ |
@@ -122,2 +122,17 @@ [English](./tutorial.md) | 简体中文 | ||
### 样式 | ||
可使用 `%c` 来添加样式: | ||
```javascript | ||
console.log('%c blue %c red', 'color:blue', 'color:red'); // blue red | ||
console.log('%c FOO', 'font-weight:bold', 'bar'); // FOO bar | ||
console.log('%c Foo %c bar', 'color:red'); // Foo %c bar | ||
``` | ||
只有第一个参数支持 `%c` 格式,一旦出现 `%c` 格式,后续的字符串参数将作为 HTML style 样式来替换 `%c`;未被替换的 `%c`、剩余的参数,将作为默认日志照常输出。 | ||
### 特殊格式 | ||
@@ -124,0 +139,0 @@ |
@@ -127,2 +127,16 @@ English | [简体中文](./tutorial_CN.md) | ||
### Styled log | ||
Use `%c` to add style to logs: | ||
```javascript | ||
console.log('%c blue %c red', 'color:blue', 'color:red'); // blue red | ||
console.log('%c FOO', 'font-weight:bold', 'bar'); // FOO bar | ||
console.log('%c Foo %c bar', 'color:red'); // Foo %c bar | ||
``` | ||
Note that only first parameter support `%c` format, and the following parameter(s) will be used as HTML style to fill `%c`, and the remain `%c` or parameters will be shown as normal logs. | ||
### Special format | ||
@@ -129,0 +143,0 @@ |
{ | ||
"name": "vconsole", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "A lightweight, extendable front-end developer tool for mobile web page.", | ||
"homepage": "https://github.com/Tencent/vConsole", | ||
"main": "dist/vconsole.min.js", | ||
"typings": "./index.d.ts", | ||
"typings": "dist/vconsole.min.d.ts", | ||
"scripts": { | ||
"test": "mocha", | ||
"dist": "webpack" | ||
"build": "webpack" | ||
}, | ||
@@ -23,21 +23,21 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-proposal-class-properties": "^7.3.0", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.2.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.3.1", | ||
"@babel/preset-env": "^7.3.1", | ||
"babel-loader": "^8.0.4", | ||
"babel-plugin-add-module-exports": "^1.0.0", | ||
"@babel/core": "^7.5.5", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.5.2", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"babel-loader": "^8.0.6", | ||
"babel-plugin-add-module-exports": "^1.0.2", | ||
"chai": "^4.2.0", | ||
"copy-webpack-plugin": "^5.0.3", | ||
"css-loader": "^2.1.0", | ||
"copy-webpack-plugin": "^5.0.4", | ||
"css-loader": "^3.2.0", | ||
"html-loader": "^0.5.5", | ||
"jsdom": "^13.2.0", | ||
"jsdom": "^15.1.1", | ||
"json-loader": "^0.5.7", | ||
"less": "^3.9.0", | ||
"less-loader": "^4.1.0", | ||
"less": "^3.10.0", | ||
"less-loader": "^5.0.0", | ||
"mocha": "^5.2.0", | ||
"style-loader": "^0.23.1", | ||
"webpack": "^4.29.0", | ||
"webpack-cli": "^3.2.1" | ||
"style-loader": "^1.0.0", | ||
"webpack": "^4.39.2", | ||
"webpack-cli": "^3.3.6" | ||
}, | ||
@@ -44,0 +44,0 @@ "author": "Tencent", |
@@ -41,2 +41,8 @@ [English](./README.md) | 简体中文 | ||
对于 TypeScript,可引入 d.ts 文件: | ||
```javascript | ||
import 'path/to/vconsole.min.d.ts'; | ||
``` | ||
详细使用方法请参阅[使用教程](./doc/tutorial_CN.md)。 | ||
@@ -43,0 +49,0 @@ |
@@ -41,2 +41,8 @@ English | [简体中文](./README_CN.md) | ||
For TypeScript users: | ||
```javascript | ||
import 'path/to/vconsole.min.d.ts'; | ||
``` | ||
See [Tutorial](./doc/tutorial.md) for more details. | ||
@@ -43,0 +49,0 @@ |
@@ -28,2 +28,4 @@ /* | ||
// built-in plugins | ||
import VConsolePlugin from '../lib/plugin.js'; | ||
import VConsoleLogPlugin from '../log/log.js'; | ||
import VConsoleDefaultPlugin from '../log/default.js'; | ||
@@ -95,3 +97,3 @@ import VConsoleSystemPlugin from '../log/system.js'; | ||
} else { | ||
$.bind(window, 'load', _onload); | ||
$.bind(window, 'DOMContentLoaded', _onload); | ||
} | ||
@@ -741,2 +743,11 @@ } else { | ||
// export static class | ||
VConsole.VConsolePlugin = VConsolePlugin; | ||
VConsole.VConsoleLogPlugin = VConsoleLogPlugin; | ||
VConsole.VConsoleDefaultPlugin = VConsoleDefaultPlugin; | ||
VConsole.VConsoleSystemPlugin = VConsoleSystemPlugin; | ||
VConsole.VConsoleNetworkPlugin = VConsoleNetworkPlugin; | ||
VConsole.VConsoleElementPlugin = VConsoleElementPlugin; | ||
VConsole.VConsoleStoragePlugin = VConsoleStoragePlugin; | ||
export default VConsole; |
@@ -469,2 +469,24 @@ /* | ||
// find %c keyword in first log only | ||
const patternC = /(\%c )|( \%c)/g; | ||
let logStyle = []; | ||
if (tool.isString(logs[0]) && patternC.test(logs[0])) { | ||
// '%c aaa %c bbb' => ['aaa', 'bbb'] | ||
const _logs = logs[0].split(patternC).filter((val) => { | ||
return val !== undefined && val !== '' && !/ ?\%c ?/.test(val); | ||
}); | ||
const matchC = logs[0].match(patternC); | ||
// use the following string logs as style | ||
for (let i = 0; i < matchC.length; i++) { | ||
if (tool.isString(logs[i + 1])) { | ||
logStyle.push(logs[i + 1]); | ||
} | ||
} | ||
// add remain logs | ||
for (let i = matchC.length + 1; i < logs.length; i++) { | ||
_logs.push(logs[i]); | ||
} | ||
logs = _logs; | ||
} | ||
let $content = $.one('.vc-item-content', $line); | ||
@@ -486,3 +508,3 @@ // generate content from item.logs | ||
// default | ||
log = '<span> ' + tool.htmlEncode(logs[i]).replace(/\n/g, '<br/>') + '</span>'; | ||
log = (logStyle[i] ? `<span style="${logStyle[i]}"> ` : '<span> ') + tool.htmlEncode(logs[i]).replace(/\n/g, '<br/>') + '</span>'; | ||
} | ||
@@ -489,0 +511,0 @@ } catch (e) { |
@@ -133,3 +133,3 @@ /* | ||
for (let id in this.domList) { | ||
this.domList[id].remove(); | ||
this.domList[id].parentNode.removeChild(this.domList[id]); | ||
this.domList[id] = undefined; | ||
@@ -136,0 +136,0 @@ } |
@@ -220,6 +220,9 @@ /* | ||
} | ||
let hostname = window.location.hostname; | ||
let list = this.getCookieList(); | ||
for (var i=0; i<list.length; i++) { | ||
document.cookie = list[i].name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT'; | ||
let name = list[i].name; | ||
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`; | ||
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`; | ||
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.${hostname.split('.').slice(-2).join('.')}`; | ||
} | ||
@@ -226,0 +229,0 @@ this.renderStorage(); |
@@ -21,6 +21,4 @@ /* | ||
import VConsole from './core/core.js'; | ||
import VConsolePlugin from './lib/plugin.js'; | ||
// export | ||
VConsole.VConsolePlugin = VConsolePlugin; | ||
export default VConsole; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1321019
4428
95