@theia/workspace 1.34.2 → 1.34.3

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 (105) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/browser/diff-service.d.ts +10 -10
  4. package/lib/browser/diff-service.js +85 -85
  5. package/lib/browser/index.d.ts +6 -6
  6. package/lib/browser/index.js +33 -33
  7. package/lib/browser/quick-open-workspace.d.ts +25 -25
  8. package/lib/browser/quick-open-workspace.js +137 -137
  9. package/lib/browser/untitled-workspace-exit-dialog.d.ts +19 -19
  10. package/lib/browser/untitled-workspace-exit-dialog.js +74 -74
  11. package/lib/browser/workspace-breadcrumbs-contribution.d.ts +10 -10
  12. package/lib/browser/workspace-breadcrumbs-contribution.js +66 -66
  13. package/lib/browser/workspace-commands.d.ts +117 -117
  14. package/lib/browser/workspace-commands.js +593 -593
  15. package/lib/browser/workspace-commands.spec.d.ts +1 -1
  16. package/lib/browser/workspace-commands.spec.js +127 -127
  17. package/lib/browser/workspace-compare-handler.d.ts +26 -26
  18. package/lib/browser/workspace-compare-handler.js +66 -66
  19. package/lib/browser/workspace-delete-handler.d.ts +75 -75
  20. package/lib/browser/workspace-delete-handler.js +214 -214
  21. package/lib/browser/workspace-duplicate-handler.d.ts +30 -30
  22. package/lib/browser/workspace-duplicate-handler.js +86 -86
  23. package/lib/browser/workspace-frontend-contribution.d.ts +135 -135
  24. package/lib/browser/workspace-frontend-contribution.js +568 -568
  25. package/lib/browser/workspace-frontend-contribution.spec.d.ts +1 -1
  26. package/lib/browser/workspace-frontend-contribution.spec.js +53 -53
  27. package/lib/browser/workspace-frontend-module.d.ts +3 -3
  28. package/lib/browser/workspace-frontend-module.js +88 -88
  29. package/lib/browser/workspace-input-dialog.d.ts +19 -19
  30. package/lib/browser/workspace-input-dialog.js +73 -73
  31. package/lib/browser/workspace-preferences.d.ts +11 -11
  32. package/lib/browser/workspace-preferences.js +46 -46
  33. package/lib/browser/workspace-schema-updater.d.ts +32 -32
  34. package/lib/browser/workspace-schema-updater.js +148 -148
  35. package/lib/browser/workspace-service.d.ts +182 -182
  36. package/lib/browser/workspace-service.js +729 -729
  37. package/lib/browser/workspace-storage-service.d.ts +15 -15
  38. package/lib/browser/workspace-storage-service.js +80 -80
  39. package/lib/browser/workspace-trust-preferences.d.ts +21 -21
  40. package/lib/browser/workspace-trust-preferences.js +65 -65
  41. package/lib/browser/workspace-trust-service.d.ts +26 -26
  42. package/lib/browser/workspace-trust-service.js +149 -149
  43. package/lib/browser/workspace-uri-contribution.d.ts +20 -20
  44. package/lib/browser/workspace-uri-contribution.js +113 -113
  45. package/lib/browser/workspace-uri-contribution.spec.d.ts +1 -1
  46. package/lib/browser/workspace-uri-contribution.spec.js +169 -169
  47. package/lib/browser/workspace-user-working-directory-provider.d.ts +12 -12
  48. package/lib/browser/workspace-user-working-directory-provider.js +62 -62
  49. package/lib/browser/workspace-utils.d.ts +15 -15
  50. package/lib/browser/workspace-utils.js +54 -54
  51. package/lib/browser/workspace-variable-contribution.d.ts +23 -23
  52. package/lib/browser/workspace-variable-contribution.js +237 -237
  53. package/lib/browser/workspace-window-title-updater.d.ts +7 -7
  54. package/lib/browser/workspace-window-title-updater.js +57 -57
  55. package/lib/common/index.d.ts +2 -2
  56. package/lib/common/index.js +29 -29
  57. package/lib/common/test/mock-workspace-server.d.ts +7 -7
  58. package/lib/common/test/mock-workspace-server.js +35 -35
  59. package/lib/common/utils.d.ts +21 -21
  60. package/lib/common/utils.js +73 -73
  61. package/lib/common/workspace-protocol.d.ts +26 -26
  62. package/lib/common/workspace-protocol.js +23 -23
  63. package/lib/node/default-workspace-server.d.ts +64 -64
  64. package/lib/node/default-workspace-server.js +248 -248
  65. package/lib/node/default-workspace-server.spec.d.ts +1 -1
  66. package/lib/node/default-workspace-server.spec.js +84 -84
  67. package/lib/node/index.d.ts +2 -2
  68. package/lib/node/index.js +29 -29
  69. package/lib/node/workspace-backend-module.d.ts +3 -3
  70. package/lib/node/workspace-backend-module.js +32 -32
  71. package/package.json +6 -6
  72. package/src/browser/diff-service.ts +62 -62
  73. package/src/browser/index.ts +22 -22
  74. package/src/browser/quick-open-workspace.ts +112 -112
  75. package/src/browser/untitled-workspace-exit-dialog.ts +70 -70
  76. package/src/browser/workspace-breadcrumbs-contribution.ts +56 -56
  77. package/src/browser/workspace-commands.spec.ts +153 -153
  78. package/src/browser/workspace-commands.ts +586 -586
  79. package/src/browser/workspace-compare-handler.ts +56 -56
  80. package/src/browser/workspace-delete-handler.ts +212 -212
  81. package/src/browser/workspace-duplicate-handler.ts +75 -75
  82. package/src/browser/workspace-frontend-contribution.spec.ts +63 -63
  83. package/src/browser/workspace-frontend-contribution.ts +558 -558
  84. package/src/browser/workspace-frontend-module.ts +115 -115
  85. package/src/browser/workspace-input-dialog.ts +60 -60
  86. package/src/browser/workspace-preferences.ts +58 -58
  87. package/src/browser/workspace-schema-updater.ts +148 -148
  88. package/src/browser/workspace-service.ts +772 -772
  89. package/src/browser/workspace-storage-service.ts +67 -67
  90. package/src/browser/workspace-trust-preferences.ts +76 -76
  91. package/src/browser/workspace-trust-service.ts +143 -143
  92. package/src/browser/workspace-uri-contribution.spec.ts +191 -191
  93. package/src/browser/workspace-uri-contribution.ts +97 -97
  94. package/src/browser/workspace-user-working-directory-provider.ts +48 -48
  95. package/src/browser/workspace-utils.ts +45 -45
  96. package/src/browser/workspace-variable-contribution.ts +222 -222
  97. package/src/browser/workspace-window-title-updater.ts +45 -45
  98. package/src/common/index.ts +18 -18
  99. package/src/common/test/mock-workspace-server.ts +29 -29
  100. package/src/common/utils.ts +69 -69
  101. package/src/common/workspace-protocol.ts +47 -47
  102. package/src/node/default-workspace-server.spec.ts +99 -99
  103. package/src/node/default-workspace-server.ts +242 -242
  104. package/src/node/index.ts +18 -18
  105. package/src/node/workspace-backend-module.ts +37 -37
