@skyvexsoftware/stratos-sdk 0.1.6 → 0.1.7

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/README.md CHANGED
@@ -16,169 +16,177 @@ Scaffold a new plugin project:
16
16
  pnpx create-stratos-plugin
17
17
  ```
18
18
 
19
- Or manually create a project with `plugin.json`, `vite.config.ts`, and `src/ui/index.tsx`. See the [plugin developer guide](https://skyvexsoftware.com/docs/plugins) for details.
19
+ This generates a ready-to-develop plugin with Tailwind CSS, TypeScript, and Vite preconfigured.
20
20
 
21
- ## Available APIs
21
+ ### Development
22
22
 
23
- ### Plugin Contract Types
23
+ 1. Open the Stratos app with `--dev` flag
24
+ 2. In your plugin directory, run:
24
25
 
25
- Type definitions for the plugin system:
26
-
27
- ```ts
28
- import type {
29
- PluginManifest,
30
- PluginContext,
31
- PluginUIContext,
32
- PluginBackgroundModule,
33
- PluginUIModule,
34
- } from "@skyvexsoftware/stratos-sdk";
26
+ ```bash
27
+ pnpm dev
35
28
  ```
36
29
 
37
- ### Vite Plugin Config
30
+ Your plugin auto-connects to the running Stratos app and appears in the sidebar. Code changes auto-reload.
38
31
 
39
- The SDK provides a shared Vite configuration for building plugins:
32
+ ### Project Structure
40
33
 
41
- ```ts
42
- import { createPluginConfig } from "@skyvexsoftware/stratos-sdk/vite";
43
-
44
- export default createPluginConfig({
45
- pluginDir: import.meta.dirname,
46
- ui: { entry: "src/ui/index.tsx" },
47
- background: { entry: "src/background/index.ts" }, // optional
48
- });
34
+ ```
35
+ my-plugin/
36
+ ├── plugin.json # Plugin manifest (name, version, author, settings)
37
+ ├── package.json
38
+ ├── vite.config.ts # Uses createPluginConfig from SDK
39
+ ├── tsconfig.json
40
+ ├── src/
41
+ │ ├── ui/
42
+ │ │ ├── index.tsx # UI entry (default export: React component)
43
+ │ │ └── global.css # Tailwind CSS
44
+ │ └── background/ # Optional: main process module
45
+ │ └── index.ts # Exports onStart(ctx) and onStop()
46
+ └── assets/
47
+ ├── icon-light.svg # Sidebar icon (dark theme)
48
+ └── icon-dark.svg # Sidebar icon (light theme)
49
49
  ```
50
50
 
51
- This handles UI bundling with externals, background module builds, asset copying, dev server auto-connect, and HMR.
51
+ ### Building
52
+
53
+ ```bash
54
+ pnpm build # Build for distribution
55
+ ```
52
56
 
53
- ### Helper Functions
57
+ Produces `dist/` with bundled UI, background module (if any), manifest, and assets. Zip and upload to the Skyvex website.
54
58
 
55
- #### `createPlugin(module)`
59
+ ## Vite Config
56
60
 
57
- Validates and returns a typed plugin background module:
61
+ The SDK provides `createPluginConfig` which handles bundling, externals, dev server auto-connect, and asset copying:
58
62
 
59
63
  ```ts
60
- import { createPlugin } from "@skyvexsoftware/stratos-sdk";
64
+ import { createPluginConfig } from "@skyvexsoftware/stratos-sdk/vite";
65
+ import tailwindcss from "@tailwindcss/vite";
61
66
 
