- 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
90 lines
2.2 KiB
JavaScript
90 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
/**
|
|
* 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.
|
|
*/
|
|
|
|
/**
|
|
* First-in, First-out task queue that manages a dedicated pool
|
|
* for each worker as well as a shared queue. The FIFO ordering is guaranteed
|
|
* across the worker specific and shared queue.
|
|
*/
|
|
class FifoQueue {
|
|
_workerQueues = [];
|
|
_sharedQueue = new InternalQueue();
|
|
enqueue(task, workerId) {
|
|
if (workerId == null) {
|
|
this._sharedQueue.enqueue(task);
|
|
return;
|
|
}
|
|
let workerQueue = this._workerQueues[workerId];
|
|
if (workerQueue == null) {
|
|
workerQueue = this._workerQueues[workerId] = new InternalQueue();
|
|
}
|
|
const sharedTop = this._sharedQueue.peekLast();
|
|
const item = {
|
|
previousSharedTask: sharedTop,
|
|
task
|
|
};
|
|
workerQueue.enqueue(item);
|
|
}
|
|
dequeue(workerId) {
|
|
const workerTop = this._workerQueues[workerId]?.peek();
|
|
const sharedTaskIsProcessed =
|
|
workerTop?.previousSharedTask?.request[1] ?? true;
|
|
|
|
// Process the top task from the shared queue if
|
|
// - there's no task in the worker specific queue or
|
|
// - if the non-worker-specific task after which this worker specific task
|
|
// has been queued wasn't processed yet
|
|
if (workerTop != null && sharedTaskIsProcessed) {
|
|
return this._workerQueues[workerId]?.dequeue()?.task ?? null;
|
|
}
|
|
return this._sharedQueue.dequeue();
|
|
}
|
|
}
|
|
exports.default = FifoQueue;
|
|
/**
|
|
* FIFO queue for a single worker / shared queue.
|
|
*/
|
|
class InternalQueue {
|
|
_head = null;
|
|
_last = null;
|
|
enqueue(value) {
|
|
const item = {
|
|
next: null,
|
|
value
|
|
};
|
|
if (this._last == null) {
|
|
this._head = item;
|
|
} else {
|
|
this._last.next = item;
|
|
}
|
|
this._last = item;
|
|
}
|
|
dequeue() {
|
|
if (this._head == null) {
|
|
return null;
|
|
}
|
|
const item = this._head;
|
|
this._head = item.next;
|
|
if (this._head == null) {
|
|
this._last = null;
|
|
}
|
|
return item.value;
|
|
}
|
|
peek() {
|
|
return this._head?.value ?? null;
|
|
}
|
|
peekLast() {
|
|
return this._last?.value ?? null;
|
|
}
|
|
}
|