launch.d.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * Copyright 2023 Google Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /// <reference types="node" />
  17. /// <reference types="node" />
  18. import childProcess from 'child_process';
  19. import { Browser, BrowserPlatform, ChromeReleaseChannel } from './browser-data/browser-data.js';
  20. /**
  21. * @public
  22. */
  23. export interface ComputeExecutablePathOptions {
  24. /**
  25. * Root path to the storage directory.
  26. */
  27. cacheDir: string;
  28. /**
  29. * Determines which platform the browser will be suited for.
  30. *
  31. * @defaultValue **Auto-detected.**
  32. */
  33. platform?: BrowserPlatform;
  34. /**
  35. * Determines which browser to launch.
  36. */
  37. browser: Browser;
  38. /**
  39. * Determines which buildId to download. BuildId should uniquely identify
  40. * binaries and they are used for caching.
  41. */
  42. buildId: string;
  43. }
  44. /**
  45. * @public
  46. */
  47. export declare function computeExecutablePath(options: ComputeExecutablePathOptions): string;
  48. /**
  49. * @public
  50. */
  51. export interface SystemOptions {
  52. /**
  53. * Determines which platform the browser will be suited for.
  54. *
  55. * @defaultValue **Auto-detected.**
  56. */
  57. platform?: BrowserPlatform;
  58. /**
  59. * Determines which browser to launch.
  60. */
  61. browser: Browser;
  62. /**
  63. * Release channel to look for on the system.
  64. */
  65. channel: ChromeReleaseChannel;
  66. }
  67. /**
  68. * @public
  69. */
  70. export declare function computeSystemExecutablePath(options: SystemOptions): string;
  71. /**
  72. * @public
  73. */
  74. export interface LaunchOptions {
  75. executablePath: string;
  76. pipe?: boolean;
  77. dumpio?: boolean;
  78. args?: string[];
  79. env?: Record<string, string | undefined>;
  80. handleSIGINT?: boolean;
  81. handleSIGTERM?: boolean;
  82. handleSIGHUP?: boolean;
  83. detached?: boolean;
  84. onExit?: () => Promise<void>;
  85. }
  86. /**
  87. * @public
  88. */
  89. export declare function launch(opts: LaunchOptions): Process;
  90. /**
  91. * @public
  92. */
  93. export declare const CDP_WEBSOCKET_ENDPOINT_REGEX: RegExp;
  94. /**
  95. * @public
  96. */
  97. export declare const WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX: RegExp;
  98. /**
  99. * @public
  100. */
  101. export declare class Process {
  102. #private;
  103. constructor(opts: LaunchOptions);
  104. get nodeProcess(): childProcess.ChildProcess;
  105. close(): Promise<void>;
  106. hasClosed(): Promise<void>;
  107. kill(): void;
  108. waitForLineOutput(regex: RegExp, timeout?: number): Promise<string>;
  109. }
  110. /**
  111. * @internal
  112. */
  113. export interface ErrorLike extends Error {
  114. name: string;
  115. message: string;
  116. }
  117. /**
  118. * @internal
  119. */
  120. export declare function isErrorLike(obj: unknown): obj is ErrorLike;
  121. /**
  122. * @internal
  123. */
  124. export declare function isErrnoException(obj: unknown): obj is NodeJS.ErrnoException;
  125. /**
  126. * @public
  127. */
  128. export declare class TimeoutError extends Error {
  129. /**
  130. * @internal
  131. */
  132. constructor(message?: string);
  133. }
  134. //# sourceMappingURL=launch.d.ts.map