@lark-apaas/miaoda-presets 1.0.5-alpha.0 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,148 +1,148 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
2
|
+
"version": 1,
|
|
3
|
+
"themeName": "UD Theme Style",
|
|
4
|
+
"theme": {
|
|
5
|
+
"seriesCnt": "6",
|
|
6
|
+
"backgroundColor": "rgba(0,0,0,0)",
|
|
7
|
+
"titleColor": "#1f2329",
|
|
8
|
+
"subtitleColor": "#8f959e",
|
|
9
|
+
"textColorShow": false,
|
|
10
|
+
"textColor": "#333",
|
|
11
|
+
"markTextColor": "#ffffff",
|
|
12
|
+
"color": [
|
|
13
|
+
"#3370eb",
|
|
14
|
+
"#1bcebf",
|
|
15
|
+
"#ffc60a",
|
|
16
|
+
"#ed6d0c",
|
|
17
|
+
"#dca1e4",
|
|
18
|
+
"#25b2e5",
|
|
19
|
+
"#6dcdeb",
|
|
20
|
+
"#288fcb",
|
|
21
|
+
"#94b5f5",
|
|
22
|
+
"#8f61d1",
|
|
23
|
+
"#8f61d1",
|
|
24
|
+
"#bf78e9",
|
|
25
|
+
"#008280",
|
|
26
|
+
"#27ad8e",
|
|
27
|
+
"#7bc335"
|
|
28
|
+
],
|
|
29
|
+
"borderColor": "#dee0e3",
|
|
30
|
+
"borderWidth": 0,
|
|
31
|
+
"visualMapColor": ["#25b2e5", "#6dcdeb", "#288fcb"],
|
|
32
|
+
"legendTextColor": "#8f959e",
|
|
33
|
+
"kColor": "#fdc6c4",
|
|
34
|
+
"kColor0": "transparent",
|
|
35
|
+
"kBorderColor": "#f54a45",
|
|
36
|
+
"kBorderColor0": "#32a645",
|
|
37
|
+
"kBorderWidth": "2",
|
|
38
|
+
"lineWidth": "1",
|
|
39
|
+
"symbolSize": "6",
|
|
40
|
+
"symbol": "emptyCircle",
|
|
41
|
+
"symbolBorderWidth": "1",
|
|
42
|
+
"lineSmooth": true,
|
|
43
|
+
"graphLineWidth": 1,
|
|
44
|
+
"graphLineColor": "#dee0e3",
|
|
45
|
+
"mapLabelColor": "#000",
|
|
46
|
+
"mapLabelColorE": "#516b91",
|
|
47
|
+
"mapBorderColor": "#516b91",
|
|
48
|
+
"mapBorderColorE": "#516b91",
|
|
49
|
+
"mapBorderWidth": 0.5,
|
|
50
|
+
"mapBorderWidthE": 1,
|
|
51
|
+
"mapAreaColor": "#f3f3f3",
|
|
52
|
+
"mapAreaColorE": "#a5e7f0",
|
|
53
|
+
"axes": [
|
|
54
|
+
{
|
|
55
|
+
"type": "all",
|
|
56
|
+
"name": "通用坐标轴",
|
|
57
|
+
"axisLineShow": true,
|
|
58
|
+
"axisLineColor": "#dee0e3",
|
|
59
|
+
"axisTickShow": false,
|
|
60
|
+
"axisTickColor": "#333",
|
|
61
|
+
"axisLabelShow": true,
|
|
62
|
+
"axisLabelColor": "#8f959e",
|
|
63
|
+
"splitLineShow": true,
|
|
64
|
+
"splitLineColor": ["#dee0e3"],
|
|
65
|
+
"splitAreaShow": false,
|
|
66
|
+
"splitAreaColor": ["rgba(250,250,250,0.05)", "rgba(200,200,200,0.02)"]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"type": "category",
|
|
70
|
+
"name": "类目坐标轴",
|
|
71
|
+
"axisLineShow": true,
|
|
72
|
+
"axisLineColor": "#333",
|
|
73
|
+
"axisTickShow": true,
|
|
74
|
+
"axisTickColor": "#333",
|
|
75
|
+
"axisLabelShow": true,
|
|
76
|
+
"axisLabelColor": "#333",
|
|
77
|
+
"splitLineShow": false,
|
|
78
|
+
"splitLineColor": ["#ccc"],
|
|
79
|
+
"splitAreaShow": false,
|
|
80
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "value",
|
|
84
|
+
"name": "数值坐标轴",
|
|
85
|
+
"axisLineShow": true,
|
|
86
|
+
"axisLineColor": "#333",
|
|
87
|
+
"axisTickShow": true,
|
|
88
|
+
"axisTickColor": "#333",
|
|
89
|
+
"axisLabelShow": true,
|
|
90
|
+
"axisLabelColor": "#333",
|
|
91
|
+
"splitLineShow": true,
|
|
92
|
+
"splitLineColor": ["#ccc"],
|
|
93
|
+
"splitAreaShow": false,
|
|
94
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"type": "log",
|
|
98
|
+
"name": "对数坐标轴",
|
|
99
|
+
"axisLineShow": true,
|
|
100
|
+
"axisLineColor": "#333",
|
|
101
|
+
"axisTickShow": true,
|
|
102
|
+
"axisTickColor": "#333",
|
|
103
|
+
"axisLabelShow": true,
|
|
104
|
+
"axisLabelColor": "#333",
|
|
105
|
+
"splitLineShow": true,
|
|
106
|
+
"splitLineColor": ["#ccc"],
|
|
107
|
+
"splitAreaShow": false,
|
|
108
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"type": "time",
|
|
112
|
+
"name": "时间坐标轴",
|
|
113
|
+
"axisLineShow": true,
|
|
114
|
+
"axisLineColor": "#333",
|
|
115
|
+
"axisTickShow": true,
|
|
116
|
+
"axisTickColor": "#333",
|
|
117
|
+
"axisLabelShow": true,
|
|
118
|
+
"axisLabelColor": "#333",
|
|
119
|
+
"splitLineShow": true,
|
|
120
|
+
"splitLineColor": ["#ccc"],
|
|
121
|
+
"splitAreaShow": false,
|
|
122
|
+
"splitAreaColor": ["rgba(250,250,250,0.3)", "rgba(200,200,200,0.3)"]
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"axisSeperateSetting": false,
|
|
126
|
+
"toolboxColor": "#8f959e",
|
|
127
|
+
"toolboxEmphasisColor": "#1f2329",
|
|
128
|
+
"tooltipAxisColor": "#dee0e3",
|
|
129
|
+
"tooltipAxisWidth": 1,
|
|
130
|
+
"timelineLineColor": "#336df4",
|
|
131
|
+
"timelineLineWidth": "-1",
|
|
132
|
+
"timelineItemColor": "#336df4",
|
|
133
|
+
"timelineItemColorE": "#1456f0",
|
|
134
|
+
"timelineCheckColor": "#1456f0",
|
|
135
|
+
"timelineCheckBorderColor": "#94b4ff",
|
|
136
|
+
"timelineItemBorderWidth": "0.5",
|
|
137
|
+
"timelineControlColor": "#336df4",
|
|
138
|
+
"timelineControlBorderColor": "#336df4",
|
|
139
|
+
"timelineControlBorderWidth": 0.5,
|
|
140
|
+
"timelineLabelColor": "#8f959e",
|
|
141
|
+
"datazoomBackgroundColor": "rgba(0,0,0,0)",
|
|
142
|
+
"datazoomDataColor": "rgba(255,255,255,0.3)",
|
|
143
|
+
"datazoomFillColor": "rgba(167,183,204,0.4)",
|
|
144
|
+
"datazoomHandleColor": "#a7b7cc",
|
|
145
|
+
"datazoomHandleWidth": "100",
|
|
146
|
+
"datazoomLabelColor": "#333"
|
|
147
|
+
}
|
|
148
148
|
}
|
package/lib/overlay/index.js
CHANGED
|
@@ -135,8 +135,8 @@ async function copyToClipboard(text) {
|
|
|
135
135
|
return fallbackCopyToClipboard(text);
|
|
136
136
|
}
|
|
137
137
|
catch (error) {
|
|
138
|
-
|
|
139
|
-
return
|
|
138
|
+
// 执行navigator.clipboard.writeText失败时,降级方案
|
|
139
|
+
return fallbackCopyToClipboard(text);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
// 获取父窗口 origin
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Webpack HMR 耗时计算插件 JavaScript 版本
|
|
4
|
+
* 在浏览器 Console 打印热更文件和耗时信息
|
|
5
|
+
*/
|
|
6
|
+
class HMRTimingPlugin {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.options = {
|
|
9
|
+
threshold: options.threshold || 1000
|
|
10
|
+
};
|
|
11
|
+
this.hmrStartTime = null;
|
|
12
|
+
this.changedFiles = new Set();
|
|
13
|
+
this.devServer = null;
|
|
14
|
+
}
|
|
15
|
+
apply(compiler) {
|
|
16
|
+
const pluginName = 'HMRTimingPlugin';
|
|
17
|
+
// 在 devServer 启动后保存引用
|
|
18
|
+
if (compiler.options.devServer) {
|
|
19
|
+
const originalSetupMiddlewares = compiler.options.devServer.setupMiddlewares;
|
|
20
|
+
const self = this;
|
|
21
|
+
compiler.options.devServer.setupMiddlewares = function (middlewares, devServer) {
|
|
22
|
+
// 保存 devServer 实例的引用
|
|
23
|
+
self.devServer = devServer;
|
|
24
|
+
global.__webpack_dev_server__ = devServer;
|
|
25
|
+
if (originalSetupMiddlewares) {
|
|
26
|
+
return originalSetupMiddlewares(middlewares, devServer);
|
|
27
|
+
}
|
|
28
|
+
return middlewares;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// 监听文件变化
|
|
32
|
+
compiler.hooks.invalid.tap(pluginName, (fileName) => {
|
|
33
|
+
this.hmrStartTime = Date.now();
|
|
34
|
+
this.changedFiles.clear();
|
|
35
|
+
if (fileName) {
|
|
36
|
+
this.changedFiles.add(fileName);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// 监听 watch 运行开始
|
|
40
|
+
compiler.hooks.watchRun.tapAsync(pluginName, (compiler, callback) => {
|
|
41
|
+
if (!this.hmrStartTime) {
|
|
42
|
+
this.hmrStartTime = Date.now();
|
|
43
|
+
}
|
|
44
|
+
// 收集变化的文件
|
|
45
|
+
if (compiler.modifiedFiles) {
|
|
46
|
+
compiler.modifiedFiles.forEach(file => this.changedFiles.add(file));
|
|
47
|
+
}
|
|
48
|
+
if (compiler.removedFiles) {
|
|
49
|
+
compiler.removedFiles.forEach(file => this.changedFiles.add(file));
|
|
50
|
+
}
|
|
51
|
+
callback();
|
|
52
|
+
});
|
|
53
|
+
// 监听编译完成
|
|
54
|
+
compiler.hooks.done.tap(pluginName, (stats) => {
|
|
55
|
+
if (this.hmrStartTime === null)
|
|
56
|
+
return;
|
|
57
|
+
const totalTime = Date.now() - this.hmrStartTime;
|
|
58
|
+
// 获取实际更新的模块
|
|
59
|
+
const updatedModules = new Set();
|
|
60
|
+
stats.compilation.modules.forEach(module => {
|
|
61
|
+
const identifier = module.resource || module.identifier?.();
|
|
62
|
+
if (identifier && typeof identifier === 'string') {
|
|
63
|
+
// 过滤掉 node_modules 中的模块
|
|
64
|
+
if (!identifier.includes('node_modules')) {
|
|
65
|
+
updatedModules.add(identifier);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// 合并文件列表
|
|
70
|
+
const allChangedFiles = new Set([
|
|
71
|
+
...Array.from(this.changedFiles),
|
|
72
|
+
...Array.from(updatedModules)
|
|
73
|
+
]);
|
|
74
|
+
// 简化文件路径
|
|
75
|
+
const simplifiedFiles = Array.from(allChangedFiles)
|
|
76
|
+
.map(file => {
|
|
77
|
+
// 移除项目根路径
|
|
78
|
+
const relativePath = file.replace(compiler.context || '', '');
|
|
79
|
+
// 移除开头的斜杠
|
|
80
|
+
return relativePath.replace(/^[\/\\]/, '');
|
|
81
|
+
})
|
|
82
|
+
.filter(file => file && file.length > 0)
|
|
83
|
+
.slice(0, 10); // 最多显示10个文件
|
|
84
|
+
const timingInfo = {
|
|
85
|
+
totalTime,
|
|
86
|
+
changedFiles: simplifiedFiles,
|
|
87
|
+
modules: stats.compilation.modules.size,
|
|
88
|
+
isOverThreshold: totalTime > this.options.threshold,
|
|
89
|
+
threshold: this.options.threshold
|
|
90
|
+
};
|
|
91
|
+
// 通过 WebSocket 发送到浏览器
|
|
92
|
+
this.sendToBrowser(compiler, timingInfo);
|
|
93
|
+
// 重置
|
|
94
|
+
this.changedFiles.clear();
|
|
95
|
+
});
|
|
96
|
+
// 注入客户端代码
|
|
97
|
+
this.injectClientScript(compiler);
|
|
98
|
+
}
|
|
99
|
+
sendToBrowser(compiler, timingInfo) {
|
|
100
|
+
// 使用 done hook 确保在编译完成后发送
|
|
101
|
+
const server = this.getDevServer(compiler);
|
|
102
|
+
if (server) {
|
|
103
|
+
if (server.sockWrite) {
|
|
104
|
+
// webpack-dev-server 3.x
|
|
105
|
+
server.sockWrite(server.sockets, 'hmr-timing', timingInfo);
|
|
106
|
+
}
|
|
107
|
+
else if (server.sendMessage) {
|
|
108
|
+
// webpack-dev-server 4.x/5.x
|
|
109
|
+
const clients = server.webSocketServer?.clients || server.clients;
|
|
110
|
+
server.sendMessage(clients, 'hmr-timing', timingInfo);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
getDevServer(compiler) {
|
|
115
|
+
// 尝试多种方式获取 devServer 实例
|
|
116
|
+
// 方式1: 从 compiler.options.devServer 存储的引用
|
|
117
|
+
if (compiler.options.devServer && compiler.options.devServer.__instance) {
|
|
118
|
+
return compiler.options.devServer.__instance;
|
|
119
|
+
}
|
|
120
|
+
// 方式2: 从全局变量
|
|
121
|
+
if (global.__webpack_dev_server__) {
|
|
122
|
+
return global.__webpack_dev_server__;
|
|
123
|
+
}
|
|
124
|
+
// 方式3: 从 compiler 上挂载的引用
|
|
125
|
+
if (compiler.__webpack_dev_server__) {
|
|
126
|
+
return compiler.__webpack_dev_server__;
|
|
127
|
+
}
|
|
128
|
+
// 方式4: 在 infrastructure 日志中查找
|
|
129
|
+
if (compiler.infrastructureLogger) {
|
|
130
|
+
const logger = compiler.infrastructureLogger;
|
|
131
|
+
if (logger.__devServer) {
|
|
132
|
+
return logger.__devServer;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
injectClientScript(compiler) {
|
|
138
|
+
const clientScript = `
|
|
139
|
+
;(function() {
|
|
140
|
+
if (typeof window === 'undefined' || !module.hot) return;
|
|
141
|
+
|
|
142
|
+
const threshold = ${this.options.threshold};
|
|
143
|
+
|
|
144
|
+
// 显示 HMR 耗时和变化文件
|
|
145
|
+
function logHMRTiming(data) {
|
|
146
|
+
const color = data.isOverThreshold ? '#ff9800' : '#4caf50';
|
|
147
|
+
|
|
148
|
+
// 主要信息
|
|
149
|
+
console.log(
|
|
150
|
+
'%c🔥 HMR 更新完成 - 耗时: %c' + data.totalTime + 'ms',
|
|
151
|
+
'color: ' + color + '; font-weight: bold; font-size: 14px;',
|
|
152
|
+
'color: ' + color + '; font-weight: bold; font-size: 16px;'
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// 热更文件列表
|
|
156
|
+
if (data.changedFiles && data.changedFiles.length > 0) {
|
|
157
|
+
console.group('📝 热更文件 (' + data.changedFiles.length + ')');
|
|
158
|
+
data.changedFiles.forEach(function(file) {
|
|
159
|
+
console.log(' •', file);
|
|
160
|
+
});
|
|
161
|
+
console.groupEnd();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 超过阈值警告
|
|
165
|
+
if (data.isOverThreshold) {
|
|
166
|
+
console.warn('⚠️ HMR 耗时超过阈值 ' + threshold + 'ms');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
console.log(''); // 空行分隔
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 监听 webpack-dev-server 的 WebSocket 消息
|
|
173
|
+
if (typeof __webpack_dev_server_client__ !== 'undefined') {
|
|
174
|
+
// webpack-dev-server 4.x/5.x
|
|
175
|
+
const originalOnMessage = __webpack_dev_server_client__.onMessage;
|
|
176
|
+
__webpack_dev_server_client__.onMessage = function(message) {
|
|
177
|
+
if (message.type === 'hmr-timing') {
|
|
178
|
+
logHMRTiming(message.data);
|
|
179
|
+
}
|
|
180
|
+
if (originalOnMessage) {
|
|
181
|
+
return originalOnMessage.apply(this, arguments);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
} else {
|
|
185
|
+
// 备用方案:监听 WebSocket
|
|
186
|
+
setTimeout(function() {
|
|
187
|
+
const ws = window.__webpack_dev_server_ws__;
|
|
188
|
+
if (ws && ws.addEventListener) {
|
|
189
|
+
ws.addEventListener('message', function(event) {
|
|
190
|
+
try {
|
|
191
|
+
const message = JSON.parse(event.data);
|
|
192
|
+
if (message.type === 'hmr-timing') {
|
|
193
|
+
logHMRTiming(message.data);
|
|
194
|
+
}
|
|
195
|
+
} catch (e) {}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}, 1000);
|
|
199
|
+
}
|
|
200
|
+
})();
|
|
201
|
+
`;
|
|
202
|
+
compiler.hooks.compilation.tap('HMRTimingPlugin', (compilation) => {
|
|
203
|
+
compilation.hooks.processAssets.tap({
|
|
204
|
+
name: 'HMRTimingPlugin',
|
|
205
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
206
|
+
}, () => {
|
|
207
|
+
// 注入到主入口文件
|
|
208
|
+
const mainAssets = Object.keys(compilation.assets).filter(name => name.match(/^(main|index|app|bundle).*\.js$/) && !name.includes('hot-update'));
|
|
209
|
+
if (mainAssets.length > 0) {
|
|
210
|
+
const assetName = mainAssets[0];
|
|
211
|
+
const asset = compilation.assets[assetName];
|
|
212
|
+
const source = asset.source();
|
|
213
|
+
const newSource = clientScript + '\n' + source;
|
|
214
|
+
compilation.assets[assetName] = {
|
|
215
|
+
source: () => newSource,
|
|
216
|
+
size: () => newSource.length,
|
|
217
|
+
map: () => asset.map ? asset.map() : null
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
module.exports = HMRTimingPlugin;
|
|
225
|
+
/**
|
|
226
|
+
* 使用示例:
|
|
227
|
+
*
|
|
228
|
+
* // webpack.config.js
|
|
229
|
+
* const HMRTimingPlugin = require('./HMRTimingPlugin');
|
|
230
|
+
*
|
|
231
|
+
* module.exports = {
|
|
232
|
+
* mode: 'development',
|
|
233
|
+
* devServer: {
|
|
234
|
+
* hot: true,
|
|
235
|
+
* },
|
|
236
|
+
* plugins: [
|
|
237
|
+
* new HMRTimingPlugin({
|
|
238
|
+
* threshold: 1000 // 超过1秒会显示警告
|
|
239
|
+
* })
|
|
240
|
+
* ]
|
|
241
|
+
* };
|
|
242
|
+
*
|
|
243
|
+
* 浏览器控制台输出示例:
|
|
244
|
+
*
|
|
245
|
+
* 🔥 HMR 更新完成 - 耗时: 523ms
|
|
246
|
+
* 📝 热更文件 (2)
|
|
247
|
+
* • src/components/App.jsx
|
|
248
|
+
* • src/styles/main.css
|
|
249
|
+
*
|
|
250
|
+
* 🔥 HMR 更新完成 - 耗时: 1250ms
|
|
251
|
+
* 📝 热更文件 (1)
|
|
252
|
+
* • src/utils/helper.js
|
|
253
|
+
* ⚠️ HMR 耗时超过阈值 1000ms
|
|
254
|
+
*
|
|
255
|
+
* 功能特性:
|
|
256
|
+
* - 显示 HMR 耗时(带颜色提示)
|
|
257
|
+
* - 显示热更新的文件列表(可折叠)
|
|
258
|
+
* - 超过阈值时显示警告
|
|
259
|
+
* - 通过 DevServer WebSocket 通信
|
|
260
|
+
* - 自动过滤 node_modules
|
|
261
|
+
* - 简化文件路径显示
|
|
262
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/miaoda-presets",
|
|
3
|
-
"version": "1.0.5
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc && npm run copy:json",
|
|
12
|
-
"copy:json": "
|
|
12
|
+
"copy:json": "cp -r src/*.json lib",
|
|
13
13
|
"watch": "tsc --watch",
|
|
14
14
|
"bump": "changeset version",
|
|
15
15
|
"change": "changeset",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"isolatedModules": true,
|
|
13
|
-
"moduleDetection": "force",
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "react-jsx",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": false,
|
|
19
|
-
"noUnusedLocals": false,
|
|
20
|
-
"noUnusedParameters": false,
|
|
21
|
-
"noImplicitAny": false,
|
|
22
|
-
"noFallthroughCasesInSwitch": false,
|
|
23
|
-
|
|
24
|
-
"sourceMap": true,
|
|
25
|
-
"allowJs": true,
|
|
26
|
-
"strictNullChecks": false,
|
|
27
|
-
|
|
28
|
-
"incremental": false,
|
|
29
|
-
},
|
|
30
|
-
"include": [
|
|
31
|
-
"client/**/*"
|
|
32
|
-
],
|
|
33
|
-
"exclude": [
|
|
34
|
-
"node_modules",
|
|
35
|
-
"dist",
|
|
36
|
-
"public"
|
|
37
|
-
]
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"emitDecoratorMetadata": true,
|
|
13
|
-
"importHelpers": true,
|
|
14
|
-
|
|
15
|
-
"outDir": "./dist",
|
|
16
|
-
|
|
17
|
-
"incremental": true,
|
|
18
|
-
|
|
19
|
-
"strict": false,
|
|
20
|
-
"composite": true,
|
|
21
|
-
"declaration": true,
|
|
22
|
-
"removeComments": false,
|
|
23
|
-
"noEmit": false,
|
|
24
|
-
|
|
25
|
-
"baseUrl": "./",
|
|
26
|
-
"paths": {
|
|
27
|
-
"@server/*": ["server/*"]
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
"types": ["node"]
|
|
31
|
-
},
|
|
32
|
-
"watchOptions": {
|
|
33
|
-
"excludeDirectories": ["node_modules/**"]
|
|
34
|
-
},
|
|
35
|
-
"include": ["server/**/*", "scripts/**/*.ts"],
|
|
36
|
-
"exclude": ["node_modules", "dist", "client", "**/*.spec.ts", "**/*.e2e-spec.ts"],
|
|
37
|
-
"ts-node": { "require": ["tsconfig-paths/register"] }
|
|
38
|
-
}
|