Skip to content

Commit d94d12a

Browse files
code-asherkylecarbs
authored andcommitted
More loading
1 parent d4fce3a commit d94d12a

File tree

4 files changed

+60
-51
lines changed

4 files changed

+60
-51
lines changed

packages/app/src/index.ts

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
import { logger } from "@coder/logger";
1+
import { logger, field, time } from "@coder/logger";
2+
import { load } from "@coder/vscode";
23
import "./index.scss";
34

4-
logger.info("Starting app");
5+
const loadTime = time(2500);
6+
logger.info("Loading IDE...");
57

68
const overlay = document.getElementById("overlay");
79
const logo = document.getElementById("logo");
10+
const msgElement = overlay
11+
? overlay.querySelector(".message") as HTMLElement
12+
: undefined;
13+
814
if (overlay && logo) {
915
overlay.addEventListener("mousemove", (event) => {
1016
const xPos = ((event.clientX - logo.offsetLeft) / 24).toFixed(2);
@@ -14,4 +20,24 @@ if (overlay && logo) {
1420
});
1521
}
1622

17-
import "@coder/vscode";
23+
load().then(() => {
24+
if (overlay) {
25+
overlay.style.opacity = "0";
26+
overlay.addEventListener("transitionend", () => {
27+
overlay.remove();
28+
});
29+
}
30+
}).catch((error: Error) => {
31+
logger.error(error.message);
32+
if (overlay) {
33+
overlay.classList.add("error");
34+
}
35+
if (msgElement) {
36+
msgElement.innerText = `Failed to load: ${error.message}. Retrying in 3 seconds...`;
37+
}
38+
setTimeout(() => {
39+
location.reload();
40+
}, 3000);
41+
}).finally(() => {
42+
logger.info("Load completed", field("duration", loadTime));
43+
});

packages/node-browser/src/child_process.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as cp from "child_process";
22
import * as stream from "stream";
33
import * as events from "events";
44
import * as net from "net";
5-
import { wush, Session } from "@coder/wush";
65
import { useBuffer, throwUnimplementedError, throwSyncError } from "./util";
76

87
/**
@@ -34,7 +33,7 @@ class ChildProcess extends events.EventEmitter implements cp.ChildProcess {
3433

3534
private emitter = new events.EventEmitter();
3635

37-
public constructor(private session: Session) {
36+
public constructor(private session) {
3837
super();
3938

4039
this.emitter = new events.EventEmitter();

packages/node-browser/src/util.ts

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export abstract class Queue<T> {
5959

6060
public constructor(max?: number) {
6161
this.items = new Map();
62-
this.run = run;
6362
this.max = max;
6463
}
6564

packages/vscode/src/index.ts

+30-45
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,39 @@
11
import { field, logger, time } from "@coder/logger";
2-
const loadTime = time(2500);
3-
42
import { Client, IURI, setUriFactory } from "@coder/ide";
53
import { URI } from "vs/base/common/uri";
64
import "./firefox";
75

8-
setUriFactory({
9-
// TODO: not sure why this is an error.
10-
// tslint:disable-next-line no-any
11-
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
12-
file: (path: string): IURI => URI.file(path),
13-
parse: (raw: string): IURI => URI.parse(raw),
14-
});
6+
const load = (): Promise<void> => {
7+
return new Promise((resolve, reject) => {
8+
setUriFactory({
9+
// TODO: not sure why this is an error.
10+
// tslint:disable-next-line no-any
11+
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
12+
file: (path: string): IURI => URI.file(path),
13+
parse: (raw: string): IURI => URI.parse(raw),
14+
});
15+
16+
reject(new Error("not finished"));
1517

16-
// export const client = new Client({
17-
// mkDirs: [
18-
// "~/vscode/extensions",
19-
// "~/.config/User",
20-
// ],
21-
// });
18+
// export const client = new Client({
19+
// mkDirs: [
20+
// "~/vscode/extensions",
21+
// "~/.config/User",
22+
// ],
23+
// });
2224

23-
// const overlayElement = document.getElementById("overlay");
24-
// const msgElement = overlayElement
25-
// ? overlayElement.querySelector(".message") as HTMLElement
26-
// : undefined;
25+
// const importTime = time(1500);
26+
// import(/* webpackPrefetch: true */ "./workbench").then((module) => {
27+
// logger.info("Loaded workbench bundle", field("duration", importTime));
28+
// const initTime = time(1500);
2729

28-
// const importTime = time(1500);
29-
// import(/* webpackPrefetch: true */ "./workbench").then((module) => {
30-
// logger.info("Loaded workbench bundle", field("duration", importTime));
31-
// const initTime = time(1500);
30+
// return module.initialize(client).then(() => {
31+
// logger.info("Initialized workbench", field("duration", initTime));
32+
//
33+
// });
34+
// }).catch((error) => {
35+
// });
36+
});
37+
};
3238

33-
// return module.initialize(client).then(() => {
34-
// logger.info("Initialized workbench", field("duration", initTime));
35-
// logger.info("Load completed", field("duration", loadTime));
36-
// if (overlayElement) {
37-
// overlayElement.style.opacity = "0";
38-
// overlayElement.addEventListener("transitionend", () => {
39-
// overlayElement.remove();
40-
// });
41-
// }
42-
// });
43-
// }).catch((error) => {
44-
// logger.error(error);
45-
// if (overlayElement) {
46-
// overlayElement.classList.add("error");
47-
// }
48-
// if (msgElement) {
49-
// msgElement.innerText = `Failed to load: ${error.message}. Retrying in 3 seconds...`;
50-
// }
51-
// setTimeout(() => {
52-
// location.reload();
53-
// }, 3000);
54-
// });
39+
export { load };

0 commit comments

Comments
 (0)