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,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,G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IACrC,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,OAAO,CAAqC;IAEpD,IAAI,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC;IACjC,WAAW,CAAC,EAAE,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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