launch.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * @license
  3. * Copyright 2023 Google Inc.
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /// <reference types="node" />
  7. /// <reference types="node" />
  8. import childProcess from 'child_process';
  9. import { type Browser, type BrowserPlatform, type ChromeReleaseChannel } from './browser-data/browser-data.js';
  10. /**
  11. * @public
  12. */
  13. export interface ComputeExecutablePathOptions {
  14. /**
  15. * Root path to the storage directory.
  16. */
  17. cacheDir: string;
  18. /**
  19. * Determines which platform the browser will be suited for.
  20. *
  21. * @defaultValue **Auto-detected.**
  22. */
  23. platform?: BrowserPlatform;
  24. /**
  25. * Determines which browser to launch.
  26. */
  27. browser: Browser;
  28. /**
  29. * Determines which buildId to download. BuildId should uniquely identify
  30. * binaries and they are used for caching.
  31. */
  32. buildId: string;
  33. }
  34. /**
  35. * @public
  36. */
  37. export declare function computeExecutablePath(options: ComputeExecutablePathOptions): string;
  38. /**
  39. * @public
  40. */
  41. export interface SystemOptions {
  42. /**
  43. * Determines which platform the browser will be suited for.
  44. *
  45. * @defaultValue **Auto-detected.**
  46. */
  47. platform?: BrowserPlatform;
  48. /**
  49. * Determines which browser to launch.
  50. */
  51. browser: Browser;
  52. /**
  53. * Release channel to look for on the system.
  54. */
  55. channel: ChromeReleaseChannel;
  56. }
  57. /**
  58. * @public
  59. */
  60. export declare function computeSystemExecutablePath(options: SystemOptions): string;
  61. /**
  62. * @public
  63. */
  64. export interface LaunchOptions {
  65. executablePath: string;
  66. pipe?: boolean;
  67. dumpio?: boolean;
  68. args?: string[];
  69. env?: Record<string, string | undefined>;
  70. handleSIGINT?: boolean;
  71. handleSIGTERM?: boolean;
  72. handleSIGHUP?: boolean;
  73. detached?: boolean;
  74. onExit?: () => Promise<void>;
  75. }
  76. /**
  77. * @public
  78. */
  79. export declare function launch(opts: LaunchOptions): Process;
  80. /**
  81. * @public
  82. */
  83. export declare const CDP_WEBSOCKET_ENDPOINT_REGEX: RegExp;
  84. /**
  85. * @public
  86. */
  87. export declare const WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX: RegExp;
  88. /**
  89. * @public
  90. */
  91. export declare class Process {
  92. #private;
  93. constructor(opts: LaunchOptions);
  94. get nodeProcess(): childProcess.ChildProcess;
  95. close(): Promise<void>;
  96. hasClosed(): Promise<void>;
  97. kill(): void;
  98. waitForLineOutput(regex: RegExp, timeout?: number): Promise<string>;
  99. }
  100. /**
  101. * @internal
  102. */
  103. export interface ErrorLike extends Error {
  104. name: string;
  105. message: string;
  106. }
  107. /**
  108. * @internal
  109. */
  110. export declare function isErrorLike(obj: unknown): obj is ErrorLike;
  111. /**
  112. * @internal
  113. */
  114. export declare function isErrnoException(obj: unknown): obj is NodeJS.ErrnoException;
  115. /**
  116. * @public
  117. */
  118. export declare class TimeoutError extends Error {
  119. /**
  120. * @internal
  121. */
  122. constructor(message?: string);
  123. }
  124. //# sourceMappingURL=launch.d.ts.map