docs(launcher): align launch profile terminology
This commit is contained in:
@@ -40,8 +40,12 @@ The integration is built on a decoupled three-layer communication model to ensur
|
||||
- **File:** `src/lib/electron/electron_relay.ts`
|
||||
- **Role:** Provides a clean, typed API for Svelte components.
|
||||
- **Responsibilities:**
|
||||
- Mapping `camelCase` UI triggers to `snake_case` IPC calls.
|
||||
- Implementing "Smart Fallbacks" (e.g., resolving `[home]` placeholders if the bridge is partially hydrated).
|
||||
- Mapping `camelCase` UI triggers to `snake_case` IPC calls.
|
||||
- Resolving a Launch Profile to a single `native_template` string before crossing IPC.
|
||||
|
||||
The reason for this split is simple: Launch Profiles are policy, while Native Templates are
|
||||
executable strings. Keeping that distinction explicit prevents the bridge from mixing config
|
||||
objects with runtime commands.
|
||||
|
||||
---
|
||||
|
||||
@@ -147,7 +151,7 @@ no-op when `window.aetherNative` is not present (i.e., in browser/non-native mod
|
||||
- `check_cache({cache_root, hash, hash_prefix_length?, verify_hash?})` — Verifies a file exists in the local hashed cache. `verify_hash: true` re-hashes to confirm integrity.
|
||||
- `download_to_cache({url, cache_root, hash, api_key, account_id, hash_prefix_length?})` — Streams a file download to the hashed cache with SHA-256 integrity check. Stale `.tmp` files (older than 5 min) from crashed downloads are cleaned up automatically on each call.
|
||||
- `copy_from_cache_to_temp({cache_root, hash, temp_root, filename, hash_prefix_length?})` — **Preferred primitive.** Copies a cached file to temp and returns `{ success, path }`. The Svelte caller decides what to do next (run a script, open it, etc.).
|
||||
- `launch_from_cache({cache_root, hash, temp_root, filename, hash_prefix_length?, script_template?})` — Combines copy + launch in one call. Uses `script_template` if provided, otherwise falls back to hardcoded extension logic. See **Configurable Launch Scripts** below.
|
||||
- `launch_from_cache({cache_root, hash, temp_root, filename, hash_prefix_length?, native_template?})` — Combines copy + launch in one call. Executes the provided `native_template` string after the file is copied to temp. If no template is supplied, treat it as an error and do not rely on Electron-side defaults.
|
||||
|
||||
> `hash_prefix_length` defaults to `2` throughout. Do not change without coordinating all devices — mismatched values create orphaned cache subdirectories.
|
||||
|
||||
@@ -180,22 +184,30 @@ All paths passed to native handlers should use tokens rather than hardcoded OS p
|
||||
|
||||
---
|
||||
|
||||
## 8. Configurable Launch Scripts (No-Rebuild File Handling)
|
||||
## 8. Launch Profiles and Native Templates (No-Rebuild File Handling)
|
||||
This launcher uses two related concepts:
|
||||
|
||||
To avoid requiring a full Electron rebuild for changes to how files are opened, `launch_from_cache`
|
||||
supports an optional `script_template` parameter. When provided, Electron runs the template
|
||||
instead of its built-in hardcoded logic. The hardcoded logic remains intact as the fallback
|
||||
when no template is configured.
|
||||
- **Launch Profile**: the Svelte-side config object keyed by file extension. A profile decides
|
||||
which app to use, whether to extend or mirror displays, whether to use an explicit open
|
||||
command, whether to run post-open automation, and how long to wait before running it.
|
||||
- **Native Template**: the single AppleScript or shell command string handed to Electron after
|
||||
Svelte resolves the profile. This is what Electron actually executes.
|
||||
|
||||
### Template Formats
|
||||
The Svelte launcher resolves a profile and then passes a native template string to
|
||||
`launch_from_cache`. Electron only executes the template it receives. If Svelte has not
|
||||
resolved a template yet, it should stop before IPC and surface a missing-profile error.
|
||||
This keeps all fallback logic in Svelte, where it can be edited without rebuilding Electron.
|
||||
The native layer should not invent or guess a default launch path.
|
||||
|
||||
### Native Template Formats
|
||||
|
||||
| Format | Example |
|
||||
| :--- | :--- |
|
||||
| **AppleScript** (macOS) | Multi-line AppleScript string with `{{path}}` placeholder |
|
||||
| **Shell command** | String prefixed with `shell:` — e.g. `shell:open "{{path}}"` |
|
||||
|
||||
The placeholder `{{path}}` is replaced with the full resolved path to the file in the
|
||||
temp directory (after the atomic copy from cache).
|
||||
The placeholder `{{path}}` is replaced with the full resolved path to the file in the temp
|
||||
directory after the atomic copy from cache.
|
||||
|
||||
### Where to Configure
|
||||
|
||||
@@ -207,13 +219,20 @@ Launch profiles are resolved in priority order by `get_launch_profile()` in
|
||||
2. **`$events_loc.launcher.launch_profiles`** — Local persistent config. Editable via the
|
||||
Launcher config UI (planned) or direct `localStorage` manipulation.
|
||||
|
||||
If neither is set, `script_template` is `null` and Electron uses its built-in hardcoded defaults.
|
||||
If neither is set, the resolved native template is `null` and the launcher should not call
|
||||
Electron until an explicit template is available.
|
||||
|
||||
Why: this avoids a second hidden source of truth. The profile map can evolve independently of
|
||||
the executable string, and Electron stays a thin executor rather than a policy engine.
|
||||
|
||||
### Key Format
|
||||
|
||||
Keys are lowercase file extensions without the dot. A `"default"` key catches all
|
||||
unrecognised extensions.
|
||||
|
||||
The JSON below illustrates the `native_template` emitted after profile resolution, not the
|
||||
full Launch Profile object schema.
|
||||
|
||||
```json
|
||||
// event_device.data_json.launch_profiles example
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user