├── .editorconfig
├── .gitignore
├── .prettierrc.js
├── CHANGELOG.EN.md
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.en.md
├── README.md
├── __tests__
├── __mocks__
│ └── index.js
└── unit
│ └── utils
│ └── shared.test.js
├── config
├── env.js
├── jest
│ ├── babelTransform.js
│ ├── cssTransform.js
│ ├── fileTransform.js
│ ├── graphqlTransform.js
│ └── setUp.js
├── modules.js
├── paths.js
├── pnpTs.js
├── polyfills.js
├── webpack.config.js
└── webpackDevServer.config.js
├── docs
├── asset-manifest.json
├── favicon.ico
├── index.html
├── index.js
└── manifest.json
├── jest.config.js
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── scripts
├── build.js
├── docs.js
├── start.js
└── test.js
└── src
├── App.js
├── App.module.css
├── components
├── header
│ ├── header.module.css
│ └── index.jsx
├── index.js
├── lockscroll
│ └── index.jsx
├── panel
│ ├── index.jsx
│ └── pannel.module.css
├── printer
│ ├── index.jsx
│ └── printer.module.css
├── protector
│ └── index.jsx
├── reactDevTools
│ ├── app
│ │ ├── App.module.css
│ │ └── index.jsx
│ ├── browser
│ │ ├── browserWindow.jsx
│ │ ├── browserWindow.module.css
│ │ └── devTools.jsx
│ ├── console
│ │ ├── console.jsx
│ │ └── console.module.css
│ ├── icon
│ │ ├── icon.jsx
│ │ ├── icon.module.css
│ │ ├── iconButton.jsx
│ │ └── iconButton.module.css
│ ├── index.jsx
│ └── setupDevToolsBackend.js
├── showmore
│ ├── index.jsx
│ └── showmore.module.css
└── toolbar
│ ├── index.jsx
│ └── toolbar.module.css
├── constants
├── error
│ └── index.js
├── feature
│ └── index.js
└── index.js
├── index.css
├── index.js
├── modules
├── application
│ └── index.js
├── console
│ └── index.js
├── header
│ └── index.js
├── index.js
├── network
│ └── index.js
├── panelCon
│ └── index.js
├── performance
│ └── index.js
├── proxy
│ └── index.js
├── settings
│ └── index.js
├── system
│ └── index.js
└── toolbar
│ └── index.js
├── panels
├── about
│ ├── about.module.css
│ └── index.jsx
├── application
│ ├── application.module.css
│ └── index.jsx
├── console
│ ├── console.module.css
│ └── index.jsx
├── detection
│ ├── detection.module.css
│ └── index.jsx
├── elements
│ ├── elements.module.css
│ └── index.jsx
├── network
│ ├── index.jsx
│ └── network.module.css
├── performance
│ ├── index.jsx
│ └── performance.module.css
├── proxy
│ ├── index.jsx
│ └── proxy.module.css
├── settings
│ ├── index.jsx
│ └── settings.module.css
└── system
│ ├── index.jsx
│ └── system.module.css
├── polyfill.js
├── reducers
├── application
│ └── index.js
├── console
│ └── index.js
├── index.js
├── network
│ └── index.js
├── settings
│ └── index.js
├── system
│ └── index.js
└── tab
│ └── index.js
├── store
└── index.js
└── utils
├── ajax
└── index.js
├── console
└── index.js
├── copy
└── index.js
├── dimension
└── index.js
├── emitter
└── index.js
├── headers
└── index.js
├── index.js
├── log
└── index.js
├── network
└── index.js
├── object
└── index.js
├── performance
└── index.js
├── resources
└── index.js
├── shared
└── index.js
├── storage
└── index.js
├── ua
└── index.js
└── url
└── index.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | insert_final_newline = true
7 | trim_trailing_whitespace = true
8 |
9 | [{*.js,*.json,*.yml}]
10 | indent_size = 2
11 | indent_style = space
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 | /dist
12 |
13 | # misc
14 | .DS_Store
15 | .env.local
16 | .env.development.local
17 | .env.test.local
18 | .env.production.local
19 |
20 | npm-debug.log*
21 | yarn-debug.log*
22 | yarn-error.log*
23 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | printWidth: 100,
3 | semi: true,
4 | singleQuote: true,
5 | trailingComma: 'all',
6 | bracketSpacing: true,
7 | jsxBracketSameLine: true,
8 | arrowParens: 'avoid',
9 | insertPragma: false,
10 | tabWidth: 2,
11 | useTabs: false,
12 | };
13 |
--------------------------------------------------------------------------------
/CHANGELOG.EN.md:
--------------------------------------------------------------------------------
1 | # 2021.8.24
2 |
3 | + Release v1.0.0
4 |
5 | # 2021.8.25
6 |
7 | + Release v1.0.1
8 | + Add English readme
9 |
10 | # 2021.8.28
11 |
12 | + Release v1.0.2
13 | + Add some unit tests and delete some useless code
14 |
15 | # 2021.8.31
16 |
17 | + Release v1.0.3
18 | + Update readme
19 |
20 | # 2021.9.02
21 |
22 | + Release v1.0.4
23 | + Add Js&&Css latest feature detection
24 |
25 | # 2021.9.03
26 |
27 | + Upgrade related dependencies
28 | + Built-in react developer tools to increase react component debugging capabilities
29 |
30 | # 2021.9.06
31 |
32 | + Add setting panel, support dynamic adjustment of panel height [https://github.com/tnfe/mdebug/pull/19](https://github.com/tnfe/mdebug/pull/19)
33 | + Added support for formatting the response in the web panel [https://github.com/tnfe/mdebug/pull/21](https://github.com/tnfe/mdebug/pull/21)
34 | + Release 2.0.0
35 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 2021.8.24
2 |
3 | + mdebug发布 v1.0.0
4 |
5 | # 2021.8.25
6 |
7 | + mdebug发布 v1.0.1
8 | + 增加英文readme
9 |
10 | # 2021.8.28
11 |
12 | + mdebug发布 v1.0.2
13 | + 增加部分单元测试,删除部分无用代码
14 |
15 | # 2021.8.31
16 |
17 | + mdebug发布 v1.0.3
18 | + 更新readme
19 |
20 | # 2021.9.02
21 |
22 | + mdebug发布 v1.0.4
23 | + 增加Js&&Css最新特性检测
24 |
25 | # 2021.9.03
26 |
27 | + 升级相关依赖
28 | + 内嵌React开发者工具, 增加react组件调试能力
29 |
30 | # 2021.9.06
31 |
32 | + 增加设置面板,支持动态调整面板高度 [https://github.com/tnfe/mdebug/pull/19](https://github.com/tnfe/mdebug/pull/19)
33 | + 网络面板增加支持对response格式化 [https://github.com/tnfe/mdebug/pull/21](https://github.com/tnfe/mdebug/pull/21)
34 | + 发布2.0.0
35 |
36 | # 2021.9.17
37 |
38 | + 新增console.clear [https://github.com/tnfe/mdebug/pull/26](https://github.com/tnfe/mdebug/pull/26)
39 | + 发布2.0.2
40 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # 为mdebug做出贡献
2 |
3 | 欢迎您 [提出问题](https://github.com/tnfe/mdebug/issues) 或 [merge requests](https://github.com/tnfe/mdebug/merge_requests), 建议您在为 mdebug 做出贡献前先阅读以下 mdebug 贡献指南。
4 |
5 | ## issues
6 |
7 | 我们通过 [issues](https://github.com/tnfe/mdebug/issues) 来收集问题和功能相关的需求。
8 |
9 | ### 首先查看已知的问题
10 |
11 | 在您准备提出问题以前,请先查看现有的 [issues](https://github.com/tnfe/mdebug/issues) 是否已有其他人提出过相似的功能或问题,以确保您提出的问题是有效的。
12 |
13 | ### 提交问题
14 |
15 | 问题的表述应当尽可能的详细,可以包含相关的代码块。
16 |
17 | ## Merge Requests
18 |
19 | 我们十分期待您通过 [Merge Requests](https://github.com/tnfe/mdebug/merge_requests) 让 mdebug 变的更加完善。
20 |
21 | ### 分支管理
22 |
23 | mdebug 主仓库只包含 master 分支,其将作为稳定的开发分支,经过测试后会打 Tag 进行发布。
24 |
25 | ### Commit Message
26 |
27 | 我们希望您能使用`npm run commit`来提交代码,保持项目的一致性。
28 | 这样可以方便生成每个版本的 Changelog,很容易地追溯历史。
29 |
30 | ### MR/PR 流程
31 |
32 | TNFE 团队会查看所有的 MR/PR,我们会运行一些代码检查和测试,一经测试通过,我们会接受这次 MR/PR,但不会立即发布外网,会有一些延迟。
33 |
34 | 当您准备 MR 时,请确保已经完成以下几个步骤:
35 |
36 | 1. 将主仓库代码 Fork 到自己名下。
37 | 2. 基于 `master` 分支创建您的开发分支。
38 | 3. 如果您更改了 API(s) 请更新代码及文档。
39 | 4. 检查您的代码语法及格式。
40 | 5. 提一个 MR/PR 到主仓库的 `master` 分支上。
41 |
42 | ### 本地开发
43 |
44 | 首先安装相关依赖
45 |
46 | ```bash
47 | npm i
48 | ```
49 |
50 | 运行代码
51 |
52 | ```bash
53 | npm run start
54 | ```
55 |
56 | 使用 [npm link](https://docs.npmjs.com/cli/link.html) 进行测试
57 |
58 | ```bash
59 | npm link
60 | ```
61 |
62 | ## 许可证
63 |
64 | 通过为 mdebug 做出贡献,代表您同意将其版权归为 mdebug 所有,开源协议为 [MIT LICENSE](https://opensource.org/licenses/MIT)
65 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 html5@mobile
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.en.md:
--------------------------------------------------------------------------------
1 | English | [简体中文](./README.md)
2 |
3 |
4 |
5 |
6 | A Lightweight, Easy To Extend Web Debugging Tool Build With React CHANGELOG
7 |
8 |
9 | Easy to use
|
10 | Full-featured |
11 | Easy to expand |
12 | high performance |
13 |
14 |
15 | Use the cdn method, one-click access |
16 | Chrome devtools-like, built-in React developer tools, support log, network, element, proxy, storage, performance, etc., have better network capture capabilities and rich log display forms |
17 | Expose rich internal events, which can be seamlessly integrated with react components |
18 | Support large amount of data display, no lag |
19 |
20 |
21 |
22 |
27 |
28 | ## Demos
29 |
30 | https://tnfe.github.io/mdebug
31 |
32 | 
33 |
34 |
35 |
36 | ## Examples
37 |
38 | + Vanilla
39 |
40 | [](https://codesandbox.io/s/crimson-sun-py8x7?fontsize=14&hidenavigation=1&theme=dark)
41 |
42 |
43 | ## Installation
44 |
45 | #### Install using npm
46 | ```
47 | npm install mdebug --save
48 |
49 | ```
50 | ## Useage
51 |
52 | ### 1. ES6
53 | ```javascript
54 | import mdebug from 'mdebug';
55 | mdebug.init();
56 | ```
57 |
58 | ### 2.CDN
59 | ```javascript
60 | (function() {
61 | var scp = document.createElement('script');
62 | // Load the latest mdebug version
63 | scp.src = 'https://unpkg.com/mdebug@latest/dist/index.js';
64 | scp.async = true;
65 | scp.charset = 'utf-8';
66 | // Successfully loaded and initialized
67 | scp.onload = function() {
68 | mdebug.init();
69 | };
70 | // Load state switch callback
71 | scp.onreadystate = function() {};
72 | // Load failed callback
73 | scp.onerror = function() {};
74 | document.getElementsByTagName('head')[0].appendChild(scp);
75 | })();
76 | ```
77 | ## API
78 |
79 | ### 1. init
80 | ```javascript
81 | mdebug.init({
82 | containerId: '' // mdebug mounts the container id, if it is empty, a unique id will be automatically generated internally,
83 | plugins: [], // Incoming mdebug plugin
84 | hideToolbar: [], // Pass in the tab id that needs to be hidden
85 | });
86 | ```
87 | ### 2. addPlugin
88 | ```javascript
89 | mdebug.addPlugin({
90 | id: '', // tab id
91 | name: '', // Chinese title corresponding to tab,
92 | enName: '', // English title corresponding to tab
93 | component: () => {}, // React component corresponding to tab
94 | });
95 | ```
96 |
97 | ### 3. removePlugin
98 | ```javascript
99 | // Support the id of the panel to be removed
100 | /*
101 | System => system;
102 | Elements => elements;
103 | Console => console
104 | Application => application
105 | NetWork => network
106 | Performance => performance
107 | Settings => settings
108 | */
109 | mdebug.removePlugin([]);
110 | ```
111 |
112 | ### 4. exportLog
113 | ```javascript
114 | /*
115 | @returned {
116 | type: '' // Log type
117 | source: [], // Original log
118 | }
119 | @params type
120 | // type is equal to log, return all console logs
121 | // type is equal to net, return all net logs
122 | */
123 | mdebug.exportLog(type);
124 |
125 | ```
126 |
127 | ### 5. on
128 | ```javascript
129 | mdebug.on(eventName, callback);
130 | ```
131 | ### 6. emit
132 | ```javascript
133 | mdebug.emit(eventName, data);
134 | ```
135 |
136 | ## Event list
137 | | **Event name** | **params** | **Trigger timing** |
138 | | ---------- | :-----------: | :-----------: |
139 | | ready | object | mdebug loaded
140 | | addTab | object | Add panel
141 | | removeTab | array | Remove panel |
142 | | changeTab | object | Panel switch|
143 |
144 |
145 | ## development
146 |
147 | 1. npm i
148 | 2. npm start
149 | 3. npm run build
150 | ## Projects
151 | 1. [eruda](https://github.com/liriliri/eruda)
152 | 2. [vConsole](https://github.com/Tencent/vConsole)
153 | 3. [react-json-tree](https://github.com/alexkuz/react-json-tree)
154 | 4. [React-based mobile debugging solution](https://github.com/abell123456/mdebug)
155 | 5. [a useful debugger for mobile](https://github.com/ghking1/mdebug)
156 | 6. [autoDevTools](https://github.com/chokcoco/autoDevTools)
157 | 7. [react-inspector](https://github.com/xyc/react-inspector)
158 | 8. [web-console](https://github.com/whinc/web-console)
159 | 9. [ChromeDevTools](https://github.com/ChromeDevTools/devtools-frontend)
160 |
161 | ## License
162 | The MIT License (MIT). Please see [License File](./LICENSE) for more information.
163 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [English](./README.en.md) | 简体中文
2 |
3 |
4 |
5 |
6 | 基于React开发的移动web调试工具 更新日志
7 |
8 |
9 |
10 | 简单易用
|
11 | 功能全面 |
12 | 易扩展 |
13 | 高性能 |
14 |
15 |
16 | 使用cdn方式,一键接入 |
17 | 类Chrome devtools, 内嵌React开发者工具,支持日志,网络,元素,代理,存储,性能等, 具有更好的网络捕获能力和丰富的日志展现形式 |
18 | 暴露内部丰富的事件, 可以和react组件无缝进行集成 |
19 | 支持大数据量展示, 不卡顿 |
20 |
21 |
22 |
23 |
28 |
29 | ## 一、快速体验
30 |
31 | https://ihtml5.github.io/mdebug
32 |
33 | 
34 |
35 |
36 |
37 | ## 二、Examples
38 |
39 | + Vanilla
40 |
41 | [](https://codesandbox.io/s/crimson-sun-py8x7?fontsize=14&hidenavigation=1&theme=dark)
42 |
43 | ## 三、安装
44 |
45 | #### Install using npm
46 | ```
47 | npm install mdebug --save
48 |
49 | ```
50 | ## 四、使用
51 |
52 | ### 1. ES6
53 | ```javascript
54 | import mdebug from 'mdebug';
55 | mdebug.init();
56 | ```
57 |
58 | ### 2.CDN
59 | ```javascript
60 | (function() {
61 | var scp = document.createElement('script');
62 | // 加载最新的mdebug版本
63 | scp.src = 'https://unpkg.com/mdebug@latest/dist/index.js';
64 | scp.async = true;
65 | scp.charset = 'utf-8';
66 | // 加载成功并初始化
67 | scp.onload = function() {
68 | mdebug.init();
69 | };
70 | // 加载状态切换回调
71 | scp.onreadystate = function() {};
72 | // 加载失败回调
73 | scp.onerror = function() {};
74 | document.getElementsByTagName('head')[0].appendChild(scp);
75 | })();
76 | ```
77 | ## 五、API
78 |
79 | ### 1. init
80 | ```javascript
81 | mdebug.init({
82 | containerId: '' // mdebug挂载容器id, 如果传空, 内部会自动生成一个不重复的id,
83 | plugins: [], // 传入mdebug插件
84 | hideToolbar: [], // 传入需要隐藏的tab id
85 | });
86 | ```
87 | ### 2. addPlugin
88 | ```javascript
89 | mdebug.addPlugin({
90 | id: '', // tab id
91 | name: '', // tab对应的中文title,
92 | enName: '', // tab对应的英文title
93 | component: () => {}, // tab对应的react组件
94 | });
95 | ```
96 |
97 | ### 3. removePlugin
98 | ```javascript
99 | // 支持移除的panel对应的id
100 | /*
101 | System => system;
102 | Elements => elements;
103 | Console => console
104 | Application => application
105 | NetWork => network
106 | Performance => performance
107 | Settings => settings
108 | */
109 | mdebug.removePlugin([]);
110 | ```
111 |
112 | ### 4. exportLog
113 | ```javascript
114 | /*
115 | @returned {
116 | type: '' // 日志类型
117 | source: [], // 原始日志
118 | }
119 | @params type
120 | // type等于log, 返回所有的console日志
121 | // type等于net, 返回所有的net日志
122 | */
123 | mdebug.exportLog(type);
124 |
125 | ```
126 |
127 | ### 5. on
128 | ```javascript
129 | mdebug.on(eventName, callback);
130 | ```
131 | ### 6. emit
132 | ```javascript
133 | mdebug.emit(eventName, data);
134 | ```
135 |
136 | ## 六、事件列表
137 | | **事件名称** | **数据** | **触发时机** |
138 | | ---------- | :-----------: | :-----------: |
139 | | ready | object | mdebug加载完毕
140 | | addTab | object | 增加面板
141 | | removeTab | array | 移除面板 |
142 | | changeTab | object | 面板切换|
143 |
144 |
145 | ## 七、开发
146 |
147 | 1. npm i
148 | 2. npm start // 启动开发
149 | 3. npm run build //打包
150 | 4. npm run test // 单元测试
151 |
152 | ## 八、相关文章
153 | 1. [移动端前端开发调试](https://www.cnblogs.com/yzg1/p/5160594.html?utm_source=tuicool&utm_medium=referral)
154 | 2. [Chrome 开发者工具](https://developers.google.com/web/tools/chrome-devtools/)
155 |
156 | ## 九、相关项目
157 | 1. [eruda](https://github.com/liriliri/eruda)
158 | 2. [vConsole](https://github.com/Tencent/vConsole)
159 | 3. [react-json-tree](https://github.com/alexkuz/react-json-tree)
160 | 4. [基于React的移动端调试解决方案](https://github.com/abell123456/mdebug)
161 | 5. [a useful debugger for mobile](https://github.com/ghking1/mdebug)
162 | 6. [autoDevTools](https://github.com/chokcoco/autoDevTools)
163 | 7. [react-inspector](https://github.com/xyc/react-inspector)
164 | 8. [web-console](https://github.com/whinc/web-console)
165 | 9. [ChromeDevTools](https://github.com/ChromeDevTools/devtools-frontend)
166 |
167 | ## 十、License
168 | The MIT License (MIT). Please see [License File](./LICENSE) for more information.
169 |
--------------------------------------------------------------------------------
/__tests__/__mocks__/index.js:
--------------------------------------------------------------------------------
1 | export const verifyBoolean = true;
2 | export const verifyArray = [];
3 | export const verifyObject = {};
4 | export const verifyError = new Error('message');
5 | export const verifyXmlhttp = new XMLHttpRequest();
--------------------------------------------------------------------------------
/__tests__/unit/utils/shared.test.js:
--------------------------------------------------------------------------------
1 | import { isObject, isError, isXMLHttpRequest } from '@/utils/shared';
2 | import {
3 | verifyBoolean,
4 | verifyArray,
5 | verifyObject,
6 | verifyError,
7 | verifyXmlhttp
8 | } from '../../__mocks__';
9 |
10 | describe('utils/shared module', () => {
11 | test('shared/isObject', () => {
12 | expect(isObject(verifyBoolean)).toBe(false);
13 | expect(isObject(verifyArray)).toBe(false);
14 | expect(isObject(verifyObject)).toBe(true);
15 | });
16 |
17 | test('shared/isError', () => {
18 | expect(isError(verifyError)).toBe(true);
19 | expect(isError(verifyXmlhttp)).toBe(false);
20 | });
21 |
22 | test('shared/isXMLHttpRequest', () => {
23 | expect(isXMLHttpRequest(verifyError)).toBe(false);
24 | expect(isXMLHttpRequest(verifyArray)).toBe(false);
25 | expect(isXMLHttpRequest(verifyXmlhttp)).toBe(true);
26 | })
27 | });
--------------------------------------------------------------------------------
/config/env.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const paths = require('./paths');
6 |
7 | // Make sure that including paths.js after env.js will read .env variables.
8 | delete require.cache[require.resolve('./paths')];
9 |
10 | const NODE_ENV = process.env.NODE_ENV;
11 | if (!NODE_ENV) {
12 | throw new Error(
13 | 'The NODE_ENV environment variable is required but was not specified.'
14 | );
15 | }
16 |
17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18 | var dotenvFiles = [
19 | `${paths.dotenv}.${NODE_ENV}.local`,
20 | `${paths.dotenv}.${NODE_ENV}`,
21 | // Don't include `.env.local` for `test` environment
22 | // since normally you expect tests to produce the same
23 | // results for everyone
24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`,
25 | paths.dotenv,
26 | ].filter(Boolean);
27 |
28 | // Load environment variables from .env* files. Suppress warnings using silent
29 | // if this file is missing. dotenv will never modify any environment variables
30 | // that have already been set. Variable expansion is supported in .env files.
31 | // https://github.com/motdotla/dotenv
32 | // https://github.com/motdotla/dotenv-expand
33 | dotenvFiles.forEach(dotenvFile => {
34 | if (fs.existsSync(dotenvFile)) {
35 | require('dotenv-expand')(
36 | require('dotenv').config({
37 | path: dotenvFile,
38 | })
39 | );
40 | }
41 | });
42 |
43 | // We support resolving modules according to `NODE_PATH`.
44 | // This lets you use absolute paths in imports inside large monorepos:
45 | // https://github.com/facebook/create-react-app/issues/253.
46 | // It works similar to `NODE_PATH` in Node itself:
47 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
50 | // https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51 | // We also resolve them to make sure all tools using them work consistently.
52 | const appDirectory = fs.realpathSync(process.cwd());
53 | process.env.NODE_PATH = (process.env.NODE_PATH || '')
54 | .split(path.delimiter)
55 | .filter(folder => folder && !path.isAbsolute(folder))
56 | .map(folder => path.resolve(appDirectory, folder))
57 | .join(path.delimiter);
58 |
59 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60 | // injected into the application via DefinePlugin in Webpack configuration.
61 | const REACT_APP = /^REACT_APP_/i;
62 |
63 | function getClientEnvironment(publicUrl) {
64 | const raw = Object.keys(process.env)
65 | .filter(key => REACT_APP.test(key))
66 | .reduce(
67 | (env, key) => {
68 | env[key] = process.env[key];
69 | return env;
70 | },
71 | {
72 | // Useful for determining whether we’re running in production mode.
73 | // Most importantly, it switches React into the correct mode.
74 | NODE_ENV: process.env.NODE_ENV || 'development',
75 | // Useful for resolving the correct path to static assets in `public`.
76 | // For example,
.
77 | // This should only be used as an escape hatch. Normally you would put
78 | // images into the `src` and `import` them in code to get their paths.
79 | PUBLIC_URL: publicUrl,
80 | }
81 | );
82 | // Stringify all values so we can feed into Webpack DefinePlugin
83 | const stringified = {
84 | 'process.env': Object.keys(raw).reduce((env, key) => {
85 | env[key] = JSON.stringify(raw[key]);
86 | return env;
87 | }, {}),
88 | };
89 |
90 | return { raw, stringified };
91 | }
92 |
93 | module.exports = getClientEnvironment;
94 |
--------------------------------------------------------------------------------
/config/jest/babelTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const babelJest = require('babel-jest');
4 |
5 | module.exports = babelJest.createTransformer({
6 | presets: [require.resolve('babel-preset-react-app')],
7 |
8 | });
9 |
--------------------------------------------------------------------------------
/config/jest/cssTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // This is a custom Jest transformer turning style imports into empty objects.
4 | // http://facebook.github.io/jest/docs/en/webpack.html
5 |
6 | module.exports = {
7 | process() {
8 | return 'module.exports = {};';
9 | },
10 | getCacheKey() {
11 | // The output is always the same.
12 | return 'cssTransform';
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/config/jest/fileTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const camelcase = require('camelcase');
5 |
6 | // This is a custom Jest transformer turning file imports into filenames.
7 | // http://facebook.github.io/jest/docs/en/webpack.html
8 |
9 | module.exports = {
10 | process(src, filename) {
11 | const assetFilename = JSON.stringify(path.basename(filename));
12 |
13 | if (filename.match(/\.svg$/)) {
14 | // Based on how SVGR generates a component name:
15 | // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
16 | const pascalCaseFileName = camelcase(path.parse(filename).name, {
17 | pascalCase: true,
18 | });
19 | const componentName = `Svg${pascalCaseFileName}`;
20 | return `const React = require('react');
21 | module.exports = {
22 | __esModule: true,
23 | default: ${assetFilename},
24 | ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25 | return {
26 | $$typeof: Symbol.for('react.element'),
27 | type: 'svg',
28 | ref: ref,
29 | key: null,
30 | props: Object.assign({}, props, {
31 | children: ${assetFilename}
32 | })
33 | };
34 | }),
35 | };`;
36 | }
37 |
38 | return `module.exports = ${assetFilename};`;
39 | },
40 | };
41 |
--------------------------------------------------------------------------------
/config/jest/graphqlTransform.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const loader = require('graphql-tag/loader');
4 |
5 | module.exports = {
6 | process(src) {
7 | return loader.call({ cacheable() {} }, src);
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/config/jest/setUp.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihtml5/mdebug/742b4a0e9c73ebb82ed2ee6a33e9c35c9f173fd8/config/jest/setUp.js
--------------------------------------------------------------------------------
/config/modules.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const paths = require('./paths');
6 | const chalk = require('react-dev-utils/chalk');
7 |
8 | /**
9 | * Get the baseUrl of a compilerOptions object.
10 | *
11 | * @param {Object} options
12 | */
13 | function getAdditionalModulePaths(options = {}) {
14 | const baseUrl = options.baseUrl;
15 |
16 | // We need to explicitly check for null and undefined (and not a falsy value) because
17 | // TypeScript treats an empty string as `.`.
18 | if (baseUrl == null) {
19 | // If there's no baseUrl set we respect NODE_PATH
20 | // Note that NODE_PATH is deprecated and will be removed
21 | // in the next major release of create-react-app.
22 |
23 | const nodePath = process.env.NODE_PATH || '';
24 | return nodePath.split(path.delimiter).filter(Boolean);
25 | }
26 |
27 | const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
28 |
29 | // We don't need to do anything if `baseUrl` is set to `node_modules`. This is
30 | // the default behavior.
31 | if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
32 | return null;
33 | }
34 |
35 | // Allow the user set the `baseUrl` to `appSrc`.
36 | if (path.relative(paths.appSrc, baseUrlResolved) === '') {
37 | return [paths.appSrc];
38 | }
39 |
40 | // Otherwise, throw an error.
41 | throw new Error(
42 | chalk.red.bold(
43 | "Your project's `baseUrl` can only be set to `src` or `node_modules`." +
44 | ' Create React App does not support other values at this time.'
45 | )
46 | );
47 | }
48 |
49 | function getModules() {
50 | // Check if TypeScript is setup
51 | const hasTsConfig = fs.existsSync(paths.appTsConfig);
52 | const hasJsConfig = fs.existsSync(paths.appJsConfig);
53 |
54 | if (hasTsConfig && hasJsConfig) {
55 | throw new Error(
56 | 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
57 | );
58 | }
59 |
60 | let config;
61 |
62 | // If there's a tsconfig.json we assume it's a
63 | // TypeScript project and set up the config
64 | // based on tsconfig.json
65 | if (hasTsConfig) {
66 | config = require(paths.appTsConfig);
67 | // Otherwise we'll check if there is jsconfig.json
68 | // for non TS projects.
69 | } else if (hasJsConfig) {
70 | config = require(paths.appJsConfig);
71 | }
72 |
73 | config = config || {};
74 | const options = config.compilerOptions || {};
75 |
76 | const additionalModulePaths = getAdditionalModulePaths(options);
77 |
78 | return {
79 | additionalModulePaths: additionalModulePaths,
80 | hasTsConfig,
81 | };
82 | }
83 |
84 | module.exports = getModules();
85 |
--------------------------------------------------------------------------------
/config/paths.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 | const fs = require('fs');
5 | const url = require('url');
6 |
7 | // Make sure any symlinks in the project folder are resolved:
8 | // https://github.com/facebook/create-react-app/issues/637
9 | const appDirectory = fs.realpathSync(process.cwd());
10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
11 |
12 | const envPublicUrl = process.env.PUBLIC_URL;
13 |
14 | function ensureSlash(inputPath, needsSlash) {
15 | const hasSlash = inputPath.endsWith('/');
16 | if (hasSlash && !needsSlash) {
17 | return inputPath.substr(0, inputPath.length - 1);
18 | } else if (!hasSlash && needsSlash) {
19 | return `${inputPath}/`;
20 | } else {
21 | return inputPath;
22 | }
23 | }
24 |
25 | const getPublicUrl = appPackageJson => envPublicUrl || require(appPackageJson).homepage;
26 |
27 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer
28 | // "public path" at which the app is served.
29 | // Webpack needs to know it to put the right 
基于React开发的移动web调试工具 更新日志
简单易用
| 功能全面 | 易扩展 | 高性能 |
---|
使用cdn方式,一键接入 | 类Chrome devtools, 内嵌React开发者工具,支持日志,网络,元素,代理,存储,性能等, 具有更好的网络捕获能力和丰富的日志展现形式 | 暴露内部丰富的事件, 可以和react组件无缝进行集成 | 支持大数据量展示, 不卡顿 |
一、快速体验
https://tnfe.github.io/mdebug二、Installation
Install using npm
2 | npm install mdebug --save
3 |
三、Useage
1.ES6
4 | import mdebug from 'mdebug';
5 | mdebug.init();
6 |
2.CDN
7 | (function() {
8 | var scp = document.createElement('script');
9 | // 加载最新的mdebug版本
10 | scp.src = 'https://new.inews.gtimg.com/tnews/9d243fb8/a1f8/9d243fb8-a1f8-4bf7-9047-dfa01d8c9ca0.js';
11 | scp.async = true;
12 | scp.charset = 'utf-8';
13 | // 加载成功并初始化
14 | scp.onload = function() {
15 | mdebug.init();
16 | };
17 | // 加载状态切换回调
18 | scp.onreadystate = function() {};
19 | // 加载失败回调
20 | scp.onerror = function() {};
21 | document.getElementsByTagName('head')[0].appendChild(scp);
22 | })();
23 |
四、API
1.init
24 | mdebug.init({
25 | containerId: '' // mdebug挂载容器id, 如果传空, 内部会自动生成一个不重复的id,
26 | plugins: [], // 传入mdebug插件
27 | hideToolbar: [], // 传入需要隐藏的tab id
28 | });
29 |
2.addPlugin
30 | mdebug.addPlugin({
31 | id: '', // tab id
32 | name: '', // tab对应的中文title,
33 | enName: '', // tab对应的英文title
34 | component: () => {}, // tab对应的react组件
35 | });
36 |
3.removePlugin
37 | // 支持移除的panel对应的id
38 | /*
39 | System => system;
40 | Elements => elements;
41 | Console => console
42 | Application => application
43 | NetWork => network
44 | Performance => performance
45 | Settings => settings
46 | */
47 | mdebug.removePlugin([]);
48 |
4.exportLog
49 | /*
50 | @returned {
51 | type: '' // 日志类型
52 | source: [], // 原始日志
53 | }
54 | @params type
55 | // type等于log, 返回所有的console日志
56 | // type等于net, 返回所有的net日志
57 | */
58 | mdebug.exportLog(type);
59 |
5.on
60 | mdebug.on(eventName, callback);
61 |
6.emit
62 | mdebug.emit(eventName, data);
63 |
五、事件列表
事件名称 | 数据 | 触发时机 |
---|
ready | object | mdebug加载完毕 |
addTab | object | 增加面板 |
removeTab | array | 移除面板 |
changeTab | object | 面板切换 |
六、开发
- npm i
- npm start // 启动开发
- npm run build //打包
七、Articles
- 移动端前端开发调试
- Chrome 开发者工具
八、Projects
- eruda
- vConsole
- react-json-tree
- 基于React的移动端调试解决方案
- a useful debugger for mobile
- autoDevTools
- react-inspector
- web-console
- ChromeDevTools
九、License
The MIT License (MIT). Please see License File for more information.