Comparing version 3.6.1 to 3.7.0
[English](./CHANGELOG.md) | 简体中文 | ||
#### 3.7.0 (2021-05-27) | ||
- `Feat(Storage)` 对于大体积 value 先展示预览值,以避免堵塞渲染。 (issue #300) | ||
- `Feat(Storage)` 新增复制按钮、删除按钮。 | ||
- `Feat(Global)` 当初始参数 `theme` 为空时,跟随系统默认主题色。 | ||
- `Chore(Storage)` 转换 Storage 面板为 `.ts` 文件。 | ||
- `Fix(Network)` 使用 `forEach` 而非 `.entries()` 来遍历 `headers` 以避免一些兼容性问题。 (issue #404) | ||
- `Fix(Network)` 修复 `Content-Type` 为空时导致的报错。 | ||
#### 3.6.1 (2021-05-24) | ||
@@ -4,0 +14,0 @@ |
English | [简体中文](./CHANGELOG_CN.md) | ||
#### 3.6.0 (2021-05-241) | ||
#### 3.7.0 (2021-05-27) | ||
- `Feat(Storage)` Show preview value to prevent large raw value blocking rendering. (issue #300) | ||
- `Feat(Storage)` Add copy button and delete button. | ||
- `Feat(Global)` Use system theme color by default when init option `theme` is empty. | ||
- `Chore(Storage)` Convert Storage panel to `.ts` file. | ||
- `Fix(Network)` Use `forEach` instead of `.entries()` when traversing `headers`. (issue #404) | ||
- `Fix(Network)` Fix error when `Content-Type` is empty. | ||
#### 3.6.1 (2021-05-24) | ||
- `Fix(Network)` Fix "Invalid base URL" error. (PR #402) | ||
@@ -6,0 +16,0 @@ |
{ | ||
"name": "vconsole", | ||
"version": "3.6.1", | ||
"version": "3.7.0", | ||
"description": "A lightweight, extendable front-end developer tool for mobile web page.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Tencent/vConsole", |
@@ -20,13 +20,2 @@ English | [简体中文](./README_CN.md) | ||
## Installing | ||
Using unpkg CDN: | ||
```html | ||
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script> | ||
``` | ||
## Usage | ||
@@ -33,0 +22,0 @@ |
@@ -34,3 +34,3 @@ /* | ||
import VConsoleElementPlugin from '../element/element.js'; | ||
import VConsoleStoragePlugin from '../storage/storage.js'; | ||
import VConsoleStoragePlugin from '../storage/storage.ts'; | ||
@@ -183,3 +183,6 @@ const VCONSOLE_ID = '#__vconsole'; | ||
_updateTheme() { | ||
const theme = this.option.theme || 'light'; | ||
let theme = this.option.theme; | ||
if (theme !== 'light' && theme !== 'dark') { | ||
theme = ''; // use system theme | ||
} | ||
this.$dom.setAttribute('data-theme', theme); | ||
@@ -186,0 +189,0 @@ } |
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
public render<T extends true>(tpl: string, data: any, toString: T): String; | ||
public render<T extends true>(tpl: string, data: any, toString: T): string; | ||
/** | ||
@@ -15,0 +15,0 @@ * Render `tpl` with `data` into a HTML element. |
@@ -92,4 +92,8 @@ /* | ||
protected getUniqueID(prefix: string = '') { | ||
return '__vc_' + prefix + Math.random().toString(36).substring(2, 8); | ||
} | ||
} // END class | ||
export default VConsolePlugin; |
@@ -145,2 +145,12 @@ /* | ||
/** | ||
* Remove all child elements of an element. | ||
*/ | ||
removeChildren($el: Element) { | ||
while ($el.firstChild) { | ||
$el.removeChild($el.lastChild); | ||
} | ||
return $el; | ||
}, | ||
/** | ||
* simply render a HTML template | ||
@@ -147,0 +157,0 @@ */ |
@@ -200,2 +200,41 @@ /* | ||
export function getStringBytes(str: string) { | ||
try { | ||
return encodeURI(str).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length - 1; | ||
} catch (e) { | ||
return 0; | ||
} | ||
} | ||
export function getBytesText(bytes: number) { | ||
if (bytes <= 0) { | ||
return ''; | ||
} | ||
if (bytes >= 1024 * 1024) { | ||
return (bytes / 1024 / 1024).toFixed(1) + ' MB'; | ||
} | ||
if (bytes >= 1024 * 1) { | ||
return (bytes / 1024).toFixed(1) + ' KB'; | ||
} | ||
return bytes + ' B'; | ||
} | ||
export function subString(str: string, len: number) { | ||
const r = /[^\x00-\xff]/g; | ||
let m: number; | ||
if (str.replace(r, '**').length > len) { | ||
m = Math.floor(len / 2); | ||
for (let i = m, l = str.length; i < l; i++) { | ||
const sub = str.substr(0, i); | ||
if (sub.replace(r, '**').length >= len) { | ||
return sub; | ||
} | ||
} | ||
} | ||
return str; | ||
} | ||
export function circularReplacer() { | ||
@@ -212,3 +251,3 @@ const seen = []; | ||
}; | ||
}; | ||
} | ||
@@ -215,0 +254,0 @@ /** |
@@ -16,3 +16,2 @@ /* | ||
import copy from 'copy-text-to-clipboard'; | ||
import * as tool from '../lib/tool.ts'; | ||
@@ -25,2 +24,3 @@ import $ from '../lib/query.ts'; | ||
import tplFoldCode from './item_fold_code.html'; | ||
import VConsoleItemCopy from '../component/item_copy'; | ||
@@ -159,14 +159,4 @@ const DEFAULT_MAX_LOG_NUMBER = 1000; | ||
// copy | ||
$.delegate(that.$tabbox, 'click', '.vc-item-copy', (e) => { | ||
const btn = e.target.closest('.vc-item-copy'); | ||
const { id } = btn.closest('.vc-item'); | ||
const text = that.cachedLogs[id]; | ||
if (text != null && copy(text, { target: document.documentElement })) { | ||
btn.classList.add('vc-item-copy-success'); | ||
setTimeout(() => { | ||
btn.classList.remove('vc-item-copy-success'); | ||
}, 600); | ||
}; | ||
VConsoleItemCopy.delegate(this.$tabbox, (id) => { | ||
return that.cachedLogs[id]; | ||
}); | ||
@@ -396,3 +386,3 @@ } | ||
if (!item._id) { | ||
item._id = '__vc_' + Math.random().toString(36).substring(2, 8); | ||
item._id = this.getUniqueID(); | ||
} | ||
@@ -489,3 +479,4 @@ | ||
logType: item.logType, | ||
style: item.style || '' | ||
style: item.style || '', | ||
btnCopy: VConsoleItemCopy.html, | ||
}); | ||
@@ -492,0 +483,0 @@ |
@@ -502,6 +502,5 @@ /* | ||
item.requestHeader = {}; | ||
// @ts-ignore | ||
for (let pair of requestHeader.entries()) { | ||
item.requestHeader[pair[0]] = pair[1]; | ||
} | ||
(<Headers>requestHeader).forEach((value, key) => { | ||
item.requestHeader[key] = value; | ||
}); | ||
} else { | ||
@@ -538,6 +537,5 @@ item.requestHeader = requestHeader; | ||
item.header = {}; | ||
// @ts-ignore | ||
for (let pair of response.headers.entries()) { | ||
item.header[pair[0]] = pair[1]; | ||
} | ||
response.headers.forEach((value, key) => { | ||
item.header[key] = value; | ||
}); | ||
item.readyState = 4; | ||
@@ -547,6 +545,6 @@ | ||
const contentType = response.headers.get('content-type'); | ||
if (contentType.includes('application/json')) { | ||
if (contentType && contentType.includes('application/json')) { | ||
item.responseType = 'json'; | ||
return response.clone().text(); | ||
} else if (contentType.includes('text/html')) { | ||
} else if (contentType && contentType.includes('text/html')) { | ||
item.responseType = 'text'; | ||
@@ -678,3 +676,3 @@ return response.clone().text(); | ||
private getURL(urlString: string) { | ||
private getURL(urlString: string = '') { | ||
return new URL(urlString, urlString.includes('http') ? undefined : window.location.href); | ||
@@ -685,13 +683,11 @@ } | ||
* generate an unique id string (32) | ||
* @private | ||
* @return string | ||
*/ | ||
private getUniqueID() { | ||
const id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | ||
const r = Math.random() * 16 | 0; | ||
const v = c == 'x' ? r : (r & 0x3 | 0x8); | ||
return v.toString(16); | ||
}); | ||
return id; | ||
} | ||
// protected getUniqueID() { | ||
// const id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | ||
// const r = Math.random() * 16 | 0; | ||
// const v = c == 'x' ? r : (r & 0x3 | 0x8); | ||
// return v.toString(16); | ||
// }); | ||
// return id; | ||
// } | ||
@@ -698,0 +694,0 @@ } // END class |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
668515
90
4339
102