Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4656da3

Browse files
code-asherkylecarbs
authored andcommittedFeb 5, 2019
Uploader online (#26)
1 parent 322760f commit 4656da3

File tree

20 files changed

+430
-264
lines changed

20 files changed

+430
-264
lines changed
 

‎packages/ide/src/client.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
import { Event } from "@coder/events";
22
import { field, logger, time, Time } from "@coder/logger";
33
import { InitData, ISharedProcessData } from "@coder/protocol";
4-
import { retry, Retry } from "./retry";
4+
import { retry } from "./retry";
5+
import { Upload } from "./upload";
56
import { client } from "./fill/client";
67
import { Clipboard, clipboard } from "./fill/clipboard";
7-
8-
export interface IURI {
9-
10-
readonly path: string;
11-
readonly fsPath: string;
12-
readonly scheme: string;
13-
14-
}
15-
16-
export interface IURIFactory {
17-
18-
/**
19-
* Convert the object to an instance of a real URI.
20-
*/
21-
create<T extends IURI>(uri: IURI): T;
22-
file(path: string): IURI;
23-
parse(raw: string): IURI;
24-
25-
}
8+
import { INotificationService, NotificationService, IProgressService, ProgressService } from "./fill/notification";
9+
import { IURIFactory } from "./fill/uri";
2610

2711
/**
2812
* A general abstraction of an IDE client.
@@ -34,9 +18,10 @@ export interface IURIFactory {
3418
*/
3519
export abstract class Client {
3620

37-
public readonly retry: Retry = retry;
21+
public readonly retry = retry;
3822
public readonly clipboard: Clipboard = clipboard;
3923
public readonly uriFactory: IURIFactory;
24+
public readonly upload = new Upload(new NotificationService(), new ProgressService());
4025
private start: Time | undefined;
4126
private readonly progressElement: HTMLElement | undefined;
4227
private tasks: string[] = [];
@@ -187,6 +172,15 @@ export abstract class Client {
187172
return this.sharedProcessDataPromise;
188173
}
189174

175+
public set notificationService(service: INotificationService) {
176+
this.retry.notificationService = service;
177+
this.upload.notificationService = service;
178+
}
179+
180+
public set progressService(service: IProgressService) {
181+
this.upload.progressService = service;
182+
}
183+
190184
/**
191185
* Initialize the IDE.
192186
*/
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import { CP } from "@coder/protocol";
22
import { client } from "./client";
3+
import { promisify } from "./util";
34

4-
export = new CP(client);
5+
const cp = new CP(client);
6+
7+
// tslint:disable-next-line no-any makes util.promisify return an object
8+
(cp as any).exec[promisify.customPromisifyArgs] = ["stdout", "stderr"];
9+
10+
export = cp;

‎packages/ide/src/fill/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Connection implements ReadWriteConnection {
1616
private readonly downEmitter: Emitter<void> = new Emitter();
1717
private readonly messageBuffer: Uint8Array[] = [];
1818
private socketTimeoutDelay = 60 * 1000;
19-
private retryName = "Web socket";
19+
private retryName = "Socket";
2020
private isUp: boolean = false;
2121
private closed: boolean = false;
2222

‎packages/ide/src/fill/notification.ts

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { logger, field } from "@coder/logger";
2+
3+
/**
4+
* Handle for a notification that allows it to be closed and updated.
5+
*/
6+
export interface INotificationHandle {
7+
8+
/**
9+
* Closes the notification.
10+
*/
11+
close(): void;
12+
13+
/**
14+
* Update the message.
15+
*/
16+
updateMessage(message: string): void;
17+
18+
/**
19+
* Update the buttons.
20+
*/
21+
updateButtons(buttons: INotificationButton[]): void;
22+
23+
}
24+
25+
/**
26+
* Notification severity.
27+
*/
28+
export enum Severity {
29+
Ignore = 0,
30+
Info = 1,
31+
Warning = 2,
32+
Error = 3,
33+
}
34+
35+
/**
36+
* Notification button.
37+
*/
38+
export interface INotificationButton {
39+
label: string;
40+
run(): void;
41+
}
42+
43+
/**
44+
* Optional notification service.
45+
*/
46+
export interface INotificationService {
47+
48+
/**
49+
* Display an error message.
50+
*/
51+
error(error: Error): void;
52+
53+
/**
54+
* Show a notification.
55+
*/
56+
prompt(severity: Severity, message: string, buttons: INotificationButton[], onCancel: () => void): INotificationHandle;
57+
58+
}
59+
60+
/**
61+
* Updatable progress.
62+
*/
63+
export interface IProgress {
64+
65+
/**
66+
* Report progress. Progress is the completed percentage from 0 to 100.
67+
*/
68+
report(progress: number): void;
69+
70+
}
71+
72+
/**
73+
* Option progress reporting service.
74+
*/
75+
export interface IProgressService {
76+
77+
/**
78+
* Start a new progress bar that resolves & disappears when the task finishes.
79+
*/
80+
start<T>(title: string, task: (progress: IProgress) => Promise<T>, onCancel: () => void): Promise<T>;
81+
82+
}
83+
84+
/**
85+
* Temporary notification service.
86+
*/
87+
export class NotificationService implements INotificationService {
88+
89+
public error(error: Error): void {
90+
logger.error(error.message, field("error", error));
91+
}
92+
93+
public prompt(_severity: Severity, message: string, _buttons: INotificationButton[], _onCancel: () => void): INotificationHandle {
94+
throw new Error(`cannot prompt using the console: ${message}`);
95+
}
96+
97+
}
98+
99+
/**
100+
* Temporary progress service.
101+
*/
102+
export class ProgressService implements IProgressService {
103+
104+
public start<T>(title: string, task: (progress: IProgress) => Promise<T>): Promise<T> {
105+
logger.info(title);
106+
107+
return task({
108+
report: (progress): void => {
109+
logger.info(`${title} progress: ${progress}`);
110+
},
111+
});
112+
}
113+
114+
}

‎packages/ide/src/fill/uri.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export interface IURI {
2+
3+
readonly path: string;
4+
readonly fsPath: string;
5+
readonly scheme: string;
6+
7+
}
8+
9+
export interface IURIFactory {
10+
11+
/**
12+
* Convert the object to an instance of a real URI.
13+
*/
14+
create<T extends IURI>(uri: IURI): T;
15+
file(path: string): IURI;
16+
parse(raw: string): IURI;
17+
18+
}

‎packages/ide/src/fill/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from "../../../../node_modules/util";
2-
import { implementation } from "util.promisify";
2+
import { implementation } from "../../../../node_modules/util.promisify";
33

44
export const promisify = implementation;

‎packages/ide/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./client";
2-
export * from "./upload";
2+
export * from "./fill/uri";
3+
export * from "./fill/notification";

‎packages/ide/src/retry.ts

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,5 @@
11
import { logger } from "@coder/logger";
2-
3-
/**
4-
* Handle for a notification that allows it to be closed and updated.
5-
*/
6-
export interface INotificationHandle {
7-
8-
/**
9-
* Closes the notification.
10-
*/
11-
close(): void;
12-
13-
/**
14-
* Update the message.
15-
*/
16-
updateMessage(message: string): void;
17-
18-
/**
19-
* Update the buttons.
20-
*/
21-
updateButtons(buttons: INotificationButton[]): void;
22-
23-
}
24-
25-
/**
26-
* Notification severity.
27-
*/
28-
enum Severity {
29-
Ignore = 0,
30-
Info = 1,
31-
Warning = 2,
32-
Error = 3,
33-
}
34-
35-
/**
36-
* Notification button.
37-
*/
38-
export interface INotificationButton {
39-
label: string;
40-
run(): void;
41-
}
42-
43-
/**
44-
* Optional notification service.
45-
*/
46-
export interface INotificationService {
47-
48-
/**
49-
* Show a notification.
50-
*/
51-
prompt(severity: Severity, message: string, buttons: INotificationButton[], onCancel: () => void): INotificationHandle;
52-
53-
}
2+
import { NotificationService, INotificationHandle, INotificationService, Severity } from "./fill/notification";
543

554
interface IRetryItem {
565
count?: number;
@@ -91,15 +40,16 @@ export class Retry {
9140
// for reasoning.)
9241
private waitDelay = 50;
9342

94-
public constructor(private notificationService?: INotificationService) {
43+
public constructor(private _notificationService: INotificationService) {
9544
this.items = new Map();
9645
}
9746

98-
/**
99-
* Set notification service.
100-
*/
101-
public setNotificationService(notificationService?: INotificationService): void {
102-
this.notificationService = notificationService;
47+
public set notificationService(service: INotificationService) {
48+
this._notificationService = service;
49+
}
50+
51+
public get notificationService(): INotificationService {
52+
return this._notificationService;
10353
}
10454

10555
/**
@@ -262,10 +212,6 @@ export class Retry {
262212
* Update, close, or show the notification.
263213
*/
264214
private updateNotification(): void {
265-
if (!this.notificationService) {
266-
return;
267-
}
268-
269215
// tslint:disable-next-line no-any because NodeJS.Timer is valid.
270216
clearTimeout(this.updateTimeout as any);
271217

@@ -343,4 +289,4 @@ export class Retry {
343289

344290
// Global instance so we can block other retries when retrying the main
345291
// connection.
346-
export const retry = new Retry();
292+
export const retry = new Retry(new NotificationService());

‎packages/ide/src/upload.ts

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { appendFile } from "fs";
33
import { promisify } from "util";
44
import { logger, Logger } from "@coder/logger";
55
import { escapePath } from "@coder/protocol";
6-
import { IURI } from "./uri";
6+
import { IURI } from "./fill/uri";
7+
import { INotificationService, IProgressService, IProgress, Severity } from "./fill/notification";
78

89
/**
910
* Represents an uploadable directory, so we can query for existing files once.
@@ -27,47 +28,6 @@ interface IEntry {
2728
});
2829
}
2930

30-
/**
31-
* Updatable progress.
32-
*/
33-
interface IProgress {
34-
35-
/**
36-
* Report progress. Progress is the completed percentage from 0 to 100.
37-
*/
38-
report(progress: number): void;
39-
40-
}
41-
42-
/**
43-
* Service for reporting progress.
44-
*/
45-
interface IProgressService {
46-
47-
/**
48-
* Start a new progress bar that resolves & disappears when the task finishes.
49-
*/
50-
start<T>(title:string, task: (progress: IProgress) => Promise<T>): Promise<T>;
51-
52-
}
53-
54-
/**
55-
* Service for notifications.
56-
*/
57-
interface INotificationService {
58-
59-
/**
60-
* Display an error message.
61-
*/
62-
error(error: Error): void;
63-
64-
/**
65-
* Ask for a decision.
66-
*/
67-
prompt(message: string, choices: string[]): Promise<string>;
68-
69-
}
70-
7131
/**
7232
* Handles file uploads.
7333
*/
@@ -76,8 +36,6 @@ export class Upload {
7636
private readonly maxParallelUploads = 100;
7737
private readonly readSize = 32000; // ~32kb max while reading in the file.
7838
private readonly packetSize = 32000; // ~32kb max when writing.
79-
private readonly notificationService: INotificationService;
80-
private readonly progressService: IProgressService;
8139
private readonly logger: Logger;
8240
private readonly currentlyUploadingFiles: Map<string, File>;
8341
private readonly queueByDirectory: Map<string, IUploadableDirectory>;
@@ -88,9 +46,10 @@ export class Upload {
8846
private uploadedFilePaths: string[];
8947
private total: number;
9048

91-
public constructor(notificationService: INotificationService, progressService: IProgressService) {
92-
this.notificationService = notificationService;
93-
this.progressService = progressService;
49+
public constructor(
50+
private _notificationService: INotificationService,
51+
private _progressService: IProgressService,
52+
) {
9453
this.logger = logger.named("Upload");
9554
this.currentlyUploadingFiles = new Map();
9655
this.queueByDirectory = new Map();
@@ -99,6 +58,22 @@ export class Upload {
9958
this.total = 0;
10059
}
10160

61+
public set notificationService(service: INotificationService) {
62+
this._notificationService = service;
63+
}
64+
65+
public get notificationService(): INotificationService {
66+
return this._notificationService;
67+
}
68+
69+
public set progressService(service: IProgressService) {
70+
this._progressService = service;
71+
}
72+
73+
public get progressService(): IProgressService {
74+
return this._progressService;
75+
}
76+
10277
/**
10378
* Upload dropped files. This will try to upload everything it can. Errors
10479
* will show via notifications. If an upload operation is ongoing, the files
@@ -125,6 +100,8 @@ export class Upload {
125100
resolve(uploaded);
126101
};
127102
});
103+
}, () => {
104+
this.cancel();
128105
});
129106
}
130107
this.uploadFiles();
@@ -214,8 +191,21 @@ export class Upload {
214191
*/
215192
private async uploadFile(path: string, file: File, existingFiles: string[]): Promise<void> {
216193
if (existingFiles.includes(path)) {
217-
const choice = await this.notificationService.prompt(`${path} already exists. Overwrite?`, ["Yes", "No"]);
218-
if (choice !== "Yes") {
194+
const shouldOverwrite = await new Promise((resolve): void => {
195+
this.notificationService.prompt(
196+
Severity.Error,
197+
`${path} already exists. Overwrite?`,
198+
[{
199+
label: "Yes",
200+
run: (): void => resolve(true),
201+
}, {
202+
label: "No",
203+
run: (): void => resolve(false),
204+
}],
205+
() => resolve(false),
206+
);
207+
});
208+
if (!shouldOverwrite) {
219209
return;
220210
}
221211
}

‎packages/protocol/src/browser/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,4 @@ export interface ActiveEval {
367367
on(event: "close", cb: () => void): void;
368368
on(event: "error", cb: (err: Error) => void): void;
369369
on(event: string, cb: (...args: any[]) => void): void;
370-
}
370+
}

‎packages/protocol/src/node/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ export class Server {
122122
this.evals.set(evalMessage.getId(), resp);
123123
}
124124
} else if (message.hasEvalEvent()) {
125-
const e = this.evals.get(message.getEvalEvent()!.getId());
125+
const evalEventMessage = message.getEvalEvent()!;
126+
logger.debug("EvalEventMessage", field("id", evalEventMessage.getId()));
127+
const e = this.evals.get(evalEventMessage.getId());
126128
if (!e) {
127129
return;
128130
}
129-
e.onEvent(message.getEvalEvent()!);
131+
e.onEvent(evalEventMessage);
130132
} else if (message.hasNewSession()) {
131133
const sessionMessage = message.getNewSession()!;
132134
logger.debug("NewSession", field("id", sessionMessage.getId()));

‎packages/server/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { field, logger, Level } from "@coder/logger";
1+
import { field, logger } from "@coder/logger";
22
import { ServerMessage, SharedProcessActiveMessage } from "@coder/protocol/src/proto";
33
import { Command, flags } from "@oclif/command";
44
import * as fs from "fs";

‎packages/vscode/src/client.ts

Lines changed: 111 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,125 @@ import "./fill/environmentService";
66
import "./fill/vscodeTextmate";
77
import "./fill/dom";
88
import "./vscode.scss";
9-
10-
import { Client as IDEClient, IURI, IURIFactory } from "@coder/ide";
11-
9+
import { Client as IDEClient, IURI, IURIFactory, IProgress, INotificationHandle } from "@coder/ide";
1210
import { registerContextMenuListener } from "vs/base/parts/contextmenu/electron-main/contextmenu";
1311
import { LogLevel } from "vs/platform/log/common/log";
1412
// import { RawContextKey, IContextKeyService } from "vs/platform/contextkey/common/contextkey";
1513
import { URI } from "vs/base/common/uri";
14+
import { INotificationService } from "vs/platform/notification/common/notification";
15+
import { IProgressService2, ProgressLocation } from "vs/platform/progress/common/progress";
16+
import { ExplorerItem, Model } from "vs/workbench/parts/files/common/explorerModel";
17+
import { DragMouseEvent } from "vs/base/browser/mouseEvent";
18+
import { IEditorService, IResourceEditor } from "vs/workbench/services/editor/common/editorService";
19+
import { IEditorGroup } from "vs/workbench/services/group/common/editorGroupsService";
20+
import { IWindowsService } from "vs/platform/windows/common/windows";
21+
import { ServiceCollection } from "vs/platform/instantiation/common/serviceCollection";
1622

1723
export class Client extends IDEClient {
1824

1925
private readonly windowId = parseInt(new Date().toISOString().replace(/[-:.TZ]/g, ""), 10);
26+
private _serviceCollection: ServiceCollection | undefined;
27+
28+
public async handleExternalDrop(target: ExplorerItem | Model, originalEvent: DragMouseEvent): Promise<void> {
29+
await this.upload.uploadDropped(
30+
originalEvent.browserEvent as DragEvent,
31+
(target instanceof ExplorerItem ? target : target.roots[0]).resource,
32+
);
33+
}
34+
35+
public handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup, afterDrop: (targetGroup: IEditorGroup) => void, targetIndex?: number): void {
36+
this.initData.then((d) => {
37+
this.upload.uploadDropped(event, URI.file(d.workingDirectory)).then((paths) => {
38+
const uris = paths.map((p) => URI.file(p));
39+
if (uris.length) {
40+
(this.serviceCollection.get(IWindowsService) as IWindowsService).addRecentlyOpened(uris);
41+
}
42+
43+
const editors: IResourceEditor[] = uris.map(uri => ({
44+
resource: uri,
45+
options: {
46+
pinned: true,
47+
index: targetIndex,
48+
},
49+
}));
50+
51+
const targetGroup = resolveTargetGroup();
52+
53+
(this.serviceCollection.get(IEditorService) as IEditorService).openEditors(editors, targetGroup).then(() => {
54+
afterDrop(targetGroup);
55+
});
56+
});
57+
});
58+
}
59+
60+
public get serviceCollection(): ServiceCollection {
61+
if (!this._serviceCollection) {
62+
throw new Error("Trying to access service collection before it has been set");
63+
}
64+
65+
return this._serviceCollection;
66+
}
67+
68+
public set serviceCollection(collection: ServiceCollection) {
69+
this._serviceCollection = collection;
70+
this.progressService = {
71+
start: <T>(title: string, task: (progress: IProgress) => Promise<T>, onCancel: () => void): Promise<T> => {
72+
let lastProgress = 0;
73+
74+
return (this.serviceCollection.get(IProgressService2) as IProgressService2).withProgress({
75+
location: ProgressLocation.Notification,
76+
title,
77+
cancellable: true,
78+
}, (progress) => {
79+
return task({
80+
report: (p): void => {
81+
progress.report({ increment: p - lastProgress });
82+
lastProgress = p;
83+
},
84+
});
85+
}, () => {
86+
onCancel();
87+
});
88+
},
89+
};
90+
91+
this.notificationService = {
92+
error: (error: Error): void => (this.serviceCollection.get(INotificationService) as INotificationService).error(error),
93+
prompt: (severity, message, buttons, onCancel): INotificationHandle => {
94+
const handle = (this.serviceCollection.get(INotificationService) as INotificationService).prompt(
95+
severity, message, buttons, { onCancel },
96+
);
97+
98+
return {
99+
close: (): void => handle.close(),
100+
updateMessage: (message): void => handle.updateMessage(message),
101+
updateButtons: (buttons): void => handle.updateActions({
102+
primary: buttons.map((button) => ({
103+
id: "",
104+
label: button.label,
105+
tooltip: "",
106+
class: undefined,
107+
enabled: true,
108+
checked: false,
109+
radio: false,
110+
dispose: (): void => undefined,
111+
run: (): Promise<void> => Promise.resolve(button.run()),
112+
})),
113+
}),
114+
};
115+
},
116+
};
117+
}
118+
119+
protected createUriFactory(): IURIFactory {
120+
return {
121+
// TODO: not sure why this is an error.
122+
// tslint:disable-next-line no-any
123+
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
124+
file: (path: string): IURI => URI.file(path),
125+
parse: (raw: string): IURI => URI.parse(raw),
126+
};
127+
}
20128

21129
protected initialize(): Promise<void> {
22130
registerContextMenuListener();
@@ -46,33 +154,6 @@ export class Client extends IDEClient {
46154
folderUri: URI.file(data.workingDirectory),
47155
});
48156

49-
// TODO: Set notification service for retrying.
50-
// this.retry.setNotificationService({
51-
// prompt: (severity, message, buttons, onCancel) => {
52-
// const handle = getNotificationService().prompt(severity, message, buttons, onCancel);
53-
// return {
54-
// close: () => handle.close(),
55-
// updateMessage: (message) => handle.updateMessage(message),
56-
// updateButtons: (buttons) => handle.updateActions({
57-
// primary: buttons.map((button) => ({
58-
// id: undefined,
59-
// label: button.label,
60-
// tooltip: undefined,
61-
// class: undefined,
62-
// enabled: true,
63-
// checked: false,
64-
// radio: false,
65-
// dispose: () => undefined,
66-
// run: () => {
67-
// button.run();
68-
// return Promise.resolve();
69-
// },
70-
// })),
71-
// }),
72-
// };
73-
// }
74-
// });
75-
76157
// TODO: Set up clipboard context.
77158
// const workbench = workbenchShell.workbench;
78159
// const contextKeys = workbench.workbenchParams.serviceCollection.get(IContextKeyService) as IContextKeyService;
@@ -85,16 +166,6 @@ export class Client extends IDEClient {
85166
}, this.initData, pathSets);
86167
}
87168

88-
protected createUriFactory(): IURIFactory {
89-
return {
90-
// TODO: not sure why this is an error.
91-
// tslint:disable-next-line no-any
92-
create: <URI>(uri: IURI): URI => URI.from(uri) as any,
93-
file: (path: string): IURI => URI.file(path),
94-
parse: (raw: string): IURI => URI.parse(raw),
95-
};
96-
}
97-
98169
}
99170

100171
export const client = new Client();

‎packages/vscode/src/fill/iconv-lite.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const decodeStream = (encoding: string): NodeJS.ReadWriteStream => {
5959
return new IconvLiteDecoderStream({ encoding });
6060
};
6161

62-
// @ts-ignore
63-
iconv.decodeStream = decodeStream;
62+
const target = iconv as typeof iconv;
63+
target.decodeStream = decodeStream;
6464

65-
export = iconv;
65+
export = target;

‎packages/vscode/src/fill/require.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
// TODO: ?
1+
import { join } from "path";
2+
23
// tslint:disable-next-line no-any
3-
(global as any).requireToUrl = (path: string): string => `${location.protocol}//{location.host}/${path}`;
4+
(global as any).requireToUrl = (path: string): string => {
5+
// TODO: can start with vs/...
6+
return join(`${location.protocol}//${location.host}/resource`, path);
7+
};

‎packages/vscode/src/fill/storageDatabase.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as globalStorage from "vs/platform/storage/node/storageIpc";
88
import * as paths from "./paths";
99
import { logger, field } from "@coder/logger";
1010

11-
export class StorageDatabase implements workspaceStorage.IStorageDatabase {
11+
class StorageDatabase implements workspaceStorage.IStorageDatabase {
1212

1313
public readonly onDidChangeItemsExternal = Event.None;
1414
private items = new Map<string, string>();
@@ -81,7 +81,7 @@ export class StorageDatabase implements workspaceStorage.IStorageDatabase {
8181

8282
}
8383

84-
export class GlobalStorageDatabase extends StorageDatabase implements IDisposable {
84+
class GlobalStorageDatabase extends StorageDatabase implements IDisposable {
8585

8686
public constructor() {
8787
super(path.join(paths.getAppDataPath(), "globalStorage", "state.vscdb"));
@@ -93,7 +93,10 @@ export class GlobalStorageDatabase extends StorageDatabase implements IDisposabl
9393

9494
}
9595

96-
// @ts-ignore
97-
workspaceStorage.SQLiteStorageDatabase = StorageDatabase;
98-
// @ts-ignore
99-
globalStorage.GlobalStorageDatabaseChannelClient = GlobalStorageDatabase;
96+
const workspaceTarget = workspaceStorage as typeof workspaceStorage;
97+
// @ts-ignore TODO: don't ignore it.
98+
workspaceTarget.SQLiteStorageDatabase = StorageDatabase;
99+
100+
const globalTarget = globalStorage as typeof globalStorage;
101+
// @ts-ignore TODO: don't ignore it.
102+
globalTarget.GlobalStorageDatabaseChannelClient = GlobalStorageDatabase;

‎packages/vscode/src/fill/vscodeTextmate.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,29 @@ target.Registry = class Registry extends vscodeTextmate.Registry {
88
...opts,
99
getOnigLib: (): Promise<vscodeTextmate.IOnigLib> => {
1010
return new Promise<vscodeTextmate.IOnigLib>((res, rej) => {
11-
const onigasm = require('onigasm');
12-
const wasmUrl = require('!!file-loader!onigasm/lib/onigasm.wasm');
11+
const onigasm = require("onigasm");
12+
const wasmUrl = require("!!file-loader!onigasm/lib/onigasm.wasm");
13+
1314
return fetch(wasmUrl).then(resp => resp.arrayBuffer()).then(buffer => {
1415
return onigasm.loadWASM(buffer);
1516
}).then(() => {
1617
res({
1718
createOnigScanner: function (patterns) { return new onigasm.OnigScanner(patterns); },
18-
createOnigString: function (s) { return new onigasm.OnigString(s); }
19-
})
19+
createOnigString: function (s) { return new onigasm.OnigString(s); },
20+
});
2021
}).catch(reason => rej(reason));
2122
});
2223
},
2324
});
2425
}
25-
}
26+
};
2627

2728
enum StandardTokenType {
2829
Other = 0,
29-
Comment = 1,
30-
String = 2,
31-
RegEx = 4,
32-
};
30+
Comment = 1,
31+
String = 2,
32+
RegEx = 4,
33+
}
3334

34-
// Any needed here to override const
35-
(<any>target).StandardTokenType = StandardTokenType;
35+
// tslint:disable-next-line no-any to override const
36+
(target as any).StandardTokenType = StandardTokenType;

‎packages/vscode/src/fill/windowsService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,6 @@ class WindowsService implements IWindowsService {
281281

282282
}
283283

284-
// @ts-ignore
285-
windowsIpc.WindowsChannelClient = WindowsService;
284+
const target = windowsIpc as typeof windowsIpc;
285+
// @ts-ignore TODO: don't ignore it.
286+
target.WindowsChannelClient = WindowsService;

‎packages/vscode/src/upload.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

‎scripts/vscode.patch

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ index 2bf7fe37d7..81cc668f12 100644
4747
}
4848
catch (err) {
4949
errorback(err);
50+
diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts
51+
index 38bf337a61..aae3a68ff5 100644
52+
--- a/src/vs/workbench/browser/dnd.ts
53+
+++ b/src/vs/workbench/browser/dnd.ts
54+
@@ -31,6 +31,7 @@ import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/co
55+
import { Disposable } from 'vs/base/common/lifecycle';
56+
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
57+
import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService';
58+
+import { client } from "../../../../../../packages/vscode";
59+
60+
export interface IDraggedResource {
61+
resource: URI;
62+
@@ -168,7 +169,7 @@ export class ResourcesDropHandler {
63+
handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup, afterDrop: (targetGroup: IEditorGroup) => void, targetIndex?: number): void {
64+
const untitledOrFileResources = extractResources(event).filter(r => this.fileService.canHandleResource(r.resource) || r.resource.scheme === Schemas.untitled);
65+
if (!untitledOrFileResources.length) {
66+
- return;
67+
+ return client.handleDrop(event, resolveTargetGroup, afterDrop, targetIndex);
68+
}
69+
70+
// Make the window active to handle the drop properly within
5071
diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts
5172
index a43d63aa51..4c6df2fcd9 100644
5273
--- a/src/vs/workbench/electron-browser/main.ts
@@ -73,6 +94,26 @@ index a43d63aa51..4c6df2fcd9 100644
7394
});
7495
});
7596
});
97+
diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts
98+
index 35bc4a82b3..9cc84bdf28 100644
99+
--- a/src/vs/workbench/electron-browser/workbench.ts
100+
+++ b/src/vs/workbench/electron-browser/workbench.ts
101+
@@ -114,6 +114,7 @@ import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/work
102+
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
103+
import { FileDialogService } from 'vs/workbench/services/dialogs/electron-browser/dialogService';
104+
import { LogStorageAction } from 'vs/platform/storage/node/storageService';
105+
+import { client } from "../../../../../../packages/vscode";
106+
107+
interface WorkbenchParams {
108+
configuration: IWindowConfiguration;
109+
@@ -248,6 +249,7 @@ export class Workbench extends Disposable implements IPartService {
110+
super();
111+
112+
this.workbenchParams = { configuration, serviceCollection };
113+
+ client.serviceCollection = serviceCollection;
114+
115+
this.hasInitialFilesToOpen =
116+
(configuration.filesToCreate && configuration.filesToCreate.length > 0) ||
76117
diff --git a/src/vs/workbench/node/extensionHostProcess.ts b/src/vs/workbench/node/extensionHostProcess.ts
77118
index 8d182d18d9..69d51e1aea 100644
78119
--- a/src/vs/workbench/node/extensionHostProcess.ts
@@ -86,6 +127,26 @@ index 8d182d18d9..69d51e1aea 100644
86127
} catch (e) {
87128
onTerminate();
88129
}
130+
diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
131+
index e600fb2f78..5d65a3124e 100644
132+
--- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
133+
+++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
134+
@@ -55,6 +55,7 @@ import { IDialogService, IConfirmationResult, IConfirmation, getConfirmMessage }
135+
import { INotificationService } from 'vs/platform/notification/common/notification';
136+
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
137+
import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
138+
+import { client } from "../../../../../../../../../packages/vscode";
139+
140+
export class FileDataSource implements IDataSource {
141+
constructor(
142+
@@ -932,6 +933,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
143+
}
144+
145+
private handleExternalDrop(tree: ITree, data: DesktopDragAndDropData, target: ExplorerItem | Model, originalEvent: DragMouseEvent): TPromise<void> {
146+
+ return client.handleExternalDrop(target, originalEvent);
147+
const droppedResources = extractResources(originalEvent.browserEvent as DragEvent, true);
148+
149+
// Check for dropped external files to be folders
89150
diff --git a/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts b/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
90151
index 7b4e8721ac..8f26dc2f28 100644
91152
--- a/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
@@ -101,3 +162,16 @@ index 7b4e8721ac..8f26dc2f28 100644
101162
try {
102163
resolve(content.default());
103164
} catch (err) {
165+
diff --git a/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts b/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
166+
index 5b4136989f..25ccc0fe9e 100644
167+
--- a/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
168+
+++ b/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
169+
@@ -178,7 +178,7 @@ function _processIconThemeDocument(id: string, iconThemeDocumentLocation: URI, i
170+
171+
const iconThemeDocumentLocationDirname = resources.dirname(iconThemeDocumentLocation);
172+
function resolvePath(path: string) {
173+
- return resources.joinPath(iconThemeDocumentLocationDirname, path);
174+
+ return "/resource" + resources.joinPath(iconThemeDocumentLocationDirname, path).path;
175+
}
176+
177+
function collectSelectors(associations: IconsAssociation, baseThemeClassName?: string) {

0 commit comments

Comments
 (0)
Please sign in to comment.