@toapi/worker 1.2.3 → 1.2.5
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/cache.js +1 -1
- package/dist/cleanup.js +1 -1
- package/dist/handle-toapi-request.js +4 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/mutate-and-invalidate.js +1 -1
- package/dist/revalidation-stream.js +2 -2
- package/dist/serve-from-network.js +1 -1
- package/dist/setup.js +4 -4
- package/package.json +4 -4
package/dist/cache.js
CHANGED
package/dist/cleanup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { META_STORE_NAME, TAGS_STORE_NAME, openCache, openCacheMetaDB, } from "./cache";
|
|
1
|
+
import { META_STORE_NAME, TAGS_STORE_NAME, openCache, openCacheMetaDB, } from "./cache.js";
|
|
2
2
|
/**
|
|
3
3
|
* Reconcile the worker's cache and metadata stores. Intended to be called
|
|
4
4
|
* from the service worker's `activate` event:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isMutation } from "@toapi/common";
|
|
2
|
-
import { getCachedEntry, getMetadata } from "./cache";
|
|
3
|
-
import { mutateAndInvalidate } from "./mutate-and-invalidate";
|
|
4
|
-
import { serveFromNetwork } from "./serve-from-network";
|
|
5
|
-
import { consoleFallback } from "./console-fallback";
|
|
2
|
+
import { getCachedEntry, getMetadata } from "./cache.js";
|
|
3
|
+
import { mutateAndInvalidate } from "./mutate-and-invalidate.js";
|
|
4
|
+
import { serveFromNetwork } from "./serve-from-network.js";
|
|
5
|
+
import { consoleFallback } from "./console-fallback.js";
|
|
6
6
|
export async function handleToapiRequest(req, options) {
|
|
7
7
|
const logger = consoleFallback(options?.logger);
|
|
8
8
|
if (isMutation(req)) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { Logger } from "@toapi/common";
|
|
2
|
-
export { cleanup } from "./cleanup";
|
|
3
|
-
export type { CleanupOptions } from "./cleanup";
|
|
4
|
-
export { handleToapiRequest, handleTapiRequest } from "./handle-toapi-request";
|
|
5
|
-
export { listenForInvalidations } from "./revalidation-stream";
|
|
6
|
-
export { setupToapiWorker } from "./setup";
|
|
7
|
-
export type { SetupToapiWorkerOptions } from "./setup";
|
|
2
|
+
export { cleanup } from "./cleanup.js";
|
|
3
|
+
export type { CleanupOptions } from "./cleanup.js";
|
|
4
|
+
export { handleToapiRequest, handleTapiRequest } from "./handle-toapi-request.js";
|
|
5
|
+
export { listenForInvalidations } from "./revalidation-stream.js";
|
|
6
|
+
export { setupToapiWorker } from "./setup.js";
|
|
7
|
+
export type { SetupToapiWorkerOptions } from "./setup.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cleanup } from "./cleanup";
|
|
2
|
-
export { handleToapiRequest, handleTapiRequest } from "./handle-toapi-request";
|
|
3
|
-
export { listenForInvalidations } from "./revalidation-stream";
|
|
4
|
-
export { setupToapiWorker } from "./setup";
|
|
1
|
+
export { cleanup } from "./cleanup.js";
|
|
2
|
+
export { handleToapiRequest, handleTapiRequest } from "./handle-toapi-request.js";
|
|
3
|
+
export { listenForInvalidations } from "./revalidation-stream.js";
|
|
4
|
+
export { setupToapiWorker } from "./setup.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TAGS_HEADER } from "@toapi/common";
|
|
2
|
-
import { invalidateTags } from "./cache";
|
|
2
|
+
import { invalidateTags } from "./cache.js";
|
|
3
3
|
export async function mutateAndInvalidate(req) {
|
|
4
4
|
const res = await fetch(req);
|
|
5
5
|
const tags = res.headers.get(TAGS_HEADER)?.split(" ")?.filter(Boolean) ?? [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INVALIDATION_POST_EVENT, TAGS_CONTENT_TYPE, } from "@toapi/common";
|
|
2
|
-
import { deleteCache, expireAll, invalidateTags } from "./cache";
|
|
3
|
-
import { consoleFallback } from "./console-fallback";
|
|
2
|
+
import { deleteCache, expireAll, invalidateTags } from "./cache.js";
|
|
3
|
+
import { consoleFallback } from "./console-fallback.js";
|
|
4
4
|
export async function listenForInvalidations({ url, timeout = 5000, logger: customLogger, }) {
|
|
5
5
|
const logger = consoleFallback(customLogger);
|
|
6
6
|
logger.info("Listening for invalidations...");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EXPIRES_AT_HEADER, TAGS_HEADER } from "@toapi/common";
|
|
2
|
-
import { deleteCacheEntry, storeCacheEntry } from "./cache";
|
|
2
|
+
import { deleteCacheEntry, storeCacheEntry } from "./cache.js";
|
|
3
3
|
export async function serveFromNetwork(req) {
|
|
4
4
|
const res = await fetch(req);
|
|
5
5
|
// only cache ok responses with tags or expires-at header
|
package/dist/setup.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { INVALIDATIONS_ROUTE } from "@toapi/common";
|
|
2
|
-
import { cleanup } from "./cleanup";
|
|
3
|
-
import { handleToapiRequest } from "./handle-toapi-request";
|
|
4
|
-
import { listenForInvalidations } from "./revalidation-stream";
|
|
5
|
-
import { consoleFallback } from "./console-fallback";
|
|
2
|
+
import { cleanup } from "./cleanup.js";
|
|
3
|
+
import { handleToapiRequest } from "./handle-toapi-request.js";
|
|
4
|
+
import { listenForInvalidations } from "./revalidation-stream.js";
|
|
5
|
+
import { consoleFallback } from "./console-fallback.js";
|
|
6
6
|
const ONE_WEEK_SECONDS = 60 * 60 * 24 * 7;
|
|
7
7
|
/**
|
|
8
8
|
* Wire up the whole Toapi service worker in a single call. This registers the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toapi/worker",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Michel Smola",
|
|
6
6
|
"email": "michel.smola@farbenmeer.de"
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@toapi/common": "^1.2.
|
|
23
|
+
"@toapi/common": "^1.2.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^25.0.3",
|
|
27
|
-
"vitest": "^
|
|
27
|
+
"vitest": "^5.0.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"typescript": "^5 || ^6.0.0"
|
|
30
|
+
"typescript": "^5 || ^6.0.0 || ^7.0.0"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|