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

83 lines
2.6 KiB
C++

/*
* 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.
*/
#include "InstanceAgent.h"
#include "SessionState.h"
#include <jsinspector-modern/InstanceTarget.h>
namespace facebook::react::jsinspector_modern {
std::shared_ptr<InstanceTarget> InstanceTarget::create(
std::shared_ptr<ExecutionContextManager> executionContextManager,
InstanceTargetDelegate& delegate,
VoidExecutor executor) {
std::shared_ptr<InstanceTarget> instanceTarget{
new InstanceTarget(executionContextManager, delegate)};
instanceTarget->setExecutor(executor);
return instanceTarget;
}
InstanceTarget::InstanceTarget(
std::shared_ptr<ExecutionContextManager> executionContextManager,
InstanceTargetDelegate& delegate)
: delegate_(delegate),
executionContextManager_(std::move(executionContextManager)) {
(void)delegate_;
}
InstanceTargetDelegate::~InstanceTargetDelegate() {}
std::shared_ptr<InstanceAgent> InstanceTarget::createAgent(
FrontendChannel channel,
SessionState& sessionState) {
auto instanceAgent =
std::make_shared<InstanceAgent>(channel, *this, sessionState);
instanceAgent->setCurrentRuntime(currentRuntime_.get());
agents_.insert(instanceAgent);
return instanceAgent;
}
InstanceTarget::~InstanceTarget() {
// Agents are owned by the session, not by InstanceTarget, but
// they hold an InstanceTarget& that we must guarantee is valid.
assert(
agents_.empty() &&
"InstanceAgent objects must be destroyed before their InstanceTarget. Did you call PageTarget::unregisterInstance()?");
}
RuntimeTarget& InstanceTarget::registerRuntime(
RuntimeTargetDelegate& delegate,
RuntimeExecutor jsExecutor) {
assert(!currentRuntime_ && "Only one Runtime allowed");
currentRuntime_ = RuntimeTarget::create(
ExecutionContextDescription{
.id = executionContextManager_->allocateExecutionContextId(),
.origin = "",
.name = "main",
.uniqueId = std::nullopt},
delegate,
jsExecutor,
makeVoidExecutor(executorFromThis()));
agents_.forEach([currentRuntime = &*currentRuntime_](InstanceAgent& agent) {
agent.setCurrentRuntime(currentRuntime);
});
return *currentRuntime_;
}
void InstanceTarget::unregisterRuntime(RuntimeTarget& Runtime) {
assert(
currentRuntime_ && currentRuntime_.get() == &Runtime &&
"Invalid unregistration");
agents_.forEach(
[](InstanceAgent& agent) { agent.setCurrentRuntime(nullptr); });
currentRuntime_.reset();
}
} // namespace facebook::react::jsinspector_modern