Touch up names.
This commit is contained in:
parent
fbe15f7a6e
commit
21d3062bf9
|
@ -10,6 +10,11 @@ import { SocketProxyProvider } from "./socket"
|
||||||
import { isFile } from "./util"
|
import { isFile } from "./util"
|
||||||
import { onMessage, wrapper } from "./wrapper"
|
import { onMessage, wrapper } from "./wrapper"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an interface to manage a child VS Code process.
|
||||||
|
*
|
||||||
|
* @remark This shouldn't be confused with the actual child process.
|
||||||
|
*/
|
||||||
export class VscodeProvider {
|
export class VscodeProvider {
|
||||||
public readonly serverRootPath: string
|
public readonly serverRootPath: string
|
||||||
public readonly vsRootPath: string
|
public readonly vsRootPath: string
|
|
@ -10,13 +10,13 @@ import { getFirstString } from "../../common/util"
|
||||||
import { Feature } from "../cli"
|
import { Feature } from "../cli"
|
||||||
import { isDevMode, rootPath, version } from "../constants"
|
import { isDevMode, rootPath, version } from "../constants"
|
||||||
import { authenticated, ensureAuthenticated, redirect, replaceTemplates } from "../http"
|
import { authenticated, ensureAuthenticated, redirect, replaceTemplates } from "../http"
|
||||||
|
import { VscodeProvider } from "../provider"
|
||||||
import { getMediaMime, pathToFsPath } from "../util"
|
import { getMediaMime, pathToFsPath } from "../util"
|
||||||
import { VscodeProvider } from "../vscode"
|
|
||||||
import { Router as WsRouter } from "../wsRouter"
|
import { Router as WsRouter } from "../wsRouter"
|
||||||
|
|
||||||
export const router = Router()
|
export const router = Router()
|
||||||
|
|
||||||
const vscode = new VscodeProvider()
|
const vscodeProvider = new VscodeProvider()
|
||||||
|
|
||||||
router.get("/", async (req, res) => {
|
router.get("/", async (req, res) => {
|
||||||
const isAuthenticated = await authenticated(req)
|
const isAuthenticated = await authenticated(req)
|
||||||
|
@ -31,7 +31,7 @@ router.get("/", async (req, res) => {
|
||||||
await fs.readFile(path.join(rootPath, "src/browser/pages/vscode.html"), "utf8"),
|
await fs.readFile(path.join(rootPath, "src/browser/pages/vscode.html"), "utf8"),
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
return await vscode.initialize({ args: req.args, remoteAuthority: req.headers.host || "" }, req.query)
|
return await vscodeProvider.initialize({ args: req.args, remoteAuthority: req.headers.host || "" }, req.query)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const devMessage = isDevMode ? "It might not have finished compiling." : ""
|
const devMessage = isDevMode ? "It might not have finished compiling." : ""
|
||||||
throw new Error(`VS Code failed to load. ${devMessage} ${error.message}`)
|
throw new Error(`VS Code failed to load. ${devMessage} ${error.message}`)
|
||||||
|
@ -91,7 +91,9 @@ router.get("/webview/*", ensureAuthenticated, async (req, res) => {
|
||||||
return res.send(await fs.readFile(req.params[0].replace(/^vscode-resource(\/file)?/, "")))
|
return res.send(await fs.readFile(req.params[0].replace(/^vscode-resource(\/file)?/, "")))
|
||||||
}
|
}
|
||||||
return res.send(
|
return res.send(
|
||||||
await fs.readFile(path.join(vscode.vsRootPath, "out/vs/workbench/contrib/webview/browser/pre", req.params[0])),
|
await fs.readFile(
|
||||||
|
path.join(vscodeProvider.vsRootPath, "out/vs/workbench/contrib/webview/browser/pre", req.params[0]),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -228,5 +230,5 @@ wsRouter.ws("/", ensureAuthenticated, async (req) => {
|
||||||
|
|
||||||
req.ws.write(responseHeaders.join("\r\n") + "\r\n\r\n")
|
req.ws.write(responseHeaders.join("\r\n") + "\r\n\r\n")
|
||||||
|
|
||||||
await vscode.sendWebsocket(req.ws, req.query, useCompression)
|
await vscodeProvider.sendWebsocket(req.ws, req.query, useCompression)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue