feat(launcher): harden native caching and telemetry; consolidate documentation
- Implemented SHA-256 integrity checks and stale temp purge in native download logic.\n- Enabled strict hash verification in background sync cycle.\n- Made CPU load gauge dynamic using real-time loadavg metadata.\n- Consolidated native app documentation into single master manual.\n- Marked legacy electron_native.js as deprecated.\n- Updated roadmap with temp cleanup and launch protection tasks.
This commit is contained in:
@@ -1,48 +1,34 @@
|
||||
# Electron Integration (Events - Launcher)
|
||||
# Aether Native Integration (Electron)
|
||||
|
||||
This document describes the Electron integration for the Aether Svelte application, which provides native capabilities for the Events module, specifically for the **Event Launcher** functionality.
|
||||
This directory contains the SvelteKit-side bridge for the Aether Native App (Electron). It provides the UI with access to OS-level capabilities required for the **Event Launcher**.
|
||||
|
||||
## Overview
|
||||
## 📖 Technical Manual
|
||||
For detailed architecture, lifecycle, and IPC specifications, see:
|
||||
👉 **[AE_EVENTS_LAUNCHER_NATIVE_INTEGRATION.md](../../../documentation/AE_EVENTS_LAUNCHER_NATIVE_INTEGRATION.md)**
|
||||
|
||||
The Event Launcher is not a standalone module but rather a set of native functions and UI elements integrated into the Events module. It is designed to be used in a hybrid event scenario where a local application (the Electron app) is used to control presentations and other event-related content on a local machine.
|
||||
## 📂 File Manifest
|
||||
|
||||
## Architecture
|
||||
| File | Role | Description |
|
||||
| :--- | :--- | :--- |
|
||||
| `electron_relay.ts` | **Messenger** | The TypeScript API used by Svelte components. Standardizes calls to `snake_case`. |
|
||||
| `electron_native.js` | **Bridge Logic** | (Internal) Logic often used in the Preload or Renderer to facilitate IPC. |
|
||||
|
||||
The Electron integration is composed of three main parts:
|
||||
## 🚀 Usage Example
|
||||
|
||||
1. **Electron Main Process (`electron.js`):** The main process of the Electron application. It is responsible for creating the browser window and handling communication with the renderer process.
|
||||
2. **Native Functions (`src/lib/electron/electron_native.js`):** A set of functions that are executed in the Electron main process and have access to the operating system's native APIs. These functions provide the core functionality for the Event Launcher, such as opening files, running commands, and managing processes.
|
||||
3. **Relay/Bridge (`src/lib/electron/electron_relay.js`):** A bridge that exposes the native functions to the Svelte application running in the renderer process. This allows the Svelte components to call the native functions.
|
||||
```typescript
|
||||
import { is_native, launch_from_cache } from '$lib/electron/electron_relay';
|
||||
|
||||
## Key Functionality
|
||||
if (is_native) {
|
||||
await launch_from_cache({
|
||||
cache_root: $ae_loc.native_device.local_file_cache_path,
|
||||
hash: file_obj.hash_sha256,
|
||||
temp_root: $ae_loc.native_device.host_file_temp_path,
|
||||
filename: file_obj.filename
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
The native functions in `electron_native.js` provide the following key functionalities for the Event Launcher:
|
||||
|
||||
- **File Caching:**
|
||||
- `check_hash_file_cache()`: Checks if a file with a specific hash exists in the local cache.
|
||||
- `download_hash_file_to_cache()`: Downloads a file from the API and stores it in the local cache.
|
||||
- **File Operations:**
|
||||
- `open_hash_file_to_temp()`: Copies a file from the cache to a temporary directory and opens it.
|
||||
- `open_local_file()`: Opens a local file.
|
||||
- **Process Management:**
|
||||
- `kill_processes()`: Kills processes by name or ID. This is used to close presentation applications after a presentation is finished.
|
||||
- **Command Execution:**
|
||||
- `run_osascript()`: Runs an AppleScript command (macOS only).
|
||||
- `run_cmd()`: Runs a shell command.
|
||||
- **Device Information:**
|
||||
- `get_device_info()`: Gets information about the device, which can be used for logging and debugging.
|
||||
|
||||
## UI Integration
|
||||
|
||||
The Event Launcher functionality is integrated into the Events module's UI as follows:
|
||||
|
||||
- **Launcher Links:** In the list of event sessions, there are "launcher" links that, when clicked, trigger the native launcher functionality.
|
||||
- **Configuration:** The visibility and behavior of the launcher links are controlled by the `mod_pres_mgmt_json` configuration in the `Event` object. This allows for fine-grained control over the launcher functionality on a per-event basis.
|
||||
|
||||
## How it Works
|
||||
|
||||
1. The Svelte application, running in the Electron renderer process, displays a list of event sessions.
|
||||
2. For each session, a "launcher" link is displayed if the configuration allows it.
|
||||
3. When the user clicks on a launcher link, a function in `electron_relay.js` is called.
|
||||
4. The relay function then calls the corresponding native function in `electron_native.js` via the Electron context bridge.
|
||||
5. The native function performs the requested action, such as downloading a file, opening a presentation, or running a command.
|
||||
## 🔐 Security Standards
|
||||
- **Namespace:** All native functions are exposed via `window.aetherNative`.
|
||||
- **Whitelisting:** Only specific intents (e.g., `launch_presentation`) are allowed.
|
||||
- **Path Isolation:** All file operations are restricted to `[home]` and `[tmp]` via placeholder resolution.
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// [DEPRECATED] 2026-02-10: This file is a legacy reference from Aether V2/V4.
|
||||
// Do NOT import this into the SvelteKit frontend.
|
||||
// The active native logic resides in the 'aether_app_native_electron' repository.
|
||||
|
||||
// @ts-nocheck
|
||||
'use strict';
|
||||
/* This should only contain functions that can not be pulled easily into Svelte */
|
||||
|
||||
@@ -23,9 +23,9 @@ export async function get_device_info() {
|
||||
}
|
||||
|
||||
// 2. File & Cache Management
|
||||
export async function check_hash_file_cache({ cache_root, hash, hash_prefix_length = 2 }: any) {
|
||||
export async function check_hash_file_cache({ cache_root, hash, hash_prefix_length = 2, verify_hash = false }: any) {
|
||||
if (!native) return false;
|
||||
return await native.check_cache({ cache_root, hash, hash_prefix_length });
|
||||
return await native.check_cache({ cache_root, hash, hash_prefix_length, verify_hash });
|
||||
}
|
||||
|
||||
export async function download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length = 2 }: any) {
|
||||
|
||||
Reference in New Issue
Block a user