@theia/workspace 1.45.1 → 1.46.1

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.
@@ -0,0 +1,13 @@
1
+ import { WorkspaceServer } from '../common/workspace-protocol';
2
+ import { ILogger } from '@theia/core';
3
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
4
+ export declare const RECENT_WORKSPACES_LOCAL_STORAGE_KEY = "workspaces";
5
+ export declare class BrowserOnlyWorkspaceServer implements WorkspaceServer {
6
+ protected logger: ILogger;
7
+ protected readonly fileService: FileService;
8
+ getRecentWorkspaces(): Promise<string[]>;
9
+ getMostRecentlyUsedWorkspace(): Promise<string | undefined>;
10
+ setMostRecentlyUsedWorkspace(uri: string): Promise<void>;
11
+ removeRecentWorkspace(uri: string): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=browser-only-workspace-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-only-workspace-server.d.ts","sourceRoot":"","sources":["../../src/browser-only/browser-only-workspace-server.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAiB,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,eAAO,MAAM,mCAAmC,eAAe,CAAC;AAEhE,qBACa,0BAA2B,YAAW,eAAe;IAG9D,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAG1B,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAEtC,mBAAmB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAiBxC,4BAA4B,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK3D,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxD,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAO1D"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BrowserOnlyWorkspaceServer = exports.RECENT_WORKSPACES_LOCAL_STORAGE_KEY = void 0;
13
+ // *****************************************************************************
14
+ // Copyright (C) 2023 EclipseSource and others.
15
+ //
16
+ // This program and the accompanying materials are made available under the
17
+ // terms of the Eclipse Public License v. 2.0 which is available at
18
+ // http://www.eclipse.org/legal/epl-2.0.
19
+ //
20
+ // This Source Code may also be made available under the following Secondary
21
+ // Licenses when the conditions for such availability set forth in the Eclipse
22
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
+ // with the GNU Classpath Exception which is available at
24
+ // https://www.gnu.org/software/classpath/license.html.
25
+ //
26
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
27
+ // *****************************************************************************
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const core_1 = require("@theia/core");
30
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
31
+ exports.RECENT_WORKSPACES_LOCAL_STORAGE_KEY = 'workspaces';
32
+ let BrowserOnlyWorkspaceServer = class BrowserOnlyWorkspaceServer {
33
+ async getRecentWorkspaces() {
34
+ const storedWorkspaces = localStorage.getItem(exports.RECENT_WORKSPACES_LOCAL_STORAGE_KEY);
35
+ if (!storedWorkspaces) {
36
+ return [];
37
+ }
38
+ try {
39
+ const parsedWorkspaces = JSON.parse(storedWorkspaces);
40
+ if ((0, core_1.isStringArray)(parsedWorkspaces)) {
41
+ return parsedWorkspaces;
42
+ }
43
+ }
44
+ catch (e) {
45
+ this.logger.error(e);
46
+ return [];
47
+ }
48
+ return [];
49
+ }
50
+ async getMostRecentlyUsedWorkspace() {
51
+ const workspaces = await this.getRecentWorkspaces();
52
+ return workspaces[0];
53
+ }
54
+ async setMostRecentlyUsedWorkspace(uri) {
55
+ const workspaces = await this.getRecentWorkspaces();
56
+ if (workspaces.includes(uri)) {
57
+ workspaces.splice(workspaces.indexOf(uri), 1);
58
+ }
59
+ localStorage.setItem(exports.RECENT_WORKSPACES_LOCAL_STORAGE_KEY, JSON.stringify([uri, ...workspaces]));
60
+ }
61
+ async removeRecentWorkspace(uri) {
62
+ const workspaces = await this.getRecentWorkspaces();
63
+ if (workspaces.includes(uri)) {
64
+ workspaces.splice(workspaces.indexOf(uri), 1);
65
+ }
66
+ localStorage.setItem(exports.RECENT_WORKSPACES_LOCAL_STORAGE_KEY, JSON.stringify(workspaces));
67
+ }
68
+ };
69
+ __decorate([
70
+ (0, inversify_1.inject)(core_1.ILogger),
71
+ __metadata("design:type", Object)
72
+ ], BrowserOnlyWorkspaceServer.prototype, "logger", void 0);
73
+ __decorate([
74
+ (0, inversify_1.inject)(file_service_1.FileService),
75
+ __metadata("design:type", file_service_1.FileService)
76
+ ], BrowserOnlyWorkspaceServer.prototype, "fileService", void 0);
77
+ BrowserOnlyWorkspaceServer = __decorate([
78
+ (0, inversify_1.injectable)()
79
+ ], BrowserOnlyWorkspaceServer);
80
+ exports.BrowserOnlyWorkspaceServer = BrowserOnlyWorkspaceServer;
81
+ //# sourceMappingURL=browser-only-workspace-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-only-workspace-server.js","sourceRoot":"","sources":["../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CAAC,EAAE,CAAC,CAAC,CAAC;SACjD;QACD,YAAY,CAAC,OAAO,CAAC,2CAAmC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACpG,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,GAAW;QACnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC1B,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;SACjD;QACD,YAAY,CAAC,OAAO,CAAC,2CAAmC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1F,CAAC;CACJ,CAAA;AA1CG;IADC,IAAA,kBAAM,EAAC,cAAO,CAAC;;0DACU;AAG1B;IADC,IAAA,kBAAM,EAAC,0BAAW,CAAC;8BACY,0BAAW;+DAAC;AANnC,0BAA0B;IADtC,IAAA,sBAAU,GAAE;GACA,0BAA0B,CA6CtC;AA7CY,gEAA0B"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=workspace-frontend-only-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-frontend-only-module.d.ts","sourceRoot":"","sources":["../../src/browser-only/workspace-frontend-only-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAc,MAAM,8BAA8B,CAAC;;AAI3E,wBAOG"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 EclipseSource 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
+ const inversify_1 = require("@theia/core/shared/inversify");
19
+ const browser_only_workspace_server_1 = require("./browser-only-workspace-server");
20
+ const common_1 = require("../common");
21
+ exports.default = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
22
+ bind(browser_only_workspace_server_1.BrowserOnlyWorkspaceServer).toSelf().inSingletonScope();
23
+ if (isBound(common_1.WorkspaceServer)) {
24
+ rebind(common_1.WorkspaceServer).toService(browser_only_workspace_server_1.BrowserOnlyWorkspaceServer);
25
+ }
26
+ else {
27
+ bind(common_1.WorkspaceServer).toService(browser_only_workspace_server_1.BrowserOnlyWorkspaceServer);
28
+ }
29
+ });
30
+ //# sourceMappingURL=workspace-frontend-only-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-frontend-only-module.js","sourceRoot":"","sources":["../../src/browser-only/workspace-frontend-only-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,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;;AAEhF,4DAA2E;AAC3E,mFAA6E;AAC7E,sCAA4C;AAE5C,kBAAe,IAAI,2BAAe,CAAC,CAAC,IAAqB,EAAE,MAAyB,EAAE,OAA2B,EAAE,MAAyB,EAAE,EAAE;IAC5I,IAAI,CAAC,0DAA0B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC7D,IAAI,OAAO,CAAC,wBAAe,CAAC,EAAE;QAC1B,MAAM,CAAC,wBAAe,CAAC,CAAC,SAAS,CAAC,0DAA0B,CAAC,CAAC;KACjE;SAAM;QACH,IAAI,CAAC,wBAAe,CAAC,CAAC,SAAS,CAAC,0DAA0B,CAAC,CAAC;KAC/D;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@theia/workspace",
3
- "version": "1.45.1",
3
+ "version": "1.46.1",
4
4
  "description": "Theia - Workspace Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.45.1",
