@theia/workspace 1.67.0-next.56 → 1.67.0-next.59

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.
Files changed (150) hide show
  1. package/lib/browser/canonical-uri-service.d.ts +12 -0
  2. package/lib/browser/canonical-uri-service.d.ts.map +1 -0
  3. package/lib/browser/canonical-uri-service.js +55 -0
  4. package/lib/browser/canonical-uri-service.js.map +1 -0
  5. package/lib/browser/diff-service.d.ts +11 -0
  6. package/lib/browser/diff-service.d.ts.map +1 -0
  7. package/lib/browser/diff-service.js +69 -0
  8. package/lib/browser/diff-service.js.map +1 -0
  9. package/lib/browser/index.d.ts +7 -0
  10. package/lib/browser/index.d.ts.map +1 -0
  11. package/lib/browser/index.js +25 -0
  12. package/lib/browser/index.js.map +1 -0
  13. package/lib/browser/quick-open-workspace.d.ts +18 -0
  14. package/lib/browser/quick-open-workspace.d.ts.map +1 -0
  15. package/lib/browser/quick-open-workspace.js +112 -0
  16. package/lib/browser/quick-open-workspace.js.map +1 -0
  17. package/lib/browser/untitled-workspace-exit-dialog.d.ts +20 -0
  18. package/lib/browser/untitled-workspace-exit-dialog.d.ts.map +1 -0
  19. package/lib/browser/untitled-workspace-exit-dialog.js +64 -0
  20. package/lib/browser/untitled-workspace-exit-dialog.js.map +1 -0
  21. package/lib/browser/workspace-breadcrumbs-contribution.d.ts +11 -0
  22. package/lib/browser/workspace-breadcrumbs-contribution.d.ts.map +1 -0
  23. package/lib/browser/workspace-breadcrumbs-contribution.js +59 -0
  24. package/lib/browser/workspace-breadcrumbs-contribution.js.map +1 -0
  25. package/lib/browser/workspace-commands.d.ts +116 -0
  26. package/lib/browser/workspace-commands.d.ts.map +1 -0
  27. package/lib/browser/workspace-commands.js +568 -0
  28. package/lib/browser/workspace-commands.js.map +1 -0
  29. package/lib/browser/workspace-commands.spec.d.ts +2 -0
  30. package/lib/browser/workspace-commands.spec.d.ts.map +1 -0
  31. package/lib/browser/workspace-commands.spec.js +128 -0
  32. package/lib/browser/workspace-commands.spec.js.map +1 -0
  33. package/lib/browser/workspace-compare-handler.d.ts +27 -0
  34. package/lib/browser/workspace-compare-handler.d.ts.map +1 -0
  35. package/lib/browser/workspace-compare-handler.js +59 -0
  36. package/lib/browser/workspace-compare-handler.js.map +1 -0
  37. package/lib/browser/workspace-delete-handler.d.ts +76 -0
  38. package/lib/browser/workspace-delete-handler.d.ts.map +1 -0
  39. package/lib/browser/workspace-delete-handler.js +207 -0
  40. package/lib/browser/workspace-delete-handler.js.map +1 -0
  41. package/lib/browser/workspace-duplicate-handler.d.ts +31 -0
  42. package/lib/browser/workspace-duplicate-handler.d.ts.map +1 -0
  43. package/lib/browser/workspace-duplicate-handler.js +79 -0
  44. package/lib/browser/workspace-duplicate-handler.js.map +1 -0
  45. package/lib/browser/workspace-frontend-contribution.d.ts +111 -0
  46. package/lib/browser/workspace-frontend-contribution.d.ts.map +1 -0
  47. package/lib/browser/workspace-frontend-contribution.js +538 -0
  48. package/lib/browser/workspace-frontend-contribution.js.map +1 -0
  49. package/lib/browser/workspace-frontend-module.d.ts +4 -0
  50. package/lib/browser/workspace-frontend-module.d.ts.map +1 -0
  51. package/lib/browser/workspace-frontend-module.js +93 -0
  52. package/lib/browser/workspace-frontend-module.js.map +1 -0
  53. package/lib/browser/workspace-input-dialog.d.ts +20 -0
  54. package/lib/browser/workspace-input-dialog.d.ts.map +1 -0
  55. package/lib/browser/workspace-input-dialog.js +64 -0
  56. package/lib/browser/workspace-input-dialog.js.map +1 -0
  57. package/lib/browser/workspace-schema-updater.d.ts +34 -0
  58. package/lib/browser/workspace-schema-updater.d.ts.map +1 -0
  59. package/lib/browser/workspace-schema-updater.js +147 -0
  60. package/lib/browser/workspace-schema-updater.js.map +1 -0
  61. package/lib/browser/workspace-service.d.ts +201 -0
  62. package/lib/browser/workspace-service.d.ts.map +1 -0
  63. package/lib/browser/workspace-service.js +758 -0
  64. package/lib/browser/workspace-service.js.map +1 -0
  65. package/lib/browser/workspace-storage-service.d.ts +16 -0
  66. package/lib/browser/workspace-storage-service.d.ts.map +1 -0
  67. package/lib/browser/workspace-storage-service.js +73 -0
  68. package/lib/browser/workspace-storage-service.js.map +1 -0
  69. package/lib/browser/workspace-trust-service.d.ts +30 -0
  70. package/lib/browser/workspace-trust-service.d.ts.map +1 -0
  71. package/lib/browser/workspace-trust-service.js +153 -0
  72. package/lib/browser/workspace-trust-service.js.map +1 -0
  73. package/lib/browser/workspace-uri-contribution.d.ts +21 -0
  74. package/lib/browser/workspace-uri-contribution.d.ts.map +1 -0
  75. package/lib/browser/workspace-uri-contribution.js +106 -0
  76. package/lib/browser/workspace-uri-contribution.js.map +1 -0
  77. package/lib/browser/workspace-uri-contribution.spec.d.ts +2 -0
  78. package/lib/browser/workspace-uri-contribution.spec.d.ts.map +1 -0
  79. package/lib/browser/workspace-uri-contribution.spec.js +170 -0
  80. package/lib/browser/workspace-uri-contribution.spec.js.map +1 -0
  81. package/lib/browser/workspace-user-working-directory-provider.d.ts +13 -0
  82. package/lib/browser/workspace-user-working-directory-provider.d.ts.map +1 -0
  83. package/lib/browser/workspace-user-working-directory-provider.js +55 -0
  84. package/lib/browser/workspace-user-working-directory-provider.js.map +1 -0
  85. package/lib/browser/workspace-utils.d.ts +16 -0
  86. package/lib/browser/workspace-utils.d.ts.map +1 -0
  87. package/lib/browser/workspace-utils.js +47 -0
  88. package/lib/browser/workspace-utils.js.map +1 -0
  89. package/lib/browser/workspace-variable-contribution.d.ts +24 -0
  90. package/lib/browser/workspace-variable-contribution.d.ts.map +1 -0
  91. package/lib/browser/workspace-variable-contribution.js +231 -0
  92. package/lib/browser/workspace-variable-contribution.js.map +1 -0
  93. package/lib/browser/workspace-window-title-updater.d.ts +8 -0
  94. package/lib/browser/workspace-window-title-updater.d.ts.map +1 -0
  95. package/lib/browser/workspace-window-title-updater.js +50 -0
  96. package/lib/browser/workspace-window-title-updater.js.map +1 -0
  97. package/lib/browser-only/browser-only-workspace-server.d.ts +13 -0
  98. package/lib/browser-only/browser-only-workspace-server.d.ts.map +1 -0
  99. package/lib/browser-only/browser-only-workspace-server.js +73 -0
  100. package/lib/browser-only/browser-only-workspace-server.js.map +1 -0
  101. package/lib/browser-only/workspace-frontend-only-module.d.ts +4 -0
  102. package/lib/browser-only/workspace-frontend-only-module.d.ts.map +1 -0
  103. package/lib/browser-only/workspace-frontend-only-module.js +30 -0
  104. package/lib/browser-only/workspace-frontend-only-module.js.map +1 -0
  105. package/lib/common/index.d.ts +5 -0
  106. package/lib/common/index.d.ts.map +1 -0
  107. package/lib/common/index.js +23 -0
  108. package/lib/common/index.js.map +1 -0
  109. package/lib/common/test/mock-workspace-server.d.ts +8 -0
  110. package/lib/common/test/mock-workspace-server.d.ts.map +1 -0
  111. package/lib/common/test/mock-workspace-server.js +31 -0
  112. package/lib/common/test/mock-workspace-server.js.map +1 -0
  113. package/lib/common/untitled-workspace-service.d.ts +9 -0
  114. package/lib/common/untitled-workspace-service.d.ts.map +1 -0
  115. package/lib/common/untitled-workspace-service.js +53 -0
  116. package/lib/common/untitled-workspace-service.js.map +1 -0
  117. package/lib/common/workspace-file-service.d.ts +27 -0
  118. package/lib/common/workspace-file-service.d.ts.map +1 -0
  119. package/lib/common/workspace-file-service.js +67 -0
  120. package/lib/common/workspace-file-service.js.map +1 -0
  121. package/lib/common/workspace-preferences.d.ts +12 -0
  122. package/lib/common/workspace-preferences.d.ts.map +1 -0
  123. package/lib/common/workspace-preferences.js +46 -0
  124. package/lib/common/workspace-preferences.js.map +1 -0
  125. package/lib/common/workspace-protocol.d.ts +27 -0
  126. package/lib/common/workspace-protocol.d.ts.map +1 -0
  127. package/lib/common/workspace-protocol.js +24 -0
  128. package/lib/common/workspace-protocol.js.map +1 -0
  129. package/lib/common/workspace-trust-preferences.d.ts +22 -0
  130. package/lib/common/workspace-trust-preferences.d.ts.map +1 -0
  131. package/lib/common/workspace-trust-preferences.js +66 -0
  132. package/lib/common/workspace-trust-preferences.js.map +1 -0
  133. package/lib/node/default-workspace-server.d.ts +78 -0
  134. package/lib/node/default-workspace-server.d.ts.map +1 -0
  135. package/lib/node/default-workspace-server.js +265 -0
  136. package/lib/node/default-workspace-server.js.map +1 -0
  137. package/lib/node/default-workspace-server.spec.d.ts +2 -0
  138. package/lib/node/default-workspace-server.spec.d.ts.map +1 -0
  139. package/lib/node/default-workspace-server.spec.js +96 -0
  140. package/lib/node/default-workspace-server.spec.js.map +1 -0
  141. package/lib/node/index.d.ts +3 -0
  142. package/lib/node/index.d.ts.map +1 -0
  143. package/lib/node/index.js +21 -0
  144. package/lib/node/index.js.map +1 -0
  145. package/lib/node/workspace-backend-module.d.ts +4 -0
  146. package/lib/node/workspace-backend-module.d.ts.map +1 -0
  147. package/lib/node/workspace-backend-module.js +40 -0
  148. package/lib/node/workspace-backend-module.js.map +1 -0
  149. package/package.json +5 -5
  150. package/src/browser/workspace-service.ts +5 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-duplicate-handler.js","sourceRoot":"","sources":["../../src/browser/workspace-duplicate-handler.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAGhF,4DAAkE;AAClE,uDAAmD;AACnD,2DAAuD;AAEvD,oFAAgF;AAChF,6EAAyE;AAGlE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAWlC;;;;;OAKG;IACH,SAAS,CAAC,IAAW;QACjB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAW;QACjB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,IAAW;QACrB,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE;YACnC,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC1D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC3D,MAAM,MAAM,GAAG,kCAAe,CAAC,yBAAyB,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBAC1G,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC7C,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,CAAC;QACL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CAEJ,CAAA;AAjDY,8DAAyB;AAGf;IADlB,IAAA,kBAAM,EAAC,0BAAW,CAAC;sCACY,0BAAW;8DAAC;AAGzB;IADlB,IAAA,kBAAM,EAAC,gCAAc,CAAC;sCACY,gCAAc;iEAAC;AAG/B;IADlB,IAAA,kBAAM,EAAC,oCAAgB,CAAC;sCACY,oCAAgB;mEAAC;oCAT7C,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAiDrC"}
