Files
Meshtastic-Android/core/common
James Rich 0a78a2755c feat(di,resources,model): enable wasmJs target
core:di has no expect declarations, just the target. core:resources' getString()
(blocking, runBlocking-based) can't exist on wasmJs -- split to expect/actual: a real
nonWebMain actual (android/jvm/iOS, same hierarchy-split pattern as core:ble) and a
wasmJsMain actual that fails loudly (there is no way to synchronously block on wasmJs;
callers on web must use the already-suspend getStringSuspend() instead). Renamed the
nonWebMain actual file to GetStringActuals.kt to avoid a JVM facade-class name collision
with commonMain's GetString.kt (both would otherwise generate an identical GetStringKt
class).

core:model's two expect declarations (getShortDateTime, platformRandomBytes) get wasmJs
actuals backed by Intl.DateTimeFormat and the Web Crypto API's getRandomValues() --
platformRandomBytes backs channel PSK/private-key generation, so it must be
cryptographically secure, never Math.random(). Third-party dependencies (takpacket-sdk
0.9.1, compose components-resources 1.12.0) confirmed to publish a wasmJs variant via
their real Gradle Module Metadata before enabling the target.

Verified via gradle-runner: compileKotlinWasmJs passes for all three, full regression
(android/jvm/iOS compiles, allTests, detekt, spotlessCheck) passes across every touched
module.
2026-08-30 19:43:57 -05:00
..

:core:common

Overview

Targets: Android · JVM (Desktop) · iOS

The :core:common module contains low-level utility functions, extensions, and common data structures that do not depend on any other Meshtastic-specific modules. It is designed to be highly reusable across the project.

Key Components

1. util package

Contains general-purpose extensions and helpers:

  • Coroutines: Helpers for structured concurrency and Flow transformations.
  • Time: Utilities for handling timestamps and durations, plus DateFormatter for display dates.
  • Exceptions: Standardized exception types for common error scenarios.
  • NumberFormatter: Locale-aware number formatting (pre-format floats before Compose display).
  • UrlUtils / CommonUri: URL helpers and a multiplatform URI abstraction.

2. MetricFormatter.kt

Centralized utility for display strings — temperature, voltage, current, percent, humidity, pressure, SNR, RSSI. Ensures consistent unit spacing and formatting across all UI surfaces.

3. BuildConfigProvider.kt

An interface for accessing build-time configuration in a multiplatform-friendly way.

Dependency Graph

graph TB
  :core:common[common]:::kmp-library

classDef android-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-application-compose fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef compose-desktop-application fill:#CAFFBF,stroke:#000,stroke-width:2px,color:#000;
classDef android-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef android-library fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-library-compose fill:#9BF6FF,stroke:#000,stroke-width:2px,color:#000;
classDef android-test fill:#A0C4FF,stroke:#000,stroke-width:2px,color:#000;
classDef jvm-library fill:#BDB2FF,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-feature fill:#FFD6A5,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library-compose fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef kmp-library fill:#FFC1CC,stroke:#000,stroke-width:2px,color:#000;
classDef unknown fill:#FFADAD,stroke:#000,stroke-width:2px,color:#000;