mirror of https://git.tuxpa.in/a/code-server.git
More loading
This commit is contained in:
parent
d44a0a3e59
commit
d128ca6d68
|
@ -1,10 +1,16 @@
|
|||
import { logger } from "@coder/logger";
|
||||
import { logger, field, time } from "@coder/logger";
|
||||
import { load } from "@coder/vscode";
|
||||
import "./index.scss";
|
||||
|
||||
logger.info("Starting app");
|
||||
const loadTime = time(2500);
|
||||
logger.info("Loading IDE...");
|
||||
|
||||
const overlay = document.getElementById("overlay");
|
||||
const logo = document.getElementById("logo");
|
||||
const msgElement = overlay
|
||||
? overlay.querySelector(".message") as HTMLElement
|
||||
: undefined;
|
||||
|
||||
if (overlay && logo) {
|
||||
overlay.addEventListener("mousemove", (event) => {
|
||||
const xPos = ((event.clientX - logo.offsetLeft) / 24).toFixed(2);
|
||||
|
@ -14,4 +20,24 @@ if (overlay && logo) {
|
|||
});
|
||||
}
|
||||
|
||||
import "@coder/vscode";
|
||||
load().then(() => {
|
||||
if (overlay) {
|
||||
overlay.style.opacity = "0";
|
||||
overlay.addEventListener("transitionend", () => {
|
||||
overlay.remove();
|
||||
});
|
||||
}
|
||||
}).catch((error: Error) => {
|
||||
logger.error(error.message);
|
||||
if (overlay) {
|
||||
overlay.classList.add("error");
|
||||
}
|
||||
if (msgElement) {
|
||||
msgElement.innerText = `Failed to load: ${error.message}. Retrying in 3 seconds...`;
|
||||
}
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 3000);
|
||||
}).finally(() => {
|
||||
logger.info("Load completed", field("duration", loadTime));
|
||||
});
|
||||
|
|
|
@ -2,7 +2,6 @@ import * as cp from "child_process";
|
|||
import * as stream from "stream";
|
||||
import * as events from "events";
|
||||
import * as net from "net";
|
||||
import { wush, Session } from "@coder/wush";
|
||||
import { useBuffer, throwUnimplementedError, throwSyncError } from "./util";
|
||||
|
||||
/**
|
||||
|
@ -34,7 +33,7 @@ class ChildProcess extends events.EventEmitter implements cp.ChildProcess {
|
|||
|
||||
private emitter = new events.EventEmitter();
|
||||
|
||||
public constructor(private session: Session) {
|
||||
public constructor(private session) {
|
||||
super();
|
||||
|
||||
this.emitter = new events.EventEmitter();
|
||||
|
|
|
@ -59,7 +59,6 @@ export abstract class Queue<T> {
|
|||
|
||||
public constructor(max?: number) {
|
||||
this.items = new Map();
|
||||
this.run = run;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,54 +1,39 @@
|
|||
import { field, logger, time } from "@coder/logger";
|
||||
const loadTime = time(2500);
|
||||
|
||||
import { Client, IURI, setUriFactory } from "@coder/ide";
|
||||
import { URI } from "vs/base/common/uri";
|
||||
import "./firefox";
|
||||
|
||||
setUriFactory({
|
||||
// TODO: not sure why this is an error.
|
||||
// tslint:disable-next-line no-any
|
||||
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
|
||||
file: (path: string): IURI => URI.file(path),
|
||||
parse: (raw: string): IURI => URI.parse(raw),
|
||||
});
|
||||
const load = (): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
setUriFactory({
|
||||
// TODO: not sure why this is an error.
|
||||
// tslint:disable-next-line no-any
|
||||
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
|
||||
file: (path: string): IURI => URI.file(path),
|
||||
parse: (raw: string): IURI => URI.parse(raw),
|
||||
});
|
||||
|
||||
// export const client = new Client({
|
||||
// mkDirs: [
|
||||
// "~/vscode/extensions",
|
||||
// "~/.config/User",
|
||||
// ],
|
||||
// });
|
||||
reject(new Error("not finished"));
|
||||
|
||||
// const overlayElement = document.getElementById("overlay");
|
||||
// const msgElement = overlayElement
|
||||
// ? overlayElement.querySelector(".message") as HTMLElement
|
||||
// : undefined;
|
||||
// export const client = new Client({
|
||||
// mkDirs: [
|
||||
// "~/vscode/extensions",
|
||||
// "~/.config/User",
|
||||
// ],
|
||||
// });
|
||||
|
||||
// const importTime = time(1500);
|
||||
// import(/* webpackPrefetch: true */ "./workbench").then((module) => {
|
||||
// logger.info("Loaded workbench bundle", field("duration", importTime));
|
||||
// const initTime = time(1500);
|
||||
// const importTime = time(1500);
|
||||
// import(/* webpackPrefetch: true */ "./workbench").then((module) => {
|
||||
// logger.info("Loaded workbench bundle", field("duration", importTime));
|
||||
// const initTime = time(1500);
|
||||
|
||||
// return module.initialize(client).then(() => {
|
||||
// logger.info("Initialized workbench", field("duration", initTime));
|
||||
// logger.info("Load completed", field("duration", loadTime));
|
||||
// if (overlayElement) {
|
||||
// overlayElement.style.opacity = "0";
|
||||
// overlayElement.addEventListener("transitionend", () => {
|
||||
// overlayElement.remove();
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }).catch((error) => {
|
||||
// logger.error(error);
|
||||
// if (overlayElement) {
|
||||
// overlayElement.classList.add("error");
|
||||
// }
|
||||
// if (msgElement) {
|
||||
// msgElement.innerText = `Failed to load: ${error.message}. Retrying in 3 seconds...`;
|
||||
// }
|
||||
// setTimeout(() => {
|
||||
// location.reload();
|
||||
// }, 3000);
|
||||
// });
|
||||
// return module.initialize(client).then(() => {
|
||||
// logger.info("Initialized workbench", field("duration", initTime));
|
||||
//
|
||||
// });
|
||||
// }).catch((error) => {
|
||||
// });
|
||||
});
|
||||
};
|
||||
|
||||
export { load };
|
||||
|
|
Loading…
Reference in New Issue