@codingame/monaco-vscode-api 1.83.6 → 1.83.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/monaco.d.ts CHANGED
@@ -18,12 +18,17 @@ export { ContextKeyExpr, RawContextKey } from './vscode/src/vs/platform/contextk
18
18
  import { IKeybindingService } from './vscode/src/vs/platform/keybinding/common/keybinding.js';
19
19
  import { KeybindingResolver } from './vscode/src/vs/platform/keybinding/common/keybindingResolver.js';
20
20
  import { ResolvedKeybindingItem } from './vscode/src/vs/platform/keybinding/common/resolvedKeybindingItem.js';
21
+ import { Event } from './vscode/src/vs/base/common/event.js';
21
22
 
22
23
  declare function writeFile(uri: URI, content: string): Promise<void>;
23
24
  declare function deleteFile(uri: URI, options?: Partial<IFileDeleteOptions>): Promise<void>;
24
25
  declare function createModelReference(resource: URI, content?: string): Promise<IReference<ITextFileEditorModel>>;
26
+ interface KeybindingProvider {
27
+ provideKeybindings(): ResolvedKeybindingItem[];
28
+ onDidChangeKeybindings: Event<void>;
29
+ }
25
30
  interface DynamicKeybindingService extends IKeybindingService {
26
- registerKeybindingProvider(provider: () => ResolvedKeybindingItem[]): IDisposable;
31
+ registerKeybindingProvider(provider: KeybindingProvider): IDisposable;
27
32
  _getResolver(): KeybindingResolver;
28
33
  }
29
34
  declare const createConfiguredEditor: typeof create;
@@ -33,4 +38,4 @@ declare const Extensions: {
33
38
  JSONContribution: string;
34
39
  };
35
40
 
36
- export { type DynamicKeybindingService, Extensions, IReference, ITextFileEditorModel, createConfiguredDiffEditor, createConfiguredEditor, createModelReference, deleteFile, writeFile };
41
+ export { type DynamicKeybindingService, Extensions, IReference, ITextFileEditorModel, type KeybindingProvider, createConfiguredDiffEditor, createConfiguredEditor, createModelReference, deleteFile, writeFile };
package/monaco.js CHANGED
@@ -36,6 +36,7 @@ import { INotificationService } from 'monaco-editor/esm/vs/platform/notification
36
36
  import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
37
37
  import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
38
38
  import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
39
+ import { Emitter } from 'monaco-editor';
39
40
  import { createInjectedClass } from './tools/injection.js';
40
41
  import './vscode/src/vs/workbench/contrib/codeEditor/browser/workbenchReferenceSearch.js';
41
42
  import './vscode/src/vs/workbench/contrib/codeEditor/browser/menuPreventer.js';
@@ -144,14 +145,27 @@ let DelegateStandaloneKeybindingService = class DelegateStandaloneKeybindingServ
144
145
  constructor(delegate, contextKeyService, commandService, telemetryService, notificationService, logService, codeEditorService) {
145
146
  super(contextKeyService, commandService, telemetryService, notificationService, logService, codeEditorService);
146
147
  this.delegate = delegate;
147
- this._register(delegate.registerKeybindingProvider(() => this.getUserKeybindingItems()));
148
+ this._onDidChangeKeybindings = new Emitter();
149
+ this._register(delegate.registerKeybindingProvider({
150
+ provideKeybindings: () => {
151
+ return this.getUserKeybindingItems();
152
+ },
153
+ onDidChangeKeybindings: this._onDidChangeKeybindings.event
154
+ }));
148
155
  }
149
156
  _getResolver() {
150
157
  return this.delegate._getResolver();
151
158
  }
159
+ updateResolver() {
160
+ super.updateResolver();
161
+ this._onDidChangeKeybindings.fire();
162
+ }
152
163
  resolveKeyboardEvent(keyboardEvent) {
153
164
  return this.delegate.resolveKeyboardEvent(keyboardEvent);
154
165
  }
166
+ resolveKeybinding(keybinding) {
167
+ return this.delegate.resolveKeybinding(keybinding);
168
+ }
155
169
  };
