@stnd/launcher 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Launcher.svelte +1067 -0
- package/README.md +177 -0
- package/launcher.ts +577 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "@stnd/launcher"
|
|
3
|
+
aliases: []
|
|
4
|
+
created: 2026-07-05 07:42
|
|
5
|
+
modified: 2026-07-05 19:23
|
|
6
|
+
last_audited: 2026-07-14
|
|
7
|
+
audit_interval_days: 90
|
|
8
|
+
next_audit: 2026-10-12
|
|
9
|
+
audit_priority: 3
|
|
10
|
+
maturity: tree
|
|
11
|
+
mode: read
|
|
12
|
+
publish: false
|
|
13
|
+
status: active
|
|
14
|
+
tags:
|
|
15
|
+
- package
|
|
16
|
+
- stnd
|
|
17
|
+
theme: kernel
|
|
18
|
+
type: package
|
|
19
|
+
visibility: private
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# @[stnd](../README)/launcher
|
|
23
|
+
|
|
24
|
+
The Universal Command Palette engine for the Standard Framework.
|
|
25
|
+
|
|
26
|
+
`@stnd/launcher` provides a centralized interface for command execution, navigation, and view management. It adheres to the *“Standard”* design philosophy: clean, keyboard-centric, and extensible.
|
|
27
|
+
|
|
28
|
+
## ELI5
|
|
29
|
+
|
|
30
|
+
Cmd+K on any Standard site — that’s this. A registry holds every command and *“view”* (a full Svelte panel, like Settings or the file navigator) any loaded module has registered; the palette searches across all of it. A module adds its own command by calling `register()` once; it shows up in the palette for everyone, no wiring needed on the app’s side.
|
|
31
|
+
|
|
32
|
+
**It’s already on** — `@stnd/launcher` is a Gold Standard module. To add your own command from inside a module:
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { register } from "@stnd/launcher";
|
|
36
|
+
register("::my-command", { title: "Do the thing", icon: "star" }, () => doTheThing());
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
The Launcher follows a **Reactive Core** pattern:
|
|
42
|
+
|
|
43
|
+
- **Engine (`launcher.ts`)**: Manages state (registry, palette, views), search logic, and public API.
|
|
44
|
+
- **UI (`Launcher.svelte`)**: A *“dumb”* view component that subscribes to the engine state and renders the appropriate interface.
|
|
45
|
+
- **Modules**: Extend the launcher by registering commands and views via `virtual:stnd/components`.
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Import and mount the `<Launcher />` component in your layout:
|
|
50
|
+
|
|
51
|
+
```svelte
|
|
52
|
+
<script>
|
|
53
|
+
import Launcher from "@stnd/launcher/Launcher.svelte";
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<!--
|
|
57
|
+
load: Optional allow-list of commands/views to enable.
|
|
58
|
+
If omitted, all registered commands are loaded.
|
|
59
|
+
-->
|
|
60
|
+
<Launcher load={["::navigator", "::search"]} />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
| :------------ | :------------------------------- | :------ | :---------------------------------------- |
|
|
67
|
+
| `load` | `string \| string[] \| function` | `null` | Filter specific commands/views to load. |
|
|
68
|
+
| `userStore` | `readable` | `null` | Svelte store containing the current user. |
|
|
69
|
+
| `searchNotes` | `function` | `null` | Async function to search app content. |
|
|
70
|
+
| `WelcomeView` | `Component` | `null` | Custom component for the empty state. |
|
|
71
|
+
|
|
72
|
+
## Core Concepts
|
|
73
|
+
|
|
74
|
+
### Registry
|
|
75
|
+
|
|
76
|
+
The registry holds all available **Commands** and **Views**.
|
|
77
|
+
|
|
78
|
+
- **Commands**: Executable actions (functions).
|
|
79
|
+
- **Views**: Interactive components rendered within the launcher window.
|
|
80
|
+
|
|
81
|
+
### Sizing
|
|
82
|
+
|
|
83
|
+
The launcher window adapts to its content.
|
|
84
|
+
|
|
85
|
+
- **Standard**: Default command palette size.
|
|
86
|
+
- **Wide**: Extended width for rich content.
|
|
87
|
+
- **Tall**: Extended height for browsing.
|
|
88
|
+
|
|
89
|
+
Views can request size changes dynamically:
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
// In your view component
|
|
93
|
+
let { setSize } = $props();
|
|
94
|
+
|
|
95
|
+
// Expand window
|
|
96
|
+
setSize({ width: "wide", height: "tall" });
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Built-in Views
|
|
100
|
+
|
|
101
|
+
### `::navigator` (Browser)
|
|
102
|
+
|
|
103
|
+
The creation of a browser-like experience within the OS.
|
|
104
|
+
|
|
105
|
+
- **Trigger**: `::navigator`
|
|
106
|
+
- **Behavior**: Starts compact, expands to a full browser window when a URL is loaded.
|
|
107
|
+
- **Usage**:
|
|
108
|
+
|
|
109
|
+
```html
|
|
110
|
+
<button data-launcher-navigator="https://google.com">Open Google</button>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### `::settings` (Complex Layout Example)
|
|
114
|
+
|
|
115
|
+
A reference implementation of a two-column sidebar layout acting as a *“Settings”* or *“Profile”* page. It demonstrates:
|
|
116
|
+
|
|
117
|
+
- Sidebar navigation.
|
|
118
|
+
- Dynamic responsive sizing (starts `wide` & `tall`).
|
|
119
|
+
- Mock form controls.
|
|
120
|
+
|
|
121
|
+
Source: `packages/views/SettingsView.svelte` (shipped by `@stnd/views`)
|
|
122
|
+
|
|
123
|
+
## API (`launcher.ts`)
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import {
|
|
127
|
+
initLauncher,
|
|
128
|
+
register,
|
|
129
|
+
launcherView,
|
|
130
|
+
launcherToggle,
|
|
131
|
+
setSize,
|
|
132
|
+
} from "@stnd/launcher";
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `initLauncher(options)`
|
|
136
|
+
|
|
137
|
+
Initialize the engine with app-specific logic.
|
|
138
|
+
|
|
139
|
+
### `register(trigger, meta, handler)`
|
|
140
|
+
|
|
141
|
+
Register a new command or view.
|
|
142
|
+
|
|
143
|
+
- **trigger**: Unique ID (e.g., `::my-view`).
|
|
144
|
+
- **meta**: Configuration object for the command/view.
|
|
145
|
+
- `title` (string): Display name.
|
|
146
|
+
- `desc` (string): Short description.
|
|
147
|
+
- `icon` (string): Icon identifier.
|
|
148
|
+
- `size` (object): Window dimensions `{ width, height }`.
|
|
149
|
+
- `requireAuth` (boolean): If `true`, only shown to authenticated users.
|
|
150
|
+
- `requireGuest` (boolean): If `true`, only shown to unauthenticated users.
|
|
151
|
+
- `requireRole` (string | string[]): Restricts visibility to users with specific roles (e.g., `"admin"`).
|
|
152
|
+
- `context` (string | string[]): Restricts visibility to specific application states (e.g., `"editor"`).
|
|
153
|
+
- **handler**: Function (action) or Svelte Component (view).
|
|
154
|
+
|
|
155
|
+
### `launcherView(view, props)`
|
|
156
|
+
|
|
157
|
+
Switch the active view.
|
|
158
|
+
|
|
159
|
+
- **view**: Trigger ID of the view.
|
|
160
|
+
- **props**: Data to pass to the view component.
|
|
161
|
+
|
|
162
|
+
## Data Attributes
|
|
163
|
+
|
|
164
|
+
The UI listens for clicks on elements with specific data attributes:
|
|
165
|
+
|
|
166
|
+
- `data-launcher-toggle`: Toggles the launcher.
|
|
167
|
+
- `data-launcher-view="::id"`: Opens a specific view.
|
|
168
|
+
- `data-launcher-navigator="url"`: Opens the navigator with a URL.
|
|
169
|
+
- `data-launcher-prompt="text"`: Opens launcher with pre-filled text.
|
|
170
|
+
|
|
171
|
+
## Notes / Observations
|
|
172
|
+
|
|
173
|
+
*(jot down anything noticed here — quirks, gotchas, ideas)*
|
|
174
|
+
|
|
175
|
+
## Todo
|
|
176
|
+
|
|
177
|
+
- [ ] Nothing tracked yet. [priority:: 3] [token_scale:: 3] [created:: 2026-07-14] [area:: framework]
|