@serwist/routing 9.0.0-preview.1 → 9.0.0-preview.11
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/Router.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Router.ts +6 -10
package/dist/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../src/Router.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAsB,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG9H,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../src/Router.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAsB,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG9H,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAevD;;;;;;;;;;;GAWG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAsC;IACzE,OAAO,CAAC,aAAa,CAAC,CAAqB;IAE3C;;OAEG;;IAMH;;;OAGG;IACH,IAAI,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAErC;IAED;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAUxB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,gBAAgB,IAAI,IAAI;IA8BxB;;;;;;;;OAQG;IACH,aAAa,CAAC,EACZ,OAAO,EACP,KAAK,GACN,EAAE;QACD;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;WAEG;QACH,KAAK,EAAE,eAAe,CAAC;KACxB,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS;IA8HjC;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,yBAAyB,GAAG;QACjF,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,MAAM,CAAC,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;KAChD;IA+CD;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,GAAE,UAA0B,GAAG,IAAI;IAIlF;;;;;;OAMG;IACH,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAI5C;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IA+CjC;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAcpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/routing",
|
|
3
|
-
"version": "9.0.0-preview.
|
|
3
|
+
"version": "9.0.0-preview.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A service worker helper library to route request URLs to handlers.",
|
|
6
6
|
"files": [
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"./package.json": "./package.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@serwist/core": "9.0.0-preview.
|
|
33
|
+
"@serwist/core": "9.0.0-preview.11"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"rollup": "4.9.6",
|
|
37
|
-
"typescript": "5.4.0-dev.
|
|
38
|
-
"@serwist/constants": "9.0.0-preview.
|
|
37
|
+
"typescript": "5.4.0-dev.20240206",
|
|
38
|
+
"@serwist/constants": "9.0.0-preview.11"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"typescript": ">=5.0.0"
|
package/src/Router.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type { HTTPMethod } from "./utils/constants.js";
|
|
|
14
14
|
import { defaultMethod } from "./utils/constants.js";
|
|
15
15
|
import { normalizeHandler } from "./utils/normalizeHandler.js";
|
|
16
16
|
|
|
17
|
+
declare const self: ServiceWorkerGlobalScope;
|
|
18
|
+
|
|
17
19
|
type RequestArgs = string | [string, RequestInit?];
|
|
18
20
|
|
|
19
21
|
interface CacheURLsMessageData {
|
|
@@ -61,14 +63,13 @@ export class Router {
|
|
|
61
63
|
* the event's request.
|
|
62
64
|
*/
|
|
63
65
|
addFetchListener(): void {
|
|
64
|
-
|
|
65
|
-
self.addEventListener("fetch", ((event: FetchEvent) => {
|
|
66
|
+
self.addEventListener("fetch", (event) => {
|
|
66
67
|
const { request } = event;
|
|
67
68
|
const responsePromise = this.handleRequest({ request, event });
|
|
68
69
|
if (responsePromise) {
|
|
69
70
|
event.respondWith(responsePromise);
|
|
70
71
|
}
|
|
71
|
-
})
|
|
72
|
+
});
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
/**
|
|
@@ -94,12 +95,8 @@ export class Router {
|
|
|
94
95
|
* ```
|
|
95
96
|
*/
|
|
96
97
|
addCacheListener(): void {
|
|
97
|
-
|
|
98
|
-
self.addEventListener("message", ((event: ExtendableMessageEvent) => {
|
|
99
|
-
// event.data is type 'any'
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
98
|
+
self.addEventListener("message", (event) => {
|
|
101
99
|
if (event.data && event.data.type === "CACHE_URLS") {
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
103
100
|
const { payload }: CacheURLsMessageData = event.data;
|
|
104
101
|
|
|
105
102
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -124,7 +121,7 @@ export class Router {
|
|
|
124
121
|
void requestPromises.then(() => event.ports[0].postMessage(true));
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
|
-
})
|
|
124
|
+
});
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
/**
|
|
@@ -291,7 +288,6 @@ export class Router {
|
|
|
291
288
|
for (const route of routes) {
|
|
292
289
|
let params: Promise<any> | undefined;
|
|
293
290
|
// route.match returns type any, not possible to change right now.
|
|
294
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
295
291
|
const matchResult = route.match({ url, sameOrigin, request, event });
|
|
296
292
|
if (matchResult) {
|
|
297
293
|
if (process.env.NODE_ENV !== "production") {
|