@serwist/routing
Advanced tools
Comparing version 8.4.4 to 9.0.0-preview.0
@@ -48,1 +48,2 @@ export {}; | ||
*/ | ||
//# sourceMappingURL=_types.d.ts.map |
@@ -9,4 +9,6 @@ import type { NavigationRouteMatchOptions } from "./NavigationRoute.js"; | ||
import { setDefaultHandler } from "./setDefaultHandler.js"; | ||
import { unregisterRoute } from "./unregisterRoute.js"; | ||
import type { HTTPMethod } from "./utils/constants.js"; | ||
export { NavigationRoute, RegExpRoute, registerRoute, Route, Router, setCatchHandler, setDefaultHandler }; | ||
export { NavigationRoute, RegExpRoute, registerRoute, Route, Router, setCatchHandler, setDefaultHandler, unregisterRoute }; | ||
export type { HTTPMethod, NavigationRouteMatchOptions }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -13,4 +13,2 @@ import { assert, logger, getFriendlyURL, SerwistError } from '@serwist/core/internal'; | ||
* | ||
* @type {string} | ||
* | ||
* @private | ||
@@ -21,4 +19,2 @@ */ const defaultMethod = "GET"; | ||
* | ||
* @type {Array<string>} | ||
* | ||
* @private | ||
@@ -332,6 +328,3 @@ */ const validMethods = [ | ||
}); | ||
// TODO(philipwalton): TypeScript errors without this typecast for | ||
// some reason (probably a bug). The real type here should work but | ||
// doesn't: `Array<Promise<Response> | undefined>`. | ||
})); // TypeScript | ||
})); | ||
event.waitUntil(requestPromises); | ||
@@ -641,3 +634,3 @@ // If a MessageChannel was used, reply to the message on success. | ||
/** | ||
* Easily register a RegExp, string, or function with a caching | ||
* Registers a RegExp, string, or function with a caching | ||
* strategy to a singleton Router instance. | ||
@@ -650,3 +643,3 @@ * | ||
* @returns The generated `Route`. | ||
*/ function registerRoute(capture, handler, method) { | ||
*/ const registerRoute = (capture, handler, method)=>{ | ||
let route; | ||
@@ -700,3 +693,3 @@ if (typeof capture === "string") { | ||
return route; | ||
} | ||
}; | ||
@@ -708,9 +701,9 @@ /** | ||
* @param handler A callback function that returns a Promise resulting in a Response. | ||
*/ function setCatchHandler(handler) { | ||
*/ const setCatchHandler = (handler)=>{ | ||
const defaultRouter = getOrCreateDefaultRouter(); | ||
defaultRouter.setCatchHandler(handler); | ||
} | ||
}; | ||
/** | ||
* Define a default `handler` that's called when no routes explicitly | ||
* Defines a default `handler` that's called when no routes explicitly | ||
* match the incoming request. | ||
@@ -722,7 +715,16 @@ * | ||
* @param handler A callback function that returns a Promise resulting in a Response. | ||
*/ function setDefaultHandler(handler) { | ||
*/ const setDefaultHandler = (handler)=>{ | ||
const defaultRouter = getOrCreateDefaultRouter(); | ||
defaultRouter.setDefaultHandler(handler); | ||
} | ||
}; | ||
export { NavigationRoute, RegExpRoute, Route, Router, registerRoute, setCatchHandler, setDefaultHandler }; | ||
/** | ||
* Unregisters a route from the singleton Router instance. | ||
* | ||
* @param route The route to unregister. | ||
*/ const unregisterRoute = (route)=>{ | ||
const defaultRouter = getOrCreateDefaultRouter(); | ||
defaultRouter.unregisterRoute(route); | ||
}; | ||
export { NavigationRoute, RegExpRoute, Route, Router, registerRoute, setCatchHandler, setDefaultHandler, unregisterRoute }; |
@@ -26,3 +26,3 @@ import type { RouteHandler } from "@serwist/core"; | ||
*/ | ||
declare class NavigationRoute extends Route { | ||
export declare class NavigationRoute extends Route { | ||
private readonly _allowlist; | ||
@@ -58,2 +58,2 @@ private readonly _denylist; | ||
} | ||
export { NavigationRoute }; | ||
//# sourceMappingURL=NavigationRoute.d.ts.map |
@@ -11,3 +11,3 @@ import type { RouteHandler } from "@serwist/core"; | ||
*/ | ||
declare class RegExpRoute extends Route { | ||
export declare class RegExpRoute extends Route { | ||
/** | ||
@@ -25,2 +25,2 @@ * If the regular expression contains | ||
} | ||
export { RegExpRoute }; | ||
//# sourceMappingURL=RegExpRoute.d.ts.map |
@@ -5,3 +5,3 @@ import type { RouteHandler, RouteMatchCallback } from "@serwist/core"; | ||
/** | ||
* Easily register a RegExp, string, or function with a caching | ||
* Registers a RegExp, string, or function with a caching | ||
* strategy to a singleton Router instance. | ||
@@ -15,3 +15,3 @@ * | ||
*/ | ||
declare function registerRoute(capture: RegExp | string | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod): Route; | ||
export { registerRoute }; | ||
export declare const registerRoute: (capture: RegExp | string | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod) => Route; | ||
//# sourceMappingURL=registerRoute.d.ts.map |
@@ -10,3 +10,3 @@ import type { RouteHandler, RouteHandlerObject, RouteMatchCallback } from "@serwist/core"; | ||
*/ | ||
declare class Route { | ||
export declare class Route { | ||
handler: RouteHandlerObject; | ||
@@ -34,2 +34,2 @@ match: RouteMatchCallback; | ||
} | ||
export { Route }; | ||
//# sourceMappingURL=Route.d.ts.map |
@@ -16,3 +16,3 @@ import type { RouteHandler, RouteHandlerCallbackOptions, RouteMatchCallbackOptions } from "@serwist/core"; | ||
*/ | ||
declare class Router { | ||
export declare class Router { | ||
private readonly _routes; | ||
@@ -125,2 +125,2 @@ private readonly _defaultHandlerMap; | ||
} | ||
export { Router }; | ||
//# sourceMappingURL=Router.d.ts.map |
@@ -8,3 +8,3 @@ import type { RouteHandler } from "@serwist/core"; | ||
*/ | ||
declare function setCatchHandler(handler: RouteHandler): void; | ||
export { setCatchHandler }; | ||
export declare const setCatchHandler: (handler: RouteHandler) => void; | ||
//# sourceMappingURL=setCatchHandler.d.ts.map |
import type { RouteHandler } from "@serwist/core"; | ||
/** | ||
* Define a default `handler` that's called when no routes explicitly | ||
* Defines a default `handler` that's called when no routes explicitly | ||
* match the incoming request. | ||
@@ -11,3 +11,3 @@ * | ||
*/ | ||
declare function setDefaultHandler(handler: RouteHandler): void; | ||
export { setDefaultHandler }; | ||
export declare const setDefaultHandler: (handler: RouteHandler) => void; | ||
//# sourceMappingURL=setDefaultHandler.d.ts.map |
@@ -6,14 +6,11 @@ export type HTTPMethod = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT"; | ||
* | ||
* @type {string} | ||
* | ||
* @private | ||
*/ | ||
export declare const defaultMethod: HTTPMethod; | ||
export declare const defaultMethod = "GET"; | ||
/** | ||
* The list of valid HTTP methods associated with requests that could be routed. | ||
* | ||
* @type {Array<string>} | ||
* | ||
* @private | ||
*/ | ||
export declare const validMethods: HTTPMethod[]; | ||
export declare const validMethods: ("DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT")[]; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -10,1 +10,2 @@ import { Router } from "../Router.js"; | ||
export declare const getOrCreateDefaultRouter: () => Router; | ||
//# sourceMappingURL=getOrCreateDefaultRouter.d.ts.map |
@@ -10,1 +10,2 @@ import type { RouteHandler, RouteHandlerObject } from "@serwist/core"; | ||
export declare const normalizeHandler: (handler: RouteHandler) => RouteHandlerObject; | ||
//# sourceMappingURL=normalizeHandler.d.ts.map |
{ | ||
"name": "@serwist/routing", | ||
"version": "8.4.4", | ||
"version": "9.0.0-preview.0", | ||
"type": "module", | ||
"description": "A service worker helper library to route request URLs to handlers.", | ||
"files": [ | ||
"dist", | ||
"!dist/**/dts" | ||
"src", | ||
"dist" | ||
], | ||
@@ -23,15 +23,8 @@ "keywords": [ | ||
"homepage": "https://serwist.pages.dev", | ||
"module": "./dist/index.js", | ||
"main": "./dist/index.cjs", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
@@ -41,8 +34,17 @@ "./package.json": "./package.json" | ||
"dependencies": { | ||
"@serwist/core": "8.4.4" | ||
"@serwist/core": "9.0.0-preview.0" | ||
}, | ||
"devDependencies": { | ||
"rollup": "4.9.1", | ||
"@serwist/constants": "8.4.4" | ||
"rollup": "4.9.6", | ||
"typescript": "5.4.0-dev.20240203", | ||
"@serwist/constants": "9.0.0-preview.0" | ||
}, | ||
"peerDependencies": { | ||
"typescript": ">=5.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"typescript": { | ||
"optional": true | ||
} | ||
}, | ||
"scripts": { | ||
@@ -49,0 +51,0 @@ "build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 4 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
87611
43
1977
23
2
3
5
1
+ Added@serwist/core@9.0.0-preview.0(transitive)
+ Addedtypescript@5.7.2(transitive)
- Removed@serwist/core@8.4.4(transitive)