7
- "@theia/filesystem": "1.45.1",
8
- "@theia/variable-resolver": "1.45.1",
6
+ "@theia/core": "1.46.1",
7
+ "@theia/filesystem": "1.46.1",
8
+ "@theia/variable-resolver": "1.46.1",
9
9
  "jsonc-parser": "^2.2.0",
10
10
  "valid-filename": "^2.0.1"
11
11
  },
@@ -16,6 +16,9 @@
16
16
  {
17
17
  "frontend": "lib/browser/workspace-frontend-module",
18
18
  "backend": "lib/node/workspace-backend-module"
19
+ },
20
+ {
21
+ "frontendOnly": "lib/browser-only/workspace-frontend-only-module"
19
22
  }
20
23
  ],
21
24
  "keywords": [
@@ -43,10 +46,10 @@
43
46
  "watch": "theiaext watch"
44
47
  },
45
48
  "devDependencies": {
46
- "@theia/ext-scripts": "1.45.1"
49
+ "@theia/ext-scripts": "1.46.1"
47
50
  },
48
51
  "nyc": {
49
52
  "extends": "../../configs/nyc.json"
50
53
  },
51
- "gitHead": "3837c50544190b80d0ad8e87aa9fa9f286c70fcc"
54
+ "gitHead": "1799210a8fba6eb81e2ddaf66f09d6fa071df012"
52
55
  }
