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,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.KeyPressHandler = void 0;
var _cliTools = require("@react-native-community/cli-tools");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
const CTRL_C = "\u0003";
/** An abstract key stroke interceptor. */
class KeyPressHandler {
_isInterceptingKeyStrokes = false;
_isHandlingKeyPress = false;
constructor(onPress) {
this._onPress = onPress;
}
/** Start observing interaction pause listeners. */
createInteractionListener() {
// Support observing prompts.
let wasIntercepting = false;
const listener = ({ pause }) => {
if (pause) {
// Track if we were already intercepting key strokes before pausing, so we can
// resume after pausing.
wasIntercepting = this._isInterceptingKeyStrokes;
this.stopInterceptingKeyStrokes();
} else if (wasIntercepting) {
// Only start if we were previously intercepting.
this.startInterceptingKeyStrokes();
}
};
return listener;
}
_handleKeypress = async (key) => {
// Prevent sending another event until the previous event has finished.
if (this._isHandlingKeyPress && key !== CTRL_C) {
return;
}
this._isHandlingKeyPress = true;
try {
_cliTools.logger.debug(`Key pressed: ${key}`);
await this._onPress(key);
} catch (error) {
return new _cliTools.CLIError(
"There was an error with the key press handler."
);
} finally {
this._isHandlingKeyPress = false;
}
};
/** Start intercepting all key strokes and passing them to the input `onPress` method. */
startInterceptingKeyStrokes() {
if (this._isInterceptingKeyStrokes) {
return;
}
this._isInterceptingKeyStrokes = true;
const { stdin } = process;
// $FlowFixMe[prop-missing]
stdin.setRawMode(true);
stdin.resume();
stdin.setEncoding("utf8");
stdin.on("data", this._handleKeypress);
}
/** Stop intercepting all key strokes. */
stopInterceptingKeyStrokes() {
if (!this._isInterceptingKeyStrokes) {
return;
}
this._isInterceptingKeyStrokes = false;
const { stdin } = process;
stdin.removeListener("data", this._handleKeypress);
// $FlowFixMe[prop-missing]
stdin.setRawMode(false);
stdin.resume();
}
}
exports.KeyPressHandler = KeyPressHandler;

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
/** An abstract key stroke interceptor. */
declare export class KeyPressHandler {
_isInterceptingKeyStrokes: $FlowFixMe;
_isHandlingKeyPress: $FlowFixMe;
_onPress: (key: string) => Promise<void>;
constructor(onPress: (key: string) => Promise<void>): void;
createInteractionListener(): ({ pause: boolean, ... }) => void;
_handleKeypress: $FlowFixMe;
startInterceptingKeyStrokes(): void;
stopInterceptingKeyStrokes(): void;
}

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = isDevServerRunning;
var _net = _interopRequireDefault(require("net"));
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* Determine whether we can run the dev server.
*
* Return values:
* - `not_running`: The port is unoccupied.
* - `matched_server_running`: The port is occupied by another instance of this
* dev server (matching the passed `projectRoot`).
* - `port_taken`: The port is occupied by another process.
* - `unknown`: An error was encountered; attempt server creation anyway.
*/
async function isDevServerRunning(devServerUrl, projectRoot) {
const { hostname, port } = new URL(devServerUrl);
try {
if (!(await isPortOccupied(hostname, port))) {
return "not_running";
}
const statusResponse = await (0, _nodeFetch.default)(
`${devServerUrl}/status`
);
const body = await statusResponse.text();
return body === "packager-status:running" &&
statusResponse.headers.get("X-React-Native-Project-Root") === projectRoot
? "matched_server_running"
: "port_taken";
} catch (e) {
return "unknown";
}
}
async function isPortOccupied(hostname, port) {
let result = false;
const server = _net.default.createServer();
return new Promise((resolve, reject) => {
server.once("error", (e) => {
server.close();
if (e.code === "EADDRINUSE") {
result = true;
} else {
reject(e);
}
});
server.once("listening", () => {
result = false;
server.close();
});
server.once("close", () => {
resolve(result);
});
server.listen({
host: hostname,
port,
});
});
}

View File

@@ -0,0 +1,25 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
/**
* Determine whether we can run the dev server.
*
* Return values:
* - `not_running`: The port is unoccupied.
* - `matched_server_running`: The port is occupied by another instance of this
* dev server (matching the passed `projectRoot`).
* - `port_taken`: The port is occupied by another process.
* - `unknown`: An error was encountered; attempt server creation anyway.
*/
declare export default function isDevServerRunning(
devServerUrl: string,
projectRoot: string
): Promise<"not_running" | "matched_server_running" | "port_taken" | "unknown">;

View File

