feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,206 @@
# Edge Launcher
<img src="https://user-images.githubusercontent.com/4672033/107800563-adb9ce00-6d3d-11eb-8425-2256d0278894.png" align=right height=200>
Launch Microsoft Edge with ease from node.
- [Disables many Edge services](https://github.com/microsoft/rnx-kit/incubator/chromium-edge-launcher/blob/main/src/flags.ts)
that add noise to automated scenarios
- Opens up the browser's `remote-debugging-port` on an available port
- Automagically locates a Edge binary to launch
- Uses a fresh Edge profile for each launch, and cleans itself up on `kill()`
- Binds `Ctrl-C` (by default) to terminate the Edge process
- Exposes a small set of [options](#api) for configurability over these details
> \_This project started as a fork of
> [Chrome Launcher](https://github.com/GoogleChrome/chrome-launcher) and
> inherits, whereas possible, all its features.
### Installing
```sh
yarn add @rnx-kit/chromium-edge-launcher
# or with npm:
npm install @rnx-kit/chromium-edge-launcher
```
## API
### `.launch([opts])`
#### Launch options
```js
{
// (optional) remote debugging port number to use. If provided port is already busy, launch() will reject
// Default: an available port is autoselected
port: number;
// (optional) Additional flags to pass to Edge, for example: ['--headless', '--disable-gpu']
// See: https://github.com/microsoft/rnx-kit/incubator/chromium-edge-launcher/blob/main/docs/edge-flags-for-tools.md
// Do note, many flags are set by default: https://github.com/microsoft/rnx-kit/incubator/chromium-edge-launcher/blob/main/src/flags.ts
edgeFlags: Array<string>;
// (optional) Close the Edge process on `Ctrl-C`
// Default: true
handleSIGINT: boolean;
// (optional) Explicit path of intended Edge binary
 // * If this `edgePath` option is defined, it will be used.
// * Otherwise, the `EDGE_PATH` env variable will be used if set. (`LIGHTHOUSE_CHROMIUM_PATH` is deprecated)
 // * Otherwise, a detected Edge Canary will be used if found
// * Otherwise, a detected Edge (stable) will be used
edgePath: string;
// (optional) Edge profile path to use, if set to `false` then the default profile will be used.
// By default, a fresh Edge profile will be created
userDataDir: string | boolean;
// (optional) Starting URL to open the browser with
// Default: `about:blank`
startingUrl: string;
// (optional) Logging level
// Default: 'silent'
logLevel: 'verbose'|'info'|'error'|'silent';
// (optional) Flags specific in [flags.ts](src/flags.ts) will not be included.
// Typically used with the defaultFlags() method and edgeFlags option.
// Default: false
ignoreDefaultFlags: boolean;
// (optional) Interval in ms, which defines how often launcher checks browser port to be ready.
// Default: 500
connectionPollInterval: number;
// (optional) A number of retries, before browser launch considered unsuccessful.
// Default: 50
maxConnectionRetries: number;
// (optional) A dict of environmental key value pairs to pass to the spawned edge process.
envVars: {[key: string]: string};
};
```
#### Launched edge interface
#### `.launch().then(edge => ...`
```js
// The remote debugging port exposed by the launched edge
edge.port: number;
// Method to kill Edge (and cleanup the profile folder)
edge.kill: () => Promise<void>;
// The process id
edge.pid: number;
// The childProcess object for the launched Edge
edge.process: childProcess
```
### `EdgeLauncher.Launcher.defaultFlags()`
Returns an `Array<string>` of the default [flags](docs/edge-flags-for-tools.md)
Edge is launched with. Typically used along with the `ignoreDefaultFlags` and
`edgeFlags` options.
Note: This array will exclude the following flags: `--remote-debugging-port`
`--disable-setuid-sandbox` `--user-data-dir`.
### `EdgeLauncher.Launcher.getInstallations()`
Returns an `Array<string>` of paths to available Edge installations. When
`edgePath` is not provided to `.launch()`, the first installation returned from
this method is used instead.
Note: This method performs synchronous I/O operations.
### `.killAll()`
Attempts to kill all Edge instances created with
[`.launch([opts])`](#launchopts). Returns a Promise that resolves to an array of
errors that occurred while killing instances. If all instances were killed
successfully, the array will be empty.
```js
const EdgeLauncher = require("@rnx-kit/chromium-edge-launcher");
async function cleanup() {
await EdgeLauncher.killAll();
}
```
## Examples
#### Launching edge:
```js
const EdgeLauncher = require("@rnx-kit/chromium-edge-launcher");
EdgeLauncher.launch({
startingUrl: "https://google.com",
}).then((edge) => {
console.log(`Edge debugging port running on ${edge.port}`);
});
```
#### Launching headless edge:
```js
const EdgeLauncher = require("@rnx-kit/chromium-edge-launcher");
EdgeLauncher.launch({
startingUrl: "https://google.com",
edgeFlags: ["--headless", "--disable-gpu"],
}).then((edge) => {
console.log(`Edge debugging port running on ${edge.port}`);
});
```
#### Launching with support for extensions and audio:
```js
const EdgeLauncher = require('@rnx-kit/chromium-edge-launcher');
const newFlags = EdgeLauncher.Launcher.defaultFlags().filter(flag => flag !== '--disable-extensions' && flag !== '--mute-audio');
EdgeLauncher.launch({
ignoreDefaultFlags: true,
edgeFlags: newFlags,
}).then(edge => { ... });
```
### Continuous Integration
In a CI environment like Travis, Edge may not be installed. If you want to use
`@rnx-kit/chromium-edge-launcher`, Travis can
[install Edge at run time with an addon](https://docs.travis-ci.com/user/edge).
Alternatively, you can also install Edge using the
[`download-edge.sh`](https://raw.githubusercontent.com/cezaraugusto/chromium-edge-launcher/v0.8.0/scripts/download-edge.sh)
script.
Then in `.travis.yml`, use it like so:
```yaml
language: node_js
install:
- yarn install
before_script:
- export DISPLAY=:99.0
- export CHROME_PATH="$(pwd)/edge-linux/edge"
- sh -e /etc/init.d/xvfb start
- sleep 3 # wait for xvfb to boot
addons:
edge: stable
```
### Acknowledgements
This project is a fork of https://github.com/cezaraugusto/chromium-edge-launcher
which started as a fork of, and is inspired by
https://github.com/cezaraugusto/chromium-edge-launcher which is released under
the Apache-2.0 License, and is copyright of Google Inc.

View File

@@ -0,0 +1,15 @@
/**
* check for MacOS default app paths first to avoid waiting for the slow lsregister command
*/
export declare function darwinFast(): string | undefined;
export declare function darwin(): string[];
/**
* Look for linux executables in 3 ways
* 1. Look into EDGE_PATH env variable
* 2. Look into the directories where .desktop are saved on gnome based distro's
* 3. Look for microsoft-edge-stable & microsoft-edge executables by using the which command
*/
export declare function linux(): string[];
export declare function wsl(): string[];
export declare function win32(): string[];
//# sourceMappingURL=edge-finder.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"edge-finder.d.ts","sourceRoot":"","sources":["../src/edge-finder.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,SAAS,CAY/C;AAED,wBAAgB,MAAM,aA2DrB;AAkBD;;;;;GAKG;AACH,wBAAgB,KAAK,aAkEpB;AAED,wBAAgB,GAAG,aAOlB;AAED,wBAAgB,KAAK,aA0BpB"}

View File

@@ -0,0 +1,245 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.win32 = exports.wsl = exports.linux = exports.darwin = exports.darwinFast = void 0;
const fs = require("fs");
const path = require("path");
const child_process_1 = require("child_process");
const os_1 = require("os");
const escapeRegExp = require("escape-string-regexp");
const log = require("lighthouse-logger");
const utils_1 = require("./utils");
const newLineRegex = /\r?\n/;
/**
* check for MacOS default app paths first to avoid waiting for the slow lsregister command
*/
function darwinFast() {
const priorityOptions = [
process.env.EDGE_PATH,
process.env.LIGHTHOUSE_CHROMIUM_PATH,
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
];
for (const edgePath of priorityOptions) {
if (edgePath && canAccess(edgePath))
return edgePath;
}
return darwin()[0];
}
exports.darwinFast = darwinFast;
function darwin() {
const suffixes = ["/Contents/MacOS/Google Edge"];
const LSREGISTER = "/System/Library/Frameworks/CoreServices.framework" +
"/Versions/A/Frameworks/LaunchServices.framework" +
"/Versions/A/Support/lsregister";
const installations = [];
const customEdgePath = resolveEdgePath();
if (customEdgePath) {
installations.push(customEdgePath);
}
(0, child_process_1.execSync)(`${LSREGISTER} -dump` +
" | grep -i 'microsoft edge\\?\\.app'" +
" | awk '{$1=\"\"; print $0}'")
.toString()
.split(newLineRegex)
.forEach((inst) => {
suffixes.forEach((suffix) => {
const execPath = path.join(inst.substring(0, inst.indexOf(".app") + 4).trim(), suffix);
if (canAccess(execPath) && installations.indexOf(execPath) === -1) {
installations.push(execPath);
}
});
});
// Retains one per line to maintain readability.
// clang-format off
const home = escapeRegExp(process.env.HOME || (0, os_1.homedir)());
const priorities = [
{ regex: new RegExp(`^${home}/Applications/.*Edge\\.app`), weight: 50 },
{ regex: /^\/Applications\/.*Edge.app/, weight: 100 },
{ regex: /^\/Volumes\/.*Edge.app/, weight: -2 },
];
if (process.env.LIGHTHOUSE_CHROMIUM_PATH) {
priorities.unshift({
regex: new RegExp(escapeRegExp(process.env.LIGHTHOUSE_CHROMIUM_PATH)),
weight: 150,
});
}
if (process.env.EDGE_PATH) {
priorities.unshift({
regex: new RegExp(escapeRegExp(process.env.EDGE_PATH)),
weight: 151,
});
}
// clang-format on
return sort(installations, priorities);
}
exports.darwin = darwin;
function resolveEdgePath() {
if (canAccess(process.env.EDGE_PATH)) {
return process.env.EDGE_PATH;
}
if (canAccess(process.env.LIGHTHOUSE_CHROMIUM_PATH)) {
log.warn("EdgeLauncher", "LIGHTHOUSE_CHROMIUM_PATH is deprecated, use EDGE_PATH env variable instead.");
return process.env.LIGHTHOUSE_CHROMIUM_PATH;
}
return undefined;
}
/**
* Look for linux executables in 3 ways
* 1. Look into EDGE_PATH env variable
* 2. Look into the directories where .desktop are saved on gnome based distro's
* 3. Look for microsoft-edge-stable & microsoft-edge executables by using the which command
*/
function linux() {
let installations = [];
// 1. Look into EDGE_PATH env variable
const customEdgePath = resolveEdgePath();
if (customEdgePath) {
installations.push(customEdgePath);
}
// 2. Look into the directories where .desktop are saved on gnome based distro's
const desktopInstallationFolders = [
path.join((0, os_1.homedir)(), ".local/share/applications/"),
"/usr/share/applications/",
];
desktopInstallationFolders.forEach((folder) => {
installations = installations.concat(findEdgeExecutables(folder));
});
// Look for microsoft-edge(-stable) & chromium(-browser) executables by using the which command
const executables = [
"microsoft-edge-stable",
"microsoft-edge",
"chromium-browser",
"chromium",
];
executables.forEach((executable) => {
try {
const edgePath = (0, child_process_1.execFileSync)("which", [executable], { stdio: "pipe" })
.toString()
.split(newLineRegex)[0];
if (canAccess(edgePath)) {
installations.push(edgePath);
}
}
catch (e) {
// Not installed.
}
});
if (!installations.length) {
throw new utils_1.EdgePathNotSetError();
}
const priorities = [
{ regex: /edge-wrapper$/, weight: 51 },
{ regex: /microsoft-edge-stable$/, weight: 50 },
{ regex: /microsoft-edge$/, weight: 49 },
{ regex: /edge-browser$/, weight: 48 },
{ regex: /edge$/, weight: 47 },
];
if (process.env.LIGHTHOUSE_CHROMIUM_PATH) {
priorities.unshift({
regex: new RegExp(escapeRegExp(process.env.LIGHTHOUSE_CHROMIUM_PATH)),
weight: 100,
});
}
if (process.env.EDGE_PATH) {
priorities.unshift({
regex: new RegExp(escapeRegExp(process.env.EDGE_PATH)),
weight: 101,
});
}
return sort(uniq(installations.filter(Boolean)), priorities);
}
exports.linux = linux;
function wsl() {
// Manually populate the environment variables assuming it's the default config
process.env.LOCALAPPDATA = (0, utils_1.getLocalAppDataPath)(`${process.env.PATH}`);
process.env.PROGRAMFILES = "/mnt/c/Program Files";
process.env["PROGRAMFILES(X86)"] = "/mnt/c/Program Files (x86)";
return win32();
}
exports.wsl = wsl;
function win32() {
const installations = [];
const suffixes = [
`${path.sep}Microsoft${path.sep}Edge SxS${path.sep}Application${path.sep}msedge.exe`,
`${path.sep}Microsoft${path.sep}Edge${path.sep}Application${path.sep}msedge.exe`,
];
const prefixes = [
process.env.LOCALAPPDATA,
process.env.PROGRAMFILES,
process.env["PROGRAMFILES(X86)"],
].filter(Boolean);
const customEdgePath = resolveEdgePath();
if (customEdgePath) {
installations.push(customEdgePath);
}
prefixes.forEach((prefix) => suffixes.forEach((suffix) => {
const edgePath = path.join(prefix, suffix);
if (canAccess(edgePath)) {
installations.push(edgePath);
}
}));
return installations;
}
exports.win32 = win32;
function sort(installations, priorities) {
const defaultPriority = 10;
return (installations
// assign priorities
.map((inst) => {
for (const pair of priorities) {
if (pair.regex.test(inst)) {
return { path: inst, weight: pair.weight };
}
}
return { path: inst, weight: defaultPriority };
})
// sort based on priorities
.sort((a, b) => b.weight - a.weight)
// remove priority flag
.map((pair) => pair.path));
}
function canAccess(file) {
if (!file) {
return false;
}
try {
fs.accessSync(file);
return true;
}
catch (e) {
return false;
}
}
function uniq(arr) {
return Array.from(new Set(arr));
}
function findEdgeExecutables(folder) {
const argumentsRegex = /(^[^ ]+).*/; // Take everything up to the first space
const edgeExecRegex = "^Exec=/.*/(microsoft-edge|edge)-.*";
const installations = [];
if (canAccess(folder)) {
// Output of the grep & print looks like:
// /opt/google/edge/microsoft-edge --profile-directory
// /home/user/Downloads/edge-linux/edge-wrapper %U
let execPaths;
// Some systems do not support grep -R so fallback to -r.
// See https://github.com/GoogleChrome/chrome-launcher/issues/46 for more context.
try {
execPaths = (0, child_process_1.execSync)(`grep -ER "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: "pipe" });
}
catch (e) {
execPaths = (0, child_process_1.execSync)(`grep -Er "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: "pipe" });
}
execPaths = execPaths
.toString()
.split(newLineRegex)
.map((execPath) => execPath.replace(argumentsRegex, "$1"));
execPaths.forEach((execPath) => canAccess(execPath) && installations.push(execPath));
}
return installations;
}
//# sourceMappingURL=edge-finder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,72 @@
/// <reference types="node" />
/// <reference types="node" />
import type { ChildProcess } from "child_process";
import * as childProcess from "child_process";
import * as fs from "fs";
export type RimrafModule = (path: string, callback: (error: Error | null | undefined) => void) => void;
export type Options = {
startingUrl?: string;
edgeFlags?: string[];
port?: number;
handleSIGINT?: boolean;
edgePath?: string;
userDataDir?: string | boolean;
logLevel?: "verbose" | "info" | "error" | "silent";
ignoreDefaultFlags?: boolean;
connectionPollInterval?: number;
maxConnectionRetries?: number;
envVars?: Record<string, string | undefined>;
};
export type LaunchedEdge = {
pid: number;
port: number;
process: ChildProcess;
kill: () => Promise<void>;
};
export type ModuleOverrides = {
fs?: typeof fs;
rimraf?: RimrafModule;
spawn?: typeof childProcess.spawn;
};
declare function launch(opts?: Options): Promise<LaunchedEdge>;
declare function killAll(): Promise<Error[]>;
declare class Launcher {
private opts;
private tmpDirandPidFileReady;
private pidFile?;
private startingUrl;
private outFile?;
private errFile?;
private edgePath?;
private ignoreDefaultFlags?;
private edgeFlags;
private requestedPort?;
private connectionPollInterval;
private maxConnectionRetries;
private fs;
private rimraf;
private spawn;
private useDefaultProfile;
private envVars;
edge?: childProcess.ChildProcess;
userDataDir?: string;
port?: number;
pid?: number;
constructor(opts?: Options, moduleOverrides?: ModuleOverrides);
private get flags();
static defaultFlags(): string[];
/** Returns the highest priority edge installation. */
static getFirstInstallation(): string | undefined;
makeTmpDir(): string;
prepare(): void;
launch(): Promise<void>;
private spawnProcess;
private cleanup;
private isDebuggerReady;
waitUntilReady(): Promise<void>;
kill(): Promise<void>;
destroyTmp(): Promise<void>;
}
export default Launcher;
export { Launcher, killAll, launch };
//# sourceMappingURL=edge-launcher.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"edge-launcher.d.ts","sourceRoot":"","sources":["../src/edge-launcher.ts"],"names":[],"mappings":";;AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AA6BzB,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,KAChD,IAAI,CAAC;AAEV,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IACnD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC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E,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;gBAGH,IAAI,GAAE,OAAY,EAC1B,eAAe,GAAE,eAAoB;IAkCvC,OAAO,KAAK,KAAK,GAsBhB;IAED,MAAM,CAAC,YAAY;IAInB,sDAAsD;IACtD,MAAM,CAAC,oBAAoB;IAM3B,UAAU;IAIV,OAAO;IAmBD,MAAM;YA+BE,YAAY;IA+C1B,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,eAAe;IAevB,cAAc;IA2Cd,IAAI;IA+BJ,UAAU;CAuBX;AAGD,eAAe,QAAQ,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC"}

View File

@@ -0,0 +1,327 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.launch = exports.killAll = exports.Launcher = void 0;
const childProcess = __importStar(require("child_process"));
const fs = __importStar(require("fs"));
const net = __importStar(require("net"));
const rimraf = __importStar(require("rimraf"));
const edgeFinder = __importStar(require("./edge-finder"));
const flags_1 = require("./flags");
const random_port_1 = require("./random-port");
const utils_1 = require("./utils");
const log = require("lighthouse-logger");
const spawn = childProcess.spawn;
const execSync = childProcess.execSync;
const isWsl = (0, utils_1.getPlatform)() === "wsl";
const isWindows = (0, utils_1.getPlatform)() === "win32";
const _SIGINT = "SIGINT";
const _SIGINT_EXIT_CODE = 130;
const _SUPPORTED_PLATFORMS = new Set(["darwin", "linux", "win32", "wsl"]);
const instances = new Set();
const sigintListener = async () => {
await killAll();
process.exit(_SIGINT_EXIT_CODE);
};
async function launch(opts = {}) {
opts.handleSIGINT = (0, utils_1.defaults)(opts.handleSIGINT, true);
const instance = new Launcher(opts);
// Kill spawned Edge process in case of ctrl-C.
if (opts.handleSIGINT && instances.size === 0) {
process.on(_SIGINT, sigintListener);
}
instances.add(instance);
await instance.launch();
const kill = async () => {
instances.delete(instance);
if (instances.size === 0) {
process.removeListener(_SIGINT, sigintListener);
}
return instance.kill();
};
return {
pid: instance.pid,
port: instance.port,
kill,
process: instance.edge,
};
}
exports.launch = launch;
async function killAll() {
const errors = [];
for (const instance of instances) {
try {
await instance.kill();
// only delete if kill did not error
// this means erroring instances remain in the Set
instances.delete(instance);
}
catch (err) {
errors.push(err);
}
}
return errors;
}
exports.killAll = killAll;
class Launcher {
constructor(opts = {}, moduleOverrides = {}) {
this.opts = opts;
this.tmpDirandPidFileReady = false;
this.fs = moduleOverrides.fs || fs;
this.rimraf = moduleOverrides.rimraf || rimraf.default;
this.spawn = moduleOverrides.spawn || spawn;
log.setLevel((0, utils_1.defaults)(this.opts.logLevel, "silent"));
// choose the first one (default)
this.startingUrl = (0, utils_1.defaults)(this.opts.startingUrl, "about:blank");
this.edgeFlags = (0, utils_1.defaults)(this.opts.edgeFlags, []);
this.requestedPort = (0, utils_1.defaults)(this.opts.port, 0);
this.edgePath = this.opts.edgePath;
this.ignoreDefaultFlags = (0, utils_1.defaults)(this.opts.ignoreDefaultFlags, false);
this.connectionPollInterval = (0, utils_1.defaults)(this.opts.connectionPollInterval, 500);
this.maxConnectionRetries = (0, utils_1.defaults)(this.opts.maxConnectionRetries, 50);
this.envVars = (0, utils_1.defaults)(opts.envVars, Object.assign({}, process.env));
if (typeof this.opts.userDataDir === "boolean") {
if (!this.opts.userDataDir) {
this.useDefaultProfile = true;
this.userDataDir = undefined;
}
else {
throw new utils_1.InvalidUserDataDirectoryError();
}
}
else {
this.useDefaultProfile = false;
this.userDataDir = this.opts.userDataDir;
}
}
get flags() {
const flags = this.ignoreDefaultFlags ? [] : flags_1.DEFAULT_FLAGS.slice();
flags.push(`--remote-debugging-port=${this.port}`);
if (!this.ignoreDefaultFlags && (0, utils_1.getPlatform)() === "linux") {
flags.push("--disable-setuid-sandbox");
}
if (!this.useDefaultProfile) {
// Place Edge profile in a custom location we'll rm -rf later
// If in WSL, we need to use the Windows format
flags.push(`--user-data-dir=${isWsl ? (0, utils_1.toWinDirFormat)(this.userDataDir) : this.userDataDir}`);
}
flags.push(...this.edgeFlags);
flags.push(this.startingUrl);
return flags;
}
static defaultFlags() {
return flags_1.DEFAULT_FLAGS.slice();
}
/** Returns the highest priority edge installation. */
static getFirstInstallation() {
if ((0, utils_1.getPlatform)() === "darwin")
return edgeFinder.darwinFast();
return edgeFinder[(0, utils_1.getPlatform)()]()[0];
}
// Wrapper function to enable easy testing.
makeTmpDir() {
return (0, utils_1.makeTmpDir)();
}
prepare() {
const platform = (0, utils_1.getPlatform)();
if (!_SUPPORTED_PLATFORMS.has(platform)) {
throw new utils_1.UnsupportedPlatformError();
}
this.userDataDir = this.userDataDir || this.makeTmpDir();
this.outFile = this.fs.openSync(`${this.userDataDir}/edge-out.log`, "a");
this.errFile = this.fs.openSync(`${this.userDataDir}/edge-err.log`, "a");
// fix for Node4
// you can't pass a fd to fs.writeFileSync
this.pidFile = `${this.userDataDir}/edge.pid`;
log.verbose("EdgeLauncher", `created ${this.userDataDir}`);
this.tmpDirandPidFileReady = true;
}
async launch() {
if (this.requestedPort !== 0) {
this.port = this.requestedPort;
// If an explict port is passed first look for an open connection...
try {
return await this.isDebuggerReady();
}
catch (err) {
log.log("EdgeLauncher", `No debugging port found on port ${this.port}, launching a new Edge.`);
}
}
if (this.edgePath === undefined) {
const installation = Launcher.getFirstInstallation();
if (!installation) {
throw new utils_1.EdgeNotInstalledError();
}
this.edgePath = installation;
}
if (!this.tmpDirandPidFileReady) {
this.prepare();
}
this.pid = await this.spawnProcess(this.edgePath);
return Promise.resolve();
}
async spawnProcess(execPath) {
const spawnPromise = (async () => {
if (this.edge) {
log.log("EdgeLauncher", `Edge already running with pid ${this.edge.pid}.`);
return this.edge.pid;
}
// If a zero value port is set, it means the launcher
// is responsible for generating the port number.
// We do this here so that we can know the port before
// we pass it into edge.
if (this.requestedPort === 0) {
this.port = await (0, random_port_1.getRandomPort)();
}
log.verbose("EdgeLauncher", `Launching with command:\n"${execPath}" ${this.flags.join(" ")}`);
console.trace("EdgeLauncher", `Launching with command:\n"${execPath}" ${this.flags.join(" ")}`);
const edge = this.spawn(execPath, this.flags, {
detached: true,
stdio: ["ignore", this.outFile, this.errFile],
env: this.envVars,
});
this.edge = edge;
this.fs.writeFileSync(this.pidFile, edge.pid.toString());
log.verbose("EdgeLauncher", `Edge running with pid ${edge.pid} on port ${this.port}.`);
return edge.pid;
})();
const pid = await spawnPromise;
await this.waitUntilReady();
return pid;
}
cleanup(client) {
if (client) {
client.removeAllListeners();
client.end();
client.destroy();
client.unref();
}
}
// resolves if ready, rejects otherwise
isDebuggerReady() {
return new Promise((resolve, reject) => {
const client = net.createConnection(this.port);
client.once("error", (err) => {
this.cleanup(client);
reject(err);
});
client.once("connect", () => {
this.cleanup(client);
resolve();
});
});
}
// resolves when debugger is ready, rejects after 10 polls
waitUntilReady() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const launcher = this;
return new Promise((resolve, reject) => {
let retries = 0;
let waitStatus = "Waiting for browser.";
const poll = () => {
if (retries === 0) {
log.log("EdgeLauncher", waitStatus);
}
retries++;
waitStatus += "..";
log.log("EdgeLauncher", waitStatus);
launcher
.isDebuggerReady()
.then(() => {
log.log("EdgeLauncher", waitStatus + `${log.greenify(log.tick)}`);
resolve();
})
.catch((err) => {
if (retries > launcher.maxConnectionRetries) {
log.error("EdgeLauncher", err.message);
const stderr = this.fs.readFileSync(`${this.userDataDir}/edge-err.log`, { encoding: "utf-8" });
log.error("EdgeLauncher", `Logging contents of ${this.userDataDir}/edge-err.log`);
log.error("EdgeLauncher", stderr);
return reject(err);
}
(0, utils_1.delay)(launcher.connectionPollInterval).then(poll);
});
};
poll();
});
}
kill() {
return new Promise((resolve, reject) => {
if (this.edge) {
this.edge.on("close", () => {
delete this.edge;
this.destroyTmp().then(resolve);
});
log.log("EdgeLauncher", `Killing Edge instance ${this.edge.pid}`);
try {
if (isWindows) {
// While pipe is the default, stderr also gets printed to process.stderr
// if you don't explicitly set `stdio`
execSync(`taskkill /pid ${this.edge.pid} /T /F`, { stdio: "pipe" });
}
else {
process.kill(-this.edge.pid);
}
}
catch (err) {
const message = `Edge could not be killed ${err !== null && err !== void 0 ? err : err.message}`;
log.warn("EdgeLauncher", message);
reject(new Error(message));
}
}
else {
// fail silently as we did not start edge
resolve();
}
});
}
destroyTmp() {
return new Promise((resolve) => {
// Only clean up the tmp dir if we created it.
if (this.userDataDir === undefined ||
this.opts.userDataDir !== undefined) {
return resolve();
}
if (this.outFile) {
this.fs.closeSync(this.outFile);
delete this.outFile;
}
if (this.errFile) {
this.fs.closeSync(this.errFile);
delete this.errFile;
}
this.rimraf(this.userDataDir, () => resolve());
});
}
}
exports.Launcher = Launcher;
// eslint-disable-next-line no-restricted-exports
exports.default = Launcher;
//# sourceMappingURL=edge-launcher.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare const DEFAULT_FLAGS: readonly string[];
//# sourceMappingURL=flags.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAwC1C,CAAC"}

View File

@@ -0,0 +1,51 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_FLAGS = void 0;
// https://github.com/cezaraugusto/chromium-edge-launcher/blob/master/docs/edge-flags-for-tools.md
exports.DEFAULT_FLAGS = [
// Disable built-in Google Translate service
"--disable-features=Translate",
// Disable all edge extensions
"--disable-extensions",
// Disable some extensions that aren't affected by --disable-extensions
"--disable-component-extensions-with-background-pages",
// Disable various background network services, including extension updating,
// safe browsing service, upgrade detector, translate, UMA
"--disable-background-networking",
// Don't update the browser 'components' listed at edge://components/
"--disable-component-update",
// Disables client-side phishing detection.
"--disable-client-side-phishing-detection",
// Disable syncing to a Google account
"--disable-sync",
// Disable reporting to UMA, but allows for collection
"--metrics-recording-only",
// Disable installation of default apps on first run
"--disable-default-apps",
// Mute any audio
"--mute-audio",
// Disable the default browser check, do not prompt to set it as such
"--no-default-browser-check",
// Skip first run wizards
"--no-first-run",
// Disable backgrounding renders for occluded windows
"--disable-backgrounding-occluded-windows",
// Disable renderer process backgrounding
"--disable-renderer-backgrounding",
// Disable task throttling of timer tasks from background pages.
"--disable-background-timer-throttling",
// Disable the default throttling of IPC between renderer & browser processes.
"--disable-ipc-flooding-protection",
// Avoid potential instability of using Gnome Keyring or KDE wallet. crbug.com/571003 crbug.com/991424
"--password-store=basic",
// Use mock keychain on Mac to prevent blocking permissions dialogs
"--use-mock-keychain",
// Disable background tracing (aka slow reports & deep reports) to avoid 'Tracing already started'
"--force-fieldtrials=*BackgroundTracing/default/",
];
//# sourceMappingURL=flags.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;AAEb,kGAAkG;AAErF,QAAA,aAAa,GAAsB;IAC9C,4CAA4C;IAC5C,8BAA8B;IAC9B,8BAA8B;IAC9B,sBAAsB;IACtB,uEAAuE;IACvE,sDAAsD;IACtD,6EAA6E;IAC7E,4DAA4D;IAC5D,iCAAiC;IACjC,qEAAqE;IACrE,4BAA4B;IAC5B,2CAA2C;IAC3C,0CAA0C;IAC1C,sCAAsC;IACtC,gBAAgB;IAChB,sDAAsD;IACtD,0BAA0B;IAC1B,oDAAoD;IACpD,wBAAwB;IACxB,iBAAiB;IACjB,cAAc;IACd,qEAAqE;IACrE,4BAA4B;IAC5B,yBAAyB;IACzB,gBAAgB;IAChB,qDAAqD;IACrD,0CAA0C;IAC1C,yCAAyC;IACzC,kCAAkC;IAClC,gEAAgE;IAChE,uCAAuC;IACvC,8EAA8E;IAC9E,mCAAmC;IACnC,sGAAsG;IACtG,wBAAwB;IACxB,mEAAmE;IACnE,qBAAqB;IACrB,kGAAkG;IAClG,iDAAiD;CAClD,CAAC"}

View File

@@ -0,0 +1,3 @@
export { Launcher, killAll, launch } from "./edge-launcher";
export type { LaunchedEdge, ModuleOverrides, Options, RimrafModule, } from "./edge-launcher";
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EACV,YAAY,EACZ,eAAe,EACf,OAAO,EACP,YAAY,GACb,MAAM,iBAAiB,CAAC"}

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.launch = exports.killAll = exports.Launcher = void 0;
var edge_launcher_1 = require("./edge-launcher");
Object.defineProperty(exports, "Launcher", { enumerable: true, get: function () { return edge_launcher_1.Launcher; } });
Object.defineProperty(exports, "killAll", { enumerable: true, get: function () { return edge_launcher_1.killAll; } });
Object.defineProperty(exports, "launch", { enumerable: true, get: function () { return edge_launcher_1.launch; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA4D;AAAnD,yGAAA,QAAQ,OAAA;AAAE,wGAAA,OAAO,OAAA;AAAE,uGAAA,MAAM,OAAA"}

View File

@@ -0,0 +1,5 @@
/**
* Return a random, unused port.
*/
export declare function getRandomPort(): Promise<number>;
//# sourceMappingURL=random-port.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"random-port.d.ts","sourceRoot":"","sources":["../src/random-port.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAU/C"}

View File

@@ -0,0 +1,25 @@
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRandomPort = void 0;
const http_1 = require("http");
/**
* Return a random, unused port.
*/
function getRandomPort() {
return new Promise((resolve, reject) => {
const server = (0, http_1.createServer)();
server.listen(0);
server.once("listening", () => {
const { port } = server.address();
server.close(() => resolve(port));
});
server.once("error", reject);
});
}
exports.getRandomPort = getRandomPort;
//# sourceMappingURL=random-port.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"random-port.js","sourceRoot":"","sources":["../src/random-port.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;AAEb,+BAAoC;AAGpC;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;YAC5B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;YACjD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,sCAUC"}

View File

@@ -0,0 +1,2 @@
export type FakeMethod = (message: string) => string;
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC"}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,35 @@
/// <reference types="node" />
export declare const enum LaunchErrorCodes {
ERR_LAUNCHER_PATH_NOT_SET = "ERR_LAUNCHER_PATH_NOT_SET",
ERR_LAUNCHER_INVALID_USER_DATA_DIRECTORY = "ERR_LAUNCHER_INVALID_USER_DATA_DIRECTORY",
ERR_LAUNCHER_UNSUPPORTED_PLATFORM = "ERR_LAUNCHER_UNSUPPORTED_PLATFORM",
ERR_LAUNCHER_NOT_INSTALLED = "ERR_LAUNCHER_NOT_INSTALLED"
}
export declare function defaults<T>(val: T | undefined, def: T): T;
export declare function delay(time: number): Promise<unknown>;
export declare class LauncherError extends Error {
message: string;
code?: string | undefined;
constructor(message?: string, code?: string | undefined);
}
export declare class EdgePathNotSetError extends LauncherError {
message: string;
code: LaunchErrorCodes;
}
export declare class InvalidUserDataDirectoryError extends LauncherError {
message: string;
code: LaunchErrorCodes;
}
export declare class UnsupportedPlatformError extends LauncherError {
message: string;
code: LaunchErrorCodes;
}
export declare class EdgeNotInstalledError extends LauncherError {
message: string;
code: LaunchErrorCodes;
}
export declare function getPlatform(): "wsl" | NodeJS.Platform;
export declare function makeTmpDir(): string;
export declare function toWinDirFormat(dir?: string): string;
export declare function getLocalAppDataPath(path: string): string;
//# sourceMappingURL=utils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAaA,0BAAkB,gBAAgB;IAChC,yBAAyB,8BAA8B;IACvD,wCAAwC,6CAA6C;IACrF,iCAAiC,sCAAsC;IACvE,0BAA0B,+BAA+B;CAC1D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAEzD;AAED,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,oBAEvC;AAED,qBAAa,aAAc,SAAQ,KAAK;IAEpB,OAAO;IAChB,IAAI,CAAC;gBADI,OAAO,SAAqB,EACrC,IAAI,CAAC,oBAAQ;CAMvB;AAED,qBAAa,mBAAoB,SAAQ,aAAa;IAC3C,OAAO,SAC4F;IACnG,IAAI,mBAA8C;CAC5D;AAED,qBAAa,6BAA8B,SAAQ,aAAa;IACrD,OAAO,SAA0C;IACjD,IAAI,mBAA6D;CAC3E;AAED,qBAAa,wBAAyB,SAAQ,aAAa;IAChD,OAAO,SAAiD;IACxD,IAAI,mBAAsD;CACpE;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IAC7C,OAAO,SAAkC;IACzC,IAAI,mBAA+C;CAC7D;AAED,wBAAgB,WAAW,4BAE1B;AAED,wBAAgB,UAAU,WAezB;AAED,wBAAgB,cAAc,CAAC,GAAG,SAAK,GAAG,MAAM,CAU/C;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKxD"}

View File

@@ -0,0 +1,144 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocalAppDataPath = exports.toWinDirFormat = exports.makeTmpDir = exports.getPlatform = exports.EdgeNotInstalledError = exports.UnsupportedPlatformError = exports.InvalidUserDataDirectoryError = exports.EdgePathNotSetError = exports.LauncherError = exports.delay = exports.defaults = exports.LaunchErrorCodes = void 0;
const child_process_1 = require("child_process");
const mkdirp = __importStar(require("mkdirp"));
const path_1 = require("path");
const isWsl = require("is-wsl");
// eslint-disable-next-line @rnx-kit/no-const-enum
var LaunchErrorCodes;
(function (LaunchErrorCodes) {
LaunchErrorCodes["ERR_LAUNCHER_PATH_NOT_SET"] = "ERR_LAUNCHER_PATH_NOT_SET";
LaunchErrorCodes["ERR_LAUNCHER_INVALID_USER_DATA_DIRECTORY"] = "ERR_LAUNCHER_INVALID_USER_DATA_DIRECTORY";
LaunchErrorCodes["ERR_LAUNCHER_UNSUPPORTED_PLATFORM"] = "ERR_LAUNCHER_UNSUPPORTED_PLATFORM";
LaunchErrorCodes["ERR_LAUNCHER_NOT_INSTALLED"] = "ERR_LAUNCHER_NOT_INSTALLED";
})(LaunchErrorCodes || (exports.LaunchErrorCodes = LaunchErrorCodes = {}));
function defaults(val, def) {
return typeof val === "undefined" ? def : val;
}
exports.defaults = defaults;
async function delay(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
exports.delay = delay;
class LauncherError extends Error {
constructor(message = "Unexpected error", code) {
super();
this.message = message;
this.code = code;
this.stack = new Error().stack;
return this;
}
}
exports.LauncherError = LauncherError;
class EdgePathNotSetError extends LauncherError {
constructor() {
super(...arguments);
this.message = "The EDGE_PATH environment variable must be set to a Edge/Chromium executable no older than Edge stable.";
this.code = LaunchErrorCodes.ERR_LAUNCHER_PATH_NOT_SET;
}
}
exports.EdgePathNotSetError = EdgePathNotSetError;
class InvalidUserDataDirectoryError extends LauncherError {
constructor() {
super(...arguments);
this.message = "userDataDir must be false or a path.";
this.code = LaunchErrorCodes.ERR_LAUNCHER_INVALID_USER_DATA_DIRECTORY;
}
}
exports.InvalidUserDataDirectoryError = InvalidUserDataDirectoryError;
class UnsupportedPlatformError extends LauncherError {
constructor() {
super(...arguments);
this.message = `Platform ${getPlatform()} is not supported.`;
this.code = LaunchErrorCodes.ERR_LAUNCHER_UNSUPPORTED_PLATFORM;
}
}
exports.UnsupportedPlatformError = UnsupportedPlatformError;
class EdgeNotInstalledError extends LauncherError {
constructor() {
super(...arguments);
this.message = "No Edge installations found.";
this.code = LaunchErrorCodes.ERR_LAUNCHER_NOT_INSTALLED;
}
}
exports.EdgeNotInstalledError = EdgeNotInstalledError;
function getPlatform() {
return isWsl ? "wsl" : process.platform;
}
exports.getPlatform = getPlatform;
function makeTmpDir() {
switch (getPlatform()) {
case "darwin":
case "linux":
return makeUnixTmpDir();
// @ts-expect-error - Fallthrough case in switch.
case "wsl":
// We populate the user's Windows temp dir so the folder is correctly created later
process.env.TEMP = getLocalAppDataPath(`${process.env.PATH}`);
// falls through
case "win32":
return makeWin32TmpDir();
default:
throw new UnsupportedPlatformError();
}
}
exports.makeTmpDir = makeTmpDir;
function toWinDirFormat(dir = "") {
const results = /\/mnt\/([a-z])\//.exec(dir);
if (!results) {
return dir;
}
const driveLetter = results[1];
return dir
.replace(`/mnt/${driveLetter}/`, `${driveLetter.toUpperCase()}:\\`)
.replace(/\//g, "\\");
}
exports.toWinDirFormat = toWinDirFormat;
function getLocalAppDataPath(path) {
const userRegExp = /\/mnt\/([a-z])\/Users\/([^/:]+)\/AppData\//;
const results = userRegExp.exec(path) || [];
return `/mnt/${results[1]}/Users/${results[2]}/AppData/Local`;
}
exports.getLocalAppDataPath = getLocalAppDataPath;
function makeUnixTmpDir() {
return (0, child_process_1.execSync)("mktemp -d -t lighthouse.XXXXXXX").toString().trim();
}
function makeWin32TmpDir() {
const winTmpPath = process.env.TEMP ||
process.env.TMP ||
(process.env.SystemRoot || process.env.windir) + "\\temp";
const randomNumber = Math.floor(Math.random() * 9e7 + 1e7);
const tmpdir = (0, path_1.join)(winTmpPath, "lighthouse." + randomNumber);
mkdirp.sync(tmpdir);
return tmpdir;
}
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,iDAAyC;AACzC,+CAAiC;AACjC,+BAA4B;AAC5B,gCAAiC;AAEjC,kDAAkD;AAClD,IAAkB,gBAKjB;AALD,WAAkB,gBAAgB;IAChC,2EAAuD,CAAA;IACvD,yGAAqF,CAAA;IACrF,2FAAuE,CAAA;IACvE,6EAAyD,CAAA;AAC3D,CAAC,EALiB,gBAAgB,gCAAhB,gBAAgB,QAKjC;AAED,SAAgB,QAAQ,CAAI,GAAkB,EAAE,GAAM;IACpD,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAChD,CAAC;AAFD,4BAEC;AAEM,KAAK,UAAU,KAAK,CAAC,IAAY;IACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7D,CAAC;AAFD,sBAEC;AAED,MAAa,aAAc,SAAQ,KAAK;IACtC,YACkB,UAAU,kBAAkB,EACrC,IAAa;QAEpB,KAAK,EAAE,CAAC;QAHQ,YAAO,GAAP,OAAO,CAAqB;QACrC,SAAI,GAAJ,IAAI,CAAS;QAGpB,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AATD,sCASC;AAED,MAAa,mBAAoB,SAAQ,aAAa;IAAtD;;QACW,YAAO,GACd,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MENTAL - USE WITH CAUTION - Launch latest Edge with the Devtools Protocol port open",
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/incubator/chromium-edge-launcher#readme",
"license": "Apache-2.0",
"author": {
"name": "Microsoft Open Source",
"email": "microsoftopensource@users.noreply.github.com"
},
"files": [
"lib/*"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/rnx-kit",
"directory": "incubator/chromium-edge-launcher"
},
"engines": {
"node": ">=14.15"
},
"scripts": {
"build": "rnx-kit-scripts build",
"format": "rnx-kit-scripts format",
"lint": "rnx-kit-scripts lint",
"test": "rnx-kit-scripts test"
},
"dependencies": {
"@types/node": "^18.0.0",
"escape-string-regexp": "^4.0.0",
"is-wsl": "^2.2.0",
"lighthouse-logger": "^1.0.0",
"mkdirp": "^1.0.4",
"rimraf": "^3.0.2"
},
"devDependencies": {
"@rnx-kit/eslint-config": "*",
"@rnx-kit/jest-preset": "*",
"@rnx-kit/scripts": "*",
"@types/mkdirp": "^1.0.1",
"@types/rimraf": "^3.0.0",
"@types/sinon": "^9.0.1",
"eslint": "^8.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"sinon": "^9.0.1",
"typescript": "^5.0.0"
},
"jest": {
"preset": "@rnx-kit/jest-preset/private"
},
"experimental": true
}