From ad3a9cfc4ab652dd957037e69600b78b69218ff9 Mon Sep 17 00:00:00 2001 From: Maiz Date: Fri, 21 May 2021 18:52:47 +0800 Subject: [PATCH] v3.6.0 (#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 #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 #399) * chore: add test file. * chore: remove console.log * docs: update docs * chore: build v3.6.0 Co-authored-by: cola119 Co-authored-by: zimv <472953586@qq.com> --- .github/ISSUE_TEMPLATE/bug_report.md | 10 + CHANGELOG.md | 53 +- CHANGELOG_CN.md | 51 +- README.md | 48 +- README_CN.md | 37 +- babel.config.js | 3 +- dev/element.html | 62 +++ dev/index.html | 3 + dev/log.html | 19 +- dev/network.html | 82 +++- dev/storage.html | 95 ++++ dev/vue.html | 83 ++++ dist/vconsole.min.js | 4 +- package-lock.json | 200 +++++--- package.json | 3 +- src/core/core.js | 8 +- src/element/element.js | 10 +- src/element/node_view.js | 4 +- src/lib/mito.js | 107 ----- src/lib/mito.ts | 117 +++++ src/lib/{plugin.js => plugin.ts} | 19 +- src/lib/query.js | 166 ------- src/lib/query.ts | 154 ++++++ src/lib/{tool.js => tool.ts} | 29 +- src/log/default.js | 72 ++- src/log/log.js | 6 +- src/network/item.html | 19 +- src/network/network.js | 567 ---------------------- src/network/network.ts | 695 +++++++++++++++++++++++++++ src/storage/storage.js | 16 +- src/types.d.ts | 4 + tsconfig.json | 10 + webpack.config.js | 5 +- webpack.dev.config.js | 14 +- 34 files changed, 1694 insertions(+), 1081 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 dev/element.html create mode 100644 dev/storage.html create mode 100644 dev/vue.html delete mode 100644 src/lib/mito.js create mode 100644 src/lib/mito.ts rename src/lib/{plugin.js => plugin.ts} (79%) delete mode 100644 src/lib/query.js create mode 100644 src/lib/query.ts rename src/lib/{tool.js => tool.ts} (91%) delete mode 100644 src/network/network.js create mode 100644 src/network/network.ts create mode 100644 src/types.d.ts create mode 100644 tsconfig.json diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..6d1d8ffe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,10 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +vConsole Version: diff --git a/CHANGELOG.md b/CHANGELOG.md index c06f64b1..efc3839e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,20 @@ English | [简体中文](./CHANGELOG_CN.md) +#### 3.6.0 (2021-05-21) + +- `Feat(Log)` Print `unhandledrejection` log. (PR #389 by @zimv) +- `Feat(Network)` Support `navigator.sendBeacon()` in Network panel. (PR #383 by @cola119) +- `Feat(Network)` Display "Type" (Request Type) in "General", including `xhr|fetch|ping`. +- `Chore(Global)` Use TypeScript. Now Network panel is conveted to `.ts` file. +- `Fix(Network)` Recover original `window.fetch()` method when remove Network panel. +- `Fix(Storage)` Fix issue that the cookie of the non-first-level domain cannot be deleted. (issue #398) +- `Fix(Element)` Fix issue that elements are rendered as nested when `attributes` or `characterData` changed. (issue #399) + + #### 3.5.2 (2021-05-13) -- `Chore` Update to Webpack5 and update all NPM packages to the latest version. -- `Fix(General)` Fix invalid click caused by wrong `selection`. +- `Chore(Global)` Update to Webpack5 and update all NPM packages to the latest version. +- `Fix(Global)` Fix invalid click caused by wrong `selection`. - `Fix(Log)` Delete `cachedLogs` when reached `maxLogNumber` limit. - `Fix(Log)` Fix XSS risk. @@ -26,32 +37,32 @@ English | [简体中文](./CHANGELOG_CN.md) #### V3.4.1 (2021-04-09) -- `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. -- `Perf(General)` Add `Symbol` polyfill. (issue #361) -- `Fix(General)` Update theme style after `setOption()`. -- `Fix(General)` Remove `transitionEnd` to prevent compatibility issues. (issue #364) +- `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. +- `Perf(Global)` Add `Symbol` polyfill. (issue #361) +- `Fix(Global)` Update theme style after `setOption()`. +- `Fix(Global)` Remove `transitionEnd` to prevent compatibility issues. (issue #364) - `Fix(Network)` Fix `fetch` optional parameter `init`. (issue #363, #365) - `Fix(Network)` Fix XSS risks. #### V3.4.0 (2021-01-14) -- `Feature(General)` Add darkmode theme, see `vConsole.option.theme` in [Public Properties & Methods](./doc/public_properties_methods.md). (PR #307 by @progrape) -- `Feature(General)` Add safe area to switch button. (issue #353) +- `Feature(Global)` Add darkmode theme, see `vConsole.option.theme` in [Public Properties & Methods](./doc/public_properties_methods.md). (PR #307 by @progrape) +- `Feature(Global)` Add safe area to switch button. (issue #353) - `Feature(Log)` Auto move input cursor to the bracket after autocomplete command. (issue #293) - `Feature(System)` Add `Location` info to System tab. (issue #343) - `Feature(Network)` Add `fetch` log in Network tab. (by @weiqian93) - `Feature(Network)` Add Request Headers to Network tab. - `Feature(Network)` Use short URL and display parameters in Network tab. (issue #291) - `Feature(Plugin)` New third-party plugin [vconsole-stats-plugin](https://github.com/smackgg/vConsole-Stats). (by @smackgg) -- `Fix(General)` The position of the switch button will be reset by mistake when clicked. -- `Fix(General)` Fix `document.documentElement.offsetHeight|offsetWidth` is unreliable in newer browsers. (PR #314 by @littlee) -- `Fix(General)` Prevent dispatchEvent for disabled or readOnly elements. (PR #314 by @norux) -- `Fix(General)` Fix nonce searching problem. (by @sunderls) -- `Fix(General)` Fix security issues. (#345 by @QiAnXinCodeSafe) -- `Fix(General)` Prevent "webkitStorageInfo deprecation" warning. -- `Perf(General)` Remove `Symbol`, `Array.from` polyfill. (issue #325, #275) -- `Perf(General)` Show all enumerable and unenumerable properties. (issue #327) +- `Fix(Global)` The position of the switch button will be reset by mistake when clicked. +- `Fix(Global)` Fix `document.documentElement.offsetHeight|offsetWidth` is unreliable in newer browsers. (PR #314 by @littlee) +- `Fix(Global)` Prevent dispatchEvent for disabled or readOnly elements. (PR #314 by @norux) +- `Fix(Global)` Fix nonce searching problem. (by @sunderls) +- `Fix(Global)` Fix security issues. (#345 by @QiAnXinCodeSafe) +- `Fix(Global)` Prevent "webkitStorageInfo deprecation" warning. +- `Perf(Global)` Remove `Symbol`, `Array.from` polyfill. (issue #325, #275) +- `Perf(Global)` Show all enumerable and unenumerable properties. (issue #327) - `Chore` Update Webpack DevServer option. (by @QinZhen001) @@ -59,17 +70,17 @@ English | [简体中文](./CHANGELOG_CN.md) - `Feature(Log)` Add `%c` log format to support custom log style, see [Tutorial](./doc/tutorial.md) for more details. - `Feature(Plugin)` Add `VConsole.VConsoleLogPlugin` (`VConsole.VConsole*` plugins etc.) to `VConsole` class. -- `Fix(General)` Fix a few minor issues. (#267 by @Molunerfinn, #272 by @domom) +- `Fix(Global)` Fix a few minor issues. (#267 by @Molunerfinn, #272 by @domom) - `Fix(Storage)` Fix remove cookie fail when it is set path=/ or top domain. (#264 by @qianxinfeng) -- `Perf(General)` Display vConsole on `window DOMContentLoaded` instead of `window load`. +- `Perf(Global)` Display vConsole on `window DOMContentLoaded` instead of `window load`. #### V3.3.2 (2019-07-04) -- `Feature(General)` Add TypeScript definition file. (by @jas0ncn) +- `Feature(Global)` Add TypeScript definition file. (by @jas0ncn) - `Fix(Log)` Avoid scrolling to bottom when away from bottom edge. (by @ele828) -- `Fix(General)` Fix switch button position issue. (by @rexschuang) -- `Fix(General)` Fix a few minor issues. (by @stenders) +- `Fix(Global)` Fix switch button position issue. (by @rexschuang) +- `Fix(Global)` Fix a few minor issues. (by @stenders) #### V3.3.0 (2019-02-02) diff --git a/CHANGELOG_CN.md b/CHANGELOG_CN.md index c6be0b22..991c53b6 100644 --- a/CHANGELOG_CN.md +++ b/CHANGELOG_CN.md @@ -1,9 +1,20 @@ [English](./CHANGELOG.md) | 简体中文 +#### 3.6.0 (2021-05-21) + +- `Feat(Log)` 新增输出 `unhandledrejection` 类型日志。 (PR #389 by @zimv) +- `Feat(Network)` 新增支持展示 `navigator.sendBeacon()` 的网络请求。 (PR #383 by @cola119) +- `Feat(Network)` 新增在 "General" 栏目展示 "Type" (Request Type) 字段,取值包括 `xhr|fetch|ping`。 +- `Chore(Global)` 开始使用 TypeScript 重构代码。现在 Network 面板首先转成了 `.ts` 文件。 +- `Fix(Network)` 修复移除 Network 面板后没有恢复原生 `window.fetch()` 方法的问题。 +- `Fix(Storage)` 修复清除所有 cookie 时无法完全删除非顶级域名下的 cookie 的问题。 (issue #398) +- `Fix(Element)` 修复当 element 的 `attributes` 或 `characterData` 变化时 element 被嵌套渲染的问题。 (issue #399) + + #### 3.5.2 (2021-05-13) - `Chore` 升级到 Webpack5,并升级所有 NPM packages 到最新版本。 -- `Fix(General)` 修复因 `selection` 选区引起的点击事件无效问题。 +- `Fix(Global)` 修复因 `selection` 选区引起的点击事件无效问题。 - `Fix(Log)` 当日志数量达到 `maxLogNumber` 上限时清空对应的 `cachedLogs`。 - `Fix(Log)` 修复 XSS 漏洞。 @@ -26,32 +37,32 @@ #### V3.4.1 (2021-04-09) -- `Feature(General)` 新增 `setSwitchPosition(x, y)` 方法以更新开关按钮的位置,见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)。 -- `Perf(General)` 添加 `Symbol` polyfill。(issue #361) -- `Fix(General)` 修复 `setOption()` 后主题样式未及时更新的问题。 -- `Fix(General)` 删除 `transitionEnd` 以避免一些兼容性问题。(issue #364) +- `Feature(Global)` 新增 `setSwitchPosition(x, y)` 方法以更新开关按钮的位置,见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)。 +- `Perf(Global)` 添加 `Symbol` polyfill。(issue #361) +- `Fix(Global)` 修复 `setOption()` 后主题样式未及时更新的问题。 +- `Fix(Global)` 删除 `transitionEnd` 以避免一些兼容性问题。(issue #364) - `Fix(Network)` 修复 `fetch` 的 `init` 未考虑为可选参数的问题。(issue #363, #365) - `Fix(Network)` 修复 XSS 漏洞。 #### V3.4.0 (2021-01-14) -- `Feature(General)` 支持暗黑模式,配置项 `vConsole.option.theme` 见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)。(by @progrape) -- `Feature(General)` 开关按钮加入拖拽安全区,避免遮挡全面屏手机底部操作区。(issue #353) +- `Feature(Global)` 支持暗黑模式,配置项 `vConsole.option.theme` 见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)。(by @progrape) +- `Feature(Global)` 开关按钮加入拖拽安全区,避免遮挡全面屏手机底部操作区。(issue #353) - `Feature(Log)` 指令输入框键入括号且自动补全括号后,光标将自动移动到括号内部。(issue #293) - `Feature(System)` 增加显示 `Location` 信息。(issue #343) - `Feature(Network)`支持 `fetch` 网络记录。(by @weiqian93) - `Feature(Network)` 支持显示 Request Headers。 - `Feature(Network)` 仅显示简短网址,URL 参数将显示在详细信息中。(issue #291) - `Feature(Plugin)` 新第三方插件 [vconsole-stats-plugin](https://github.com/smackgg/vConsole-Stats)。(by @smackgg) -- `Fix(General)` 修复点击开关按钮后位置会被重置的问题。 -- `Fix(General)` 修复 `document.documentElement.offsetHeight|offsetWidth` 在新浏览器中不够准确的问题。(by @littlee) -- `Fix(General)` 阻止用户事件派发到 readOnly 或 disabled 的 element 上。(by @norux) -- `Fix(General)` 修复 nonce 查找不准确的问题。(by @sunderls) -- `Fix(General)` 修复一个安全问题。(#345 by @QiAnXinCodeSafe) -- `Fix(General)` 屏蔽 "webkitStorageInfo deprecation" 告警。 -- `Perf(General)` 删除 `Symbol`、`Array.from` polyfill。(issue #325, #275) -- `Perf(General)` 日志中显示对象内所有的 enumerable 和 unenumerable 属性。 (issue #327) +- `Fix(Global)` 修复点击开关按钮后位置会被重置的问题。 +- `Fix(Global)` 修复 `document.documentElement.offsetHeight|offsetWidth` 在新浏览器中不够准确的问题。(by @littlee) +- `Fix(Global)` 阻止用户事件派发到 readOnly 或 disabled 的 element 上。(by @norux) +- `Fix(Global)` 修复 nonce 查找不准确的问题。(by @sunderls) +- `Fix(Global)` 修复一个安全问题。(#345 by @QiAnXinCodeSafe) +- `Fix(Global)` 屏蔽 "webkitStorageInfo deprecation" 告警。 +- `Perf(Global)` 删除 `Symbol`、`Array.from` polyfill。(issue #325, #275) +- `Perf(Global)` 日志中显示对象内所有的 enumerable 和 unenumerable 属性。 (issue #327) - `Chore` 更新 Webpack DevServer 的配置项。(by @QinZhen001) @@ -59,16 +70,16 @@ - `Feature(Log)` 增加 `%c` 以支持自定义日志样式,详情见 [使用教程](./doc/tutorial_CN.md)。 - `Feature(Plugin)` 增加 `VConsole.VConsoleLogPlugin` 等 `VConsole.VConsole*` 内置插件在 `VConsole` class 上的挂载。 -- `Fix(General)` 修复若干小问题。(#267 by @Molunerfinn, #272 by @domom) +- `Fix(Global)` 修复若干小问题。(#267 by @Molunerfinn, #272 by @domom) - `Fix(Storage)` 修复当 cookie `path=/` 或设置了 `domain` 时删除失败的问题。(#264 by @qianxinfeng) -- `Perf(General)` 在 `window DOMContentLoaded` 而不是 `window load` 时显示 vConsole。 +- `Perf(Global)` 在 `window DOMContentLoaded` 而不是 `window load` 时显示 vConsole。 #### V3.3.2 (2019-07-04) -- `Feature(General)` 增加 TypeScript 声明文件。(by @jas0ncn) -- `Fix(General)` 修复开关按钮拖动后位置不对的问题。(by @rexschuang) -- `Fix(General)` 修复若干小问题。(by @stenders) +- `Feature(Global)` 增加 TypeScript 声明文件。(by @jas0ncn) +- `Fix(Global)` 修复开关按钮拖动后位置不对的问题。(by @rexschuang) +- `Fix(Global)` 修复若干小问题。(by @stenders) - `Fix(Log)` 不在列表底部时避免自动滚动。(by @ele828) diff --git a/README.md b/README.md index 4b34d944..2e17ee27 100644 --- a/README.md +++ b/README.md @@ -17,34 +17,50 @@ A lightweight, extendable front-end developer tool for mobile web page. - Custom plugin -## Usage +## Installing + + -Download the [latest release](https://github.com/Tencent/vConsole/releases/latest). (DO NOT copy `dist/vconsole.min.js` in the dev branch) +Using unpkg CDN: + +```html + +``` + + +## Usage -Or, install via npm: +Method 1: Using npm (Recommanded) +```bash +$ npm install vconsole ``` -npm install vconsole + +```javascript +import VConsole from 'vconsole'; + +const vConsole = new VConsole(); +// or init with options +const vConsole = new VConsole({ maxLogNumber: 1000 }); + +// call `console` methods as usual +console.log('Hello world'); + +// remove it when you finish debugging +vConsole.destroy(); ``` -Import `dist/vconsole.min.js` to your project: +Method 2: Using unpkg CDN in HTML: ```html - + ``` -For TypeScript users: - -```javascript -import 'path/to/vconsole.min.d.ts'; -``` - -See [Tutorial](./doc/tutorial.md) for more details. +See [Tutorial](./doc/tutorial.md) for more usage details. ## Preview diff --git a/README_CN.md b/README_CN.md index 1e523d86..2399ce98 100644 --- a/README_CN.md +++ b/README_CN.md @@ -19,31 +19,38 @@ vConsole ## 上手 -下载 vConsole 的[最新版本](https://github.com/Tencent/vConsole/releases/latest)。(不要直接下载 dev 分支下的 `dist/vconsole.min.js`) - -或者使用 npm 安装: +方法一:使用 npm(推荐) +```bash +$ npm install vconsole ``` -npm install vconsole + +Import 并初始化后,即可使用 `console.log` 功能,如 Chrome devtools 上一样。 + +```javascript +import VConsole from 'vconsole'; + +const vConsole = new VConsole(); +// 或者使用 options 选项初始化 +const vConsole = new VConsole({ maxLogNumber: 1000 }); + +// 接下来即可照常使用 `console` 等方法 +console.log('Hello world'); + +// 结束调试后,可移除掉 +vConsole.destroy(); ``` -引入 `dist/vconsole.min.js` 到项目中: +方法二:使用 unpkg 的 CDN 直接插入到 HTML ```html - + ``` -对于 TypeScript,可引入 d.ts 文件: - -```javascript -import 'path/to/vconsole.min.d.ts'; -``` - 详细使用方法请参阅[使用教程](./doc/tutorial_CN.md)。 diff --git a/babel.config.js b/babel.config.js index c610c6e9..c6f863ad 100644 --- a/babel.config.js +++ b/babel.config.js @@ -11,7 +11,8 @@ module.exports = function(api) { }, "loose": true } - ] + ], + "@babel/preset-typescript", ], "plugins": [ [ diff --git a/dev/element.html b/dev/element.html new file mode 100644 index 00000000..43aac6da --- /dev/null +++ b/dev/element.html @@ -0,0 +1,62 @@ + + + + + + + Test: Element + + + + + + +
+

Element

+
+ Hello World! +
+ changeAttr + changeCharacterData +
+ + + + + + \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 32c3f192..877b645a 100644 --- a/dev/index.html +++ b/dev/index.html @@ -12,7 +12,10 @@ log network async + storage + element plugin + Vue \ No newline at end of file diff --git a/dev/log.html b/dev/log.html index 9ed4644a..1f16182b 100644 --- a/dev/log.html +++ b/dev/log.html @@ -11,7 +11,7 @@ -
+
formattedLog styledLog normalObject @@ -21,6 +21,7 @@ smallArray repeatLog window.error + promiseReject XSS: Log XSS: Storage changeTheme @@ -136,6 +137,21 @@ console.info('windowError() End'); } +function promiseReject() { + console.info('promiseReject() Start'); + Promise.reject('reject string'); + Promise.reject(new Error('reject an Error')); + Promise.reject({message: 'reject an object'}); + Promise.reject(666).then((result) => { + console.log('resolved', result); + }, (result) => { + console.log('rejected', result); + }); + setTimeout(() => { + console.info('promiseReject() End'); + }, 0) +} + function xssLog() { console.info('xssLog() Start'); const arr = [ @@ -168,5 +184,4 @@ console.log('Current Theme:', theme); console.info('changeTheme() End'); } - \ No newline at end of file diff --git a/dev/network.html b/dev/network.html index 453b26c6..bd88289d 100644 --- a/dev/network.html +++ b/dev/network.html @@ -8,6 +8,7 @@ + @@ -39,25 +42,28 @@ function postAjax() { console.info('postAjax() Start, response should be logged after End'); const xhr = new XMLHttpRequest(); - xhr.open('POST', './data/success.json'); - xhr.send({ - foo: 'bar', - id: Math.random(), - type: 'xhr', - '': ' XSS Attack!' - }); xhr.onload = () => { console.log('postAjax Response:', JSON.parse(xhr.response)); }; xhr.onerror = () => { console.log('postAjax Error'); }; + xhr.onreadystatechange = () => { + console.log('onreadystatechange', `readyState=${xhr.readyState}`, `status=${xhr.status}`); + }; + xhr.open('POST', './data/success.json?method=fetchPost'); + xhr.send({ + foo: 'bar', + id: Math.random(), + type: 'xhr', + '': ' XSS Attack!' + }); console.info('postAjax() End'); } function getAjax() { console.info('getAjax() Start, response should be logged after End'); - const url = './data/success.json?type=xhr&id=' + Math.random() + '&'; + const url = './data/success.json?method=xhrGet&id=' + Math.random() + '&'; const xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.setRequestHeader('custom-header', 'foobar'); @@ -73,7 +79,7 @@ function getFetch() { console.info('getFetch() Start, response should be logged after End'); - window.fetch('./data/success.json?type=fetch&id=' + Math.random(), { + window.fetch('./data/success.json?method=fetchGet&id=' + Math.random(), { method: 'GET', headers: { 'custom-header': 'foobar', @@ -89,7 +95,7 @@ function getFetchSimple() { console.info('getFetchSimple() Start, response should be logged after End'); - window.fetch('./data/success.json?type=fetch&id=' + Math.random()).then((data) => { + window.fetch('./data/success.json?type=fetchGet&id=' + Math.random()).then((data) => { return data.json(); }).then((data) => { console.log('getFetchSimple Response:', data); @@ -99,7 +105,7 @@ function postFetch() { console.info('postFetch() Start, response should be logged after End'); - window.fetch('./data/success.json', { + window.fetch('./data/success.json?method=fetchPost', { method: 'POST', body: { foo: 'bar', id: Math.random(), type: 'fetch' }, // body: new Blob([new ArrayBuffer(233)], { type: 'image/png' }), @@ -126,7 +132,7 @@ headers.append('custom-header', 'foobar'); // headers.append('content-type', 'application/json'); headers.append('content-type', 'application/x-www-form-urlencoded'); - const req = new Request('./data/success.json?type=fetch&id=' + Math.random(), { + const req = new Request('./data/success.json?method=fetchPost&id=' + Math.random(), { method: 'POST', body: { foo: 'bar', id: Math.random() }, // body: new Blob([new ArrayBuffer(233)], { type: 'image/png' }), @@ -145,7 +151,7 @@ function getFetchText() { console.info('getFetchText() Start, response should be logged after End'); - window.fetch('./data/success.txt?type=fetch&id=' + Math.random(), { + window.fetch('./data/success.txt?type=fetchGet&id=' + Math.random(), { method: 'GET', headers: { 'custom-header': 'foobar', @@ -159,18 +165,44 @@ console.info('getFetchText() End'); } -function getAjaxText() { - console.info('getAjaxText() Start, response should be logged after End'); +function postImage() { + console.info('postImage() Start, response should be logged after End'); const xhr = new XMLHttpRequest(); - xhr.open('GET', './data/success.txt?type=xhr&id=' + Math.random()); - xhr.setRequestHeader('custom-header', 'foobar'); + xhr.open('POST', '../example/snapshot/panel_log.jpg?method=xhrPost&id=' + Math.random()); xhr.send(); - xhr.onload = () => { - console.log('getAjaxText Response:', xhr.response); - }; - xhr.onerror = () => { - console.log('getAjaxText Error'); - }; - console.info('getAjaxText() End'); + + window.fetch('../example/snapshot/qrcode.png?method=fetchPost&id=' + Math.random(), { + method: 'POST', + }); + console.info('postImage() End'); +} + +function sendBeacon() { + console.info('sendBeacon() Start, response should be logged after End'); + window.navigator.sendBeacon('./data/success.json?method=beacon', JSON.stringify({ + foo: 'bar', + id: Math.random(), + type: 'sendBeacon' + })); + console.info('sendBeacon() End'); +} + +function axiosRequest(method) { + console.info('axiosRequest() Start'); + axios({ + method, + url: './data/success.json?method=axios&r=' + Math.random(), + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + data: { + foo: 'bar' + } + }) + .then(function(response) { + console.log('axiosRequest response:', response); + }) + .catch(function(error) { + console.log('axiosRequest error:', error); + }); + console.info('axiosRequest() End'); } \ No newline at end of file diff --git a/dev/storage.html b/dev/storage.html new file mode 100644 index 00000000..5bbf6c3a --- /dev/null +++ b/dev/storage.html @@ -0,0 +1,95 @@ + + + + + + + Test: Storage + + + + + + +
+ setCookie +
+ + + + + + \ No newline at end of file diff --git a/dev/vue.html b/dev/vue.html new file mode 100644 index 00000000..d50d8605 --- /dev/null +++ b/dev/vue.html @@ -0,0 +1,83 @@ + + + + + + + Test: Vue + + + + + + + + +
+
+ + +
+
+ + + + + + \ No newline at end of file diff --git a/dist/vconsole.min.js b/dist/vconsole.min.js index 99277463..320b4432 100644 --- a/dist/vconsole.min.js +++ b/dist/vconsole.min.js @@ -1,5 +1,5 @@ /*! - * vConsole v3.5.2 (https://github.com/Tencent/vConsole) + * vConsole v3.6.0 (https://github.com/Tencent/vConsole) * * Tencent is pleased to support the open source community by making vConsole available. * Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. @@ -7,4 +7,4 @@ * http://opensource.org/licenses/MIT * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("VConsole",[],t):"object"==typeof exports?exports.VConsole=t():e.VConsole=t()}(self,(function(){return(()=>{var __webpack_modules__={2582:(e,t,n)=>{n(1646),n(6394),n(2004),n(462),n(8407),n(2429),n(1172),n(8288),n(1274),n(8201),n(6626),n(3211),n(9952),n(15),n(9831),n(7521),n(2972),n(6956),n(5222),n(2257);var o=n(1287);e.exports=o.Symbol},6163:e=>{e.exports=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}},2569:(e,t,n)=>{var o=n(794);e.exports=function(e){if(!o(e))throw TypeError(String(e)+" is not an object");return e}},5766:(e,t,n)=>{var o=n(2977),r=n(97),i=n(6782),a=function(e){return function(t,n,a){var c,s=o(t),l=r(s.length),d=i(a,l);if(e&&n!=n){for(;l>d;)if((c=s[d++])!=c)return!0}else for(;l>d;d++)if((e||d in s)&&s[d]===n)return e||d||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},4805:(e,t,n)=>{var o=n(2938),r=n(5044),i=n(1324),a=n(97),c=n(4822),s=[].push,l=function(e){var t=1==e,n=2==e,l=3==e,d=4==e,v=6==e,u=7==e,f=5==e||v;return function(p,h,g,b){for(var m,_,y=i(p),w=r(y),C=o(h,g,3),x=a(w.length),E=0,O=b||c,T=t?O(p,x):n||u?O(p,0):void 0;x>E;E++)if((f||E in w)&&(_=C(m=w[E],E,y),e))if(t)T[E]=_;else if(_)switch(e){case 3:return!0;case 5:return m;case 6:return E;case 2:s.call(T,m)}else switch(e){case 4:return!1;case 7:s.call(T,m)}return v?-1:l||d?d:T}};e.exports={forEach:l(0),map:l(1),filter:l(2),some:l(3),every:l(4),find:l(5),findIndex:l(6),filterOut:l(7)}},9269:(e,t,n)=>{var o=n(6544),r=n(3649),i=n(4061),a=r("species");e.exports=function(e){return i>=51||!o((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},4822:(e,t,n)=>{var o=n(794),r=n(4521),i=n(3649)("species");e.exports=function(e,t){var n;return r(e)&&("function"!=typeof(n=e.constructor)||n!==Array&&!r(n.prototype)?o(n)&&null===(n=n[i])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===t?0:t)}},9624:e=>{var t={}.toString;e.exports=function(e){return t.call(e).slice(8,-1)}},3058:(e,t,n)=>{var o=n(8191),r=n(9624),i=n(3649)("toStringTag"),a="Arguments"==r(function(){return arguments}());e.exports=o?r:function(e){var t,n,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:a?r(t):"Object"==(o=r(t))&&"function"==typeof t.callee?"Arguments":o}},3478:(e,t,n)=>{var o=n(4402),r=n(929),i=n(6683),a=n(4615);e.exports=function(e,t){for(var n=r(t),c=a.f,s=i.f,l=0;l{var o=n(8494),r=n(4615),i=n(4677);e.exports=o?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},4677:e=>{e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},5999:(e,t,n)=>{"use strict";var o=n(2670),r=n(4615),i=n(4677);e.exports=function(e,t,n){var a=o(t);a in e?r.f(e,a,i(0,n)):e[a]=n}},2219:(e,t,n)=>{var o=n(1287),r=n(4402),i=n(491),a=n(4615).f;e.exports=function(e){var t=o.Symbol||(o.Symbol={});r(t,e)||a(t,e,{value:i.f(e)})}},8494:(e,t,n)=>{var o=n(6544);e.exports=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},6668:(e,t,n)=>{var o=n(7583),r=n(794),i=o.document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},6918:(e,t,n)=>{var o=n(5897);e.exports=o("navigator","userAgent")||""},4061:(e,t,n)=>{var o,r,i=n(7583),a=n(6918),c=i.process,s=c&&c.versions,l=s&&s.v8;l?r=(o=l.split("."))[0]<4?1:o[0]+o[1]:a&&(!(o=a.match(/Edge\/(\d+)/))||o[1]>=74)&&(o=a.match(/Chrome\/(\d+)/))&&(r=o[1]),e.exports=r&&+r},5690:e=>{e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},7263:(e,t,n)=>{var o=n(7583),r=n(6683).f,i=n(57),a=n(1270),c=n(460),s=n(3478),l=n(4451);e.exports=function(e,t){var n,d,v,u,f,p=e.target,h=e.global,g=e.stat;if(n=h?o:g?o[p]||c(p,{}):(o[p]||{}).prototype)for(d in t){if(u=t[d],v=e.noTargetGet?(f=r(n,d))&&f.value:n[d],!l(h?d:p+(g?".":"#")+d,e.forced)&&void 0!==v){if(typeof u==typeof v)continue;s(u,v)}(e.sham||v&&v.sham)&&i(u,"sham",!0),a(n,d,u,e)}}},6544:e=>{e.exports=function(e){try{return!!e()}catch(e){return!0}}},2938:(e,t,n)=>{var o=n(6163);e.exports=function(e,t,n){if(o(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,o){return e.call(t,n,o)};case 3:return function(n,o,r){return e.call(t,n,o,r)}}return function(){return e.apply(t,arguments)}}},5897:(e,t,n)=>{var o=n(1287),r=n(7583),i=function(e){return"function"==typeof e?e:void 0};e.exports=function(e,t){return arguments.length<2?i(o[e])||i(r[e]):o[e]&&o[e][t]||r[e]&&r[e][t]}},7583:(e,t,n)=>{var o=function(e){return e&&e.Math==Math&&e};e.exports=o("object"==typeof globalThis&&globalThis)||o("object"==typeof window&&window)||o("object"==typeof self&&self)||o("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},4402:(e,t,n)=>{var o=n(1324),r={}.hasOwnProperty;e.exports=function(e,t){return r.call(o(e),t)}},4639:e=>{e.exports={}},482:(e,t,n)=>{var o=n(5897);e.exports=o("document","documentElement")},275:(e,t,n)=>{var o=n(8494),r=n(6544),i=n(6668);e.exports=!o&&!r((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},5044:(e,t,n)=>{var o=n(6544),r=n(9624),i="".split;e.exports=o((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==r(e)?i.call(e,""):Object(e)}:Object},9734:(e,t,n)=>{var o=n(1314),r=Function.toString;"function"!=typeof o.inspectSource&&(o.inspectSource=function(e){return r.call(e)}),e.exports=o.inspectSource},2743:(e,t,n)=>{var o,r,i,a=n(9491),c=n(7583),s=n(794),l=n(57),d=n(4402),v=n(1314),u=n(9137),f=n(4639),p="Object already initialized",h=c.WeakMap;if(a||v.state){var g=v.state||(v.state=new h),b=g.get,m=g.has,_=g.set;o=function(e,t){if(m.call(g,e))throw new TypeError(p);return t.facade=e,_.call(g,e,t),t},r=function(e){return b.call(g,e)||{}},i=function(e){return m.call(g,e)}}else{var y=u("state");f[y]=!0,o=function(e,t){if(d(e,y))throw new TypeError(p);return t.facade=e,l(e,y,t),t},r=function(e){return d(e,y)?e[y]:{}},i=function(e){return d(e,y)}}e.exports={set:o,get:r,has:i,enforce:function(e){return i(e)?r(e):o(e,{})},getterFor:function(e){return function(t){var n;if(!s(t)||(n=r(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}}},4521:(e,t,n)=>{var o=n(9624);e.exports=Array.isArray||function(e){return"Array"==o(e)}},4451:(e,t,n)=>{var o=n(6544),r=/#|\.prototype\./,i=function(e,t){var n=c[a(e)];return n==l||n!=s&&("function"==typeof t?o(t):!!t)},a=i.normalize=function(e){return String(e).replace(r,".").toLowerCase()},c=i.data={},s=i.NATIVE="N",l=i.POLYFILL="P";e.exports=i},794:e=>{e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},6268:e=>{e.exports=!1},8640:(e,t,n)=>{var o=n(4061),r=n(6544);e.exports=!!Object.getOwnPropertySymbols&&!r((function(){return!String(Symbol())||!Symbol.sham&&o&&o<41}))},9491:(e,t,n)=>{var o=n(7583),r=n(9734),i=o.WeakMap;e.exports="function"==typeof i&&/native code/.test(r(i))},3590:(e,t,n)=>{var o,r=n(2569),i=n(8728),a=n(5690),c=n(4639),s=n(482),l=n(6668),d=n(9137),v=d("IE_PROTO"),u=function(){},f=function(e){return"