@skyvexsoftware/stratos-sdk 0.5.5 → 0.5.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.
@@ -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
@@ -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
- const SERVER_PORT = 2066;
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(`${API_BASE}/api/flight-events`, {
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(`${API_BASE}/api/flight-events/comments`, {
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(`${API_BASE}/api/flight-events/comments/${id}`, {
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(`${API_BASE}/api/flight-events/comments/${id}`, {
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
- const SERVER_PORT = 2066;
12
- const API_BASE = `http://127.0.0.1:${SERVER_PORT}/api/flight-manager`;
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
- const SERVER_PORT = 2066;
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(`${API_BASE}/api/simulator/flight-phase/snapshot`, {
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
- const SERVER_PORT = 2066;
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(`${API_BASE}/api/simulator/landing-analysis/snapshot`, {
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());
@@ -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
- const SERVER_PORT = 2066;
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(`${API_BASE}/api/simulator/snapshot`, {
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
- // Server configuration - matches shell main process
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(SERVER_URL, {
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
- const SERVER_PORT = 2066;
17
- const API_BASE = `http://127.0.0.1:${SERVER_PORT}/api/flight-manager`;
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";
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";
@@ -44,6 +44,7 @@ export type CurrentFlight = {
44
44
  longitude: number;
45
45
  altitude: number;
46
46
  groundSpeed: number;
47
+ indicatedAirspeed: number;
47
48
  heading: number;
48
49
  startingFuel: number;
49
50
  currentFuel: number;
@@ -88,6 +89,7 @@ export type RecoverableFlight = {
88
89
  altitude: number | null;
89
90
  heading: number | null;
90
91
  groundSpeed: number | null;
92
+ indicatedAirspeed: number | null;
91
93
  startedAt: number | null;
92
94
  elapsedMs: number;
93
95
  status: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyvexsoftware/stratos-sdk",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Plugin SDK for Stratos — types, hooks, and UI components",
5
5
  "author": {
6
6
  "name": "Skyvex Software",