@@ -0,0 +1,69 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { inject, injectable } from '@theia/core/shared/inversify';
17
+ import { WorkspaceServer } from '../common/workspace-protocol';
18
+ import { ILogger, isStringArray } from '@theia/core';
19
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
20
+
21
+ export const RECENT_WORKSPACES_LOCAL_STORAGE_KEY = 'workspaces';
22
+
23
+ @injectable()
24
+ export class BrowserOnlyWorkspaceServer implements WorkspaceServer {
25
+
26
+ @inject(ILogger)
27
+ protected logger: ILogger;
28
+
29
+ @inject(FileService)
30
+ protected readonly fileService: FileService;
31
+
32
+ async getRecentWorkspaces(): Promise<string[]> {
33
+ const storedWorkspaces = localStorage.getItem(RECENT_WORKSPACES_LOCAL_STORAGE_KEY);
34
+ if (!storedWorkspaces) {
35
+ return [];
36
+ }
37
+ try {
38
+ const parsedWorkspaces = JSON.parse(storedWorkspaces);
39
+ if (isStringArray(parsedWorkspaces)) {
40
+ return parsedWorkspaces;
41
+ }
42
+ } catch (e) {
43
+ this.logger.error(e);
44
+ return [];
45
+ }
46
+ return [];
47
+ }
48
+
49
+ async getMostRecentlyUsedWorkspace(): Promise<string | undefined> {
50
+ const workspaces = await this.getRecentWorkspaces();
51
+ return workspaces[0];
52
+ }
53
+
54
+ async setMostRecentlyUsedWorkspace(uri: string): Promise<void> {
55
+ const workspaces = await this.getRecentWorkspaces();
56
+ if (workspaces.includes(uri)) {
57
+ workspaces.splice(workspaces.indexOf(uri), 1);
58
+ }
59
+ localStorage.setItem(RECENT_WORKSPACES_LOCAL_STORAGE_KEY, JSON.stringify([uri, ...workspaces]));
60
+ }
61
+
62
+ async removeRecentWorkspace(uri: string): Promise<void> {
63
+ const workspaces = await this.getRecentWorkspaces();
64
+ if (workspaces.includes(uri)) {
65
+ workspaces.splice(workspaces.indexOf(uri), 1);
66
+ }
67
+ localStorage.setItem(RECENT_WORKSPACES_LOCAL_STORAGE_KEY, JSON.stringify(workspaces));
68
+ }
69
+ }
@@ -0,0 +1,28 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
18
+ import { BrowserOnlyWorkspaceServer } from './browser-only-workspace-server';
19
+ import { WorkspaceServer } from '../common';
20
+
21
+ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
22
+ bind(BrowserOnlyWorkspaceServer).toSelf().inSingletonScope();
23
+ if (isBound(WorkspaceServer)) {
24
+ rebind(WorkspaceServer).toService(BrowserOnlyWorkspaceServer);
25
+ } else {
26
+ bind(WorkspaceServer).toService(BrowserOnlyWorkspaceServer);
27
+ }
28
+ });