@skyvexsoftware/stratos-sdk 0.1.10 → 0.1.12
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 +49 -43
- package/dist/bin/deploy.d.ts +13 -0
- package/dist/bin/deploy.js +154 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ my-plugin/
|
|
|
42
42
|
│ │ ├── index.tsx # UI entry (default export: React component)
|
|
43
43
|
│ │ └── global.css # Tailwind CSS
|
|
44
44
|
│ └── background/ # Optional: main process module
|
|
45
|
-
│ └── index.ts #
|
|
45
|
+
│ └── index.ts # export default createPlugin({...})
|
|
46
46
|
└── assets/
|
|
47
47
|
├── icon-light.svg # Sidebar icon (dark theme)
|
|
48
48
|
└── icon-dark.svg # Sidebar icon (light theme)
|
|
@@ -77,7 +77,7 @@ The `vite` option accepts any Vite config to merge in (plugins, resolve, css, et
|
|
|
77
77
|
|
|
78
78
|
## Plugin Manifest
|
|
79
79
|
|
|
80
|
-
`plugin.json` defines your plugin's metadata
|
|
80
|
+
`plugin.json` defines your plugin's metadata. Background modules don't need manifest configuration — the shell discovers them automatically if `background/index.js` exists in the built output.
|
|
81
81
|
|
|
82
82
|
```json
|
|
83
83
|
{
|
|
@@ -87,7 +87,7 @@ The `vite` option accepts any Vite config to merge in (plugins, resolve, css, et
|
|
|
87
87
|
"name": "My Plugin",
|
|
88
88
|
"version": "0.1.0",
|
|
89
89
|
"description": "A Stratos plugin",
|
|
90
|
-
"author": { "id": "my-org", "name": "My
|
|
90
|
+
"author": { "id": "my-org", "name": "My Organisation" },
|
|
91
91
|
"icon_light": "icon-light.svg",
|
|
92
92
|
"icon_dark": "icon-dark.svg"
|
|
93
93
|
}
|
|
@@ -110,7 +110,7 @@ function MyComponent() {
|
|
|
110
110
|
pluginId,
|
|
111
111
|
auth, // { isAuthenticated, token, user }
|
|
112
112
|
airline, // { id, name, icao, logo_light, logo_dark }
|
|
113
|
-
config, // { get(key, defaultValue) }
|
|
113
|
+
config, // { get(key, defaultValue?) } — airline-scoped settings
|
|
114
114
|
navigation, // { navigateTo, navigateToPlugin, navigateToShell }
|
|
115
115
|
toast, // { success, error, info, warning }
|
|
116
116
|
logger, // { info, warn, error, debug }
|
|
@@ -120,84 +120,90 @@ function MyComponent() {
|
|
|
120
120
|
|
|
121
121
|
Individual hooks are also available:
|
|
122
122
|
|
|
123
|
-
| Hook |
|
|
124
|
-
| ---------------------- |
|
|
125
|
-
| `usePluginContext()` |
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
123
|
+
| Hook | Description |
|
|
124
|
+
| ---------------------- | ---------------------------------------------- |
|
|
125
|
+
| `usePluginContext()` | All shell services combined |
|
|
126
|
+
| `useSimData()` | Real-time simulator data (RAF-throttled) |
|
|
127
|
+
| `useFlightPhase()` | Current flight phase with selector support |
|
|
128
|
+
| `useFlightEvents()` | Flight event log with comment mutations |
|
|
129
|
+
| `useFlightManager()` | Low-level flight lifecycle control |
|
|
130
|
+
| `useTrackingSession()` | High-level tracking state with derived fields |
|
|
131
|
+
| `useLandingAnalysis()` | Landing rate, bounces, and settled analysis |
|
|
132
|
+
| `useShellAuth()` | Authentication state and token |
|
|
133
|
+
| `useShellConfig()` | Scoped configuration access |
|
|
134
|
+
| `useShellNavigation()` | Route navigation utilities |
|
|
135
|
+
| `useShellToast()` | Toast/notification functions |
|
|
136
|
+
| `usePluginLogger()` | Scoped renderer-side logger |
|
|
131
137
|
|
|
132
138
|
### Background Module
|
|
133
139
|
|
|
134
|
-
Optional main-process code with access to IPC, Express routes, SQLite, and more:
|
|
140
|
+
Optional main-process code with access to IPC, Express routes, SQLite, and more. Must use the `createPlugin` helper (imported from the `/helpers` subpath) with a default export:
|
|
135
141
|
|
|
136
142
|
```ts
|
|
137
|
-
import { createPlugin } from "@skyvexsoftware/stratos-sdk";
|
|
143
|
+
import { createPlugin } from "@skyvexsoftware/stratos-sdk/helpers";
|
|
138
144
|
|
|
139
145
|
export default createPlugin({
|
|
140
146
|
async onStart(ctx) {
|
|
141
|
-
// ctx.logger
|
|
142
|
-
// ctx.config
|
|
143
|
-
// ctx.ipc
|
|
144
|
-
// ctx.auth
|
|
145
|
-
// ctx.server
|
|
147
|
+
// ctx.logger — scoped logger
|
|
148
|
+
// ctx.config — per-plugin config store (async)
|
|
149
|
+
// ctx.ipc — IPC handler registration
|
|
150
|
+
// ctx.auth — read-only auth token access (async)
|
|
151
|
+
// ctx.server — Express router registration
|
|
146
152
|
// ctx.database — SQLite database access
|
|
147
153
|
ctx.logger.info("MyPlugin", "Started");
|
|
148
154
|
},
|
|
149
|
-
async onStop() {
|
|
150
|
-
|
|
155
|
+
async onStop(ctx) {
|
|
156
|
+
ctx.logger.info("MyPlugin", "Stopped");
|
|
151
157
|
},
|
|
152
158
|
});
|
|
153
159
|
```
|
|
154
160
|
|
|
155
|
-
|
|
161
|
+
Named exports are not supported — the shell requires the `createPlugin` default export pattern for type safety and validation.
|
|
156
162
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```tsx
|
|
160
|
-
import { PluginRouter } from "@skyvexsoftware/stratos-sdk";
|
|
163
|
+
### UI Components
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
{ path: "home", component: HomePage },
|
|
164
|
-
{ path: "settings", component: SettingsPage },
|
|
165
|
-
{ path: "detail/:id", component: DetailPage },
|
|
166
|
-
];
|
|
165
|
+
Pre-styled shadcn/ui components that match the Stratos design system:
|
|
167
166
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
167
|
+
```tsx
|
|
168
|
+
import { Button, Card, CardContent, Input, Dialog } from "@skyvexsoftware/stratos-sdk";
|
|
171
169
|
```
|
|
172
170
|
|
|
173
|
-
|
|
171
|
+
Available: Button, Card, Dialog, Input, Label, Select, Badge, Separator, Tabs, Tooltip, AlertDialog, RadioGroup, Slider, Switch, Textarea.
|
|
174
172
|
|
|
175
|
-
###
|
|
173
|
+
### Icons
|
|
176
174
|
|
|
177
|
-
|
|
175
|
+
The full [Lucide](https://lucide.dev) icon set is available via `STRATOS_ICONS`:
|
|
178
176
|
|
|
179
177
|
```tsx
|
|
180
|
-
import {
|
|
178
|
+
import { STRATOS_ICONS, STRATOS_ICON_NAMES } from "@skyvexsoftware/stratos-sdk";
|
|
179
|
+
|
|
180
|
+
const Icon = STRATOS_ICONS["Helicopter"];
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
Or import icons directly from `lucide-react` in your plugin.
|
|
184
184
|
|
|
185
185
|
### Types
|
|
186
186
|
|
|
187
187
|
```ts
|
|
188
|
-
import { FlightPhase,
|
|
188
|
+
import { FlightPhase, EventCategory } from "@skyvexsoftware/stratos-sdk";
|
|
189
189
|
import type { FlightData, PluginManifest, PluginContext } from "@skyvexsoftware/stratos-sdk";
|
|
190
190
|
```
|
|
191
191
|
|
|
192
192
|
### Utilities
|
|
193
193
|
|
|
194
194
|
```ts
|
|
195
|
-
import { cn } from "@skyvexsoftware/stratos-sdk";
|
|
196
|
-
|
|
197
195
|
// Tailwind class merging
|
|
196
|
+
import { cn } from "@skyvexsoftware/stratos-sdk";
|
|
198
197
|
cn("bg-red-500", isActive && "text-white", className);
|
|
198
|
+
|
|
199
|
+
// Unit conversion helpers
|
|
200
|
+
import { weightFromLbs, formatAltitude } from "@skyvexsoftware/stratos-sdk/helpers";
|
|
199
201
|
```
|
|
200
202
|
|
|
201
|
-
##
|
|
203
|
+
## Documentation
|
|
204
|
+
|
|
205
|
+
Full documentation is available at [docs.skyvexsoftware.com](https://docs.skyvexsoftware.com).
|
|
206
|
+
|
|
207
|
+
## Licence
|
|
202
208
|
|
|
203
209
|
MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* stratos-deploy — Bundle and upload a Stratos plugin.
|
|
4
|
+
*
|
|
5
|
+
* Zips dist/ into bundle.zip. If SKYVEX_API_TOKEN is set, uploads to the
|
|
6
|
+
* Skyvex API. Otherwise outputs the zip path for manual upload.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* stratos-deploy # from plugin root after pnpm build
|
|
10
|
+
* pnpm bundle # if package.json has "bundle": "pnpm build && stratos-deploy"
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* stratos-deploy — Bundle and upload a Stratos plugin.
|
|
4
|
+
*
|
|
5
|
+
* Zips dist/ into bundle.zip. If SKYVEX_API_TOKEN is set, uploads to the
|
|
6
|
+
* Skyvex API. Otherwise outputs the zip path for manual upload.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* stratos-deploy # from plugin root after pnpm build
|
|
10
|
+
* pnpm bundle # if package.json has "bundle": "pnpm build && stratos-deploy"
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from "fs";
|
|
13
|
+
import * as path from "path";
|
|
14
|
+
import { execSync } from "child_process";
|
|
15
|
+
import * as https from "https";
|
|
16
|
+
import * as http from "http";
|
|
17
|
+
const API_BASE = "https://skyvexsoftware.com/api/stratos";
|
|
18
|
+
// ── Helpers ──────────────────────────────────────────────────────────
|
|
19
|
+
function fatal(message) {
|
|
20
|
+
console.error(`\n Error: ${message}\n`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
function formatSize(bytes) {
|
|
24
|
+
if (bytes < 1024)
|
|
25
|
+
return `${bytes} B`;
|
|
26
|
+
if (bytes < 1024 * 1024)
|
|
27
|
+
return `${(bytes / 1024).toFixed(1)} kB`;
|
|
28
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
29
|
+
}
|
|
30
|
+
// ── Validation ───────────────────────────────────────────────────────
|
|
31
|
+
function validateBuild(cwd) {
|
|
32
|
+
const distDir = path.join(cwd, "dist");
|
|
33
|
+
const manifestPath = path.join(distDir, "plugin.json");
|
|
34
|
+
if (!fs.existsSync(manifestPath)) {
|
|
35
|
+
fatal("No built plugin found. Run pnpm build first.");
|
|
36
|
+
}
|
|
37
|
+
const uiEntry = path.join(distDir, "ui", "index.js");
|
|
38
|
+
if (!fs.existsSync(uiEntry)) {
|
|
39
|
+
fatal("Build output incomplete — missing ui/index.js");
|
|
40
|
+
}
|
|
41
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
42
|
+
if (!manifest.id || !manifest.version) {
|
|
43
|
+
fatal("plugin.json missing required fields: id, version");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
id: manifest.id,
|
|
47
|
+
version: manifest.version,
|
|
48
|
+
name: manifest.name ?? manifest.id,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// ── Zip ──────────────────────────────────────────────────────────────
|
|
52
|
+
function createBundle(cwd) {
|
|
53
|
+
const bundlePath = path.join(cwd, "bundle.zip");
|
|
54
|
+
// Remove stale bundle
|
|
55
|
+
if (fs.existsSync(bundlePath)) {
|
|
56
|
+
fs.unlinkSync(bundlePath);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
execSync("zip -r ../bundle.zip .", {
|
|
60
|
+
cwd: path.join(cwd, "dist"),
|
|
61
|
+
stdio: "pipe",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
fatal("Failed to create bundle.zip. Ensure 'zip' is installed.");
|
|
66
|
+
}
|
|
67
|
+
return bundlePath;
|
|
68
|
+
}
|
|
69
|
+
// ── Upload ───────────────────────────────────────────────────────────
|
|
70
|
+
function upload(pluginId, version, bundlePath, token) {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
const boundary = `----StratosDeploy${Date.now()}`;
|
|
73
|
+
const fileContent = fs.readFileSync(bundlePath);
|
|
74
|
+
const parts = [];
|
|
75
|
+
// Version field
|
|
76
|
+
parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="version"\r\n\r\n${version}\r\n`));
|
|
77
|
+
// File field
|
|
78
|
+
parts.push(Buffer.from(`--${boundary}\r\nContent-Disposition: form-data; name="file"; filename="bundle.zip"\r\nContent-Type: application/zip\r\n\r\n`));
|
|
79
|
+
parts.push(fileContent);
|
|
80
|
+
parts.push(Buffer.from(`\r\n--${boundary}--\r\n`));
|
|
81
|
+
const body = Buffer.concat(parts);
|
|
82
|
+
const url = new URL(`${API_BASE}/plugins/${pluginId}/versions`);
|
|
83
|
+
const options = {
|
|
84
|
+
hostname: url.hostname,
|
|
85
|
+
port: url.port || 443,
|
|
86
|
+
path: url.pathname,
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: {
|
|
89
|
+
Authorization: `Bearer ${token}`,
|
|
90
|
+
"Content-Type": `multipart/form-data; boundary=${boundary}`,
|
|
91
|
+
"Content-Length": body.length,
|
|
92
|
+
Accept: "application/json",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
const transport = url.protocol === "https:" ? https : http;
|
|
96
|
+
const req = transport.request(options, (res) => {
|
|
97
|
+
let data = "";
|
|
98
|
+
res.on("data", (chunk) => (data += chunk.toString()));
|
|
99
|
+
res.on("end", () => resolve({
|
|
100
|
+
ok: res.statusCode === 201,
|
|
101
|
+
status: res.statusCode ?? 0,
|
|
102
|
+
body: data,
|
|
103
|
+
}));
|
|
104
|
+
});
|
|
105
|
+
req.on("error", (err) => resolve({ ok: false, status: 0, body: err.message }));
|
|
106
|
+
req.write(body);
|
|
107
|
+
req.end();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// ── Main ─────────────────────────────────────────────────────────────
|
|
111
|
+
async function main() {
|
|
112
|
+
const cwd = process.cwd();
|
|
113
|
+
const { id, version, name } = validateBuild(cwd);
|
|
114
|
+
const bundlePath = createBundle(cwd);
|
|
115
|
+
const bundleSize = fs.statSync(bundlePath).size;
|
|
116
|
+
console.log(`\n ${name} v${version} — bundle.zip (${formatSize(bundleSize)})`);
|
|
117
|
+
const token = process.env.SKYVEX_API_TOKEN;
|
|
118
|
+
if (token) {
|
|
119
|
+
console.log(" Uploading to Skyvex...");
|
|
120
|
+
const result = await upload(id, version, bundlePath, token);
|
|
121
|
+
if (result.ok) {
|
|
122
|
+
console.log(" Published! Server is signing and publishing to CDN.\n");
|
|
123
|
+
fs.unlinkSync(bundlePath);
|
|
124
|
+
}
|
|
125
|
+
else if (result.status === 422) {
|
|
126
|
+
try {
|
|
127
|
+
const errors = JSON.parse(result.body);
|
|
128
|
+
const messages = errors.errors
|
|
129
|
+
? Object.values(errors.errors).flat().join(", ")
|
|
130
|
+
: (errors.message ?? result.body);
|
|
131
|
+
fatal(`Validation failed: ${messages}`);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
fatal(`Validation failed (${result.status}): ${result.body}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (result.status === 401) {
|
|
138
|
+
fatal("Authentication failed. Check your SKYVEX_API_TOKEN.");
|
|
139
|
+
}
|
|
140
|
+
else if (result.status === 403) {
|
|
141
|
+
fatal("Permission denied. You do not own this plugin.");
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
fatal(`Upload failed (${result.status}): ${result.body}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.log(" No SKYVEX_API_TOKEN found.");
|
|
149
|
+
console.log(" Upload manually at https://skyvexsoftware.com");
|
|
150
|
+
console.log(" Or set SKYVEX_API_TOKEN to deploy from the CLI\n");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
main();
|
|
154
|
+
//# sourceMappingURL=deploy.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyvexsoftware/stratos-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Plugin SDK for Stratos — types, hooks, and UI components",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Skyvex Software",
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"import": "./dist/vite/plugin-config.js"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
+
"bin": {
|
|
49
|
+
"stratos-deploy": "./dist/bin/deploy.js"
|
|
50
|
+
},
|
|
48
51
|
"files": [
|
|
49
52
|
"dist",
|
|
50
53
|
"!dist/**/*.map"
|
|
@@ -72,11 +75,11 @@
|
|
|
72
75
|
"@radix-ui/react-tabs": "^1.1.0",
|
|
73
76
|
"@radix-ui/react-tooltip": "^1.1.0",
|
|
74
77
|
"@tanstack/react-query": "^5.0.0",
|
|
78
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
75
79
|
"class-variance-authority": "^0.7.0",
|
|
76
80
|
"lucide-react": ">=0.300.0",
|
|
77
81
|
"react": "^19.0.0",
|
|
78
82
|
"socket.io-client": "^4.0.0",
|
|
79
|
-
"@vitejs/plugin-react": "^5.0.0",
|
|
80
83
|
"vite": "^7.0.0"
|
|
81
84
|
},
|
|
82
85
|
"dependencies": {
|
|
@@ -96,9 +99,9 @@
|
|
|
96
99
|
"@radix-ui/react-tabs": "^1.1.8",
|
|
97
100
|
"@radix-ui/react-tooltip": "^1.1.12",
|
|
98
101
|
"@types/react": "^19.1.2",
|
|
99
|
-
"class-variance-authority": "^0.7.1",
|
|
100
|
-
"lucide-react": "^0.503.0",
|
|
101
102
|
"@vitejs/plugin-react": "^5.1.4",
|
|
103
|
+
"class-variance-authority": "^0.7.1",
|
|
104
|
+
"lucide-react": "^0.577.0",
|
|
102
105
|
"socket.io-client": "^4.8.3",
|
|
103
106
|
"typescript": "^5.8.3",
|
|
104
107
|
"vite": "^7.3.1"
|