Files
Eric FELIXINE e30ae8ed09 feat(smart-app): implement complete mobile app MVP
- 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
2026-06-01 18:00:35 -04:00

158 lines
5.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.downloadProfile = downloadProfile;
function _child_process() {
const data = require("child_process");
_child_process = function () {
return data;
};
return data;
}
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _os() {
const data = _interopRequireDefault(require("os"));
_os = function () {
return data;
};
return data;
}
function _hermesProfileTransformer() {
const data = _interopRequireDefault(require("hermes-profile-transformer"));
_hermesProfileTransformer = function () {
return data;
};
return data;
}
var _sourcemapUtils = require("./sourcemapUtils");
function _cliPlatformAndroid() {
const data = require("@react-native-community/cli-platform-android");
_cliPlatformAndroid = function () {
return data;
};
return data;
}
var _metroBundleOptions = require("./metroBundleOptions");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Get the last modified hermes profile
* @param packageNameWithSuffix
*/
function getLatestFile(packageNameWithSuffix) {
try {
const file = (0, _child_process().execSync)(`adb shell run-as ${packageNameWithSuffix} ls cache/ -tp | grep -v /$ | grep -E '.cpuprofile' | head -1
`);
return file.toString().trim();
} catch (e) {
throw e;
}
}
function execSyncWithLog(command) {
_cliTools().logger.debug(`${command}`);
return (0, _child_process().execSync)(command);
}
/**
* A wrapper that converts an object to JSON with 4 spaces for indentation.
*
* @param obj Any object that can be represented as JSON
* @returns A JSON string
*/
function jsonStringify(obj) {
return JSON.stringify(obj, undefined, 4);
}
/**
* Pull and convert a Hermes tracing profile to Chrome tracing profile
* @param ctx
* @param dstPath
* @param fileName
* @param sourceMapPath
* @param raw
* @param generateSourceMap
* @param appId
* @param appIdSuffix
*/
async function downloadProfile(ctx, dstPath, filename, sourcemapPath, raw, shouldGenerateSourcemap, port = '8081', appId, appIdSuffix, host = 'localhost') {
try {
const androidProject = (0, _cliPlatformAndroid().getAndroidProject)(ctx);
const packageNameWithSuffix = [appId || androidProject.packageName, appIdSuffix].filter(Boolean).join('.');
// If file name is not specified, pull the latest file from device
const file = filename || getLatestFile(packageNameWithSuffix);
if (!file) {
throw new (_cliTools().CLIError)('There is no file in the cache/ directory. Did you record a profile from the developer menu?');
}
_cliTools().logger.info(`File to be pulled: ${file}`);
// If destination path is not specified, pull to the current directory
dstPath = dstPath || ctx.root;
_cliTools().logger.debug('Internal commands run to pull the file:');
// If --raw, pull the hermes profile to dstPath
if (raw) {
execSyncWithLog(`adb shell run-as ${packageNameWithSuffix} cat cache/${file} > ${dstPath}/${file}`);
_cliTools().logger.success(`Successfully pulled the file to ${dstPath}/${file}`);
}
// Else: transform the profile to Chrome format and pull it to dstPath
else {
const osTmpDir = _os().default.tmpdir();
const tempFilePath = _path().default.join(osTmpDir, file);
execSyncWithLog(`adb shell run-as ${packageNameWithSuffix} cat cache/${file} > ${tempFilePath}`);
const bundleOptions = (0, _metroBundleOptions.getMetroBundleOptions)(tempFilePath, host);
// If path to source map is not given
if (!sourcemapPath) {
// Get or generate the source map
if (shouldGenerateSourcemap) {
sourcemapPath = await (0, _sourcemapUtils.generateSourcemap)(port, bundleOptions);
} else {
sourcemapPath = await (0, _sourcemapUtils.findSourcemap)(ctx, port, bundleOptions);
}
// Run without source map
if (!sourcemapPath) {
_cliTools().logger.warn('Cannot find source maps, running the transformer without it');
_cliTools().logger.info('Instructions on how to get source maps: set `bundleInDebug: true` in your app/build.gradle file, inside the `project.ext.react` map.');
}
}
// Run transformer tool to convert from Hermes to Chrome format
const events = await (0, _hermesProfileTransformer().default)(tempFilePath, sourcemapPath, 'index.bundle');
const transformedFilePath = `${dstPath}/${_path().default.basename(file, '.cpuprofile')}-converted.json`;
// Convert to JSON in chunks because JSON.stringify() will fail for large
// arrays with the error "RangeError: Invalid string length"
const out = events.map(jsonStringify).join(',');
_fs().default.writeFileSync(transformedFilePath, '[' + out + ']', 'utf-8');
_cliTools().logger.success(`Successfully converted to Chrome tracing format and pulled the file to ${transformedFilePath}`);
}
} catch (e) {
throw e;
}
}
//# sourceMappingURL=downloadProfile.ts.map