62
- export default createPlugin({
63
- async onStart(ctx) {
64
- ctx.logger.info("MyPlugin", "Starting...");
65
- },
66
- async onStop() {
67
- // cleanup
67
+ export default createPluginConfig({
68
+ ui: { entry: "src/ui/index.tsx" },
69
+ background: { entry: "src/background/index.ts" }, // optional
70
+ vite: {
71
+ plugins: [tailwindcss()],
68
72
  },
69
73
  });
70
74
  ```
71
75
 
72
- #### `PluginRouter` component
73
-
74
- Optional lightweight router for plugins that need internal multi-page navigation:
76
+ The `vite` option accepts any Vite config to merge in (plugins, resolve, css, etc.).
75
77
 
76
- ```tsx
77
- import { PluginRouter } from "@skyvexsoftware/stratos-sdk";
78
- import TrackingPage from "./pages/TrackingPage";
79
- import HistoryPage from "./pages/HistoryPage";
80
- import HistoryDetailPage from "./pages/HistoryDetailPage";
78
+ ## Plugin Manifest
81
79
 
82
- const routes = [
83
- { path: "tracking", component: TrackingPage },
84
- { path: "history", component: HistoryPage },
85
- { path: "history/:id", component: HistoryDetailPage },
86
- ];
80
+ `plugin.json` defines your plugin's metadata:
87
81
 
88
- export default function MyPluginRoot() {
89
- return <PluginRouter routes={routes} defaultPath="tracking" />;
82
+ ```json
83
+ {
84
+ "$schema": "https://cdn.skyvexsoftware.com/schemas/stratos-plugin.json",
85
+ "id": "my-plugin",
86
+ "type": "airline",
87
+ "name": "My Plugin",
88
+ "version": "0.1.0",
89
+ "description": "A Stratos plugin",
90
+ "author": { "id": "my-org", "name": "My Organization" },
91
+ "icon_light": "icon-light.svg",
92
+ "icon_dark": "icon-dark.svg"
90
93
  }
91
94
  ```
92
95
 
93
- For single-page plugins, just export the component directly:
96
+ - `type`: `"airline"` (scoped to a virtual airline) or `"user"` (user-installed)
97
+ - `availableSettings`: Optional array of setting definitions (boolean, text, number, list, etc.)
94
98
 
95
- ```tsx
96
- import HomePage from "./HomePage";
97
- export default HomePage;
98
- ```
99
+ ## API Reference
99
100
 
100
- #### `usePluginRoute()`
101
+ ### UI Context
101
102
 
102
- Returns the current sub-path within the plugin (the URL portion after `/plugins/{pluginId}/`):
103
+ Access shell services from plugin components:
103
104
 
104
105
  ```tsx
105
- import { usePluginRoute } from "@skyvexsoftware/stratos-sdk";
106
+ import { usePluginContext } from "@skyvexsoftware/stratos-sdk";
106
107
 
107
108
  function MyComponent() {
108
- const { subPath } = usePluginRoute();
109
- // e.g. "history/abc123"
110
- }
111
- ```
112
-
113
- #### `usePluginParams()`
114
-
115
- Access route params matched by `PluginRouter` (e.g. `history/:id`):
116
-
117
- ```tsx
118
- import { usePluginParams } from "@skyvexsoftware/stratos-sdk";
119
-
120
- function DetailPage() {
121
- const { id } = usePluginParams<{ id: string }>();
122
- // id === "abc123" when URL is /plugins/my-plugin/history/abc123
109
+ const {
110
+ pluginId,
111
+ auth, // { isAuthenticated, token, user }
112
+ airline, // { id, name, icao, logo_light, logo_dark }
113
+ config, // { get(key, defaultValue) }
114
+ navigation, // { navigateTo, navigateToPlugin, navigateToShell }
115
+ toast, // { success, error, info, warning }
116
+ logger, // { info, warn, error, debug }
117
+ } = usePluginContext();
123
118
  }
124
119
  ```
125
120
 
126
- ### React Hooks
127
-
128
- Access shell services from plugin components. All hooks must be used within a `PluginShellProvider` (provided by the shell at runtime).
121
+ Individual hooks are also available:
129
122
 
130
123
  | Hook | Returns | Description |
131
124
  | ---------------------- | -------------------- | ------------------------------ |
125
+ | `usePluginContext()` | Full PluginUIContext | All services combined |
132
126
  | `useShellAuth()` | Auth state | Authentication state and token |
133
127
  | `useShellConfig()` | Config store | Scoped configuration access |
134
128
  | `useShellNavigation()` | Navigation helpers | Route navigation utilities |
135
129
  | `useShellToast()` | Toast API | Toast/notification functions |
136
130
  | `usePluginLogger()` | Logger | Scoped renderer-side logger |
137
- | `usePluginContext()` | Full PluginUIContext | All of the above combined |
138
131
 
139
- ```tsx
140
- import { useShellAuth, useShellToast } from "@skyvexsoftware/stratos-sdk";
132
+ ### Background Module
141
133
 
142
- function MyComponent() {
143
- const { isAuthenticated } = useShellAuth();
144
- const toast = useShellToast();
145
-
146
- return (
147
- <button onClick={() => toast.success("Hello!")}>
148
- {isAuthenticated ? "Logged in" : "Not authenticated"}
149
- </button>
150
- );
151
- }
134
+ Optional main-process code with access to IPC, Express routes, SQLite, and more:
135
+
136
+ ```ts
137
+ import { createPlugin } from "@skyvexsoftware/stratos-sdk";
138
+
139
+ export default createPlugin({
140
+ async onStart(ctx) {
141
+ // ctx.logger — scoped logger
142
+ // ctx.config — per-plugin config store
143
+ // ctx.ipc — IPC handler registration
144
+ // ctx.auth — read-only auth token access
145
+ // ctx.server — Express router registration
146
+ // ctx.database — SQLite database access
147
+ ctx.logger.info("MyPlugin", "Started");
148
+ },
149
+ async onStop() {
150
+ // cleanup
151
+ },
152
+ });
152
153
  ```
153
154
 
154
- ### UI Primitives
155
+ ### Routing
155
156
 
156
- Pre-styled shadcn/ui components using Tailwind CSS and Radix UI:
157
+ For multi-page plugins, use `PluginRouter`:
157
158
 
158
159
  ```tsx
159
- import { Button, Card, CardContent, Input, Label } from "@skyvexsoftware/stratos-sdk";
160
+ import { PluginRouter } from "@skyvexsoftware/stratos-sdk";
161
+
162
+ const routes = [
163
+ { path: "home", component: HomePage },
164
+ { path: "settings", component: SettingsPage },
165
+ { path: "detail/:id", component: DetailPage },
166
+ ];
167
+
168
+ export default function Plugin() {
169
+ return <PluginRouter routes={routes} defaultPath="home" />;
170
+ }
160
171
  ```
161
172
 
162
- Available components:
173
+ For single-page plugins, just export the component directly.
174
+
175
+ ### UI Components
163
176
 
164
- - **Button** with variants: default, destructive, outline, secondary, ghost, link
165
- - **Card** — CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter
166
- - **Dialog** — DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription
167
- - **Input** text input with validation states
168
- - **Label** — form label
169
- - **Select** — SelectTrigger, SelectContent, SelectItem, SelectGroup, SelectValue
170
- - **Badge** — with variants: default, secondary, destructive, outline
171
- - **Separator** — horizontal or vertical divider
172
- - **Tabs** — TabsList, TabsTrigger, TabsContent
173
- - **Tooltip** — TooltipProvider, TooltipTrigger, TooltipContent
177
+ Pre-styled shadcn/ui components that match the Stratos design system:
178
+
179
+ ```tsx
180
+ import { Button, Card, CardContent, Input, Dialog } from "@skyvexsoftware/stratos-sdk";
181
+ ```
174
182
 
175
- ### Shared Types
183
+ Available: Button, Card, Dialog, Input, Label, Select, Badge, Separator, Tabs, Tooltip, AlertDialog, RadioGroup, Slider, Switch, Textarea.
176
184
 
177
- Common types used across plugins:
185
+ ### Types
178
186
 
179
187
  ```ts
180
188
  import { FlightPhase, SimulatorType } from "@skyvexsoftware/stratos-sdk";
181
- import type { FlightData, ThemeMode } from "@skyvexsoftware/stratos-sdk";
189
+ import type { FlightData, PluginManifest, PluginContext } from "@skyvexsoftware/stratos-sdk";
182
190
  ```
183
191
 
184
192
  ### Utilities
@@ -186,21 +194,10 @@ import type { FlightData, ThemeMode } from "@skyvexsoftware/stratos-sdk";
186
194
  ```ts
187
195
  import { cn } from "@skyvexsoftware/stratos-sdk";
188
196
 
189
- // Tailwind class merging utility
190
- cn("bg-red-500", conditional && "text-white", className);
197
+ // Tailwind class merging
198
+ cn("bg-red-500", isActive && "text-white", className);
191
199
  ```
192
200
 
193
- ## Peer Dependencies
194
-
195
- The SDK expects these to be provided by the Stratos shell at runtime:
196
-
197
- - `react` ^19.0.0
198
- - `@radix-ui/react-*` (dialog, label, select, separator, slot, tabs, tooltip)
199
- - `@tanstack/react-query` ^5.0.0
200
- - `class-variance-authority` ^0.7.0
201
- - `lucide-react` >=0.300.0
202
- - `socket.io-client` ^4.0.0
203
-
204
201
  ## License
205
202
 
206
203
  MIT
@@ -185,6 +185,19 @@ export function stratosDevServer(options) {
185
185
  process.once("SIGTERM", cleanup);
186
186
  // Start connecting after the HTTP server is listening
187
187
  server.httpServer?.once("listening", () => {
188
+ // Set the HMR port dynamically so Vite's HMR client connects
189
+ // directly to this dev server's WebSocket (cross-origin is OK for WS).
190
+ const addr = server.httpServer?.address();
191
+ if (addr && typeof addr === "object") {
192
+ server.config.server.hmr =
193
+ typeof server.config.server.hmr === "object"
194
+ ? {
195
+ ...server.config.server.hmr,
196
+ port: addr.port,
197
+ clientPort: addr.port,
198
+ }
199
+ : { port: addr.port, clientPort: addr.port };
200
+ }
188
201
  connect();
189
202
  });
190
203
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyvexsoftware/stratos-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Plugin SDK for Stratos — types, hooks, and UI components",
5
5
  "author": {
6
6
  "name": "Skyvex Software",