- 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
119 lines
2.8 KiB
JavaScript
119 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = function (PromiseArgument) {
|
|
var Promise;
|
|
function throat(size, fn) {
|
|
var queue = new Queue();
|
|
function run(fn, self, args) {
|
|
if (size) {
|
|
size--;
|
|
var result = new Promise(function (resolve) {
|
|
resolve(fn.apply(self, args));
|
|
});
|
|
result.then(release, release);
|
|
return result;
|
|
} else {
|
|
return new Promise(function (resolve) {
|
|
queue.push(new Delayed(resolve, fn, self, args));
|
|
});
|
|
}
|
|
}
|
|
function release() {
|
|
size++;
|
|
if (!queue.isEmpty()) {
|
|
var next = queue.shift();
|
|
next.resolve(run(next.fn, next.self, next.args));
|
|
}
|
|
}
|
|
if (typeof size === 'function') {
|
|
var temp = fn;
|
|
fn = size;
|
|
size = temp;
|
|
}
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError(
|
|
'Expected throat size to be a number but got ' + typeof size
|
|
);
|
|
}
|
|
if (fn !== undefined && typeof fn !== 'function') {
|
|
throw new TypeError(
|
|
'Expected throat fn to be a function but got ' + typeof fn
|
|
);
|
|
}
|
|
if (typeof fn === 'function') {
|
|
return function () {
|
|
var args = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
args.push(arguments[i]);
|
|
}
|
|
return run(fn, this, args);
|
|
};
|
|
} else {
|
|
return function (fn) {
|
|
if (typeof fn !== 'function') {
|
|
throw new TypeError(
|
|
'Expected throat fn to be a function but got ' + typeof fn
|
|
);
|
|
}
|
|
var args = [];
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
args.push(arguments[i]);
|
|
}
|
|
return run(fn, this, args);
|
|
};
|
|
}
|
|
}
|
|
if (arguments.length === 1 && typeof PromiseArgument === 'function') {
|
|
Promise = PromiseArgument;
|
|
return throat;
|
|
} else {
|
|
Promise = module.exports.Promise;
|
|
if (typeof Promise !== 'function') {
|
|
throw new Error(
|
|
'You must provide a Promise polyfill for this library to work in older environments'
|
|
);
|
|
}
|
|
return throat(arguments[0], arguments[1]);
|
|
}
|
|
};
|
|
|
|
module.exports.default = module.exports;
|
|
|
|
/* istanbul ignore next */
|
|
if (typeof Promise === 'function') {
|
|
module.exports.Promise = Promise;
|
|
}
|
|
|
|
function Delayed(resolve, fn, self, args) {
|
|
this.resolve = resolve;
|
|
this.fn = fn;
|
|
this.self = self || null;
|
|
this.args = args;
|
|
}
|
|
|
|
function Queue() {
|
|
this._s1 = [];
|
|
this._s2 = [];
|
|
}
|
|
|
|
Queue.prototype.push = function (value) {
|
|
this._s1.push(value);
|
|
};
|
|
|
|
Queue.prototype.shift = function () {
|
|
var s2 = this._s2;
|
|
if (s2.length === 0) {
|
|
var s1 = this._s1;
|
|
if (s1.length === 0) {
|
|
return;
|
|
}
|
|
this._s1 = s2;
|
|
s2 = this._s2 = s1.reverse();
|
|
}
|
|
return s2.pop();
|
|
};
|
|
|
|
Queue.prototype.isEmpty = function () {
|
|
return !this._s1.length && !this._s2.length;
|
|
};
|