- 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
66 lines
1.8 KiB
Plaintext
66 lines
1.8 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';
|
|
|
|
/**
|
|
* Decode a UTF-8 encoded string from Hermes with a known length.
|
|
* Based on Emscripten's UTF8ToString with the following differences:
|
|
* - Always reads all bytes up to the given length, including null bytes. This
|
|
* means that we can decode strings that contain null bytes in the middle.
|
|
* - Allow UTF-8 encoded code points that are part of a surrogate pair, even though
|
|
* this is technically invalid UTF-8 that UTF8ToString would convert to 0xfffd.
|
|
*/
|
|
export default function HermesParserDecodeUTF8String(
|
|
ptrIn: number,
|
|
length: number,
|
|
heap: Uint8Array,
|
|
): string {
|
|
let ptr = ptrIn;
|
|
const endPtr = ptr + length;
|
|
let str = '';
|
|
|
|
while (ptr < endPtr) {
|
|
// ASCII characters fit in single byte code point
|
|
let u0 = heap[ptr++];
|
|
if (!(u0 & 0x80)) {
|
|
str += String.fromCharCode(u0);
|
|
continue;
|
|
}
|
|
|
|
// Two byte code point
|
|
const u1 = heap[ptr++] & 0x3f;
|
|
if ((u0 & 0xe0) === 0xc0) {
|
|
str += String.fromCharCode(((u0 & 0x1f) << 6) | u1);
|
|
continue;
|
|
}
|
|
|
|
const u2 = heap[ptr++] & 0x3f;
|
|
if ((u0 & 0xf0) === 0xe0) {
|
|
// Three byte code point
|
|
u0 = ((u0 & 0x0f) << 12) | (u1 << 6) | u2;
|
|
} else {
|
|
// Four byte code point
|
|
u0 = ((u0 & 0x07) << 18) | (u1 << 12) | (u2 << 6) | (heap[ptr++] & 0x3f);
|
|
}
|
|
|
|
if (u0 < 0x10000) {
|
|
// Code point fits into a single UTF-16 code unit
|
|
str += String.fromCharCode(u0);
|
|
} else {
|
|
// Code point does not fit into single UTF-16 code unit so convert to surrogate pair
|
|
u0 -= 0x10000;
|
|
str += String.fromCharCode(0xd800 | (u0 >> 10), 0xdc00 | (u0 & 0x3ff));
|
|
}
|
|
}
|
|
|
|
return str;
|
|
}
|