1
- import * as fs from "fs" ;
2
- import {
3
- Client , Emitter , getFactory , IPosition , IFileConflict , ConflictResolution ,
4
- Event ,
5
- IDisposable ,
6
- IDocumentContentChangedEvent , IURI , IRange , escapePath ,
7
- IOrphanedChangedEvent ,
8
- } from 'coder/common' ;
9
- import { Protocol } from 'vs/base/parts/ipc/node/ipc.net' ;
10
- import { IModelService } from 'vs/editor/common/services/modelService' ;
11
- import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
12
- import { ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle' ;
13
- import { TPromise } from 'vs/base/common/winjs.base' ;
14
- import { ITextModel , TrackedRangeStickiness , IModelDeltaDecoration } from 'vs/editor/common/model' ;
15
- import { Position } from 'vs/editor/common/core/position' ;
16
- import { Selection } from 'vs/editor/common/core/selection' ;
17
- import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
18
- import { registerContextMenuListener } from 'vs/base/parts/contextmenu/electron-main/contextmenu' ;
19
- import { Workbench } from 'vs/workbench/electron-browser/workbench' ;
20
- import { StorageService } from 'coder/storageService' ;
21
- import { IContentData , IFileService , FileOperationError , FileOperationResult , FileSystemProviderCapabilities , IStat , FileType } from 'vs/platform/files/common/files' ;
22
- import { onInstantiation as onFileServiceInstantiation } from 'vs/workbench/services/files/electron-browser/fileService' ;
23
- import { URI } from 'vs/base/common/uri' ;
24
- import { EventEmitter } from 'events' ;
25
- import { Range } from 'vs/editor/common/core/range' ;
26
- import product from 'vs/platform/node/product' ;
27
- import { CONFLICT_RESOLUTION_SCHEME } from 'vs/workbench/parts/files/electron-browser/saveErrorHandler' ;
28
- import { ITextFileService , ModelState } from 'vs/workbench/services/textfile/common/textfiles' ;
29
- import { field , logger } from 'coder/logger' ;
30
- import { events } from 'coder/analytics' ;
31
- import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations' ;
32
- import { registerCollaboratorDecorations } from 'coder/collaborators' ;
33
- import { IInitData as ISharedProcessInitData } from 'vs/code/electron-browser/sharedProcess/sharedProcessClient' ;
34
- import { LogLevel } from 'vs/platform/log/common/log' ;
35
- import { INotificationService , Severity } from 'vs/platform/notification/common/notification' ;
36
- import { toLocalISOString } from 'vs/base/common/date' ;
37
- import { RawContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
1
+ import { Client } from "@coder/ide" ;
2
+ import { Emitter } from "@coder/events" ;
3
+ import { logger } from "@coder/logger" ;
4
+
5
+ import { Protocol } from "vs/base/parts/ipc/node/ipc.net" ;
6
+ import { IModelService } from "vs/editor/common/services/modelService" ;
7
+ import { ICodeEditorService } from "vs/editor/browser/services/codeEditorService" ;
8
+ import { registerContextMenuListener } from "vs/base/parts/contextmenu/electron-main/contextmenu" ;
9
+ import { Workbench } from "vs/workbench/electron-browser/workbench" ;
10
+ import { IDecorationsService } from "vs/workbench/services/decorations/browser/decorations" ;
11
+ import { LogLevel } from "vs/platform/log/common/log" ;
12
+ import { INotificationService , Severity } from "vs/platform/notification/common/notification" ;
13
+ import { toLocalISOString } from "vs/base/common/date" ;
14
+ import { RawContextKey , IContextKeyService } from "vs/platform/contextkey/common/contextkey" ;
15
+
16
+ import { StorageService } from "./storageService" ;
38
17
39
18
let protoResolve : ( protocol : Protocol ) => void ;
40
19
export const protocolPromise = new Promise < Protocol > ( ( res ) => {
@@ -79,14 +58,6 @@ function getCodeEditorService(): ICodeEditorService {
79
58
return workbench . workbenchParams . serviceCollection . get ( ICodeEditorService ) as ICodeEditorService ;
80
59
}
81
60
82
- function getFileService ( ) : IFileService {
83
- return workbench . workbenchParams . serviceCollection . get ( IFileService ) as IFileService ;
84
- }
85
-
86
- function getTextFileService ( ) : ITextFileService {
87
- return workbench . workbenchParams . serviceCollection . get ( ITextFileService ) as ITextFileService ;
88
- }
89
-
90
61
function getNotificationService ( ) : INotificationService {
91
62
return workbench . workbenchParams . serviceCollection . get ( INotificationService ) as INotificationService ;
92
63
}
@@ -96,6 +67,7 @@ export const initialize = async (client: Client): Promise<void> {
96
67
event . preventDefault ( ) ;
97
68
} ) ;
98
69
70
+ // TODO: Fetch configuration.
99
71
const storageServicePromise = client . wrapTask ( "Set configurations" , 5 , async ( state ) => {
100
72
const storageService = new StorageService ( state . global , state . workspace ) ;
101
73
storageResolve ( storageService ) ;
@@ -239,7 +211,14 @@ export const initialize = async (client: Client): Promise<void> {
239
211
await registerCollaboratorDecorations ( client , decorations ) ;
240
212
241
213
return workbenchShell ;
242
- } , client . workspace . then ( ( w ) => w . connect ( ) ) , mountPromise , client . mkDirs ) ;
214
+ } , client . mkDirs ) ;
215
+
216
+ client . wrapTask ( "Set up saving state" , 5 , async ( ) => {
217
+ if ( ! navigator . sendBeacon ) {
218
+ throw new Error ( "cannot save state" ) ;
219
+ }
220
+ // TODO: save storageSevice.globalObject and storageService.workspaceObject
221
+ } ) ;
243
222
244
223
await workbenchPromise ;
245
224
} ;
0 commit comments