@@ -0,0 +1,111 @@
1
+ import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService, MaybeArray } from '@theia/core/lib/common';
2
+ import { OpenerService, KeybindingRegistry, KeybindingContribution, FrontendApplicationContribution, OnWillStopAction, Navigatable, SaveableSource, Widget } from '@theia/core/lib/browser';
3
+ import { FileDialogService, FileDialogTreeFilters } from '@theia/filesystem/lib/browser';
4
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
5
+ import { WorkspaceService } from './workspace-service';
6
+ import { WorkspaceFileService } from '../common';
7
+ import { QuickOpenWorkspace } from './quick-open-workspace';
8
+ import URI from '@theia/core/lib/common/uri';
9
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
10
+ import { EncodingRegistry } from '@theia/core/lib/browser/encoding-registry';
11
+ import { DisposableCollection } from '@theia/core/lib/common/disposable';
12
+ import { PreferenceConfigurations } from '@theia/core/lib/common/preferences/preference-configurations';
13
+ import { FileStat } from '@theia/filesystem/lib/common/files';
14
+ import { FilesystemSaveableService } from '@theia/filesystem/lib/browser/filesystem-saveable-service';
15
+ export declare enum WorkspaceStates {
16
+ /**
17
+ * The state is `empty` when no workspace is opened.
18
+ */
19
+ empty = "empty",
20
+ /**
21
+ * The state is `workspace` when a workspace is opened.
22
+ */
23
+ workspace = "workspace",
24
+ /**
25
+ * The state is `folder` when a folder is opened. (1 folder)
26
+ */
27
+ folder = "folder"
28
+ }
29
+ export type WorkspaceState = keyof typeof WorkspaceStates;
30
+ export type WorkbenchState = keyof typeof WorkspaceStates;
31
+ /** Create the workspace section after open {@link CommonMenus.FILE_OPEN}. */
32
+ export declare const FILE_WORKSPACE: string[];
33
+ export declare class WorkspaceFrontendContribution implements CommandContribution, KeybindingContribution, MenuContribution, FrontendApplicationContribution {
34
+ protected readonly messageService: MessageService;
35
+ protected readonly fileService: FileService;
36
+ protected readonly openerService: OpenerService;
37
+ protected readonly workspaceService: WorkspaceService;
38
+ protected readonly quickOpenWorkspace: QuickOpenWorkspace;
39
+ protected readonly fileDialogService: FileDialogService;
40
+ protected readonly contextKeyService: ContextKeyService;
41
+ protected readonly encodingRegistry: EncodingRegistry;
42
+ protected readonly preferenceConfigurations: PreferenceConfigurations;
43
+ protected readonly saveService: FilesystemSaveableService;
44
+ protected readonly workspaceFileService: WorkspaceFileService;
45
+ configure(): void;
46
+ protected readonly toDisposeOnUpdateEncodingOverrides: DisposableCollection;
47
+ protected updateEncodingOverrides(): void;
48
+ protected updateStyles(): void;
49
+ registerCommands(commands: CommandRegistry): void;
50
+ registerMenus(menus: MenuModelRegistry): void;
51
+ registerKeybindings(keybindings: KeybindingRegistry): void;
52
+ /**
53
+ * This is the generic `Open` method. Opens files and directories too. Resolves to the opened URI.
54
+ * Except when you are on either Windows or Linux `AND` running in electron. If so, it opens a file.
55
+ */
56
+ protected doOpen(): Promise<URI[] | undefined>;
57
+ /**
58
+ * Opens a set of files after prompting the `Open File` dialog. Resolves to `undefined`, if
59
+ * - the workspace root is not set,
60
+ * - the file to open does not exist, or
61
+ * - it was not a file, but a directory.
62
+ *
63
+ * Otherwise, resolves to the set of URIs of the files.
64
+ */
65
+ protected doOpenFile(): Promise<URI[] | undefined>;
66
+ /**
67
+ * Opens one or more folders after prompting the `Open Folder` dialog. Resolves to `undefined`, if
68
+ * - the user's selection is empty or contains only files.
69
+ * - the new workspace is equal to the old workspace.
70
+ *
71
+ * Otherwise, resolves to the URI of the new workspace:
72
+ * - a single folder if a single folder was selected.
73
+ * - a new, untitled workspace file if multiple folders were selected.
74
+ */
75
+ protected doOpenFolder(): Promise<URI | undefined>;
76
+ protected getOpenableWorkspaceUri(uris: MaybeArray<URI>): Promise<URI | undefined>;
77
+ protected createMultiRootWorkspace(roots: FileStat[]): Promise<URI>;
78
+ /**
79
+ * Opens a workspace after raising the `Open Workspace` dialog. Resolves to the URI of the recently opened workspace,
80
+ * if it was successful. Otherwise, resolves to `undefined`.
81
+ */
82
+ protected doOpenWorkspace(): Promise<URI | undefined>;
83
+ protected closeWorkspace(): Promise<void>;
84
+ /**
85
+ * @returns whether the file was successfully saved.
86
+ */
87
+ protected saveWorkspaceAs(): Promise<boolean>;
88
+ canBeSavedAs(widget: Widget | undefined): widget is Widget & SaveableSource & Navigatable;
89
+ saveAs(widget: Widget & SaveableSource & Navigatable): Promise<void>;
90
+ protected updateWorkspaceStateKey(): WorkspaceState;
91
+ protected updateWorkbenchStateKey(): WorkbenchState;
92
+ protected doUpdateState(): WorkspaceState | WorkbenchState;
93
+ protected getWorkspaceDialogFileFilters(): FileDialogTreeFilters;
94
+ private isElectron;
95
+ /**
96
+ * Get the current workspace URI.
97
+ *
98
+ * @returns the current workspace URI.
99
+ */
100
+ private getCurrentWorkspaceUri;
101
+ onWillStop(): OnWillStopAction<boolean> | undefined;
102
+ }
103
+ export declare namespace WorkspaceFrontendContribution {
104
+ /**
105
+ * File filter for all Theia and VS Code workspace file types.
106
+ *
107
+ * @deprecated Since 1.39.0 Use `WorkspaceFrontendContribution#getWorkspaceDialogFileFilters` instead.
108
+ */
109
+ const DEFAULT_FILE_FILTER: FileDialogTreeFilters;
110
+ }
111
+ //# sourceMappingURL=workspace-frontend-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-frontend-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/workspace-frontend-contribution.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,538 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.WorkspaceFrontendContribution = exports.FILE_WORKSPACE = exports.WorkspaceStates = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const inversify_1 = require("@theia/core/shared/inversify");
21
+ const common_1 = require("@theia/core/lib/common");
22
+ const core_1 = require("@theia/core");
23
+ const browser_1 = require("@theia/core/lib/browser");
24
+ const browser_2 = require("@theia/filesystem/lib/browser");
25
+ const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
26
+ const workspace_service_1 = require("./workspace-service");
27
+ const common_2 = require("../common");
28
+ const workspace_commands_1 = require("./workspace-commands");
29
+ const quick_open_workspace_1 = require("./quick-open-workspace");
30
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
31
+ const encoding_registry_1 = require("@theia/core/lib/browser/encoding-registry");
32
+ const encodings_1 = require("@theia/core/lib/common/encodings");
33
+ const disposable_1 = require("@theia/core/lib/common/disposable");
34
+ const preference_configurations_1 = require("@theia/core/lib/common/preferences/preference-configurations");
35
+ const nls_1 = require("@theia/core/lib/common/nls");
36
+ const buffer_1 = require("@theia/core/lib/common/buffer");
37
+ const untitled_workspace_exit_dialog_1 = require("./untitled-workspace-exit-dialog");
38
+ const filesystem_saveable_service_1 = require("@theia/filesystem/lib/browser/filesystem-saveable-service");
39
+ const frontend_application_state_1 = require("@theia/core/lib/common/frontend-application-state");
40
+ var WorkspaceStates;
41
+ (function (WorkspaceStates) {
42
+ /**
43
+ * The state is `empty` when no workspace is opened.
44
+ */
45
+ WorkspaceStates["empty"] = "empty";
46
+ /**
47
+ * The state is `workspace` when a workspace is opened.
48
+ */
49
+ WorkspaceStates["workspace"] = "workspace";
50
+ /**
51
+ * The state is `folder` when a folder is opened. (1 folder)
52
+ */
53
+ WorkspaceStates["folder"] = "folder";
54
+ })(WorkspaceStates || (exports.WorkspaceStates = WorkspaceStates = {}));
55
+ ;
56
+ /** Create the workspace section after open {@link CommonMenus.FILE_OPEN}. */
57
+ exports.FILE_WORKSPACE = [...browser_1.CommonMenus.FILE, '2_workspace'];
58
+ let WorkspaceFrontendContribution = class WorkspaceFrontendContribution {
59
+ constructor() {
60
+ this.toDisposeOnUpdateEncodingOverrides = new disposable_1.DisposableCollection();
61
+ }
62
+ configure() {
63
+ const workspaceExtensions = this.workspaceFileService.getWorkspaceFileExtensions();
64
+ for (const extension of workspaceExtensions) {
65
+ this.encodingRegistry.registerOverride({ encoding: encodings_1.UTF8, extension });
66
+ }
67
+ this.updateEncodingOverrides();
68
+ const workspaceFolderCountKey = this.contextKeyService.createKey('workspaceFolderCount', 0);
69
+ const updateWorkspaceFolderCountKey = () => workspaceFolderCountKey.set(this.workspaceService.tryGetRoots().length);
70
+ updateWorkspaceFolderCountKey();
71
+ const workspaceStateKey = this.contextKeyService.createKey('workspaceState', 'empty');
72
+ const updateWorkspaceStateKey = () => workspaceStateKey.set(this.updateWorkspaceStateKey());
73
+ updateWorkspaceStateKey();
74
+ const workbenchStateKey = this.contextKeyService.createKey('workbenchState', 'empty');
75
+ const updateWorkbenchStateKey = () => workbenchStateKey.set(this.updateWorkbenchStateKey());
76
+ updateWorkbenchStateKey();
77
+ this.updateStyles();
78
+ this.workspaceService.onWorkspaceChanged(() => {
79
+ this.updateEncodingOverrides();
80
+ updateWorkspaceFolderCountKey();
81
+ updateWorkspaceStateKey();
82
+ updateWorkbenchStateKey();
83
+ this.updateStyles();
84
+ });
85
+ }
86
+ updateEncodingOverrides() {
87
+ this.toDisposeOnUpdateEncodingOverrides.dispose();
88
+ for (const root of this.workspaceService.tryGetRoots()) {
89
+ for (const configPath of this.preferenceConfigurations.getPaths()) {
90
+ const parent = root.resource.resolve(configPath);
91
+ this.toDisposeOnUpdateEncodingOverrides.push(this.encodingRegistry.registerOverride({ encoding: encodings_1.UTF8, parent }));
92
+ }
93
+ }
94
+ }
95
+ updateStyles() {
96
+ document.body.classList.remove('theia-no-open-workspace');
97
+ // Display the 'no workspace opened' theme color when no folders are opened (single-root).
98
+ if (!this.workspaceService.isMultiRootWorkspaceOpened &&
99
+ !this.workspaceService.tryGetRoots().length) {
100
+ document.body.classList.add('theia-no-open-workspace');
101
+ }
102
+ }
103
+ registerCommands(commands) {
104
+ // Not visible/enabled on Windows/Linux in electron.
105
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.OPEN, {
106
+ isEnabled: () => core_1.isOSX || !this.isElectron(),
107
+ isVisible: () => core_1.isOSX || !this.isElectron(),
108
+ execute: () => this.doOpen()
109
+ });
110
+ // Visible/enabled only on Windows/Linux in electron.
111
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.OPEN_FILE, {
112
+ isEnabled: () => true,
113
+ execute: () => this.doOpenFile()
114
+ });
115
+ // Visible/enabled only on Windows/Linux in electron.
116
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.OPEN_FOLDER, {
117
+ isEnabled: () => true,
118
+ execute: () => this.doOpenFolder()
119
+ });
120
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.OPEN_WORKSPACE, {
121
+ isEnabled: () => true,
122
+ execute: () => this.doOpenWorkspace()
123
+ });
124
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.CLOSE, {
125
+ isEnabled: () => this.workspaceService.opened,
126
+ execute: () => this.closeWorkspace()
127
+ });
128
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.OPEN_RECENT_WORKSPACE, {
129
+ execute: () => this.quickOpenWorkspace.select()
130
+ });
131
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.SAVE_WORKSPACE_AS, {
132
+ isVisible: () => this.workspaceService.opened,
133
+ isEnabled: () => this.workspaceService.opened,
134
+ execute: () => this.saveWorkspaceAs()
135
+ });
136
+ commands.registerCommand(workspace_commands_1.WorkspaceCommands.OPEN_WORKSPACE_FILE, {
137
+ isEnabled: () => this.workspaceService.saved,
138
+ execute: () => {
139
+ if (this.workspaceService.saved && this.workspaceService.workspace) {
140
+ (0, browser_1.open)(this.openerService, this.workspaceService.workspace.resource);
141
+ }
142
+ }
143
+ });
144
+ }
145
+ registerMenus(menus) {
146
+ if (core_1.isOSX || !this.isElectron()) {
147
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_OPEN, {
148
+ commandId: workspace_commands_1.WorkspaceCommands.OPEN.id,
149
+ order: 'a00'
150
+ });
151
+ }
152
+ if (!core_1.isOSX && this.isElectron()) {
153
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_OPEN, {
154
+ commandId: workspace_commands_1.WorkspaceCommands.OPEN_FILE.id,
155
+ label: `${workspace_commands_1.WorkspaceCommands.OPEN_FILE.dialogLabel}...`,
156
+ order: 'a01'
157
+ });
158
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_OPEN, {
159
+ commandId: workspace_commands_1.WorkspaceCommands.OPEN_FOLDER.id,
160
+ label: `${workspace_commands_1.WorkspaceCommands.OPEN_FOLDER.dialogLabel}...`,
161
+ order: 'a02'
162
+ });
163
+ }
164
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_OPEN, {
165
+ commandId: workspace_commands_1.WorkspaceCommands.OPEN_WORKSPACE.id,
166
+ order: 'a10'
167
+ });
168
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_OPEN, {
169
+ commandId: workspace_commands_1.WorkspaceCommands.OPEN_RECENT_WORKSPACE.id,
170
+ order: 'a20'
171
+ });
172
+ menus.registerMenuAction(exports.FILE_WORKSPACE, {
173
+ commandId: workspace_commands_1.WorkspaceCommands.ADD_FOLDER.id,
174
+ order: 'a10'
175
+ });
176
+ menus.registerMenuAction(exports.FILE_WORKSPACE, {
177
+ commandId: workspace_commands_1.WorkspaceCommands.SAVE_WORKSPACE_AS.id,
178
+ order: 'a20'
179
+ });
180
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_CLOSE, {
181
+ commandId: workspace_commands_1.WorkspaceCommands.CLOSE.id
182
+ });
183
+ menus.registerMenuAction(browser_1.CommonMenus.FILE_SAVE, {
184
+ commandId: workspace_commands_1.WorkspaceCommands.SAVE_AS.id,
185
+ });
186
+ menus.registerMenuAction(browser_1.SHELL_TABBAR_CONTEXT_COPY, {
187
+ commandId: workspace_commands_1.WorkspaceCommands.COPY_RELATIVE_FILE_PATH.id,
188
+ label: workspace_commands_1.WorkspaceCommands.COPY_RELATIVE_FILE_PATH.label,
189
+ });
190
+ }
191
+ registerKeybindings(keybindings) {
192
+ keybindings.registerKeybinding({
193
+ command: core_1.isOSX || !this.isElectron() ? workspace_commands_1.WorkspaceCommands.OPEN.id : workspace_commands_1.WorkspaceCommands.OPEN_FILE.id,
194
+ keybinding: this.isElectron() ? 'ctrlcmd+o' : 'ctrlcmd+alt+o',
195
+ });
196
+ if (!core_1.isOSX && this.isElectron()) {
197
+ keybindings.registerKeybinding({
198
+ command: workspace_commands_1.WorkspaceCommands.OPEN_FOLDER.id,
199
+ keybinding: 'ctrl+k ctrl+o',
200
+ });
201
+ }
202
+ keybindings.registerKeybinding({
203
+ command: workspace_commands_1.WorkspaceCommands.OPEN_WORKSPACE.id,
204
+ keybinding: 'ctrlcmd+alt+w',
205
+ });
206
+ keybindings.registerKeybinding({
207
+ command: workspace_commands_1.WorkspaceCommands.OPEN_RECENT_WORKSPACE.id,
208
+ keybinding: 'ctrlcmd+alt+r',
209
+ });
210
+ keybindings.registerKeybinding({
211
+ command: workspace_commands_1.WorkspaceCommands.SAVE_AS.id,
212
+ keybinding: 'ctrlcmd+shift+s',
213
+ });
214
+ keybindings.registerKeybinding({
215
+ command: workspace_commands_1.WorkspaceCommands.COPY_RELATIVE_FILE_PATH.id,
216
+ keybinding: common_1.isWindows ? 'ctrl+k ctrl+shift+c' : 'ctrlcmd+shift+alt+c',
217
+ when: '!editorFocus'
218
+ });
219
+ }
220
+ /**
221
+ * This is the generic `Open` method. Opens files and directories too. Resolves to the opened URI.
222
+ * Except when you are on either Windows or Linux `AND` running in electron. If so, it opens a file.
223
+ */
224
+ async doOpen() {
225
+ var _a;
226
+ if (!core_1.isOSX && this.isElectron()) {
227
+ return this.doOpenFile();
228
+ }
229
+ const [rootStat] = await this.workspaceService.roots;
230
+ let selectedUris = await this.fileDialogService.showOpenDialog({
231
+ title: workspace_commands_1.WorkspaceCommands.OPEN.dialogLabel,
232
+ canSelectFolders: true,
233
+ canSelectFiles: true,
234
+ canSelectMany: true
235
+ }, rootStat);
236
+ if (selectedUris) {
237
+ if (!Array.isArray(selectedUris)) {
238
+ selectedUris = [selectedUris];
239
+ }
240
+ const folders = [];
241
+ // Only open files then open all folders in a new workspace, as done with Electron see doOpenFolder.
242
+ for (const uri of selectedUris) {
243
+ const destination = await this.fileService.resolve(uri);
244
+ if (destination.isDirectory) {
245
+ if (((_a = this.getCurrentWorkspaceUri()) === null || _a === void 0 ? void 0 : _a.toString()) !== uri.toString()) {
246
+ folders.push(uri);
247
+ }
248
+ }
249
+ else {
250
+ await (0, browser_1.open)(this.openerService, uri);
251
+ }
252
+ }
253
+ if (folders.length > 0) {
254
+ const openableURI = await this.getOpenableWorkspaceUri(folders);
255
+ if (openableURI && (!this.workspaceService.workspace || !openableURI.isEqual(this.workspaceService.workspace.resource))) {
256
+ this.workspaceService.open(openableURI);
257
+ }
258
+ }
259
+ return selectedUris;
260
+ }
261
+ return undefined;
262
+ }
263
+ /**
264
+ * Opens a set of files after prompting the `Open File` dialog. Resolves to `undefined`, if
265
+ * - the workspace root is not set,
266
+ * - the file to open does not exist, or
267
+ * - it was not a file, but a directory.
268
+ *
269
+ * Otherwise, resolves to the set of URIs of the files.
270
+ */
271
+ async doOpenFile() {
272
+ const props = {
273
+ title: workspace_commands_1.WorkspaceCommands.OPEN_FILE.dialogLabel,
274
+ canSelectFolders: false,
275
+ canSelectFiles: true,
276
+ canSelectMany: true
277
+ };
278
+ const [rootStat] = await this.workspaceService.roots;
279
+ let selectedFilesUris = await this.fileDialogService.showOpenDialog(props, rootStat);
280
+ if (selectedFilesUris) {
281
+ if (!Array.isArray(selectedFilesUris)) {
282
+ selectedFilesUris = [selectedFilesUris];
283
+ }
284
+ const result = [];
285
+ for (const uri of selectedFilesUris) {
286
+ const destination = await this.fileService.resolve(uri);
287
+ if (destination.isFile) {
288
+ await (0, browser_1.open)(this.openerService, uri);
289
+ result.push(uri);
290
+ }
291
+ }
292
+ return result;
293
+ }
294
+ return undefined;
295
+ }
296
+ /**
297
+ * Opens one or more folders after prompting the `Open Folder` dialog. Resolves to `undefined`, if
298
+ * - the user's selection is empty or contains only files.
299
+ * - the new workspace is equal to the old workspace.
300
+ *
301
+ * Otherwise, resolves to the URI of the new workspace:
302
+ * - a single folder if a single folder was selected.
303
+ * - a new, untitled workspace file if multiple folders were selected.
304
+ */
305
+ async doOpenFolder() {
306
+ const props = {
307
+ title: workspace_commands_1.WorkspaceCommands.OPEN_FOLDER.dialogLabel,
308
+ canSelectFolders: true,
309
+ canSelectFiles: false,
310
+ canSelectMany: true,
311
+ };
312
+ const [rootStat] = await this.workspaceService.roots;
313
+ const targetFolders = await this.fileDialogService.showOpenDialog(props, rootStat);
314
+ if (targetFolders) {
315
+ const openableUri = await this.getOpenableWorkspaceUri(targetFolders);
316
+ if (openableUri) {
317
+ if (!this.workspaceService.workspace || !openableUri.isEqual(this.workspaceService.workspace.resource)) {
318
+ this.workspaceService.open(openableUri);
319
+ return openableUri;
320
+ }
321
+ }
322
+ ;
323
+ }
324
+ return undefined;
325
+ }
326
+ async getOpenableWorkspaceUri(uris) {
327
+ if (Array.isArray(uris)) {
328
+ if (uris.length < 2) {
329
+ return uris[0];
330
+ }
331
+ else {
332
+ const foldersToOpen = (await Promise.all(uris.map(uri => this.fileService.resolve(uri))))
333
+ .filter(fileStat => !!(fileStat === null || fileStat === void 0 ? void 0 : fileStat.isDirectory));
334
+ if (foldersToOpen.length === 1) {
335
+ return foldersToOpen[0].resource;
336
+ }
337
+ else {
338
+ return this.createMultiRootWorkspace(foldersToOpen);
339
+ }
340
+ }
341
+ }
342
+ else {
343
+ return uris;
344
+ }
345
+ }
346
+ async createMultiRootWorkspace(roots) {
347
+ const untitledWorkspace = await this.workspaceService.getUntitledWorkspace();
348
+ const folders = Array.from(new Set(roots.map(stat => stat.resource.path.toString())), path => ({ path }));
349
+ const workspaceStat = await this.fileService.createFile(untitledWorkspace, buffer_1.BinaryBuffer.fromString(JSON.stringify({ folders }, null, 4)), // eslint-disable-line no-null/no-null
350
+ { overwrite: true });
351
+ return workspaceStat.resource;
352
+ }
353
+ /**
354
+ * Opens a workspace after raising the `Open Workspace` dialog. Resolves to the URI of the recently opened workspace,
355
+ * if it was successful. Otherwise, resolves to `undefined`.
356
+ */
357
+ async doOpenWorkspace() {
358
+ var _a;
359
+ const props = {
360
+ title: workspace_commands_1.WorkspaceCommands.OPEN_WORKSPACE.dialogLabel,
361
+ canSelectFiles: true,
362
+ canSelectFolders: false,
363
+ filters: this.getWorkspaceDialogFileFilters()
364
+ };
365
+ const [rootStat] = await this.workspaceService.roots;
366
+ const workspaceFileUri = await this.fileDialogService.showOpenDialog(props, rootStat);
367
+ if (workspaceFileUri &&
368
+ ((_a = this.getCurrentWorkspaceUri()) === null || _a === void 0 ? void 0 : _a.toString()) !== workspaceFileUri.toString()) {
369
+ if (await this.fileService.exists(workspaceFileUri)) {
370
+ this.workspaceService.open(workspaceFileUri);
371
+ return workspaceFileUri;
372
+ }
373
+ }
374
+ return undefined;
375
+ }
376
+ async closeWorkspace() {
377
+ await this.workspaceService.close();
378
+ }
379
+ /**
380
+ * @returns whether the file was successfully saved.
381
+ */
382
+ async saveWorkspaceAs() {
383
+ let exist = false;
384
+ let overwrite = false;
385
+ let selected;
386
+ do {
387
+ selected = await this.fileDialogService.showSaveDialog({
388
+ title: workspace_commands_1.WorkspaceCommands.SAVE_WORKSPACE_AS.label,
389
+ filters: this.getWorkspaceDialogFileFilters()
390
+ });
391
+ if (selected) {
392
+ const displayName = selected.displayName;
393
+ const extensions = this.workspaceFileService.getWorkspaceFileExtensions(true);
394
+ if (!extensions.some(ext => displayName.endsWith(ext))) {
395
+ const defaultExtension = extensions[this.workspaceFileService.defaultFileTypeIndex];
396
+ selected = selected.parent.resolve(`${displayName}${defaultExtension}`);
397
+ }
398
+ exist = await this.fileService.exists(selected);
399
+ if (exist) {
400
+ overwrite = await this.saveService.confirmOverwrite(selected);
401
+ }
402
+ }
403
+ } while (selected && exist && !overwrite);
404
+ if (selected) {
405
+ try {
406
+ await this.workspaceService.save(selected);
407
+ return true;
408
+ }
409
+ catch {
410
+ this.messageService.error(nls_1.nls.localizeByDefault("Unable to save workspace '{0}'", selected.path.fsPath()));
411
+ }
412
+ }
413
+ return false;
414
+ }
415
+ canBeSavedAs(widget) {
416
+ return this.saveService.canSaveAs(widget);
417
+ }
418
+ async saveAs(widget) {
419
+ await this.saveService.saveAs(widget);
420
+ }
421
+ updateWorkspaceStateKey() {
422
+ return this.doUpdateState();
423
+ }
424
+ updateWorkbenchStateKey() {
425
+ return this.doUpdateState();
426
+ }
427
+ doUpdateState() {
428
+ if (this.workspaceService.opened) {
429
+ return this.workspaceService.isMultiRootWorkspaceOpened ? 'workspace' : 'folder';
430
+ }
431
+ return 'empty';
432
+ }
433
+ getWorkspaceDialogFileFilters() {
434
+ const filters = {};
435
+ for (const fileType of this.workspaceFileService.getWorkspaceFileTypes()) {
436
+ filters[`${nls_1.nls.localizeByDefault('{0} workspace', fileType.name)} (*.${fileType.extension})`] = [fileType.extension];
437
+ }
438
+ return filters;
439
+ }
440
+ isElectron() {
441
+ return core_1.environment.electron.is();
442
+ }
443
+ /**
444
+ * Get the current workspace URI.
445
+ *
446
+ * @returns the current workspace URI.
447
+ */
448
+ getCurrentWorkspaceUri() {
449
+ var _a;
450
+ return (_a = this.workspaceService.workspace) === null || _a === void 0 ? void 0 : _a.resource;
451
+ }
452
+ onWillStop() {
453
+ const { workspace } = this.workspaceService;
454
+ if (workspace && this.workspaceService.isUntitledWorkspace(workspace.resource)) {
455
+ return {
456
+ prepare: async (reason) => reason === frontend_application_state_1.StopReason.Reload && this.workspaceService.isSafeToReload(workspace.resource),
457
+ action: async (alreadyConfirmedSafe) => {
458
+ if (alreadyConfirmedSafe) {
459
+ return true;
460
+ }
461
+ const shouldSaveFile = await new untitled_workspace_exit_dialog_1.UntitledWorkspaceExitDialog({
462
+ title: nls_1.nls.localizeByDefault('Do you want to save your workspace configuration as a file?')
463
+ }).open();
464
+ if (shouldSaveFile === "Don't Save") {
465
+ return true;
466
+ }
467
+ else if (shouldSaveFile === 'Save') {
468
+ return this.saveWorkspaceAs();
469
+ }
470
+ return false; // If cancel, prevent exit.
471
+ },
472
+ reason: 'Untitled workspace.',
473
+ // Since deleting the workspace would hobble any future functionality, run this late.
474
+ priority: 100,
475
+ };
476
+ }
477
+ }
478
+ };
479
+ exports.WorkspaceFrontendContribution = WorkspaceFrontendContribution;
480
+ tslib_1.__decorate([
481
+ (0, inversify_1.inject)(common_1.MessageService),
482
+ tslib_1.__metadata("design:type", common_1.MessageService)
483
+ ], WorkspaceFrontendContribution.prototype, "messageService", void 0);
484
+ tslib_1.__decorate([
485
+ (0, inversify_1.inject)(file_service_1.FileService),
486
+ tslib_1.__metadata("design:type", file_service_1.FileService)
487
+ ], WorkspaceFrontendContribution.prototype, "fileService", void 0);
488
+ tslib_1.__decorate([
489
+ (0, inversify_1.inject)(browser_1.OpenerService),
490
+ tslib_1.__metadata("design:type", Object)
491
+ ], WorkspaceFrontendContribution.prototype, "openerService", void 0);
492
+ tslib_1.__decorate([
493
+ (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
494
+ tslib_1.__metadata("design:type", workspace_service_1.WorkspaceService)
495
+ ], WorkspaceFrontendContribution.prototype, "workspaceService", void 0);
496
+ tslib_1.__decorate([
497
+ (0, inversify_1.inject)(quick_open_workspace_1.QuickOpenWorkspace),
498
+ tslib_1.__metadata("design:type", quick_open_workspace_1.QuickOpenWorkspace)
499
+ ], WorkspaceFrontendContribution.prototype, "quickOpenWorkspace", void 0);
500
+ tslib_1.__decorate([
501
+ (0, inversify_1.inject)(browser_2.FileDialogService),
502
+ tslib_1.__metadata("design:type", Object)
503
+ ], WorkspaceFrontendContribution.prototype, "fileDialogService", void 0);
504
+ tslib_1.__decorate([
505
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
506
+ tslib_1.__metadata("design:type", Object)
507
+ ], WorkspaceFrontendContribution.prototype, "contextKeyService", void 0);
508
+ tslib_1.__decorate([
509
+ (0, inversify_1.inject)(encoding_registry_1.EncodingRegistry),
510
+ tslib_1.__metadata("design:type", encoding_registry_1.EncodingRegistry)
511
+ ], WorkspaceFrontendContribution.prototype, "encodingRegistry", void 0);
512
+ tslib_1.__decorate([
513
+ (0, inversify_1.inject)(preference_configurations_1.PreferenceConfigurations),
514
+ tslib_1.__metadata("design:type", preference_configurations_1.PreferenceConfigurations)
515
+ ], WorkspaceFrontendContribution.prototype, "preferenceConfigurations", void 0);
516
+ tslib_1.__decorate([
517
+ (0, inversify_1.inject)(filesystem_saveable_service_1.FilesystemSaveableService),
518
+ tslib_1.__metadata("design:type", filesystem_saveable_service_1.FilesystemSaveableService)
519
+ ], WorkspaceFrontendContribution.prototype, "saveService", void 0);
520
+ tslib_1.__decorate([
521
+ (0, inversify_1.inject)(common_2.WorkspaceFileService),
522
+ tslib_1.__metadata("design:type", common_2.WorkspaceFileService)
523
+ ], WorkspaceFrontendContribution.prototype, "workspaceFileService", void 0);
524
+ exports.WorkspaceFrontendContribution = WorkspaceFrontendContribution = tslib_1.__decorate([
525
+ (0, inversify_1.injectable)()
526
+ ], WorkspaceFrontendContribution);
527
+ (function (WorkspaceFrontendContribution) {
528
+ /**
529
+ * File filter for all Theia and VS Code workspace file types.
530
+ *
531
+ * @deprecated Since 1.39.0 Use `WorkspaceFrontendContribution#getWorkspaceDialogFileFilters` instead.
532
+ */
533
+ WorkspaceFrontendContribution.DEFAULT_FILE_FILTER = {
534
+ 'Theia Workspace (*.theia-workspace)': [common_2.THEIA_EXT],
535
+ 'VS Code Workspace (*.code-workspace)': [common_2.VSCODE_EXT]
536
+ };
537
+ })(WorkspaceFrontendContribution || (exports.WorkspaceFrontendContribution = WorkspaceFrontendContribution = {}));
538
+ //# sourceMappingURL=workspace-frontend-contribution.js.map