@@ -0,0 +1,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = loadMetroConfig;
var _metroPlatformResolver = require("./metroPlatformResolver");
var _cliTools = require("@react-native-community/cli-tools");
var _metroConfig = require("metro-config");
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* Get the config options to override based on RN CLI inputs.
*/
function getOverrideConfig(ctx, config) {
const outOfTreePlatforms = Object.keys(ctx.platforms).filter(
(platform) => ctx.platforms[platform].npmPackageName
);
const resolver = {
platforms: [...Object.keys(ctx.platforms), "native"],
};
if (outOfTreePlatforms.length) {
resolver.resolveRequest = (0,
_metroPlatformResolver.reactNativePlatformResolver)(
outOfTreePlatforms.reduce((result, platform) => {
result[platform] = ctx.platforms[platform].npmPackageName;
return result;
}, {}),
config.resolver?.resolveRequest
);
}
return {
resolver,
serializer: {
// We can include multiple copies of InitializeCore here because metro will
// only add ones that are already part of the bundle
getModulesRunBeforeMainModule: () => [
require.resolve(
_path.default.join(
ctx.reactNativePath,
"Libraries/Core/InitializeCore"
),
{
paths: [ctx.root],
}
),
...outOfTreePlatforms.map((platform) =>
require.resolve(
`${ctx.platforms[platform].npmPackageName}/Libraries/Core/InitializeCore`,
{
paths: [ctx.root],
}
)
),
],
},
};
}
/**
* Load Metro config.
*
* Allows the CLI to override select values in `metro.config.js` based on
* dynamic user options in `ctx`.
*/
async function loadMetroConfig(ctx, options = {}) {
const cwd = ctx.root;
const projectConfig = await (0, _metroConfig.resolveConfig)(
options.config,
cwd
);
if (projectConfig.isEmpty) {
throw new _cliTools.CLIError(`No Metro config found in ${cwd}`);
}
_cliTools.logger.debug(`Reading Metro config from ${projectConfig.filepath}`);
if (!global.__REACT_NATIVE_METRO_CONFIG_LOADED) {
for (const line of `
=================================================================================================
From React Native 0.73, your project's Metro config should extend '@react-native/metro-config'
or it will fail to build. Please copy the template at:
https://github.com/facebook/react-native/blob/main/packages/react-native/template/metro.config.js
This warning will be removed in future (https://github.com/facebook/metro/issues/1018).
=================================================================================================
`
.trim()
.split("\n")) {
_cliTools.logger.warn(line);
}
}
const config = await (0, _metroConfig.loadConfig)({
cwd,
...options,
});
const overrideConfig = getOverrideConfig(ctx, config);
return (0, _metroConfig.mergeConfig)(config, overrideConfig);
}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
import type { Config } from "@react-native-community/cli-types";
import type { ConfigT, YargArguments } from "metro-config";
export type { Config };
export type ConfigLoadingContext = $ReadOnly<{
root: Config["root"],
reactNativePath: Config["reactNativePath"],
platforms: Config["platforms"],
...
}>;
/**
* Load Metro config.
*
* Allows the CLI to override select values in `metro.config.js` based on
* dynamic user options in `ctx`.
*/
declare export default function loadMetroConfig(
ctx: ConfigLoadingContext,
options: YargArguments
): Promise<ConfigT>;

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.reactNativePlatformResolver = reactNativePlatformResolver;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
/**
* This is an implementation of a metro resolveRequest option which will remap react-native imports
* to different npm packages based on the platform requested. This allows a single metro instance/config
* to produce bundles for multiple out of tree platforms at a time.
*
* @param platformImplementations
* A map of platform to npm package that implements that platform
*
* Ex:
* {
* windows: 'react-native-windows'
* macos: 'react-native-macos'
* }
*/
function reactNativePlatformResolver(platformImplementations, customResolver) {
return (context, moduleName, platform) => {
let modifiedModuleName = moduleName;
if (platform != null && platformImplementations[platform]) {
if (moduleName === "react-native") {
modifiedModuleName = platformImplementations[platform];
} else if (moduleName.startsWith("react-native/")) {
modifiedModuleName = `${
platformImplementations[platform]
}/${modifiedModuleName.slice("react-native/".length)}`;
}
}
if (customResolver) {
return customResolver(context, modifiedModuleName, platform);
}
return context.resolveRequest(context, modifiedModuleName, platform);
};
}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
import type { CustomResolver } from "metro-resolver";
/**
* This is an implementation of a metro resolveRequest option which will remap react-native imports
* to different npm packages based on the platform requested. This allows a single metro instance/config
* to produce bundles for multiple out of tree platforms at a time.
*
* @param platformImplementations
* A map of platform to npm package that implements that platform
*
* Ex:
* {
* windows: 'react-native-windows'
* macos: 'react-native-macos'
* }
*/
declare export function reactNativePlatformResolver(
platformImplementations: {
[platform: string]: string,
},
customResolver: ?CustomResolver
): CustomResolver;

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = parseKeyValueParamArray;
var _querystring = _interopRequireDefault(require("querystring"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
function parseKeyValueParamArray(keyValueArray) {
const result = {};
for (const item of keyValueArray) {
if (item.indexOf("=") === -1) {
throw new Error('Expected parameter to include "=" but found: ' + item);
}
if (item.indexOf("&") !== -1) {
throw new Error('Parameter cannot include "&" but found: ' + item);
}
Object.assign(result, _querystring.default.parse(item));
}
return result;
}

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
declare export default function parseKeyValueParamArray(
keyValueArray: $ReadOnlyArray<string>
): Record<string, string>;