@skyvexsoftware/stratos-sdk 0.5.5 → 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 +1 -0
- package/dist/index.js +1 -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";
|
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";
|