@skyvexsoftware/stratos-sdk 0.5.4 → 0.5.6
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/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/server.d.ts +10 -0
- package/dist/helpers/server.js +13 -0
- package/dist/hooks/useFlightEvents.js +5 -6
- package/dist/hooks/useFlightManager.js +2 -2
- package/dist/hooks/useFlightPhase.js +2 -3
- package/dist/hooks/useLandingAnalysis.js +2 -3
- package/dist/hooks/useSimData.js +2 -3
- package/dist/hooks/useSimulatorData.js +2 -4
- package/dist/hooks/useTrackingSession.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/shared-types/socket-events.d.ts +20 -0
- package/dist/shared-types/socket-events.js +3 -0
- package/package.json +1 -1
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createPlugin } from "./createPlugin";
|
|
2
|
+
export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./server";
|
|
2
3
|
export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./units";
|
|
3
4
|
export type { WeightUnit, AltitudeUnit, DistanceUnit, UnitPreferences, } from "./units";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { createPlugin } from "./createPlugin";
|
|
2
|
+
export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./server";
|
|
2
3
|
export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./units";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__STRATOS_SERVER_PORT__?: number;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/** The port the local Stratos Express server listens on. */
|
|
7
|
+
export declare const STRATOS_APP_PORT: number;
|
|
8
|
+
/** Base URL of the local Stratos Express server (no trailing slash). */
|
|
9
|
+
export declare const STRATOS_APP_BASE: string;
|
|
10
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function resolvePort() {
|
|
2
|
+
// Renderer — preload sets this via contextBridge (read-only, frozen)
|
|
3
|
+
if (typeof window !== "undefined" && window.__STRATOS_SERVER_PORT__)
|
|
4
|
+
return window.__STRATOS_SERVER_PORT__;
|
|
5
|
+
// Main process — shell sets process.env.STRATOS_PORT from --stratos-port arg
|
|
6
|
+
if (typeof process !== "undefined" && process.env?.STRATOS_PORT)
|
|
7
|
+
return parseInt(process.env.STRATOS_PORT, 10);
|
|
8
|
+
return 2066;
|
|
9
|
+
}
|
|
10
|
+
/** The port the local Stratos Express server listens on. */
|
|
11
|
+
export const STRATOS_APP_PORT = resolvePort();
|
|
12
|
+
/** Base URL of the local Stratos Express server (no trailing slash). */
|
|
13
|
+
export const STRATOS_APP_BASE = `http://127.0.0.1:${STRATOS_APP_PORT}`;
|
|
@@ -9,14 +9,13 @@ import { useEffect, useMemo } from "react";
|
|
|
9
9
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
10
10
|
import { useSocket } from "./useSimulatorData";
|
|
11
11
|
import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
12
|
-
|
|
13
|
-
const API_BASE = `http://127.0.0.1:${SERVER_PORT}`;
|
|
12
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
14
13
|
export const flightEventsKeys = {
|
|
15
14
|
all: ["flight-events"],
|
|
16
15
|
log: (flightId) => [...flightEventsKeys.all, "log", flightId ?? "current"],
|
|
17
16
|
};
|
|
18
17
|
async function fetchFlightEvents() {
|
|
19
|
-
const response = await fetch(`${
|
|
18
|
+
const response = await fetch(`${STRATOS_APP_BASE}/api/flight-events`, {
|
|
20
19
|
headers: { Accept: "application/json" },
|
|
21
20
|
});
|
|
22
21
|
const json = (await response.json());
|
|
@@ -65,7 +64,7 @@ export function useFlightEvents(options) {
|
|
|
65
64
|
// ── Comment Mutations ──────────────────────────────────────────────
|
|
66
65
|
const addCommentMutation = useMutation({
|
|
67
66
|
mutationFn: async (message) => {
|
|
68
|
-
const response = await fetch(`${
|
|
67
|
+
const response = await fetch(`${STRATOS_APP_BASE}/api/flight-events/comments`, {
|
|
69
68
|
method: "POST",
|
|
70
69
|
headers: { "Content-Type": "application/json" },
|
|
71
70
|
body: JSON.stringify({ message }),
|
|
@@ -78,7 +77,7 @@ export function useFlightEvents(options) {
|
|
|
78
77
|
});
|
|
79
78
|
const editCommentMutation = useMutation({
|
|
80
79
|
mutationFn: async ({ id, message }) => {
|
|
81
|
-
await fetch(`${
|
|
80
|
+
await fetch(`${STRATOS_APP_BASE}/api/flight-events/comments/${id}`, {
|
|
82
81
|
method: "PUT",
|
|
83
82
|
headers: { "Content-Type": "application/json" },
|
|
84
83
|
body: JSON.stringify({ message }),
|
|
@@ -107,7 +106,7 @@ export function useFlightEvents(options) {
|
|
|
107
106
|
});
|
|
108
107
|
const deleteCommentMutation = useMutation({
|
|
109
108
|
mutationFn: async (id) => {
|
|
110
|
-
await fetch(`${
|
|
109
|
+
await fetch(`${STRATOS_APP_BASE}/api/flight-events/comments/${id}`, {
|
|
111
110
|
method: "DELETE",
|
|
112
111
|
});
|
|
113
112
|
},
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import { useEffect, useState, useCallback } from "react";
|
|
9
9
|
import { useSocket } from "./useSimulatorData";
|
|
10
10
|
import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
11
|
-
|
|
12
|
-
const API_BASE =
|
|
11
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
12
|
+
const API_BASE = `${STRATOS_APP_BASE}/api/flight-manager`;
|
|
13
13
|
async function api(path, method = "GET", body) {
|
|
14
14
|
const response = await fetch(`${API_BASE}${path}`, {
|
|
15
15
|
method,
|
|
@@ -9,13 +9,12 @@ import { useEffect } from "react";
|
|
|
9
9
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
10
|
import { useSocket } from "./useSimulatorData";
|
|
11
11
|
import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
12
|
-
|
|
13
|
-
const API_BASE = `http://127.0.0.1:${SERVER_PORT}`;
|
|
12
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
14
13
|
export const flightPhaseKeys = {
|
|
15
14
|
snapshot: ["flight-phase", "snapshot"],
|
|
16
15
|
};
|
|
17
16
|
async function fetchPhaseSnapshot() {
|
|
18
|
-
const response = await fetch(`${
|
|
17
|
+
const response = await fetch(`${STRATOS_APP_BASE}/api/simulator/flight-phase/snapshot`, {
|
|
19
18
|
headers: { Accept: "application/json" },
|
|
20
19
|
});
|
|
21
20
|
const json = (await response.json());
|
|
@@ -9,13 +9,12 @@ import { useEffect } from "react";
|
|
|
9
9
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
10
|
import { useSocket } from "./useSimulatorData";
|
|
11
11
|
import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
12
|
-
|
|
13
|
-
const API_BASE = `http://127.0.0.1:${SERVER_PORT}`;
|
|
12
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
14
13
|
export const landingAnalysisKeys = {
|
|
15
14
|
snapshot: ["landing-analysis", "snapshot"],
|
|
16
15
|
};
|
|
17
16
|
async function fetchLandingSnapshot() {
|
|
18
|
-
const response = await fetch(`${
|
|
17
|
+
const response = await fetch(`${STRATOS_APP_BASE}/api/simulator/landing-analysis/snapshot`, {
|
|
19
18
|
headers: { Accept: "application/json" },
|
|
20
19
|
});
|
|
21
20
|
const json = (await response.json());
|
package/dist/hooks/useSimData.js
CHANGED
|
@@ -28,13 +28,12 @@ import { useEffect, useRef } from "react";
|
|
|
28
28
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
29
29
|
import { useSocket } from "./useSimulatorData";
|
|
30
30
|
import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
31
|
-
|
|
32
|
-
const API_BASE = `http://127.0.0.1:${SERVER_PORT}`;
|
|
31
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
33
32
|
export const simDataKeys = {
|
|
34
33
|
snapshot: ["simulator", "snapshot"],
|
|
35
34
|
};
|
|
36
35
|
async function fetchSnapshot() {
|
|
37
|
-
const response = await fetch(`${
|
|
36
|
+
const response = await fetch(`${STRATOS_APP_BASE}/api/simulator/snapshot`, {
|
|
38
37
|
headers: { Accept: "application/json" },
|
|
39
38
|
});
|
|
40
39
|
const json = (await response.json());
|
|
@@ -14,9 +14,7 @@ import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
|
14
14
|
// Re-export canonical types so existing consumers that import from
|
|
15
15
|
// "./useSimulatorData" continue to work without changes.
|
|
16
16
|
export { SOCKET_EVENTS, };
|
|
17
|
-
|
|
18
|
-
const SERVER_PORT = 2066;
|
|
19
|
-
const SERVER_URL = `http://127.0.0.1:${SERVER_PORT}`;
|
|
17
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
20
18
|
class SocketManager {
|
|
21
19
|
constructor() {
|
|
22
20
|
this.socket = null;
|
|
@@ -67,7 +65,7 @@ class SocketManager {
|
|
|
67
65
|
return;
|
|
68
66
|
this.connectionState = "connecting";
|
|
69
67
|
this.notify();
|
|
70
|
-
this.socket = io(
|
|
68
|
+
this.socket = io(STRATOS_APP_BASE, {
|
|
71
69
|
transports: ["websocket", "polling"],
|
|
72
70
|
reconnection: true,
|
|
73
71
|
reconnectionAttempts: 5,
|
|
@@ -13,8 +13,8 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
13
13
|
import { useSocket } from "./useSimulatorData";
|
|
14
14
|
import { SOCKET_EVENTS } from "../shared-types/socket-events";
|
|
15
15
|
import { FlightPhase } from "../shared-types/simulator";
|
|
16
|
-
|
|
17
|
-
const API_BASE =
|
|
16
|
+
import { STRATOS_APP_BASE } from "../helpers/server";
|
|
17
|
+
const API_BASE = `${STRATOS_APP_BASE}/api/flight-manager`;
|
|
18
18
|
export const trackingSessionKeys = {
|
|
19
19
|
state: ["tracking-session", "state"],
|
|
20
20
|
pendingRecovery: ["tracking-session", "pending-recovery"],
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { BounceData, CapturePoint, FlightData, FlightDataSnapshot, FlightEv
|
|
|
6
6
|
export type { ThemeMode } from "./shared-types/theme";
|
|
7
7
|
export type { FlightPlan, FlightStatus, CurrentFlight, FlightComment, PreflightCheck, PreflightCheckResult, StartFlightOptions, FlightManagerPayload, StartFlightResult, RecoverableFlight, } from "./shared-types/flight-manager";
|
|
8
8
|
export { createPlugin } from "./helpers/createPlugin";
|
|
9
|
+
export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./helpers/server";
|
|
9
10
|
export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./helpers/units";
|
|
10
11
|
export type { WeightUnit, AltitudeUnit, DistanceUnit, UnitPreferences, } from "./helpers/units";
|
|
11
12
|
export { PluginUICtx, usePluginContext } from "./hooks/context";
|
|
@@ -22,7 +23,7 @@ export { useShellNavigation } from "./hooks/useShellNavigation";
|
|
|
22
23
|
export { useShellToast } from "./hooks/useShellToast";
|
|
23
24
|
export { useSocket, useSimulatorData, useProtocolUrl, useNotifications, useSystemMetrics, } from "./hooks/useSimulatorData";
|
|
24
25
|
export { SOCKET_EVENTS } from "./shared-types/socket-events";
|
|
25
|
-
export type { ConnectionState, LogEntryPayload, NotificationPayload, ProtocolUrlPayload, SimulatorDataPayload, SimulatorStatusPayload, SocketEventName, SystemMetricsPayload, } from "./shared-types/socket-events";
|
|
26
|
+
export type { AutoStartConfirmPayload, ConnectionState, LogEntryPayload, NotificationPayload, ProtocolUrlPayload, SimulatorDataPayload, SimulatorStatusPayload, SocketEventName, SystemMetricsPayload, } from "./shared-types/socket-events";
|
|
26
27
|
export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, Badge, badgeVariants, Button, buttonVariants, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Input, Label, RadioGroup, RadioGroupItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./ui";
|
|
27
28
|
export type { BadgeProps, ButtonProps } from "./ui";
|
|
28
29
|
export { STRATOS_ICONS, STRATOS_ICON_NAMES } from "./icons";
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { FlightPhase, SimulatorType, EventCategory, } from "./shared-types/simulator";
|
|
3
3
|
// ── Helper Functions ───────────────────────────────────────────────────
|
|
4
4
|
export { createPlugin } from "./helpers/createPlugin";
|
|
5
|
+
export { STRATOS_APP_PORT, STRATOS_APP_BASE } from "./helpers/server";
|
|
5
6
|
export { weightToLbs, weightFromLbs, altitudeToFt, altitudeFromFt, verticalSpeedFromFpm, verticalSpeedToFpm, distanceToNm, distanceFromNm, formatWeight, formatAltitude, formatDistance, formatVerticalSpeed, } from "./helpers/units";
|
|
6
7
|
// ── React Hooks ────────────────────────────────────────────────────────
|
|
7
8
|
export { PluginUICtx, usePluginContext } from "./hooks/context";
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* All flight-related events include a `timestamp` field (epoch ms).
|
|
31
31
|
*/
|
|
32
32
|
import type { FlightData, FlightTrends, SimulatorStatus } from "./simulator";
|
|
33
|
+
import type { FlightPlan } from "./flight-manager";
|
|
33
34
|
/** Canonical Socket.io event names shared by shell and SDK. */
|
|
34
35
|
export declare const SOCKET_EVENTS: {
|
|
35
36
|
/** Real-time flight data broadcast (~10-20 Hz). Payload: SimulatorDataPayload */
|
|
@@ -62,6 +63,8 @@ export declare const SOCKET_EVENTS: {
|
|
|
62
63
|
readonly LOG_ENTRY: "log:entry";
|
|
63
64
|
/** VA session expired (401 from upstream VA API). No payload. */
|
|
64
65
|
readonly AUTH_SESSION_EXPIRED: "auth:session-expired";
|
|
66
|
+
/** Auto-start detected a VA confirmation — renderer should show dialog. */
|
|
67
|
+
readonly AUTO_START_CONFIRM: "flight:auto-start-confirm";
|
|
65
68
|
readonly PLUGIN_LOADED: "plugin:loaded";
|
|
66
69
|
readonly PLUGIN_UNLOADED: "plugin:unloaded";
|
|
67
70
|
readonly PLUGIN_EVENT: "plugin:event";
|
|
@@ -166,6 +169,23 @@ export type LogEntryPayload = {
|
|
|
166
169
|
message: string;
|
|
167
170
|
data?: string;
|
|
168
171
|
};
|
|
172
|
+
/**
|
|
173
|
+
* Payload for `flight:auto-start-confirm` events.
|
|
174
|
+
*
|
|
175
|
+
* Emitted when auto-start receives a VA confirmation that the pilot
|
|
176
|
+
* must acknowledge before tracking begins. The renderer should show
|
|
177
|
+
* the VaConfirmDialog.
|
|
178
|
+
*/
|
|
179
|
+
export type AutoStartConfirmPayload = {
|
|
180
|
+
/** VA-issued confirmation message. */
|
|
181
|
+
confirmation: string;
|
|
182
|
+
/** Current sim variables for display. */
|
|
183
|
+
simVariables: Record<string, string>;
|
|
184
|
+
/** The flight plan built from the matched booking. */
|
|
185
|
+
flightPlan: FlightPlan;
|
|
186
|
+
/** Booking bid_id so the renderer can fetch the full booking. */
|
|
187
|
+
bidId: number;
|
|
188
|
+
};
|
|
169
189
|
/** Socket.io connection state as observed by the client. */
|
|
170
190
|
export type ConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
171
191
|
//# sourceMappingURL=socket-events.d.ts.map
|
|
@@ -71,6 +71,9 @@ export const SOCKET_EVENTS = {
|
|
|
71
71
|
// Auth events
|
|
72
72
|
/** VA session expired (401 from upstream VA API). No payload. */
|
|
73
73
|
AUTH_SESSION_EXPIRED: "auth:session-expired",
|
|
74
|
+
// Auto-start events
|
|
75
|
+
/** Auto-start detected a VA confirmation — renderer should show dialog. */
|
|
76
|
+
AUTO_START_CONFIRM: "flight:auto-start-confirm",
|
|
74
77
|
// Plugin events
|
|
75
78
|
PLUGIN_LOADED: "plugin:loaded",
|
|
76
79
|
PLUGIN_UNLOADED: "plugin:unloaded",
|