routup 6.0.0-beta.2 → 6.0.0-beta.3
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/bun.d.mts +2 -2
- package/dist/bun.mjs +2 -2
- package/dist/cloudflare.d.mts +2 -2
- package/dist/cloudflare.mjs +2 -2
- package/dist/deno.d.mts +2 -2
- package/dist/deno.mjs +2 -2
- package/dist/generic.d.mts +2 -2
- package/dist/generic.mjs +2 -2
- package/dist/{index-6qjxyFZh.d.mts → index-BeNEpRff.d.mts} +163 -27
- package/dist/node.d.mts +2 -2
- package/dist/node.mjs +2 -2
- package/dist/service-worker.d.mts +2 -2
- package/dist/service-worker.mjs +2 -2
- package/dist/{src-BfsqxIfL.mjs → src-KLwWuArk.mjs} +139 -34
- package/dist/src-KLwWuArk.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/src-BfsqxIfL.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as AppOptions, $t as
|
|
1
|
+
import { $ as AppOptions, $t as DispatcherEvent, A as sendFormat, At as NodeMiddleware, B as setResponseHeaderAttachment, Bt as HandlerBaseOptions, C as getRequestAcceptableContentTypes, Ct as isWebHandlerProvider, D as setResponseContentTypeByFileName, Dt as fromNodeHandler, E as toResponse, Et as WebHandlerProvider, F as SendFileStats, Ft as HandlerOptions, G as EventStreamHandle, Gt as IPathMatcher, H as appendResponseHeader, Ht as HandlerErrorListener, I as sendFile, It as defineErrorHandler, J as EventStreamListener, Jt as PathMatcherOptions, K as EventStreamOptions, Kt as Path, L as sendCreated, Lt as ErrorHandler, M as SendFileContentOptions, Mt as CoreHandler, N as SendFileDisposition, Nt as CoreHandlerOptions, O as sendStream, Ot as fromNodeMiddleware, P as SendFileOptions, Pt as Handler, Q as AppContext, Qt as HandlerType, R as sendAccepted, Rt as ErrorHandlerOptions, S as getRequestAcceptableContentType, St as isWebHandler, T as isRequestCacheable, Tt as WebHandler, U as appendResponseHeaderDirective, Ut as isPath, V as setResponseHeaderInline, Vt as HandlerBeforeListener, W as serializeEventStreamMessage, Wt as PathMatcher, X as ResponseCacheHeadersOptions, Xt as createError, Y as EventStreamMessage, Yt as isError, Z as setResponseCacheHeaders, Zt as HandlerSymbol, _ as getRequestAcceptableLanguages, _t as PluginError, a as SmartRouter, an as AppResponse, at as Route, b as getRequestAcceptableCharset, bt as isHandler, c as RequestProtocolOptions, cn as HeaderName, ct as LruCacheOptions, d as RequestIpOptions, dn as AppError, dt as Plugin, en as IDispatcher, et as AppOptionsInput, f as getRequestIP, fn as ErrorSymbol, ft as PluginInstallContext, g as getRequestAcceptableLanguage, gt as isPluginError, h as matchRequestContentType, ht as PluginInstallError, i as TrieRouter, in as AppRequest, it as ObjectLiteral, j as SendFileContent, jt as defineCoreHandler, k as sendRedirect, kt as NodeHandler, l as getRequestProtocol, ln as MethodName, lt as ICache, m as getRequestHostName, mt as PluginNotInstalledError, n as App, nn as AppEvent, nt as BaseRouterOptions, o as SmartRouterOptions, on as IAppEvent, ot as RouteMatch, p as RequestHostNameOptions, pn as HTTPErrorInput, pt as PluginInstallFn, q as createEventStream, qt as PathMatcherExecResult, r as buildRoutePathMatcher, rn as AppEventCreateContext, rt as IRouter, s as LinearRouter, sn as NextFn, st as LruCache, t as normalizeAppOptions, tn as IDispatcherEvent, tt as IApp, u as useRequestNegotiator, un as MethodNameLike, ut as isPlugin, v as getRequestAcceptableEncoding, vt as PluginErrorCode, w as getRequestHeader, wt as fromWebHandler, x as getRequestAcceptableCharsets, xt as isHandlerOptions, y as getRequestAcceptableEncodings, yt as matchHandlerMethod, z as setResponseHeaderContentType, zt as HandlerAfterListener } from "./index-BeNEpRff.mjs";
|
|
2
2
|
import * as _$srvx from "srvx";
|
|
3
3
|
import { ServerOptions } from "srvx";
|
|
4
4
|
import * as _$srvx_service_worker0 from "srvx/service-worker";
|
|
@@ -6,5 +6,5 @@ import * as _$srvx_service_worker0 from "srvx/service-worker";
|
|
|
6
6
|
//#region src/_entries/service-worker.d.ts
|
|
7
7
|
declare function serve(app: IApp, options?: Omit<ServerOptions, 'fetch'>): _$srvx.Server<_$srvx_service_worker0.ServiceWorkerHandler>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { App, AppContext, AppError, AppEvent, AppEventCreateContext, AppOptions, AppOptionsInput, AppRequest, AppResponse, BaseRouterOptions, CoreHandler, CoreHandlerOptions, DispatcherEvent, ErrorHandler, ErrorHandlerOptions, ErrorSymbol, EventStreamHandle, EventStreamListener, EventStreamMessage, EventStreamOptions, HTTPErrorInput, Handler, HandlerAfterListener, HandlerBaseOptions, HandlerBeforeListener, HandlerErrorListener, HandlerOptions, HandlerSymbol, HandlerType, HeaderName, IApp, IAppEvent, ICache, IDispatcher, IDispatcherEvent, IPathMatcher, IRouter, LinearRouter, LruCache, LruCacheOptions, MethodName, MethodNameLike, NextFn, NodeHandler, NodeMiddleware, ObjectLiteral, Path, PathMatcher, PathMatcherExecResult, PathMatcherOptions, Plugin,
|
|
9
|
+
export { App, AppContext, AppError, AppEvent, AppEventCreateContext, AppOptions, AppOptionsInput, AppRequest, AppResponse, BaseRouterOptions, CoreHandler, CoreHandlerOptions, DispatcherEvent, ErrorHandler, ErrorHandlerOptions, ErrorSymbol, EventStreamHandle, EventStreamListener, EventStreamMessage, EventStreamOptions, HTTPErrorInput, Handler, HandlerAfterListener, HandlerBaseOptions, HandlerBeforeListener, HandlerErrorListener, HandlerOptions, HandlerSymbol, HandlerType, HeaderName, IApp, IAppEvent, ICache, IDispatcher, IDispatcherEvent, IPathMatcher, IRouter, LinearRouter, LruCache, LruCacheOptions, MethodName, MethodNameLike, NextFn, NodeHandler, NodeMiddleware, ObjectLiteral, Path, PathMatcher, PathMatcherExecResult, PathMatcherOptions, Plugin, PluginError, PluginErrorCode, PluginInstallContext, PluginInstallError, PluginInstallFn, PluginNotInstalledError, RequestHostNameOptions, RequestIpOptions, RequestProtocolOptions, ResponseCacheHeadersOptions, Route, RouteMatch, SendFileContent, SendFileContentOptions, SendFileDisposition, SendFileOptions, SendFileStats, SmartRouter, SmartRouterOptions, TrieRouter, WebHandler, WebHandlerProvider, appendResponseHeader, appendResponseHeaderDirective, buildRoutePathMatcher, createError, createEventStream, defineCoreHandler, defineErrorHandler, fromNodeHandler, fromNodeMiddleware, fromWebHandler, getRequestAcceptableCharset, getRequestAcceptableCharsets, getRequestAcceptableContentType, getRequestAcceptableContentTypes, getRequestAcceptableEncoding, getRequestAcceptableEncodings, getRequestAcceptableLanguage, getRequestAcceptableLanguages, getRequestHeader, getRequestHostName, getRequestIP, getRequestProtocol, isError, isHandler, isHandlerOptions, isPath, isPlugin, isPluginError, isRequestCacheable, isWebHandler, isWebHandlerProvider, matchHandlerMethod, matchRequestContentType, normalizeAppOptions, sendAccepted, sendCreated, sendFile, sendFormat, sendRedirect, sendStream, serializeEventStreamMessage, serve, setResponseCacheHeaders, setResponseContentTypeByFileName, setResponseHeaderAttachment, setResponseHeaderContentType, setResponseHeaderInline, toResponse, useRequestNegotiator };
|
|
10
10
|
//# sourceMappingURL=service-worker.d.mts.map
|
package/dist/service-worker.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as setResponseHeaderContentType, A as isWebHandler, B as sendStream, C as getRequestAcceptableCharset, D as isHandler, E as matchHandlerMethod, F as defineCoreHandler, G as useRequestNegotiator, H as sendFormat, I as Handler, J as sendCreated, K as getRequestHeader, L as HandlerSymbol, M as fromNodeHandler, N as fromNodeMiddleware, O as isHandlerOptions, P as defineErrorHandler, Q as isError, R as HandlerType, S as getRequestAcceptableEncodings, T as isRequestCacheable, U as getRequestAcceptableContentType, V as sendRedirect, W as getRequestAcceptableContentTypes, X as toResponse, Y as sendAccepted, Z as createError, _ as getRequestHostName, a as LinearRouter, at as createEventStream, b as getRequestAcceptableLanguages, c as PluginNotInstalledError, ct as ErrorSymbol, d as isPluginError, dt as HeaderName, et as setResponseHeaderAttachment, f as PluginErrorCode, ft as MethodName, g as getRequestIP, h as getRequestProtocol, i as TrieRouter, it as appendResponseHeaderDirective, j as isWebHandlerProvider, k as fromWebHandler, l as PluginInstallError, lt as setResponseCacheHeaders, m as PathMatcher, n as normalizeAppOptions, nt as setResponseContentTypeByFileName, o as buildRoutePathMatcher, ot as serializeEventStreamMessage, p as isPath, pt as LruCache, q as sendFile, r as SmartRouter, rt as appendResponseHeader, s as isPlugin, st as AppError, t as App, tt as setResponseHeaderInline, u as PluginError, ut as AppEvent, v as matchRequestContentType, w as getRequestAcceptableCharsets, x as getRequestAcceptableEncoding, y as getRequestAcceptableLanguage, z as DispatcherEvent } from "./src-KLwWuArk.mjs";
|
|
2
2
|
import { serve as serve$1 } from "srvx/service-worker";
|
|
3
3
|
//#region src/_entries/service-worker.ts
|
|
4
4
|
function serve(app, options) {
|
|
@@ -8,6 +8,6 @@ function serve(app, options) {
|
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
11
|
-
export { App, AppError, AppEvent, DispatcherEvent, ErrorSymbol, Handler, HandlerSymbol, HandlerType, HeaderName, LinearRouter, LruCache, MethodName, PathMatcher,
|
|
11
|
+
export { App, AppError, AppEvent, DispatcherEvent, ErrorSymbol, Handler, HandlerSymbol, HandlerType, HeaderName, LinearRouter, LruCache, MethodName, PathMatcher, PluginError, PluginErrorCode, PluginInstallError, PluginNotInstalledError, SmartRouter, TrieRouter, appendResponseHeader, appendResponseHeaderDirective, buildRoutePathMatcher, createError, createEventStream, defineCoreHandler, defineErrorHandler, fromNodeHandler, fromNodeMiddleware, fromWebHandler, getRequestAcceptableCharset, getRequestAcceptableCharsets, getRequestAcceptableContentType, getRequestAcceptableContentTypes, getRequestAcceptableEncoding, getRequestAcceptableEncodings, getRequestAcceptableLanguage, getRequestAcceptableLanguages, getRequestHeader, getRequestHostName, getRequestIP, getRequestProtocol, isError, isHandler, isHandlerOptions, isPath, isPlugin, isPluginError, isRequestCacheable, isWebHandler, isWebHandlerProvider, matchHandlerMethod, matchRequestContentType, normalizeAppOptions, sendAccepted, sendCreated, sendFile, sendFormat, sendRedirect, sendStream, serializeEventStreamMessage, serve, setResponseCacheHeaders, setResponseContentTypeByFileName, setResponseHeaderAttachment, setResponseHeaderContentType, setResponseHeaderInline, toResponse, useRequestNegotiator };
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=service-worker.mjs.map
|
|
@@ -1421,7 +1421,6 @@ function isPath(input) {
|
|
|
1421
1421
|
const PluginErrorCode = {
|
|
1422
1422
|
PLUGIN: "PLUGIN",
|
|
1423
1423
|
NOT_INSTALLED: "PLUGIN_NOT_INSTALLED",
|
|
1424
|
-
ALREADY_INSTALLED: "PLUGIN_ALREADY_INSTALLED",
|
|
1425
1424
|
INSTALL: "PLUGIN_INSTALL"
|
|
1426
1425
|
};
|
|
1427
1426
|
//#endregion
|
|
@@ -1442,19 +1441,6 @@ var PluginError = class extends AppError {
|
|
|
1442
1441
|
}
|
|
1443
1442
|
};
|
|
1444
1443
|
//#endregion
|
|
1445
|
-
//#region src/plugin/error/sub/already-installed.ts
|
|
1446
|
-
var PluginAlreadyInstalledError = class extends PluginError {
|
|
1447
|
-
pluginName;
|
|
1448
|
-
constructor(pluginName) {
|
|
1449
|
-
super({
|
|
1450
|
-
message: `Plugin "${pluginName}" is already installed on this router.`,
|
|
1451
|
-
code: PluginErrorCode.ALREADY_INSTALLED
|
|
1452
|
-
});
|
|
1453
|
-
this.name = "PluginAlreadyInstalledError";
|
|
1454
|
-
this.pluginName = pluginName;
|
|
1455
|
-
}
|
|
1456
|
-
};
|
|
1457
|
-
//#endregion
|
|
1458
1444
|
//#region src/plugin/error/sub/install.ts
|
|
1459
1445
|
var PluginInstallError = class extends PluginError {
|
|
1460
1446
|
pluginName;
|
|
@@ -2269,8 +2255,26 @@ function normalizeAppOptions(input) {
|
|
|
2269
2255
|
const AppSymbol = Symbol.for("App");
|
|
2270
2256
|
//#endregion
|
|
2271
2257
|
//#region src/app/check.ts
|
|
2258
|
+
/**
|
|
2259
|
+
* Discriminate an `IApp` argument from handlers, plugins, and other
|
|
2260
|
+
* inputs `App.use()` accepts. Two-stage check:
|
|
2261
|
+
*
|
|
2262
|
+
* 1. Fast path: brand check (`hasInstanceof` against `AppSymbol`).
|
|
2263
|
+
* Hits for every instance of the bundled `App` class and any
|
|
2264
|
+
* subclass that calls `markInstanceof(this, AppSymbol)` — that's
|
|
2265
|
+
* the common case, so we want it to be a single property lookup
|
|
2266
|
+
* with no key-by-key probing.
|
|
2267
|
+
*
|
|
2268
|
+
* 2. Fallback: structural check for the `IApp` surface `flatten()`
|
|
2269
|
+
* reads at mount time (`fetch`, `routes`, `plugins`,
|
|
2270
|
+
* `pluginSingletons`). Lets any object implementing the `IApp`
|
|
2271
|
+
* contract — not just instances of the bundled `App` class — be
|
|
2272
|
+
* mounted via `app.use(child)`.
|
|
2273
|
+
*/
|
|
2272
2274
|
function isAppInstance(input) {
|
|
2273
|
-
|
|
2275
|
+
if (hasInstanceof(input, AppSymbol)) return true;
|
|
2276
|
+
if (!isObject(input)) return false;
|
|
2277
|
+
return typeof input.fetch === "function" && Array.isArray(input.routes) && isObject(input.plugins) && isObject(input.pluginSingletons);
|
|
2274
2278
|
}
|
|
2275
2279
|
//#endregion
|
|
2276
2280
|
//#region src/app/module.ts
|
|
@@ -2322,17 +2326,35 @@ var App = class App {
|
|
|
2322
2326
|
*/
|
|
2323
2327
|
_options;
|
|
2324
2328
|
/**
|
|
2325
|
-
* Registry of installed plugins
|
|
2329
|
+
* Registry of installed plugins on this App, keyed by plugin name
|
|
2330
|
+
* then by canonical mount key (the joined `this._path` +
|
|
2331
|
+
* install-time `path`, falling back to `'/'` for a root install).
|
|
2332
|
+
* Inner-map value is the plugin version (or `undefined`).
|
|
2326
2333
|
*
|
|
2327
|
-
*
|
|
2328
|
-
*
|
|
2329
|
-
* `
|
|
2330
|
-
*
|
|
2334
|
+
* Per-path keying lets `hasPluginAt` answer "is plugin X mounted at
|
|
2335
|
+
* /api?" precisely. By default `install()` is permissive and
|
|
2336
|
+
* appends — same `(name, key)` writes the latest version. Plugins
|
|
2337
|
+
* opt into deduplication via `singleton` (any-path) or
|
|
2338
|
+
* `singletonByPath` (same-path) flags.
|
|
2339
|
+
*
|
|
2340
|
+
* Read by `flatten()` when merging a child's registry into this
|
|
2341
|
+
* one, so `parent.hasPlugin('foo')` reflects plugins installed on
|
|
2342
|
+
* mounted children too.
|
|
2331
2343
|
*
|
|
2332
2344
|
* @protected
|
|
2333
2345
|
*/
|
|
2334
2346
|
_plugins;
|
|
2335
2347
|
/**
|
|
2348
|
+
* Names of plugins installed with `singleton: true`. Re-installing
|
|
2349
|
+
* any of these names — even at a different mount path — is a
|
|
2350
|
+
* silent no-op. The claim is sticky: once a name is in here, it
|
|
2351
|
+
* stays for the lifetime of the App. Propagated through
|
|
2352
|
+
* `flatten()` so a child's singleton claim survives the mount.
|
|
2353
|
+
*
|
|
2354
|
+
* @protected
|
|
2355
|
+
*/
|
|
2356
|
+
_pluginSingletons;
|
|
2357
|
+
/**
|
|
2336
2358
|
* Every route registered on this App, in registration order.
|
|
2337
2359
|
*
|
|
2338
2360
|
* Read by `use(otherApp)` to snapshot routes at flatten time.
|
|
@@ -2343,6 +2365,7 @@ var App = class App {
|
|
|
2343
2365
|
this.name = input.name;
|
|
2344
2366
|
this._path = input.path;
|
|
2345
2367
|
this._plugins = /* @__PURE__ */ new Map();
|
|
2368
|
+
this._pluginSingletons = /* @__PURE__ */ new Set();
|
|
2346
2369
|
this.router = input.router ?? new LinearRouter();
|
|
2347
2370
|
this._options = Object.freeze(normalizeAppOptions(input.options ?? {}));
|
|
2348
2371
|
markInstanceof(this, AppSymbol);
|
|
@@ -2356,15 +2379,31 @@ var App = class App {
|
|
|
2356
2379
|
return this._routes;
|
|
2357
2380
|
}
|
|
2358
2381
|
/**
|
|
2359
|
-
* Public read of the installed-plugin registry. Used by
|
|
2360
|
-
*
|
|
2361
|
-
*
|
|
2362
|
-
*
|
|
2382
|
+
* Public read of the installed-plugin registry. Used by `flatten()`
|
|
2383
|
+
* to merge a child's plugins into this App without reaching into
|
|
2384
|
+
* the child's protected fields.
|
|
2385
|
+
*
|
|
2386
|
+
* Outer key: plugin name. Inner key: canonical mount path (`'/'`
|
|
2387
|
+
* for root mounts). Inner value: installed version (or `undefined`).
|
|
2388
|
+
*
|
|
2389
|
+
* Returned as nested `ReadonlyMap` — callers must not mutate; go
|
|
2390
|
+
* through `app.use(plugin)` to install.
|
|
2363
2391
|
*/
|
|
2364
2392
|
get plugins() {
|
|
2365
2393
|
return this._plugins;
|
|
2366
2394
|
}
|
|
2367
2395
|
/**
|
|
2396
|
+
* Public read of the sticky singleton-claim set. Once a plugin
|
|
2397
|
+
* name is claimed singleton on an App, every subsequent install
|
|
2398
|
+
* of that name is a silent no-op. Used by `flatten()` to
|
|
2399
|
+
* propagate child claims forward at mount time.
|
|
2400
|
+
*
|
|
2401
|
+
* Returned as `ReadonlySet` — callers must not mutate.
|
|
2402
|
+
*/
|
|
2403
|
+
get pluginSingletons() {
|
|
2404
|
+
return this._pluginSingletons;
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2368
2407
|
* Register a route with the active router and record it on the
|
|
2369
2408
|
* App so `setRouter` / `use(child)` can read the canonical list
|
|
2370
2409
|
* back.
|
|
@@ -2618,38 +2657,104 @@ var App = class App {
|
|
|
2618
2657
|
* @protected
|
|
2619
2658
|
*/
|
|
2620
2659
|
flatten(child, path) {
|
|
2621
|
-
for (const name of child.plugins.keys()) if (this._plugins.has(name)) throw new PluginAlreadyInstalledError(name);
|
|
2622
|
-
for (const [name, version] of child.plugins) this._plugins.set(name, version);
|
|
2623
2660
|
for (const route of child.routes) this.register({
|
|
2624
2661
|
path: joinPaths(this._path, path, route.path),
|
|
2625
2662
|
method: route.method,
|
|
2626
2663
|
data: route.data
|
|
2627
2664
|
});
|
|
2665
|
+
const namesBeforeMerge = new Set(this._plugins.keys());
|
|
2666
|
+
for (const [name, childPaths] of child.plugins) {
|
|
2667
|
+
if (this._pluginSingletons.has(name)) continue;
|
|
2668
|
+
let entry = this._plugins.get(name);
|
|
2669
|
+
for (const [childKey, version] of childPaths) {
|
|
2670
|
+
const composedKey = joinPaths(this._path, path, childKey) ?? "/";
|
|
2671
|
+
if (entry && entry.has(composedKey)) continue;
|
|
2672
|
+
if (!entry) {
|
|
2673
|
+
entry = /* @__PURE__ */ new Map();
|
|
2674
|
+
this._plugins.set(name, entry);
|
|
2675
|
+
}
|
|
2676
|
+
entry.set(composedKey, version);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
for (const name of child.pluginSingletons) if (!namesBeforeMerge.has(name)) this._pluginSingletons.add(name);
|
|
2628
2680
|
}
|
|
2629
2681
|
/**
|
|
2630
|
-
* Check if a plugin with the given name is installed on this App
|
|
2682
|
+
* Check if a plugin with the given name is installed on this App at
|
|
2683
|
+
* *any* mount path.
|
|
2631
2684
|
*/
|
|
2632
2685
|
hasPlugin(name) {
|
|
2633
|
-
|
|
2686
|
+
const entry = this._plugins.get(name);
|
|
2687
|
+
return !!entry && entry.size > 0;
|
|
2688
|
+
}
|
|
2689
|
+
/**
|
|
2690
|
+
* Check if a plugin with the given name is installed at the given
|
|
2691
|
+
* install-time `path`. `path` is interpreted the same way as the
|
|
2692
|
+
* argument to `app.use(path, plugin)` — relative to this App. Omit
|
|
2693
|
+
* `path` to check the root install.
|
|
2694
|
+
*/
|
|
2695
|
+
hasPluginAt(name, path) {
|
|
2696
|
+
const entry = this._plugins.get(name);
|
|
2697
|
+
if (!entry) return false;
|
|
2698
|
+
const key = joinPaths(this._path, path) ?? "/";
|
|
2699
|
+
return entry.has(key);
|
|
2634
2700
|
}
|
|
2635
2701
|
/**
|
|
2636
2702
|
* Get the version of an installed plugin by name, or `undefined`
|
|
2637
|
-
*
|
|
2703
|
+
* when the plugin is not installed. When the plugin is mounted at
|
|
2704
|
+
* several paths, returns the version of an arbitrary mount —
|
|
2705
|
+
* typical usage installs the same plugin object at every mount, so
|
|
2706
|
+
* the version is identical. Use `getPluginVersionAt` to read the
|
|
2707
|
+
* version of a specific mount.
|
|
2638
2708
|
*/
|
|
2639
2709
|
getPluginVersion(name) {
|
|
2640
|
-
|
|
2710
|
+
const entry = this._plugins.get(name);
|
|
2711
|
+
if (!entry) return;
|
|
2712
|
+
const first = entry.values().next();
|
|
2713
|
+
return first.done ? void 0 : first.value;
|
|
2714
|
+
}
|
|
2715
|
+
/**
|
|
2716
|
+
* Get the version of a plugin installed at the given install-time
|
|
2717
|
+
* `path`, or `undefined` when no install matches. `path` is
|
|
2718
|
+
* interpreted relative to this App (same convention as
|
|
2719
|
+
* `app.use(path, plugin)`); omit it to read the root install.
|
|
2720
|
+
*/
|
|
2721
|
+
getPluginVersionAt(name, path) {
|
|
2722
|
+
const entry = this._plugins.get(name);
|
|
2723
|
+
if (!entry) return;
|
|
2724
|
+
return entry.get(joinPaths(this._path, path) ?? "/");
|
|
2725
|
+
}
|
|
2726
|
+
/**
|
|
2727
|
+
* List every canonical mount path the named plugin is installed
|
|
2728
|
+
* at. Returns an empty array when the plugin is not installed.
|
|
2729
|
+
* Each path is the joined `app._path` + install-time path,
|
|
2730
|
+
* normalized to `'/'` for root mounts.
|
|
2731
|
+
*/
|
|
2732
|
+
getPluginMountPaths(name) {
|
|
2733
|
+
const entry = this._plugins.get(name);
|
|
2734
|
+
if (!entry) return [];
|
|
2735
|
+
return Array.from(entry.keys());
|
|
2641
2736
|
}
|
|
2642
2737
|
install(plugin, context = {}) {
|
|
2643
|
-
|
|
2738
|
+
const mountKey = joinPaths(this._path, context.path) ?? "/";
|
|
2739
|
+
const existing = this._plugins.get(plugin.name);
|
|
2740
|
+
if (this._pluginSingletons.has(plugin.name)) return this;
|
|
2741
|
+
if (plugin.singleton && existing && existing.size > 0) return this;
|
|
2742
|
+
if (plugin.singletonByPath && existing && existing.has(mountKey)) return this;
|
|
2644
2743
|
const scratch = new App({ name: plugin.name });
|
|
2645
2744
|
plugin.install(scratch);
|
|
2646
2745
|
if (context.path) this.use(context.path, scratch);
|
|
2647
2746
|
else this.use(scratch);
|
|
2648
|
-
this._plugins.
|
|
2747
|
+
let entry = this._plugins.get(plugin.name);
|
|
2748
|
+
if (!entry) {
|
|
2749
|
+
entry = /* @__PURE__ */ new Map();
|
|
2750
|
+
this._plugins.set(plugin.name, entry);
|
|
2751
|
+
}
|
|
2752
|
+
entry.set(mountKey, plugin.version);
|
|
2753
|
+
if (plugin.singleton) this._pluginSingletons.add(plugin.name);
|
|
2649
2754
|
return this;
|
|
2650
2755
|
}
|
|
2651
2756
|
};
|
|
2652
2757
|
//#endregion
|
|
2653
|
-
export {
|
|
2758
|
+
export { setResponseHeaderContentType as $, isWebHandler as A, sendStream as B, getRequestAcceptableCharset as C, isHandler as D, matchHandlerMethod as E, defineCoreHandler as F, useRequestNegotiator as G, sendFormat as H, Handler as I, sendCreated as J, getRequestHeader as K, HandlerSymbol as L, fromNodeHandler as M, fromNodeMiddleware as N, isHandlerOptions as O, defineErrorHandler as P, isError as Q, HandlerType as R, getRequestAcceptableEncodings as S, isRequestCacheable as T, getRequestAcceptableContentType as U, sendRedirect as V, getRequestAcceptableContentTypes as W, toResponse as X, sendAccepted as Y, createError as Z, getRequestHostName as _, LinearRouter as a, createEventStream as at, getRequestAcceptableLanguages as b, PluginNotInstalledError as c, ErrorSymbol as ct, isPluginError as d, HeaderName as dt, setResponseHeaderAttachment as et, PluginErrorCode as f, MethodName as ft, getRequestIP as g, getRequestProtocol as h, TrieRouter as i, appendResponseHeaderDirective as it, isWebHandlerProvider as j, fromWebHandler as k, PluginInstallError as l, setResponseCacheHeaders as lt, PathMatcher as m, normalizeAppOptions as n, setResponseContentTypeByFileName as nt, buildRoutePathMatcher as o, serializeEventStreamMessage as ot, isPath as p, LruCache as pt, sendFile as q, SmartRouter as r, appendResponseHeader as rt, isPlugin as s, AppError as st, App as t, setResponseHeaderInline as tt, PluginError as u, AppEvent as ut, matchRequestContentType as v, getRequestAcceptableCharsets as w, getRequestAcceptableEncoding as x, getRequestAcceptableLanguage as y, DispatcherEvent as z };
|
|
2654
2759
|
|
|
2655
|
-
//# sourceMappingURL=src-
|
|
2760
|
+
//# sourceMappingURL=src-KLwWuArk.mjs.map
|