@j0hanz/superfetch 2.5.2 → 2.6.0

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.
Files changed (46) hide show
  1. package/README.md +356 -223
  2. package/dist/assets/logo.svg +24837 -24835
  3. package/dist/cache.d.ts +28 -20
  4. package/dist/cache.js +292 -514
  5. package/dist/config.d.ts +41 -7
  6. package/dist/config.js +298 -148
  7. package/dist/crypto.js +25 -12
  8. package/dist/dom-noise-removal.js +379 -421
  9. package/dist/errors.d.ts +2 -2
  10. package/dist/errors.js +25 -8
  11. package/dist/fetch.d.ts +18 -16
  12. package/dist/fetch.js +1132 -526
  13. package/dist/host-normalization.js +40 -10
  14. package/dist/http-native.js +628 -287
  15. package/dist/index.js +67 -7
  16. package/dist/instructions.md +44 -30
  17. package/dist/ip-blocklist.d.ts +8 -0
  18. package/dist/ip-blocklist.js +65 -0
  19. package/dist/json.js +14 -9
  20. package/dist/language-detection.d.ts +2 -11
  21. package/dist/language-detection.js +289 -280
  22. package/dist/markdown-cleanup.d.ts +0 -1
  23. package/dist/markdown-cleanup.js +391 -429
  24. package/dist/mcp-validator.js +4 -2
  25. package/dist/mcp.js +184 -135
  26. package/dist/observability.js +89 -21
  27. package/dist/resources.js +16 -6
  28. package/dist/server-tuning.d.ts +2 -0
  29. package/dist/server-tuning.js +25 -23
  30. package/dist/session.d.ts +1 -0
  31. package/dist/session.js +41 -33
  32. package/dist/tasks.d.ts +2 -0
  33. package/dist/tasks.js +91 -9
  34. package/dist/timer-utils.d.ts +5 -0
  35. package/dist/timer-utils.js +20 -0
  36. package/dist/tools.d.ts +28 -5
  37. package/dist/tools.js +317 -183
  38. package/dist/transform-types.d.ts +5 -1
  39. package/dist/transform.d.ts +3 -2
  40. package/dist/transform.js +1138 -421
  41. package/dist/type-guards.d.ts +1 -0
  42. package/dist/type-guards.js +7 -0
  43. package/dist/workers/transform-child.d.ts +1 -0
  44. package/dist/workers/transform-child.js +118 -0
  45. package/dist/workers/transform-worker.js +87 -78
  46. package/package.json +21 -13
package/dist/cache.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import type { ServerResponse } from 'node:http';
2
+ import { z } from 'zod';
2
3
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ declare const CachedPayloadSchema: z.ZodObject<{
5
+ content: z.ZodOptional<z.ZodString>;
6
+ markdown: z.ZodOptional<z.ZodString>;
7
+ title: z.ZodOptional<z.ZodString>;
8
+ }, z.core.$strict>;
9
+ export type CachedPayload = z.infer<typeof CachedPayloadSchema>;
3
10
  export interface CacheEntry {
4
11
  url: string;
5
12
  title?: string;
@@ -7,38 +14,39 @@ export interface CacheEntry {
7
14
  fetchedAt: string;
8
15
  expiresAt: string;
9
16
  }
10
- export interface CachedPayload {
11
- content?: string;
12
- markdown?: string;
13
- title?: string;
14
- }
15
- export interface CacheKeyParts {
16
- namespace: string;
17
- urlHash: string;
18
- }
19
17
  export interface McpIcon {
20
18
  src: string;
21
19
  mimeType: string;
22
- sizes: string[];
20
+ sizes?: string[];
23
21
  }
24
- export declare function parseCachedPayload(raw: string): CachedPayload | null;
25
- export declare function resolveCachedPayloadContent(payload: CachedPayload): string | null;
26
- export declare function createCacheKey(namespace: string, url: string, vary?: Record<string, unknown> | string): string | null;
27
- export declare function parseCacheKey(cacheKey: string): CacheKeyParts | null;
28
- export declare function toResourceUri(cacheKey: string): string | null;
29
- interface CacheUpdateEvent {
30
- cacheKey: string;
22
+ export interface CacheKeyParts {
31
23
  namespace: string;
32
24
  urlHash: string;
33
25
  }
34
- type CacheUpdateListener = (event: CacheUpdateEvent) => void;
26
+ export interface CacheSetOptions {
27
+ force?: boolean;
28
+ }
29
+ export interface CacheGetOptions {
30
+ force?: boolean;
31
+ }
35
32
  interface CacheEntryMetadata {
36
33
  url: string;
37
34
  title?: string;
38
35
  }
36
+ interface CacheUpdateEvent {
37
+ cacheKey: string;
38
+ namespace: string;
39
+ urlHash: string;
40
+ }
41
+ type CacheUpdateListener = (event: CacheUpdateEvent) => unknown;
42
+ export declare function parseCachedPayload(raw: string): CachedPayload | null;
43
+ export declare function resolveCachedPayloadContent(payload: CachedPayload): string | null;
44
+ export declare function createCacheKey(namespace: string, url: string, vary?: Record<string, unknown> | string): string | null;
45
+ export declare function parseCacheKey(cacheKey: string): CacheKeyParts | null;
46
+ export declare function toResourceUri(cacheKey: string): string | null;
39
47
  export declare function onCacheUpdate(listener: CacheUpdateListener): () => void;
40
- export declare function get(cacheKey: string | null): CacheEntry | undefined;
41
- export declare function set(cacheKey: string | null, content: string, metadata: CacheEntryMetadata): void;
48
+ export declare function get(cacheKey: string | null, options?: CacheGetOptions): CacheEntry | undefined;
49
+ export declare function set(cacheKey: string | null, content: string, metadata: CacheEntryMetadata, options?: CacheSetOptions): void;
42
50
  export declare function keys(): readonly string[];
43
51
  export declare function isEnabled(): boolean;
44
52
  export declare function registerCachedContentResource(server: McpServer, serverIcons?: McpIcon[]): void;