@lark-apaas/coding-preset-vite-react 1.0.13-alpha.12 → 1.0.13-alpha.2
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.
- package/lib/plugins/error-overlay.d.ts.map +1 -1
- package/lib/plugins/error-overlay.js +1 -105
- package/lib/plugins/error-overlay.js.map +1 -1
- package/lib/server-log/dev-logs/api-list-handler.d.ts.map +1 -1
- package/lib/server-log/dev-logs/api-list-handler.js +9 -7
- package/lib/server-log/dev-logs/api-list-handler.js.map +1 -1
- package/package.json +1 -1
- package/src/overlay/vite-client.js +1 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-overlay.d.ts","sourceRoot":"","sources":["../../src/plugins/error-overlay.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAoC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"error-overlay.d.ts","sourceRoot":"","sources":["../../src/plugins/error-overlay.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAoC,MAAM,MAAM,CAAC;AAIrE,MAAM,WAAW,yBAAyB;IACxC,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAsCD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,MAAM,CAsDlF;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -37,69 +37,6 @@ exports.errorOverlayPlugin = errorOverlayPlugin;
|
|
|
37
37
|
const fs = __importStar(require("node:fs"));
|
|
38
38
|
const path = __importStar(require("node:path"));
|
|
39
39
|
const OVERLAY_PATH = '/@error-overlay.js';
|
|
40
|
-
// 内联到 <script> 前必须转义 `<` `>` 和 line separator,避免 payload 里出现 `</script>` 破坏 script tag
|
|
41
|
-
function safeInlineJson(json) {
|
|
42
|
-
return json
|
|
43
|
-
.replace(/</g, '\\u003c')
|
|
44
|
-
.replace(/>/g, '\\u003e')
|
|
45
|
-
.replace(/\u2028/g, '\\u2028')
|
|
46
|
-
.replace(/\u2029/g, '\\u2029');
|
|
47
|
-
}
|
|
48
|
-
// 序列化 Vite 内部 err 对象为可 JSON 序列化的 payload,字段与 Vite prepareError 对齐
|
|
49
|
-
function serializeErrorPayload(err) {
|
|
50
|
-
const e = (err ?? {});
|
|
51
|
-
const stripAnsi = (s) => String(s ?? '').replace(/\x1b\[[0-9;]*m/g, '');
|
|
52
|
-
const payload = {
|
|
53
|
-
message: stripAnsi(e.message),
|
|
54
|
-
stack: stripAnsi(e.stack),
|
|
55
|
-
id: e.id ?? '',
|
|
56
|
-
frame: stripAnsi(e.frame ?? ''),
|
|
57
|
-
plugin: e.plugin ?? '',
|
|
58
|
-
pluginCode: e.pluginCode ? String(e.pluginCode) : '',
|
|
59
|
-
loc: e.loc ?? null,
|
|
60
|
-
};
|
|
61
|
-
return JSON.stringify(payload);
|
|
62
|
-
}
|
|
63
|
-
function buildCustomErrorHtml(errorPayloadJson, overlayPath) {
|
|
64
|
-
const escapedOverlayPath = JSON.stringify(overlayPath);
|
|
65
|
-
const safe = safeInlineJson(errorPayloadJson);
|
|
66
|
-
return `<!DOCTYPE html>
|
|
67
|
-
<html>
|
|
68
|
-
<head>
|
|
69
|
-
<meta charset="UTF-8">
|
|
70
|
-
<title>Compile Error</title>
|
|
71
|
-
<script type="module">
|
|
72
|
-
const error = ${safe};
|
|
73
|
-
try {
|
|
74
|
-
window.parent.postMessage({
|
|
75
|
-
type: 'SELECTED_LOG',
|
|
76
|
-
payload: JSON.stringify({
|
|
77
|
-
type: 'typedLogV2',
|
|
78
|
-
level: 'error',
|
|
79
|
-
id: 'compile-' + Date.now() + '-' + Math.random().toString(36).slice(2, 10),
|
|
80
|
-
args: ['Compile Error', error.message, error.plugin || '', error.id || '', error.frame || ''].filter(Boolean),
|
|
81
|
-
meta: { type: 'compile-error', noStacktrace: false, stacktrace: [] },
|
|
82
|
-
}),
|
|
83
|
-
}, '*');
|
|
84
|
-
window.parent.postMessage({ type: 'RenderError', data: 'compileError' }, '*');
|
|
85
|
-
} catch (e) { /* postMessage 失败可安全忽略,如 target origin 不匹配 */ }
|
|
86
|
-
try {
|
|
87
|
-
window.__COMPILE_ERROR__ = error;
|
|
88
|
-
const s = document.createElement('script');
|
|
89
|
-
s.type = 'module';
|
|
90
|
-
s.src = ${escapedOverlayPath};
|
|
91
|
-
document.head.appendChild(s);
|
|
92
|
-
} catch (e) {
|
|
93
|
-
function escapeHtml(s) { return String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); }
|
|
94
|
-
document.body.innerHTML =
|
|
95
|
-
'<h1 style="font-family:sans-serif;color:#e11d48">编译错误</h1>' +
|
|
96
|
-
'<pre style="font-family:monospace;white-space:pre-wrap">' + escapeHtml(error.message || '') + '</pre>';
|
|
97
|
-
}
|
|
98
|
-
</script>
|
|
99
|
-
</head>
|
|
100
|
-
<body></body>
|
|
101
|
-
</html>`;
|
|
102
|
-
}
|
|
103
40
|
/**
|
|
104
41
|
* 解析 overlay 客户端脚本路径。
|
|
105
42
|
*
|
|
@@ -165,7 +102,6 @@ function errorOverlayPlugin(options = {}) {
|
|
|
165
102
|
configureServer(server) {
|
|
166
103
|
if (!enabled)
|
|
167
104
|
return;
|
|
168
|
-
// Serve /@error-overlay.js (URL-matched; safe to register early).
|
|
169
105
|
server.middlewares.use((req, res, next) => {
|
|
170
106
|
if (req.url !== overlayPath)
|
|
171
107
|
return next();
|
|
@@ -181,46 +117,6 @@ function errorOverlayPlugin(options = {}) {
|
|
|
181
117
|
res.end(`// error: ${e instanceof Error ? e.message : String(e)}`);
|
|
182
118
|
}
|
|
183
119
|
});
|
|
184
|
-
// 拦截 Vite compile / transform 抛出的 err,替代 Vite 内置的 500 error HTML (`new ErrorOverlay(error)`)
|
|
185
|
-
// 为我们的 postMessage SELECTED_LOG + 加载自定义 overlay 响应。
|
|
186
|
-
// 关键:必须走 configureServer 返回的 post-hook,让本 middleware 位于 stack 中
|
|
187
|
-
// transformMiddleware/htmlFallbackMiddleware 之后、Vite 自身 errorMiddleware 之前;
|
|
188
|
-
// 这样 next(err) 才会先命中我们。
|
|
189
|
-
return () => {
|
|
190
|
-
// 4-arg error middleware (connect 的错误路径要求 4 参数签名)。
|
|
191
|
-
const compileErrorHandler = (err, _req, res, next) => {
|
|
192
|
-
try {
|
|
193
|
-
if (res.writableEnded || res.headersSent) {
|
|
194
|
-
return next(err);
|
|
195
|
-
}
|
|
196
|
-
const payloadJson = serializeErrorPayload(err);
|
|
197
|
-
const html = buildCustomErrorHtml(payloadJson, overlayPath);
|
|
198
|
-
const buf = Buffer.from(html, 'utf-8');
|
|
199
|
-
res.statusCode = 500;
|
|
200
|
-
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
201
|
-
res.setHeader('Content-Length', String(buf.length));
|
|
202
|
-
res.end(buf);
|
|
203
|
-
}
|
|
204
|
-
catch (e) {
|
|
205
|
-
console.error('[error-overlay] error middleware failed:', e);
|
|
206
|
-
return next(err);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
// 关键:必须在 stack 里找到 Vite 内置的 viteErrorMiddleware 并 splice 到它之前。
|
|
210
|
-
// 单纯 `use()` append 只能位于 indexHtmlMiddleware 前,拿不到 HTML transform 失败;
|
|
211
|
-
// 而 Vite 的 errorMiddleware 是最后一个,我们必须紧挨着它前面才能截住所有 next(err)。
|
|
212
|
-
// 用 setImmediate 让本 splice 发生在 Vite 完成所有 `use()` 之后。
|
|
213
|
-
setImmediate(() => {
|
|
214
|
-
const mws = server.middlewares;
|
|
215
|
-
const idx = mws.stack.findIndex((m) => m.handle?.name === 'viteErrorMiddleware');
|
|
216
|
-
if (idx >= 0) {
|
|
217
|
-
mws.stack.splice(idx, 0, { route: '', handle: compileErrorHandler });
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
server.middlewares.use(compileErrorHandler);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
120
|
},
|
|
225
121
|
transformIndexHtml(html) {
|
|
226
122
|
if (!enabled)
|
|
@@ -229,7 +125,7 @@ function errorOverlayPlugin(options = {}) {
|
|
|
229
125
|
{
|
|
230
126
|
tag: 'script',
|
|
231
127
|
attrs: { type: 'module', src: overlayPath },
|
|
232
|
-
injectTo: 'head
|
|
128
|
+
injectTo: 'head',
|
|
233
129
|
},
|
|
234
130
|
];
|
|
235
131
|
return { html, tags };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-overlay.js","sourceRoot":"","sources":["../../src/plugins/error-overlay.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"error-overlay.js","sourceRoot":"","sources":["../../src/plugins/error-overlay.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,gDAsDC;AAhHD,4CAA8B;AAC9B,gDAAkC;AAGlC,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAS1C;;;;;;;;GAQG;AACH,SAAS,uBAAuB;IAC9B,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kCAAkC,CAAC,EAAE,4BAA4B;QACzF,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,2BAA2B,CAAC,EAAU,4BAA4B;KAC3F,CAAC;IACF,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC1D,CAAC;AAED,SAAS,mBAAmB,CAAC,cAAsB;IACjD,MAAM,UAAU,GAAG,uBAAuB,EAAE,CAAC;IAC7C,IAAI,CAAC,UAAU;QAAE,OAAO,0CAA0C,CAAC;IAEnE,IAAI,IAAI,GAAG,EAAE,CAAC,YA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
-
{"version":3,"file":"api-list-handler.d.ts","sourceRoot":"","sources":["../../../src/server-log/dev-logs/api-list-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"api-list-handler.d.ts","sourceRoot":"","sources":["../../../src/server-log/dev-logs/api-list-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,cAAc,EAAE,MAAM,SAAS,CAAC;AA0K5D;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAsBrD"}
|
|
@@ -7,9 +7,9 @@ const SERVER_PORT = process.env.SERVER_PORT || '3000';
|
|
|
7
7
|
*/
|
|
8
8
|
function extractModuleFromPath(path) {
|
|
9
9
|
const segments = path.split('/').filter(Boolean);
|
|
10
|
-
// 跳过 'api' 前缀
|
|
10
|
+
// 跳过 'api' / 'openapi' 前缀
|
|
11
11
|
let startIndex = 0;
|
|
12
|
-
if (segments[0] === 'api') {
|
|
12
|
+
if (segments[0] === 'api' || segments[0] === 'openapi') {
|
|
13
13
|
startIndex = 1;
|
|
14
14
|
}
|
|
15
15
|
// 跳过版本号 (v1, v2, etc.)
|
|
@@ -81,8 +81,10 @@ async function fetchRoutesFromBackend(basePath) {
|
|
|
81
81
|
const debugRoutes = routeConfig.routes;
|
|
82
82
|
return debugRoutes
|
|
83
83
|
.filter((route) => {
|
|
84
|
-
//
|
|
85
|
-
|
|
84
|
+
// 保留业务 API(/api/)和开放 API(/openapi/),排除内部/框架/capability 路由
|
|
85
|
+
const isBusinessApi = route.path.includes('/api/');
|
|
86
|
+
const isOpenApi = route.path.includes('/openapi/');
|
|
87
|
+
return (isBusinessApi || isOpenApi) &&
|
|
86
88
|
!route.path.includes('__framework__') &&
|
|
87
89
|
!route.path.includes('__innerapi__') &&
|
|
88
90
|
!route.path.includes('__platform__') &&
|
|
@@ -91,9 +93,9 @@ async function fetchRoutesFromBackend(basePath) {
|
|
|
91
93
|
!route.path.includes('/api/sdk_innerapi');
|
|
92
94
|
})
|
|
93
95
|
.map((route) => {
|
|
94
|
-
//
|
|
95
|
-
const
|
|
96
|
-
const apiPath =
|
|
96
|
+
// 取最左出现的 /api/ 或 /openapi/ 段(避免 /api/openapi/foo 被误截成 /openapi/foo)
|
|
97
|
+
const apiSegmentMatch = route.path.match(/\/(?:openapi|api)\/.*/);
|
|
98
|
+
const apiPath = apiSegmentMatch?.[0] || route.path;
|
|
97
99
|
const method = route.method || 'ALL';
|
|
98
100
|
return {
|
|
99
101
|
id: generateRouteId(method, apiPath),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-list-handler.js","sourceRoot":"","sources":["../../../src/server-log/dev-logs/api-list-handler.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"api-list-handler.js","sourceRoot":"","sources":["../../../src/server-log/dev-logs/api-list-handler.ts"],"names":[],"mappings":";;AA6KA,oDAsBC;AAjMD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC;AA4CtD;;GAEG;AACH,SAAS,qBAAqB,CAAC,IAAY;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEjD,0BAA0B;IAC1B,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QACvD,UAAU,GAAG,CAAC,CAAC;IACjB,CAAC;IAED,uBAAuB;IACvB,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,UAAU,EAAE,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,G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Q,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;YACpD,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,QAAQ,CAAC,CAAC;YACtD,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;YAE3C,GAAG,CAAC,IAAI,CAAC;gBACP,MAAM;gBACN,KAAK,EAAE,MAAM,CAAC,MAAM;aACrB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;YAC3D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,wBAAwB;gBAC/B,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAClE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/coding-preset-vite-react",
|
|
3
|
-
"version": "1.0.13-alpha.
|
|
3
|
+
"version": "1.0.13-alpha.2",
|
|
4
4
|
"description": "Vite 8 preset for miaoda-coding vite-react (jsPage) templates — pure frontend, no fullstack baggage",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -502,29 +502,14 @@ if (!window.__VITE_ERROR_OVERLAY_INITIALIZED__) {
|
|
|
502
502
|
|
|
503
503
|
// ===== Global Error Listeners =====
|
|
504
504
|
function setupGlobalErrorListeners() {
|
|
505
|
-
// capture 阶段才能拿到资源 404(IMG/SCRIPT/LINK 的 error 不冒泡)
|
|
506
505
|
window.addEventListener('error', (event) => {
|
|
507
506
|
// 忽略编译错误模式下的运行时错误
|
|
508
507
|
if (currentMode === 'compileError') return;
|
|
509
508
|
|
|
510
509
|
if (event.error) {
|
|
511
510
|
handleRuntimeError(event.error);
|
|
512
|
-
return;
|
|
513
511
|
}
|
|
514
|
-
|
|
515
|
-
const target = event.target;
|
|
516
|
-
if (target && target !== window && target.tagName) {
|
|
517
|
-
const tag = target.tagName;
|
|
518
|
-
if (tag === 'IMG' || tag === 'SCRIPT' || tag === 'LINK') {
|
|
519
|
-
const url = target.src || target.href || '';
|
|
520
|
-
// 过滤已知常见噪声 (favicon / apple-touch-icon / manifest 等浏览器自动请求),
|
|
521
|
-
// 避免用户"页面日志"面板被这类无害 404 淹没
|
|
522
|
-
if (/\/favicon\.(ico|png|svg)|\/apple-touch-icon|\/manifest\.json|\/robots\.txt/.test(url)) return;
|
|
523
|
-
// 资源 404 只上报到页面日志,不 render overlay(避免整页遮盖用户预览)
|
|
524
|
-
logError(['Resource load failed', tag.toLowerCase(), url], 'runtimeError');
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}, true);
|
|
512
|
+
});
|
|
528
513
|
|
|
529
514
|
window.addEventListener('unhandledrejection', (event) => {
|
|
530
515
|
if (currentMode === 'compileError') return;
|
|
@@ -577,19 +562,6 @@ if (!window.__VITE_ERROR_OVERLAY_INITIALIZED__) {
|
|
|
577
562
|
};
|
|
578
563
|
|
|
579
564
|
// ===== Initialize =====
|
|
580
|
-
// 500 error HTML 场景兼容:宿主 HTML 塞 window.__COMPILE_ERROR__ 后加载本脚本,触发一次 render
|
|
581
|
-
if (window.__COMPILE_ERROR__) {
|
|
582
|
-
try {
|
|
583
|
-
const err = window.__COMPILE_ERROR__;
|
|
584
|
-
const msg = (err.message || '') + (err.frame ? '\n\n' + err.frame : '');
|
|
585
|
-
showCompileError(msg);
|
|
586
|
-
} catch (e) {
|
|
587
|
-
// showCompileError 失败可安全忽略 —— overlay 渲染降级不阻塞后续 setup;
|
|
588
|
-
// 且 SELECTED_LOG postMessage 已在服务端内联 script 里发过,页面日志不会丢
|
|
589
|
-
}
|
|
590
|
-
try { delete window.__COMPILE_ERROR__; } catch (e) { /* strict-mode / non-configurable delete 失败可安全忽略,不影响主流程 */ }
|
|
591
|
-
}
|
|
592
|
-
|
|
593
565
|
setupViteHMRListener();
|
|
594
566
|
setupGlobalErrorListeners();
|
|
595
567
|
}
|