@@ -1,148 +1,148 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
- import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
19
- import { InMemoryResources, isArray, isObject } from '@theia/core/lib/common';
20
- import { IJSONSchema } from '@theia/core/lib/common/json-schema';
21
- import URI from '@theia/core/lib/common/uri';
22
- import { Deferred } from '@theia/core/lib/common/promise-util';
23
-
24
- export interface SchemaUpdateMessage {
25
- key: string,
26
- schema?: IJSONSchema,
27
- deferred: Deferred<boolean>;
28
- }
29
-
30
- export namespace AddKeyMessage {
31
- export const is = (message: SchemaUpdateMessage | undefined): message is Required<SchemaUpdateMessage> => !!message && message.schema !== undefined;
32
- }
33
-
34
- @injectable()
35
- export class WorkspaceSchemaUpdater implements JsonSchemaContribution {
36
-
37
- protected readonly uri = new URI(workspaceSchemaId);
38
- protected readonly editQueue: SchemaUpdateMessage[] = [];
39
- protected safeToHandleQueue = new Deferred();
40
-
41
- @inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources;
42
-
43
- @postConstruct()
44
- protected init(): void {
45
- this.inmemoryResources.add(this.uri, JSON.stringify(workspaceSchema));
46
- this.safeToHandleQueue.resolve();
47
- }
48
-
49
- registerSchemas(context: JsonSchemaRegisterContext): void {
50
- context.registerSchema({
51
- fileMatch: ['*.theia-workspace', '*.code-workspace'],
52
- url: this.uri.toString()
53
- });
54
- }
55
-
56
- protected async retrieveCurrent(): Promise<WorkspaceSchema> {
57
- const current = await this.inmemoryResources.resolve(this.uri).readContents();
58
-
59
- const content = JSON.parse(current);
60
-
61
- if (!WorkspaceSchema.is(content)) {
62
- throw new Error('Failed to retrieve current workspace schema.');
63
- }
64
-
65
- return content;
66
- }
67
-
68
- async updateSchema(message: Omit<SchemaUpdateMessage, 'deferred'>): Promise<boolean> {
69
- const doHandle = this.editQueue.length === 0;
70
- const deferred = new Deferred<boolean>();
71
- this.editQueue.push({ ...message, deferred });
72
- if (doHandle) {
73
- this.handleQueue();
74
- }
75
- return deferred.promise;
76
- }
77
-
78
- protected async handleQueue(): Promise<void> {
79
- await this.safeToHandleQueue.promise;
80
- this.safeToHandleQueue = new Deferred();
81
- const cache = await this.retrieveCurrent();
82
- while (this.editQueue.length) {
83
- const nextMessage = this.editQueue.shift();
84
- if (AddKeyMessage.is(nextMessage)) {
85
- this.addKey(nextMessage, cache);
86
- } else if (nextMessage) {
87
- this.removeKey(nextMessage, cache);
88
- }
89
- }
90
- this.inmemoryResources.update(this.uri, JSON.stringify(cache));
91
- this.safeToHandleQueue.resolve();
92
- }
93
-
94
- protected addKey({ key, schema, deferred }: Required<SchemaUpdateMessage>, cache: WorkspaceSchema): void {
95
- if (key in cache.properties) {
96
- return deferred.resolve(false);
97
- }
98
-
99
- cache.properties[key] = schema;
100
- deferred.resolve(true);
101
- }
102
-
103
- protected removeKey({ key, deferred }: SchemaUpdateMessage, cache: WorkspaceSchema): void {
104
- const canDelete = !cache.required.includes(key);
105
- if (!canDelete) {
106
- return deferred.resolve(false);
107
- }
108
-
109
- const keyPresent = delete cache.properties[key];
110
- deferred.resolve(keyPresent);
111
- }
112
- }
113
-
114
- export type WorkspaceSchema = Required<Pick<IJSONSchema, 'properties' | 'required'>>;
115
-
116
- export namespace WorkspaceSchema {
117
- export function is(candidate: unknown): candidate is WorkspaceSchema {
118
- return isObject<WorkspaceSchema>(candidate)
119
- && typeof candidate.properties === 'object'
120
- && isArray(candidate.required);
121
- }
122
- }
123
-
124
- export const workspaceSchemaId = 'vscode://schemas/workspace';
125
- export const workspaceSchema: IJSONSchema = {
126
- $id: workspaceSchemaId,
127
- type: 'object',
128
- title: 'Workspace File',
129
- required: ['folders'],
130
- default: { folders: [{ path: '' }], settings: {} },
131
- properties: {
132
- folders: {
133
- description: 'Root folders in the workspace',
134
- type: 'array',
135
- items: {
136
- type: 'object',
137
- properties: {
138
- path: {
139
- type: 'string',
140
- }
141
- },
142
- required: ['path']
143
- }
144
- }
145
- },
146
- allowComments: true,
147
- allowTrailingCommas: true,
148
- };
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
19
+ import { InMemoryResources, isArray, isObject } from '@theia/core/lib/common';
20
+ import { IJSONSchema } from '@theia/core/lib/common/json-schema';
21
+ import URI from '@theia/core/lib/common/uri';
22
+ import { Deferred } from '@theia/core/lib/common/promise-util';
23
+
24
+ export interface SchemaUpdateMessage {
25
+ key: string,
26
+ schema?: IJSONSchema,
27
+ deferred: Deferred<boolean>;
28
+ }
29
+
30
+ export namespace AddKeyMessage {
31
+ export const is = (message: SchemaUpdateMessage | undefined): message is Required<SchemaUpdateMessage> => !!message && message.schema !== undefined;
32
+ }
33
+
34
+ @injectable()
35
+ export class WorkspaceSchemaUpdater implements JsonSchemaContribution {
36
+
37
+ protected readonly uri = new URI(workspaceSchemaId);
38
+ protected readonly editQueue: SchemaUpdateMessage[] = [];
39
+ protected safeToHandleQueue = new Deferred();
40
+
41
+ @inject(InMemoryResources) protected readonly inmemoryResources: InMemoryResources;
42
+
43
+ @postConstruct()
44
+ protected init(): void {
45
+ this.inmemoryResources.add(this.uri, JSON.stringify(workspaceSchema));
46
+ this.safeToHandleQueue.resolve();
47
+ }
48
+
49
+ registerSchemas(context: JsonSchemaRegisterContext): void {
50
+ context.registerSchema({
51
+ fileMatch: ['*.theia-workspace', '*.code-workspace'],
52
+ url: this.uri.toString()
53
+ });
54
+ }
55
+
56
+ protected async retrieveCurrent(): Promise<WorkspaceSchema> {
57
+ const current = await this.inmemoryResources.resolve(this.uri).readContents();
58
+
59
+ const content = JSON.parse(current);
60
+
61
+ if (!WorkspaceSchema.is(content)) {
62
+ throw new Error('Failed to retrieve current workspace schema.');
63
+ }
64
+
65
+ return content;
66
+ }
67
+
68
+ async updateSchema(message: Omit<SchemaUpdateMessage, 'deferred'>): Promise<boolean> {
69
+ const doHandle = this.editQueue.length === 0;
70
+ const deferred = new Deferred<boolean>();
71
+ this.editQueue.push({ ...message, deferred });
72
+ if (doHandle) {
73
+ this.handleQueue();
74
+ }
75
+ return deferred.promise;
76
+ }
77
+
78
+ protected async handleQueue(): Promise<void> {
79
+ await this.safeToHandleQueue.promise;
80
+ this.safeToHandleQueue = new Deferred();
81
+ const cache = await this.retrieveCurrent();
82
+ while (this.editQueue.length) {
83
+ const nextMessage = this.editQueue.shift();
84
+ if (AddKeyMessage.is(nextMessage)) {
85
+ this.addKey(nextMessage, cache);
86
+ } else if (nextMessage) {
87
+ this.removeKey(nextMessage, cache);
88
+ }
89
+ }
90
+ this.inmemoryResources.update(this.uri, JSON.stringify(cache));
91
+ this.safeToHandleQueue.resolve();
92
+ }
93
+
94
+ protected addKey({ key, schema, deferred }: Required<SchemaUpdateMessage>, cache: WorkspaceSchema): void {
95
+ if (key in cache.properties) {
96
+ return deferred.resolve(false);
97
+ }
98
+
99
+ cache.properties[key] = schema;
100
+ deferred.resolve(true);
101
+ }
102
+
103
+ protected removeKey({ key, deferred }: SchemaUpdateMessage, cache: WorkspaceSchema): void {
104
+ const canDelete = !cache.required.includes(key);
105
+ if (!canDelete) {
106
+ return deferred.resolve(false);
107
+ }
108
+
109
+ const keyPresent = delete cache.properties[key];
110
+ deferred.resolve(keyPresent);
111
+ }
112
+ }
113
+
114
+ export type WorkspaceSchema = Required<Pick<IJSONSchema, 'properties' | 'required'>>;
115
+
116
+ export namespace WorkspaceSchema {
117
+ export function is(candidate: unknown): candidate is WorkspaceSchema {
118
+ return isObject<WorkspaceSchema>(candidate)
119
+ && typeof candidate.properties === 'object'
120
+ && isArray(candidate.required);
121
+ }
122
+ }
123
+
124
+ export const workspaceSchemaId = 'vscode://schemas/workspace';
125
+ export const workspaceSchema: IJSONSchema = {
126
+ $id: workspaceSchemaId,
127
+ type: 'object',
128
+ title: 'Workspace File',
129
+ required: ['folders'],
130
+ default: { folders: [{ path: '' }], settings: {} },
131
+ properties: {
132
+ folders: {
133
+ description: 'Root folders in the workspace',
134
+ type: 'array',
135
+ items: {
136
+ type: 'object',
137
+ properties: {
138
+ path: {
139
+ type: 'string',
140
+ }
141
+ },
142
+ required: ['path']
143
+ }
144
+ }
145
+ },
146
+ allowComments: true,
147
+ allowTrailingCommas: true,
148
+ };