@lark-apaas/devtool-kits 0.1.0-alpha.9 → 1.0.1

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/index.js CHANGED
@@ -1370,8 +1370,8 @@ var require_node = __commonJS({
1370
1370
  }
1371
1371
  break;
1372
1372
  case "FILE":
1373
- var fs9 = __require("fs");
1374
- stream2 = new fs9.SyncWriteStream(fd2, {
1373
+ var fs10 = __require("fs");
1374
+ stream2 = new fs10.SyncWriteStream(fd2, {
1375
1375
  autoClose: false
1376
1376
  });
1377
1377
  stream2._type = "fs";
@@ -17559,11 +17559,11 @@ var require_mime_types = __commonJS({
17559
17559
  return exts[0];
17560
17560
  }
17561
17561
  __name(extension, "extension");
17562
- function lookup(path5) {
17563
- if (!path5 || typeof path5 !== "string") {
17562
+ function lookup(path6) {
17563
+ if (!path6 || typeof path6 !== "string") {
17564
17564
  return false;
17565
17565
  }
17566
- var extension2 = extname("x." + path5).toLowerCase().substr(1);
17566
+ var extension2 = extname("x." + path6).toLowerCase().substr(1);
17567
17567
  if (!extension2) {
17568
17568
  return false;
17569
17569
  }
@@ -21250,8 +21250,8 @@ var require_node2 = __commonJS({
21250
21250
  }
21251
21251
  break;
21252
21252
  case "FILE":
21253
- var fs9 = __require("fs");
21254
- stream2 = new fs9.SyncWriteStream(fd2, {
21253
+ var fs10 = __require("fs");
21254
+ stream2 = new fs10.SyncWriteStream(fd2, {
21255
21255
  autoClose: false
21256
21256
  });
21257
21257
  stream2._type = "fs";
@@ -22020,8 +22020,8 @@ var require_node3 = __commonJS({
22020
22020
  }
22021
22021
  break;
22022
22022
  case "FILE":
22023
- var fs9 = __require("fs");
22024
- stream2 = new fs9.SyncWriteStream(fd2, {
22023
+ var fs10 = __require("fs");
22024
+ stream2 = new fs10.SyncWriteStream(fd2, {
22025
22025
  autoClose: false
22026
22026
  });
22027
22027
  stream2._type = "fs";
@@ -22118,7 +22118,7 @@ var require_path_to_regexp = __commonJS({
22118
22118
  "use strict";
22119
22119
  module.exports = pathToRegexp;
22120
22120
  var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
22121
- function pathToRegexp(path5, keys, options) {
22121
+ function pathToRegexp(path6, keys, options) {
22122
22122
  options = options || {};
22123
22123
  keys = keys || [];
22124
22124
  var strict = options.strict;
@@ -22132,8 +22132,8 @@ var require_path_to_regexp = __commonJS({
22132
22132
  var pos = 0;
22133
22133
  var backtrack = "";
22134
22134
  var m;
22135
- if (path5 instanceof RegExp) {
22136
- while (m = MATCHING_GROUP_REGEXP.exec(path5.source)) {
22135
+ if (path6 instanceof RegExp) {
22136
+ while (m = MATCHING_GROUP_REGEXP.exec(path6.source)) {
22137
22137
  if (m[0][0] === "\\") continue;
22138
22138
  keys.push({
22139
22139
  name: m[1] || name++,
@@ -22141,18 +22141,18 @@ var require_path_to_regexp = __commonJS({
22141
22141
  offset: m.index
22142
22142
  });
22143
22143
  }
22144
- return path5;
22144
+ return path6;
22145
22145
  }
22146
- if (Array.isArray(path5)) {
22147
- path5 = path5.map(function(value) {
22146
+ if (Array.isArray(path6)) {
22147
+ path6 = path6.map(function(value) {
22148
22148
  return pathToRegexp(value, keys, options).source;
22149
22149
  });
22150
- return new RegExp(path5.join("|"), flags);
22150
+ return new RegExp(path6.join("|"), flags);
22151
22151
  }
22152
- if (typeof path5 !== "string") {
22152
+ if (typeof path6 !== "string") {
22153
22153
  throw new TypeError("path must be a string, array of strings, or regular expression");
22154
22154
  }
22155
- path5 = path5.replace(/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g, function(match, slash, format, key, capture, star, optional, offset) {
22155
+ path6 = path6.replace(/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g, function(match, slash, format, key, capture, star, optional, offset) {
22156
22156
  if (match[0] === "\\") {
22157
22157
  backtrack += match;
22158
22158
  pos += 2;
@@ -22167,7 +22167,7 @@ var require_path_to_regexp = __commonJS({
22167
22167
  if (slash || format) {
22168
22168
  backtrack = "";
22169
22169
  } else {
22170
- backtrack += path5.slice(pos, offset);
22170
+ backtrack += path6.slice(pos, offset);
22171
22171
  }
22172
22172
  pos = offset + match.length;
22173
22173
  if (match === "*") {
@@ -22194,7 +22194,7 @@ var require_path_to_regexp = __commonJS({
22194
22194
  extraOffset += result.length - match.length;
22195
22195
  return result;
22196
22196
  });
22197
- while (m = MATCHING_GROUP_REGEXP.exec(path5)) {
22197
+ while (m = MATCHING_GROUP_REGEXP.exec(path6)) {
22198
22198
  if (m[0][0] === "\\") continue;
22199
22199
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
22200
22200
  keys.splice(keysOffset + i, 0, {
@@ -22205,13 +22205,13 @@ var require_path_to_regexp = __commonJS({
22205
22205
  }
22206
22206
  i++;
22207
22207
  }
22208
- path5 += strict ? "" : path5[path5.length - 1] === "/" ? "?" : "/?";
22208
+ path6 += strict ? "" : path6[path6.length - 1] === "/" ? "?" : "/?";
22209
22209
  if (end) {
22210
- path5 += "$";
22211
- } else if (path5[path5.length - 1] !== "/") {
22212
- path5 += lookahead ? "(?=/|$)" : "(?:/|$)";
22210
+ path6 += "$";
22211
+ } else if (path6[path6.length - 1] !== "/") {
22212
+ path6 += lookahead ? "(?=/|$)" : "(?:/|$)";
22213
22213
  }
22214
- return new RegExp("^" + path5, flags);
22214
+ return new RegExp("^" + path6, flags);
22215
22215
  }
22216
22216
  __name(pathToRegexp, "pathToRegexp");
22217
22217
  }
@@ -22225,19 +22225,19 @@ var require_layer = __commonJS({
22225
22225
  var debug = require_src3()("express:router:layer");
22226
22226
  var hasOwnProperty = Object.prototype.hasOwnProperty;
22227
22227
  module.exports = Layer;
22228
- function Layer(path5, options, fn) {
22228
+ function Layer(path6, options, fn) {
22229
22229
  if (!(this instanceof Layer)) {
22230
- return new Layer(path5, options, fn);
22230
+ return new Layer(path6, options, fn);
22231
22231
  }
22232
- debug("new %o", path5);
22232
+ debug("new %o", path6);
22233
22233
  var opts = options || {};
22234
22234
  this.handle = fn;
22235
22235
  this.name = fn.name || "<anonymous>";
22236
22236
  this.params = void 0;
22237
22237
  this.path = void 0;
22238
- this.regexp = pathRegexp(path5, this.keys = [], opts);
22239
- this.regexp.fast_star = path5 === "*";
22240
- this.regexp.fast_slash = path5 === "/" && opts.end === false;
22238
+ this.regexp = pathRegexp(path6, this.keys = [], opts);
22239
+ this.regexp.fast_star = path6 === "*";
22240
+ this.regexp.fast_slash = path6 === "/" && opts.end === false;
22241
22241
  }
22242
22242
  __name(Layer, "Layer");
22243
22243
  Layer.prototype.handle_error = /* @__PURE__ */ __name(function handle_error(error, req, res, next) {
@@ -22262,9 +22262,9 @@ var require_layer = __commonJS({
22262
22262
  next(err);
22263
22263
  }
22264
22264
  }, "handle");
22265
- Layer.prototype.match = /* @__PURE__ */ __name(function match(path5) {
22265
+ Layer.prototype.match = /* @__PURE__ */ __name(function match(path6) {
22266
22266
  var match2;
22267
- if (path5 != null) {
22267
+ if (path6 != null) {
22268
22268
  if (this.regexp.fast_slash) {
22269
22269
  this.params = {};
22270
22270
  this.path = "";
@@ -22272,12 +22272,12 @@ var require_layer = __commonJS({
22272
22272
  }
22273
22273
  if (this.regexp.fast_star) {
22274
22274
  this.params = {
22275
- "0": decode_param(path5)
22275
+ "0": decode_param(path6)
22276
22276
  };
22277
- this.path = path5;
22277
+ this.path = path6;
22278
22278
  return true;
22279
22279
  }
22280
- match2 = this.regexp.exec(path5);
22280
+ match2 = this.regexp.exec(path6);
22281
22281
  }
22282
22282
  if (!match2) {
22283
22283
  this.params = void 0;
@@ -22373,10 +22373,10 @@ var require_route = __commonJS({
22373
22373
  var slice = Array.prototype.slice;
22374
22374
  var toString = Object.prototype.toString;
22375
22375
  module.exports = Route;
22376
- function Route(path5) {
22377
- this.path = path5;
22376
+ function Route(path6) {
22377
+ this.path = path6;
22378
22378
  this.stack = [];
22379
- debug("new %o", path5);
22379
+ debug("new %o", path6);
22380
22380
  this.methods = {};
22381
22381
  }
22382
22382
  __name(Route, "Route");
@@ -22592,8 +22592,8 @@ var require_router = __commonJS({
22592
22592
  if (++sync > 100) {
22593
22593
  return setImmediate(next, err);
22594
22594
  }
22595
- var path5 = getPathname(req);
22596
- if (path5 == null) {
22595
+ var path6 = getPathname(req);
22596
+ if (path6 == null) {
22597
22597
  return done(layerError);
22598
22598
  }
22599
22599
  var layer;
@@ -22601,7 +22601,7 @@ var require_router = __commonJS({
22601
22601
  var route;
22602
22602
  while (match !== true && idx < stack.length) {
22603
22603
  layer = stack[idx++];
22604
- match = matchLayer(layer, path5);
22604
+ match = matchLayer(layer, path6);
22605
22605
  route = layer.route;
22606
22606
  if (typeof match !== "boolean") {
22607
22607
  layerError = layerError || match;
@@ -22639,19 +22639,19 @@ var require_router = __commonJS({
22639
22639
  } else if (route) {
22640
22640
  layer.handle_request(req, res, next);
22641
22641
  } else {
22642
- trim_prefix(layer, layerError, layerPath, path5);
22642
+ trim_prefix(layer, layerError, layerPath, path6);
22643
22643
  }
22644
22644
  sync = 0;
22645
22645
  });
22646
22646
  }
22647
22647
  __name(next, "next");
22648
- function trim_prefix(layer, layerError, layerPath, path5) {
22648
+ function trim_prefix(layer, layerError, layerPath, path6) {
22649
22649
  if (layerPath.length !== 0) {
22650
- if (layerPath !== path5.slice(0, layerPath.length)) {
22650
+ if (layerPath !== path6.slice(0, layerPath.length)) {
22651
22651
  next(layerError);
22652
22652
  return;
22653
22653
  }
22654
- var c = path5[layerPath.length];
22654
+ var c = path6[layerPath.length];
22655
22655
  if (c && c !== "/" && c !== ".") return next(layerError);
22656
22656
  debug("trim prefix (%s) from url %s", layerPath, req.url);
22657
22657
  removed = layerPath;
@@ -22732,7 +22732,7 @@ var require_router = __commonJS({
22732
22732
  }, "process_params");
22733
22733
  proto.use = /* @__PURE__ */ __name(function use(fn) {
22734
22734
  var offset = 0;
22735
- var path5 = "/";
22735
+ var path6 = "/";
22736
22736
  if (typeof fn !== "function") {
22737
22737
  var arg = fn;
22738
22738
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -22740,7 +22740,7 @@ var require_router = __commonJS({
22740
22740
  }
22741
22741
  if (typeof arg !== "function") {
22742
22742
  offset = 1;
22743
- path5 = fn;
22743
+ path6 = fn;
22744
22744
  }
22745
22745
  }
22746
22746
  var callbacks = flatten(slice.call(arguments, offset));
@@ -22752,8 +22752,8 @@ var require_router = __commonJS({
22752
22752
  if (typeof fn !== "function") {
22753
22753
  throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
22754
22754
  }
22755
- debug("use %o %s", path5, fn.name || "<anonymous>");
22756
- var layer = new Layer(path5, {
22755
+ debug("use %o %s", path6, fn.name || "<anonymous>");
22756
+ var layer = new Layer(path6, {
22757
22757
  sensitive: this.caseSensitive,
22758
22758
  strict: false,
22759
22759
  end: false
@@ -22763,9 +22763,9 @@ var require_router = __commonJS({
22763
22763
  }
22764
22764
  return this;
22765
22765
  }, "use");
22766
- proto.route = /* @__PURE__ */ __name(function route(path5) {
22767
- var route2 = new Route(path5);
22768
- var layer = new Layer(path5, {
22766
+ proto.route = /* @__PURE__ */ __name(function route(path6) {
22767
+ var route2 = new Route(path6);
22768
+ var layer = new Layer(path6, {
22769
22769
  sensitive: this.caseSensitive,
22770
22770
  strict: this.strict,
22771
22771
  end: true
@@ -22775,8 +22775,8 @@ var require_router = __commonJS({
22775
22775
  return route2;
22776
22776
  }, "route");
22777
22777
  methods.concat("all").forEach(function(method) {
22778
- proto[method] = function(path5) {
22779
- var route = this.route(path5);
22778
+ proto[method] = function(path6) {
22779
+ var route = this.route(path6);
22780
22780
  route[method].apply(route, slice.call(arguments, 1));
22781
22781
  return this;
22782
22782
  };
@@ -22816,9 +22816,9 @@ var require_router = __commonJS({
22816
22816
  return toString.call(obj).replace(objectRegExp, "$1");
22817
22817
  }
22818
22818
  __name(gettype, "gettype");
22819
- function matchLayer(layer, path5) {
22819
+ function matchLayer(layer, path6) {
22820
22820
  try {
22821
- return layer.match(path5);
22821
+ return layer.match(path6);
22822
22822
  } catch (err) {
22823
22823
  return err;
22824
22824
  }
@@ -22941,13 +22941,13 @@ var require_view = __commonJS({
22941
22941
  "../../../node_modules/express/lib/view.js"(exports, module) {
22942
22942
  "use strict";
22943
22943
  var debug = require_src3()("express:view");
22944
- var path5 = __require("path");
22945
- var fs9 = __require("fs");
22946
- var dirname = path5.dirname;
22947
- var basename = path5.basename;
22948
- var extname = path5.extname;
22949
- var join5 = path5.join;
22950
- var resolve = path5.resolve;
22944
+ var path6 = __require("path");
22945
+ var fs10 = __require("fs");
22946
+ var dirname = path6.dirname;
22947
+ var basename = path6.basename;
22948
+ var extname = path6.extname;
22949
+ var join5 = path6.join;
22950
+ var resolve = path6.resolve;
22951
22951
  module.exports = View;
22952
22952
  function View(name, options) {
22953
22953
  var opts = options || {};
@@ -22977,17 +22977,17 @@ var require_view = __commonJS({
22977
22977
  }
22978
22978
  __name(View, "View");
22979
22979
  View.prototype.lookup = /* @__PURE__ */ __name(function lookup(name) {
22980
- var path6;
22980
+ var path7;
22981
22981
  var roots = [].concat(this.root);
22982
22982
  debug('lookup "%s"', name);
22983
- for (var i = 0; i < roots.length && !path6; i++) {
22983
+ for (var i = 0; i < roots.length && !path7; i++) {
22984
22984
  var root = roots[i];
22985
22985
  var loc = resolve(root, name);
22986
22986
  var dir = dirname(loc);
22987
22987
  var file = basename(loc);
22988
- path6 = this.resolve(dir, file);
22988
+ path7 = this.resolve(dir, file);
22989
22989
  }
22990
- return path6;
22990
+ return path7;
22991
22991
  }, "lookup");
22992
22992
  View.prototype.render = /* @__PURE__ */ __name(function render(options, callback) {
22993
22993
  debug('render "%s"', this.path);
@@ -22995,21 +22995,21 @@ var require_view = __commonJS({
22995
22995
  }, "render");
22996
22996
  View.prototype.resolve = /* @__PURE__ */ __name(function resolve2(dir, file) {
22997
22997
  var ext = this.ext;
22998
- var path6 = join5(dir, file);
22999
- var stat = tryStat(path6);
22998
+ var path7 = join5(dir, file);
22999
+ var stat = tryStat(path7);
23000
23000
  if (stat && stat.isFile()) {
23001
- return path6;
23001
+ return path7;
23002
23002
  }
23003
- path6 = join5(dir, basename(file, ext), "index" + ext);
23004
- stat = tryStat(path6);
23003
+ path7 = join5(dir, basename(file, ext), "index" + ext);
23004
+ stat = tryStat(path7);
23005
23005
  if (stat && stat.isFile()) {
23006
- return path6;
23006
+ return path7;
23007
23007
  }
23008
23008
  }, "resolve");
23009
- function tryStat(path6) {
23010
- debug('stat "%s"', path6);
23009
+ function tryStat(path7) {
23010
+ debug('stat "%s"', path7);
23011
23011
  try {
23012
- return fs9.statSync(path6);
23012
+ return fs10.statSync(path7);
23013
23013
  } catch (e) {
23014
23014
  return void 0;
23015
23015
  }
@@ -23658,8 +23658,8 @@ var require_node4 = __commonJS({
23658
23658
  }
23659
23659
  break;
23660
23660
  case "FILE":
23661
- var fs9 = __require("fs");
23662
- stream2 = new fs9.SyncWriteStream(fd2, {
23661
+ var fs10 = __require("fs");
23662
+ stream2 = new fs10.SyncWriteStream(fd2, {
23663
23663
  autoClose: false
23664
23664
  });
23665
23665
  stream2._type = "fs";
@@ -23859,8 +23859,8 @@ var require_types = __commonJS({
23859
23859
  var require_mime = __commonJS({
23860
23860
  "../../../node_modules/mime/mime.js"(exports, module) {
23861
23861
  "use strict";
23862
- var path5 = __require("path");
23863
- var fs9 = __require("fs");
23862
+ var path6 = __require("path");
23863
+ var fs10 = __require("fs");
23864
23864
  function Mime() {
23865
23865
  this.types = /* @__PURE__ */ Object.create(null);
23866
23866
  this.extensions = /* @__PURE__ */ Object.create(null);
@@ -23882,7 +23882,7 @@ var require_mime = __commonJS({
23882
23882
  };
23883
23883
  Mime.prototype.load = function(file) {
23884
23884
  this._loading = file;
23885
- var map = {}, content = fs9.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
23885
+ var map = {}, content = fs10.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
23886
23886
  lines.forEach(function(line) {
23887
23887
  var fields = line.replace(/\s*#.*|^\s*|\s*$/g, "").split(/\s+/);
23888
23888
  map[fields.shift()] = fields;
@@ -23890,8 +23890,8 @@ var require_mime = __commonJS({
23890
23890
  this.define(map);
23891
23891
  this._loading = null;
23892
23892
  };
23893
- Mime.prototype.lookup = function(path6, fallback) {
23894
- var ext = path6.replace(/^.*[\.\/\\]/, "").toLowerCase();
23893
+ Mime.prototype.lookup = function(path7, fallback) {
23894
+ var ext = path7.replace(/^.*[\.\/\\]/, "").toLowerCase();
23895
23895
  return this.types[ext] || fallback || this.default_type;
23896
23896
  };
23897
23897
  Mime.prototype.extension = function(mimeType) {
@@ -24127,34 +24127,34 @@ var require_send = __commonJS({
24127
24127
  var escapeHtml = require_escape_html();
24128
24128
  var etag = require_etag();
24129
24129
  var fresh = require_fresh();
24130
- var fs9 = __require("fs");
24130
+ var fs10 = __require("fs");
24131
24131
  var mime = require_mime();
24132
24132
  var ms = require_ms5();
24133
24133
  var onFinished = require_on_finished();
24134
24134
  var parseRange = require_range_parser();
24135
- var path5 = __require("path");
24135
+ var path6 = __require("path");
24136
24136
  var statuses = require_statuses();
24137
24137
  var Stream = __require("stream");
24138
24138
  var util = __require("util");
24139
- var extname = path5.extname;
24140
- var join5 = path5.join;
24141
- var normalize = path5.normalize;
24142
- var resolve = path5.resolve;
24143
- var sep = path5.sep;
24139
+ var extname = path6.extname;
24140
+ var join5 = path6.join;
24141
+ var normalize = path6.normalize;
24142
+ var resolve = path6.resolve;
24143
+ var sep = path6.sep;
24144
24144
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
24145
24145
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
24146
24146
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
24147
24147
  module.exports = send;
24148
24148
  module.exports.mime = mime;
24149
- function send(req, path6, options) {
24150
- return new SendStream(req, path6, options);
24149
+ function send(req, path7, options) {
24150
+ return new SendStream(req, path7, options);
24151
24151
  }
24152
24152
  __name(send, "send");
24153
- function SendStream(req, path6, options) {
24153
+ function SendStream(req, path7, options) {
24154
24154
  Stream.call(this);
24155
24155
  var opts = options || {};
24156
24156
  this.options = opts;
24157
- this.path = path6;
24157
+ this.path = path7;
24158
24158
  this.req = req;
24159
24159
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
24160
24160
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -24203,8 +24203,8 @@ var require_send = __commonJS({
24203
24203
  this._index = index2;
24204
24204
  return this;
24205
24205
  }, "index"), "send.index: pass index as option");
24206
- SendStream.prototype.root = /* @__PURE__ */ __name(function root(path6) {
24207
- this._root = resolve(String(path6));
24206
+ SendStream.prototype.root = /* @__PURE__ */ __name(function root(path7) {
24207
+ this._root = resolve(String(path7));
24208
24208
  debug("root %s", this._root);
24209
24209
  return this;
24210
24210
  }, "root");
@@ -24311,10 +24311,10 @@ var require_send = __commonJS({
24311
24311
  var lastModified = this.res.getHeader("Last-Modified");
24312
24312
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
24313
24313
  }, "isRangeFresh");
24314
- SendStream.prototype.redirect = /* @__PURE__ */ __name(function redirect(path6) {
24314
+ SendStream.prototype.redirect = /* @__PURE__ */ __name(function redirect(path7) {
24315
24315
  var res = this.res;
24316
24316
  if (hasListeners(this, "directory")) {
24317
- this.emit("directory", res, path6);
24317
+ this.emit("directory", res, path7);
24318
24318
  return;
24319
24319
  }
24320
24320
  if (this.hasTrailingSlash()) {
@@ -24334,42 +24334,42 @@ var require_send = __commonJS({
24334
24334
  SendStream.prototype.pipe = /* @__PURE__ */ __name(function pipe(res) {
24335
24335
  var root = this._root;
24336
24336
  this.res = res;
24337
- var path6 = decode(this.path);
24338
- if (path6 === -1) {
24337
+ var path7 = decode(this.path);
24338
+ if (path7 === -1) {
24339
24339
  this.error(400);
24340
24340
  return res;
24341
24341
  }
24342
- if (~path6.indexOf("\0")) {
24342
+ if (~path7.indexOf("\0")) {
24343
24343
  this.error(400);
24344
24344
  return res;
24345
24345
  }
24346
24346
  var parts;
24347
24347
  if (root !== null) {
24348
- if (path6) {
24349
- path6 = normalize("." + sep + path6);
24348
+ if (path7) {
24349
+ path7 = normalize("." + sep + path7);
24350
24350
  }
24351
- if (UP_PATH_REGEXP.test(path6)) {
24352
- debug('malicious path "%s"', path6);
24351
+ if (UP_PATH_REGEXP.test(path7)) {
24352
+ debug('malicious path "%s"', path7);
24353
24353
  this.error(403);
24354
24354
  return res;
24355
24355
  }
24356
- parts = path6.split(sep);
24357
- path6 = normalize(join5(root, path6));
24356
+ parts = path7.split(sep);
24357
+ path7 = normalize(join5(root, path7));
24358
24358
  } else {
24359
- if (UP_PATH_REGEXP.test(path6)) {
24360
- debug('malicious path "%s"', path6);
24359
+ if (UP_PATH_REGEXP.test(path7)) {
24360
+ debug('malicious path "%s"', path7);
24361
24361
  this.error(403);
24362
24362
  return res;
24363
24363
  }
24364
- parts = normalize(path6).split(sep);
24365
- path6 = resolve(path6);
24364
+ parts = normalize(path7).split(sep);
24365
+ path7 = resolve(path7);
24366
24366
  }
24367
24367
  if (containsDotFile(parts)) {
24368
24368
  var access = this._dotfiles;
24369
24369
  if (access === void 0) {
24370
24370
  access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
24371
24371
  }
24372
- debug('%s dotfile "%s"', access, path6);
24372
+ debug('%s dotfile "%s"', access, path7);
24373
24373
  switch (access) {
24374
24374
  case "allow":
24375
24375
  break;
@@ -24383,13 +24383,13 @@ var require_send = __commonJS({
24383
24383
  }
24384
24384
  }
24385
24385
  if (this._index.length && this.hasTrailingSlash()) {
24386
- this.sendIndex(path6);
24386
+ this.sendIndex(path7);
24387
24387
  return res;
24388
24388
  }
24389
- this.sendFile(path6);
24389
+ this.sendFile(path7);
24390
24390
  return res;
24391
24391
  }, "pipe");
24392
- SendStream.prototype.send = /* @__PURE__ */ __name(function send2(path6, stat) {
24392
+ SendStream.prototype.send = /* @__PURE__ */ __name(function send2(path7, stat) {
24393
24393
  var len = stat.size;
24394
24394
  var options = this.options;
24395
24395
  var opts = {};
@@ -24401,9 +24401,9 @@ var require_send = __commonJS({
24401
24401
  this.headersAlreadySent();
24402
24402
  return;
24403
24403
  }
24404
- debug('pipe "%s"', path6);
24405
- this.setHeader(path6, stat);
24406
- this.type(path6);
24404
+ debug('pipe "%s"', path7);
24405
+ this.setHeader(path7, stat);
24406
+ this.type(path7);
24407
24407
  if (this.isConditionalGET()) {
24408
24408
  if (this.isPreconditionFailure()) {
24409
24409
  this.error(412);
@@ -24454,28 +24454,28 @@ var require_send = __commonJS({
24454
24454
  res.end();
24455
24455
  return;
24456
24456
  }
24457
- this.stream(path6, opts);
24457
+ this.stream(path7, opts);
24458
24458
  }, "send");
24459
- SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(path6) {
24459
+ SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(path7) {
24460
24460
  var i = 0;
24461
24461
  var self = this;
24462
- debug('stat "%s"', path6);
24463
- fs9.stat(path6, /* @__PURE__ */ __name(function onstat(err, stat) {
24464
- if (err && err.code === "ENOENT" && !extname(path6) && path6[path6.length - 1] !== sep) {
24462
+ debug('stat "%s"', path7);
24463
+ fs10.stat(path7, /* @__PURE__ */ __name(function onstat(err, stat) {
24464
+ if (err && err.code === "ENOENT" && !extname(path7) && path7[path7.length - 1] !== sep) {
24465
24465
  return next(err);
24466
24466
  }
24467
24467
  if (err) return self.onStatError(err);
24468
- if (stat.isDirectory()) return self.redirect(path6);
24469
- self.emit("file", path6, stat);
24470
- self.send(path6, stat);
24468
+ if (stat.isDirectory()) return self.redirect(path7);
24469
+ self.emit("file", path7, stat);
24470
+ self.send(path7, stat);
24471
24471
  }, "onstat"));
24472
24472
  function next(err) {
24473
24473
  if (self._extensions.length <= i) {
24474
24474
  return err ? self.onStatError(err) : self.error(404);
24475
24475
  }
24476
- var p = path6 + "." + self._extensions[i++];
24476
+ var p = path7 + "." + self._extensions[i++];
24477
24477
  debug('stat "%s"', p);
24478
- fs9.stat(p, function(err2, stat) {
24478
+ fs10.stat(p, function(err2, stat) {
24479
24479
  if (err2) return next(err2);
24480
24480
  if (stat.isDirectory()) return next();
24481
24481
  self.emit("file", p, stat);
@@ -24484,7 +24484,7 @@ var require_send = __commonJS({
24484
24484
  }
24485
24485
  __name(next, "next");
24486
24486
  }, "sendFile");
24487
- SendStream.prototype.sendIndex = /* @__PURE__ */ __name(function sendIndex(path6) {
24487
+ SendStream.prototype.sendIndex = /* @__PURE__ */ __name(function sendIndex(path7) {
24488
24488
  var i = -1;
24489
24489
  var self = this;
24490
24490
  function next(err) {
@@ -24492,9 +24492,9 @@ var require_send = __commonJS({
24492
24492
  if (err) return self.onStatError(err);
24493
24493
  return self.error(404);
24494
24494
  }
24495
- var p = join5(path6, self._index[i]);
24495
+ var p = join5(path7, self._index[i]);
24496
24496
  debug('stat "%s"', p);
24497
- fs9.stat(p, function(err2, stat) {
24497
+ fs10.stat(p, function(err2, stat) {
24498
24498
  if (err2) return next(err2);
24499
24499
  if (stat.isDirectory()) return next();
24500
24500
  self.emit("file", p, stat);
@@ -24504,10 +24504,10 @@ var require_send = __commonJS({
24504
24504
  __name(next, "next");
24505
24505
  next();
24506
24506
  }, "sendIndex");
24507
- SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(path6, options) {
24507
+ SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(path7, options) {
24508
24508
  var self = this;
24509
24509
  var res = this.res;
24510
- var stream2 = fs9.createReadStream(path6, options);
24510
+ var stream2 = fs10.createReadStream(path7, options);
24511
24511
  this.emit("stream", stream2);
24512
24512
  stream2.pipe(res);
24513
24513
  function cleanup() {
@@ -24523,10 +24523,10 @@ var require_send = __commonJS({
24523
24523
  self.emit("end");
24524
24524
  }, "onend"));
24525
24525
  }, "stream");
24526
- SendStream.prototype.type = /* @__PURE__ */ __name(function type(path6) {
24526
+ SendStream.prototype.type = /* @__PURE__ */ __name(function type(path7) {
24527
24527
  var res = this.res;
24528
24528
  if (res.getHeader("Content-Type")) return;
24529
- var type2 = mime.lookup(path6);
24529
+ var type2 = mime.lookup(path7);
24530
24530
  if (!type2) {
24531
24531
  debug("no content-type");
24532
24532
  return;
@@ -24535,9 +24535,9 @@ var require_send = __commonJS({
24535
24535
  debug("content-type %s", type2);
24536
24536
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
24537
24537
  }, "type");
24538
- SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(path6, stat) {
24538
+ SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(path7, stat) {
24539
24539
  var res = this.res;
24540
- this.emit("headers", res, path6, stat);
24540
+ this.emit("headers", res, path7, stat);
24541
24541
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
24542
24542
  debug("accept ranges");
24543
24543
  res.setHeader("Accept-Ranges", "bytes");
@@ -24604,9 +24604,9 @@ var require_send = __commonJS({
24604
24604
  }) : createError(status, err);
24605
24605
  }
24606
24606
  __name(createHttpError, "createHttpError");
24607
- function decode(path6) {
24607
+ function decode(path7) {
24608
24608
  try {
24609
- return decodeURIComponent(path6);
24609
+ return decodeURIComponent(path7);
24610
24610
  } catch (err) {
24611
24611
  return -1;
24612
24612
  }
@@ -25864,10 +25864,10 @@ var require_utils2 = __commonJS({
25864
25864
  exports.wetag = createETagGenerator({
25865
25865
  weak: true
25866
25866
  });
25867
- exports.isAbsolute = function(path5) {
25868
- if ("/" === path5[0]) return true;
25869
- if (":" === path5[1] && ("\\" === path5[2] || "/" === path5[2])) return true;
25870
- if ("\\\\" === path5.substring(0, 2)) return true;
25867
+ exports.isAbsolute = function(path6) {
25868
+ if ("/" === path6[0]) return true;
25869
+ if (":" === path6[1] && ("\\" === path6[2] || "/" === path6[2])) return true;
25870
+ if ("\\\\" === path6.substring(0, 2)) return true;
25871
25871
  };
25872
25872
  exports.flatten = deprecate.function(flatten, "utils.flatten: use array-flatten npm module instead");
25873
25873
  exports.normalizeType = function(type) {
@@ -26083,7 +26083,7 @@ var require_application = __commonJS({
26083
26083
  }, "handle");
26084
26084
  app.use = /* @__PURE__ */ __name(function use(fn) {
26085
26085
  var offset = 0;
26086
- var path5 = "/";
26086
+ var path6 = "/";
26087
26087
  if (typeof fn !== "function") {
26088
26088
  var arg = fn;
26089
26089
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -26091,7 +26091,7 @@ var require_application = __commonJS({
26091
26091
  }
26092
26092
  if (typeof arg !== "function") {
26093
26093
  offset = 1;
26094
- path5 = fn;
26094
+ path6 = fn;
26095
26095
  }
26096
26096
  }
26097
26097
  var fns = flatten(slice.call(arguments, offset));
@@ -26102,12 +26102,12 @@ var require_application = __commonJS({
26102
26102
  var router = this._router;
26103
26103
  fns.forEach(function(fn2) {
26104
26104
  if (!fn2 || !fn2.handle || !fn2.set) {
26105
- return router.use(path5, fn2);
26105
+ return router.use(path6, fn2);
26106
26106
  }
26107
- debug(".use app under %s", path5);
26108
- fn2.mountpath = path5;
26107
+ debug(".use app under %s", path6);
26108
+ fn2.mountpath = path6;
26109
26109
  fn2.parent = this;
26110
- router.use(path5, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
26110
+ router.use(path6, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
26111
26111
  var orig = req.app;
26112
26112
  fn2.handle(req, res, function(err) {
26113
26113
  setPrototypeOf(req, orig.request);
@@ -26119,9 +26119,9 @@ var require_application = __commonJS({
26119
26119
  }, this);
26120
26120
  return this;
26121
26121
  }, "use");
26122
- app.route = /* @__PURE__ */ __name(function route(path5) {
26122
+ app.route = /* @__PURE__ */ __name(function route(path6) {
26123
26123
  this.lazyrouter();
26124
- return this._router.route(path5);
26124
+ return this._router.route(path6);
26125
26125
  }, "route");
26126
26126
  app.engine = /* @__PURE__ */ __name(function engine(ext, fn) {
26127
26127
  if (typeof fn !== "function") {
@@ -26172,7 +26172,7 @@ var require_application = __commonJS({
26172
26172
  }
26173
26173
  return this;
26174
26174
  }, "set");
26175
- app.path = /* @__PURE__ */ __name(function path5() {
26175
+ app.path = /* @__PURE__ */ __name(function path6() {
26176
26176
  return this.parent ? this.parent.path() + this.mountpath : "";
26177
26177
  }, "path");
26178
26178
  app.enabled = /* @__PURE__ */ __name(function enabled(setting) {
@@ -26188,19 +26188,19 @@ var require_application = __commonJS({
26188
26188
  return this.set(setting, false);
26189
26189
  }, "disable");
26190
26190
  methods.forEach(function(method) {
26191
- app[method] = function(path5) {
26191
+ app[method] = function(path6) {
26192
26192
  if (method === "get" && arguments.length === 1) {
26193
- return this.set(path5);
26193
+ return this.set(path6);
26194
26194
  }
26195
26195
  this.lazyrouter();
26196
- var route = this._router.route(path5);
26196
+ var route = this._router.route(path6);
26197
26197
  route[method].apply(route, slice.call(arguments, 1));
26198
26198
  return this;
26199
26199
  };
26200
26200
  });
26201
- app.all = /* @__PURE__ */ __name(function all(path5) {
26201
+ app.all = /* @__PURE__ */ __name(function all(path6) {
26202
26202
  this.lazyrouter();
26203
- var route = this._router.route(path5);
26203
+ var route = this._router.route(path6);
26204
26204
  var args = slice.call(arguments, 1);
26205
26205
  for (var i = 0; i < methods.length; i++) {
26206
26206
  route[methods[i]].apply(route, args);
@@ -27013,7 +27013,7 @@ var require_request = __commonJS({
27013
27013
  ];
27014
27014
  return subdomains2.slice(offset);
27015
27015
  }, "subdomains"));
27016
- defineGetter(req, "path", /* @__PURE__ */ __name(function path5() {
27016
+ defineGetter(req, "path", /* @__PURE__ */ __name(function path6() {
27017
27017
  return parse(this).pathname;
27018
27018
  }, "path"));
27019
27019
  defineGetter(req, "hostname", /* @__PURE__ */ __name(function hostname() {
@@ -27347,7 +27347,7 @@ var require_response = __commonJS({
27347
27347
  var http = __require("http");
27348
27348
  var isAbsolute3 = require_utils2().isAbsolute;
27349
27349
  var onFinished = require_on_finished();
27350
- var path5 = __require("path");
27350
+ var path6 = __require("path");
27351
27351
  var statuses = require_statuses();
27352
27352
  var merge = require_utils_merge();
27353
27353
  var sign = require_cookie_signature().sign;
@@ -27356,9 +27356,9 @@ var require_response = __commonJS({
27356
27356
  var setCharset = require_utils2().setCharset;
27357
27357
  var cookie = require_cookie();
27358
27358
  var send = require_send();
27359
- var extname = path5.extname;
27359
+ var extname = path6.extname;
27360
27360
  var mime = send.mime;
27361
- var resolve = path5.resolve;
27361
+ var resolve = path6.resolve;
27362
27362
  var vary = require_vary();
27363
27363
  var res = Object.create(http.ServerResponse.prototype);
27364
27364
  module.exports = res;
@@ -27535,26 +27535,26 @@ var require_response = __commonJS({
27535
27535
  this.type("txt");
27536
27536
  return this.send(body);
27537
27537
  }, "sendStatus");
27538
- res.sendFile = /* @__PURE__ */ __name(function sendFile(path6, options, callback) {
27538
+ res.sendFile = /* @__PURE__ */ __name(function sendFile(path7, options, callback) {
27539
27539
  var done = callback;
27540
27540
  var req = this.req;
27541
27541
  var res2 = this;
27542
27542
  var next = req.next;
27543
27543
  var opts = options || {};
27544
- if (!path6) {
27544
+ if (!path7) {
27545
27545
  throw new TypeError("path argument is required to res.sendFile");
27546
27546
  }
27547
- if (typeof path6 !== "string") {
27547
+ if (typeof path7 !== "string") {
27548
27548
  throw new TypeError("path must be a string to res.sendFile");
27549
27549
  }
27550
27550
  if (typeof options === "function") {
27551
27551
  done = options;
27552
27552
  opts = {};
27553
27553
  }
27554
- if (!opts.root && !isAbsolute3(path6)) {
27554
+ if (!opts.root && !isAbsolute3(path7)) {
27555
27555
  throw new TypeError("path must be absolute or specify root to res.sendFile");
27556
27556
  }
27557
- var pathname = encodeURI(path6);
27557
+ var pathname = encodeURI(path7);
27558
27558
  var file = send(req, pathname, opts);
27559
27559
  sendfile(res2, file, opts, function(err) {
27560
27560
  if (done) return done(err);
@@ -27564,7 +27564,7 @@ var require_response = __commonJS({
27564
27564
  }
27565
27565
  });
27566
27566
  }, "sendFile");
27567
- res.sendfile = function(path6, options, callback) {
27567
+ res.sendfile = function(path7, options, callback) {
27568
27568
  var done = callback;
27569
27569
  var req = this.req;
27570
27570
  var res2 = this;
@@ -27574,7 +27574,7 @@ var require_response = __commonJS({
27574
27574
  done = options;
27575
27575
  opts = {};
27576
27576
  }
27577
- var file = send(req, path6, opts);
27577
+ var file = send(req, path7, opts);
27578
27578
  sendfile(res2, file, opts, function(err) {
27579
27579
  if (done) return done(err);
27580
27580
  if (err && err.code === "EISDIR") return next();
@@ -27584,7 +27584,7 @@ var require_response = __commonJS({
27584
27584
  });
27585
27585
  };
27586
27586
  res.sendfile = deprecate.function(res.sendfile, "res.sendfile: Use res.sendFile instead");
27587
- res.download = /* @__PURE__ */ __name(function download(path6, filename, options, callback) {
27587
+ res.download = /* @__PURE__ */ __name(function download(path7, filename, options, callback) {
27588
27588
  var done = callback;
27589
27589
  var name = filename;
27590
27590
  var opts = options || null;
@@ -27601,7 +27601,7 @@ var require_response = __commonJS({
27601
27601
  opts = filename;
27602
27602
  }
27603
27603
  var headers = {
27604
- "Content-Disposition": contentDisposition(name || path6)
27604
+ "Content-Disposition": contentDisposition(name || path7)
27605
27605
  };
27606
27606
  if (opts && opts.headers) {
27607
27607
  var keys = Object.keys(opts.headers);
@@ -27614,7 +27614,7 @@ var require_response = __commonJS({
27614
27614
  }
27615
27615
  opts = Object.create(opts);
27616
27616
  opts.headers = headers;
27617
- var fullPath = !opts.root ? resolve(path6) : path6;
27617
+ var fullPath = !opts.root ? resolve(path7) : path7;
27618
27618
  return this.sendFile(fullPath, opts, done);
27619
27619
  }, "download");
27620
27620
  res.contentType = res.type = /* @__PURE__ */ __name(function contentType(type) {
@@ -27932,11 +27932,11 @@ var require_serve_static = __commonJS({
27932
27932
  }
27933
27933
  var forwardError = !fallthrough;
27934
27934
  var originalUrl = parseUrl.original(req);
27935
- var path5 = parseUrl(req).pathname;
27936
- if (path5 === "/" && originalUrl.pathname.substr(-1) !== "/") {
27937
- path5 = "";
27935
+ var path6 = parseUrl(req).pathname;
27936
+ if (path6 === "/" && originalUrl.pathname.substr(-1) !== "/") {
27937
+ path6 = "";
27938
27938
  }
27939
- var stream = send(req, path5, opts);
27939
+ var stream = send(req, path6, opts);
27940
27940
  stream.on("directory", onDirectory);
27941
27941
  if (setHeaders) {
27942
27942
  stream.on("headers", setHeaders);
@@ -28389,32 +28389,152 @@ function collapseExtraBlankLines(text) {
28389
28389
  }
28390
28390
  __name(collapseExtraBlankLines, "collapseExtraBlankLines");
28391
28391
 
28392
+ // src/helpers/proxy-error/index.ts
28393
+ import fs2 from "fs";
28394
+ import path2 from "path";
28395
+ import { createReadStream } from "fs";
28396
+ import { createInterface } from "readline";
28397
+ var errorHtmlTemplate = null;
28398
+ function getDirname() {
28399
+ return __dirname;
28400
+ }
28401
+ __name(getDirname, "getDirname");
28402
+ function getErrorHtmlTemplate() {
28403
+ if (!errorHtmlTemplate) {
28404
+ const dirname = getDirname();
28405
+ const htmlPath = path2.join(dirname, "error.html");
28406
+ errorHtmlTemplate = fs2.readFileSync(htmlPath, "utf-8");
28407
+ }
28408
+ return errorHtmlTemplate;
28409
+ }
28410
+ __name(getErrorHtmlTemplate, "getErrorHtmlTemplate");
28411
+ function parseLogLine(line) {
28412
+ const trimmed = line.trim();
28413
+ if (!trimmed) return null;
28414
+ const match = trimmed.match(/^\[\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\]\s+\[server\]\s+(.*)$/);
28415
+ if (match) {
28416
+ return match[1];
28417
+ }
28418
+ return trimmed;
28419
+ }
28420
+ __name(parseLogLine, "parseLogLine");
28421
+ async function readRecentErrorLogs(logDir, maxLogs, fileName) {
28422
+ const logFilePath = path2.join(logDir, fileName);
28423
+ try {
28424
+ await fs2.promises.access(logFilePath);
28425
+ } catch {
28426
+ return [];
28427
+ }
28428
+ const allLines = [];
28429
+ const stream = createReadStream(logFilePath, {
28430
+ encoding: "utf8"
28431
+ });
28432
+ const rl = createInterface({
28433
+ input: stream,
28434
+ crlfDelay: Infinity
28435
+ });
28436
+ try {
28437
+ for await (const line of rl) {
28438
+ const parsed = parseLogLine(line);
28439
+ if (parsed !== null) {
28440
+ allLines.push(parsed);
28441
+ }
28442
+ }
28443
+ } finally {
28444
+ rl.close();
28445
+ stream.destroy();
28446
+ }
28447
+ let startIndex = -1;
28448
+ for (let i = allLines.length - 1; i >= 0; i--) {
28449
+ if (allLines[i].includes("dev:server")) {
28450
+ startIndex = i;
28451
+ break;
28452
+ }
28453
+ }
28454
+ if (startIndex === -1) {
28455
+ return [];
28456
+ }
28457
+ let endIndex = allLines.length;
28458
+ for (let i = startIndex; i < allLines.length; i++) {
28459
+ if (/Found \d+ errors?\./.test(allLines[i])) {
28460
+ endIndex = i + 1;
28461
+ break;
28462
+ }
28463
+ }
28464
+ const errorSection = allLines.slice(startIndex, endIndex);
28465
+ if (errorSection.length > maxLogs) {
28466
+ return errorSection.slice(-maxLogs);
28467
+ }
28468
+ return errorSection;
28469
+ }
28470
+ __name(readRecentErrorLogs, "readRecentErrorLogs");
28471
+ function injectErrorData(template, errorLogs) {
28472
+ let logsText = "";
28473
+ if (errorLogs.length > 0) {
28474
+ logsText = errorLogs.join("\n");
28475
+ } else {
28476
+ logsText = "\u672A\u627E\u5230\u76F8\u5173\u9519\u8BEF\u65E5\u5FD7";
28477
+ }
28478
+ return template.replace("{{.errorData.message}}", `\u670D\u52A1\u542F\u52A8\u5F02\u5E38\uFF0C\u8BF7\u6839\u636E\u65E5\u5FD7\u4FEE\u590D\u76F8\u5173\u95EE\u9898
28479
+ ${JSON.stringify(logsText)}`);
28480
+ }
28481
+ __name(injectErrorData, "injectErrorData");
28482
+ function handleDevProxyError(err, _req, res, options) {
28483
+ const { logDir = path2.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "server.log" } = options || {};
28484
+ console.error("[Proxy Error]:", err.message);
28485
+ if (res.headersSent) {
28486
+ console.error("[Proxy Error]: Headers already sent, cannot send error page");
28487
+ return;
28488
+ }
28489
+ (async () => {
28490
+ try {
28491
+ const errorLogs = await readRecentErrorLogs(logDir, maxErrorLogs, logFileName);
28492
+ const template = getErrorHtmlTemplate();
28493
+ const html = injectErrorData(template, errorLogs);
28494
+ res.writeHead(502, {
28495
+ "Content-Type": "text/html; charset=utf-8",
28496
+ "Cache-Control": "no-cache, no-store, must-revalidate"
28497
+ });
28498
+ res.end(html);
28499
+ } catch (error) {
28500
+ console.error("[Proxy Error]: Failed to send error page:", error);
28501
+ if (!res.headersSent) {
28502
+ res.writeHead(502, {
28503
+ "Content-Type": "text/plain; charset=utf-8"
28504
+ });
28505
+ res.end(`Node \u670D\u52A1\u542F\u52A8\u5F02\u5E38\uFF0C\u8BF7\u6839\u636E\u65E5\u5FD7\u4FEE\u590D\u76F8\u5173\u95EE\u9898`);
28506
+ }
28507
+ }
28508
+ })();
28509
+ }
28510
+ __name(handleDevProxyError, "handleDevProxyError");
28511
+
28392
28512
  // src/middlewares/index.ts
28393
- import path4 from "path";
28513
+ import path5 from "path";
28394
28514
 
28395
28515
  // src/middlewares/openapi/router.ts
28396
28516
  var import_express = __toESM(require_express2(), 1);
28397
28517
 
28398
28518
  // src/middlewares/openapi/controller.ts
28399
- import fs4 from "fs/promises";
28519
+ import fs5 from "fs/promises";
28400
28520
  import crypto from "crypto";
28401
28521
 
28402
28522
  // src/middlewares/openapi/services.ts
28403
- import { promises as fs3 } from "fs";
28404
- import path3 from "path";
28523
+ import { promises as fs4 } from "fs";
28524
+ import path4 from "path";
28405
28525
  import ts from "typescript";
28406
28526
 
28407
28527
  // src/middlewares/openapi/utils.ts
28408
- import path2 from "path";
28409
- import { promises as fs2 } from "fs";
28528
+ import path3 from "path";
28529
+ import { promises as fs3 } from "fs";
28410
28530
  async function findControllerFiles(dir) {
28411
28531
  const files = [];
28412
28532
  async function scan(currentDir) {
28413
- const entries = await fs2.readdir(currentDir, {
28533
+ const entries = await fs3.readdir(currentDir, {
28414
28534
  withFileTypes: true
28415
28535
  });
28416
28536
  for (const entry of entries) {
28417
- const fullPath = path2.join(currentDir, entry.name);
28537
+ const fullPath = path3.join(currentDir, entry.name);
28418
28538
  if (entry.isDirectory()) {
28419
28539
  await scan(fullPath);
28420
28540
  } else if (entry.isFile() && entry.name.endsWith(".controller.ts")) {
@@ -28487,21 +28607,21 @@ __name(transformOpenapiPaths, "transformOpenapiPaths");
28487
28607
  // src/middlewares/openapi/services.ts
28488
28608
  async function enhanceOpenApiWithSourceInfo(options = {}) {
28489
28609
  const startTime = Date.now();
28490
- const openapiPath = options.openapiPath || path3.resolve(__dirname, "../client/src/api/gen/openapi.json");
28491
- const serverDir = options.serverDir || path3.resolve(__dirname, "../server");
28610
+ const openapiPath = options.openapiPath || path4.resolve(__dirname, "../client/src/api/gen/openapi.json");
28611
+ const serverDir = options.serverDir || path4.resolve(__dirname, "../server");
28492
28612
  const writeFile = options.writeFile !== false;
28493
28613
  let openapi;
28494
28614
  if (options.openapiData) {
28495
28615
  openapi = JSON.parse(JSON.stringify(options.openapiData));
28496
28616
  } else {
28497
- const openapiContent = await fs3.readFile(openapiPath, "utf-8");
28617
+ const openapiContent = await fs4.readFile(openapiPath, "utf-8");
28498
28618
  openapi = JSON.parse(openapiContent);
28499
28619
  }
28500
28620
  const controllerFiles = await findControllerFiles(serverDir);
28501
28621
  const sourceMap = await buildSourceMap(controllerFiles, processControllerFile);
28502
28622
  const enhanced = enhanceOpenApiPaths(openapi, sourceMap);
28503
28623
  if (writeFile) {
28504
- await fs3.writeFile(openapiPath, JSON.stringify(openapi, null, 2) + "\n", "utf-8");
28624
+ await fs4.writeFile(openapiPath, JSON.stringify(openapi, null, 2) + "\n", "utf-8");
28505
28625
  }
28506
28626
  const duration = Date.now() - startTime;
28507
28627
  return {
@@ -28516,8 +28636,8 @@ async function enhanceOpenApiWithSourceInfo(options = {}) {
28516
28636
  }
28517
28637
  __name(enhanceOpenApiWithSourceInfo, "enhanceOpenApiWithSourceInfo");
28518
28638
  async function processControllerFile(filePath) {
28519
- const relativePath = path3.relative(process.cwd(), filePath);
28520
- const content = await fs3.readFile(filePath, "utf-8");
28639
+ const relativePath = path4.relative(process.cwd(), filePath);
28640
+ const content = await fs4.readFile(filePath, "utf-8");
28521
28641
  const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
28522
28642
  return extractControllerMetadata(sourceFile, relativePath);
28523
28643
  }
@@ -28605,7 +28725,7 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir) {
28605
28725
  let cache = null;
28606
28726
  return async (_req, res, context) => {
28607
28727
  try {
28608
- const fileBuffer = await fs4.readFile(openapiFilePath, "utf-8");
28728
+ const fileBuffer = await fs5.readFile(openapiFilePath, "utf-8");
28609
28729
  const currentHash = crypto.createHash("md5").update(fileBuffer).digest("hex");
28610
28730
  if (cache && cache.fileHash === currentHash) {
28611
28731
  return res.json(cache.data);
@@ -28677,7 +28797,7 @@ __name(createOpenapiMiddleware, "createOpenapiMiddleware");
28677
28797
  var import_express2 = __toESM(require_express2(), 1);
28678
28798
 
28679
28799
  // src/middlewares/dev-logs/utils.ts
28680
- import { promises as fs5 } from "fs";
28800
+ import { promises as fs6 } from "fs";
28681
28801
  import { isAbsolute, join, relative } from "path";
28682
28802
 
28683
28803
  // src/middlewares/dev-logs/helper/path-matcher.ts
@@ -28710,8 +28830,8 @@ function hasSpecialPatterns(pattern) {
28710
28830
  return /[{*]/.test(pattern);
28711
28831
  }
28712
28832
  __name(hasSpecialPatterns, "hasSpecialPatterns");
28713
- function normalizePathForMatching(path5) {
28714
- return path5.replace(/\/+/g, "/").replace(/\/+$/, "");
28833
+ function normalizePathForMatching(path6) {
28834
+ return path6.replace(/\/+/g, "/").replace(/\/+$/, "");
28715
28835
  }
28716
28836
  __name(normalizePathForMatching, "normalizePathForMatching");
28717
28837
 
@@ -28729,14 +28849,14 @@ function getRelativePath(filePath) {
28729
28849
  __name(getRelativePath, "getRelativePath");
28730
28850
  async function fileExists(filePath) {
28731
28851
  try {
28732
- await fs5.access(filePath);
28852
+ await fs6.access(filePath);
28733
28853
  return true;
28734
28854
  } catch {
28735
28855
  return false;
28736
28856
  }
28737
28857
  }
28738
28858
  __name(fileExists, "fileExists");
28739
- function parseLogLine(line) {
28859
+ function parseLogLine2(line) {
28740
28860
  const trimmed = line.trim();
28741
28861
  if (!trimmed) return void 0;
28742
28862
  try {
@@ -28745,7 +28865,7 @@ function parseLogLine(line) {
28745
28865
  return void 0;
28746
28866
  }
28747
28867
  }
28748
- __name(parseLogLine, "parseLogLine");
28868
+ __name(parseLogLine2, "parseLogLine");
28749
28869
  function extractNumber(message, pattern) {
28750
28870
  if (typeof message !== "string") return void 0;
28751
28871
  const match = message.match(pattern);
@@ -28812,23 +28932,23 @@ __name(serializeError, "serializeError");
28812
28932
  import { join as join2 } from "path";
28813
28933
 
28814
28934
  // src/middlewares/dev-logs/services.ts
28815
- import { createReadStream, promises as fs6 } from "fs";
28816
- import { createInterface } from "readline";
28935
+ import { createReadStream as createReadStream2, promises as fs7 } from "fs";
28936
+ import { createInterface as createInterface2 } from "readline";
28817
28937
  async function readLogEntriesByTrace(filePath, traceId, limit) {
28818
28938
  const exists = await fileExists(filePath);
28819
28939
  if (!exists) {
28820
28940
  return void 0;
28821
28941
  }
28822
28942
  const matches = [];
28823
- const stream = createReadStream(filePath, {
28943
+ const stream = createReadStream2(filePath, {
28824
28944
  encoding: "utf8"
28825
28945
  });
28826
- const rl = createInterface({
28946
+ const rl = createInterface2({
28827
28947
  input: stream,
28828
28948
  crlfDelay: Infinity
28829
28949
  });
28830
28950
  for await (const line of rl) {
28831
- const entry = parseLogLine(line);
28951
+ const entry = parseLogLine2(line);
28832
28952
  if (!entry) continue;
28833
28953
  if (entry.trace_id !== traceId) continue;
28834
28954
  matches.push(entry);
@@ -28902,7 +29022,7 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter, method
28902
29022
  }
28903
29023
  }, "processLogEntry");
28904
29024
  const processLine = /* @__PURE__ */ __name((line) => {
28905
- const entry = parseLogLine(line);
29025
+ const entry = parseLogLine2(line);
28906
29026
  if (entry?.trace_id) {
28907
29027
  processLogEntry(entry);
28908
29028
  }
@@ -28912,7 +29032,7 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter, method
28912
29032
  }
28913
29033
  __name(readRecentTraceCalls, "readRecentTraceCalls");
28914
29034
  async function readFileReverse(filePath, chunkSize, processLine) {
28915
- const handle = await fs6.open(filePath, "r");
29035
+ const handle = await fs7.open(filePath, "r");
28916
29036
  try {
28917
29037
  const stats = await handle.stat();
28918
29038
  let position = stats.size;
@@ -28974,10 +29094,10 @@ async function readLogFilePage(filePath, page, pageSize) {
28974
29094
  const capacity = page * pageSize;
28975
29095
  const buffer = [];
28976
29096
  let totalLines = 0;
28977
- const stream = createReadStream(filePath, {
29097
+ const stream = createReadStream2(filePath, {
28978
29098
  encoding: "utf8"
28979
29099
  });
28980
- const rl = createInterface({
29100
+ const rl = createInterface2({
28981
29101
  input: stream,
28982
29102
  crlfDelay: Infinity
28983
29103
  });
@@ -29038,7 +29158,7 @@ function handleError(res, error, message = "Failed to read log file") {
29038
29158
  }
29039
29159
  __name(handleError, "handleError");
29040
29160
  function createGetTraceEntriesHandler(logDir) {
29041
- const appLogPath = join2(logDir, "app.log");
29161
+ const appLogPath = join2(logDir, "server.log");
29042
29162
  return async (req, res) => {
29043
29163
  const traceId = (req.params.traceId || "").trim();
29044
29164
  if (!traceId) {
@@ -29166,11 +29286,11 @@ var import_express3 = __toESM(require_express2(), 1);
29166
29286
 
29167
29287
  // src/middlewares/collect-logs/controller.ts
29168
29288
  import { join as join4 } from "path";
29169
- import fs8 from "fs";
29289
+ import fs9 from "fs";
29170
29290
 
29171
29291
  // src/middlewares/collect-logs/utils.ts
29172
29292
  import { isAbsolute as isAbsolute2, join as join3 } from "path";
29173
- import fs7 from "fs";
29293
+ import fs8 from "fs";
29174
29294
  function resolveLogDir2(provided) {
29175
29295
  if (!provided) {
29176
29296
  return join3(process.cwd(), "logs");
@@ -29179,8 +29299,8 @@ function resolveLogDir2(provided) {
29179
29299
  }
29180
29300
  __name(resolveLogDir2, "resolveLogDir");
29181
29301
  function ensureDir(dir) {
29182
- if (!fs7.existsSync(dir)) {
29183
- fs7.mkdirSync(dir, {
29302
+ if (!fs8.existsSync(dir)) {
29303
+ fs8.mkdirSync(dir, {
29184
29304
  recursive: true
29185
29305
  });
29186
29306
  }
@@ -29212,7 +29332,7 @@ function collectLogsHandler(logDir, fileName) {
29212
29332
  ...logContent,
29213
29333
  server_time: (/* @__PURE__ */ new Date()).toISOString()
29214
29334
  }) + "\n";
29215
- await fs8.promises.appendFile(filePath, logLine);
29335
+ await fs9.promises.appendFile(filePath, logLine);
29216
29336
  res.json({
29217
29337
  success: true
29218
29338
  });
@@ -29240,7 +29360,7 @@ function collectLogsBatchHandler(logDir, fileName) {
29240
29360
  server_time: (/* @__PURE__ */ new Date()).toISOString()
29241
29361
  }) + "\n");
29242
29362
  }
29243
- await fs8.promises.appendFile(filePath, logLines.join(""));
29363
+ await fs9.promises.appendFile(filePath, logLines.join(""));
29244
29364
  res.json({
29245
29365
  success: true
29246
29366
  });
@@ -29303,7 +29423,7 @@ function isGlobalMiddleware(middleware) {
29303
29423
  }
29304
29424
  __name(isGlobalMiddleware, "isGlobalMiddleware");
29305
29425
  function computeMountPath(basePath, mountPath) {
29306
- const routePath = path4.posix.join(basePath, mountPath);
29426
+ const routePath = path5.posix.join(basePath, mountPath);
29307
29427
  return routePath.startsWith("/") ? routePath : `/${routePath}`;
29308
29428
  }
29309
29429
  __name(computeMountPath, "computeMountPath");
@@ -29311,7 +29431,7 @@ function logMiddlewareRegistration(middleware, fullMountPath) {
29311
29431
  if (middleware.routes && middleware.routes.length > 0) {
29312
29432
  console.log(`[Middleware] Registered: ${middleware.name} at ${fullMountPath}`);
29313
29433
  middleware.routes.forEach((route) => {
29314
- const routePath = route.path === "/" ? fullMountPath : path4.posix.join(fullMountPath, route.path);
29434
+ const routePath = route.path === "/" ? fullMountPath : path5.posix.join(fullMountPath, route.path);
29315
29435
  console.log(` ${route.method} ${routePath} - ${route.description}`);
29316
29436
  });
29317
29437
  } else {
@@ -29373,6 +29493,7 @@ export {
29373
29493
  createCollectLogsMiddleware,
29374
29494
  createDevLogsMiddleware,
29375
29495
  createOpenapiMiddleware,
29496
+ handleDevProxyError,
29376
29497
  normalizeBasePath,
29377
29498
  postprocessDrizzleSchema,
29378
29499
  registerMiddlewares