- 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
92 lines
2.5 KiB
JavaScript
92 lines
2.5 KiB
JavaScript
"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;
|