Skip to content

Commit 5b2064d

Browse files
authored
Merge pull request #529 from Tencent/dev
v3.14.5
2 parents 1dcdc22 + 94e9fdc commit 5b2064d

File tree

14 files changed

+130
-40
lines changed

14 files changed

+130
-40
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
English | [简体中文](./CHANGELOG_CN.md)
22

3+
## 3.14.5 (2022-04-06)
4+
5+
- `Fix(Core)` Fix unexpected error when init vConsole twice in short time. (issue #525)
6+
- `Fix(Log)` Fix bug that `console.time | console.timeEnd` do not output log. (issue #523)
7+
- `Fix(Element)` Fix `undefined is not an object` error when updating attributes. (issue #526)
8+
- `Fix(Network)` Do not proxy response body reader when response is done.
9+
- `Chore` Fix typo that Svelte is not transpiled by Babel on Windows. (PR #528)
10+
11+
312
## 3.14.4 (2022-03-31)
413

514
- `Fix(Network)` Fix CPU high load bug when response is a large string. (issue #515)

CHANGELOG_CN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
[English](./CHANGELOG.md) | 简体中文
22

3+
## 3.14.5 (2022-04-06)
4+
5+
- `Fix(Core)` 修复极短时间内重复初始化 vConsole 导致的报错。 (issue #525)
6+
- `Fix(Log)` 修复 `console.time | console.timeEnd` 不输出日志的问题。 (issue #523)
7+
- `Fix(Element)` 修复更新 attributes 时引起的 `undefined is not an object` 错误。 (issue #526)
8+
- `Fix(Network)` 当请求完成后,不再代理 response body reader。
9+
- `Chore` 修复 Svelte 在 Windows 环境中未被 Babel 转义的问题。 (PR #528)
10+
11+
312
## 3.14.4 (2022-03-31)
413

514
- `Fix(Network)` 修复回包超大时导致的卡死问题。 (issue #515)

dev/common.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<a onclick="setOption()" href="javascript:;" class="weui_btn weui_btn_default">setOption</a>
2121
<a onclick="destroy()" href="javascript:;" class="weui_btn weui_btn_default">Destroy</a>
2222
<a onclick="newVConsole()" href="javascript:;" class="weui_btn weui_btn_default">new VConsole</a>
23+
<a onclick="existingId()" href="javascript:;" class="weui_btn weui_btn_default">Existing Id</a>
2324
</div>
2425
</body>
2526
</html>
@@ -105,4 +106,13 @@
105106
window.vConsole.destroy();
106107
console.log('vConsole is destroyed');
107108
}
109+
110+
function existingId() {
111+
window.vConsole.destroy();
112+
const div = document.createElement('DIV');
113+
div.id = '__vconsole';
114+
document.body.append(div);
115+
116+
window.vConsole = new window.VConsole();
117+
}
108118
</script>

dev/log.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@
129129

130130
function logTime() {
131131
vConsole.show();
132-
const label = 'aaa';
132+
const label = 'ab';
133133
console.time(label);
134-
console.log('Wait...');
135-
setTimeout(() => {
136-
console.timeEnd(label);
137-
}, Math.ceil(Math.random() * 2000));
134+
for (let i = 0; i < 10; i++) {
135+
console.log('Wait...', i);
136+
}
137+
console.timeEnd(label);
138138
}
139139

140140
function formattingLog() {

dev/network.html

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<link href="./lib/demo.css" rel="stylesheet"/>
99

1010
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
11+
<script src="https://unpkg.com/zepto/dist/zepto.min.js"></script>
12+
<script src="https://unpkg.com/wavesurfer.js"></script>
1113
<script src="../dist/vconsole.min.js"></script>
1214
</head>
1315
<body ontouchstart>
@@ -45,8 +47,10 @@
4547
<a onclick="sendBeacon()" href="javascript:;" class="weui_btn weui_btn_default">sendBeacon</a>
4648
<a onclick="axiosRequest('GET')" href="javascript:;" class="weui_btn weui_btn_default">Axios: GET</a>
4749
<a onclick="axiosRequest('POST')" href="javascript:;" class="weui_btn weui_btn_default">Axios: POST</a>
50+
<a onclick="zeptoRequest('POST')" href="javascript:;" class="weui_btn weui_btn_default">Zepto: POST</a>
4851
<a onclick="scrolling()" href="javascript:;" class="weui_btn weui_btn_default">Scrolling</a>
4952
<a onclick="crossDomain()" href="javascript:;" class="weui_btn weui_btn_default">Cross Domain</a>
53+
<a onclick="testWavesurfer()" href="javascript:;" class="weui_btn weui_btn_default">Wavesurfer.js</a>
5054
</div>
5155

5256
<div class="section">
@@ -113,8 +117,9 @@
113117
if (postType === 'json') {
114118
postData = JSON.stringify(postData);
115119
}
116-
console.log('post data:', postData);
120+
console.log(xhr.setRequestHeader);
117121
xhr.open('POST', `./data/${file}?method=fetchPost&c=中文`);
122+
xhr.setRequestHeader.apply(xhr, ['custom-auth', 'foobar']);
118123
xhr.send(postData);
119124
// xhr.send(JSON.stringify({foo: 'bar', id: Math.random(), '<xss0>': '<xss1> XSS Attack!'}));
120125
}
@@ -173,7 +178,7 @@
173178
}
174179

175180
function getFetchSimple() {
176-
window.fetch('./data/large.json?type=fetchGet&id=' + Math.random()).then((data) => {
181+
window.fetch('./data/massive.json?type=fetchGet&id=' + Math.random()).then((data) => {
177182
return data.json();
178183
}).then((data) => {
179184
console.log('getFetchSimple Response:', data);
@@ -375,6 +380,29 @@
375380
});
376381
}
377382

383+
function zeptoRequest(method = 'GET') {
384+
vConsole.show();
385+
$.ajax({
386+
type: method,
387+
async: true,
388+
url: './data/success.json?method=zepto&r=' + Math.random(),
389+
headers: {
390+
'content-type': 'application/x-www-form-urlencoded',
391+
'custom-auth': 'foobar'
392+
},
393+
data: {
394+
foo: 'bar',
395+
},
396+
xhrFields:{
397+
withCredentials: true
398+
},
399+
dataType: 'json',
400+
success(data) {
401+
console.log('zeptoRequest response:', data);
402+
},
403+
});
404+
}
405+
378406
function optionsXHR() {
379407
console.info('optionsXHR() Start');
380408
const url = window.location.origin + '/dev/success.json?method=optionsXHR&s=200&id=' + Math.random() + '&<xss0>';
@@ -413,6 +441,19 @@
413441
console.info('optionsFetch() End');
414442
}
415443

444+
function testWavesurfer() {
445+
showPanel();
446+
const div = document.createElement('DIV');
447+
div.id = 'waveform';
448+
document.body.append(div);
449+
var wavesurfer = WaveSurfer.create({
450+
container: '#waveform',
451+
waveColor: 'violet',
452+
progressColor: 'purple'
453+
});
454+
wavesurfer.load('./data/a.wav?method=fetch');
455+
}
456+
416457
function scrolling() {
417458
vConsole.setOption('maxNetworkNumber', 60);
418459
let n = 0

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vconsole",
3-
"version": "3.14.4",
3+
"version": "3.14.5",
44
"description": "A lightweight, extendable front-end developer tool for mobile web page.",
55
"homepage": "https://github.com/Tencent/vConsole",
66
"files": [

src/core/core.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class VConsole {
6666
console.debug('[vConsole] vConsole is already exists.');
6767
return VConsole.instance;
6868
}
69+
VConsole.instance = this;
6970

7071
this.isInited = false;
7172
this.option = {
@@ -131,7 +132,7 @@ export class VConsole {
131132
* Get singleton instance.
132133
**/
133134
public static get instance() {
134-
return (<any>$.one(VCONSOLE_ID))?.__VCONSOLE_INSTANCE as VConsole;
135+
return (<any>window).__VCONSOLE_INSTANCE;
135136
}
136137

137138
/**
@@ -142,12 +143,7 @@ export class VConsole {
142143
console.debug('[vConsole] Cannot set `VConsole.instance` because the value is not the instance of VConsole.');
143144
return;
144145
}
145-
const $elm = $.one(VCONSOLE_ID);
146-
if ($elm) {
147-
(<any>$elm).__VCONSOLE_INSTANCE = value;
148-
} else {
149-
console.debug('[vConsole] Cannot set `VConsole.instance` because vConsole has not finished initializing yet.');
150-
}
146+
(<any>window).__VCONSOLE_INSTANCE = value;
151147
}
152148

153149
/**
@@ -219,9 +215,6 @@ export class VConsole {
219215
const pluginId = e.detail.pluginId;
220216
this.showPlugin(pluginId);
221217
});
222-
223-
// bind vConsole instance
224-
VConsole.instance = this;
225218
}
226219

227220
// set options into component

src/element/element.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ export class VConsoleElementPlugin extends VConsoleSveltePlugin {
182182

183183
protected _onCharacterDataChange(mutation: MutationRecord) {
184184
const node = this.nodeMap.get(mutation.target);
185+
if (!node) {
186+
return;
187+
}
185188
node.textContent = mutation.target.textContent;
186189
this._refreshStore();
187190
}
@@ -233,6 +236,9 @@ export class VConsoleElementPlugin extends VConsoleSveltePlugin {
233236

234237
protected _updateVNodeAttributes(elem: Node) {
235238
const node = this.nodeMap.get(elem);
239+
if (!node) {
240+
return;
241+
}
236242
if (elem instanceof Element) {
237243
node.id = elem.id || '';
238244
node.className = elem.className || '';

src/log/log.model.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,16 @@ export class VConsoleLogModel extends VConsoleModel {
149149
window.console.timeEnd = ((label: string = '') => {
150150
const pre = timeLog[label];
151151
if (pre) {
152-
console.log(label + ':', (Date.now() - pre) + 'ms');
152+
this.addLog({
153+
type: 'log',
154+
origData: [label + ':', (Date.now() - pre) + 'ms'],
155+
});
153156
delete timeLog[label];
154157
} else {
155-
console.log(label + ': 0ms');
158+
this.addLog({
159+
type: 'log',
160+
origData: [label + ': 0ms'],
161+
});
156162
}
157163
}).bind(window.console);
158164

0 commit comments

Comments
 (0)