@open-wa/driver-interface 5.0.0-alpha.8 → 5.1.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.
package/LICENSE.md CHANGED
@@ -55,9 +55,9 @@ Licensor hereby grants permission by this license ("License"), free of charge,
55
55
  4. Compliance with Human Rights Laws and Human Rights Principles:
56
56
 
57
57
  a. **Human Rights Laws**. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any applicable laws, regulations, or rules that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights (the "Human Rights Laws"). Where the Human Rights Laws of more than one jurisdiction are applicable to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
58
-
58
+
59
59
  b. **Human Rights Principles**. Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights (https://www.un.org/en/universal-declaration-human-rights/) and the United Nations Global Compact (https://www.unglobalcompact.org/ what-is-gc/mission/principles) that define recognized principles of international human rights (the "Human Rights Principles"). It is Licensor's express intent that all use of the Software be consistent with Human Rights Principles. If Licensor receives notification or otherwise learns of an alleged violation of any Human Rights Principles relating to Licensee's use of the Software, Licensor may in its discretion and without obligation (i) (a) notify Licensee of such allegation and (b) allow Licensee 90 days from notification under (i)(a) to investigate and respond to Licensor regarding the allegation and (ii) (a) after the earlier of 90 days from notification under (i)(a), or Licensee's response under (i)(b), notify Licensee of License termination and (b) allow Licensee an additional 90 days from notification under (ii)(a) to cease use of the Software.
60
-
60
+
61
61
  c. **Indemnity**. Licensee shall hold harmless and indemnify Licensor against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor's reasonable attorneys' fees, arising out of or relating to Licensee's non-compliance with this License or use of the Software in violation of Human Rights Laws or Human Rights Principles. 
62
62
 
63
63
  5. Enforceability: If any portion or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by applicable law, the court may modify this License to affect the original intent of the parties as closely as possible. The section headings are for convenience only and are not intended to affect the construction or interpretation of this License. Any rule of construction to the effect that ambiguities are to be resolved against the drafting party shall not apply in interpreting this License. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
package/README.md CHANGED
@@ -16,4 +16,4 @@ See the [docs site](https://openwa.dev).
16
16
 
17
17
  ## License
18
18
 
19
- [H-DNH V1.0](https://github.com/open-wa/wa-automate-nodejs/blob/main/LICENSE.md) — Hippocratic + Do Not Harm
19
+ [H-DNH 1.1](https://github.com/open-wa/wa-automate-nodejs/blob/master/LICENSE.md) — Hippocratic + Do Not Harm
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region src/types.d.ts
2
- type DriverName = 'puppeteer' | 'playwright' | 'remote' | 'lightpanda' | string;
3
- interface IDriverContext {
2
+ export type DriverName = 'puppeteer' | 'playwright' | 'remote' | 'lightpanda' | string;
3
+ export interface IDriverContext {
4
4
  logger?: {
5
5
  debug(msg: string, meta?: Record<string, unknown>): void;
6
6
  info(msg: string, meta?: Record<string, unknown>): void;
@@ -8,14 +8,14 @@ interface IDriverContext {
8
8
  error(msg: string, meta?: Record<string, unknown>): void;
9
9
  };
10
10
  }
11
- interface LightpandaOptions {
11
+ export interface LightpandaOptions {
12
12
  executablePath?: string;
13
13
  portStart?: number;
14
14
  host?: string;
15
15
  startupTimeoutMs?: number;
16
16
  disableTelemetry?: boolean;
17
17
  }
18
- interface LaunchOptions {
18
+ export interface LaunchOptions {
19
19
  headless?: boolean;
20
20
  executablePath?: string;
21
21
  args?: string[];
@@ -32,7 +32,7 @@ interface LaunchOptions {
32
32
  } | null;
33
33
  lightpanda?: LightpandaOptions;
34
34
  }
35
- interface ConnectOptions {
35
+ export interface ConnectOptions {
36
36
  wsEndpoint?: string;
37
37
  cdpEndpoint?: string;
38
38
  headers?: Record<string, string>;
@@ -40,15 +40,15 @@ interface ConnectOptions {
40
40
  }
41
41
  //#endregion
42
42
  //#region src/driver.d.ts
43
- type NavigationWaitUntil = 'load' | 'domcontentloaded' | 'networkidle' | 'networkidle0' | 'networkidle2';
44
- interface DisposableHandle {
43
+ export type NavigationWaitUntil = 'load' | 'domcontentloaded' | 'networkidle' | 'networkidle0' | 'networkidle2';
44
+ export interface DisposableHandle {
45
45
  dispose(): Promise<void> | void;
46
46
  }
47
- interface WaitForFunctionOptions {
47
+ export interface WaitForFunctionOptions {
48
48
  timeoutMs?: number;
49
49
  polling?: number | 'raf' | 'mutation';
50
50
  }
51
- interface IFrame {
51
+ export interface IFrame {
52
52
  url(): string;
53
53
  name(): string;
54
54
  isMainFrame(): boolean;
@@ -56,19 +56,19 @@ interface IFrame {
56
56
  content?(): Promise<string>;
57
57
  unwrap(): unknown;
58
58
  }
59
- interface IRequestContinueOverrides {
59
+ export interface IRequestContinueOverrides {
60
60
  url?: string;
61
61
  method?: string;
62
62
  postData?: string;
63
63
  headers?: Record<string, string>;
64
64
  }
65
- interface IRequestResponse {
65
+ export interface IRequestResponse {
66
66
  status?: number;
67
67
  headers?: Record<string, string>;
68
68
  contentType?: string;
69
69
  body?: string | Uint8Array;
70
70
  }
71
- interface IRequest {
71
+ export interface IRequest {
72
72
  url(): string;
73
73
  method(): string;
74
74
  headers(): Record<string, string>;
@@ -80,7 +80,7 @@ interface IRequest {
80
80
  respond(response: IRequestResponse): Promise<void>;
81
81
  unwrap(): unknown;
82
82
  }
83
- interface IConsoleMessage {
83
+ export interface IConsoleMessage {
84
84
  type(): string;
85
85
  text(): string;
86
86
  location?(): {
@@ -91,7 +91,7 @@ interface IConsoleMessage {
91
91
  args?(): unknown[];
92
92
  unwrap(): unknown;
93
93
  }
94
- interface IPageEventMap {
94
+ export interface IPageEventMap {
95
95
  close: void;
96
96
  console: IConsoleMessage;
97
97
  pageerror: Error;
@@ -100,8 +100,8 @@ interface IPageEventMap {
100
100
  requestfinished: IRequest;
101
101
  framenavigated: IFrame;
102
102
  }
103
- type PageEventHandler<K extends keyof IPageEventMap> = IPageEventMap[K] extends void ? () => void | Promise<void> : (payload: IPageEventMap[K]) => void | Promise<void>;
104
- interface IDriver {
103
+ export type PageEventHandler<K extends keyof IPageEventMap> = IPageEventMap[K] extends void ? () => void | Promise<void> : (payload: IPageEventMap[K]) => void | Promise<void>;
104
+ export interface IDriver {
105
105
  readonly name: DriverName;
106
106
  readonly version?: string;
107
107
  init(ctx?: IDriverContext): Promise<void>;
@@ -109,7 +109,7 @@ interface IDriver {
109
109
  connect(options: ConnectOptions): Promise<IBrowser>;
110
110
  unwrap(): unknown;
111
111
  }
112
- interface IBrowser {
112
+ export interface IBrowser {
113
113
  readonly name: DriverName;
114
114
  newPage(options?: {
115
115
  clearFirstPage?: boolean;
@@ -118,9 +118,10 @@ interface IBrowser {
118
118
  close(): Promise<void>;
119
119
  isConnected(): boolean;
120
120
  versionString(): Promise<string>;
121
+ processId?(): number | undefined;
121
122
  unwrap(): unknown;
122
123
  }
123
- interface IPage {
124
+ export interface IPage {
124
125
  readonly name: DriverName;
125
126
  goto(url: string, options?: {
126
127
  waitUntil?: NavigationWaitUntil;
@@ -163,7 +164,7 @@ interface IPage {
163
164
  isClosed(): boolean;
164
165
  unwrap(): unknown;
165
166
  }
166
- interface IElementHandle {
167
+ export interface IElementHandle {
167
168
  click(): Promise<void>;
168
169
  type(text: string): Promise<void>;
169
170
  getAttribute(name: string): Promise<string | null>;
@@ -173,27 +174,27 @@ interface IElementHandle {
173
174
  }
174
175
  //#endregion
175
176
  //#region src/capabilities.d.ts
176
- type DriverCapabilityKey = 'cdp' | 'requestInterception' | 'serviceWorkerBypass' | 'stealth' | 'pdf' | 'tracing' | 'persistentContext' | 'browserExtensions' | 'exposeBinding' | 'screenshot' | 'rendering';
177
- type CapabilitySupport = {
177
+ export type DriverCapabilityKey = 'cdp' | 'requestInterception' | 'serviceWorkerBypass' | 'stealth' | 'pdf' | 'tracing' | 'persistentContext' | 'browserExtensions' | 'exposeBinding' | 'screenshot' | 'rendering';
178
+ export type CapabilitySupport = {
178
179
  supported: true;
179
180
  notes?: string;
180
181
  } | {
181
182
  supported: false;
182
183
  reason: string;
183
184
  };
184
- type DriverCapabilities = Record<DriverCapabilityKey, CapabilitySupport>;
185
- interface IHasCapabilities {
185
+ export type DriverCapabilities = Record<DriverCapabilityKey, CapabilitySupport>;
186
+ export interface IHasCapabilities {
186
187
  readonly name: string;
187
188
  readonly version?: string;
188
189
  readonly capabilities: DriverCapabilities;
189
190
  has<C extends DriverCapabilityKey>(cap: C): this is this & CapabilityExtensionMap[C];
190
191
  require<C extends DriverCapabilityKey>(cap: C): void;
191
192
  }
192
- interface ICapabilityErrorFactory {
193
+ export interface ICapabilityErrorFactory {
193
194
  createCapabilityError?<C extends DriverCapabilityKey>(capability: C, reason?: string): Error;
194
195
  }
195
- type CapabilitySubject = Pick<IHasCapabilities, 'name' | 'capabilities'> & ICapabilityErrorFactory;
196
- interface CapabilityExtensionMap {
196
+ export type CapabilitySubject = Pick<IHasCapabilities, 'name' | 'capabilities'> & ICapabilityErrorFactory;
197
+ export interface CapabilityExtensionMap {
197
198
  cdp: ICDPSupport;
198
199
  requestInterception: IRequestInterceptionSupport;
199
200
  serviceWorkerBypass: IServiceWorkerBypassSupport;
@@ -206,59 +207,58 @@ interface CapabilityExtensionMap {
206
207
  screenshot: IScreenshotSupport;
207
208
  rendering: IRenderingSupport;
208
209
  }
209
- interface ICDPSupport {
210
+ export interface ICDPSupport {
210
211
  cdp(): ICDPSession;
211
212
  }
212
- interface ICDPSession {
213
+ export interface ICDPSession {
213
214
  send<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
214
215
  detach(): Promise<void>;
215
216
  }
216
- interface IRequestInterceptionSupport {
217
+ export interface IRequestInterceptionSupport {
217
218
  setRequestInterception(enabled: boolean): Promise<void>;
218
219
  }
219
- interface IServiceWorkerBypassSupport {
220
+ export interface IServiceWorkerBypassSupport {
220
221
  setBypassServiceWorker(bypass: boolean): Promise<void>;
221
222
  }
222
- interface IStealthSupport {
223
+ export interface IStealthSupport {
223
224
  enableStealth(enabled: boolean): Promise<void>;
224
225
  }
225
- interface IPdfSupport {
226
+ export interface IPdfSupport {
226
227
  pdf(options?: {
227
228
  path?: string;
228
229
  format?: 'A4' | 'Letter';
229
230
  }): Promise<Uint8Array>;
230
231
  }
231
- interface ITracingSupport {
232
+ export interface ITracingSupport {
232
233
  startTracing(options?: {
233
234
  categories?: string[];
234
235
  }): Promise<void>;
235
236
  stopTracing(): Promise<Uint8Array>;
236
237
  }
237
- interface IPersistentContextSupport {
238
+ export interface IPersistentContextSupport {
238
239
  getPersistentContext(): unknown;
239
240
  }
240
- interface IBrowserExtensionsSupport {
241
+ export interface IBrowserExtensionsSupport {
241
242
  loadExtension(path: string): Promise<void>;
242
243
  }
243
- interface IExposeBindingSupport {
244
+ export interface IExposeBindingSupport {
244
245
  exposeBinding(name: string, fn: (...args: any[]) => any): Promise<void>;
245
246
  }
246
- interface IScreenshotSupport {
247
+ export interface IScreenshotSupport {
247
248
  screenshot(options?: {
248
249
  type?: 'png' | 'jpeg';
249
250
  fullPage?: boolean;
250
251
  }): Promise<Uint8Array>;
251
252
  }
252
- interface IRenderingSupport {
253
+ export interface IRenderingSupport {
253
254
  readonly rendering?: true;
254
255
  }
255
- declare class DriverCapabilityError extends Error {
256
+ export declare class DriverCapabilityError extends Error {
256
257
  readonly driverName: string;
257
258
  readonly capability: DriverCapabilityKey;
258
259
  readonly reason?: string | undefined;
259
260
  constructor(driverName: string, capability: DriverCapabilityKey, reason?: string | undefined);
260
261
  }
261
- declare function requireCapability<C extends DriverCapabilityKey>(subject: CapabilitySubject, capability: C): void;
262
+ export declare function requireCapability<C extends DriverCapabilityKey>(subject: CapabilitySubject, capability: C): void;
262
263
  //#endregion
263
- export { CapabilityExtensionMap, CapabilitySubject, CapabilitySupport, ConnectOptions, DisposableHandle, DriverCapabilities, DriverCapabilityError, DriverCapabilityKey, DriverName, IBrowser, IBrowserExtensionsSupport, ICDPSession, ICDPSupport, ICapabilityErrorFactory, IConsoleMessage, IDriver, IDriverContext, IElementHandle, IExposeBindingSupport, IFrame, IHasCapabilities, IPage, IPageEventMap, IPdfSupport, IPersistentContextSupport, IRenderingSupport, IRequest, IRequestContinueOverrides, IRequestInterceptionSupport, IRequestResponse, IScreenshotSupport, IServiceWorkerBypassSupport, IStealthSupport, ITracingSupport, LaunchOptions, LightpandaOptions, NavigationWaitUntil, PageEventHandler, WaitForFunctionOptions, requireCapability };
264
264
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/driver.ts","../src/capabilities.ts"],"mappings":";KAAY,UAAA;AAAA,UAEK,cAAA;EACb,MAAA;IACI,KAAA,CAAM,GAAA,UAAa,IAAA,GAAO,MAAA;IAC1B,IAAA,CAAK,GAAA,UAAa,IAAA,GAAO,MAAA;IACzB,IAAA,CAAK,GAAA,UAAa,IAAA,GAAO,MAAA;IACzB,KAAA,CAAM,GAAA,UAAa,IAAA,GAAO,MAAA;EAAA;AAAA;AAAA,UAIjB,iBAAA;EACb,cAAA;EACA,SAAA;EACA,IAAA;EACA,gBAAA;EACA,gBAAA;AAAA;AAAA,UAGa,aAAA;EACb,QAAA;EACA,cAAA;EACA,IAAA;EACA,KAAA;IAAU,MAAA;IAAgB,QAAA;IAAmB,QAAA;EAAA;EAC7C,WAAA;EACA,SAAA;EACA,eAAA;IAAoB,KAAA;IAAe,MAAA;EAAA;EACnC,UAAA,GAAa,iBAAA;AAAA;AAAA,UAGA,cAAA;EACb,UAAA;EACA,WAAA;EACA,OAAA,GAAU,MAAA;EACV,SAAA;AAAA;;;KChCQ,mBAAA;AAAA,UAEK,gBAAA;EACb,OAAA,IAAW,OAAA;AAAA;AAAA,UAGE,sBAAA;EACb,SAAA;EACA,OAAA;AAAA;AAAA,UAGa,MAAA;EACb,GAAA;EACA,IAAA;EACA,W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,IAAA,kBAAsB,OAAA;AAAA;AAAA,UAG7C,kBAAA;EACb,UAAA,CAAW,OAAA;IAAY,IAAA;IAAuB,QAAA;EAAA,IAAuB,OAAA,CAAQ,UAAA;AAAA;AAAA,UAGhE,iBAAA;EAAA,SACJ,SAAA;AAAA;AAAA,cAGA,qBAAA,SAA8B,KAAA;EAAA,SAEnB,UAAA;EAAA,SACA,UAAA,EAAY,mBAAA;EAAA,SACZ,MAAA;cAFA,UAAA,UACA,UAAA,EAAY,mBAAA,EACZ,MAAA;AAAA;AAAA,iBAWR,iBAAA,WAA4B,mBAAA,CAAA,CAAqB,OAAA,EAAS,iBAAA,EAAmB,UAAA,EAAY,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/driver.ts","../src/capabilities.ts"],"mappings":";YAAY;iBAEK;EACb;IACI,MAAM,aAAa,OAAO;IAC1B,KAAK,aAAa,OAAO;IACzB,KAAK,aAAa,OAAO;IACzB,MAAM,aAAa,OAAO;;;iBAIjB;EACb;EACA;EACA;EACA;EACA;;iBAGa;EACb;EACA;EACA;EACA;IAAU;IAAgB;IAAmB;;EAC7C;EACA;EACA;IAAoB;IAAe;;EACnC,aAAa;;iBAGA;EACb;EACA;EACA,UAAU;EACV;;;;YChCQ;iBAEK;EACb,WAAW;;iBAGE;EACb;EACA;;iBAGa;EACb;EACA;EACA;EACA,eAAe;EACf,YAAY;EACZ;;iBAGa;EACb;EACA;EACA;EACA,UAAU;;iBAGG;EACb;EACA,UAAU;EACV;EACA,gBAAgB;;iBAGH;EACb;EACA;EACA,WAAW;EACX;EACA;EACA,SAAS;EACT,MAAM,qBAAqB;EAC3B,SAAS,YAAY,4BAA4B;EACjD,QAAQ,UAAU,mBAAmB;EACrC;;iBAGa;EACb;EACA;EACA;IAAe;IAAc;IAAqB;;EAClD;EACA;;iBAGa;EACb;EACA,SAAS;EACT,WAAW;EACX,SAAS;EACT,eAAe;EACf,iBAAiB;EACjB,gBAAgB;;YAGR,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AEvD,SAAS;EACT;EAEA;;iBAGa;EACb,SAAS;EACT,KAAK,eAAe;EACpB,aAAa,eAAe;EAC5B,eAAe;EACf,WAAW;EACX;;;;YClJQ;YAaA;EACJ;EAAiB;;EACjB;EAAkB;;YAEd,qBAAqB,OAAO,qBAAqB;iBAE5C;WACJ;WACA;WACA,cAAc;EAEvB,IAAI,UAAU,qBAAqB,KAAK,mBAAmB,uBAAuB;EAElF,QAAQ,UAAU,qBAAqB,KAAK;;iBAG/B;EACb,uBAAuB,UAAU,qBAAqB,YAAY,GAAG,kBAAkB;;YAG/E,oBAAoB,KAAK,6CAA6C;iBAEjE;EACb,KAAK;EACL,qBAAqB;EACrB,qBAAqB;EACrB,SAAS;EACT,KAAK;EACL,SAAS;EACT,mBAAmB;EACnB,mBAAmB;EACnB,eAAe;EACf,YAAY;EACZ,WAAW;;iBAGE;EACb,OAAO;;iBAGM;EACb,KAAK,aAAa,gBAAgB,SAAS,0BAA0B,QAAQ;EAC7E,UAAU;;iBAGG;EACb,uBAAuB,mBAAmB;;iBAG7B;EACb,uBAAuB,kBAAkB;;iBAG5B;EACb,cAAc,mBAAmB;;iBAGpB;EACb,IAAI;IAAY;IAAe;MAA6B,QAAQ;;iBAGvD;EACb,aAAa;IAAY;MAA0B;EACnD,eAAe,QAAQ;;iBAGV;EACb;;iBAGa;EACb,cAAc,eAAe;;iBAGhB;EACb,cAAc,cAAc,QAAQ,sBAAsB;;iBAG7C;EACb,WAAW;IAAY;IAAuB;MAAuB,QAAQ;;iBAGhE;WACJ;;qBAGA,8BAA8B;WAEnB;WACA,YAAY;WACZ;EAHpB,YACoB,oBACA,YAAY,qBACZ;;wBAWR,kBAAkB,UAAU,qBAAqB,SAAS,mBAAmB,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/driver-interface",
3
- "version": "5.0.0-alpha.8",
3
+ "version": "5.1.0",
4
4
  "description": "Browser driver abstraction interfaces for open-wa",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",
@@ -15,12 +15,16 @@
15
15
  "access": "public"
16
16
  },
17
17
  "devDependencies": {
18
- "typescript": "^6.0.3"
18
+ "typescript": "^7.0.2"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
22
22
  "url": "https://github.com/open-wa/wa-automate-nodejs.git"
23
23
  },
24
+ "license": "SEE LICENSE IN LICENSE.md",
25
+ "files": [
26
+ "dist"
27
+ ],
24
28
  "scripts": {
25
29
  "build": "tsdown src/index.ts --format cjs",
26
30
  "dev": "tsdown src/index.ts --format cjs --watch",
@@ -1,11 +0,0 @@
1
- $ tsdown src/index.ts --format cjs
2
- ℹ tsdown v0.21.7 powered by rolldown v1.0.0-rc.12
3
- ℹ entry: src/index.ts
4
- ℹ tsconfig: tsconfig.json
5
- ℹ Build start
6
- ℹ dist/index.cjs 0.83 kB │ gzip: 0.38 kB
7
- ℹ 1 files, total: 0.83 kB
8
- ℹ dist/index.d.cts.map 5.31 kB │ gzip: 1.42 kB
9
- ℹ dist/index.d.cts 9.09 kB │ gzip: 2.35 kB
10
- ℹ 2 files, total: 14.40 kB
11
- ✔ Build complete in 2526ms
package/CHANGELOG.md DELETED
@@ -1,27 +0,0 @@
1
- # @open-wa/driver-interface
2
-
3
- ## 5.0.0-alpha.8
4
-
5
- ## 5.0.0-alpha.7
6
-
7
- ## 5.0.0-alpha.6
8
-
9
- ## 5.0.0-alpha.5
10
-
11
- ## 5.0.0-alpha.4
12
-
13
- ## 5.0.0-alpha.3
14
-
15
- ## 5.0.0-alpha.2
16
-
17
- ## 6.0.0-alpha.2
18
-
19
- ### Minor Changes
20
-
21
- - Dry run minor bump
22
-
23
- ## 5.0.1-alpha.2
24
-
25
- ### Patch Changes
26
-
27
- - Dry run patch bump
@@ -1,123 +0,0 @@
1
- export type DriverCapabilityKey =
2
- | 'cdp'
3
- | 'requestInterception'
4
- | 'serviceWorkerBypass'
5
- | 'stealth'
6
- | 'pdf'
7
- | 'tracing'
8
- | 'persistentContext'
9
- | 'browserExtensions'
10
- | 'exposeBinding'
11
- | 'screenshot'
12
- | 'rendering';
13
-
14
- export type CapabilitySupport =
15
- | { supported: true; notes?: string }
16
- | { supported: false; reason: string };
17
-
18
- export type DriverCapabilities = Record<DriverCapabilityKey, CapabilitySupport>;
19
-
20
- export interface IHasCapabilities {
21
- readonly name: string;
22
- readonly version?: string;
23
- readonly capabilities: DriverCapabilities;
24
-
25
- has<C extends DriverCapabilityKey>(cap: C): this is this & CapabilityExtensionMap[C];
26
-
27
- require<C extends DriverCapabilityKey>(cap: C): void;
28
- }
29
-
30
- export interface ICapabilityErrorFactory {
31
- createCapabilityError?<C extends DriverCapabilityKey>(capability: C, reason?: string): Error;
32
- }
33
-
34
- export type CapabilitySubject = Pick<IHasCapabilities, 'name' | 'capabilities'> & ICapabilityErrorFactory;
35
-
36
- export interface CapabilityExtensionMap {
37
- cdp: ICDPSupport;
38
- requestInterception: IRequestInterceptionSupport;
39
- serviceWorkerBypass: IServiceWorkerBypassSupport;
40
- stealth: IStealthSupport;
41
- pdf: IPdfSupport;
42
- tracing: ITracingSupport;
43
- persistentContext: IPersistentContextSupport;
44
- browserExtensions: IBrowserExtensionsSupport;
45
- exposeBinding: IExposeBindingSupport;
46
- screenshot: IScreenshotSupport;
47
- rendering: IRenderingSupport;
48
- }
49
-
50
- export interface ICDPSupport {
51
- cdp(): ICDPSession;
52
- }
53
-
54
- export interface ICDPSession {
55
- send<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
56
- detach(): Promise<void>;
57
- }
58
-
59
- export interface IRequestInterceptionSupport {
60
- setRequestInterception(enabled: boolean): Promise<void>;
61
- }
62
-
63
- export interface IServiceWorkerBypassSupport {
64
- setBypassServiceWorker(bypass: boolean): Promise<void>;
65
- }
66
-
67
- export interface IStealthSupport {
68
- enableStealth(enabled: boolean): Promise<void>;
69
- }
70
-
71
- export interface IPdfSupport {
72
- pdf(options?: { path?: string; format?: 'A4' | 'Letter' }): Promise<Uint8Array>;
73
- }
74
-
75
- export interface ITracingSupport {
76
- startTracing(options?: { categories?: string[] }): Promise<void>;
77
- stopTracing(): Promise<Uint8Array>;
78
- }
79
-
80
- export interface IPersistentContextSupport {
81
- getPersistentContext(): unknown;
82
- }
83
-
84
- export interface IBrowserExtensionsSupport {
85
- loadExtension(path: string): Promise<void>;
86
- }
87
-
88
- export interface IExposeBindingSupport {
89
- exposeBinding(name: string, fn: (...args: any[]) => any): Promise<void>;
90
- }
91
-
92
- export interface IScreenshotSupport {
93
- screenshot(options?: { type?: 'png' | 'jpeg'; fullPage?: boolean }): Promise<Uint8Array>;
94
- }
95
-
96
- export interface IRenderingSupport {
97
- readonly rendering?: true;
98
- }
99
-
100
- export class DriverCapabilityError extends Error {
101
- constructor(
102
- public readonly driverName: string,
103
- public readonly capability: DriverCapabilityKey,
104
- public readonly reason?: string
105
- ) {
106
- super(
107
- `Driver '${driverName}' does not support capability '${capability}'${
108
- reason ? `: ${reason}` : ''
109
- }`
110
- );
111
- this.name = 'DriverCapabilityError';
112
- }
113
- }
114
-
115
- export function requireCapability<C extends DriverCapabilityKey>(subject: CapabilitySubject, capability: C): void {
116
- const support = subject.capabilities[capability];
117
- if (support.supported) {
118
- return;
119
- }
120
-
121
- throw subject.createCapabilityError?.(capability, support.reason)
122
- ?? new DriverCapabilityError(subject.name, capability, support.reason);
123
- }
package/src/driver.ts DELETED
@@ -1,146 +0,0 @@
1
- import { LaunchOptions, ConnectOptions, IDriverContext, DriverName } from './types';
2
-
3
- export type NavigationWaitUntil = 'load' | 'domcontentloaded' | 'networkidle' | 'networkidle0' | 'networkidle2';
4
-
5
- export interface DisposableHandle {
6
- dispose(): Promise<void> | void;
7
- }
8
-
9
- export interface WaitForFunctionOptions {
10
- timeoutMs?: number;
11
- polling?: number | 'raf' | 'mutation';
12
- }
13
-
14
- export interface IFrame {
15
- url(): string;
16
- name(): string;
17
- isMainFrame(): boolean;
18
- parentFrame(): IFrame | null;
19
- content?(): Promise<string>;
20
- unwrap(): unknown;
21
- }
22
-
23
- export interface IRequestContinueOverrides {
24
- url?: string;
25
- method?: string;
26
- postData?: string;
27
- headers?: Record<string, string>;
28
- }
29
-
30
- export interface IRequestResponse {
31
- status?: number;
32
- headers?: Record<string, string>;
33
- contentType?: string;
34
- body?: string | Uint8Array;
35
- }
36
-
37
- export interface IRequest {
38
- url(): string;
39
- method(): string;
40
- headers(): Record<string, string>;
41
- resourceType(): string | null;
42
- isNavigationRequest(): boolean;
43
- frame(): IFrame | null;
44
- abort(errorCode?: string): Promise<void>;
45
- continue(overrides?: IRequestContinueOverrides): Promise<void>;
46
- respond(response: IRequestResponse): Promise<void>;
47
- unwrap(): unknown;
48
- }
49
-
50
- export interface IConsoleMessage {
51
- type(): string;
52
- text(): string;
53
- location?(): { url?: string; lineNumber?: number; columnNumber?: number };
54
- args?(): unknown[];
55
- unwrap(): unknown;
56
- }
57
-
58
- export interface IPageEventMap {
59
- close: void;
60
- console: IConsoleMessage;
61
- pageerror: Error;
62
- request: IRequest;
63
- requestfailed: IRequest;
64
- requestfinished: IRequest;
65
- framenavigated: IFrame;
66
- }
67
-
68
- export type PageEventHandler<K extends keyof IPageEventMap> = IPageEventMap[K] extends void
69
- ? () => void | Promise<void>
70
- : (payload: IPageEventMap[K]) => void | Promise<void>;
71
-
72
- export interface IDriver {
73
- readonly name: DriverName;
74
- readonly version?: string;
75
-
76
- init(ctx?: IDriverContext): Promise<void>;
77
- launch(options?: LaunchOptions): Promise<IBrowser>;
78
- connect(options: ConnectOptions): Promise<IBrowser>;
79
-
80
- unwrap(): unknown;
81
- }
82
-
83
- export interface IBrowser {
84
- readonly name: DriverName;
85
-
86
- newPage(options?: {
87
- //clears the first page
88
- clearFirstPage?: boolean
89
- }): Promise<IPage>;
90
- pages(): Promise<IPage[]>;
91
- close(): Promise<void>;
92
- isConnected(): boolean;
93
- versionString(): Promise<string>;
94
-
95
- unwrap(): unknown;
96
- }
97
-
98
- export interface IPage {
99
- readonly name: DriverName;
100
-
101
- goto(url: string, options?: { waitUntil?: NavigationWaitUntil; timeoutMs?: number }): Promise<void>;
102
- url(): string;
103
- reload(): Promise<void>;
104
- mainFrame(): IFrame | null;
105
-
106
- evaluateOnNewDocument<Arg, Ret>(fn: (arg: Arg) => Ret | Promise<Ret>, arg: Arg): Promise<void>;
107
-
108
- evaluate<Arg, Ret>(fn: (arg: Arg) => Ret | Promise<Ret>, arg: Arg): Promise<Ret>;
109
- evaluateScript<Ret = unknown>(script: string): Promise<Ret>;
110
- addInitScript(script: string): Promise<DisposableHandle>;
111
-
112
- setViewport(viewport: { width: number; height: number }): Promise<void>;
113
- setUserAgent(ua: string): Promise<void>;
114
- setRequestInterception(enabled: boolean): Promise<void>;
115
-
116
- waitForSelector(selector: string, options?: { timeoutMs?: number }): Promise<IElementHandle | null>;
117
- waitForFunction(script: string, options?: WaitForFunctionOptions): Promise<void>;
118
- waitForFunction<Arg>(fn: (arg: Arg) => boolean, arg: Arg, options?: WaitForFunctionOptions): Promise<void>;
119
- $(selector: string): Promise<IElementHandle | null>;
120
- $$(selector: string): Promise<IElementHandle[]>;
121
-
122
- click(selector: string): Promise<void>;
123
- type(selector: string, text: string, options?: { delayMs?: number }): Promise<void>;
124
-
125
- screenshot(options?: { type?: 'png' | 'jpeg'; fullPage?: boolean }): Promise<Uint8Array>;
126
-
127
- exposeFunction(name: string, fn: (...args: any[]) => any): Promise<void>;
128
- on<K extends keyof IPageEventMap>(event: K, handler: PageEventHandler<K>): DisposableHandle;
129
- on(event: string, handler: (...args: any[]) => void | Promise<void>): DisposableHandle;
130
- off<K extends keyof IPageEventMap>(event: K, handler: PageEventHandler<K>): void;
131
- off(event: string, handler: (...args: any[]) => void | Promise<void>): void;
132
-
133
- close(): Promise<void>;
134
- isClosed(): boolean;
135
-
136
- unwrap(): unknown;
137
- }
138
-
139
- export interface IElementHandle {
140
- click(): Promise<void>;
141
- type(text: string): Promise<void>;
142
- getAttribute(name: string): Promise<string | null>;
143
- textContent(): Promise<string | null>;
144
- dispose(): Promise<void>;
145
- unwrap(): unknown;
146
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './driver';
3
- export * from './capabilities';
package/src/types.ts DELETED
@@ -1,36 +0,0 @@
1
- export type DriverName = 'puppeteer' | 'playwright' | 'remote' | 'lightpanda' | string;
2
-
3
- export interface IDriverContext {
4
- logger?: {
5
- debug(msg: string, meta?: Record<string, unknown>): void;
6
- info(msg: string, meta?: Record<string, unknown>): void;
7
- warn(msg: string, meta?: Record<string, unknown>): void;
8
- error(msg: string, meta?: Record<string, unknown>): void;
9
- };
10
- }
11
-
12
- export interface LightpandaOptions {
13
- executablePath?: string;
14
- portStart?: number;
15
- host?: string;
16
- startupTimeoutMs?: number;
17
- disableTelemetry?: boolean;
18
- }
19
-
20
- export interface LaunchOptions {
21
- headless?: boolean;
22
- executablePath?: string;
23
- args?: string[];
24
- proxy?: { server: string; username?: string; password?: string };
25
- userDataDir?: string;
26
- timeoutMs?: number;
27
- defaultViewport?: { width: number; height: number } | null;
28
- lightpanda?: LightpandaOptions;
29
- }
30
-
31
- export interface ConnectOptions {
32
- wsEndpoint?: string;
33
- cdpEndpoint?: string;
34
- headers?: Record<string, string>;
35
- timeoutMs?: number;
36
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src"
6
- },
7
- "include": [
8
- "src/**/*"
9
- ]
10
- }