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