156
170
  DelegateStandaloneKeybindingService = __decorate([
157
171
  ( __param(1, IContextKeyService)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-api",
3
- "version": "1.83.6",
3
+ "version": "1.83.8",
4
4
  "description": "VSCode public API plugged on the monaco editor",
5
5
  "keywords": [],
6
6
  "author": {
@@ -36,6 +36,10 @@
36
36
  "types": "./lifecycle.d.ts",
37
37
  "default": "./lifecycle.js"
38
38
  },
39
+ "./workbench": {
40
+ "types": "./workbench.d.ts",
41
+ "default": "./workbench.js"
42
+ },
39
43
  "./service-override/*": {
40
44
  "types": "./service-override/*.d.ts",
41
45
  "default": "./service-override/*.js"
@@ -75,6 +79,9 @@
75
79
  "lifecycle": [
76
80
  "./lifecycle.d.ts"
77
81
  ],
82
+ "workbench": [
83
+ "./workbench.d.ts"
84
+ ],
78
85
  "l10n": [
79
86
  "./l10n.d.ts"
80
87
  ],
@@ -1,21 +1,21 @@
1
1
  import { __decorate, __param } from '../external/tslib/tslib.es6.js';
2
2
  import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
3
3
  import { IBrowserWorkbenchEnvironmentService, BrowserWorkbenchEnvironmentService } from '../vscode/src/vs/workbench/services/environment/browser/environmentService.js';
4
- import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
5
4
  import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
6
5
  import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
6
+ import { logsPath, getWorkspaceIdentifier, getWorkbenchConstructionOptions } from '../workbench.js';
7
7
  let InjectedBrowserWorkbenchEnvironmentService = class InjectedBrowserWorkbenchEnvironmentService extends BrowserWorkbenchEnvironmentService {
8
- constructor(options, productService) {
9
- super('default', ( URI.from({ scheme: 'logs', path: '/' })), options, productService);
8
+ constructor(workspaceId = getWorkspaceIdentifier().id, options = getWorkbenchConstructionOptions(), productService) {
9
+ super(workspaceId, logsPath, options, productService);
10
10
  }
11
11
  };
12
12
  InjectedBrowserWorkbenchEnvironmentService = __decorate([
13
- ( __param(1, IProductService))
13
+ ( __param(2, IProductService))
14
14
  ], InjectedBrowserWorkbenchEnvironmentService);
15
- function getServiceOverride(options = {}) {
15
+ function getServiceOverride(options) {
16
16
  return {
17
17
  [( IEnvironmentService.toString())]: new SyncDescriptor(InjectedBrowserWorkbenchEnvironmentService, [], true),
18
- [( IBrowserWorkbenchEnvironmentService.toString())]: new SyncDescriptor(InjectedBrowserWorkbenchEnvironmentService, [options], true)
18
+ [( IBrowserWorkbenchEnvironmentService.toString())]: new SyncDescriptor(InjectedBrowserWorkbenchEnvironmentService, [undefined, options], true)
19
19
  };
20
20
  }
21
21
  export { getServiceOverride as default };
@@ -16,8 +16,11 @@ export { HTMLFileSystemProvider } from 'monaco-editor/esm/vs/platform/files/brow
16
16
  import * as path from 'monaco-editor/esm/vs/base/common/path.js';
17
17
  import '../vscode/src/vs/workbench/contrib/files/browser/files.contribution.js';
18
18
  import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
19
- export { IndexedDBFileSystemProvider } from '../vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js';
19
+ import { IndexedDBFileSystemProvider } from '../vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.js';
20
+ import { IndexedDB } from 'monaco-editor/esm/vs/base/browser/indexedDB.js';
20
21
  export { IndexedDB } from 'monaco-editor/esm/vs/base/browser/indexedDB.js';
22
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
23
+ import { logsPath } from '../workbench.js';
21
24
  class RegisteredFile {
22
25
  constructor(uri, readonly) {
23
26
  this.uri = uri;
@@ -395,13 +398,13 @@ const userDataFileSystemProvider = new InMemoryFileSystemProvider();
395
398
  void userDataFileSystemProvider.mkdir(( URI.from({ scheme: Schemas.vscodeUserData, path: '/User/' })));
396
399
  const providers = {
397
400
  extension: extensionFileSystemProvider,
398
- logs: new InMemoryFileSystemProvider(),
401
+ [logsPath.scheme]: new InMemoryFileSystemProvider(),
399
402
  [Schemas.vscodeUserData]: userDataFileSystemProvider,
400
403
  [Schemas.tmp]: new InMemoryFileSystemProvider(),
401
404
  file: fileSystemProvider
402
405
  };
403
406
  let MemoryFileService = class MemoryFileService extends FileService {
404
- constructor(logService) {
407
+ constructor(logService, telemetryService) {
405
408
  super(logService);
406
409
  for (const [scheme, provider] of Object.entries(providers)) {
407
410
  let disposable = this.registerProvider(scheme, provider);
@@ -411,11 +414,15 @@ let MemoryFileService = class MemoryFileService extends FileService {
411
414
  disposable = this.registerProvider(scheme, fileSystemProvider);
412
415
  });
413
416
  }
417
+ if (provider instanceof IndexedDBFileSystemProvider) {
418
+ this._register(provider.onReportError(e => telemetryService.publicLog2('indexedDBFileSystemProviderError', e)));
419
+ }
414
420
  }
415
421
  }
416
422
  };
417
423
  MemoryFileService = __decorate([
418
- ( __param(0, ILogService))
424
+ ( __param(0, ILogService)),
425
+ ( __param(1, ITelemetryService))
419
426
  ], MemoryFileService);
420
427
  function getServiceOverride() {
421
428
  return {
@@ -433,6 +440,14 @@ async function initFile(scheme, file, content, options) {
433
440
  if (provider == null || provider.writeFile == null) {
434
441
  throw new Error(`${scheme} provider doesn't exist or doesn't support writing files`);
435
442
  }
443
+ if (!(options?.overwrite ?? false)) {
444
+ try {
445
+ await provider.stat(file);
446
+ return;
447
+ }
448
+ catch (error) {
449
+ }
450
+ }
436
451
  await provider.writeFile(file, content instanceof Uint8Array ? content : encoder.encode(content), {
437
452
  atomic: false,
438
453
  create: true,
@@ -441,7 +456,16 @@ async function initFile(scheme, file, content, options) {
441
456
  ...options
442
457
  });
443
458
  }
459
+ async function createIndexedDBProviders() {
460
+ const userDataStore = 'vscode-userdata-store';
461
+ const logsStore = 'vscode-logs-store';
462
+ const indexedDB = await IndexedDB.create('vscode-web-db', 3, [userDataStore, logsStore]);
463
+ providers[logsPath.scheme] = new IndexedDBFileSystemProvider(logsPath.scheme, indexedDB, logsStore, false);
464
+ const userDataProvider = new IndexedDBFileSystemProvider(Schemas.vscodeUserData, indexedDB, userDataStore, true);
465
+ providers[Schemas.vscodeUserData] = userDataProvider;
466
+ return userDataProvider;
467
+ }
444
468
  function registerFileSystemOverlay(priority, provider) {
445
469
  return fileSystemProvider.register(priority, provider);
446
470
  }
447
- export { DelegateFileSystemProvider, FilePermission, FileType, InMemoryFileSystemProvider, RegisteredFile, RegisteredFileSystemProvider, RegisteredMemoryFile, RegisteredReadOnlyFile, getServiceOverride as default, initFile, registerCustomProvider, registerExtensionFile, registerFileSystemOverlay };
471
+ export { DelegateFileSystemProvider, FilePermission, FileType, InMemoryFileSystemProvider, IndexedDBFileSystemProvider, RegisteredFile, RegisteredFileSystemProvider, RegisteredMemoryFile, RegisteredReadOnlyFile, createIndexedDBProviders, getServiceOverride as default, initFile, registerCustomProvider, registerExtensionFile, registerFileSystemOverlay };
@@ -10,7 +10,7 @@ import { BrowserKeyboardLayoutService } from '../vscode/src/vs/workbench/service
10
10
  import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
11
11
  import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
12
12
  import { CommandService } from '../vscode/src/vs/workbench/services/commands/common/commandService.js';
13
- import { toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
13
+ import { DisposableStore, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
14
14
  import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
15
15
  import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
16
16
  import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
@@ -23,6 +23,7 @@ import { WorkbenchContextKeysHandler } from '../vscode/src/vs/workbench/browser/
23
23
  import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
24
24
  import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
25
25
  import getServiceOverride$1, { initFile } from './files.js';
26
+ import '../monaco.js';
26
27
  import { onRenderWorkbench } from '../lifecycle.js';
27
28
  import '../services.js';
28
29
  import '../vscode/src/vs/workbench/browser/workbench.contribution.js';
@@ -45,13 +46,18 @@ let DynamicWorkbenchKeybindingService = class DynamicWorkbenchKeybindingService
45
46
  registerKeybindingProvider(provider) {
46
47
  this.keybindingProviders.push(provider);
47
48
  this.updateResolver();
48
- return toDisposable(() => {
49
+ const store = new DisposableStore();
50
+ store.add(provider.onDidChangeKeybindings(() => {
51
+ this.updateResolver();
52
+ }));
53
+ store.add(toDisposable(() => {
49
54
  const idx = this.keybindingProviders.indexOf(provider);
50
55
  if (idx >= 0) {
51
56
  this.keybindingProviders.splice(idx, 1);
52
57
  this.updateResolver();
53
58
  }
54
- });
59
+ }));
60
+ return store;
55
61
  }
56
62
  _getResolver() {
57
63
  return super._getResolver();
@@ -63,7 +69,7 @@ let DynamicWorkbenchKeybindingService = class DynamicWorkbenchKeybindingService
63
69
  return super._dispatch(e, target);
64
70
  }
65
71
  getUserKeybindingItems() {
66
- return [...super.getUserKeybindingItems(), ...this.keybindingProviders.flatMap(provider => provider())];
72
+ return [...super.getUserKeybindingItems(), ...this.keybindingProviders.flatMap(provider => provider.provideKeybindings())];
67
73
  }
68
74
  };
69
75
  DynamicWorkbenchKeybindingService = __decorate([
@@ -1,5 +1,4 @@
1
1
  import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
2
- import { IWorkbenchLayoutService } from '../vscode/src/vs/workbench/services/layout/browser/layoutService.js';
3
2
  import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
4
3
  import { Event, Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
5
4
  import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
@@ -13,8 +12,9 @@ import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
13
12
  import { IEditorGroupsService } from '../vscode/src/vs/workbench/services/editor/common/editorGroupsService.js';
14
13
  import { IStatusbarService } from '../vscode/src/vs/workbench/services/statusbar/browser/statusbar.js';
15
14
  import { onRenderWorkbench } from '../lifecycle.js';
15
+ import { getWorkbenchContainer } from '../workbench.js';
16
16
  class LayoutService {
17
- constructor(container) {
17
+ constructor(container = getWorkbenchContainer()) {
18
18
  this.container = container;
19
19
  this.onDidChangeFullscreen = Event.None;
20
20
  this.onDidChangeZenMode = Event.None;
@@ -210,8 +210,6 @@ onRenderWorkbench((accessor) => {
210
210
  if (layoutService instanceof LayoutService) {
211
211
  layoutService.init(accessor);
212
212
  }
213
- });
214
- function getServiceOverride(container = document.body) {
215
213
  const platformClass = isWindows ? 'windows' : isLinux ? 'linux' : 'mac';
216
214
  const workbenchClasses = coalesce([
217
215
  'monaco-workbench',
@@ -219,12 +217,13 @@ function getServiceOverride(container = document.body) {
219
217
  'web',
220
218
  isChrome ? 'chromium' : isFirefox ? 'firefox' : isSafari ? 'safari' : undefined
221
219
  ]);
222
- container.classList.add(...workbenchClasses);
220
+ layoutService.container.classList.add(...workbenchClasses);
223
221
  document.body.classList.add(platformClass);
224
222
  document.body.classList.add('web');
223
+ });
224
+ function getServiceOverride(container) {
225
225
  return {
226
- [( ILayoutService.toString())]: new SyncDescriptor(LayoutService, [container], true),
227
- [( IWorkbenchLayoutService.toString())]: new SyncDescriptor(LayoutService, [container], true)
226
+ [( ILayoutService.toString())]: new SyncDescriptor(LayoutService, [container], true)
228
227
  };
229
228
  }
230
229
  export { LayoutService, getServiceOverride as default };
@@ -1,19 +1,21 @@
1
1
  import { __decorate, __param } from '../external/tslib/tslib.es6.js';
2
2
  import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
3
- import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
4
3
  import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
5
- import { ILoggerService, LogLevel } from 'monaco-editor/esm/vs/platform/log/common/log.js';
4
+ import { ILoggerService, getLogLevel } from 'monaco-editor/esm/vs/platform/log/common/log.js';
6
5
  import { FileLoggerService } from '../vscode/src/vs/platform/log/common/fileLog.js';
7
6
  import '../vscode/src/vs/workbench/contrib/output/browser/output.contribution.js';
7
+ import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
8
+ import { logsPath } from '../workbench.js';
8
9
  let _FileLoggerService = class _FileLoggerService extends FileLoggerService {
9
- constructor(logLevel, fileService) {
10
- super(logLevel, ( URI.from({ scheme: 'logs', path: '/' })), fileService);
10
+ constructor(logLevel, fileService, environmentService) {
11
+ super(logLevel ?? getLogLevel(environmentService), logsPath, fileService);
11
12
  }
12
13
  };
13
14
  _FileLoggerService = __decorate([
14
- ( __param(1, IFileService))
15
+ ( __param(1, IFileService)),
16
+ ( __param(2, IEnvironmentService))
15
17
  ], _FileLoggerService);
16
- function getServiceOverride(logLevel = LogLevel.Info) {
18
+ function getServiceOverride(logLevel) {
17
19
  return {
18
20
  [( ILoggerService.toString())]: new SyncDescriptor(_FileLoggerService, [logLevel], true)
19
21
  };
@@ -8,12 +8,12 @@ import { IWorkspaceContextService } from '../../vscode/src/vs/platform/workspace
8
8
  import { IUriIdentityService } from '../../vscode/src/vs/platform/uriIdentity/common/uriIdentity.js';
9
9
  import { ICodeEditor, IDiffEditor } from '../../vscode/src/vs/editor/browser/editorBrowser.js';
10
10
  import { IEditorOptions, IResourceEditorInput, ITextResourceEditorInput } from '../../vscode/src/vs/platform/editor/common/editor.js';
11
+ import { IHostService } from '../../vscode/src/vs/workbench/services/host/browser/host.js';
11
12
  import { IEditorGroupsService } from '../../vscode/src/vs/workbench/services/editor/common/editorGroupsService.js';
12
13
  import { EditorInput } from '../../vscode/src/vs/workbench/common/editor/editorInput.js';
13
14
  import { PreferredGroup } from '../../vscode/src/vs/workbench/services/editor/common/editorService.js';
14
15
  import { IEditorResolverService } from '../../vscode/src/vs/workbench/services/editor/common/editorResolverService.js';
15
16
  import { ITextEditorService } from '../../vscode/src/vs/workbench/services/textfile/common/textEditorService.js';
16
- import { IHostService } from '../../vscode/src/vs/workbench/services/host/browser/host.js';
17
17
  import { IWorkspaceTrustRequestService } from '../../vscode/src/vs/platform/workspace/common/workspaceTrust.js';
18
18
  import { EditorService } from '../../vscode/src/vs/workbench/services/editor/browser/editorService.js';
19
19
 
package/services.d.ts CHANGED
@@ -9,6 +9,7 @@ import { ServiceIdentifier, GetLeadingNonServiceArgs, ServicesAccessor } from '.
9
9
  export { IInstantiationService } from './vscode/src/vs/platform/instantiation/common/instantiation.js';
10
10
  export { IAction } from './vscode/src/vs/base/common/actions.js';
11
11
  import { IDisposable } from './vscode/src/vs/base/common/lifecycle.js';
12
+ import { IWorkbenchConstructionOptions } from './vscode/src/vs/workbench/browser/web.api.js';
12
13
  export { SyncDescriptor } from './vscode/src/vs/platform/instantiation/common/descriptors.js';
13
14
  export { ICommandService } from './vscode/src/vs/platform/commands/common/commands.js';
14
15
  export { INeverShowAgainOptions, INotification, INotificationActions, INotificationHandle, INotificationProgress, INotificationProgressProperties, INotificationProperties, INotificationService, IPromptChoice, IPromptChoiceWithMenu, IPromptOptions, IStatusMessageOptions, NeverShowAgainScope, NoOpNotification, NoOpProgress, NotificationMessage, NotificationPriority, NotificationsFilter } from './vscode/src/vs/platform/notification/common/notification.js';
@@ -73,7 +74,7 @@ export { ITitleService } from './vscode/src/vs/workbench/services/title/common/t
73
74
  export { IBannerService } from './vscode/src/vs/workbench/services/banner/browser/bannerService.js';
74
75
  export { IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService, IWorkspaceTrustUriInfo } from './vscode/src/vs/platform/workspace/common/workspaceTrust.js';
75
76
 
76
- declare function initialize(overrides: IEditorOverrideServices, container?: HTMLElement): Promise<void>;
77
+ declare function initialize(overrides: IEditorOverrideServices, container?: HTMLElement, configuration?: IWorkbenchConstructionOptions): Promise<void>;
77
78
  declare function waitServicesReady(): Promise<void>;
78
79
  declare function checkServicesReady(): void;
79
80
  declare function getService<T>(identifier: ServiceIdentifier<T>): Promise<T>;
@@ -84,4 +85,4 @@ declare function createInstanceSync<Ctor extends new (...args: any[]) => any, R
84
85
  */
85
86
  declare function withReadyServices(callback: (serviceAccessor: ServicesAccessor) => IDisposable): IDisposable;
86
87
 
87
- export { checkServicesReady, createInstance, createInstanceSync, getService, initialize, waitServicesReady, withReadyServices };
88
+ export { IWorkbenchConstructionOptions, checkServicesReady, createInstance, createInstanceSync, getService, initialize, waitServicesReady, withReadyServices };
package/services.js CHANGED
@@ -12,6 +12,7 @@ import getServiceOverride$2 from './service-override/extensions.js';
12
12
  import getServiceOverride$3 from './service-override/files.js';
13
13
  import getServiceOverride$4 from './service-override/quickaccess.js';
14
14
  import { startup, serviceInitializedBarrier, serviceInitializedEmitter } from './lifecycle.js';
15
+ import { initialize as initialize$1 } from './workbench.js';
15
16
  export { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
16
17
  export { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
17
18
  export { INotificationService, NeverShowAgainScope, NoOpNotification, NoOpProgress, NotificationPriority, NotificationsFilter } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
@@ -81,12 +82,13 @@ StandaloneServices.withServices(() => {
81
82
  servicesInitialized = true;
82
83
  return Disposable.None;
83
84
  });
84
- async function initialize(overrides, container) {
85
+ async function initialize(overrides, container = document.body, configuration = {}) {
85
86
  if (servicesInitialized) {
86
87
  throw new Error('The services are already initialized.');
87
88
  }
89
+ initialize$1(container, configuration);
88
90
  const instantiationService = StandaloneServices.initialize({
89
- ...getServiceOverride(container),
91
+ ...getServiceOverride(),
90
92
  ...getServiceOverride$1(),
91
93
  ...getServiceOverride$2(),
92
94
  ...getServiceOverride$3(),
@@ -3,10 +3,10 @@ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
3
3
  import { EditorPaneDescriptor } from '../../editor.js';
4
4
  import { EditorExtensions } from '../../../common/editor.js';
5
5
  import { ActiveEditorGroupLockedContext, MultipleEditorGroupsContext, EditorPinnedAndUnpinnedTabsContext, EditorGroupEditorsCountContext, ActiveEditorLastInGroupContext, EditorTabsVisibleContext, ActiveEditorAvailableEditorIdsContext, ActiveEditorPinnedContext, ActiveEditorStickyContext, ActiveEditorCanSplitInGroupContext, SideBySideEditorActiveContext, TextCompareEditorActiveContext, ActiveEditorDirtyContext } from '../../../common/contextkeys.js';
6
- import { SideBySideEditorInput } from '../../../common/editor/sideBySideEditorInput.js';
6
+ import { SideBySideEditorInput, SideBySideEditorInputSerializer } from '../../../common/editor/sideBySideEditorInput.js';
7
7
  import { TextResourceEditor } from './textResourceEditor.js';
8
8
  import { SideBySideEditor } from './sideBySideEditor.js';
9
- import { DiffEditorInput } from '../../../common/editor/diffEditorInput.js';
9
+ import { DiffEditorInput, DiffEditorInputSerializer } from '../../../common/editor/diffEditorInput.js';
10
10
  import { UntitledTextEditorInput } from '../../../services/untitled/common/untitledTextEditorInput.js';
11
11
  import { TextResourceEditorInput } from '../../../common/editor/textResourceEditorInput.js';
12
12
  import { TextDiffEditor } from './textDiffEditor.js';
@@ -28,7 +28,7 @@ import { Extensions as Extensions$1 } from 'monaco-editor/esm/vs/platform/quicki
28
28
  import { ActiveGroupEditorsByMostRecentlyUsedQuickAccess, AllEditorsByAppearanceQuickAccess, AllEditorsByMostRecentlyUsedQuickAccess } from './editorQuickAccess.js';
29
29
  import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
30
30
  import { registerIcon } from 'monaco-editor/esm/vs/platform/theme/common/iconRegistry.js';
31
- import { UntitledTextEditorWorkingCopyEditorHandler } from '../../../services/untitled/common/untitledTextEditorHandler.js';
31
+ import { UntitledTextEditorInputSerializer, UntitledTextEditorWorkingCopyEditorHandler } from '../../../services/untitled/common/untitledTextEditorHandler.js';
32
32
  import { DynamicEditorConfigurations } from './editorConfiguration.js';
33
33
  import { ToggleTabsVisibilityAction, ToggleSeparatePinnedTabsAction } from '../../actions/layoutActions.js';
34
34
  ( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(EditorPaneDescriptor.create(TextResourceEditor, TextResourceEditor.ID, ( localizeWithPath(
@@ -60,6 +60,9 @@ import { ToggleTabsVisibilityAction, ToggleSeparatePinnedTabsAction } from '../.
60
60
  ))), [
61
61
  ( new SyncDescriptor(SideBySideEditorInput))
62
62
  ]);
63
+ ( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(UntitledTextEditorInput.ID, UntitledTextEditorInputSerializer);
64
+ ( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(SideBySideEditorInput.ID, SideBySideEditorInputSerializer);
65
+ ( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(DiffEditorInput.ID, DiffEditorInputSerializer);
63
66
  ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(EditorAutoSave, 2 );
64
67
  ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(EditorStatus, 2 );
65
68
  ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(UntitledTextEditorWorkingCopyEditorHandler, 2 );
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
2
  import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
3
- import { SideBySideEditorInput } from './sideBySideEditorInput.js';
3
+ import { SideBySideEditorInput, AbstractSideBySideEditorInputSerializer } from './sideBySideEditorInput.js';
4
4
  import { BINARY_DIFF_EDITOR_ID, TEXT_DIFF_EDITOR_ID, isResourceDiffEditorInput } from '../editor.js';
5
5
  import { BaseTextEditorModel } from './textEditorModel.js';
6
6
  import { DiffEditorModel } from './diffEditorModel.js';
@@ -165,4 +165,9 @@ let DiffEditorInput = class DiffEditorInput extends SideBySideEditorInput {
165
165
  DiffEditorInput = DiffEditorInput_1 = ( __decorate([
166
166
  ( __param(5, IEditorService))
167
167
  ], DiffEditorInput));
168
- export { DiffEditorInput };
168
+ class DiffEditorInputSerializer extends AbstractSideBySideEditorInputSerializer {
169
+ createEditorInput(instantiationService, name, description, secondaryInput, primaryInput) {
170
+ return instantiationService.createInstance(DiffEditorInput, name, description, secondaryInput, primaryInput, undefined);
171
+ }
172
+ }
173
+ export { DiffEditorInput, DiffEditorInputSerializer };
@@ -1,7 +1,8 @@
1
1
  import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
2
  import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
3
3
  import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
4
- import { isResourceDiffEditorInput, isResourceSideBySideEditorInput, isResourceMergeEditorInput, isEditorInput, findViewStateForEditor, isResourceEditorInput, isDiffEditorInput } from '../editor.js';
4
+ import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
5
+ import { isResourceDiffEditorInput, isResourceSideBySideEditorInput, isResourceMergeEditorInput, isEditorInput, findViewStateForEditor, isResourceEditorInput, isDiffEditorInput, EditorExtensions } from '../editor.js';
5
6
  import { EditorInput } from './editorInput.js';
6
7
  import { IEditorService } from '../../services/editor/common/editorService.js';
7
8
  var SideBySideEditorInput_1;
@@ -231,4 +232,57 @@ let SideBySideEditorInput = class SideBySideEditorInput extends EditorInput {
231
232
  SideBySideEditorInput = SideBySideEditorInput_1 = ( __decorate([
232
233
  ( __param(4, IEditorService))
233
234
  ], SideBySideEditorInput));
234
- export { SideBySideEditorInput };
235
+ class AbstractSideBySideEditorInputSerializer {
236
+ canSerialize(editorInput) {
237
+ const input = editorInput;
238
+ if (input.primary && input.secondary) {
239
+ const [secondaryInputSerializer, primaryInputSerializer] = this.getSerializers(input.secondary.typeId, input.primary.typeId);
240
+ return !!(secondaryInputSerializer?.canSerialize(input.secondary) && primaryInputSerializer?.canSerialize(input.primary));
241
+ }
242
+ return false;
243
+ }
244
+ serialize(editorInput) {
245
+ const input = editorInput;
246
+ if (input.primary && input.secondary) {
247
+ const [secondaryInputSerializer, primaryInputSerializer] = this.getSerializers(input.secondary.typeId, input.primary.typeId);
248
+ if (primaryInputSerializer && secondaryInputSerializer) {
249
+ const primarySerialized = primaryInputSerializer.serialize(input.primary);
250
+ const secondarySerialized = secondaryInputSerializer.serialize(input.secondary);
251
+ if (primarySerialized && secondarySerialized) {
252
+ const serializedEditorInput = {
253
+ name: input.getPreferredName(),
254
+ description: input.getPreferredDescription(),
255
+ primarySerialized: primarySerialized,
256
+ secondarySerialized: secondarySerialized,
257
+ primaryTypeId: input.primary.typeId,
258
+ secondaryTypeId: input.secondary.typeId
259
+ };
260
+ return JSON.stringify(serializedEditorInput);
261
+ }
262
+ }
263
+ }
264
+ return undefined;
265
+ }
266
+ deserialize(instantiationService, serializedEditorInput) {
267
+ const deserialized = JSON.parse(serializedEditorInput);
268
+ const [secondaryInputSerializer, primaryInputSerializer] = this.getSerializers(deserialized.secondaryTypeId, deserialized.primaryTypeId);
269
+ if (primaryInputSerializer && secondaryInputSerializer) {
270
+ const primaryInput = primaryInputSerializer.deserialize(instantiationService, deserialized.primarySerialized);
271
+ const secondaryInput = secondaryInputSerializer.deserialize(instantiationService, deserialized.secondarySerialized);
272
+ if (primaryInput instanceof EditorInput && secondaryInput instanceof EditorInput) {
273
+ return this.createEditorInput(instantiationService, deserialized.name, deserialized.description, secondaryInput, primaryInput);
274
+ }
275
+ }
276
+ return undefined;
277
+ }
278
+ getSerializers(secondaryEditorInputTypeId, primaryEditorInputTypeId) {
279
+ const registry = ( Registry.as(EditorExtensions.EditorFactory));
280
+ return [registry.getEditorSerializer(secondaryEditorInputTypeId), registry.getEditorSerializer(primaryEditorInputTypeId)];
281
+ }
282
+ }
283
+ class SideBySideEditorInputSerializer extends AbstractSideBySideEditorInputSerializer {
284
+ createEditorInput(instantiationService, name, description, secondaryInput, primaryInput) {
285
+ return instantiationService.createInstance(SideBySideEditorInput, name, description, secondaryInput, primaryInput);
286
+ }
287
+ }
288
+ export { AbstractSideBySideEditorInputSerializer, SideBySideEditorInput, SideBySideEditorInputSerializer };
@@ -235,6 +235,22 @@ interface ITextDiffEditorPane extends IEditorPane {
235
235
  */
236
236
  interface IEditorControl extends ICompositeControl {
237
237
  }
238
+ interface IEditorSerializer {
239
+ /**
240
+ * Determines whether the given editor can be serialized by the serializer.
241
+ */
242
+ canSerialize(editor: EditorInput): boolean;
243
+ /**
244
+ * Returns a string representation of the provided editor that contains enough information
245
+ * to deserialize back to the original editor from the deserialize() method.
246
+ */
247
+ serialize(editor: EditorInput): string | undefined;
248
+ /**
249
+ * Returns an editor from the provided serialized form of the editor. This form matches
250
+ * the value returned from the serialize() method.
251
+ */
252
+ deserialize(instantiationService: IInstantiationService, serializedEditor: string): EditorInput | undefined;
253
+ }
238
254
  interface IUntitledTextResourceEditorInput extends IBaseTextResourceEditorInput {
239
255
  /**
240
256
  * Optional resource for the untitled editor. Depending on the value, the editor:
@@ -711,4 +727,4 @@ declare const enum EditorsOrder {
711
727
  SEQUENTIAL = 1
712
728
  }
713
729
 
714
- export { AbstractEditorInput, CloseDirection, EditorCloseContext, EditorInputCapabilities, type EditorInputWithOptions, type EditorInputWithOptionsAndGroup, type EditorInputWithPreferredResource, EditorPaneSelectionChangeReason, EditorPaneSelectionCompareResult, EditorsOrder, type GroupIdentifier, GroupModelChangeKind, type IActiveEditorChangeEvent, type IEditorCloseEvent, type IEditorControl, type IEditorDescriptor, type IEditorIdentifier, type IEditorMemento, type IEditorOpenContext, type IEditorPane, type IEditorPaneSelection, type IEditorPaneSelectionChangeEvent, type IEditorPartOptions, type IEditorPartOptionsChangeEvent, type IEditorWillMoveEvent, type IEditorWillOpenEvent, type IFileEditorInput, type IFindEditorOptions, type IMatchEditorOptions, type IMoveResult, type IResourceDiffEditorInput, type IResourceMergeEditorInput, type IResourceMergeEditorInputSide, type IResourceSideBySideEditorInput, type IRevertOptions, type ISaveOptions, type ITextDiffEditorPane, type IUntitledTextResourceEditorInput, type IUntypedEditorInput, type IUntypedFileEditorInput, type IVisibleEditorPane, type PreventPinnedEditorClose, SaveReason, type SaveSource, SideBySideEditor, Verbosity };
730
+ export { AbstractEditorInput, CloseDirection, EditorCloseContext, EditorInputCapabilities, type EditorInputWithOptions, type EditorInputWithOptionsAndGroup, type EditorInputWithPreferredResource, EditorPaneSelectionChangeReason, EditorPaneSelectionCompareResult, EditorsOrder, type GroupIdentifier, GroupModelChangeKind, type IActiveEditorChangeEvent, type IEditorCloseEvent, type IEditorControl, type IEditorDescriptor, type IEditorIdentifier, type IEditorMemento, type IEditorOpenContext, type IEditorPane, type IEditorPaneSelection, type IEditorPaneSelectionChangeEvent, type IEditorPartOptions, type IEditorPartOptionsChangeEvent, type IEditorSerializer, type IEditorWillMoveEvent, type IEditorWillOpenEvent, type IFileEditorInput, type IFindEditorOptions, type IMatchEditorOptions, type IMoveResult, type IResourceDiffEditorInput, type IResourceMergeEditorInput, type IResourceMergeEditorInputSide, type IResourceSideBySideEditorInput, type IRevertOptions, type ISaveOptions, type ITextDiffEditorPane, type IUntitledTextResourceEditorInput, type IUntypedEditorInput, type IUntypedFileEditorInput, type IVisibleEditorPane, type PreventPinnedEditorClose, SaveReason, type SaveSource, SideBySideEditor, Verbosity };
@@ -1,14 +1,65 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
2
  import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
3
3
  import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
4
5
  import { ITextEditorService } from '../../textfile/common/textEditorService.js';
5
- import { isEqual, toLocalResource } from 'monaco-editor/esm/vs/base/common/resources.js';
6
+ import { toLocalResource, isEqual } from 'monaco-editor/esm/vs/base/common/resources.js';
7
+ import { PLAINTEXT_LANGUAGE_ID } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
6
8
  import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
9
+ import { IFilesConfigurationService } from '../../filesConfiguration/common/filesConfigurationService.js';
7
10
  import { IPathService } from '../../path/common/pathService.js';
8
11
  import { UntitledTextEditorInput } from './untitledTextEditorInput.js';
9
12
  import { NO_TYPE_ID } from '../../workingCopy/common/workingCopy.js';
10
13
  import { IWorkingCopyEditorService } from '../../workingCopy/common/workingCopyEditorService.js';
11
14
  import { IUntitledTextEditorService } from './untitledTextEditorService.js';
15
+ let UntitledTextEditorInputSerializer = class UntitledTextEditorInputSerializer {
16
+ constructor(filesConfigurationService, environmentService, pathService) {
17
+ this.filesConfigurationService = filesConfigurationService;
18
+ this.environmentService = environmentService;
19
+ this.pathService = pathService;
20
+ }
21
+ canSerialize(editorInput) {
22
+ return this.filesConfigurationService.isHotExitEnabled && !editorInput.isDisposed();
23
+ }
24
+ serialize(editorInput) {
25
+ if (!this.filesConfigurationService.isHotExitEnabled || editorInput.isDisposed()) {
26
+ return undefined;
27
+ }
28
+ const untitledTextEditorInput = editorInput;
29
+ let resource = untitledTextEditorInput.resource;
30
+ if (untitledTextEditorInput.model.hasAssociatedFilePath) {
31
+ resource = toLocalResource(resource, this.environmentService.remoteAuthority, this.pathService.defaultUriScheme);
32
+ }
33
+ let languageId;
34
+ const languageIdCandidate = untitledTextEditorInput.getLanguageId();
35
+ if (languageIdCandidate !== PLAINTEXT_LANGUAGE_ID) {
36
+ languageId = languageIdCandidate;
37
+ }
38
+ else if (untitledTextEditorInput.model.hasLanguageSetExplicitly) {
39
+ languageId = languageIdCandidate;
40
+ }
41
+ const serialized = {
42
+ resourceJSON: resource.toJSON(),
43
+ modeId: languageId,
44
+ encoding: untitledTextEditorInput.getEncoding()
45
+ };
46
+ return JSON.stringify(serialized);
47
+ }
48
+ deserialize(instantiationService, serializedEditorInput) {
49
+ return instantiationService.invokeFunction(accessor => {
50
+ const deserialized = JSON.parse(serializedEditorInput);
51
+ const resource = URI.revive(deserialized.resourceJSON);
52
+ const languageId = deserialized.modeId;
53
+ const encoding = deserialized.encoding;
54
+ return accessor.get(ITextEditorService).createTextEditor({ resource, languageId, encoding, forceUntitled: true });
55
+ });
56
+ }
57
+ };
58
+ UntitledTextEditorInputSerializer = ( __decorate([
59
+ ( __param(0, IFilesConfigurationService)),
60
+ ( __param(1, IWorkbenchEnvironmentService)),
61
+ ( __param(2, IPathService))
62
+ ], UntitledTextEditorInputSerializer));
12
63
  let UntitledTextEditorWorkingCopyEditorHandler = class UntitledTextEditorWorkingCopyEditorHandler extends Disposable {
13
64
  constructor(workingCopyEditorService, environmentService, pathService, textEditorService, untitledTextEditorService) {
14
65
  super();
@@ -45,4 +96,4 @@ UntitledTextEditorWorkingCopyEditorHandler = ( __decorate([
45
96
  ( __param(3, ITextEditorService)),
46
97
  ( __param(4, IUntitledTextEditorService))
47
98
  ], UntitledTextEditorWorkingCopyEditorHandler));
48
- export { UntitledTextEditorWorkingCopyEditorHandler };
99
+ export { UntitledTextEditorInputSerializer, UntitledTextEditorWorkingCopyEditorHandler };
@@ -5,7 +5,13 @@ function getWorkspaceIdentifier(workspaceUri) {
5
5
  configPath: workspaceUri
6
6
  };
7
7
  }
8
+ function getSingleFolderWorkspaceIdentifier(folderUri) {
9
+ return {
10
+ id: getWorkspaceId(folderUri),
11
+ uri: folderUri
12
+ };
13
+ }
8
14
  function getWorkspaceId(uri) {
9
15
  return ( hash(( uri.toString())).toString(16));
10
16
  }
11
- export { getWorkspaceIdentifier };
17
+ export { getSingleFolderWorkspaceIdentifier, getWorkspaceIdentifier };