Cache.d.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @license
  3. * Copyright 2023 Google Inc.
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. import { Browser, type BrowserPlatform } from './browser-data/browser-data.js';
  7. /**
  8. * @public
  9. */
  10. export declare class InstalledBrowser {
  11. #private;
  12. browser: Browser;
  13. buildId: string;
  14. platform: BrowserPlatform;
  15. readonly executablePath: string;
  16. /**
  17. * @internal
  18. */
  19. constructor(cache: Cache, browser: Browser, buildId: string, platform: BrowserPlatform);
  20. /**
  21. * Path to the root of the installation folder. Use
  22. * {@link computeExecutablePath} to get the path to the executable binary.
  23. */
  24. get path(): string;
  25. readMetadata(): Metadata;
  26. writeMetadata(metadata: Metadata): void;
  27. }
  28. /**
  29. * @internal
  30. */
  31. export interface ComputeExecutablePathOptions {
  32. /**
  33. * Determines which platform the browser will be suited for.
  34. *
  35. * @defaultValue **Auto-detected.**
  36. */
  37. platform?: BrowserPlatform;
  38. /**
  39. * Determines which browser to launch.
  40. */
  41. browser: Browser;
  42. /**
  43. * Determines which buildId to download. BuildId should uniquely identify
  44. * binaries and they are used for caching.
  45. */
  46. buildId: string;
  47. }
  48. export interface Metadata {
  49. aliases: Record<string, string>;
  50. }
  51. /**
  52. * The cache used by Puppeteer relies on the following structure:
  53. *
  54. * - rootDir
  55. * -- <browser1> | browserRoot(browser1)
  56. * ---- <platform>-<buildId> | installationDir()
  57. * ------ the browser-platform-buildId
  58. * ------ specific structure.
  59. * -- <browser2> | browserRoot(browser2)
  60. * ---- <platform>-<buildId> | installationDir()
  61. * ------ the browser-platform-buildId
  62. * ------ specific structure.
  63. * @internal
  64. */
  65. export declare class Cache {
  66. #private;
  67. constructor(rootDir: string);
  68. /**
  69. * @internal
  70. */
  71. get rootDir(): string;
  72. browserRoot(browser: Browser): string;
  73. metadataFile(browser: Browser): string;
  74. readMetadata(browser: Browser): Metadata;
  75. writeMetadata(browser: Browser, metadata: Metadata): void;
  76. resolveAlias(browser: Browser, alias: string): string | undefined;
  77. installationDir(browser: Browser, platform: BrowserPlatform, buildId: string): string;
  78. clear(): void;
  79. uninstall(browser: Browser, platform: BrowserPlatform, buildId: string): void;
  80. getInstalledBrowsers(): InstalledBrowser[];
  81. computeExecutablePath(options: ComputeExecutablePathOptions): string;
  82. }
  83. //# sourceMappingURL=Cache.d.ts.map