Skip to content

Commit

Permalink
Merge pull request #521 from Tencent/dev
Browse files Browse the repository at this point in the history
v3.14.2
  • Loading branch information
Maizify authored Mar 25, 2022
2 parents 8991654 + 26d10d8 commit b16a209
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
English | [简体中文](./CHANGELOG_CN.md)

## 3.14.2 (2022-03-25)

- `Fix(Network)` Remove debugging console.log.
- `Chore` Drop `console.log` in Webpack process to ensure that no debugging logs appear in release version.
- `Chore` Add new build command to compile files in different scenarios.


## 3.14.1 (2022-03-24)

- `Fix(Network)` Fix `responseSize` error when `readyState === 3`.
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[English](./CHANGELOG.md) | 简体中文

## 3.14.2 (2022-03-25)

- `Fix(Network)` 删除调试日志。
- `Chore` 在构建时自动删除 `console.log` 以确保调试日志不会出现在正式版本中。
- `Chore` 添加新的编译命令以编译出不同场景下的文件。


## 3.14.1 (2022-03-24)

- `Fix(Network)` 修复当 `readyState === 3` 时的 `responseSize` 错误。
Expand Down
11 changes: 11 additions & 0 deletions dev/plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<a onclick="newGlobalToolButton()" href="javascript:;" class="weui_btn weui_btn_default">newGlobalToolButton</a>
<a onclick="newTabUseJQuery()" href="javascript:;" class="weui_btn weui_btn_default">newTabUseJQuery</a>
<a onclick="newTabUseDOM()" href="javascript:;" class="weui_btn weui_btn_default">newTabUseDOM</a>
<a onclick="newBuiltinTab()" href="javascript:;" class="weui_btn weui_btn_default">newBuiltinTab</a>
<a onclick="removePlugin()" href="javascript:;" class="weui_btn weui_btn_default">removePlugin</a>
</div>
</body>
Expand Down Expand Up @@ -117,6 +118,16 @@
console.info('newTabUseDOM() End');
}

function newBuiltinTab() {
class MyPlugin extends window.VConsole.VConsoleStoragePlugin {

}
var plugin = new MyPlugin('tab6', 'Tab6');
vConsole.addPlugin(plugin);
vConsole.show();
vConsole.showPlugin('tab6');
}

