- 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
145 lines
3.5 KiB
Plaintext
145 lines
3.5 KiB
Plaintext
/**
|
|
* 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
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {
|
|
DeltaResult,
|
|
Graph,
|
|
// eslint-disable-next-line no-unused-vars
|
|
MixedOutput,
|
|
Options,
|
|
ReadOnlyGraph,
|
|
} from './DeltaBundler/types.flow';
|
|
import type EventEmitter from 'events';
|
|
|
|
const DeltaCalculator = require('./DeltaBundler/DeltaCalculator');
|
|
|
|
export type {
|
|
DeltaResult,
|
|
Graph,
|
|
Dependencies,
|
|
MixedOutput,
|
|
Module,
|
|
ReadOnlyGraph,
|
|
TransformFn,
|
|
TransformResult,
|
|
TransformResultDependency,
|
|
TransformResultWithSource,
|
|
} from './DeltaBundler/types.flow';
|
|
|
|
/**
|
|
* `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This
|
|
* module handles all the transformer instances so it can support multiple
|
|
* concurrent clients requesting their own deltas. This is done through the
|
|
* `clientId` param (which maps a client to a specific delta transformer).
|
|
*/
|
|
class DeltaBundler<T = MixedOutput> {
|
|
_changeEventSource: EventEmitter;
|
|
_deltaCalculators: Map<Graph<T>, DeltaCalculator<T>> = new Map();
|
|
|
|
constructor(changeEventSource: EventEmitter) {
|
|
this._changeEventSource = changeEventSource;
|
|
}
|
|
|
|
end(): void {
|
|
this._deltaCalculators.forEach((deltaCalculator: DeltaCalculator<T>) =>
|
|
deltaCalculator.end(),
|
|
);
|
|
this._deltaCalculators = new Map();
|
|
}
|
|
|
|
async getDependencies(
|
|
entryPoints: $ReadOnlyArray<string>,
|
|
options: Options<T>,
|
|
): Promise<ReadOnlyGraph<T>['dependencies']> {
|
|
const deltaCalculator = new DeltaCalculator(
|
|
new Set(entryPoints),
|
|
this._changeEventSource,
|
|
options,
|
|
);
|
|
|
|
await deltaCalculator.getDelta({reset: true, shallow: options.shallow});
|
|
const graph = deltaCalculator.getGraph();
|
|
|
|
deltaCalculator.end();
|
|
return graph.dependencies;
|
|
}
|
|
|
|
// Note: the graph returned by this function needs to be ended when finished
|
|
// so that we don't leak graphs that are not reachable.
|
|
// To get just the dependencies, use getDependencies which will not leak graphs.
|
|
async buildGraph(
|
|
entryPoints: $ReadOnlyArray<string>,
|
|
options: Options<T>,
|
|
): Promise<Graph<T>> {
|
|
const deltaCalculator = new DeltaCalculator(
|
|
new Set(entryPoints),
|
|
this._changeEventSource,
|
|
options,
|
|
);
|
|
|
|
await deltaCalculator.getDelta({reset: true, shallow: options.shallow});
|
|
const graph = deltaCalculator.getGraph();
|
|
|
|
this._deltaCalculators.set(graph, deltaCalculator);
|
|
return graph;
|
|
}
|
|
|
|
async getDelta(
|
|
graph: Graph<T>,
|
|
{
|
|
reset,
|
|
shallow,
|
|
}: {
|
|
reset: boolean,
|
|
shallow: boolean,
|
|
...
|
|
},
|
|
): Promise<DeltaResult<T>> {
|
|
const deltaCalculator = this._deltaCalculators.get(graph);
|
|
|
|
if (!deltaCalculator) {
|
|
throw new Error('Graph not found');
|
|
}
|
|
|
|
return await deltaCalculator.getDelta({reset, shallow});
|
|
}
|
|
|
|
listen(graph: Graph<T>, callback: () => Promise<void>): () => void {
|
|
const deltaCalculator = this._deltaCalculators.get(graph);
|
|
|
|
if (!deltaCalculator) {
|
|
throw new Error('Graph not found');
|
|
}
|
|
|
|
deltaCalculator.on('change', callback);
|
|
|
|
return () => {
|
|
deltaCalculator.removeListener('change', callback);
|
|
};
|
|
}
|
|
|
|
endGraph(graph: Graph<T>): void {
|
|
const deltaCalculator = this._deltaCalculators.get(graph);
|
|
|
|
if (!deltaCalculator) {
|
|
throw new Error('Graph not found');
|
|
}
|
|
|
|
deltaCalculator.end();
|
|
|
|
this._deltaCalculators.delete(graph);
|
|
}
|
|
}
|
|
|
|
module.exports = DeltaBundler;
|