@lark-apaas/devtool-kits 1.0.5-alpha.1 → 1.0.5-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/dist/error.html CHANGED
@@ -159,8 +159,8 @@
159
159
  // 探测服务是否恢复
160
160
  async function probeService() {
161
161
  try {
162
- // 获取当前 URL,去掉 _retry_count 参数
163
- const currentUrl = getCurrentUrlWithoutRetryCount();
162
+ // 获取当前 URL
163
+ const currentUrl = window.location.pathname + window.location.search;
164
164
 
165
165
  console.log('[Probe] 探测服务状态:', currentUrl);
166
166
 
@@ -200,17 +200,6 @@
200
200
  }
201
201
  }
202
202
 
203
- // 获取当前 URL(去掉 _retry_count 参数)
204
- function getCurrentUrlWithoutRetryCount() {
205
- try {
206
- const url = new URL(window.location.href);
207
- url.searchParams.delete('_retry_count');
208
- return url.pathname + url.search;
209
- } catch (e) {
210
- return window.location.pathname;
211
- }
212
- }
213
-
214
203
  // 复制错误信息到剪贴板
215
204
  async function handleCopy() {
216
205
  if (!errorData) {
@@ -250,6 +239,7 @@
250
239
 
251
240
  // 告诉妙搭修复
252
241
  function handleRepair() {
242
+ console.log('[Render Error Repair] 告诉妙搭修复错误:', errorData);
253
243
  sendPostMessage({
254
244
  type: 'RenderErrorRepair',
255
245
  data: errorData,
@@ -346,7 +336,7 @@
346
336
  class="error-image"
347
337
  />
348
338
  <p class="title">哎呀,写错代码了</p>
349
- <p class="description">可复制错误信息,或告诉妙搭进行修复</p>
339
+ <p class="description">可复制错误信息,或告诉妙搭进行修复。</p>
350
340
  <div class="button-group">
351
341
  <button class="button button-copy" id="copyBtn" onclick="handleCopy()">
352
342
  复制错误信息
package/dist/index.cjs CHANGED
@@ -28547,7 +28547,7 @@ function injectErrorData(template, errorLogs) {
28547
28547
  }
28548
28548
  __name(injectErrorData, "injectErrorData");
28549
28549
  function handleDevProxyError(err, req, res, options) {
28550
- const { logDir = import_node_path2.default.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "server.log", retryTimeout = 5e3, retryInterval = 500, target, maxRedirects = 3 } = options || {};
28550
+ const { logDir = import_node_path2.default.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "server.log", retryTimeout = 5e3, retryInterval = 500, target } = options || {};
28551
28551
  console.error("[Proxy Error]:", err.message);
28552
28552
  if (res.headersSent) {
28553
28553
  console.error("[Proxy Error]: Headers already sent, cannot send error page");
@@ -28571,14 +28571,13 @@ function handleDevProxyError(err, req, res, options) {
28571
28571
  console.log(`[Proxy Error]: Waiting for service recovery at ${host}:${port} (timeout: ${retryTimeout}ms)...`);
28572
28572
  const recovered = await waitForServiceRecovery(host, port, retryTimeout, retryInterval);
28573
28573
  if (recovered) {
28574
- console.log("[Proxy Error]: Service recovered, sending retry response");
28575
- } else {
28576
- console.log("[Proxy Error]: Service did not recover within timeout, sending retry response");
28574
+ console.log("[Proxy Error]: Service recovered, sending redirect");
28575
+ sendSimpleRedirect(req, res);
28576
+ return;
28577
28577
  }
28578
+ console.log("[Proxy Error]: Service did not recover within timeout, showing error page");
28578
28579
  }
28579
- const redirected = sendSimpleRetryResponse(req, res, maxRedirects);
28580
- if (redirected) return;
28581
- console.log("[Proxy Error]: Falling back to scenario 2 (detailed error page)");
28580
+ console.log("[Proxy Error]: Falling back to scenario 2 (detailed error page with probe)");
28582
28581
  }
28583
28582
  console.log("[Proxy Error]: Compile error or non-connection error, showing error page");
28584
28583
  const template = getErrorHtmlTemplate();
@@ -28600,45 +28599,17 @@ function handleDevProxyError(err, req, res, options) {
28600
28599
  })();
28601
28600
  }
28602
28601
  __name(handleDevProxyError, "handleDevProxyError");
28603
- function getRedirectCount(url) {
28604
- try {
28605
- const urlObj = new URL(url, "http://localhost");
28606
- const retryCount = urlObj.searchParams.get("_retry_count");
28607
- return retryCount ? parseInt(retryCount, 10) : 0;
28608
- } catch {
28609
- return 0;
28610
- }
28611
- }
28612
- __name(getRedirectCount, "getRedirectCount");
28613
- function addRedirectCount(url, count) {
28614
- try {
28615
- const urlObj = new URL(url, "http://localhost");
28616
- urlObj.searchParams.set("_retry_count", String(count));
28617
- return urlObj.pathname + urlObj.search;
28618
- } catch {
28619
- return url;
28620
- }
28621
- }
28622
- __name(addRedirectCount, "addRedirectCount");
28623
- function sendSimpleRetryResponse(req, res, maxRedirects) {
28624
- if (res.headersSent) return true;
28602
+ function sendSimpleRedirect(req, res) {
28603
+ if (res.headersSent) return;
28625
28604
  const originalUrl = req.url || "/";
28626
- const currentCount = getRedirectCount(originalUrl);
28627
- if (currentCount >= maxRedirects) {
28628
- console.log(`[Proxy Error]: Max redirects (${maxRedirects}) reached, will show detailed error page`);
28629
- return false;
28630
- }
28631
- const nextCount = currentCount + 1;
28632
- const redirectUrl = addRedirectCount(originalUrl, nextCount);
28633
- console.log(`[Proxy Error]: Redirecting (attempt ${nextCount}/${maxRedirects}) to ${redirectUrl}`);
28605
+ console.log("[Proxy Error]: Sending 302 redirect to", originalUrl);
28634
28606
  res.writeHead(302, {
28635
- "Location": redirectUrl,
28607
+ "Location": originalUrl,
28636
28608
  "Cache-Control": "no-cache, no-store, must-revalidate"
28637
28609
  });
28638
28610
  res.end();
28639
- return true;
28640
28611
  }
28641
- __name(sendSimpleRetryResponse, "sendSimpleRetryResponse");
28612
+ __name(sendSimpleRedirect, "sendSimpleRedirect");
28642
28613
 
28643
28614
  // src/middlewares/index.ts
28644
28615
  var import_node_path8 = __toESM(require("path"), 1);