Skip to content

Commit ad3a9cf

Browse files
Maizifycola119zimv
authored
v3.6.0 (Tencent#401)
* feat: support sendBeacon network * chore: add sendBeacon dev * feat: print unhandledrejection log * refactor: change 'unhandledrejection' to 'Uncaught (in promise)' * Update issue templates * chore: rename functions * chore(log): use `addEventListener("error", ...)` instead of `window.onerror`. * docs: update usage * fix(storage): Fix the issue that the cookie of the non-first-level domain cannot be deleted. (issue Tencent#398) * chore: Use TypeScript. * Feat(Network): Display "Type" (Request Type) in "General", including `xhr|fetch|ping`. * chore(Network): Optimization mockSendBeacon(). * fix(Network): Display fetch response as formatted JSON. * chore(Network): Optimization mockFetch(), convert response body into text according to the `content-type`. * Fix(Network): Recover original `window.fetch()` method when remove Network panel. * Fix(Element): Fix issue that elements are rendered as nested when `attributes` or `characterData` changed. (issue Tencent#399) * chore: add test file. * chore: remove console.log * docs: update docs * chore: build v3.6.0 Co-authored-by: cola119 <[email protected]> Co-authored-by: zimv <[email protected]>
1 parent ec4e845 commit ad3a9cf

34 files changed

+1694
-1081
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
vConsole Version:

CHANGELOG.md

+32-21
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
English | [简体中文](./CHANGELOG_CN.md)
22

3+
#### 3.6.0 (2021-05-21)
4+
5+
- `Feat(Log)` Print `unhandledrejection` log. (PR #389 by @zimv)
6+
- `Feat(Network)` Support `navigator.sendBeacon()` in Network panel. (PR #383 by @cola119)
7+
- `Feat(Network)` Display "Type" (Request Type) in "General", including `xhr|fetch|ping`.
8+
- `Chore(Global)` Use TypeScript. Now Network panel is conveted to `.ts` file.
9+
- `Fix(Network)` Recover original `window.fetch()` method when remove Network panel.
10+
- `Fix(Storage)` Fix issue that the cookie of the non-first-level domain cannot be deleted. (issue #398)
11+
- `Fix(Element)` Fix issue that elements are rendered as nested when `attributes` or `characterData` changed. (issue #399)
12+
13+
314
#### 3.5.2 (2021-05-13)
415

5-
- `Chore` Update to Webpack5 and update all NPM packages to the latest version.
6-
- `Fix(General)` Fix invalid click caused by wrong `selection`.
16+
- `Chore(Global)` Update to Webpack5 and update all NPM packages to the latest version.
17+
- `Fix(Global)` Fix invalid click caused by wrong `selection`.
718
- `Fix(Log)` Delete `cachedLogs` when reached `maxLogNumber` limit.
819
- `Fix(Log)` Fix XSS risk.
920

@@ -26,50 +37,50 @@ English | [简体中文](./CHANGELOG_CN.md)
2637

2738
#### V3.4.1 (2021-04-09)
2839

29-
- `Feature(General)` Add `setSwitchPosition(x, y)` method to update the position of switch button, see [Public Properties & Methods](./doc/public_properties_methods.md) for more details.
30-
- `Perf(General)` Add `Symbol` polyfill. (issue #361)
31-
- `Fix(General)` Update theme style after `setOption()`.
32-
- `Fix(General)` Remove `transitionEnd` to prevent compatibility issues. (issue #364)
40+
- `Feature(Global)` Add `setSwitchPosition(x, y)` method to update the position of switch button, see [Public Properties & Methods](./doc/public_properties_methods.md) for more details.
41+
- `Perf(Global)` Add `Symbol` polyfill. (issue #361)
42+
- `Fix(Global)` Update theme style after `setOption()`.
43+
- `Fix(Global)` Remove `transitionEnd` to prevent compatibility issues. (issue #364)
3344
- `Fix(Network)` Fix `fetch` optional parameter `init`. (issue #363, #365)
3445
- `Fix(Network)` Fix XSS risks.
3546

3647

3748
#### V3.4.0 (2021-01-14)
3849

39-
- `Feature(General)` Add darkmode theme, see `vConsole.option.theme` in [Public Properties & Methods](./doc/public_properties_methods.md). (PR #307 by @progrape)
40-
- `Feature(General)` Add safe area to switch button. (issue #353)
50+
- `Feature(Global)` Add darkmode theme, see `vConsole.option.theme` in [Public Properties & Methods](./doc/public_properties_methods.md). (PR #307 by @progrape)
51+
- `Feature(Global)` Add safe area to switch button. (issue #353)
4152
- `Feature(Log)` Auto move input cursor to the bracket after autocomplete command. (issue #293)
4253
- `Feature(System)` Add `Location` info to System tab. (issue #343)
4354
- `Feature(Network)` Add `fetch` log in Network tab. (by @weiqian93)
4455
- `Feature(Network)` Add Request Headers to Network tab.
4556
- `Feature(Network)` Use short URL and display parameters in Network tab. (issue #291)
4657
- `Feature(Plugin)` New third-party plugin [vconsole-stats-plugin](https://github.com/smackgg/vConsole-Stats). (by @smackgg)
47-
- `Fix(General)` The position of the switch button will be reset by mistake when clicked.
48-
- `Fix(General)` Fix `document.documentElement.offsetHeight|offsetWidth` is unreliable in newer browsers. (PR #314 by @littlee)
49-
- `Fix(General)` Prevent dispatchEvent for disabled or readOnly elements. (PR #314 by @norux)
50-
- `Fix(General)` Fix nonce searching problem. (by @sunderls)
51-
- `Fix(General)` Fix security issues. (#345 by @QiAnXinCodeSafe)
52-
- `Fix(General)` Prevent "webkitStorageInfo deprecation" warning.
53-
- `Perf(General)` Remove `Symbol`, `Array.from` polyfill. (issue #325, #275)
54-
- `Perf(General)` Show all enumerable and unenumerable properties. (issue #327)
58+
- `Fix(Global)` The position of the switch button will be reset by mistake when clicked.
59+
- `Fix(Global)` Fix `document.documentElement.offsetHeight|offsetWidth` is unreliable in newer browsers. (PR #314 by @littlee)
60+
- `Fix(Global)` Prevent dispatchEvent for disabled or readOnly elements. (PR #314 by @norux)
61+
- `Fix(Global)` Fix nonce searching problem. (by @sunderls)
62+
- `Fix(Global)` Fix security issues. (#345 by @QiAnXinCodeSafe)
63+
- `Fix(Global)` Prevent "webkitStorageInfo deprecation" warning.
64+
- `Perf(Global)` Remove `Symbol`, `Array.from` polyfill. (issue #325, #275)
65+
- `Perf(Global)` Show all enumerable and unenumerable properties. (issue #327)
5566
- `Chore` Update Webpack DevServer option. (by @QinZhen001)
5667

5768

5869
#### V3.3.4 (2019-08-19)
5970

6071
- `Feature(Log)` Add `%c` log format to support custom log style, see [Tutorial](./doc/tutorial.md) for more details.
6172
- `Feature(Plugin)` Add `VConsole.VConsoleLogPlugin` (`VConsole.VConsole*` plugins etc.) to `VConsole` class.
62-
- `Fix(General)` Fix a few minor issues. (#267 by @Molunerfinn, #272 by @domom)
73+
- `Fix(Global)` Fix a few minor issues. (#267 by @Molunerfinn, #272 by @domom)
6374
- `Fix(Storage)` Fix remove cookie fail when it is set path=/ or top domain. (#264 by @qianxinfeng)
64-
- `Perf(General)` Display vConsole on `window DOMContentLoaded` instead of `window load`.
75+
- `Perf(Global)` Display vConsole on `window DOMContentLoaded` instead of `window load`.
6576

6677

6778
#### V3.3.2 (2019-07-04)
6879

69-
- `Feature(General)` Add TypeScript definition file. (by @jas0ncn)
80+
- `Feature(Global)` Add TypeScript definition file. (by @jas0ncn)
7081
- `Fix(Log)` Avoid scrolling to bottom when away from bottom edge. (by @ele828)
71-
- `Fix(General)` Fix switch button position issue. (by @rexschuang)
72-
- `Fix(General)` Fix a few minor issues. (by @stenders)
82+
- `Fix(Global)` Fix switch button position issue. (by @rexschuang)
83+
- `Fix(Global)` Fix a few minor issues. (by @stenders)
7384

7485

7586
#### V3.3.0 (2019-02-02)

CHANGELOG_CN.md

+31-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
[English](./CHANGELOG.md) | 简体中文
22

3+
#### 3.6.0 (2021-05-21)
4+
5+
- `Feat(Log)` 新增输出 `unhandledrejection` 类型日志。 (PR #389 by @zimv)
6+
- `Feat(Network)` 新增支持展示 `navigator.sendBeacon()` 的网络请求。 (PR #383 by @cola119)
7+
- `Feat(Network)` 新增在 "General" 栏目展示 "Type" (Request Type) 字段,取值包括 `xhr|fetch|ping`
8+
- `Chore(Global)` 开始使用 TypeScript 重构代码。现在 Network 面板首先转成了 `.ts` 文件。
9+
- `Fix(Network)` 修复移除 Network 面板后没有恢复原生 `window.fetch()` 方法的问题。
10+
- `Fix(Storage)` 修复清除所有 cookie 时无法完全删除非顶级域名下的 cookie 的问题。 (issue #398)
11+
- `Fix(Element)` 修复当 element 的 `attributes``characterData` 变化时 element 被嵌套渲染的问题。 (issue #399)
12+
13+
314
#### 3.5.2 (2021-05-13)
415

516
- `Chore` 升级到 Webpack5,并升级所有 NPM packages 到最新版本。
6-
- `Fix(General)` 修复因 `selection` 选区引起的点击事件无效问题。
17+
- `Fix(Global)` 修复因 `selection` 选区引起的点击事件无效问题。
718
- `Fix(Log)` 当日志数量达到 `maxLogNumber` 上限时清空对应的 `cachedLogs`
819
- `Fix(Log)` 修复 XSS 漏洞。
920

@@ -26,49 +37,49 @@
2637

2738
#### V3.4.1 (2021-04-09)
2839

29-
- `Feature(General)` 新增 `setSwitchPosition(x, y)` 方法以更新开关按钮的位置,见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)
30-
- `Perf(General)` 添加 `Symbol` polyfill。(issue #361)
31-
- `Fix(General)` 修复 `setOption()` 后主题样式未及时更新的问题。
32-
- `Fix(General)` 删除 `transitionEnd` 以避免一些兼容性问题。(issue #364)
40+
- `Feature(Global)` 新增 `setSwitchPosition(x, y)` 方法以更新开关按钮的位置,见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)
41+
- `Perf(Global)` 添加 `Symbol` polyfill。(issue #361)
42+
- `Fix(Global)` 修复 `setOption()` 后主题样式未及时更新的问题。
43+
- `Fix(Global)` 删除 `transitionEnd` 以避免一些兼容性问题。(issue #364)
3344
- `Fix(Network)` 修复 `fetch``init` 未考虑为可选参数的问题。(issue #363, #365)
3445
- `Fix(Network)` 修复 XSS 漏洞。
3546

3647

3748
#### V3.4.0 (2021-01-14)
3849

39-
- `Feature(General)` 支持暗黑模式,配置项 `vConsole.option.theme`[Public Properties & Methods](./doc/public_properties_methods_CN.md)。(by @progrape)
40-
- `Feature(General)` 开关按钮加入拖拽安全区,避免遮挡全面屏手机底部操作区。(issue #353)
50+
- `Feature(Global)` 支持暗黑模式,配置项 `vConsole.option.theme`[Public Properties & Methods](./doc/public_properties_methods_CN.md)。(by @progrape)
51+
- `Feature(Global)` 开关按钮加入拖拽安全区,避免遮挡全面屏手机底部操作区。(issue #353)
4152
- `Feature(Log)` 指令输入框键入括号且自动补全括号后,光标将自动移动到括号内部。(issue #293)
4253
- `Feature(System)` 增加显示 `Location` 信息。(issue #343)
4354
- `Feature(Network)`支持 `fetch` 网络记录。(by @weiqian93)
4455
- `Feature(Network)` 支持显示 Request Headers。
4556
- `Feature(Network)` 仅显示简短网址,URL 参数将显示在详细信息中。(issue #291)
4657
- `Feature(Plugin)` 新第三方插件 [vconsole-stats-plugin](https://github.com/smackgg/vConsole-Stats)。(by @smackgg)
47-
- `Fix(General)` 修复点击开关按钮后位置会被重置的问题。
48-
- `Fix(General)` 修复 `document.documentElement.offsetHeight|offsetWidth` 在新浏览器中不够准确的问题。(by @littlee)
49-
- `Fix(General)` 阻止用户事件派发到 readOnly 或 disabled 的 element 上。(by @norux)
50-
- `Fix(General)` 修复 nonce 查找不准确的问题。(by @sunderls)
51-
- `Fix(General)` 修复一个安全问题。(#345 by @QiAnXinCodeSafe)
52-
- `Fix(General)` 屏蔽 "webkitStorageInfo deprecation" 告警。
53-
- `Perf(General)` 删除 `Symbol``Array.from` polyfill。(issue #325, #275)
54-
- `Perf(General)` 日志中显示对象内所有的 enumerable 和 unenumerable 属性。 (issue #327)
58+
- `Fix(Global)` 修复点击开关按钮后位置会被重置的问题。
59+
- `Fix(Global)` 修复 `document.documentElement.offsetHeight|offsetWidth` 在新浏览器中不够准确的问题。(by @littlee)
60+
- `Fix(Global)` 阻止用户事件派发到 readOnly 或 disabled 的 element 上。(by @norux)
61+
- `Fix(Global)` 修复 nonce 查找不准确的问题。(by @sunderls)
62+
- `Fix(Global)` 修复一个安全问题。(#345 by @QiAnXinCodeSafe)
63+
- `Fix(Global)` 屏蔽 "webkitStorageInfo deprecation" 告警。
64+
- `Perf(Global)` 删除 `Symbol``Array.from` polyfill。(issue #325, #275)
65+
- `Perf(Global)` 日志中显示对象内所有的 enumerable 和 unenumerable 属性。 (issue #327)
5566
- `Chore` 更新 Webpack DevServer 的配置项。(by @QinZhen001)
5667

5768

5869
#### V3.3.4 (2019-08-19)
5970

6071
- `Feature(Log)` 增加 `%c` 以支持自定义日志样式,详情见 [使用教程](./doc/tutorial_CN.md)
6172
- `Feature(Plugin)` 增加 `VConsole.VConsoleLogPlugin``VConsole.VConsole*` 内置插件在 `VConsole` class 上的挂载。
62-
- `Fix(General)` 修复若干小问题。(#267 by @Molunerfinn, #272 by @domom)
73+
- `Fix(Global)` 修复若干小问题。(#267 by @Molunerfinn, #272 by @domom)
6374
- `Fix(Storage)` 修复当 cookie `path=/` 或设置了 `domain` 时删除失败的问题。(#264 by @qianxinfeng)
64-
- `Perf(General)``window DOMContentLoaded` 而不是 `window load` 时显示 vConsole。
75+
- `Perf(Global)``window DOMContentLoaded` 而不是 `window load` 时显示 vConsole。
6576

6677

6778
#### V3.3.2 (2019-07-04)
6879

69-
- `Feature(General)` 增加 TypeScript 声明文件。(by @jas0ncn
70-
- `Fix(General)` 修复开关按钮拖动后位置不对的问题。(by @rexschuang
71-
- `Fix(General)` 修复若干小问题。(by @stenders
80+
- `Feature(Global)` 增加 TypeScript 声明文件。(by @jas0ncn
81+
- `Fix(Global)` 修复开关按钮拖动后位置不对的问题。(by @rexschuang
82+
- `Fix(Global)` 修复若干小问题。(by @stenders
7283
- `Fix(Log)` 不在列表底部时避免自动滚动。(by @ele828
7384

7485

README.md

+32-16
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,50 @@ A lightweight, extendable front-end developer tool for mobile web page.
1717
- Custom plugin
1818

1919

20-
## Usage
20+
## Installing
21+
22+
2123

22-
Download the [latest release](https://github.com/Tencent/vConsole/releases/latest). (DO NOT copy `dist/vconsole.min.js` in the dev branch)
24+
Using unpkg CDN:
25+
26+
```html
27+
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
28+
```
29+
30+
31+
## Usage
2332

24-
Or, install via npm:
33+
Method 1: Using npm (Recommanded)
2534

35+
```bash
36+
$ npm install vconsole
2637
```
27-
npm install vconsole
38+
39+
```javascript
40+
import VConsole from 'vconsole';
41+
42+
const vConsole = new VConsole();
43+
// or init with options
44+
const vConsole = new VConsole({ maxLogNumber: 1000 });
45+
46+
// call `console` methods as usual
47+
console.log('Hello world');
48+
49+
// remove it when you finish debugging
50+
vConsole.destroy();
2851
```
2952

30-
Import `dist/vconsole.min.js` to your project:
53+
Method 2: Using unpkg CDN in HTML:
3154

3255
```html
33-
<script src="path/to/vconsole.min.js"></script>
56+
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
3457
<script>
35-
// init vConsole
36-
var vConsole = new VConsole();
37-
console.log('Hello world');
58+
// VConsole will be exported to `window.VConsole` by default.
59+
var vConsole = new window.VConsole();
3860
</script>
3961
```
4062

41-
For TypeScript users:
42-
43-
```javascript
44-
import 'path/to/vconsole.min.d.ts';
45-
```
46-
47-
See [Tutorial](./doc/tutorial.md) for more details.
63+
See [Tutorial](./doc/tutorial.md) for more usage details.
4864

4965

5066
## Preview

README_CN.md

+22-15
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,38 @@ vConsole
1919

2020
## 上手
2121

22-
下载 vConsole 的[最新版本](https://github.com/Tencent/vConsole/releases/latest)。(不要直接下载 dev 分支下的 `dist/vconsole.min.js`
23-
24-
或者使用 npm 安装:
22+
方法一:使用 npm(推荐)
2523

24+
```bash
25+
$ npm install vconsole
2626
```
27-
npm install vconsole
27+
28+
Import 并初始化后,即可使用 `console.log` 功能,如 Chrome devtools 上一样。
29+
30+
```javascript
31+
import VConsole from 'vconsole';
32+
33+
const vConsole = new VConsole();
34+
// 或者使用 options 选项初始化
35+
const vConsole = new VConsole({ maxLogNumber: 1000 });
36+
37+
// 接下来即可照常使用 `console` 等方法
38+
console.log('Hello world');
39+
40+
// 结束调试后,可移除掉
41+
vConsole.destroy();
2842
```
2943

30-
引入 `dist/vconsole.min.js` 到项目中:
44+
方法二:使用 unpkg 的 CDN 直接插入到 HTML
3145

3246
```html
33-
<script src="path/to/vconsole.min.js"></script>
47+
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
3448
<script>
35-
// 初始化
36-
var vConsole = new VConsole();
37-
console.log('Hello world');
49+
// VConsole 默认会挂载到 `window.VConsole` 上
50+
var vConsole = new window.VConsole();
3851
</script>
3952
```
4053

41-
对于 TypeScript,可引入 d.ts 文件:
42-
43-
```javascript
44-
import 'path/to/vconsole.min.d.ts';
45-
```
46-
4754
详细使用方法请参阅[使用教程](./doc/tutorial_CN.md)
4855

4956

babel.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module.exports = function(api) {
1111
},
1212
"loose": true
1313
}
14-
]
14+
],
15+
"@babel/preset-typescript",
1516
],
1617
"plugins": [
1718
[

dev/element.html

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
6+
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
7+
<title>Test: Element</title>
8+
<link href="../example/lib/weui.min.css" rel="stylesheet"/>
9+
<link href="../example/lib/demo.css" rel="stylesheet"/>
10+
11+
<script type="module" src="../dist/vconsole.min.js"></script>
12+
</head>
13+
<body ontouchstart>
14+
<div id="page" class="page">
15+
<h1 id="title" class="page_title">Element</h1>
16+
<div id="text" class="weui_text_area">
17+
Hello World!
18+
</div>
19+
<a onclick="changeAttr()" href="javascript:;" class="weui_btn weui_btn_default">changeAttr</a>
20+
<a onclick="changeCharacterData()" href="javascript:;" class="weui_btn weui_btn_default">changeCharacterData</a>
21+
</div>
22+
</body>
23+
</html>
24+
25+
<script type="module">
26+
import '../dist/vconsole.min.js';
27+
28+
window.vConsole = new window.VConsole({
29+
maxLogNumber: 1000,
30+
// disableLogScrolling: true,
31+
onReady: function() {
32+
console.log('vConsole is ready.');
33+
},
34+
onClearLog: function() {
35+
console.log('on clearLog');
36+
}
37+
});
38+
</script>
39+
40+
<script>
41+
let handleMethod;
42+
function changeAttr() {
43+
handleMethod = () => {
44+
console.log('changeAttr');
45+
document.body.style.background = `hsl(${(Math.random() * 255) | 0}, 92%, 67%)`;
46+
document.getElementById('page').style.background = `hsl(${(Math.random() * 255) | 0}, 92%, 67%)`;
47+
};
48+
}
49+
function changeCharacterData() {
50+
handleMethod = () => {
51+
console.log('changeCharacterData');
52+
const node = document.getElementById('title').firstChild;
53+
node.textContent = Math.random();
54+
};
55+
}
56+
57+
document.addEventListener("click", () => {
58+
if (handleMethod) {
59+
handleMethod();
60+
}
61+
});
62+
</script>

0 commit comments

Comments
 (0)