Files
Eric FELIXINE e30ae8ed09 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
2026-06-01 18:00:35 -04:00

150 lines
4.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = openDebuggerMiddleware;
var _getDevToolsFrontendUrl = _interopRequireDefault(
require("../utils/getDevToolsFrontendUrl")
);
var _url = _interopRequireDefault(require("url"));
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
*/
const debuggerInstances = new Map();
/**
* Open the JavaScript debugger for a given CDP target (direct Hermes debugging).
*
* Currently supports Hermes targets, opening debugger websocket URL in Chrome
* DevTools.
*
* @see https://chromedevtools.github.io/devtools-protocol/
*/
function openDebuggerMiddleware({
serverBaseUrl,
logger,
browserLauncher,
eventReporter,
experiments,
inspectorProxy,
}) {
return async (req, res, next) => {
if (
req.method === "POST" ||
(experiments.enableOpenDebuggerRedirect && req.method === "GET")
) {
const { query } = _url.default.parse(req.url, true);
const { appId, device } = query;
const targets = inspectorProxy.getPageDescriptions().filter(
// Only use targets with better reloading support
(app) =>
app.title === "React Native Experimental (Improved Chrome Reloads)" ||
app.reactNative.capabilities?.nativePageReloads === true
);
let target;
const launchType = req.method === "POST" ? "launch" : "redirect";
if (typeof appId === "string" || typeof device === "string") {
logger?.info(
(launchType === "launch" ? "Launching" : "Redirecting to") +
" JS debugger (experimental)..."
);
if (typeof device === "string") {
target = targets.find(
(_target) => _target.reactNative.logicalDeviceId === device
);
}
if (!target && typeof appId === "string") {
target = targets.find((_target) => _target.description === appId);
}
} else {
logger?.info(
(launchType === "launch" ? "Launching" : "Redirecting to") +
" JS debugger for first available target..."
);
target = targets[0];
}
if (!target) {
res.writeHead(404);
res.end("Unable to find Chrome DevTools inspector target");
logger?.warn(
"No compatible apps connected. JavaScript debugging can only be used with the Hermes engine."
);
eventReporter?.logEvent({
type: "launch_debugger_frontend",
launchType,
status: "coded_error",
errorCode: "NO_APPS_FOUND",
});
return;
}
try {
switch (launchType) {
case "launch":
const frontendInstanceId =
device != null
? "device:" + device
: "app:" + (appId ?? "<null>");
await debuggerInstances.get(frontendInstanceId)?.kill();
debuggerInstances.set(
frontendInstanceId,
await browserLauncher.launchDebuggerAppWindow(
(0, _getDevToolsFrontendUrl.default)(
experiments,
target.webSocketDebuggerUrl,
serverBaseUrl
)
)
);
res.end();
break;
case "redirect":
res.writeHead(302, {
Location: (0, _getDevToolsFrontendUrl.default)(
experiments,
target.webSocketDebuggerUrl,
// Use a relative URL.
""
),
});
res.end();
break;
default:
}
eventReporter?.logEvent({
type: "launch_debugger_frontend",
launchType,
status: "success",
appId: appId ?? null,
deviceId: device ?? null,
});
return;
} catch (e) {
logger?.error(
"Error launching JS debugger: " + e.message ?? "Unknown error"
);
res.writeHead(500);
res.end();
eventReporter?.logEvent({
type: "launch_debugger_frontend",
launchType,
status: "error",
error: e,
});
return;
}
}
next();
};
}