- 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
91 lines
3.1 KiB
JavaScript
91 lines
3.1 KiB
JavaScript
'use strict';
|
|
|
|
var Alias = require('../nodes/Alias.js');
|
|
var identity = require('../nodes/identity.js');
|
|
var Scalar = require('../nodes/Scalar.js');
|
|
|
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
function findTagObject(value, tagName, tags) {
|
|
if (tagName) {
|
|
const match = tags.filter(t => t.tag === tagName);
|
|
const tagObj = match.find(t => !t.format) ?? match[0];
|
|
if (!tagObj)
|
|
throw new Error(`Tag ${tagName} not found`);
|
|
return tagObj;
|
|
}
|
|
return tags.find(t => t.identify?.(value) && !t.format);
|
|
}
|
|
function createNode(value, tagName, ctx) {
|
|
if (identity.isDocument(value))
|
|
value = value.contents;
|
|
if (identity.isNode(value))
|
|
return value;
|
|
if (identity.isPair(value)) {
|
|
const map = ctx.schema[identity.MAP].createNode?.(ctx.schema, null, ctx);
|
|
map.items.push(value);
|
|
return map;
|
|
}
|
|
if (value instanceof String ||
|
|
value instanceof Number ||
|
|
value instanceof Boolean ||
|
|
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
) {
|
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
value = value.valueOf();
|
|
}
|
|
const { aliasDuplicateObjects, onAnchor, onTagObj, schema, sourceObjects } = ctx;
|
|
// Detect duplicate references to the same object & use Alias nodes for all
|
|
// after first. The `ref` wrapper allows for circular references to resolve.
|
|
let ref = undefined;
|
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
ref = sourceObjects.get(value);
|
|
if (ref) {
|
|
ref.anchor ?? (ref.anchor = onAnchor(value));
|
|
return new Alias.Alias(ref.anchor);
|
|
}
|
|
else {
|
|
ref = { anchor: null, node: null };
|
|
sourceObjects.set(value, ref);
|
|
}
|
|
}
|
|
if (tagName?.startsWith('!!'))
|
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
if (!tagObj) {
|
|
if (value && typeof value.toJSON === 'function') {
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
value = value.toJSON();
|
|
}
|
|
if (!value || typeof value !== 'object') {
|
|
const node = new Scalar.Scalar(value);
|
|
if (ref)
|
|
ref.node = node;
|
|
return node;
|
|
}
|
|
tagObj =
|
|
value instanceof Map
|
|
? schema[identity.MAP]
|
|
: Symbol.iterator in Object(value)
|
|
? schema[identity.SEQ]
|
|
: schema[identity.MAP];
|
|
}
|
|
if (onTagObj) {
|
|
onTagObj(tagObj);
|
|
delete ctx.onTagObj;
|
|
}
|
|
const node = tagObj?.createNode
|
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
: typeof tagObj?.nodeClass?.from === 'function'
|
|
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
: new Scalar.Scalar(value);
|
|
if (tagName)
|
|
node.tag = tagName;
|
|
else if (!tagObj.default)
|
|
node.tag = tagObj.tag;
|
|
if (ref)
|
|
ref.node = node;
|
|
return node;
|
|
}
|
|
|
|
exports.createNode = createNode;
|