@skyvexsoftware/stratos-sdk 0.1.1
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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/helpers/createPlugin.d.ts +22 -0
- package/dist/helpers/createPlugin.js +32 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/units.d.ts +36 -0
- package/dist/helpers/units.js +101 -0
- package/dist/hooks/context.d.ts +12 -0
- package/dist/hooks/context.js +18 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/useFlightEvents.d.ts +37 -0
- package/dist/hooks/useFlightEvents.js +152 -0
- package/dist/hooks/useFlightManager.d.ts +20 -0
- package/dist/hooks/useFlightManager.js +90 -0
- package/dist/hooks/useFlightPhase.d.ts +31 -0
- package/dist/hooks/useFlightPhase.js +67 -0
- package/dist/hooks/useLandingAnalysis.d.ts +37 -0
- package/dist/hooks/useLandingAnalysis.js +87 -0
- package/dist/hooks/usePluginLogger.d.ts +13 -0
- package/dist/hooks/usePluginLogger.js +16 -0
- package/dist/hooks/useShellAuth.d.ts +14 -0
- package/dist/hooks/useShellAuth.js +13 -0
- package/dist/hooks/useShellConfig.d.ts +14 -0
- package/dist/hooks/useShellConfig.js +14 -0
- package/dist/hooks/useShellNavigation.d.ts +12 -0
- package/dist/hooks/useShellNavigation.js +15 -0
- package/dist/hooks/useShellToast.d.ts +12 -0
- package/dist/hooks/useShellToast.js +15 -0
- package/dist/hooks/useSimData.d.ts +70 -0
- package/dist/hooks/useSimData.js +135 -0
- package/dist/hooks/useSimulatorData.d.ts +57 -0
- package/dist/hooks/useSimulatorData.js +258 -0
- package/dist/hooks/useTrackingSession.d.ts +40 -0
- package/dist/hooks/useTrackingSession.js +152 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +13 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +28 -0
- package/dist/shared-types/flight-manager.d.ts +112 -0
- package/dist/shared-types/flight-manager.js +2 -0
- package/dist/shared-types/index.d.ts +7 -0
- package/dist/shared-types/index.js +4 -0
- package/dist/shared-types/simulator.d.ts +386 -0
- package/dist/shared-types/simulator.js +48 -0
- package/dist/shared-types/socket-events.d.ts +171 -0
- package/dist/shared-types/socket-events.js +79 -0
- package/dist/shared-types/theme.d.ts +3 -0
- package/dist/shared-types/theme.js +2 -0
- package/dist/types/context.d.ts +206 -0
- package/dist/types/context.js +8 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/dist/types/manifest.d.ts +42 -0
- package/dist/types/manifest.js +12 -0
- package/dist/types/module.d.ts +31 -0
- package/dist/types/module.js +7 -0
- package/dist/ui/alert-dialog.d.ts +21 -0
- package/dist/ui/alert-dialog.js +27 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +21 -0
- package/dist/ui/button.d.ts +17 -0
- package/dist/ui/button.js +39 -0
- package/dist/ui/card.d.ts +10 -0
- package/dist/ui/card.js +25 -0
- package/dist/ui/dialog.d.ts +14 -0
- package/dist/ui/dialog.js +25 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.js +16 -0
- package/dist/ui/input.d.ts +4 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/label.d.ts +5 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/radio-group.d.ts +6 -0
- package/dist/ui/radio-group.js +11 -0
- package/dist/ui/select.d.ts +14 -0
- package/dist/ui/select.js +27 -0
- package/dist/ui/separator.d.ts +5 -0
- package/dist/ui/separator.js +8 -0
- package/dist/ui/slider.d.ts +5 -0
- package/dist/ui/slider.js +8 -0
- package/dist/ui/switch.d.ts +13 -0
- package/dist/ui/switch.js +9 -0
- package/dist/ui/tabs.d.ts +8 -0
- package/dist/ui/tabs.js +13 -0
- package/dist/ui/textarea.d.ts +4 -0
- package/dist/ui/textarea.js +7 -0
- package/dist/ui/tooltip.d.ts +8 -0
- package/dist/ui/tooltip.js +11 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +6 -0
- package/dist/vite/externals.d.ts +9 -0
- package/dist/vite/externals.js +19 -0
- package/dist/vite/plugin-config.d.ts +49 -0
- package/dist/vite/plugin-config.js +236 -0
- package/dist/vite/serve-externals.d.ts +9 -0
- package/dist/vite/serve-externals.js +78 -0
- package/dist/vite/stratos-dev-server.d.ts +21 -0
- package/dist/vite/stratos-dev-server.js +188 -0
- package/package.json +96 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// NOTE: This file runs inside the plugin developer's Vite process, NOT inside
|
|
2
|
+
// Stratos. Using console.log / console.error here is intentional and correct —
|
|
3
|
+
// this is tooling/build infrastructure, not app code.
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import { build } from "vite";
|
|
7
|
+
import { io as ioClient } from "socket.io-client";
|
|
8
|
+
/**
|
|
9
|
+
* Vite plugin that auto-connects a plugin's dev server to a running Stratos
|
|
10
|
+
* app. Only active in serve (dev) mode.
|
|
11
|
+
*
|
|
12
|
+
* On startup it:
|
|
13
|
+
* - Reads plugin.json from the plugin directory
|
|
14
|
+
* - Derives the dev URL from the Vite HTTP server address
|
|
15
|
+
* - Connects to Stratos's Socket.io server and emits dev:plugin-connect
|
|
16
|
+
* - Retries with exponential backoff if Stratos isn't running
|
|
17
|
+
*
|
|
18
|
+
* If src/background/ exists, it watches for changes and rebuilds the
|
|
19
|
+
* background bundle, then notifies Stratos via dev:plugin-bg-updated.
|
|
20
|
+
*/
|
|
21
|
+
export function stratosDevServer(options) {
|
|
22
|
+
const { pluginDir } = options;
|
|
23
|
+
return {
|
|
24
|
+
name: "stratos-dev-server",
|
|
25
|
+
apply: "serve",
|
|
26
|
+
configureServer(server) {
|
|
27
|
+
const stratosPort = options.stratosPort ??
|
|
28
|
+
(process.env.STRATOS_PORT
|
|
29
|
+
? parseInt(process.env.STRATOS_PORT, 10)
|
|
30
|
+
: 2066);
|
|
31
|
+
let socket = null;
|
|
32
|
+
let retryTimeout = null;
|
|
33
|
+
let retryDelay = 3000;
|
|
34
|
+
const MAX_RETRY_DELAY = 30000;
|
|
35
|
+
// Read plugin manifest
|
|
36
|
+
let manifest = {};
|
|
37
|
+
const manifestPath = path.resolve(pluginDir, "plugin.json");
|
|
38
|
+
try {
|
|
39
|
+
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
console.error("[stratos-dev-server] Failed to read plugin.json at", manifestPath);
|
|
43
|
+
}
|
|
44
|
+
const pluginId = manifest.id ?? "unknown";
|
|
45
|
+
function clearRetry() {
|
|
46
|
+
if (retryTimeout) {
|
|
47
|
+
clearTimeout(retryTimeout);
|
|
48
|
+
retryTimeout = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function scheduleRetry() {
|
|
52
|
+
clearRetry();
|
|
53
|
+
retryTimeout = setTimeout(() => {
|
|
54
|
+
retryTimeout = null;
|
|
55
|
+
connect();
|
|
56
|
+
}, retryDelay);
|
|
57
|
+
retryDelay = Math.min(retryDelay * 2, MAX_RETRY_DELAY);
|
|
58
|
+
}
|
|
59
|
+
function getDevUrl() {
|
|
60
|
+
const addr = server.httpServer?.address();
|
|
61
|
+
if (addr && typeof addr === "object") {
|
|
62
|
+
const host = addr.address === "::" || addr.address === "0.0.0.0"
|
|
63
|
+
? "localhost"
|
|
64
|
+
: addr.address;
|
|
65
|
+
return `http://${host}:${addr.port}`;
|
|
66
|
+
}
|
|
67
|
+
return "http://localhost:5173";
|
|
68
|
+
}
|
|
69
|
+
function connect() {
|
|
70
|
+
if (socket) {
|
|
71
|
+
socket.removeAllListeners();
|
|
72
|
+
socket.disconnect();
|
|
73
|
+
socket = null;
|
|
74
|
+
}
|
|
75
|
+
const stratosUrl = `http://127.0.0.1:${stratosPort}`;
|
|
76
|
+
socket = ioClient(stratosUrl, {
|
|
77
|
+
reconnection: false,
|
|
78
|
+
timeout: 5000,
|
|
79
|
+
});
|
|
80
|
+
socket.on("connect", () => {
|
|
81
|
+
retryDelay = 3000; // reset on success
|
|
82
|
+
const devUrl = getDevUrl();
|
|
83
|
+
const distPath = path.resolve(pluginDir, "dist");
|
|
84
|
+
console.log(`[stratos-dev-server] Connected to Stratos (localhost:${stratosPort})`);
|
|
85
|
+
socket.emit("dev:plugin-connect", {
|
|
86
|
+
manifest,
|
|
87
|
+
devUrl,
|
|
88
|
+
capabilities: ["ui", "hot-reload"],
|
|
89
|
+
distPath,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
socket.on("dev:plugin-mounted", (data) => {
|
|
93
|
+
const id = data?.pluginId ?? pluginId;
|
|
94
|
+
console.log(`[stratos-dev-server] Plugin "${id}" mounted`);
|
|
95
|
+
});
|
|
96
|
+
socket.on("dev:plugin-error", (data) => {
|
|
97
|
+
const msg = data?.message ?? data?.error ?? "Unknown error";
|
|
98
|
+
console.error(`[stratos-dev-server] Plugin error from Stratos: ${msg}`);
|
|
99
|
+
});
|
|
100
|
+
socket.on("disconnect", () => {
|
|
101
|
+
console.log("[stratos-dev-server] Disconnected from Stratos, retrying...");
|
|
102
|
+
scheduleRetry();
|
|
103
|
+
});
|
|
104
|
+
socket.on("connect_error", () => {
|
|
105
|
+
scheduleRetry();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// ── Background file watcher ──────────────────────────────────────────
|
|
109
|
+
const bgDir = path.resolve(pluginDir, "src/background");
|
|
110
|
+
let bgWatcher = null;
|
|
111
|
+
let bgDebounce = null;
|
|
112
|
+
async function rebuildBackground() {
|
|
113
|
+
try {
|
|
114
|
+
await build({
|
|
115
|
+
configFile: false,
|
|
116
|
+
root: pluginDir,
|
|
117
|
+
build: {
|
|
118
|
+
lib: {
|
|
119
|
+
entry: "src/background/index.ts",
|
|
120
|
+
formats: ["es"],
|
|
121
|
+
fileName: () => "index.js",
|
|
122
|
+
},
|
|
123
|
+
outDir: path.resolve(pluginDir, "dist/background"),
|
|
124
|
+
emptyOutDir: true,
|
|
125
|
+
minify: false,
|
|
126
|
+
sourcemap: true,
|
|
127
|
+
},
|
|
128
|
+
logLevel: "warn",
|
|
129
|
+
});
|
|
130
|
+
const bundlePath = path.resolve(pluginDir, "dist/background/index.js");
|
|
131
|
+
console.log("[stratos-dev-server] Background rebuilt, notifying Stratos...");
|
|
132
|
+
if (socket?.connected) {
|
|
133
|
+
socket.emit("dev:plugin-bg-updated", {
|
|
134
|
+
pluginId,
|
|
135
|
+
bundlePath,
|
|
136
|
+
timestamp: Date.now(),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
142
|
+
console.error(`[stratos-dev-server] Background build failed: ${message}`);
|
|
143
|
+
if (socket?.connected) {
|
|
144
|
+
socket.emit("dev:plugin-bg-error", {
|
|
145
|
+
pluginId,
|
|
146
|
+
error: message,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (fs.existsSync(bgDir)) {
|
|
152
|
+
bgWatcher = fs.watch(bgDir, { recursive: true }, () => {
|
|
153
|
+
if (bgDebounce)
|
|
154
|
+
clearTimeout(bgDebounce);
|
|
155
|
+
bgDebounce = setTimeout(() => {
|
|
156
|
+
bgDebounce = null;
|
|
157
|
+
void rebuildBackground();
|
|
158
|
+
}, 200);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// ── Cleanup ───────────────────────────────────────────────────────────
|
|
162
|
+
function cleanup() {
|
|
163
|
+
clearRetry();
|
|
164
|
+
if (bgDebounce) {
|
|
165
|
+
clearTimeout(bgDebounce);
|
|
166
|
+
bgDebounce = null;
|
|
167
|
+
}
|
|
168
|
+
bgWatcher?.close();
|
|
169
|
+
if (socket) {
|
|
170
|
+
if (socket.connected) {
|
|
171
|
+
socket.emit("dev:plugin-disconnect", { pluginId });
|
|
172
|
+
}
|
|
173
|
+
socket.removeAllListeners();
|
|
174
|
+
socket.disconnect();
|
|
175
|
+
socket = null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
server.httpServer?.once("close", cleanup);
|
|
179
|
+
process.once("SIGINT", cleanup);
|
|
180
|
+
process.once("SIGTERM", cleanup);
|
|
181
|
+
// Start connecting after the HTTP server is listening
|
|
182
|
+
server.httpServer?.once("listening", () => {
|
|
183
|
+
connect();
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=stratos-dev-server.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skyvexsoftware/stratos-sdk",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Plugin SDK for Stratos — types, hooks, and UI components",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Skyvex Software",
|
|
7
|
+
"email": "jordan@skyvexsoftware.com"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./types": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"import": "./dist/types/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./ui": {
|
|
23
|
+
"types": "./dist/ui/index.d.ts",
|
|
24
|
+
"import": "./dist/ui/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./hooks": {
|
|
27
|
+
"types": "./dist/hooks/index.d.ts",
|
|
28
|
+
"import": "./dist/hooks/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./helpers": {
|
|
31
|
+
"types": "./dist/helpers/index.d.ts",
|
|
32
|
+
"import": "./dist/helpers/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./vite": {
|
|
35
|
+
"types": "./dist/vite/plugin-config.d.ts",
|
|
36
|
+
"import": "./dist/vite/plugin-config.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"!dist/**/*.map"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@radix-ui/react-alert-dialog": "^1.1.0",
|
|
48
|
+
"@radix-ui/react-dialog": "^1.1.0",
|
|
49
|
+
"@radix-ui/react-label": "^2.1.0",
|
|
50
|
+
"@radix-ui/react-radio-group": "^1.3.0",
|
|
51
|
+
"@radix-ui/react-select": "^2.1.0",
|
|
52
|
+
"@radix-ui/react-separator": "^1.1.0",
|
|
53
|
+
"@radix-ui/react-slider": "^1.3.0",
|
|
54
|
+
"@radix-ui/react-slot": "^1.2.0",
|
|
55
|
+
"@radix-ui/react-switch": "^1.2.0",
|
|
56
|
+
"@radix-ui/react-tabs": "^1.1.0",
|
|
57
|
+
"@radix-ui/react-tooltip": "^1.1.0",
|
|
58
|
+
"@tanstack/react-query": "^5.0.0",
|
|
59
|
+
"class-variance-authority": "^0.7.0",
|
|
60
|
+
"lucide-react": ">=0.300.0",
|
|
61
|
+
"react": "^19.0.0",
|
|
62
|
+
"socket.io-client": "^4.0.0",
|
|
63
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
64
|
+
"vite": "^7.0.0"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"clsx": "^2.1.1",
|
|
68
|
+
"tailwind-merge": "^3.2.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
72
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
73
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
74
|
+
"@radix-ui/react-radio-group": "^1.3.8",
|
|
75
|
+
"@radix-ui/react-select": "^2.1.8",
|
|
76
|
+
"@radix-ui/react-separator": "^1.1.4",
|
|
77
|
+
"@radix-ui/react-slider": "^1.3.6",
|
|
78
|
+
"@radix-ui/react-slot": "^1.2.0",
|
|
79
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
80
|
+
"@radix-ui/react-tabs": "^1.1.8",
|
|
81
|
+
"@radix-ui/react-tooltip": "^1.1.12",
|
|
82
|
+
"@types/react": "^19.1.2",
|
|
83
|
+
"class-variance-authority": "^0.7.1",
|
|
84
|
+
"lucide-react": "^0.503.0",
|
|
85
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
86
|
+
"socket.io-client": "^4.8.3",
|
|
87
|
+
"typescript": "^5.8.3",
|
|
88
|
+
"vite": "^7.3.1"
|
|
89
|
+
},
|
|
90
|
+
"scripts": {
|
|
91
|
+
"build": "tsc -b",
|
|
92
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
93
|
+
"tsc": "tsc --noEmit",
|
|
94
|
+
"typecheck": "tsc --noEmit"
|
|
95
|
+
}
|
|
96
|
+
}
|