routup 6.0.0-beta.1 → 6.0.0-beta.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.
@@ -20,11 +20,9 @@ const DEFAULT_MAX_SIZE = 1024;
20
20
  * `ICache` (e.g. wrapping `lru-cache`) and pass it via the router's
21
21
  * `BaseRouterOptions.cache` slot.
22
22
  */
23
- var LruCache = class LruCache {
24
- options;
23
+ var LruCache = class {
25
24
  inner;
26
25
  constructor(options = {}) {
27
- this.options = options;
28
26
  this.inner = new QuickLRU({ maxSize: options.maxSize ?? DEFAULT_MAX_SIZE });
29
27
  }
30
28
  get(key) {
@@ -39,9 +37,6 @@ var LruCache = class LruCache {
39
37
  clear() {
40
38
  this.inner.clear();
41
39
  }
42
- clone() {
43
- return new LruCache({ ...this.options });
44
- }
45
40
  };
46
41
  //#endregion
47
42
  //#region src/constants.ts
@@ -1539,7 +1534,7 @@ function buildRoutePathMatcher(route) {
1539
1534
  * `BaseRouterOptions.cache` to skip the linear walk on repeated
1540
1535
  * requests for the same path. Default is no caching.
1541
1536
  */
1542
- var LinearRouter = class LinearRouter {
1537
+ var LinearRouter = class {
1543
1538
  _routes;
1544
1539
  _matchers;
1545
1540
  cache;
@@ -1580,9 +1575,6 @@ var LinearRouter = class LinearRouter {
1580
1575
  this.cache?.set(path, matches);
1581
1576
  return matches;
1582
1577
  }
1583
- clone() {
1584
- return new LinearRouter({ cache: this.cache?.clone() });
1585
- }
1586
1578
  };
1587
1579
  //#endregion
1588
1580
  //#region src/router/trie/parser.ts
@@ -1989,7 +1981,7 @@ function pushIntoBucket(buckets, methodKey, route) {
1989
1981
  * method's buckets) is the full answer — no need to walk the param
1990
1982
  * branch or collect prefix candidates at intermediate nodes.
1991
1983
  */
1992
- var TrieRouter = class TrieRouter {
1984
+ var TrieRouter = class {
1993
1985
  /**
1994
1986
  * Monotonic counter assigned as the registration `index` on each
1995
1987
  * route — the dispatch loop uses it to preserve registration
@@ -2089,9 +2081,6 @@ var TrieRouter = class TrieRouter {
2089
2081
  this.cache?.set(cacheKey, matches);
2090
2082
  return matches;
2091
2083
  }
2092
- clone() {
2093
- return new TrieRouter({ cache: this.cache?.clone() });
2094
- }
2095
2084
  /**
2096
2085
  * T1: returns the pre-computed candidate list when the request's
2097
2086
  * static spine has no param sibling, no prefix routes, and no
@@ -2203,7 +2192,7 @@ const DEFAULT_THRESHOLD = 30;
2203
2192
  * buffer; on the first `lookup()` call, picks `LinearRouter` or
2204
2193
  * `TrieRouter` based on the registered route count and replays the
2205
2194
  * pending list onto the chosen inner router. Every subsequent call
2206
- * — `add`, `lookup`, `clone` — forwards to the inner.
2195
+ * — `add`, `lookup` — forwards to the inner.
2207
2196
  *
2208
2197
  * Use this when you don't want to commit to a router family up-front
2209
2198
  * (e.g. a library that registers a variable number of routes
@@ -2215,7 +2204,7 @@ const DEFAULT_THRESHOLD = 30;
2215
2204
  * that matters in routup today: linear-vs-trie at the registration-
2216
2205
  * size crossover.
2217
2206
  */
2218
- var SmartRouter = class SmartRouter {
2207
+ var SmartRouter = class {
2219
2208
  inner;
2220
2209
  pending = [];
2221
2210
  threshold;
@@ -2243,12 +2232,6 @@ var SmartRouter = class SmartRouter {
2243
2232
  }
2244
2233
  return this.inner.lookup(path, method);
2245
2234
  }
2246
- clone() {
2247
- return new SmartRouter({
2248
- threshold: this.threshold,
2249
- cache: this.cache?.clone()
2250
- });
2251
- }
2252
2235
  /**
2253
2236
  * Pick the inner router based on the registered route count.
2254
2237
  * `LinearRouter` for tiny tables, `TrieRouter` past the
@@ -2352,15 +2335,14 @@ var App = class App {
2352
2335
  /**
2353
2336
  * Every route registered on this App, in registration order.
2354
2337
  *
2355
- * Read by `use(otherApp)` to snapshot routes at flatten time
2356
- * and by `clone()` to seed the copy. Late mutations to `_routes`
2357
- * after a flatten do not propagate.
2338
+ * Read by `use(otherApp)` to snapshot routes at flatten time.
2339
+ * Late mutations to `_routes` after a flatten do not propagate.
2358
2340
  */
2359
2341
  _routes = [];
2360
2342
  constructor(input = {}) {
2361
2343
  this.name = input.name;
2362
2344
  this._path = input.path;
2363
- this._plugins = new Map(input.plugins);
2345
+ this._plugins = /* @__PURE__ */ new Map();
2364
2346
  this.router = input.router ?? new LinearRouter();
2365
2347
  this._options = Object.freeze(normalizeAppOptions(input.options ?? {}));
2366
2348
  markInstanceof(this, AppSymbol);
@@ -2384,8 +2366,8 @@ var App = class App {
2384
2366
  }
2385
2367
  /**
2386
2368
  * Register a route with the active router and record it on the
2387
- * App so `clone` / `setRouter` / `use(child)` can read the
2388
- * canonical list back.
2369
+ * App so `setRouter` / `use(child)` can read the canonical list
2370
+ * back.
2389
2371
  *
2390
2372
  * @protected
2391
2373
  */
@@ -2666,29 +2648,8 @@ var App = class App {
2666
2648
  this._plugins.set(plugin.name, plugin.version);
2667
2649
  return this;
2668
2650
  }
2669
- /**
2670
- * Return a new `App` that mirrors this one but owns independent
2671
- * mountable state — fresh router of the same family seeded with
2672
- * the current routes, shallow copy of options, and a fresh
2673
- * plugins map carrying the same entries.
2674
- */
2675
- clone() {
2676
- const next = new App({
2677
- name: this.name,
2678
- path: this._path,
2679
- options: { ...this._options },
2680
- plugins: this._plugins,
2681
- router: this.router.clone()
2682
- });
2683
- for (const route of this._routes) next.register({
2684
- path: route.path,
2685
- method: route.method,
2686
- data: route.data
2687
- });
2688
- return next;
2689
- }
2690
2651
  };
2691
2652
  //#endregion
2692
2653
  export { isError as $, fromWebHandler as A, DispatcherEvent as B, getRequestAcceptableEncodings as C, matchHandlerMethod as D, isRequestCacheable as E, defineErrorHandler as F, getRequestAcceptableContentTypes as G, sendRedirect as H, defineCoreHandler as I, sendFile as J, useRequestNegotiator as K, Handler as L, isWebHandlerProvider as M, fromNodeHandler as N, isHandler as O, fromNodeMiddleware as P, createError as Q, HandlerSymbol as R, getRequestAcceptableEncoding as S, getRequestAcceptableCharsets as T, sendFormat as U, sendStream as V, getRequestAcceptableContentType as W, sendAccepted as X, sendCreated as Y, toResponse as Z, getRequestIP as _, LinearRouter as a, appendResponseHeaderDirective as at, getRequestAcceptableLanguage as b, PluginNotInstalledError as c, AppError as ct, PluginError as d, AppEvent as dt, setResponseHeaderContentType as et, isPluginError as f, HeaderName as ft, getRequestProtocol as g, PathMatcher as h, TrieRouter as i, appendResponseHeader as it, isWebHandler as j, isHandlerOptions as k, PluginInstallError as l, ErrorSymbol as lt, isPath as m, LruCache as mt, normalizeAppOptions as n, setResponseHeaderInline as nt, buildRoutePathMatcher as o, createEventStream as ot, PluginErrorCode as p, MethodName as pt, getRequestHeader as q, SmartRouter as r, setResponseContentTypeByFileName as rt, isPlugin as s, serializeEventStreamMessage as st, App as t, setResponseHeaderAttachment as tt, PluginAlreadyInstalledError as u, setResponseCacheHeaders as ut, getRequestHostName as v, getRequestAcceptableCharset as w, getRequestAcceptableLanguages as x, matchRequestContentType as y, HandlerType as z };
2693
2654
 
2694
- //# sourceMappingURL=src-DaK6SZc0.mjs.map
2655
+ //# sourceMappingURL=src-BfsqxIfL.mjs.map