Remove temporary browser-test dependency extension.js
Browse files
node_modules/playwright-core/lib/tools/utils/extension.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
"use strict";
|
| 2 |
-
var __create = Object.create;
|
| 3 |
-
var __defProp = Object.defineProperty;
|
| 4 |
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 5 |
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 6 |
-
var __getProtoOf = Object.getPrototypeOf;
|
| 7 |
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 8 |
-
var __export = (target, all) => {
|
| 9 |
-
for (var name in all)
|
| 10 |
-
__defProp(target, name, { get: all[name], enumerable: true });
|
| 11 |
-
};
|
| 12 |
-
var __copyProps = (to, from, except, desc) => {
|
| 13 |
-
if (from && typeof from === "object" || typeof from === "function") {
|
| 14 |
-
for (let key of __getOwnPropNames(from))
|
| 15 |
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 16 |
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 17 |
-
}
|
| 18 |
-
return to;
|
| 19 |
-
};
|
| 20 |
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
| 21 |
-
// If the importer is in node compatibility mode or this is not an ESM
|
| 22 |
-
// file that has been converted to a CommonJS file using a Babel-
|
| 23 |
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
| 24 |
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
| 25 |
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
| 26 |
-
mod
|
| 27 |
-
));
|
| 28 |
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 29 |
-
var extension_exports = {};
|
| 30 |
-
__export(extension_exports, {
|
| 31 |
-
findPlaywrightExtensionProfile: () => findPlaywrightExtensionProfile,
|
| 32 |
-
isExtensionInstalledInProfile: () => isExtensionInstalledInProfile,
|
| 33 |
-
isPlaywrightExtensionInstalled: () => isPlaywrightExtensionInstalled,
|
| 34 |
-
playwrightExtensionId: () => playwrightExtensionId,
|
| 35 |
-
playwrightExtensionInstallUrl: () => playwrightExtensionInstallUrl
|
| 36 |
-
});
|
| 37 |
-
module.exports = __toCommonJS(extension_exports);
|
| 38 |
-
var import_fs = __toESM(require("fs"));
|
| 39 |
-
var import_path = __toESM(require("path"));
|
| 40 |
-
const playwrightExtensionId = "mmlmfjhmonkocbjadbfplnigmagldckm";
|
| 41 |
-
const playwrightExtensionInstallUrl = `https://chromewebstore.google.com/detail/playwright-extension/${playwrightExtensionId}`;
|
| 42 |
-
async function findPlaywrightExtensionProfile(userDataDir) {
|
| 43 |
-
const profiles = await listProfileDirectories(userDataDir);
|
| 44 |
-
const lastUsed = await readLastUsedProfile(userDataDir);
|
| 45 |
-
const ordered = lastUsed && profiles.includes(lastUsed) ? [lastUsed, ...profiles.filter((profile) => profile !== lastUsed)] : profiles;
|
| 46 |
-
for (const profile of ordered) {
|
| 47 |
-
if (await isExtensionInstalledInProfile(import_path.default.join(userDataDir, profile)))
|
| 48 |
-
return profile;
|
| 49 |
-
}
|
| 50 |
-
return void 0;
|
| 51 |
-
}
|
| 52 |
-
async function listProfileDirectories(userDataDir) {
|
| 53 |
-
let entries;
|
| 54 |
-
try {
|
| 55 |
-
entries = await import_fs.default.promises.readdir(userDataDir);
|
| 56 |
-
} catch {
|
| 57 |
-
return [];
|
| 58 |
-
}
|
| 59 |
-
const profiles = entries.filter((entry) => entry === "Default" || /^Profile \d+$/.test(entry));
|
| 60 |
-
profiles.sort((a, b) => profileRank(a) - profileRank(b));
|
| 61 |
-
return profiles;
|
| 62 |
-
}
|
| 63 |
-
function profileRank(profile) {
|
| 64 |
-
return profile === "Default" ? -1 : parseInt(profile.slice("Profile ".length), 10);
|
| 65 |
-
}
|
| 66 |
-
async function readLastUsedProfile(userDataDir) {
|
| 67 |
-
try {
|
| 68 |
-
const localState = JSON.parse(await import_fs.default.promises.readFile(import_path.default.join(userDataDir, "Local State"), "utf-8"));
|
| 69 |
-
const lastUsed = localState?.profile?.last_used;
|
| 70 |
-
return typeof lastUsed === "string" ? lastUsed : void 0;
|
| 71 |
-
} catch {
|
| 72 |
-
return void 0;
|
| 73 |
-
}
|
| 74 |
-
}
|
| 75 |
-
async function isPlaywrightExtensionInstalled(userDataDir) {
|
| 76 |
-
return await findPlaywrightExtensionProfile(userDataDir) !== void 0;
|
| 77 |
-
}
|
| 78 |
-
async function isExtensionInstalledInProfile(profileDir) {
|
| 79 |
-
if (await pathExists(import_path.default.join(profileDir, "Extensions", playwrightExtensionId)))
|
| 80 |
-
return true;
|
| 81 |
-
for (const fileName of ["Preferences", "Secure Preferences"]) {
|
| 82 |
-
if (await hasExtensionSettingsRecord(import_path.default.join(profileDir, fileName)))
|
| 83 |
-
return true;
|
| 84 |
-
}
|
| 85 |
-
return false;
|
| 86 |
-
}
|
| 87 |
-
async function hasExtensionSettingsRecord(prefsPath) {
|
| 88 |
-
let prefs;
|
| 89 |
-
try {
|
| 90 |
-
prefs = JSON.parse(await import_fs.default.promises.readFile(prefsPath, "utf-8"));
|
| 91 |
-
} catch {
|
| 92 |
-
return false;
|
| 93 |
-
}
|
| 94 |
-
const record = prefs?.extensions?.settings?.[playwrightExtensionId];
|
| 95 |
-
return !!record && typeof record === "object" && Object.keys(record).length > 0;
|
| 96 |
-
}
|
| 97 |
-
async function pathExists(p) {
|
| 98 |
-
try {
|
| 99 |
-
await import_fs.default.promises.access(p);
|
| 100 |
-
return true;
|
| 101 |
-
} catch {
|
| 102 |
-
return false;
|
| 103 |
-
}
|
| 104 |
-
}
|
| 105 |
-
// Annotate the CommonJS export names for ESM import in node:
|
| 106 |
-
0 && (module.exports = {
|
| 107 |
-
findPlaywrightExtensionProfile,
|
| 108 |
-
isExtensionInstalledInProfile,
|
| 109 |
-
isPlaywrightExtensionInstalled,
|
| 110 |
-
playwrightExtensionId,
|
| 111 |
-
playwrightExtensionInstallUrl
|
| 112 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|