Comparing version 3.9.5 to 3.10.0
[English](./CHANGELOG.md) | 简体中文 | ||
#### 3.9.5 (2021-11-10) | ||
## 3.10.0 (2021-12-17) | ||
> 这个版本中,我们重构了大部分核心逻辑,并且使用 Svelte 作为所有面板的视图层模板引擎。 | ||
> 这带来了一些重大变化(Breaking changes),少数属性和方法无法保证向下兼容。 | ||
> 如果你是 vConsole 插件开发者,应该关注这些变化。 | ||
**Breaking Changes:** | ||
- `Refactor(Core|Log|Network|Element)` 使用 Svelte 作为所有视图的模板引擎。 | ||
- `Refactor(Core)` **删除** `vConsole.(tabList | activedTab | $dom)` 属性。 | ||
- `Refactor(Plugin)` **重命名** `vConsole.showTab(pluginID)` 为 `vConsole.showPlugin(pluginID)`。 | ||
- `Refactor(Plugin)` **更新**插件事件 `addTopBar` 的配置参数 `{ data, onClick }`: `onClick` 会接收 2 个参数(之前是 0 个): `(event: Event, data?: any) => boolean`,其中 `data` 为上述配置参数的 `data` 字段。 | ||
- `Feat(Core)` **删除**辅助函数 `vConsole.tool` 和 `vConsole.$`。 | ||
**Common Updates:** | ||
- `Feat(Log)` 支持展示对象键值为 `Symbol` 类型的键值对。 | ||
- `Feat(Log)` 命令行支持多级关键字提示。 | ||
- `Feat(Log)` 支持使用 `%s, %d, %o` 来格式化展示字符串,并且优化了 `%c` 的 CSS 样式逻辑。 | ||
- `Feat(Log)` 对存在大量键值的对象或数组,加入翻页逻辑以提升渲染性能,每 50 一页。 | ||
- `Feat(Network)` Request 的属性值支持复制。 | ||
- `Feat(Element)` 提升交互体验,选中的节点将会被高亮,并且展开/收起(Expand/Coolapse)基于选中的节点来进行。 | ||
- `Feat(Style)` 样式标签会在 vConsole 初始化后才注入 `<head>` 中,并在 vConsole 销毁后会自动移除。 | ||
- `Refactor(Storage)` 优化了部分交互体验。 | ||
- `Fix(Network)` 当 `Fetch` 发生 Error 时,会 throw 到外部,以符合标准实现。 (issue #458) | ||
## 3.9.5 (2021-11-10) | ||
- `Style(Log)` 支持 `BigInt` 类型并更新 `Symbol` 类型的样式。 | ||
@@ -15,3 +41,3 @@ - `Refactor(Style)` 在 vConsole 初始化时再懒加载 style 标签(而非 import 后就加载)。 | ||
#### 3.9.4 (2021-10-26) | ||
## 3.9.4 (2021-10-26) | ||
@@ -21,3 +47,3 @@ - `Refactor(Global)` 为 `VConsole` 类的方法参数添加 Typescript 声明. | ||
#### 3.9.3 (2021-10-22) | ||
## 3.9.3 (2021-10-22) | ||
@@ -30,3 +56,3 @@ - `Fix(Network)` 修复未完成初始化时调用 `setOption()` 导致的 `Cannot read property 'setAttribute' of null`错误。 (PR #453 by @Zhangstring) | ||
#### 3.9.1 (2021-07-27) | ||
## 3.9.1 (2021-07-27) | ||
@@ -38,3 +64,3 @@ - `Fix(Log)` 修正命令行输入框样式。 (PR #437 by @FredZeng) | ||
#### 3.9.0 (2021-07-16) | ||
## 3.9.0 (2021-07-16) | ||
@@ -54,3 +80,3 @@ - `Feat(Log)` 显示 audio 资源加载失败的报错。 (PR #419 by @zimv) | ||
#### 3.8.1 (2021-06-24) | ||
## 3.8.1 (2021-06-24) | ||
@@ -64,3 +90,3 @@ - `Fix(Log)` 不再合并包含 object 或 array 的重复日志,以避免合并结构相同但取值不同的对象。 | ||
#### 3.8.0 (2021-06-23) | ||
## 3.8.0 (2021-06-23) | ||
@@ -72,3 +98,3 @@ - `Feat(Log)` 新增显示资源(image/video/link/script)加载失败报错。 (PR #411 by @zimv) | ||
#### 3.7.0 (2021-05-27) | ||
## 3.7.0 (2021-05-27) | ||
@@ -83,3 +109,3 @@ - `Feat(Storage)` 对于大体积 value 先展示预览值,以避免堵塞渲染。 (issue #300) | ||
#### 3.6.1 (2021-05-24) | ||
## 3.6.1 (2021-05-24) | ||
@@ -89,3 +115,3 @@ - `Fix(Network)` 修复 "Invalid base URL" 错误。 (PR #402) | ||
#### 3.6.0 (2021-05-21) | ||
## 3.6.0 (2021-05-21) | ||
@@ -101,3 +127,3 @@ - `Feat(Log)` 新增输出 `unhandledrejection` 类型日志。 (PR #389 by @zimv) | ||
#### 3.5.2 (2021-05-13) | ||
## 3.5.2 (2021-05-13) | ||
@@ -110,3 +136,3 @@ - `Chore` 升级到 Webpack5,并升级所有 NPM packages 到最新版本。 | ||
#### 3.5.1 (2021-05-07) | ||
## 3.5.1 (2021-05-07) | ||
@@ -117,3 +143,3 @@ - `Chore(Babel)` 修复由 `catch` 写法引起的 babel-loader 构建问题。 (PR #392 by @myl0204) | ||
#### 3.5.0 (2021-04-28) | ||
## 3.5.0 (2021-04-28) | ||
@@ -128,3 +154,3 @@ - `Feature(Log)` 新增复制单行日志的能力。 (by @akai) | ||
#### V3.4.1 (2021-04-09) | ||
## v3.4.1 (2021-04-09) | ||
@@ -139,3 +165,3 @@ - `Feature(Global)` 新增 `setSwitchPosition(x, y)` 方法以更新开关按钮的位置,见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)。 | ||
#### V3.4.0 (2021-01-14) | ||
## v3.4.0 (2021-01-14) | ||
@@ -161,3 +187,3 @@ - `Feature(Global)` 支持暗黑模式,配置项 `vConsole.option.theme` 见 [Public Properties & Methods](./doc/public_properties_methods_CN.md)。(by @progrape) | ||
#### V3.3.4 (2019-08-19) | ||
## v3.3.4 (2019-08-19) | ||
@@ -171,3 +197,3 @@ - `Feature(Log)` 增加 `%c` 以支持自定义日志样式,详情见 [使用教程](./doc/tutorial_CN.md)。 | ||
#### V3.3.2 (2019-07-04) | ||
## v3.3.2 (2019-07-04) | ||
@@ -180,3 +206,3 @@ - `Feature(Global)` 增加 TypeScript 声明文件。(by @jas0ncn) | ||
#### V3.3.0 (2019-02-02) | ||
## v3.3.0 (2019-02-02) | ||
@@ -187,3 +213,3 @@ - `Feature(Log)` 新增自动合并相同日志的能力。频繁输出相同日志时不再会被刷屏。 | ||
#### V3.2.2 (2019-01-17) | ||
## v3.2.2 (2019-01-17) | ||
@@ -200,3 +226,3 @@ - `Feature` 新增控制台输入提示。 (by @65147400) | ||
#### V3.2.0 (2018-04-10) | ||
## v3.2.0 (2018-04-10) | ||
@@ -210,3 +236,3 @@ - `Feature` 支持 `console.time()` 及 `console.timeEnd()`。 | ||
#### V3.1.0 (2017-12-27) | ||
## v3.1.0 (2017-12-27) | ||
@@ -220,3 +246,3 @@ - `Feature` 新增 `vConsole.showSwitch()` 及 `vConsole.hideSwitch()` 方法,请查阅[公共属性及方法](./doc/public_properties_methods_CN.md)。 | ||
#### V3.0.0 (2017-09-27) | ||
## v3.0.0 (2017-09-27) | ||
@@ -253,5 +279,5 @@ 基础: | ||
## V2.x.x | ||
## v2.x.x | ||
#### V2.5.2 (2016-12-27) | ||
## v2.5.2 (2016-12-27) | ||
@@ -261,3 +287,3 @@ - `Fix` 捕获执行自定义命令行时发生的错误。 | ||
#### V2.5.1 (2016-10-18) | ||
## v2.5.1 (2016-10-18) | ||
@@ -269,3 +295,3 @@ - `Fix` 修复一些情况下的 `scrollHeight` 错误。 | ||
#### V2.5.0 (2016-09-28) | ||
## v2.5.0 (2016-09-28) | ||
@@ -278,3 +304,3 @@ - `Feature` 新增 `vConsole.removePlugin()` 方法,请查阅[公共属性及方法](./doc/public_properties_methods_CN.md)。 | ||
#### V2.4.0 (2016-08-31) | ||
## v2.4.0 (2016-08-31) | ||
@@ -289,3 +315,3 @@ - `Feature` 新增 `addTopBar` 插件事件,请查阅[插件:Event 事件列表](./doc/plugin_event_list_CN.md)。 | ||
#### V2.3.1 (2016-08-16) | ||
## v2.3.1 (2016-08-16) | ||
@@ -296,3 +322,3 @@ - `Fix` 删除 V2.3.0 中的 `tap` 事件,恢复为 `click` 事件(依旧支持快速响应),以避免冲突。 | ||
#### V2.3.0 (2016-08-15) | ||
## v2.3.0 (2016-08-15) | ||
@@ -304,3 +330,3 @@ - `Feature` 支持逐级展开 Object 或 Array 的子元素。 | ||
#### V2.2.1 (2016-08-08) | ||
## v2.2.1 (2016-08-08) | ||
@@ -311,3 +337,3 @@ - `Feature` 在 System 面板中添加完整的 performance timing 测速点。 | ||
#### V2.2.0 (2016-07-13) | ||
## v2.2.0 (2016-07-13) | ||
@@ -318,3 +344,3 @@ - `Feature` 新增 `vConsole.version` 属性,以获取当前版本号。 | ||
#### v2.1.0 (2016-06-29) | ||
## v2.1.0 (2016-06-29) | ||
@@ -327,3 +353,3 @@ - `Feature` 新增 `vConsole.tool` 及 `vConsole.$` 辅助函数,请查阅[辅助函数](./doc/helper_functions_CN.md)。 | ||
#### v2.0.1 (2016-06-16) | ||
## v2.0.1 (2016-06-16) | ||
@@ -336,3 +362,3 @@ - `Fix` 修复 vConsole 可能无法运行在 X5 内核浏览器的问题。 | ||
#### v2.0.0 (2016-06-05) | ||
## v2.0.0 (2016-06-05) | ||
@@ -353,3 +379,3 @@ - `Feature` 完全重构,支持自定义插件,请查阅[插件:入门](./doc/plugin_getting_started_CN.md)。 | ||
#### v1.3.0 (2016-05-20) | ||
## v1.3.0 (2016-05-20) | ||
@@ -359,3 +385,3 @@ - `Feature` 支持拖拽右下角开关。 | ||
#### v1.2.1 (2016-05-16) | ||
## v1.2.1 (2016-05-16) | ||
@@ -365,3 +391,3 @@ - `Fix` 修复发送 POST 请求时丢失数据的问题。 | ||
#### v1.2.0 (2016-05-11) | ||
## v1.2.0 (2016-05-11) | ||
@@ -375,3 +401,3 @@ - `Feature` 新增网络面板,可展示 AJAX 请求。 | ||
#### v1.1.0 (2016-05-06) | ||
## v1.1.0 (2016-05-06) | ||
@@ -382,3 +408,3 @@ - `Feature` 支持 `window.onerror()` 的异常信息捕获。 | ||
#### v1.0.5 (2016-04-29) | ||
## v1.0.5 (2016-04-29) | ||
@@ -389,3 +415,3 @@ - `Fix` 修复 webpack 编译失败的问题。 | ||
#### v1.0.4 (2016-04-28) | ||
## v1.0.4 (2016-04-28) | ||
@@ -396,4 +422,4 @@ - `Fix` 修复 `package.json` 的 main 路径。 | ||
#### v1.0.2 (2016-04-27) | ||
## v1.0.2 (2016-04-27) | ||
- 初始发布。 |
109
CHANGELOG.md
English | [简体中文](./CHANGELOG_CN.md) | ||
#### 3.9.5 (2021-11-10) | ||
## 3.10.0 (2021-12-17) | ||
> In this version, we refactored a lot of core logic, and used Svelte as the rendering engine for all views. | ||
> So there are some breaking changes, a small number of methods and properties are not forward compatible. | ||
> If you are a vConsole plugin developer, you should pay attention to these changes. | ||
**Breaking Changes:** | ||
- `Refactor(Core|Log|Network|Element)` Rebuild all views by using Svelte as template engine. | ||
- `Refactor(Core)` **Remove** `vConsole.(tabList | activedTab | $dom)` properties. | ||
- `Refactor(Plugin)` **Rename** `vConsole.showTab(pluginID)` to `vConsole.showPlugin(pluginID)`. | ||
- `Refactor(Plugin)` **Change** callback option `{ data, onClick }` of plugin event `addTopBar`: `onClick` method will receive 2 arguments (which was 0 before): `(event: Event, data?: any) => boolean`, which `data` is the above option's `data` field. | ||
- `Feat(Core)` **Remove** helper functions `vConsole.tool` and `vConsole.$`. | ||
**Common Updates:** | ||
- `Feat(Log)` Support object's `Symbol` keys. | ||
- `Feat(Log)` Support multi-level keyword hint in Log's command line input. | ||
- `Feat(Log)` Support string formatting `%s, %d, %o`, and better `%c` CSS styling formatting. | ||
- `Feat(Log)` Add pagination to objects or arrays to improve rendering performance, with 50 key-values per page. | ||
- `Feat(Network)` Add copy buttons to request attributes. | ||
- `Feat(Element)` Improve UX, selected node will be highlighted and applied to Expand/Collapse action. | ||
- `Feat(Style)` Style tags will be loaded into `<head>` after vConsole initialization, and removed after destruction. | ||
- `Refactor(Storage)` Improve UX. | ||
- `Fix(Network)` Throw error when `Fetch` get an error. (issue #458) | ||
## 3.9.5 (2021-11-10) | ||
- `Style(Log)` Add support for `BigInt` and update `Symbol` log style. | ||
@@ -15,3 +42,3 @@ - `Refactor(Style)` Lazy load style tag when vConsole init. | ||
#### 3.9.4 (2021-10-26) | ||
## 3.9.4 (2021-10-26) | ||
@@ -21,3 +48,3 @@ - `Refactor(Global)` Add Typescript declaration to `VConsole` class. | ||
#### 3.9.3 (2021-10-22) | ||
## 3.9.3 (2021-10-22) | ||
@@ -30,3 +57,3 @@ - `Fix(Network)` Fix `Cannot read property 'setAttribute' of null` error when call `setOption()` before init. (PR #453 by @Zhangstring) | ||
#### 3.9.1 (2021-07-27) | ||
## 3.9.1 (2021-07-27) | ||
@@ -38,3 +65,3 @@ - `Fix(Log)` Fix command input style. (PR #437 by @FredZeng) | ||
#### 3.9.0 (2021-07-16) | ||
## 3.9.0 (2021-07-16) | ||
@@ -54,3 +81,3 @@ - `Feat(Log)` Show audio loading error log. (PR #419 by @zimv) | ||
#### 3.8.1 (2021-06-24) | ||
## 3.8.1 (2021-06-24) | ||
@@ -64,3 +91,3 @@ - `Fix(Log)` Do not merge repeated logs with object(s) or array(s) into one line to avoid merging objects with the same structure but different values. | ||
#### 3.8.0 (2021-06-23) | ||
## 3.8.0 (2021-06-23) | ||
@@ -72,3 +99,3 @@ - `Feat(Log)` Show resource (image/video/link/script) loading error log. (PR #411 by @zimv) | ||
#### 3.7.0 (2021-05-27) | ||
## 3.7.0 (2021-05-27) | ||
@@ -83,3 +110,3 @@ - `Feat(Storage)` Show preview value to prevent large raw value blocking rendering. (issue #300) | ||
#### 3.6.1 (2021-05-24) | ||
## 3.6.1 (2021-05-24) | ||
@@ -89,3 +116,3 @@ - `Fix(Network)` Fix "Invalid base URL" error. (PR #402) | ||
#### 3.6.0 (2021-05-21) | ||
## 3.6.0 (2021-05-21) | ||
@@ -101,3 +128,3 @@ - `Feat(Log)` Print `unhandledrejection` log. (PR #389 by @zimv) | ||
#### 3.5.2 (2021-05-13) | ||
## 3.5.2 (2021-05-13) | ||
@@ -110,3 +137,3 @@ - `Chore(Global)` Update to Webpack5 and update all NPM packages to the latest version. | ||
#### 3.5.1 (2021-05-07) | ||
## 3.5.1 (2021-05-07) | ||
@@ -117,3 +144,3 @@ - `Chore(Babel)` Fix incorrect `catch` built by babel-loader. (PR #392 by @myl0204) | ||
#### 3.5.0 (2021-04-28) | ||
## 3.5.0 (2021-04-28) | ||
@@ -128,3 +155,3 @@ - `Feat(Log)` Add ability to copy a single line of logs. (by @akai) | ||
#### V3.4.1 (2021-04-09) | ||
## v3.4.1 (2021-04-09) | ||
@@ -139,3 +166,3 @@ - `Feat(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. | ||
#### V3.4.0 (2021-01-14) | ||
## v3.4.0 (2021-01-14) | ||
@@ -161,3 +188,3 @@ - `Feat(Global)` Add darkmode theme, see `vConsole.option.theme` in [Public Properties & Methods](./doc/public_properties_methods.md). (PR #307 by @progrape) | ||
#### V3.3.4 (2019-08-19) | ||
## v3.3.4 (2019-08-19) | ||
@@ -171,3 +198,3 @@ - `Feat(Log)` Add `%c` log format to support custom log style, see [Tutorial](./doc/tutorial.md) for more details. | ||
#### V3.3.2 (2019-07-04) | ||
## v3.3.2 (2019-07-04) | ||
@@ -180,3 +207,3 @@ - `Feat(Global)` Add TypeScript definition file. (by @jas0ncn) | ||
#### V3.3.0 (2019-02-02) | ||
## v3.3.0 (2019-02-02) | ||
@@ -187,3 +214,3 @@ - `Feat(Log)` Add the ability to collapse the same log. | ||
#### V3.2.2 (2019-01-17) | ||
## v3.2.2 (2019-01-17) | ||
@@ -200,3 +227,3 @@ - `Feat` Add console command prompt. (by @65147400) | ||
#### V3.2.0 (2018-04-10) | ||
## v3.2.0 (2018-04-10) | ||
@@ -210,3 +237,3 @@ - `Feat` Support `console.time()` and `console.timeEnd()`. | ||
#### V3.1.0 (2017-12-27) | ||
## v3.1.0 (2017-12-27) | ||
@@ -220,3 +247,3 @@ - `Feat` Add `vConsole.showSwitch()` and `vConsole.hideSwitch()` methods, see [Public Properties & Methods](./doc/public_properties_methods.md). | ||
#### V3.0.0 (2017-09-27) | ||
## v3.0.0 (2017-09-27) | ||
@@ -253,5 +280,5 @@ Basic: | ||
## V2.x.x | ||
## v2.x.x | ||
#### V2.5.2 (2016-12-27) | ||
## v2.5.2 (2016-12-27) | ||
@@ -261,3 +288,3 @@ - `Fix` Catch errors when eval custom commands in Log tab. | ||
#### V2.5.1 (2016-10-18) | ||
## v2.5.1 (2016-10-18) | ||
@@ -269,3 +296,3 @@ - `Fix` Fix `scrollHeight` error in some cases. | ||
#### V2.5.0 (2016-09-28) | ||
## v2.5.0 (2016-09-28) | ||
@@ -278,3 +305,3 @@ - `Feat` Add `vConsole.removePlugin()` method, see [Public Properties & Methods](./doc/public_properties_methods.md). | ||
#### V2.4.0 (2016-08-31) | ||
## v2.4.0 (2016-08-31) | ||
@@ -289,3 +316,3 @@ - `Feat` Add `addTopBar` plugin event, see [Plugin: Event List](./doc/plugin_event_list.md). | ||
#### V2.3.1 (2016-08-16) | ||
## v2.3.1 (2016-08-16) | ||
@@ -296,3 +323,3 @@ - `Fix` Replace custom `tap` event (in V2.3.0) with `click` event (still support fast response) to prevent conflicts. | ||
#### V2.3.0 (2016-08-15) | ||
## v2.3.0 (2016-08-15) | ||
@@ -304,3 +331,3 @@ - `Feat` Objects or Arrays can be expended layer by layer. | ||
#### V2.2.1 (2016-08-08) | ||
## v2.2.1 (2016-08-08) | ||
@@ -311,3 +338,3 @@ - `Perf` Add complete performance timing log to System tab. | ||
#### V2.2.0 (2016-07-13) | ||
## v2.2.0 (2016-07-13) | ||
@@ -318,3 +345,3 @@ - `Feat` Add `vConsole.version` property. | ||
#### V2.1.0 (2016-06-29) | ||
## v2.1.0 (2016-06-29) | ||
@@ -327,3 +354,3 @@ - `Feat` Add `vConsole.tool` & `vConsole.$` helper functions, see [Helper Functions](./doc/helper_functions.md). | ||
#### v2.0.1 (2016-06-16) | ||
## v2.0.1 (2016-06-16) | ||
@@ -336,3 +363,3 @@ - `Fix` Fix error that vConsole may not work at X5 browser engine. | ||
#### v2.0.0 (2016-06-05) | ||
## v2.0.0 (2016-06-05) | ||
@@ -353,3 +380,3 @@ - `Feat` Rebuild completely, support custom plugin, see [Plugin: Getting Started](./doc/plugin_getting_started.md). | ||
#### v1.3.0 (2016-05-20) | ||
## v1.3.0 (2016-05-20) | ||
@@ -360,3 +387,3 @@ - `Feat` Support Drag and Drop switch button. | ||
#### v1.2.1 (2016-05-16) | ||
## v1.2.1 (2016-05-16) | ||
@@ -366,3 +393,3 @@ - `Fix` Fix data lost when sending a POST request. | ||
#### v1.2.0 (2016-05-11) | ||
## v1.2.0 (2016-05-11) | ||
@@ -376,3 +403,3 @@ - `Feat` Add network panel. | ||
#### v1.1.0 (2016-05-06) | ||
## v1.1.0 (2016-05-06) | ||
@@ -383,3 +410,3 @@ - `Feat` Support `window.onerror()` to catch exceptions and errors. | ||
#### v1.0.5 (2016-04-29) | ||
## v1.0.5 (2016-04-29) | ||
@@ -390,3 +417,3 @@ - `Fix` Fix webpack compilation. | ||
#### v1.0.4 (2016-04-28) | ||
## v1.0.4 (2016-04-28) | ||
@@ -397,4 +424,4 @@ - `Fix` Fix the `main` path in `package.json`. | ||
#### v1.0.2 (2016-04-27) | ||
## v1.0.2 (2016-04-27) | ||
- Initial release. |
@@ -19,5 +19,3 @@ declare module "lib/tool" { | ||
/** | ||
* determines whether the passed value is a specific type | ||
* @param any value | ||
* @return boolean | ||
* Determine whether a value is of a specific type. | ||
*/ | ||
@@ -41,2 +39,6 @@ export function isNumber(value: any): boolean; | ||
/** | ||
* Get an object's constructor name. | ||
*/ | ||
export function getObjName(obj: any): string; | ||
/** | ||
* check whether an object is plain (using {}) | ||
@@ -48,17 +50,15 @@ * @param object obj | ||
/** | ||
* HTML encode a string | ||
* @param string text | ||
* @return string | ||
* Escape HTML to XSS-safe text. | ||
*/ | ||
export function htmlEncode(text: string): string; | ||
export function htmlEncode(text: string | number): string; | ||
/** | ||
* Change invisible characters to visible characters | ||
* Convert a text's invisible characters to visible characters. | ||
*/ | ||
export function invisibleTextEncode(text: string): string; | ||
export function getVisibleText(text: string): string; | ||
/** | ||
* Simple JSON stringify, stringify top level key-value | ||
* A safe `JSON.stringify` method. | ||
*/ | ||
export function SimpleJSONStringify(stringObject: any): string; | ||
export function safeJSONStringify(obj: any, maxDepth?: number, keyMaxLen?: number): string; | ||
/** | ||
* rewrite JSON.stringify, catch unknown exception | ||
* Call original `JSON.stringify` and catch unknown exceptions. | ||
*/ | ||
@@ -69,12 +69,20 @@ export function JSONStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; | ||
export function subString(str: string, len: number): string; | ||
export function circularReplacer(): (key: any, value: any) => any; | ||
/** | ||
* get an object's all keys ignore whether they are not enumerable | ||
* Sore an `string[]` by string. | ||
*/ | ||
export function getObjAllKeys(obj: any): any[]; | ||
export function sortArray(arr: string[]): string[]; | ||
/** | ||
* get an object's prototype name | ||
* Get enumerable keys of an object or array. | ||
*/ | ||
export function getObjName(obj: any): string; | ||
export function getEnumerableKeys(obj: any): string[]; | ||
/** | ||
* Get enumerable and non-enumerable keys of an object or array. | ||
*/ | ||
export function getEnumerableAndNonEnumerableKeys(obj: any): string[]; | ||
/** | ||
* Get non-enumerable keys of an object or array. | ||
*/ | ||
export function getNonEnumerableKeys(obj: any): string[]; | ||
export function getSymbolKeys(obj: any): symbol[]; | ||
/** | ||
* localStorage methods | ||
@@ -84,20 +92,6 @@ */ | ||
export function getStorage(key: string): string; | ||
} | ||
declare module "lib/mito" { | ||
/** | ||
* Mito.js | ||
* A simple template engine | ||
* | ||
* @author Maiz | ||
* Generate a 6-digit unique string with prefix `"__vc_" + ${prefix}` | ||
*/ | ||
export default class Mito { | ||
/** | ||
* Render `tpl` with `data` into a HTML string. | ||
*/ | ||
render<T extends true>(tpl: string, data: any, toString: T): string; | ||
/** | ||
* Render `tpl` with `data` into a HTML element. | ||
*/ | ||
render<T extends false>(tpl: string, data: any, toString?: T): Element; | ||
} | ||
export function getUniqueID(prefix?: string): string; | ||
} | ||
@@ -149,9 +143,2 @@ declare module "lib/query" { | ||
removeChildren($el: Element): Element; | ||
/** | ||
* simply render a HTML template | ||
*/ | ||
render: { | ||
<T extends true>(tpl: string, data: any, toString: T): string; | ||
<T_1 extends false>(tpl: string, data: any, toString?: T_1): Element; | ||
}; | ||
}; | ||
@@ -164,10 +151,27 @@ /** | ||
declare module "lib/plugin" { | ||
type VConsolePluginEvent = (data?: any) => void; | ||
export type IVConsolePluginEvent = (data?: any) => void; | ||
export interface IVConsoleTopbarOptions { | ||
name: string; | ||
className: string; | ||
actived?: boolean; | ||
data?: { | ||
[key: string]: string; | ||
}; | ||
onClick?: (e: Event, data?: any) => any; | ||
} | ||
export interface IVConsoleToolbarOptions { | ||
name: string; | ||
global?: boolean; | ||
data?: { | ||
[key: string]: string; | ||
}; | ||
onClick?: (e: Event, data?: any) => any; | ||
} | ||
/** | ||
* vConsole Plugin Class | ||
*/ | ||
class VConsolePlugin { | ||
export class VConsolePlugin { | ||
isReady: boolean; | ||
eventList: { | ||
[eventName: string]: VConsolePluginEvent; | ||
[eventName: string]: IVConsolePluginEvent; | ||
}; | ||
@@ -190,3 +194,3 @@ protected _id: string; | ||
*/ | ||
on(eventName: string, callback: VConsolePluginEvent): this; | ||
on(eventName: string, callback: IVConsolePluginEvent): this; | ||
/** | ||
@@ -200,171 +204,314 @@ * trigger an event | ||
} | ||
declare module "component/item_copy" { | ||
export default class VConsoleItemCopy { | ||
static html: string; | ||
declare module "lib/sveltePlugin" { | ||
import VConsolePlugin from "lib/plugin"; | ||
import { SvelteComponent } from 'svelte'; | ||
export class VConsoleSveltePlugin<T extends {} = {}> extends VConsolePlugin { | ||
CompClass: typeof SvelteComponent; | ||
compInstance?: SvelteComponent; | ||
initialProps: T; | ||
constructor(id: string, name: string, CompClass: typeof SvelteComponent, initialProps: T); | ||
onReady(): void; | ||
onRenderTab(callback: any): void; | ||
onRemove(): void; | ||
} | ||
} | ||
declare module "lib/model" { | ||
type AConstructorTypeOf<T, U extends any[] = any[]> = new (...args: U) => T; | ||
export class VConsoleModel { | ||
static singleton: { | ||
[ctorName: string]: VConsoleModel; | ||
}; | ||
protected _onDataUpdateCallbacks: Function[]; | ||
/** | ||
* Delegate copy button `onClick` event on a perent element. | ||
* Get a singleton of a model. | ||
*/ | ||
static delegate($el: Element, getCopyText: (id: string) => string): void; | ||
static getSingleton<T extends VConsoleModel>(ctor: AConstructorTypeOf<T>, ctorName: string): T; | ||
} | ||
export default VConsoleModel; | ||
} | ||
declare module "core/core.model" { | ||
export const contentStore: { | ||
subscribe: (this: void, run: import("svelte/store").Subscriber<{ | ||
updateTime: number; | ||
}>, invalidate?: (value?: { | ||
updateTime: number; | ||
}) => void) => import("svelte/store").Unsubscriber; | ||
set: (this: void, value: { | ||
updateTime: number; | ||
}) => void; | ||
update: (this: void, updater: import("svelte/store").Updater<{ | ||
updateTime: number; | ||
}>) => void; | ||
updateTime: () => void; | ||
}; | ||
} | ||
declare module "log/logTool" { | ||
import type { IVConsoleLog, IVConsoleLogData } from "log/log.model"; | ||
/** | ||
* Get a value's text content and its type. | ||
*/ | ||
export const getValueTextAndType: (val: any, wrapString?: boolean) => { | ||
text: any; | ||
valueType: string; | ||
}; | ||
/** | ||
* A simple parser to get `[` or `]` information. | ||
*/ | ||
export const getLastIdentifier: (text: string) => { | ||
front: { | ||
text: string; | ||
pos: number; | ||
before: string; | ||
after: string; | ||
}; | ||
back: { | ||
text: string; | ||
pos: number; | ||
before: string; | ||
after: string; | ||
}; | ||
}; | ||
export const isMatchedFilterText: (log: IVConsoleLog, filterText: string) => boolean; | ||
/** | ||
* Styling log output (`%c`), or string substitutions (`%s`, `%d`, `%o`). | ||
* Apply to the first log only. | ||
*/ | ||
export const getLogDatasWithFormatting: (origDatas: any[]) => IVConsoleLogData[]; | ||
/** | ||
* An empty class for rendering views. | ||
*/ | ||
export class VConsoleUninvocatableObject { | ||
} | ||
} | ||
declare module "log/log.store" { | ||
import type { Writable } from 'svelte/store'; | ||
import type { IVConsoleLog } from "log/log.model"; | ||
export interface IVConsoleLogStore { | ||
logList: IVConsoleLog[]; | ||
} | ||
/** | ||
* Log Store Factory | ||
*/ | ||
export class VConsoleLogStore { | ||
static storeMap: { | ||
[pluginId: string]: Writable<IVConsoleLogStore>; | ||
}; | ||
/** | ||
* Copy a text to clipboard | ||
* Create a store. | ||
*/ | ||
static copy(text: string): boolean; | ||
static create(pluginId: string): Writable<IVConsoleLogStore>; | ||
/** | ||
* Delete a store. | ||
*/ | ||
static delete(pluginId: string): void; | ||
/** | ||
* Get a store by pluginId, | ||
*/ | ||
static get(pluginId: string): Writable<IVConsoleLogStore>; | ||
/** | ||
* Get a store's raw data. | ||
*/ | ||
static getRaw(pluginId: string): IVConsoleLogStore; | ||
/** | ||
* Get all stores. | ||
*/ | ||
static getAll(): { | ||
[pluginId: string]: Writable<IVConsoleLogStore>; | ||
}; | ||
} | ||
} | ||
declare module "log/log" { | ||
import VConsolePlugin from "lib/plugin"; | ||
type VConsoleLogArgs = any[]; | ||
type VConsoleLogType = 'log' | 'info' | 'warn' | 'debug' | 'error'; | ||
interface VConsoleLogItem { | ||
_id?: string; | ||
tabName?: 'default' | 'system'; | ||
logType: VConsoleLogType; | ||
logs?: VConsoleLogArgs; | ||
content?: Element; | ||
noOrigin?: boolean; | ||
date?: number; | ||
declare module "log/log.model" { | ||
import { VConsoleModel } from "lib/model"; | ||
/********************************** | ||
* Interfaces | ||
**********************************/ | ||
export type IConsoleLogMethod = 'log' | 'info' | 'debug' | 'warn' | 'error'; | ||
export interface IVConsoleLogData { | ||
origData: any; | ||
style?: string; | ||
logClass?: string; | ||
} | ||
interface VConsoleLogView { | ||
export interface IVConsoleLog { | ||
_id: string; | ||
logType: VConsoleLogType; | ||
logText: string; | ||
hasContent: boolean; | ||
hasFold: boolean; | ||
count: number; | ||
type: IConsoleLogMethod; | ||
cmdType?: 'input' | 'output'; | ||
repeated?: number; | ||
date: number; | ||
data: IVConsoleLogData[]; | ||
} | ||
class VConsoleLogTab extends VConsolePlugin { | ||
tplTabbox: string; | ||
allowUnformattedLog: boolean; | ||
isReady: boolean; | ||
isShow: boolean; | ||
$tabbox: Element; | ||
console: { | ||
[method: string]: any; | ||
}; | ||
logList: VConsoleLogItem[]; | ||
cachedLogs: { | ||
[id: string]: string; | ||
}; | ||
previousLog: VConsoleLogView; | ||
isInBottom: boolean; | ||
export type IVConsoleLogListMap = { | ||
[pluginId: string]: IVConsoleLog[]; | ||
}; | ||
export type IVConsoleLogFilter = { | ||
[pluginId: string]: string; | ||
}; | ||
export interface IVConsoleAddLogOptions { | ||
noOrig?: boolean; | ||
cmdType?: 'input' | 'output'; | ||
} | ||
/********************************** | ||
* Stores | ||
**********************************/ | ||
/********************************** | ||
* Model | ||
**********************************/ | ||
export class VConsoleLogModel extends VConsoleModel { | ||
readonly LOG_METHODS: IConsoleLogMethod[]; | ||
ADDED_LOG_PLUGIN_ID: string[]; | ||
maxLogNumber: number; | ||
logNumber: number; | ||
constructor(...args: any[]); | ||
protected logCounter: number; | ||
protected pluginPattern: RegExp; | ||
/** | ||
* when vConsole is ready, | ||
* this event will be triggered (after 'add' event) | ||
* @public | ||
* The original `window.console` methods. | ||
*/ | ||
onInit(): void; | ||
origConsole: { | ||
[method: string]: Function; | ||
}; | ||
/** | ||
* this event will make this plugin be registered as a tab | ||
* @public | ||
* Bind a Log plugin. | ||
* When binding first plugin, `window.console` will be hooked. | ||
*/ | ||
onRenderTab(callback: Function): void; | ||
onAddTopBar(callback: Function): void; | ||
onAddTool(callback: Function): void; | ||
bindPlugin(pluginId: string): boolean; | ||
/** | ||
* after init | ||
* @public | ||
* Unbind a Log plugin. | ||
* When no binded plugin exists, hooked `window.console` will be recovered. | ||
*/ | ||
onReady(): void; | ||
unbindPlugin(pluginId: string): boolean; | ||
/** | ||
* before remove | ||
* @public | ||
* Hook `window.console` with vConsole log method. | ||
* Methods will be hooked only once. | ||
*/ | ||
onRemove(): void; | ||
onShow(): void; | ||
onHide(): void; | ||
onShowConsole(): void; | ||
onUpdateOption(): void; | ||
updateMaxLogNumber(): void; | ||
limitMaxLogs(): void; | ||
showLogType(logType: string): void; | ||
autoScrollToBottom(): void; | ||
scrollToBottom(): void; | ||
mockConsole(): void; | ||
/** | ||
* replace window.console with vConsole method | ||
* Recover `window.console`. | ||
*/ | ||
protected mockConsole(): void; | ||
clearLog(): void; | ||
beforeRenderLog($line: Element): void; | ||
unmockConsole(): void; | ||
/** | ||
* print log to origin console | ||
* @protected | ||
* Call origin `window.console[method](...args)` | ||
*/ | ||
printOriginLog(item: VConsoleLogItem): void; | ||
callOriginalConsole(method: string, ...args: any[]): void; | ||
/** | ||
* print a log to log box | ||
* Remove all logs. | ||
*/ | ||
protected printLog(item: VConsoleLogItem): void; | ||
clearLog(): void; | ||
/** | ||
* Render the count of a repeated log | ||
* Remove a plugin's logs. | ||
*/ | ||
printRepeatLog(): void; | ||
clearPluginLog(pluginId: string): void; | ||
/** | ||
* Render a new log | ||
* Add a vConsole log. | ||
*/ | ||
protected printNewLog(item: VConsoleLogItem, logs: VConsoleLogArgs): void; | ||
addLog(item?: { | ||
type: IConsoleLogMethod; | ||
origData: any[]; | ||
}, opt?: IVConsoleAddLogOptions): void; | ||
/** | ||
* generate the HTML element of a folded line | ||
* Execute a JS command. | ||
*/ | ||
protected getFoldedLine(obj: any, outer?: string): Element; | ||
evalCommand(cmd: string): void; | ||
protected _extractPluginIdByLog(log: IVConsoleLog): string; | ||
protected _isRepeatedLog(pluginId: string, log: IVConsoleLog): boolean; | ||
protected _updateLastLogRepeated(pluginId: string): void; | ||
protected _pushLogList(pluginId: string, log: IVConsoleLog): void; | ||
protected _limitLogListLength(): void; | ||
} | ||
export default VConsoleLogTab; | ||
} | ||
declare module "log/log" { | ||
import { VConsoleSveltePlugin } from "lib/sveltePlugin"; | ||
import { VConsoleLogModel } from "log/log.model"; | ||
/** | ||
* vConsole Log Plugin (base class). | ||
*/ | ||
export class VConsoleLogPlugin extends VConsoleSveltePlugin { | ||
module: VConsoleLogModel; | ||
isReady: boolean; | ||
isShow: boolean; | ||
isInBottom: boolean; | ||
constructor(id: string, name: string); | ||
onReady(): void; | ||
onRemove(): void; | ||
onAddTopBar(callback: Function): void; | ||
onAddTool(callback: Function): void; | ||
onUpdateOption(): void; | ||
} | ||
export default VConsoleLogPlugin; | ||
} | ||
declare module "log/default" { | ||
import VConsoleLogTab from "log/log"; | ||
class VConsoleDefaultTab extends VConsoleLogTab { | ||
private filterText; | ||
constructor(...args: any[]); | ||
import { VConsoleLogPlugin } from "log/log"; | ||
export class VConsoleDefaultPlugin extends VConsoleLogPlugin { | ||
protected onErrorHandler: any; | ||
protected resourceErrorHandler: any; | ||
protected rejectionHandler: any; | ||
onReady(): void; | ||
beforeRenderLog($line: Element): void; | ||
onRemove(): void; | ||
/** | ||
* replace window.console & window.onerror with vConsole method | ||
* Catch window errors. | ||
*/ | ||
protected mockConsole(): void; | ||
protected bindErrors(): void; | ||
/** | ||
* Catch window.onerror | ||
* Not catch window errors. | ||
*/ | ||
private catchWindowOnError; | ||
protected unbindErrors(): void; | ||
/** | ||
* Promise.reject has no rejection handler | ||
* about https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event | ||
* Catch `window.onerror`. | ||
*/ | ||
private catchUnhandledRejection; | ||
protected catchWindowOnError(): void; | ||
/** | ||
* Catch resource loading error: image, video, link, script | ||
* Catch resource loading error: image, video, link, script. | ||
*/ | ||
private catchResourceError; | ||
protected catchResourceError(): void; | ||
/** | ||
* Run a command | ||
* Catch `Promise.reject`. | ||
* @reference https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event | ||
*/ | ||
private evalCommand; | ||
private checkFilterInLine; | ||
private catchUnhandledRejection; | ||
} | ||
export default VConsoleDefaultTab; | ||
export default VConsoleDefaultPlugin; | ||
} | ||
declare module "log/system" { | ||
/** | ||
* vConsole System Tab | ||
*/ | ||
import VConsoleLogTab from "log/log"; | ||
class VConsoleSystemTab extends VConsoleLogTab { | ||
constructor(...args: any[]); | ||
onInit(): void; | ||
import { VConsoleLogPlugin } from "log/log"; | ||
export class VConsoleSystemPlugin extends VConsoleLogPlugin { | ||
onReady(): void; | ||
printSystemInfo(): void; | ||
} | ||
export default VConsoleSystemTab; | ||
export default VConsoleSystemPlugin; | ||
} | ||
declare module "network/network" { | ||
import VConsolePlugin from "lib/plugin"; | ||
class VConsoleNetworkTab extends VConsolePlugin { | ||
private $tabbox; | ||
private $header; | ||
private reqList; | ||
private domList; | ||
private isShow; | ||
private isInBottom; | ||
declare module "network/network.model" { | ||
import { VConsoleModel } from "lib/model"; | ||
export class VConsoleNetworkRequestItem { | ||
id: string; | ||
name: string; | ||
method: string; | ||
url: string; | ||
status: number | string; | ||
statusText: string; | ||
readyState: XMLHttpRequest['readyState']; | ||
header: { | ||
[key: string]: string; | ||
}; | ||
responseType: XMLHttpRequest['responseType']; | ||
requestType: 'xhr' | 'fetch' | 'ping'; | ||
requestHeader: HeadersInit; | ||
response: any; | ||
startTime: number; | ||
endTime: number; | ||
costTime: number; | ||
getData: { | ||
[key: string]: string; | ||
}; | ||
postData: { | ||
[key: string]: string; | ||
} | string; | ||
actived: boolean; | ||
constructor(id: string); | ||
} | ||
/** | ||
* Network Store | ||
*/ | ||
export const requestList: import("svelte/store").Writable<{ | ||
[id: string]: VConsoleNetworkRequestItem; | ||
}>; | ||
/** | ||
* Network Model | ||
*/ | ||
export class VConsoleNetworkModel extends VConsoleModel { | ||
private _xhrOpen; | ||
@@ -375,33 +522,24 @@ private _xhrSend; | ||
private _sendBeacon; | ||
constructor(...args: any[]); | ||
onRenderTab(callback: any): void; | ||
onAddTool(callback: any): void; | ||
onReady(): void; | ||
onRemove(): void; | ||
onShow(): void; | ||
onHide(): void; | ||
onShowConsole(): void; | ||
autoScrollToBottom(): void; | ||
scrollToBottom(): void; | ||
constructor(); | ||
unMock(): void; | ||
clearLog(): void; | ||
private renderHeader; | ||
/** | ||
* add or update a request item by request ID | ||
* @private | ||
*/ | ||
* add or update a request item by request ID | ||
* @private | ||
*/ | ||
private updateRequest; | ||
/** | ||
* mock XMLHttpRequest | ||
* @private | ||
*/ | ||
* mock XMLHttpRequest | ||
* @private | ||
*/ | ||
private mockXHR; | ||
/** | ||
* mock fetch request | ||
* @private | ||
*/ | ||
* mock fetch request | ||
* @private | ||
*/ | ||
private mockFetch; | ||
/** | ||
* mock navigator.sendBeacon | ||
* @private | ||
*/ | ||
* mock navigator.sendBeacon | ||
* @private | ||
*/ | ||
private mockSendBeacon; | ||
@@ -411,65 +549,106 @@ private getFormattedBody; | ||
} | ||
export default VConsoleNetworkTab; | ||
export default VConsoleNetworkModel; | ||
} | ||
declare module "element/node_view" { | ||
class NodeView { | ||
node: any; | ||
view: HTMLElement; | ||
constructor(node: any); | ||
get(): HTMLElement; | ||
_create(node: any, isRoot?: boolean): HTMLElement; | ||
_createTextNode(node: any, view: any): void; | ||
_createElementNode(node: any, view: any): void; | ||
declare module "network/network" { | ||
import { VConsoleSveltePlugin } from "lib/sveltePlugin"; | ||
import { VConsoleNetworkModel } from "network/network.model"; | ||
export class VConsoleNetworkPlugin extends VConsoleSveltePlugin { | ||
protected module: VConsoleNetworkModel; | ||
constructor(id: string, name: string, renderProps?: {}); | ||
onAddTool(callback: any): void; | ||
onRemove(): void; | ||
} | ||
export default NodeView; | ||
} | ||
declare module "element/element.model" { | ||
export interface IVConsoleNode { | ||
nodeType: typeof Node.prototype.nodeType; | ||
nodeName: typeof Node.prototype.nodeName; | ||
textContent: typeof Node.prototype.textContent; | ||
id: typeof Element.prototype.id; | ||
className: typeof Element.prototype.className; | ||
attributes: { | ||
[name: string]: string; | ||
}[]; | ||
childNodes: IVConsoleNode[]; | ||
_isExpand?: boolean; | ||
_isActived?: boolean; | ||
_isSingleLine?: boolean; | ||
_isNullEndTag?: boolean; | ||
} | ||
/** | ||
* Element Store | ||
*/ | ||
export const rootNode: import("svelte/store").Writable<IVConsoleNode>; | ||
export const activedNode: import("svelte/store").Writable<IVConsoleNode>; | ||
} | ||
declare module "element/element" { | ||
import VConsolePlugin from "lib/plugin"; | ||
class VConsoleElementsTab extends VConsolePlugin { | ||
isInited: boolean; | ||
node: {}; | ||
$tabbox: Element; | ||
nodes: any[]; | ||
activedElem: Element; | ||
observer: any; | ||
constructor(...args: any[]); | ||
onRenderTab(callback: any): void; | ||
onAddTool(callback: any): void; | ||
import MutationObserver from 'mutation-observer'; | ||
import { VConsoleSveltePlugin } from "lib/sveltePlugin"; | ||
import type { IVConsoleNode } from "element/element.model"; | ||
/** | ||
* vConsole Element Panel | ||
*/ | ||
export class VConsoleElementPlugin extends VConsoleSveltePlugin { | ||
protected isInited: boolean; | ||
protected observer: MutationObserver; | ||
protected nodeMap: WeakMap<Node, IVConsoleNode>; | ||
constructor(id: string, name: string, renderProps?: {}); | ||
onShow(): void; | ||
onRemove(): void; | ||
onMutation(mutation: any): void; | ||
onChildRemove(mutation: any): void; | ||
onChildAdd(mutation: any): void; | ||
onAttributesChange(mutation: any): void; | ||
onCharacterDataChange(mutation: any): void; | ||
renderView(node: any, $related: any, renderMethod?: 'replace' | 'insertBefore'): HTMLElement; | ||
getNode(elem: any): any; | ||
_isIgnoredElement(elem: any): boolean; | ||
_isInVConsole(elem: any): boolean; | ||
onAddTool(callback: any): void; | ||
protected _init(): void; | ||
protected _handleMutation(mutation: MutationRecord): void; | ||
protected _onChildRemove(mutation: MutationRecord): void; | ||
protected _onChildAdd(mutation: MutationRecord): void; | ||
protected _onAttributesChange(mutation: MutationRecord): void; | ||
protected _onCharacterDataChange(mutation: MutationRecord): void; | ||
/** | ||
* Generate an VNode for rendering views. VNode will be updated if existing. | ||
* VNode will be stored in a WeakMap. | ||
*/ | ||
protected _generateVNode(elem: Node): IVConsoleNode; | ||
protected _updateVNodeAttributes(elem: Node): void; | ||
/** | ||
* Expand the actived node. | ||
* If the node is collapsed, expand it. | ||
* If the node is expanded, expand it's child nodes. | ||
*/ | ||
protected _expandActivedNode(): void; | ||
/** | ||
* Collapse the actived node. | ||
* If the node is expanded, and has expanded child nodes, collapse it's child nodes. | ||
* If the node is expanded, and has no expanded child node, collapse it self. | ||
* If the node is collapsed, do nothing. | ||
*/ | ||
protected _collapseActivedNode(): void; | ||
protected _isIgnoredNode(elem: Node): boolean; | ||
protected _isInVConsole(elem: Element): boolean; | ||
protected _refreshStore(): void; | ||
} | ||
export default VConsoleElementsTab; | ||
} | ||
declare module "lib/sveltePlugin" { | ||
import VConsolePlugin from "lib/plugin"; | ||
import { SvelteComponent } from 'svelte'; | ||
export class VConsoleSveltePlugin<T extends {} = {}> extends VConsolePlugin { | ||
Comp: typeof SvelteComponent; | ||
comp?: SvelteComponent; | ||
initialProps: T; | ||
$dom: HTMLElement; | ||
constructor(id: string, name: string, Comp: typeof SvelteComponent, renderProps: T); | ||
onRenderTab(callback: any): void; | ||
onRemove(): void; | ||
declare module "storage/storage.model" { | ||
import { CookieStorage } from 'cookie-storage'; | ||
import { VConsoleModel } from "lib/model"; | ||
interface IStorageItem { | ||
name: string; | ||
storage: Storage; | ||
} | ||
export default VConsoleSveltePlugin; | ||
export class VConsoleStorageModel extends VConsoleModel { | ||
protected cookiesStorage: CookieStorage; | ||
protected storages: IStorageItem[]; | ||
/** | ||
* Get the singleton of storage list. | ||
*/ | ||
getAllStorages(): IStorageItem[]; | ||
} | ||
} | ||
declare module "components/Storage/index" { | ||
export { default as StorageTab } from './Template.svelte'; | ||
} | ||
declare module "storage/storage" { | ||
import VConsoleSveltePlugin from "lib/sveltePlugin"; | ||
export default class VConsoleStorageTab extends VConsoleSveltePlugin { | ||
constructor(id: string, name: string, renderProps?: { | ||
propA: number; | ||
}); | ||
import { VConsoleSveltePlugin } from "lib/sveltePlugin"; | ||
import { VConsoleStorageModel } from "storage/storage.model"; | ||
export class VConsoleStoragePlugin extends VConsoleSveltePlugin { | ||
protected model: VConsoleStorageModel; | ||
constructor(id: string, name: string, renderProps?: {}); | ||
onShow(): void; | ||
onAddTopBar(callback: Function): void; | ||
onAddTool(callback: Function): void; | ||
} | ||
@@ -481,10 +660,10 @@ } | ||
*/ | ||
import * as tool from "lib/tool"; | ||
import VConsolePlugin from "lib/plugin"; | ||
import VConsoleLogPlugin from "log/log"; | ||
import VConsoleDefaultPlugin from "log/default"; | ||
import VConsoleSystemPlugin from "log/system"; | ||
import VConsoleNetworkPlugin from "network/network"; | ||
import VConsoleElementPlugin from "element/element"; | ||
import VConsoleStoragePlugin from "storage/storage"; | ||
import type { SvelteComponent } from 'svelte'; | ||
import { VConsolePlugin } from "lib/plugin"; | ||
import { VConsoleLogPlugin } from "log/log"; | ||
import { VConsoleDefaultPlugin } from "log/default"; | ||
import { VConsoleSystemPlugin } from "log/system"; | ||
import { VConsoleNetworkPlugin } from "network/network"; | ||
import { VConsoleElementPlugin } from "element/element"; | ||
import { VConsoleStoragePlugin } from "storage/storage"; | ||
interface VConsoleOptions { | ||
@@ -500,32 +679,8 @@ defaultPlugins?: ('system' | 'network' | 'element' | 'storage')[]; | ||
version: string; | ||
$dom: HTMLElement; | ||
isInited: boolean; | ||
option: VConsoleOptions; | ||
protected activedTab: string; | ||
protected tabList: any[]; | ||
protected pluginList: {}; | ||
protected switchPos: { | ||
hasMoved: boolean; | ||
x: number; | ||
y: number; | ||
startX: number; | ||
startY: number; | ||
endX: number; | ||
endY: number; | ||
protected compInstance: SvelteComponent; | ||
protected pluginList: { | ||
[id: string]: VConsolePlugin; | ||
}; | ||
tool: typeof tool; | ||
$: { | ||
one: (selector: string, contextElement?: Element | Document) => HTMLElement; | ||
all: (selector: string, contextElement?: Element | Document) => HTMLElement[]; | ||
addClass: ($el: Element | Element[], className: string) => void; | ||
removeClass: ($el: Element | Element[], className: string) => void; | ||
hasClass: ($el: Element, className: string) => boolean; | ||
bind: ($el: Element | Element[], eventType: any, fn: any, useCapture?: boolean) => void; | ||
delegate: ($el: Element, eventType: string, selector: string, fn: (event: Event, $target: HTMLElement) => void) => void; | ||
removeChildren($el: Element): Element; | ||
render: { | ||
<T extends true>(tpl: string, data: any, toString: T): string; | ||
<T_1 extends false>(tpl: string, data: any, toString?: T_1): Element; | ||
}; | ||
}; | ||
static VConsolePlugin: typeof VConsolePlugin; | ||
@@ -540,33 +695,15 @@ static VConsoleLogPlugin: typeof VConsoleLogPlugin; | ||
/** | ||
* add built-in plugins | ||
* @private | ||
*/ | ||
* Add built-in plugins. | ||
*/ | ||
private _addBuiltInPlugins; | ||
/** | ||
* render panel DOM | ||
* @private | ||
*/ | ||
private _render; | ||
* Init svelte component. | ||
*/ | ||
private _initComponent; | ||
private _updateComponentByOptions; | ||
/** | ||
* Update theme | ||
* @private | ||
*/ | ||
private _updateTheme; | ||
setSwitchPosition(switchX: number, switchY: number): void; | ||
* Update the position of Switch button. | ||
*/ | ||
setSwitchPosition(x: number, y: number): void; | ||
/** | ||
* Get an safe [x, y] position for switch button | ||
* @private | ||
*/ | ||
private _getSwitchButtonSafeAreaXY; | ||
/** | ||
* simulate tap event by touchstart & touchend | ||
* @private | ||
*/ | ||
private _mockTap; | ||
/** | ||
* bind DOM events | ||
* @private | ||
*/ | ||
private _bindEvent; | ||
/** | ||
* auto run after initialization | ||
@@ -576,18 +713,17 @@ * @private | ||
private _autoRun; | ||
private _showFirstPluginWhenEmpty; | ||
/** | ||
* trigger a vConsole.option event | ||
*/ | ||
* Trigger a `vConsole.option` event. | ||
*/ | ||
triggerEvent(eventName: string, param?: any): void; | ||
/** | ||
* init a plugin | ||
* @private | ||
*/ | ||
* Init a plugin. | ||
*/ | ||
private _initPlugin; | ||
/** | ||
* trigger an event for each plugin | ||
* @private | ||
*/ | ||
* Trigger an event for each plugin/ | ||
*/ | ||
private _triggerPluginsEvent; | ||
/** | ||
* trigger an event by plugin's name | ||
* trigger an event by plugin's id | ||
* @private | ||
@@ -597,48 +733,36 @@ */ | ||
/** | ||
* add a new plugin | ||
* @public | ||
* @param object VConsolePlugin object | ||
* @return boolean | ||
*/ | ||
* Add a new plugin. | ||
*/ | ||
addPlugin(plugin: VConsolePlugin): boolean; | ||
/** | ||
* remove a plugin | ||
* @public | ||
* @param string pluginID | ||
* @return boolean | ||
*/ | ||
* Remove a plugin. | ||
*/ | ||
removePlugin(pluginID: string): boolean; | ||
/** | ||
* show console panel | ||
* @public | ||
*/ | ||
* Show console panel. | ||
*/ | ||
show(): void; | ||
/** | ||
* hide console panel | ||
* @public | ||
*/ | ||
* Hide console panel. | ||
*/ | ||
hide(): void; | ||
/** | ||
* show switch button | ||
* @public | ||
*/ | ||
* Show switch button | ||
*/ | ||
showSwitch(): void; | ||
/** | ||
* hide switch button | ||
*/ | ||
* Hide switch button. | ||
*/ | ||
hideSwitch(): void; | ||
/** | ||
* show a tab | ||
* @public | ||
*/ | ||
showTab(tabID: string): void; | ||
* Show a plugin panel. | ||
*/ | ||
showPlugin(pluginId: string): void; | ||
/** | ||
* update option(s) | ||
* @public | ||
*/ | ||
* Update option(s). | ||
*/ | ||
setOption(keyOrObj: any, value?: any): void; | ||
/** | ||
* uninstall vConsole | ||
* @public | ||
*/ | ||
* Remove vConsole. | ||
*/ | ||
destroy(): void; | ||
@@ -657,22 +781,19 @@ } | ||
} | ||
declare module "components/Button/index" { | ||
export { default as Btn } from './Template.svelte'; | ||
} | ||
declare module "lib/cookiesStorage" { | ||
import { CookieStorage as CookiesStorage } from 'cookie-storage'; | ||
export const cookiesStorage: CookiesStorage; | ||
} | ||
declare module "components/Storage/utils" { | ||
interface IStorageItem { | ||
name: string; | ||
storage: Storage; | ||
declare module "lib/mito" { | ||
/** | ||
* Mito.js | ||
* A simple template engine | ||
* | ||
* @author Maiz | ||
*/ | ||
export default class Mito { | ||
/** | ||
* Render `tpl` with `data` into a HTML string. | ||
*/ | ||
render<T extends true>(tpl: string, data: any, toString: T): string; | ||
/** | ||
* Render `tpl` with `data` into a HTML element. | ||
*/ | ||
render<T extends false>(tpl: string, data: any, toString?: T): Element; | ||
} | ||
export const getAllStorages: () => IStorageItem[]; | ||
} | ||
declare module "components/Tab/index" { | ||
export { default as Tabs } from './Tabs.svelte'; | ||
export { default as TabList } from './TabList.svelte'; | ||
export { default as TabPanel } from './TabPanel.svelte'; | ||
export { default as Tab } from './Tab.svelte'; | ||
export const TabsContext: {}; | ||
} |
{ | ||
"name": "vconsole", | ||
"version": "3.9.5", | ||
"version": "3.10.0", | ||
"description": "A lightweight, extendable front-end developer tool for mobile web page.", | ||
@@ -16,3 +16,2 @@ "homepage": "https://github.com/Tencent/vConsole", | ||
"build:typings": "tsc --build tsconfig.type.json", | ||
"build:typings:TODO": "dts-bundle-generator --no-banner=true -o dist/vconsole.min.d.ts src/vconsole.ts", | ||
"build:dev": "webpack --mode=development --progress", | ||
@@ -33,8 +32,6 @@ "watch": "webpack --mode=development --watch --progress", | ||
"dependencies": { | ||
"@fortawesome/free-solid-svg-icons": "^5.15.3", | ||
"cookie-storage": "^6.1.0", | ||
"copy-text-to-clipboard": "^3.0.1", | ||
"core-js": "^3.11.0", | ||
"mutation-observer": "^1.0.3", | ||
"svelte-fa": "^2.2.1" | ||
"mutation-observer": "^1.0.3" | ||
}, | ||
@@ -53,5 +50,2 @@ "devDependencies": { | ||
"css-loader": "^5.2.4", | ||
"dts-bundle-generator": "^5.9.0", | ||
"html-loader": "^2.1.2", | ||
"jsdom": "^16.5.3", | ||
"json-loader": "^0.5.7", | ||
@@ -64,7 +58,7 @@ "less": "^4.1.1", | ||
"svelte-preprocess": "^4.7.4", | ||
"typescript": "^4.3.5", | ||
"webpack": "^5.44.0", | ||
"webpack-cli": "^4.7.0", | ||
"webpack-dev-server": "^3.11.2", | ||
"webpack-merge": "^5.7.3" | ||
"typescript": "^4.5.4", | ||
"webpack": "^5.65.0", | ||
"webpack-cli": "^4.9.1", | ||
"webpack-dev-server": "^4.6.0", | ||
"webpack-merge": "^5.8.0" | ||
}, | ||
@@ -71,0 +65,0 @@ "author": "Tencent", |
[English](./README.md) | 简体中文 | ||
vConsole | ||
============================== | ||
[![npm version](https://badge.fury.io/js/vconsole.svg)](https://badge.fury.io/js/vconsole) | ||
--- | ||
一个轻量、可拓展、针对手机网页的前端开发者调试面板。 | ||
vConsole 是框架无关的,可以在 Vue、React 或其他任何框架中使用。 | ||
## 特性 | ||
现在 vConsole 是微信小程序的官方调试工具。 | ||
- 查看 console 日志 | ||
- 查看网络请求 | ||
- 查看页面 element 结构 | ||
- 查看 Cookies、localStorage 和 SessionStorage | ||
## 功能特性 | ||
- 日志(Logs): `console.log|info|error|...` | ||
- 网络(Network): `XMLHttpRequest`, `Fetch`, `sendBeacon` | ||
- 节点(Element): HTML 节点树 | ||
- 存储(Storage): `Cookies`, `LocalStorage`, `SessionStorage` | ||
- 手动执行 JS 命令行 | ||
- 自定义插件 | ||
详情可参考下方的截图。 | ||
## 版本说明 | ||
最新版本: [![npm version](https://img.shields.io/npm/v/vconsole/latest.svg)](https://www.npmjs.com/package/vconsole) | ||
每个版本的详细说明请参阅 [Changelog](./CHANGELOG_CN.md)。 | ||
## 上手 | ||
方法一:使用 npm(推荐) | ||
详细使用方法请参阅[使用教程](./doc/tutorial_CN.md)。 | ||
将 vConsole 添加到项目中主要有以下方式: | ||
#### 方法一:使用 npm(推荐) | ||
```bash | ||
@@ -31,6 +48,6 @@ $ npm install vconsole | ||
```javascript | ||
import VConsole from 'vconsole'; | ||
import { VConsole } from 'vconsole'; | ||
const vConsole = new VConsole(); | ||
// 或者使用 options 选项初始化 | ||
// 或者使用配置参数来初始化,详情见文档 | ||
const vConsole = new VConsole({ maxLogNumber: 1000 }); | ||
@@ -45,6 +62,6 @@ | ||
方法二:使用 unpkg 的 CDN 直接插入到 HTML | ||
#### 方法二:使用 CDN 直接插入到 HTML | ||
```html | ||
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script> | ||
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> | ||
<script> | ||
@@ -56,5 +73,8 @@ // VConsole 默认会挂载到 `window.VConsole` 上 | ||
详细使用方法请参阅[使用教程](./doc/tutorial_CN.md)。 | ||
可用的 CDN: | ||
- https://unpkg.com/vconsole@latest/dist/vconsole.min.js | ||
- https://cdn.jsdelivr.net/npm/vconsole@latest/dist/vconsole.min.js | ||
## 手机预览 | ||
@@ -66,6 +86,29 @@ | ||
![](./doc/snapshot/panel_log.jpg) ![](./doc/snapshot/panel_network.jpg) ![](./doc/snapshot/panel_element.jpg) ![](./doc/snapshot/panel_storage.jpg) | ||
# 截图 | ||
| | | | ||
|---|---| | ||
| **概览**: | | | ||
| 浅色主题 | 暗色主题 | | ||
| ![](./doc/screenshot/overview_light.jpg) | ![](./doc/screenshot/overview_dark.jpg) | | ||
| **Log 面板**: | | | ||
| Log 样式 | 命令行 | | ||
| ![](./doc/screenshot/plugin_log_types.jpg) | ![](./doc/screenshot/plugin_log_command.jpg) | | ||
| **System 面板**: | | | ||
| Performance 信息 | 输出到不同的 log 面板 | | ||
| ![](./doc/screenshot/plugin_system.jpg) | `console.log('[system]', '输出到system面板')` | | ||
| **Network 面板**: | | | ||
| 请求、回包的详情 | | | ||
| ![](./doc/screenshot/plugin_network.jpg) | | | ||
| **Element 面板**: | | | ||
| 展示 HTML 对象结构 | | | ||
| ![](./doc/screenshot/plugin_element.jpg) | | | ||
| **Storage 面板**: | | | ||
| 添加、编辑、删除、复制 Cookies / LocalStorage / SessionStorage | | | ||
| ![](./doc/screenshot/plugin_storage.jpg) | | | ||
## 文档 | ||
@@ -78,3 +121,2 @@ | ||
- [公共属性及方法](./doc/public_properties_methods_CN.md) | ||
- [辅助函数](./doc/helper_functions_CN.md) | ||
@@ -98,8 +140,4 @@ 插件: | ||
## 更新记录 | ||
[CHANGELOG_CN.md](./CHANGELOG_CN.md) | ||
## 交流反馈 | ||
@@ -106,0 +144,0 @@ |
English | [简体中文](./README_CN.md) | ||
vConsole | ||
============================== | ||
[![npm version](https://badge.fury.io/js/vconsole.svg)](https://badge.fury.io/js/vconsole) | ||
--- | ||
A lightweight, extendable front-end developer tool for mobile web page. | ||
vConsole is framework-free, you can use it in Vue or React or any other framework application. | ||
Now vConsole is the official debugging tool for WeChat Miniprograms. | ||
## Features | ||
- View console logs | ||
- View network requests | ||
- View document elements | ||
- View Cookies, LocalStorage and SessionStorage | ||
- Logs: `console.log|info|error|...` | ||
- Network: `XMLHttpRequest`, `Fetch`, `sendBeacon` | ||
- Element: HTML elements tree | ||
- Storage: `Cookies`, `LocalStorage`, `SessionStorage` | ||
- Execute JS command manually | ||
- Custom plugin | ||
- Custom plugins | ||
For details, please see the screenshots below. | ||
## Usage | ||
Method 1: Using npm (Recommanded) | ||
## Release Notes | ||
Latest version: [![npm version](https://img.shields.io/npm/v/vconsole/latest.svg)](https://www.npmjs.com/package/vconsole) | ||
Detailed release notes for each version are available on [Changelog](./CHANGELOG.md). | ||
## Guide | ||
See [Tutorial](./doc/tutorial.md) for more usage details. | ||
For installation, there are 2 primary ways of adding vConsole to a project: | ||
#### Method 1: Using npm (Recommanded) | ||
```bash | ||
@@ -29,3 +46,3 @@ $ npm install vconsole | ||
```javascript | ||
import VConsole from 'vconsole'; | ||
import { VConsole } from 'vconsole'; | ||
@@ -43,6 +60,6 @@ const vConsole = new VConsole(); | ||
Method 2: Using unpkg CDN in HTML: | ||
#### Method 2: Using CDN in HTML: | ||
```html | ||
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script> | ||
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> | ||
<script> | ||
@@ -54,14 +71,41 @@ // VConsole will be exported to `window.VConsole` by default. | ||
See [Tutorial](./doc/tutorial.md) for more usage details. | ||
Available CDN: | ||
- https://unpkg.com/vconsole@latest/dist/vconsole.min.js | ||
- https://cdn.jsdelivr.net/npm/vconsole@latest/dist/vconsole.min.js | ||
## Preview | ||
![](./doc/snapshot/qrcode.png) | ||
[http://wechatfe.github.io/vconsole/demo.html](http://wechatfe.github.io/vconsole/demo.html) | ||
![](./doc/snapshot/panel_log.jpg) ![](./doc/snapshot/panel_network.jpg) ![](./doc/snapshot/panel_element.jpg) ![](./doc/snapshot/panel_storage.jpg) | ||
![](./doc/screenshot/qrcode.png) | ||
# Screenshots | ||
| | | | ||
|---|---| | ||
| **Overview**: | | | ||
| Light theme | Dark theme | | ||
| ![](./doc/screenshot/overview_light.jpg) | ![](./doc/screenshot/overview_dark.jpg) | | ||
| **Log Panel**: | | | ||
| Log styling | Command line | | ||
| ![](./doc/screenshot/plugin_log_types.jpg) | ![](./doc/screenshot/plugin_log_command.jpg) | | ||
| **System Panel**: | | | ||
| Performance info | Output logs to different panel | | ||
| ![](./doc/screenshot/plugin_system.jpg) | `console.log('[system]', 'output to system panel.')` | | ||
| **Network Panel**: | | | ||
| Request details | | | ||
| ![](./doc/screenshot/plugin_network.jpg) | | | ||
| **Element Panel**: | | | ||
| Realtime HTML elements structure | | | ||
| ![](./doc/screenshot/plugin_element.jpg) | | | ||
| **Storage Panel**: | | | ||
| Add, edit, delete or copy Cookies / LocalStorage / SessionStorage | | | ||
| ![](./doc/screenshot/plugin_storage.jpg) | | | ||
## Documentation | ||
@@ -73,3 +117,2 @@ | ||
- [Public Properties & Methods](./doc/public_properties_methods.md) | ||
- [Helper Functions](./doc/helper_functions.md) | ||
@@ -92,7 +135,3 @@ Plugin: | ||
## Changelog | ||
[CHANGELOG.md](./CHANGELOG.md) | ||
## Feedback | ||
@@ -102,3 +141,3 @@ | ||
![](./doc/snapshot/qq_group.png) | ||
![](./doc/screenshot/qq_group.png) | ||
@@ -105,0 +144,0 @@ |
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
280727
4
23
9
792
142
1
- Removedsvelte-fa@^2.2.1
- Removed@fortawesome/fontawesome-common-types@0.2.36(transitive)
- Removed@fortawesome/free-solid-svg-icons@5.15.4(transitive)
- Removedsvelte-fa@2.4.0(transitive)