From 4d29dd5b5fda121c7ea7c52d63af55b132a743d9 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Wed, 17 Jul 2024 18:49:27 -0700 Subject: [PATCH] Rename endpoint functions --- emain/emain.ts | 6 +++--- frontend/app/store/global.ts | 10 +++++----- frontend/app/store/wos.ts | 4 ++-- frontend/app/view/preview.tsx | 4 ++-- frontend/app/view/term/termsticker.tsx | 4 ++-- frontend/util/endpoints.ts | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/emain/emain.ts b/emain/emain.ts index 05095fa8e..38114656f 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -14,7 +14,7 @@ import * as services from "../frontend/app/store/services"; import * as keyutil from "../frontend/util/keyutil"; import { fireAndForget } from "../frontend/util/util"; -import { getServerWebEndpoint, WebServerEndpointVarName, WSServerEndpointVarName } from "@/util/endpoints"; +import { getWebServerEndpoint, WebServerEndpointVarName, WSServerEndpointVarName } from "@/util/endpoints"; import { WaveDevVarName, WaveDevViteVarName } from "@/util/isdev"; import { sprintf } from "sprintf-js"; const electronApp = electron.app; @@ -268,7 +268,7 @@ function shFrameNavHandler(event: Electron.Event { electron.ipcMain.on("download", (event, payload) => { const window = electron.BrowserWindow.fromWebContents(event.sender); - const streamingUrl = getServerWebEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(payload.filePath); + const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(payload.filePath); window.webContents.downloadURL(streamingUrl); }); diff --git a/frontend/app/store/global.ts b/frontend/app/store/global.ts index 8be433160..a3ab7b4a2 100644 --- a/frontend/app/store/global.ts +++ b/frontend/app/store/global.ts @@ -6,7 +6,7 @@ import { getLayoutStateAtomForTab } from "@/faraday/lib/layoutAtom"; import { layoutTreeStateReducer } from "@/faraday/lib/layoutState"; import { handleIncomingRpcMessage } from "@/app/store/wshrpc"; -import { getServerWebEndpoint, getServerWSEndpoint } from "@/util/endpoints"; +import { getWSServerEndpoint, getWebServerEndpoint } from "@/util/endpoints"; import * as layoututil from "@/util/layoututil"; import { produce } from "immer"; import * as jotai from "jotai"; @@ -270,7 +270,7 @@ function handleWSMessage(msg: any) { } function initWS() { - globalWS = new WSControl(getServerWSEndpoint(), globalStore, globalWindowId, "", (msg) => { + globalWS = new WSControl(getWSServerEndpoint(), globalStore, globalWindowId, "", (msg) => { handleWSMessage(msg); }); globalWS.connectNow("initWS"); @@ -324,7 +324,7 @@ async function fetchWaveFile( if (offset != null) { usp.set("offset", offset.toString()); } - const resp = await fetch(getServerWebEndpoint() + "/wave/file?" + usp.toString()); + const resp = await fetch(getWebServerEndpoint() + "/wave/file?" + usp.toString()); if (!resp.ok) { if (resp.status === 404) { return { data: null, fileInfo: null }; @@ -367,6 +367,8 @@ function getObjectId(obj: any): number { } export { + PLATFORM, + WOS, atoms, createBlock, fetchWaveFile, @@ -378,12 +380,10 @@ export { globalStore, globalWS, initWS, - PLATFORM, sendWSCommand, setBlockFocus, setPlatform, useBlockAtom, useBlockCache, useSettingsAtom, - WOS, }; diff --git a/frontend/app/store/wos.ts b/frontend/app/store/wos.ts index 60856a3f7..8330f02f3 100644 --- a/frontend/app/store/wos.ts +++ b/frontend/app/store/wos.ts @@ -4,7 +4,7 @@ // WaveObjectStore import { sendRpcCommand } from "@/app/store/wshrpc"; -import { getServerWebEndpoint } from "@/util/endpoints"; +import { getWebServerEndpoint } from "@/util/endpoints"; import * as jotai from "jotai"; import * as React from "react"; import { v4 as uuidv4 } from "uuid"; @@ -79,7 +79,7 @@ function callBackendService(service: string, method: string, args: any[], noUICo const usp = new URLSearchParams(); usp.set("service", service); usp.set("method", method); - const url = getServerWebEndpoint() + "/wave/service?" + usp.toString(); + const url = getWebServerEndpoint() + "/wave/service?" + usp.toString(); const fetchPromise = fetch(url, { method: "POST", body: JSON.stringify(waveCall), diff --git a/frontend/app/view/preview.tsx b/frontend/app/view/preview.tsx index ec4bb66ac..fb118a50c 100644 --- a/frontend/app/view/preview.tsx +++ b/frontend/app/view/preview.tsx @@ -6,7 +6,7 @@ import { Markdown } from "@/element/markdown"; import { globalStore, useBlockAtom } from "@/store/global"; import * as services from "@/store/services"; import * as WOS from "@/store/wos"; -import { getServerWebEndpoint } from "@/util/endpoints"; +import { getWebServerEndpoint } from "@/util/endpoints"; import * as util from "@/util/util"; import clsx from "clsx"; import * as jotai from "jotai"; @@ -275,7 +275,7 @@ function MarkdownPreview({ contentAtom }: { contentAtom: jotai.Atom diff --git a/frontend/app/view/term/termsticker.tsx b/frontend/app/view/term/termsticker.tsx index 6c3110547..1b3511e29 100644 --- a/frontend/app/view/term/termsticker.tsx +++ b/frontend/app/view/term/termsticker.tsx @@ -3,7 +3,7 @@ import { WshServer } from "@/app/store/wshserver"; import { createBlock } from "@/store/global"; -import { getServerWebEndpoint } from "@/util/endpoints"; +import { getWebServerEndpoint } from "@/util/endpoints"; import clsx from "clsx"; import * as jotai from "jotai"; import * as React from "react"; @@ -117,7 +117,7 @@ function TermSticker({ sticker, config }: { sticker: StickerType; config: Sticke if (sticker.imgsrc == null) { return null; } - const streamingUrl = getServerWebEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(sticker.imgsrc); + const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?path=" + encodeURIComponent(sticker.imgsrc); return (
diff --git a/frontend/util/endpoints.ts b/frontend/util/endpoints.ts index 3165e0e70..5f5858fc4 100644 --- a/frontend/util/endpoints.ts +++ b/frontend/util/endpoints.ts @@ -4,6 +4,6 @@ import { lazy } from "./util"; export const WebServerEndpointVarName = "WAVE_SERVER_WEB_ENDPOINT"; export const WSServerEndpointVarName = "WAVE_SERVER_WS_ENDPOINT"; -export const getServerWebEndpoint = lazy(() => `http://${getEnv(WebServerEndpointVarName)}`); +export const getWebServerEndpoint = lazy(() => `http://${getEnv(WebServerEndpointVarName)}`); -export const getServerWSEndpoint = lazy(() => `ws://${getEnv(WSServerEndpointVarName)}`); +export const getWSServerEndpoint = lazy(() => `ws://${getEnv(WSServerEndpointVarName)}`);