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,22 @@
The MIT License (MIT)
Copyright (c) 2015 650 Industries
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,77 @@
# spawn-async [![Tests](https://github.com/expo/spawn-async/actions/workflows/main.yml/badge.svg)](https://github.com/expo/spawn-async/actions/workflows/main.yml)
A cross-platform version of Node's `child_process.spawn` as an async function that returns a promise. Supports Node 12 LTS and up.
## Usage:
```js
import spawnAsync from '@expo/spawn-async';
(async function () {
let resultPromise = spawnAsync('echo', ['hello', 'world']);
let spawnedChildProcess = resultPromise.child;
try {
let {
pid,
output: [stdout, stderr],
stdout,
stderr,
status,
signal,
} = await resultPromise;
} catch (e) {
console.error(e.stack);
// The error object also has the same properties as the result object
}
})();
```
## API
`spawnAsync` takes the same arguments as [`child_process.spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). Its options are the same as those of `child_process.spawn` plus:
- `ignoreStdio`: whether to ignore waiting for the child process's stdio streams to close before resolving the result promise. When ignoring stdio, the returned values for `stdout` and `stderr` will be empty strings. The default value of this option is `false`.
- `maxBuffer`: the maximum bytes retained from `stdout` and `stderr` (independently). Output is collected with a sliding window. When set explicitly, exceeding it rejects the promise with an error whose `code` is `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` and whose `stdout`/`stderr` carry the truncated tail. When omitted, the default is `buffer.constants.MAX_STRING_LENGTH` (~512 MiB).
It returns a promise whose result is an object with these properties:
- `pid`: the process ID of the spawned child process
- `output`: an array with stdout and stderr's output
- `stdout`: a string of what the child process wrote to stdout
- `stderr`: a string of what the child process wrote to stderr
- `status`: the exit code of the child process
- `signal`: the signal (ex: `SIGTERM`) used to stop the child process if it did not exit on its own
If there's an error running the child process or it exits with a non-zero status code, `spawnAsync` rejects the returned promise. The Error object also has the properties listed above.
### Accessing the child process
Sometimes you may want to access the child process object--for example, if you wanted to attach event handlers to `stdio` or `stderr` and process data as it is available instead of waiting for the process to be resolved.
You can do this by accessing `.child` on the Promise that is returned by `spawnAsync`.
Here is an example:
```js
(async () => {
let ffmpeg$ = spawnAsync('ffmpeg', ['-i', 'path/to/source.flac', '-codec:a', 'libmp3lame', '-b:a', '320k', '-ar', '44100', 'path/to/output.mp3']);
let childProcess = ffmpeg$.child;
childProcess.stdout.on('data', (data) => {
console.log(`ffmpeg stdout: ${data}`);
});
childProcess.stderr.on('data', (data) => {
console.error(`ffmpeg stderr: ${data}`);
});
let result = await ffmpeg$;
console.log(`ffmpeg pid ${result.pid} exited with code ${result.code}`);
})();
```
## Notes
### `maxBuffer`
`maxBuffer` is a later addition to the API. Set it when child output could exhaust memory and crash the parent process, or when the command or arguments are influenced by untrusted input — an attacker can otherwise force unbounded output to crash the parent.
The default of `buffer.constants.MAX_STRING_LENGTH` (~512 MiB) is a crash-safe floor, not a memory bound: at that size the materialized string itself can still exhaust process memory.
When `maxBuffer` is set explicitly, exceeding it rejects the promise immediately with `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`. When left at the default, exceeding it doesn't reject; the sliding-window tail is still readable, but reading `stdout`/`stderr` throws `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` with the truncated tail attached.

View File

@@ -0,0 +1,21 @@
/// <reference types="node" />
import { ChildProcess, SpawnOptions as NodeSpawnOptions } from 'child_process';
declare namespace spawnAsync {
interface SpawnOptions extends NodeSpawnOptions {
ignoreStdio?: boolean;
maxBuffer?: number;
}
interface SpawnPromise<T> extends Promise<T> {
child: ChildProcess;
}
interface SpawnResult {
pid?: number;
output: string[];
stdout: string;
stderr: string;
status: number | null;
signal: string | null;
}
}
declare function spawnAsync(command: string, args?: ReadonlyArray<string>, options?: spawnAsync.SpawnOptions): spawnAsync.SpawnPromise<spawnAsync.SpawnResult>;
export = spawnAsync;

View File

@@ -0,0 +1,154 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const buffer_1 = require("buffer");
const cross_spawn_1 = __importDefault(require("cross-spawn"));
const DEFAULT_MAX_BUFFER = buffer_1.constants.MAX_STRING_LENGTH;
function spawnAsync(command, args, options = {}) {
const stubError = new Error();
const callerStack = stubError.stack ? stubError.stack.replace(/^.*/, ' ...') : null;
const { ignoreStdio: optionsIgnoreStdio, maxBuffer: optionsMaxBuffer, ...nodeOptions } = options;
// NOTE(@kitten): When `maxBuffer` is set explicitly, we enforce it strictly
// and don't produce a result without it being strictly enforced
const enforceMaxBufferStrictly = optionsMaxBuffer != null;
const ignoreStdio = !!optionsIgnoreStdio;
const maxBuffer = Math.min(optionsMaxBuffer !== null && optionsMaxBuffer !== void 0 ? optionsMaxBuffer : DEFAULT_MAX_BUFFER, buffer_1.constants.MAX_STRING_LENGTH);
let child = (0, cross_spawn_1.default)(command, args, nodeOptions);
let promise = new Promise((resolve, reject) => {
var _a, _b;
const stdoutChunks = { buffer: [], maxExceeded: false };
const stderrChunks = { buffer: [], maxExceeded: false };
function makeHandler(chunks) {
let length = 0;
return (chunk) => {
chunks.buffer.push(chunk);
length += typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.byteLength;
while (chunks.buffer.length > 0 && length > maxBuffer) {
chunks.maxExceeded = true;
chunk = chunks.buffer[0];
const chunkLength = typeof chunk === 'string' ? Buffer.byteLength(chunk) : chunk.byteLength;
if (length - chunkLength < maxBuffer) {
const replacement = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
const excess = length - maxBuffer;
chunks.buffer[0] = replacement.subarray(excess);
length -= excess;
break;
}
else {
chunks.buffer.shift();
length -= chunkLength;
}
}
};
}
function attachResult(target, assign, stdoutChunks, stderrChunks, skipMaxBufferCheck) {
function makeMaxBufferError() {
const argumentString = args && args.length > 0 ? ` ${args.join(' ')}` : '';
const error = new Error(`${command}${argumentString} exceeded maxBuffer of ${maxBuffer} bytes`);
error.code = 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER';
return attachResult(error, assign, stdoutChunks, stderrChunks, true);
}
let _stdout;
let _stderr;
const map = {
stdout: {
enumerable: true,
configurable: true,
get() {
if (!skipMaxBufferCheck && stdoutChunks.maxExceeded) {
throw makeMaxBufferError();
}
else if (_stdout === undefined) {
_stdout = Buffer.concat(stdoutChunks.buffer.map((chunk) => typeof chunk === 'string' ? Buffer.from(chunk) : chunk)).toString('utf8');
}
return _stdout;
},
},
stderr: {
enumerable: true,
configurable: true,
get() {
if (!skipMaxBufferCheck && stderrChunks.maxExceeded) {
throw makeMaxBufferError();
}
else if (_stderr === undefined) {
_stderr = Buffer.concat(stderrChunks.buffer.map((chunk) => typeof chunk === 'string' ? Buffer.from(chunk) : chunk)).toString('utf8');
}
return _stderr;
},
},
output: {
enumerable: true,
configurable: true,
get: () => [target.stdout, target.stderr],
},
};
for (const key in assign) {
map[key] = {
value: assign[key],
enumerable: true,
writable: true,
configurable: true,
};
}
Object.defineProperties(target, map);
return target;
}
if (!ignoreStdio) {
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', makeHandler(stdoutChunks));
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', makeHandler(stderrChunks));
}
// Use 'exit' instead of 'close' when there are no piped stdio streams for us to drain;
// 'close' can be deferred past 'exit' when the child has grandchildren that inherit its
// stdio fds, so waiting on it without anything to read just stalls
const completionEvent = ignoreStdio || (!child.stdout && !child.stderr) ? 'exit' : 'close';
let completionListener = (code, signal) => {
child.removeListener('error', errorListener);
const argumentString = args && args.length > 0 ? ` ${args.join(' ')}` : '';
let error = null;
if (code !== 0) {
error = signal
? new Error(`${command}${argumentString} exited with signal: ${signal}`)
: new Error(`${command}${argumentString} exited with non-zero code: ${code}`);
}
const assignResult = {
pid: child.pid,
status: code,
signal,
};
if (error) {
if (error.stack && callerStack)
error.stack += `\n${callerStack}`;
// When we're already rejecting, we don't enforce the max buffer error, and accept that we
// may truncate stderr/stdout
reject(attachResult(error, assignResult, stdoutChunks, stderrChunks, true));
}
else if (enforceMaxBufferStrictly && (stdoutChunks.maxExceeded || stderrChunks.maxExceeded)) {
// When a `maxBuffer` is passed, we enforce the maximum on stdout and stderr strictly
const error = new Error(`${command}${argumentString} exceeded maxBuffer of ${maxBuffer} bytes`);
error.code = 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER';
reject(attachResult(error, assignResult, stdoutChunks, stderrChunks, true));
}
else {
const result = {};
resolve(attachResult(result, assignResult, stdoutChunks, stderrChunks));
}
};
let errorListener = (error) => {
child.removeListener(completionEvent, completionListener);
const assignResult = {
pid: child.pid,
status: null,
signal: null,
};
reject(attachResult(error, assignResult, stdoutChunks, stderrChunks));
};
child.once(completionEvent, completionListener);
child.once('error', errorListener);
});
promise.child = child;
return promise;
}
module.exports = spawnAsync;
//# sourceMappingURL=spawnAsync.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,53 @@
{
"name": "@expo/spawn-async",
"version": "1.8.0",
"description": "A Promise-based interface into processes created by child_process.spawn",
"main": "./build/spawnAsync.js",
"types": "./build/spawnAsync.d.ts",
"files": [
"build",
"!build/**/__tests__"
],
"engines": {
"node": ">=12"
},
"scripts": {
"build": "tsc",
"clean": "rm -rf build",
"prepare": "yarn clean && yarn build",
"start": "tsc --watch",
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/expo/spawn-async.git"
},
"keywords": [
"spawn",
"child_process",
"async",
"promise",
"process"
],
"author": "Expo",
"license": "MIT",
"bugs": {
"url": "https://github.com/expo/spawn-async/issues"
},
"homepage": "https://github.com/expo/spawn-async#readme",
"jest": {
"preset": "ts-jest",
"rootDir": "src"
},
"dependencies": {
"cross-spawn": "^7.0.6"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.3",
"jest": "^29.5.0",
"ts-jest": "^29.0.5",
"typescript": "^5.0.2"
}
}