const pluginList = ['default', 'system', 'network', 'element', 'storage'];
function removePlugin() {
console.info('removePlugin() Start');
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vconsole",
"version": "3.14.1",
"version": "3.14.2",
"description": "A lightweight, extendable front-end developer tool for mobile web page.",
"homepage": "https://github.com/Tencent/vConsole",
"files": [
Expand All @@ -12,13 +12,20 @@
"main": "dist/vconsole.min.js",
"typings": "dist/vconsole.min.d.ts",
"scripts": {
"build": "webpack --mode=production --progress",
"build": "webpack --mode=production --progress --env target=web",
"build:wx": "webpack --mode=production --progress --env target=wx",
"build:typings": "node ./build/build.typings.js",
"build:dev": "webpack --mode=development --progress",
"watch": "webpack --mode=development --watch --progress",
"serve": "webpack serve --config webpack.serve.config --progress",
"test:pack": "npx npm-packlist"
},
"sideEffects": [
"lib/*",
"element/*",
"network/*",
"storage/*"
],
"keywords": [
"console",
"debug",
Expand Down
39 changes: 26 additions & 13 deletions src/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ import { VConsoleStoragePlugin } from '../storage/storage';
import { VConsoleLogExporter } from '../log/log.exporter';
import { VConsoleNetworkExporter } from '../network/network.exporter';


const VCONSOLE_ID = '#__vconsole';

export class VConsole {
public version: string = __VERSION__;
public isInited: boolean;
public isInited: boolean = false;
public option: VConsoleOptions = {};

protected compInstance: SvelteComponent;
Expand All @@ -54,13 +53,13 @@ export class VConsole {
public network: VConsoleNetworkExporter;

// Export static classes
public static VConsolePlugin = VConsolePlugin;
public static VConsoleLogPlugin = VConsoleLogPlugin;
public static VConsoleDefaultPlugin = VConsoleDefaultPlugin;
public static VConsoleSystemPlugin = VConsoleSystemPlugin;
public static VConsoleNetworkPlugin = VConsoleNetworkPlugin;
public static VConsoleElementPlugin = VConsoleElementPlugin;
public static VConsoleStoragePlugin = VConsoleStoragePlugin;
public static VConsolePlugin: typeof VConsolePlugin;
public static VConsoleLogPlugin: typeof VConsoleLogPlugin;
public static VConsoleDefaultPlugin: typeof VConsoleDefaultPlugin;
public static VConsoleSystemPlugin: typeof VConsoleSystemPlugin;
public static VConsoleNetworkPlugin: typeof VConsoleNetworkPlugin;
public static VConsoleElementPlugin: typeof VConsoleElementPlugin;
public static VConsoleStoragePlugin: typeof VConsoleStoragePlugin;

constructor(opt?: VConsoleOptions) {
if (!!VConsole.instance && VConsole.instance instanceof VConsole) {
Expand Down Expand Up @@ -163,10 +162,12 @@ export class VConsole {
const plugins = {
// 'default': { proto: VConsoleSystemPlugin, name: 'Log' },
'system': { proto: VConsoleSystemPlugin, name: 'System' },
'network': { proto: VConsoleNetworkPlugin, name: 'Network' },
'element': { proto: VConsoleElementPlugin, name: 'Element' },
'storage': { proto: VConsoleStoragePlugin, name: 'Storage' }
};
if (__TARGET__ === 'web') {
plugins['network'] = { proto: VConsoleNetworkPlugin, name: 'Network' };
plugins['element'] = { proto: VConsoleElementPlugin, name: 'Element' };
plugins['storage'] = { proto: VConsoleStoragePlugin, name: 'Storage' };
}
if (!!list && tool.isArray(list)) {
for (let i = 0; i < list.length; i++) {
const pluginConf = plugins[list[i]];
Expand Down Expand Up @@ -559,4 +560,16 @@ export class VConsole {

} // END class

export default VConsole;

// Export built-in plugins
VConsole.VConsolePlugin = VConsolePlugin;
VConsole.VConsoleLogPlugin = VConsoleLogPlugin;
VConsole.VConsoleDefaultPlugin = VConsoleDefaultPlugin;
VConsole.VConsoleSystemPlugin = VConsoleSystemPlugin;

// for tree shaking
if (__TARGET__ === 'web') {
VConsole.VConsoleNetworkPlugin = VConsoleNetworkPlugin;
VConsole.VConsoleElementPlugin = VConsoleElementPlugin;
VConsole.VConsoleStoragePlugin = VConsoleStoragePlugin;
}
2 changes: 1 addition & 1 deletion src/network/beacon.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class BeaconProxyHandler<T extends typeof navigator.sendBeacon> implement
}

public apply(target: T, thisArg: T, argsList: any[]) {
console.log('on call!!')
// console.log('on call!!')
const urlString: string = argsList[0];
const data: BodyInit = argsList[1];
const item = new VConsoleNetworkRequestItem();
Expand Down
2 changes: 1 addition & 1 deletion src/network/fetch.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class FetchProxyHandler<T extends typeof fetch> implements ProxyHandler<T
item.readyState = 4;

this.handleResponseBody(resp.clone(), item).then((responseValue: string | ArrayBuffer) => {
console.log(item.responseType, responseValue)
// console.log(item.responseType, responseValue)
item.responseSize = typeof responseValue === 'string' ? responseValue.length : responseValue.byteLength;
item.responseSizeText = tool.getBytesText(item.responseSize);
item.response = Helper.genResonseByResponseType(item.responseType, responseValue);
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare var __VERSION__: string;
declare var __TARGET__: 'web' | 'wx';

declare module '*.html' {
const _: string;
Expand Down
2 changes: 1 addition & 1 deletion src/vconsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Unless required by applicable law or agreed to in writing, software distributed
import 'core-js/stable/symbol';
import 'core-js/stable/promise';

// classes
// vConsole Core Class
import { VConsole } from './core/core';

// export
Expand Down
18 changes: 8 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ const { execSync } = require('child_process');
const TerserPlugin = require('terser-webpack-plugin');
const sveltePreprocess = require('svelte-preprocess');
const pkg = require('./package.json');
const BuildTarget = ['web', 'wx'];

module.exports = (env, argv) => {
const isDev = argv.mode === 'development';
const __TARGET__ = BuildTarget.indexOf(env.target) === -1 ? BuildTarget[0] : env.target;
return {
mode: argv.mode,
devtool: false,
Expand Down Expand Up @@ -95,18 +97,13 @@ module.exports = (env, argv) => {
minimizer: [
new TerserPlugin({
extractComments: false,
terserOptions: {
compress: {
pure_funcs: ['console.log'], // drop `console.log` only
},
},
}),
],
// splitChunks: {
// cacheGroups: {
// styles: {
// name: "styles",
// type: "css/mini-extract",
// chunks: "all",
// enforce: true,
// },
// },
// },
},
watchOptions: {
ignored: ['**/node_modules'],
Expand All @@ -126,6 +123,7 @@ module.exports = (env, argv) => {
}),
new Webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__TARGET__: JSON.stringify(__TARGET__),
}),
{
apply: (compiler) => {
Expand Down

0 comments on commit b16a209

Please sign in to comment.