# Aether Native Integration (Electron)

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**.

The native implementation lives in a separate repo:
`~/OSIT_dev/aether_app_native_electron/`

## Technical Manual

For detailed architecture, lifecycle, and IPC specifications, see:
[PROJECT\_\_AE_Events_Launcher_Native_integration.md](../../../documentation/PROJECT__AE_Events_Launcher_Native_integration.md)

## File Manifest

| File                 | Role                           | Description                                                                                                                                                |
| :------------------- | :----------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `electron_relay.ts`  | **Active — Messenger**         | The TypeScript API used by Svelte components. Standardizes all IPC calls to `snake_case`. This is the only file in this directory that should be imported. |
| `electron_native.js` | **DEPRECATED — Do not import** | Legacy V2/V4 reference file. The active native logic lives in `aether_app_native_electron/`. Kept for historical reference only.                           |

## Usage Example

```typescript
import { is_native, launch_from_cache } from '$lib/electron/electron_relay';

if (is_native) {
    await launch_from_cache({
        cache_root: $ae_loc.local_file_cache_path,
        hash: file_obj.hash_sha256,
        temp_root: $ae_loc.host_file_temp_path,
        filename: file_obj.filename
    });
}
```

## Security Model

- All native functions are accessed via `window.aetherNative` (contextBridge)
- Only explicitly whitelisted IPC channels are exposed — no arbitrary code execution
- Path isolation: all file operations use `[home]` / `[tmp]` placeholders resolved by the native bridge
- Context isolation is enabled; Node integration is disabled in the renderer

## Bridge Architecture (Three Layers)

```text
Svelte Component
  └── electron_relay.ts          (this directory — typed wrappers, snake_case API)
        └── window.aetherNative  (contextBridge whitelist in preload/index.ts)
              └── ipcMain handlers (aether_app_native_electron/src/main/*.ts)
```
