@puppeteer/browsers
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -18,2 +18,11 @@ /** | ||
/** | ||
* @public | ||
*/ | ||
export type InstalledBrowser = { | ||
path: string; | ||
browser: Browser; | ||
buildId: string; | ||
platform: BrowserPlatform; | ||
}; | ||
/** | ||
* The cache used by Puppeteer relies on the following structure: | ||
@@ -38,3 +47,4 @@ * | ||
clear(): void; | ||
getInstalledBrowsers(): InstalledBrowser[]; | ||
} | ||
//# sourceMappingURL=Cache.d.ts.map |
@@ -72,5 +72,45 @@ "use strict"; | ||
} | ||
getInstalledBrowsers() { | ||
if (!fs_1.default.existsSync(__classPrivateFieldGet(this, _Cache_rootDir, "f"))) { | ||
return []; | ||
} | ||
const types = fs_1.default.readdirSync(__classPrivateFieldGet(this, _Cache_rootDir, "f")); | ||
const browsers = types.filter((t) => { | ||
return Object.values(browser_data_js_1.Browser).includes(t); | ||
}); | ||
return browsers.flatMap(browser => { | ||
const files = fs_1.default.readdirSync(this.browserRoot(browser)); | ||
return files | ||
.map(file => { | ||
const result = parseFolderPath(path_1.default.join(this.browserRoot(browser), file)); | ||
if (!result) { | ||
return null; | ||
} | ||
return { | ||
path: path_1.default.join(this.browserRoot(browser), file), | ||
browser, | ||
platform: result.platform, | ||
buildId: result.buildId, | ||
}; | ||
}) | ||
.filter((item) => { | ||
return item !== null; | ||
}); | ||
}); | ||
} | ||
} | ||
exports.Cache = Cache; | ||
_Cache_rootDir = new WeakMap(); | ||
function parseFolderPath(folderPath) { | ||
const name = path_1.default.basename(folderPath); | ||
const splits = name.split('-'); | ||
if (splits.length !== 2) { | ||
return; | ||
} | ||
const [platform, buildId] = splits; | ||
if (!buildId || !platform) { | ||
return; | ||
} | ||
return { platform, buildId }; | ||
} | ||
//# sourceMappingURL=Cache.js.map |
@@ -17,2 +17,3 @@ /** | ||
import { Browser, BrowserPlatform } from './browser-data/browser-data.js'; | ||
import { InstalledBrowser } from './Cache.js'; | ||
/** | ||
@@ -65,11 +66,2 @@ * @public | ||
*/ | ||
export type InstalledBrowser = { | ||
path: string; | ||
browser: Browser; | ||
buildId: string; | ||
platform: BrowserPlatform; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export declare function install(options: InstallOptions): Promise<InstalledBrowser>; | ||
@@ -76,0 +68,0 @@ /** |
@@ -17,7 +17,7 @@ /** | ||
export { launch, computeExecutablePath, computeSystemExecutablePath, TimeoutError, LaunchOptions, ComputeExecutablePathOptions as Options, SystemOptions, CDP_WEBSOCKET_ENDPOINT_REGEX, WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, Process, } from './launch.js'; | ||
export { install, canDownload, InstallOptions, InstalledBrowser, } from './install.js'; | ||
export { install, canDownload, InstallOptions } from './install.js'; | ||
export { detectBrowserPlatform } from './detectPlatform.js'; | ||
export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, createProfile, ProfileOptions, } from './browser-data/browser-data.js'; | ||
export { CLI, makeProgressCallback } from './CLI.js'; | ||
export { Cache } from './Cache.js'; | ||
export { Cache, InstalledBrowser } from './Cache.js'; | ||
//# sourceMappingURL=main.d.ts.map |
@@ -18,2 +18,11 @@ /** | ||
/** | ||
* @public | ||
*/ | ||
export type InstalledBrowser = { | ||
path: string; | ||
browser: Browser; | ||
buildId: string; | ||
platform: BrowserPlatform; | ||
}; | ||
/** | ||
* The cache used by Puppeteer relies on the following structure: | ||
@@ -38,3 +47,4 @@ * | ||
clear(): void; | ||
getInstalledBrowsers(): InstalledBrowser[]; | ||
} | ||
//# sourceMappingURL=Cache.d.ts.map |
@@ -66,4 +66,44 @@ /** | ||
} | ||
getInstalledBrowsers() { | ||
if (!fs.existsSync(__classPrivateFieldGet(this, _Cache_rootDir, "f"))) { | ||
return []; | ||
} | ||
const types = fs.readdirSync(__classPrivateFieldGet(this, _Cache_rootDir, "f")); | ||
const browsers = types.filter((t) => { | ||
return Object.values(Browser).includes(t); | ||
}); | ||
return browsers.flatMap(browser => { | ||
const files = fs.readdirSync(this.browserRoot(browser)); | ||
return files | ||
.map(file => { | ||
const result = parseFolderPath(path.join(this.browserRoot(browser), file)); | ||
if (!result) { | ||
return null; | ||
} | ||
return { | ||
path: path.join(this.browserRoot(browser), file), | ||
browser, | ||
platform: result.platform, | ||
buildId: result.buildId, | ||
}; | ||
}) | ||
.filter((item) => { | ||
return item !== null; | ||
}); | ||
}); | ||
} | ||
} | ||
_Cache_rootDir = new WeakMap(); | ||
function parseFolderPath(folderPath) { | ||
const name = path.basename(folderPath); | ||
const splits = name.split('-'); | ||
if (splits.length !== 2) { | ||
return; | ||
} | ||
const [platform, buildId] = splits; | ||
if (!buildId || !platform) { | ||
return; | ||
} | ||
return { platform, buildId }; | ||
} | ||
//# sourceMappingURL=Cache.js.map |
@@ -17,2 +17,3 @@ /** | ||
import { Browser, BrowserPlatform } from './browser-data/browser-data.js'; | ||
import { InstalledBrowser } from './Cache.js'; | ||
/** | ||
@@ -65,11 +66,2 @@ * @public | ||
*/ | ||
export type InstalledBrowser = { | ||
path: string; | ||
browser: Browser; | ||
buildId: string; | ||
platform: BrowserPlatform; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export declare function install(options: InstallOptions): Promise<InstalledBrowser>; | ||
@@ -76,0 +68,0 @@ /** |
@@ -17,7 +17,7 @@ /** | ||
export { launch, computeExecutablePath, computeSystemExecutablePath, TimeoutError, LaunchOptions, ComputeExecutablePathOptions as Options, SystemOptions, CDP_WEBSOCKET_ENDPOINT_REGEX, WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, Process, } from './launch.js'; | ||
export { install, canDownload, InstallOptions, InstalledBrowser, } from './install.js'; | ||
export { install, canDownload, InstallOptions } from './install.js'; | ||
export { detectBrowserPlatform } from './detectPlatform.js'; | ||
export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, createProfile, ProfileOptions, } from './browser-data/browser-data.js'; | ||
export { CLI, makeProgressCallback } from './CLI.js'; | ||
export { Cache } from './Cache.js'; | ||
export { Cache, InstalledBrowser } from './Cache.js'; | ||
//# sourceMappingURL=main.d.ts.map |
@@ -17,3 +17,3 @@ /** | ||
export { launch, computeExecutablePath, computeSystemExecutablePath, TimeoutError, CDP_WEBSOCKET_ENDPOINT_REGEX, WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX, Process, } from './launch.js'; | ||
export { install, canDownload, } from './install.js'; | ||
export { install, canDownload } from './install.js'; | ||
export { detectBrowserPlatform } from './detectPlatform.js'; | ||
@@ -20,0 +20,0 @@ export { resolveBuildId, Browser, BrowserPlatform, ChromeReleaseChannel, createProfile, } from './browser-data/browser-data.js'; |
{ | ||
"name": "@puppeteer/browsers", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "Download and launch browsers", | ||
@@ -26,3 +26,3 @@ "scripts": { | ||
"build": { | ||
"command": "tsc -b && chmod a+x lib/cjs/main-cli.js lib/esm/main-cli.js", | ||
"command": "tsc -b && tsx ../../tools/chmod.ts 755 lib/cjs/main-cli.js lib/esm/main-cli.js", | ||
"files": [ | ||
@@ -29,0 +29,0 @@ "src/**/*.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
339833
5111