- 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
214 lines
4.6 KiB
Plaintext
214 lines
4.6 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
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const {ParserError} = require('./errors');
|
|
const path = require('path');
|
|
|
|
export type TypeDeclarationMap = {[declarationName: string]: $FlowFixMe};
|
|
|
|
export type TypeResolutionStatus =
|
|
| $ReadOnly<{
|
|
type: 'alias' | 'enum',
|
|
successful: true,
|
|
name: string,
|
|
}>
|
|
| $ReadOnly<{
|
|
successful: false,
|
|
}>;
|
|
|
|
function extractNativeModuleName(filename: string): string {
|
|
// this should drop everything after the file name. For Example it will drop:
|
|
// .android.js, .android.ts, .android.tsx, .ios.js, .ios.ts, .ios.tsx, .js, .ts, .tsx
|
|
return path.basename(filename).split('.')[0];
|
|
}
|
|
|
|
export type ParserErrorCapturer = <T>(fn: () => T) => ?T;
|
|
|
|
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
export type PropAST = Object;
|
|
|
|
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
|
export type ASTNode = Object;
|
|
|
|
function createParserErrorCapturer(): [
|
|
Array<ParserError>,
|
|
ParserErrorCapturer,
|
|
] {
|
|
// $FlowFixMe[missing-empty-array-annot]
|
|
const errors = [];
|
|
function guard<T>(fn: () => T): ?T {
|
|
try {
|
|
return fn();
|
|
} catch (error) {
|
|
if (!(error instanceof ParserError)) {
|
|
throw error;
|
|
}
|
|
// $FlowFixMe[incompatible-call]
|
|
errors.push(error);
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// $FlowFixMe[incompatible-return]
|
|
return [errors, guard];
|
|
}
|
|
|
|
function verifyPlatforms(
|
|
hasteModuleName: string,
|
|
moduleName: string,
|
|
): $ReadOnly<{
|
|
cxxOnly: boolean,
|
|
excludedPlatforms: Array<'iOS' | 'android'>,
|
|
}> {
|
|
let cxxOnly = false;
|
|
const excludedPlatforms = new Set<'iOS' | 'android'>();
|
|
const namesToValidate = [moduleName, hasteModuleName];
|
|
|
|
namesToValidate.forEach(name => {
|
|
if (name.endsWith('Android')) {
|
|
excludedPlatforms.add('iOS');
|
|
return;
|
|
}
|
|
|
|
if (name.endsWith('IOS')) {
|
|
excludedPlatforms.add('android');
|
|
return;
|
|
}
|
|
|
|
if (name.endsWith('Windows')) {
|
|
excludedPlatforms.add('iOS');
|
|
excludedPlatforms.add('android');
|
|
return;
|
|
}
|
|
|
|
if (name.endsWith('Cxx')) {
|
|
cxxOnly = true;
|
|
excludedPlatforms.add('iOS');
|
|
excludedPlatforms.add('android');
|
|
return;
|
|
}
|
|
});
|
|
|
|
return {
|
|
cxxOnly,
|
|
excludedPlatforms: Array.from(excludedPlatforms),
|
|
};
|
|
}
|
|
|
|
// TODO(T108222691): Use flow-types for @babel/parser
|
|
function visit(
|
|
astNode: $FlowFixMe,
|
|
visitor: {
|
|
[type: string]: (node: $FlowFixMe) => void,
|
|
},
|
|
) {
|
|
const queue = [astNode];
|
|
while (queue.length !== 0) {
|
|
let item = queue.shift();
|
|
|
|
if (!(typeof item === 'object' && item != null)) {
|
|
continue;
|
|
}
|
|
|
|
if (
|
|
typeof item.type === 'string' &&
|
|
typeof visitor[item.type] === 'function'
|
|
) {
|
|
// Don't visit any children
|
|
visitor[item.type](item);
|
|
} else if (Array.isArray(item)) {
|
|
queue.push(...item);
|
|
} else {
|
|
queue.push(...Object.values(item));
|
|
}
|
|
}
|
|
}
|
|
|
|
function getConfigType(
|
|
// TODO(T71778680): Flow-type this node.
|
|
ast: $FlowFixMe,
|
|
Visitor: ({isComponent: boolean, isModule: boolean}) => {
|
|
[type: string]: (node: $FlowFixMe) => void,
|
|
},
|
|
): 'module' | 'component' | 'none' {
|
|
let infoMap = {
|
|
isComponent: false,
|
|
isModule: false,
|
|
};
|
|
|
|
visit(ast, Visitor(infoMap));
|
|
|
|
const {isModule, isComponent} = infoMap;
|
|
if (isModule && isComponent) {
|
|
throw new Error(
|
|
'Found type extending "TurboModule" and exported "codegenNativeComponent" declaration in one file. Split them into separated files.',
|
|
);
|
|
}
|
|
|
|
if (isModule) {
|
|
return 'module';
|
|
} else if (isComponent) {
|
|
return 'component';
|
|
} else {
|
|
return 'none';
|
|
}
|
|
}
|
|
|
|
// TODO(T71778680): Flow-type ASTNodes.
|
|
function isModuleRegistryCall(node: $FlowFixMe): boolean {
|
|
if (node.type !== 'CallExpression') {
|
|
return false;
|
|
}
|
|
|
|
const callExpression = node;
|
|
|
|
if (callExpression.callee.type !== 'MemberExpression') {
|
|
return false;
|
|
}
|
|
|
|
const memberExpression = callExpression.callee;
|
|
if (
|
|
!(
|
|
memberExpression.object.type === 'Identifier' &&
|
|
memberExpression.object.name === 'TurboModuleRegistry'
|
|
)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
if (
|
|
!(
|
|
memberExpression.property.type === 'Identifier' &&
|
|
(memberExpression.property.name === 'get' ||
|
|
memberExpression.property.name === 'getEnforcing')
|
|
)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
if (memberExpression.computed) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
module.exports = {
|
|
getConfigType,
|
|
extractNativeModuleName,
|
|
createParserErrorCapturer,
|
|
verifyPlatforms,
|
|
visit,
|
|
isModuleRegistryCall,
|
|
};
|