@lark-apaas/fullstack-rspack-preset 1.0.8-alpha.log.1 → 1.0.8-alpha.log.10
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.
|
@@ -16,11 +16,11 @@ function ErrorContainer(document, root, errorTitle) {
|
|
|
16
16
|
// 创建图片元素
|
|
17
17
|
const img = document.createElement('img');
|
|
18
18
|
img.src =
|
|
19
|
-
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/
|
|
19
|
+
'https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg';
|
|
20
20
|
img.alt = 'Error';
|
|
21
21
|
// 图片占位
|
|
22
|
-
img.width =
|
|
23
|
-
img.height =
|
|
22
|
+
img.width = 100;
|
|
23
|
+
img.height = 100;
|
|
24
24
|
img.className = 'overlay-error-image';
|
|
25
25
|
content.appendChild(img);
|
|
26
26
|
// 创建标题元素
|
|
@@ -67,7 +67,7 @@ function RootStyle(document, root) {
|
|
|
67
67
|
|
|
68
68
|
.overlay-error-image {
|
|
69
69
|
margin-bottom: 12px; /* mb-3 */
|
|
70
|
-
width:
|
|
70
|
+
width: 100px; /* w-[100px] */
|
|
71
71
|
height: auto;
|
|
72
72
|
}
|
|
73
73
|
|
package/lib/overlay/index.js
CHANGED
|
@@ -157,9 +157,14 @@ function sendPostMessage(message, targetOrigin) {
|
|
|
157
157
|
/**
|
|
158
158
|
* 上报错误信息
|
|
159
159
|
* @param {(string | Error)[]} messages 日志信息
|
|
160
|
-
* @param {
|
|
160
|
+
* @param {'compileError' | 'runtimeError'} mode 日志模式
|
|
161
161
|
*/
|
|
162
|
-
function logError(messages,
|
|
162
|
+
function logError(messages, mode) {
|
|
163
|
+
const logMeta = {
|
|
164
|
+
noStacktrace: mode === 'compileError',
|
|
165
|
+
stacktrace: mode === 'compileError' ? [] : undefined,
|
|
166
|
+
type: mode === 'compileError' ? 'compile-error' : 'uncaught-render-error',
|
|
167
|
+
};
|
|
163
168
|
try {
|
|
164
169
|
// 优先使用暴露的 __RUNTIME_LOGGER__ 上报错误
|
|
165
170
|
// 运行时错误出现时,window已经挂载
|
|
@@ -167,14 +172,20 @@ function logError(messages, noStacktrace = false) {
|
|
|
167
172
|
window.__RUNTIME_LOGGER__.get().log({
|
|
168
173
|
level: 'error',
|
|
169
174
|
args: messages,
|
|
170
|
-
meta:
|
|
171
|
-
noStacktrace,
|
|
172
|
-
stacktrace: noStacktrace ? [] : undefined,
|
|
173
|
-
}
|
|
175
|
+
meta: logMeta,
|
|
174
176
|
});
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
179
|
// 首次执行编译报错会走此处逻辑;
|
|
180
|
+
const parts = [];
|
|
181
|
+
for (const m of messages) {
|
|
182
|
+
if (m instanceof Error) {
|
|
183
|
+
parts.push(m.message, m);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
parts.push(m);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
178
189
|
const logJSON = {
|
|
179
190
|
id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
180
191
|
const r = Math.random() * 16 | 0;
|
|
@@ -183,13 +194,10 @@ function logError(messages, noStacktrace = false) {
|
|
|
183
194
|
}),
|
|
184
195
|
type: 'typedLogV2',
|
|
185
196
|
level: 'error',
|
|
186
|
-
args:
|
|
187
|
-
meta:
|
|
188
|
-
noStacktrace,
|
|
189
|
-
stacktrace: noStacktrace ? [] : undefined,
|
|
190
|
-
}
|
|
197
|
+
args: parts,
|
|
198
|
+
meta: logMeta,
|
|
191
199
|
};
|
|
192
|
-
sendPostMessage({ type: 'SELECTED_LOG', payload: logJSON });
|
|
200
|
+
sendPostMessage({ type: 'SELECTED_LOG', payload: JSON.stringify(logJSON) });
|
|
193
201
|
}
|
|
194
202
|
catch (e) {
|
|
195
203
|
console.log('上报错误信息失败', e);
|
|
@@ -219,15 +227,15 @@ function render() {
|
|
|
219
227
|
if (currentCompileErrorMessage) {
|
|
220
228
|
currentMode = 'compileError';
|
|
221
229
|
// 发送编译错误
|
|
222
|
-
logError(['Compile Error', currentCompileErrorMessage],
|
|
230
|
+
logError(['Compile Error', currentCompileErrorMessage], currentMode);
|
|
223
231
|
ErrorContainer(rootDocument, root, '编译出错');
|
|
224
232
|
}
|
|
225
233
|
else if (currentRuntimeErrors.length) {
|
|
226
234
|
currentMode = 'runtimeError';
|
|
227
235
|
// 发送运行错误
|
|
228
|
-
logError(['Uncaught Render Error', currentRuntimeErrors]);
|
|
236
|
+
logError(['Uncaught Render Error', ...currentRuntimeErrors], currentMode);
|
|
229
237
|
// 叠加全部报错,将报错信息发送到妙搭
|
|
230
|
-
ErrorContainer(rootDocument, root, '
|
|
238
|
+
ErrorContainer(rootDocument, root, '页面出错了');
|
|
231
239
|
}
|
|
232
240
|
});
|
|
233
241
|
}
|
|
@@ -102,7 +102,7 @@ function getSlardarScriptContent(option = {}) {
|
|
|
102
102
|
|
|
103
103
|
// 添加 TTI 监控脚本
|
|
104
104
|
const performanceScript = document.createElement('script');
|
|
105
|
-
performanceScript.src = 'https://sf3-scmcdn-cn.feishucdn.com/obj/unpkg/byted/performance/0.1.
|
|
105
|
+
performanceScript.src = 'https://sf3-scmcdn-cn.feishucdn.com/obj/unpkg/byted/performance/0.1.2/dist/performance.iife.js';
|
|
106
106
|
document.head.appendChild(performanceScript);
|
|
107
107
|
`;
|
|
108
108
|
}
|