- 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
108 lines
2.6 KiB
JavaScript
108 lines
2.6 KiB
JavaScript
'use strict';
|
|
|
|
//This file contains the ES6 extensions to the core Promises/A+ API
|
|
|
|
var Promise = require('./core.js');
|
|
|
|
module.exports = Promise;
|
|
|
|
/* Static Functions */
|
|
|
|
var TRUE = valuePromise(true);
|
|
var FALSE = valuePromise(false);
|
|
var NULL = valuePromise(null);
|
|
var UNDEFINED = valuePromise(undefined);
|
|
var ZERO = valuePromise(0);
|
|
var EMPTYSTRING = valuePromise('');
|
|
|
|
function valuePromise(value) {
|
|
var p = new Promise(Promise._61);
|
|
p._65 = 1;
|
|
p._55 = value;
|
|
return p;
|
|
}
|
|
Promise.resolve = function (value) {
|
|
if (value instanceof Promise) return value;
|
|
|
|
if (value === null) return NULL;
|
|
if (value === undefined) return UNDEFINED;
|
|
if (value === true) return TRUE;
|
|
if (value === false) return FALSE;
|
|
if (value === 0) return ZERO;
|
|
if (value === '') return EMPTYSTRING;
|
|
|
|
if (typeof value === 'object' || typeof value === 'function') {
|
|
try {
|
|
var then = value.then;
|
|
if (typeof then === 'function') {
|
|
return new Promise(then.bind(value));
|
|
}
|
|
} catch (ex) {
|
|
return new Promise(function (resolve, reject) {
|
|
reject(ex);
|
|
});
|
|
}
|
|
}
|
|
return valuePromise(value);
|
|
};
|
|
|
|
Promise.all = function (arr) {
|
|
var args = Array.prototype.slice.call(arr);
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
if (args.length === 0) return resolve([]);
|
|
var remaining = args.length;
|
|
function res(i, val) {
|
|
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
if (val instanceof Promise && val.then === Promise.prototype.then) {
|
|
while (val._65 === 3) {
|
|
val = val._55;
|
|
}
|
|
if (val._65 === 1) return res(i, val._55);
|
|
if (val._65 === 2) reject(val._55);
|
|
val.then(function (val) {
|
|
res(i, val);
|
|
}, reject);
|
|
return;
|
|
} else {
|
|
var then = val.then;
|
|
if (typeof then === 'function') {
|
|
var p = new Promise(then.bind(val));
|
|
p.then(function (val) {
|
|
res(i, val);
|
|
}, reject);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
args[i] = val;
|
|
if (--remaining === 0) {
|
|
resolve(args);
|
|
}
|
|
}
|
|
for (var i = 0; i < args.length; i++) {
|
|
res(i, args[i]);
|
|
}
|
|
});
|
|
};
|
|
|
|
Promise.reject = function (value) {
|
|
return new Promise(function (resolve, reject) {
|
|
reject(value);
|
|
});
|
|
};
|
|
|
|
Promise.race = function (values) {
|
|
return new Promise(function (resolve, reject) {
|
|
values.forEach(function(value){
|
|
Promise.resolve(value).then(resolve, reject);
|
|
});
|
|
});
|
|
};
|
|
|
|
/* Prototype Methods */
|
|
|
|
Promise.prototype['catch'] = function (onRejected) {
|
|
return this.then(null, onRejected);
|
|
};
|