@pagepocket/interceptor 0.6.1

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.
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,87 @@
1
+ export type ResourceType = "document" | "stylesheet" | "script" | "image" | "font" | "media" | "xhr" | "fetch" | "other" | (string & {});
2
+ export type BodySource = {
3
+ kind: "buffer";
4
+ data: Uint8Array;
5
+ } | {
6
+ kind: "stream";
7
+ stream: ReadableStream<Uint8Array>;
8
+ } | {
9
+ kind: "late";
10
+ read: () => Promise<Uint8Array>;
11
+ };
12
+ export interface NetworkRequestEvent {
13
+ type: "request";
14
+ requestId: string;
15
+ url: string;
16
+ method: string;
17
+ headers: Record<string, string>;
18
+ frameId?: string;
19
+ resourceType?: ResourceType;
20
+ initiator?: {
21
+ type?: string;
22
+ url?: string;
23
+ };
24
+ timestamp: number;
25
+ }
26
+ export interface NetworkResponseEvent {
27
+ type: "response";
28
+ requestId: string;
29
+ url: string;
30
+ status: number;
31
+ statusText?: string;
32
+ headers: Record<string, string>;
33
+ mimeType?: string;
34
+ fromDiskCache?: boolean;
35
+ fromServiceWorker?: boolean;
36
+ timestamp: number;
37
+ body?: BodySource;
38
+ }
39
+ export interface NetworkRequestFailedEvent {
40
+ type: "failed";
41
+ requestId: string;
42
+ url: string;
43
+ errorText: string;
44
+ timestamp: number;
45
+ }
46
+ export type NetworkEvent = NetworkRequestEvent | NetworkResponseEvent | NetworkRequestFailedEvent;
47
+ export interface NetworkEventHandlers {
48
+ onEvent(event: NetworkEvent): void;
49
+ onError?(error: Error): void;
50
+ onLog?(msg: string, meta?: unknown): void;
51
+ }
52
+ export interface InterceptorCapabilities {
53
+ canGetResponseBody: boolean;
54
+ canStreamResponseBody: boolean;
55
+ canGetRequestBody: boolean;
56
+ providesResourceType: boolean;
57
+ }
58
+ export type InterceptTarget = {
59
+ kind: "url";
60
+ url: string;
61
+ } | {
62
+ kind: "puppeteer-page";
63
+ page: unknown;
64
+ } | {
65
+ kind: "cdp-tab";
66
+ tabId: number;
67
+ };
68
+ export type InterceptOptions = Record<string, unknown>;
69
+ export type NavigateOptions = Record<string, unknown>;
70
+ export interface InterceptSession {
71
+ navigate?(url: string, options?: NavigateOptions): Promise<void>;
72
+ stop(): Promise<void>;
73
+ }
74
+ export declare const TriggerActionValues: {
75
+ readonly HOVER: "HOVER";
76
+ readonly SCROLL_TO_END: "SCROLL_TO_END";
77
+ };
78
+ export type TriggerAction = (typeof TriggerActionValues)[keyof typeof TriggerActionValues];
79
+ export type InterceptorActions = {
80
+ triggerActions?: TriggerAction[];
81
+ };
82
+ export interface NetworkInterceptorAdapter {
83
+ readonly name: string;
84
+ readonly capabilities: InterceptorCapabilities;
85
+ start(target: InterceptTarget, handlers: NetworkEventHandlers, options?: InterceptOptions & InterceptorActions): Promise<InterceptSession>;
86
+ }
87
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,OAAO,GACP,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,UA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,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC/C,KAAK,CACH,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,gBAAgB,GAAG,kBAAkB,GAC9C,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9B"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ export const TriggerActionValues = {
2
+ HOVER: "HOVER",
3
+ SCROLL_TO_END: "SCROLL_TO_END"
4
+ };
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA+EA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,OAAO;IACd,aAAa,EAAE,eAAe;CACtB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@pagepocket/interceptor",
3
+ "version": "0.6.1",
4
+ "description": "Shared interceptor adapter contract types and helpers.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "devDependencies": {
15
+ "@types/node": "^20.17.12",
16
+ "tsx": "^4.21.0",
17
+ "typescript": "^5.7.2"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "test": "tsx --test specs/*.spec.ts"
22
+ }
23
+ }