@theia/filesystem 1.37.0-next.16 → 1.37.0-next.18

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 (26) hide show
  1. package/lib/electron-browser/file-dialog/electron-file-dialog-service.d.ts +1 -41
  2. package/lib/electron-browser/file-dialog/electron-file-dialog-service.d.ts.map +1 -1
  3. package/lib/electron-browser/file-dialog/electron-file-dialog-service.js +46 -86
  4. package/lib/electron-browser/file-dialog/electron-file-dialog-service.js.map +1 -1
  5. package/lib/electron-browser/preload.d.ts +2 -0
  6. package/lib/electron-browser/preload.d.ts.map +1 -0
  7. package/lib/electron-browser/preload.js +31 -0
  8. package/lib/electron-browser/preload.js.map +1 -0
  9. package/lib/electron-common/electron-api.d.ts +35 -0
  10. package/lib/electron-common/electron-api.d.ts.map +1 -0
  11. package/lib/electron-common/electron-api.js +21 -0
  12. package/lib/electron-common/electron-api.js.map +1 -0
  13. package/lib/electron-main/electron-api-main.d.ts +6 -0
  14. package/lib/electron-main/electron-api-main.d.ts.map +1 -0
  15. package/lib/electron-main/electron-api-main.js +79 -0
  16. package/lib/electron-main/electron-api-main.js.map +1 -0
  17. package/lib/electron-main/electron-main-module.d.ts +4 -0
  18. package/lib/electron-main/electron-main-module.d.ts.map +1 -0
  19. package/lib/electron-main/electron-main-module.js +25 -0
  20. package/lib/electron-main/electron-main-module.js.map +1 -0
  21. package/package.json +7 -3
  22. package/src/electron-browser/file-dialog/electron-file-dialog-service.ts +53 -116
  23. package/src/electron-browser/preload.ts +30 -0
  24. package/src/electron-common/electron-api.ts +55 -0
  25. package/src/electron-main/electron-api-main.ts +78 -0
  26. package/src/electron-main/electron-main-module.ts +23 -0
@@ -1,10 +1,9 @@
1
- import { FileFilter, OpenDialogOptions, SaveDialogOptions } from '@theia/core/electron-shared/electron';
2
1
  import URI from '@theia/core/lib/common/uri';
3
2
  import { MaybeArray } from '@theia/core/lib/common/types';
4
3
  import { MessageService } from '@theia/core/lib/common/message-service';
5
4
  import { FileStat } from '../../common/files';
6
5
  import { DefaultFileDialogService, OpenFileDialogProps, SaveFileDialogProps } from '../../browser/file-dialog';
7
- declare type DialogProperties = 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory' | 'dontAddToRecent';
6
+ import { OpenDialogOptions, SaveDialogOptions } from '../../electron-common/electron-api';
8
7
  export declare class ElectronFileDialogService extends DefaultFileDialogService {
9
8
  protected readonly messageService: MessageService;
10
9
  showOpenDialog(props: OpenFileDialogProps & {
@@ -14,46 +13,7 @@ export declare class ElectronFileDialogService extends DefaultFileDialogService
14
13
  showSaveDialog(props: SaveFileDialogProps, folder?: FileStat): Promise<URI | undefined>;
15
14
  protected canReadWrite(uris: MaybeArray<URI>): Promise<boolean>;
16
15
  protected canRead(uris: MaybeArray<URI>): Promise<boolean>;
17
- protected toDialogOptions(uri: URI, props: SaveFileDialogProps | OpenFileDialogProps, dialogTitle: string): electron.FileDialogProps;
18
- /**
19
- * Specifies whether an _All Files_ filter should be added to the dialog.
20
- *
21
- * On Linux, the _All Files_ filter [hides](https://github.com/eclipse-theia/theia/issues/11321) files without an extension.
22
- * The bug is resolved in Electron >=18.
23
- */
24
- protected shouldAddAllFilesFilter(electronProps: electron.FileDialogProps): boolean;
25
16
  protected toOpenDialogOptions(uri: URI, props: OpenFileDialogProps): OpenDialogOptions;
26
17
  protected toSaveDialogOptions(uri: URI, props: SaveFileDialogProps): SaveDialogOptions;
27
18
  }
28
- export declare namespace electron {
29
- /**
30
- * Common "super" interface of the `electron.SaveDialogOptions` and `electron.OpenDialogOptions` types.
31
- */
32
- interface FileDialogProps {
33
- /**
34
- * The dialog title.
35
- */
36
- readonly title?: string;
37
- /**
38
- * The default path, where the dialog opens. Requires an FS path.
39
- */
40
- readonly defaultPath?: string;
41
- /**
42
- * Resource filter.
43
- */
44
- readonly filters?: FileFilter[];
45
- }
46
- namespace dialog {
47
- /**
48
- * Converts the Theia specific `OpenFileDialogProps` into an electron specific array.
49
- *
50
- * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
51
- * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
52
- *
53
- * See: https://github.com/electron/electron/issues/10252#issuecomment-322012159
54
- */
55
- function toDialogProperties(props: OpenFileDialogProps): Array<DialogProperties>;
56
- }
57
- }
58
- export {};
59
19
  //# sourceMappingURL=electron-file-dialog-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"electron-file-dialog-service.d.ts","sourceRoot":"","sources":["../../../src/electron-browser/file-dialog/electron-file-dialog-service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAExG,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAI/G,aAAK,gBAAgB,GAAG,UAAU,GAAG,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,GACxF,iBAAiB,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,yBAAyB,GAAG,iBAAiB,CAAC;AAW9G,qBACa,yBAA0B,SAAQ,wBAAwB;IAE3C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAE3D,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG;QAAE,aAAa,EAAE,IAAI,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7H,cAAc,CAAC,KAAK,EAAE,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KAAK,EAAE,mBAAmB,GAAG,iBAAiB;CAyBzF"}
@@ -24,9 +24,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
24
24
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.electron = exports.ElectronFileDialogService = void 0;
27
+ exports.ElectronFileDialogService = void 0;
28
28
  const inversify_1 = require("@theia/core/shared/inversify");
29
- const electronRemote = require("@theia/core/electron-shared/@electron/remote");
30
29
  const os_1 = require("@theia/core/lib/common/os");
31
30
  const message_service_1 = require("@theia/core/lib/common/message-service");
32
31
  const filesystem_1 = require("../../common/filesystem");
@@ -43,10 +42,8 @@ let ElectronFileDialogService = class ElectronFileDialogService extends file_dia
43
42
  async showOpenDialog(props, folder) {
44
43
  const rootNode = await this.getRootNode(folder);
45
44
  if (rootNode) {
46
- const { filePaths } = props.modal !== false ?
47
- await electronRemote.dialog.showOpenDialog(electronRemote.getCurrentWindow(), this.toOpenDialogOptions(rootNode.uri, props)) :
48
- await electronRemote.dialog.showOpenDialog(this.toOpenDialogOptions(rootNode.uri, props));
49
- if (filePaths.length === 0) {
45
+ const filePaths = await window.electronTheiaFilesystem.showOpenDialog(this.toOpenDialogOptions(rootNode.uri, props));
46
+ if (!filePaths || filePaths.length === 0) {
50
47
  return undefined;
51
48
  }
52
49
  const uris = filePaths.map(path => file_uri_1.FileUri.create(path));
@@ -59,9 +56,7 @@ let ElectronFileDialogService = class ElectronFileDialogService extends file_dia
59
56
  async showSaveDialog(props, folder) {
60
57
  const rootNode = await this.getRootNode(folder);
61
58
  if (rootNode) {
62
- const { filePath } = props.modal !== false ?
63
- await electronRemote.dialog.showSaveDialog(electronRemote.getCurrentWindow(), this.toSaveDialogOptions(rootNode.uri, props)) :
64
- await electronRemote.dialog.showSaveDialog(this.toSaveDialogOptions(rootNode.uri, props));
59
+ const filePath = await window.electronTheiaFilesystem.showSaveDialog(this.toSaveDialogOptions(rootNode.uri, props));
65
60
  if (!filePath) {
66
61
  return undefined;
67
62
  }
@@ -97,46 +92,56 @@ let ElectronFileDialogService = class ElectronFileDialogService extends file_dia
97
92
  }
98
93
  return unreadableResourcePaths.length === 0;
99
94
  }
100
- toDialogOptions(uri, props, dialogTitle) {
101
- const electronProps = {
102
- title: props.title || dialogTitle,
103
- defaultPath: file_uri_1.FileUri.fsPath(uri),
104
- };
105
- const { canSelectFiles = true, canSelectFolders = false, } = props;
106
- if (!os_1.isOSX && canSelectFiles && canSelectFolders) {
107
- console.warn('canSelectFiles === true && canSelectFolders === true is only supported on OSX!');
95
+ toOpenDialogOptions(uri, props) {
96
+ if (!os_1.isOSX && props.canSelectFiles !== false && props.canSelectFolders === true) {
97
+ console.warn(`Cannot have 'canSelectFiles' and 'canSelectFolders' at the same time. Fallback to 'folder' dialog. \nProps was: ${JSON.stringify(props)}.`);
98
+ // Given that both props are set, fallback to using a `folder` dialog.
99
+ props.canSelectFiles = false;
100
+ props.canSelectFolders = true;
108
101
  }
109
- if ((os_1.isOSX && canSelectFiles) || !canSelectFolders) {
110
- electronProps.filters = props.filters ? Object.entries(props.filters).map(([name, extensions]) => ({ name, extensions })) : [];
111
- if (this.shouldAddAllFilesFilter(electronProps)) {
112
- electronProps.filters.push({ name: 'All Files', extensions: ['*'] });
102
+ const result = {
103
+ path: file_uri_1.FileUri.fsPath(uri)
104
+ };
105
+ result.title = props.title;
106
+ result.buttonLabel = props.openLabel;
107
+ result.maxWidth = props.maxWidth;
108
+ result.modal = props.modal;
109
+ result.openFiles = props.canSelectFiles;
110
+ result.openFolders = props.canSelectFolders;
111
+ result.selectMany = props.canSelectMany;
112
+ if (props.filters) {
113
+ result.filters = [];
114
+ const filters = Object.entries(props.filters);
115
+ for (const [label, extensions] of filters) {
116
+ result.filters.push({ name: label, extensions: extensions });
117
+ }
118
+ if (props.canSelectFiles) {
119
+ if (filters.length > 0) {
120
+ result.filters.push({ name: 'All Files', extensions: ['*'] });
121
+ }
113
122
  }
114
123
  }
115
- return electronProps;
116
- }
117
- /**
118
- * Specifies whether an _All Files_ filter should be added to the dialog.
119
- *
120
- * On Linux, the _All Files_ filter [hides](https://github.com/eclipse-theia/theia/issues/11321) files without an extension.
121
- * The bug is resolved in Electron >=18.
122
- */
123
- shouldAddAllFilesFilter(electronProps) {
124
- const foundFilters = !!electronProps.filters && electronProps.filters.length > 0;
125
- const isNotLinux = os_1.OS.type() !== os_1.OS.Type.Linux;
126
- return isNotLinux || foundFilters;
127
- }
128
- toOpenDialogOptions(uri, props) {
129
- const properties = electron.dialog.toDialogProperties(props);
130
- const buttonLabel = props.openLabel;
131
- return Object.assign(Object.assign({}, this.toDialogOptions(uri, props, 'Open')), { properties, buttonLabel });
124
+ return result;
132
125
  }
133
126
  toSaveDialogOptions(uri, props) {
134
- const buttonLabel = props.saveLabel;
135
127
  if (props.inputValue) {
136
128
  uri = uri.resolve(props.inputValue);
137
129
  }
138
- const defaultPath = file_uri_1.FileUri.fsPath(uri);
139
- return Object.assign(Object.assign({}, this.toDialogOptions(uri, props, 'Save')), { buttonLabel, defaultPath });
130
+ const result = {
131
+ path: file_uri_1.FileUri.fsPath(uri)
132
+ };
133
+ result.title = props.title;
134
+ result.buttonLabel = props.saveLabel;
135
+ result.maxWidth = props.maxWidth;
136
+ result.modal = props.modal;
137
+ if (props.filters) {
138
+ result.filters = [];
139
+ const filters = Object.entries(props.filters);
140
+ for (const [label, extensions] of filters) {
141
+ result.filters.push({ name: label, extensions: extensions });
142
+ }
143
+ }
144
+ return result;
140
145
  }
141
146
  };
142
147
  __decorate([
@@ -147,49 +152,4 @@ ElectronFileDialogService = __decorate([
147
152
  (0, inversify_1.injectable)()
148
153
  ], ElectronFileDialogService);
149
154
  exports.ElectronFileDialogService = ElectronFileDialogService;
150
- var electron;
151
- (function (electron) {
152
- let dialog;
153
- (function (dialog) {
154
- /**
155
- * Converts the Theia specific `OpenFileDialogProps` into an electron specific array.
156
- *
157
- * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
158
- * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
159
- *
160
- * See: https://github.com/electron/electron/issues/10252#issuecomment-322012159
161
- */
162
- function toDialogProperties(props) {
163
- if (!os_1.isOSX && props.canSelectFiles !== false && props.canSelectFolders === true) {
164
- console.warn(`Cannot have 'canSelectFiles' and 'canSelectFolders' at the same time. Fallback to 'folder' dialog. \nProps was: ${JSON.stringify(props)}.`);
165
- // Given that both props are set, fallback to using a `folder` dialog.
166
- props.canSelectFiles = false;
167
- props.canSelectFolders = true;
168
- }
169
- const properties = [];
170
- if (!os_1.isOSX) {
171
- if (props.canSelectFiles !== false && props.canSelectFolders !== true) {
172
- properties.push('openFile');
173
- }
174
- if (props.canSelectFolders === true && props.canSelectFiles === false) {
175
- properties.push('openDirectory');
176
- }
177
- }
178
- else {
179
- if (props.canSelectFiles !== false) {
180
- properties.push('openFile');
181
- }
182
- if (props.canSelectFolders === true) {
183
- properties.push('openDirectory');
184
- properties.push('createDirectory');
185
- }
186
- }
187
- if (props.canSelectMany === true) {
188
- properties.push('multiSelections');
189
- }
190
- return properties;
191
- }
192
- dialog.toDialogProperties = toDialogProperties;
193
- })(dialog = electron.dialog || (electron.dialog = {}));
194
- })(electron = exports.electron || (exports.electron = {}));
195
155
  //# sourceMappingURL=electron-file-dialog-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"electron-file-dialog-service.js","sourceRoot":"","sources":["../../../src/electron-browser/file-dialog/electron-file-dialog-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;AAEhF,4DAAkE;AAElE,+EAA+E;AAE/E,kDAAsD;AAEtD,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,CAAC,gBAAgB,KAAK,IAAI,EAAE;oBACnE,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBAC/B;gBACD,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI,IAAI,KAAK,CAAC,cAAc,KAAK,KAAK,EAAE;oBACnE,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;iBACpC;aACJ;iBAAM;gBACH,IAAI,KAAK,CAAC,cAAc,KAAK,KAAK,EAAE;oBAChC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBAC/B;gBACD,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI,EAAE;oBACjC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;oBACjC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBACtC;aACJ;YACD,IAAI,KAAK,CAAC,aAAa,KAAK,IAAI,EAAE;gBAC9B,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACtC;YACD,OAAO,UAAU,CAAC;QACtB,CAAC;QA7Be,yBAAkB,qBA6BjC,CAAA;IACL,CAAC,EAxCgB,MAAM,GAAN,eAAM,KAAN,eAAM,QAwCtB;AACL,CAAC,EAjEgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAiExB"}
1
+ {"version":3,"file":"electron-file-dialog-service.js","sourceRoot":"","sources":["../../../src/electron-browser/file-dialog/electron-file-dialog-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;;;;AAEhF,4DAAkE;AAElE,kDAAkD;AAElD,4EAAwE;AAExE,wDAAqD;AACrD,2DAA+G;AAC/G,EAAE;AACF,6F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C,OAAO,EAAE;YACf,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC9C,KAAK,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,OAAO,EAAE;gBACvC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;aAChE;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CAEJ,CAAA;AAhI2B;IAAvB,IAAA,kBAAM,EAAC,gCAAc,CAAC;8BAAoC,gCAAc;iEAAC;AAFjE,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAkIrC;AAlIY,8DAAyB"}
@@ -0,0 +1,2 @@
1
+ export declare function preload(): void;
2
+ //# sourceMappingURL=preload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preload.d.ts","sourceRoot":"","sources":["../../src/electron-browser/preload.ts"],"names":[],"mappings":"AAyBA,wBAAgB,OAAO,IAAI,IAAI,CAI9B"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preload = void 0;
4
+ // *****************************************************************************
5
+ // Copyright (C) 2023 STMicroelectronics and others.
6
+ //
7
+ // This program and the accompanying materials are made available under the
8
+ // terms of the Eclipse Public License v. 2.0 which is available at
9
+ // http://www.eclipse.org/legal/epl-2.0.
10
+ //
11
+ // This Source Code may also be made available under the following Secondary
12
+ // Licenses when the conditions for such availability set forth in the Eclipse
13
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
+ // with the GNU Classpath Exception which is available at
15
+ // https://www.gnu.org/software/classpath/license.html.
16
+ //
17
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
18
+ // *****************************************************************************
19
+ const electron_api_1 = require("../electron-common/electron-api");
20
+ // eslint-disable-next-line import/no-extraneous-dependencies
21
+ const electron_1 = require("@theia/core/electron-shared/electron");
22
+ const api = {
23
+ showOpenDialog: (options) => electron_1.ipcRenderer.invoke(electron_api_1.CHANNEL_SHOW_OPEN, options),
24
+ showSaveDialog: (options) => electron_1.ipcRenderer.invoke(electron_api_1.CHANNEL_SHOW_SAVE, options),
25
+ };
26
+ function preload() {
27
+ console.log('exposing theia filesystem electron api');
28
+ electron_1.contextBridge.exposeInMainWorld('electronTheiaFilesystem', api);
29
+ }
30
+ exports.preload = preload;
31
+ //# sourceMappingURL=preload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preload.js","sourceRoot":"","sources":["../../src/electron-browser/preload.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,kEAAiJ;AAEjJ,6DAA6D;AAC7D,mEAAkF;AAElF,MAAM,GAAG,GAAuB;IAC5B,cAAc,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC,sBAAW,CAAC,MAAM,CAAC,gCAAiB,EAAE,OAAO,CAAC;IAC9F,cAAc,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC,sBAAW,CAAC,MAAM,CAAC,gCAAiB,EAAE,OAAO,CAAC;CACjG,CAAC;AAEF,SAAgB,OAAO;IACnB,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IAEtD,wBAAa,CAAC,iBAAiB,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;AACpE,CAAC;AAJD,0BAIC"}
@@ -0,0 +1,35 @@
1
+ export interface FileFilter {
2
+ name: string;
3
+ extensions: string[];
4
+ }
5
+ export interface OpenDialogOptions {
6
+ title?: string;
7
+ maxWidth?: number;
8
+ path: string;
9
+ buttonLabel?: string;
10
+ modal?: boolean;
11
+ openFiles?: boolean;
12
+ openFolders?: boolean;
13
+ selectMany?: boolean;
14
+ filters?: FileFilter[];
15
+ }
16
+ export interface SaveDialogOptions {
17
+ title?: string;
18
+ maxWidth?: number;
19
+ path: string;
20
+ buttonLabel?: string;
21
+ modal?: boolean;
22
+ filters?: FileFilter[];
23
+ }
24
+ export interface TheiaFilesystemAPI {
25
+ showOpenDialog(options: OpenDialogOptions): Promise<string[] | undefined>;
26
+ showSaveDialog(options: SaveDialogOptions): Promise<string | undefined>;
27
+ }
28
+ declare global {
29
+ interface Window {
30
+ electronTheiaFilesystem: TheiaFilesystemAPI;
31
+ }
32
+ }
33
+ export declare const CHANNEL_SHOW_OPEN = "ShowOpenDialog";
34
+ export declare const CHANNEL_SHOW_SAVE = "ShowSaveDialog";
35
+ //# sourceMappingURL=electron-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electron-api.d.ts","sourceRoot":"","sources":["../../src/electron-common/electron-api.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAC/B,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IAC1E,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC3E;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,uBAAuB,EAAE,kBAAkB,CAAA;KAC9C;CACJ;AAED,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAClD,eAAO,MAAM,iBAAiB,mBAAmB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 STMicroelectronics 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CHANNEL_SHOW_SAVE = exports.CHANNEL_SHOW_OPEN = void 0;
19
+ exports.CHANNEL_SHOW_OPEN = 'ShowOpenDialog';
20
+ exports.CHANNEL_SHOW_SAVE = 'ShowSaveDialog';
21
+ //# sourceMappingURL=electron-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electron-api.js","sourceRoot":"","sources":["../../src/electron-common/electron-api.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;AAuCnE,QAAA,iBAAiB,GAAG,gBAAgB,CAAC;AACrC,QAAA,iBAAiB,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ElectronMainApplication, ElectronMainApplicationContribution } from '@theia/core/lib/electron-main/electron-main-application';
2
+ import { MaybePromise } from '@theia/core';
3
+ export declare class ElectronApi implements ElectronMainApplicationContribution {
4
+ onStart(application: ElectronMainApplication): MaybePromise<void>;
5
+ }
6
+ //# sourceMappingURL=electron-api-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electron-api-main.d.ts","sourceRoot":"","sources":["../../src/electron-main/electron-api-main.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,uBAAuB,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,qBACa,WAAY,YAAW,mCAAmC;IACnE,OAAO,CAAC,WAAW,EAAE,uBAAuB,GAAG,YAAY,CAAC,IAAI,CAAC;CAmDpE"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 STMicroelectronics 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ 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;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.ElectronApi = void 0;
25
+ const inversify_1 = require("@theia/core/shared/inversify");
26
+ const electron_api_1 = require("../electron-common/electron-api");
27
+ const electron_1 = require("@theia/core/electron-shared/electron");
28
+ let ElectronApi = class ElectronApi {
29
+ onStart(application) {
30
+ // dialogs
31
+ electron_1.ipcMain.handle(electron_api_1.CHANNEL_SHOW_OPEN, async (event, options) => {
32
+ const properties = [];
33
+ // checking proper combination of file/dir opening is done on the renderer side
34
+ if (options.openFiles) {
35
+ properties.push('openFile');
36
+ }
37
+ if (options.openFolders) {
38
+ properties.push('openDirectory');
39
+ }
40
+ if (options.selectMany === true) {
41
+ properties.push('multiSelections');
42
+ }
43
+ const dialogOpts = {
44
+ defaultPath: options.path,
45
+ buttonLabel: options.buttonLabel,
46
+ filters: options.filters,
47
+ title: options.title,
48
+ properties: properties
49
+ };
50
+ if (options.modal) {
51
+ const win = electron_1.BrowserWindow.fromWebContents(event.sender);
52
+ if (win) {
53
+ return (await electron_1.dialog.showOpenDialog(win, dialogOpts)).filePaths;
54
+ }
55
+ }
56
+ return (await electron_1.dialog.showOpenDialog(dialogOpts)).filePaths;
57
+ });
58
+ electron_1.ipcMain.handle(electron_api_1.CHANNEL_SHOW_SAVE, async (event, options) => {
59
+ const dialogOpts = {
60
+ defaultPath: options.path,
61
+ buttonLabel: options.buttonLabel,
62
+ filters: options.filters,
63
+ title: options.title
64
+ };
65
+ if (options.modal) {
66
+ const win = electron_1.BrowserWindow.fromWebContents(event.sender);
67
+ if (win) {
68
+ return (await electron_1.dialog.showSaveDialog(win, dialogOpts)).filePath;
69
+ }
70
+ }
71
+ return (await electron_1.dialog.showSaveDialog(dialogOpts)).filePath;
72
+ });
73
+ }
74
+ };
75
+ ElectronApi = __decorate([
76
+ (0, inversify_1.injectable)()
77
+ ], ElectronApi);
78
+ exports.ElectronApi = ElectronApi;
79
+ //# sourceMappingURL=electron-api-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electron-api-main.js","sourceRoot":"","sources":["../../src/electron-main/electron-api-main.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;;;;;;;;;AAEhF,4DAA0D;AAI1D,kEAA6H;AAC7H,mEACgD;AAGhD,IAAa,WAAW,GAAxB,MAAa,WAAW;IACpB,OAAO,CAAC,WAAoC;QACxC,UAAU;QACV,kBAAO,CAAC,MAAM,CAAC,gCAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,OAA0B,EAAE,EAAE;YAC1E,MAAM,UAAU,GAA4C,EAAE,CAAC;YAE/D,+EAA+E;YAC/E,IAAI,OAAO,CAAC,SAAS,EAAE;gBACnB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aAC/B;YACD,IAAI,OAAO,CAAC,WAAW,EAAE;gBACrB,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aACpC;YAED,IAAI,OAAO,CAAC,UAAU,KAAK,IAAI,EAAE;gBA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AQ,CAAC;QAC9D,CAAC,CAAC,CAAC;IAEP,CAAC;CACJ,CAAA;AApDY,WAAW;IADvB,IAAA,sBAAU,GAAE;GACA,WAAW,CAoDvB;AApDY,kCAAW"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=electron-main-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electron-main-module.d.ts","sourceRoot":"","sources":["../../src/electron-main/electron-main-module.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAI/D,wBAGG"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // *****************************************************************************
4
+ // Copyright (C) 2023 STMicroelectronics and others.
5
+ //
6
+ // This program and the accompanying materials are made available under the
7
+ // terms of the Eclipse Public License v. 2.0 which is available at
8
+ // http://www.eclipse.org/legal/epl-2.0.
9
+ //
10
+ // This Source Code may also be made available under the following Secondary
11
+ // Licenses when the conditions for such availability set forth in the Eclipse
12
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
13
+ // with the GNU Classpath Exception which is available at
14
+ // https://www.gnu.org/software/classpath/license.html.
15
+ //
16
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17
+ // *****************************************************************************
18
+ const inversify_1 = require("@theia/core/shared/inversify");
19
+ const electron_main_application_1 = require("@theia/core/lib/electron-main/electron-main-application");
20
+ const electron_api_main_1 = require("./electron-api-main");
21
+ exports.default = new inversify_1.ContainerModule(bind => {
22
+ bind(electron_api_main_1.ElectronApi).toSelf().inSingletonScope();
23
+ bind(electron_main_application_1.ElectronMainApplicationContribution).toService(electron_api_main_1.ElectronApi);
24
+ });
25
+ //# sourceMappingURL=electron-main-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electron-main-module.js","sourceRoot":"","sources":["../../src/electron-main/electron-main-module.ts"],"names":[],"mappings":";;AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,4DAA+D;AAC/D,uGAA8G;AAC9G,2DAAkD;AAElD,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,+BAAW,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC9C,IAAI,CAAC,+DAAmC,CAAC,CAAC,SAAS,CAAC,+BAAW,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/filesystem",
3
- "version": "1.37.0-next.16+a71f64e27",
3
+ "version": "1.37.0-next.18+a9471e7af",
4
4
  "description": "Theia - FileSystem Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.37.0-next.16+a71f64e27",
6
+ "@theia/core": "1.37.0-next.18+a9471e7af",
7
7
  "@types/body-parser": "^1.17.0",
8
8
  "@types/multer": "^1.4.7",
9
9
  "@types/rimraf": "^2.0.2",
@@ -24,6 +24,10 @@
24
24
  "access": "public"
25
25
  },
26
26
  "theiaExtensions": [
27
+ {
28
+ "preload": "lib/electron-browser/preload",
29
+ "electronMain": "lib/electron-main/electron-main-module"
30
+ },
27
31
  {
28
32
  "frontend": "lib/browser/filesystem-frontend-module",
29
33
  "backend": "lib/node/filesystem-backend-module"
@@ -68,5 +72,5 @@
68
72
  "nyc": {
69
73
  "extends": "../../configs/nyc.json"
70
74
  },
71
- "gitHead": "a71f64e279de001beb4e6e71a4448c1234199437"
75
+ "gitHead": "a9471e7af5168f59b57bd398d715743a6c72f6ff"
72
76
  }
@@ -15,21 +15,13 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { inject, injectable } from '@theia/core/shared/inversify';
18
- import { FileFilter, OpenDialogOptions, SaveDialogOptions } from '@theia/core/electron-shared/electron';
19
- import * as electronRemote from '@theia/core/electron-shared/@electron/remote';
20
18
  import URI from '@theia/core/lib/common/uri';
21
- import { isOSX, OS } from '@theia/core/lib/common/os';
19
+ import { isOSX } from '@theia/core/lib/common/os';
22
20
  import { MaybeArray } from '@theia/core/lib/common/types';
23
21
  import { MessageService } from '@theia/core/lib/common/message-service';
24
22
  import { FileStat } from '../../common/files';
25
23
  import { FileAccess } from '../../common/filesystem';
26
24
  import { DefaultFileDialogService, OpenFileDialogProps, SaveFileDialogProps } from '../../browser/file-dialog';
27
-
28
- // See https://github.com/electron/electron/blob/v9.0.2/docs/api/dialog.md
29
- // These properties get extended with newer versions of Electron
30
- type DialogProperties = 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' |
31
- 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory' | 'dontAddToRecent';
32
-
33
25
  //
34
26
  // We are OK to use this here because the electron backend and frontend are on the same host.
35
27
  // If required, we can move this single service (and its module) to a dedicated Theia extension,
@@ -38,6 +30,7 @@ type DialogProperties = 'openFile' | 'openDirectory' | 'multiSelections' | 'show
38
30
  //
39
31
  // eslint-disable-next-line @theia/runtime-import-check
40
32
  import { FileUri } from '@theia/core/lib/node/file-uri';
33
+ import { OpenDialogOptions, SaveDialogOptions } from '../../electron-common/electron-api';
41
34
 
42
35
  @injectable()
43
36
  export class ElectronFileDialogService extends DefaultFileDialogService {
@@ -49,10 +42,8 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
49
42
  override async showOpenDialog(props: OpenFileDialogProps, folder?: FileStat): Promise<MaybeArray<URI> | undefined> {
50
43
  const rootNode = await this.getRootNode(folder);
51
44
  if (rootNode) {
52
- const { filePaths } = props.modal !== false ?
53
- await electronRemote.dialog.showOpenDialog(electronRemote.getCurrentWindow(), this.toOpenDialogOptions(rootNode.uri, props)) :
54
- await electronRemote.dialog.showOpenDialog(this.toOpenDialogOptions(rootNode.uri, props));
55
- if (filePaths.length === 0) {
45
+ const filePaths = await window.electronTheiaFilesystem.showOpenDialog(this.toOpenDialogOptions(rootNode.uri, props));
46
+ if (!filePaths || filePaths.length === 0) {
56
47
  return undefined;
57
48
  }
58
49
 
@@ -67,9 +58,8 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
67
58
  override async showSaveDialog(props: SaveFileDialogProps, folder?: FileStat): Promise<URI | undefined> {
68
59
  const rootNode = await this.getRootNode(folder);
69
60
  if (rootNode) {
70
- const { filePath } = props.modal !== false ?
71
- await electronRemote.dialog.showSaveDialog(electronRemote.getCurrentWindow(), this.toSaveDialogOptions(rootNode.uri, props)) :
72
- await electronRemote.dialog.showSaveDialog(this.toSaveDialogOptions(rootNode.uri, props));
61
+ const filePath = await window.electronTheiaFilesystem.showSaveDialog(this.toSaveDialogOptions(rootNode.uri, props));
62
+
73
63
  if (!filePath) {
74
64
  return undefined;
75
65
  }
@@ -110,120 +100,67 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
110
100
  return unreadableResourcePaths.length === 0;
111
101
  }
112
102
 
113
- protected toDialogOptions(uri: URI, props: SaveFileDialogProps | OpenFileDialogProps, dialogTitle: string): electron.FileDialogProps {
114
- type Mutable<T> = { -readonly [K in keyof T]: T[K] };
115
- const electronProps: Mutable<electron.FileDialogProps> = {
116
- title: props.title || dialogTitle,
117
- defaultPath: FileUri.fsPath(uri),
118
- };
119
- const {
120
- canSelectFiles = true,
121
- canSelectFolders = false,
122
- } = props as OpenFileDialogProps;
123
- if (!isOSX && canSelectFiles && canSelectFolders) {
124
- console.warn('canSelectFiles === true && canSelectFolders === true is only supported on OSX!');
103
+ protected toOpenDialogOptions(uri: URI, props: OpenFileDialogProps): OpenDialogOptions {
104
+ if (!isOSX && props.canSelectFiles !== false && props.canSelectFolders === true) {
105
+ console.warn(`Cannot have 'canSelectFiles' and 'canSelectFolders' at the same time. Fallback to 'folder' dialog. \nProps was: ${JSON.stringify(props)}.`);
106
+
107
+ // Given that both props are set, fallback to using a `folder` dialog.
108
+ props.canSelectFiles = false;
109
+ props.canSelectFolders = true;
125
110
  }
126
- if ((isOSX && canSelectFiles) || !canSelectFolders) {
127
- electronProps.filters = props.filters ? Object.entries(props.filters).map(([name, extensions]) => ({ name, extensions })) : [];
128
- if (this.shouldAddAllFilesFilter(electronProps)) {
129
- electronProps.filters.push({ name: 'All Files', extensions: ['*'] });
111
+
112
+ const result: OpenDialogOptions = {
113
+ path: FileUri.fsPath(uri)
114
+ };
115
+
116
+ result.title = props.title;
117
+ result.buttonLabel = props.openLabel;
118
+ result.maxWidth = props.maxWidth;
119
+ result.modal = props.modal;
120
+ result.openFiles = props.canSelectFiles;
121
+ result.openFolders = props.canSelectFolders;
122
+ result.selectMany = props.canSelectMany;
123
+
124
+ if (props.filters) {
125
+ result.filters = [];
126
+ const filters = Object.entries(props.filters);
127
+ for (const [label, extensions] of filters) {
128
+ result.filters.push({ name: label, extensions: extensions });
130
129
  }
131
- }
132
- return electronProps;
133
- }
134
130
 
135
- /**
136
- * Specifies whether an _All Files_ filter should be added to the dialog.
137
- *
138
- * On Linux, the _All Files_ filter [hides](https://github.com/eclipse-theia/theia/issues/11321) files without an extension.
139
- * The bug is resolved in Electron >=18.
140
- */
141
- protected shouldAddAllFilesFilter(electronProps: electron.FileDialogProps): boolean {
142
- const foundFilters = !!electronProps.filters && electronProps.filters.length > 0;
143
- const isNotLinux = OS.type() !== OS.Type.Linux;
144
- return isNotLinux || foundFilters;
145
- }
131
+ if (props.canSelectFiles) {
132
+ if (filters.length > 0) {
133
+ result.filters.push({ name: 'All Files', extensions: ['*'] });
134
+ }
135
+ }
136
+ }
146
137
 
147
- protected toOpenDialogOptions(uri: URI, props: OpenFileDialogProps): OpenDialogOptions {
148
- const properties = electron.dialog.toDialogProperties(props);
149
- const buttonLabel = props.openLabel;
150
- return { ...this.toDialogOptions(uri, props, 'Open'), properties, buttonLabel };
138
+ return result;
151
139
  }
152
140
 
153
141
  protected toSaveDialogOptions(uri: URI, props: SaveFileDialogProps): SaveDialogOptions {
154
- const buttonLabel = props.saveLabel;
155
142
  if (props.inputValue) {
156
143
  uri = uri.resolve(props.inputValue);
157
144
  }
158
- const defaultPath = FileUri.fsPath(uri);
159
- return { ...this.toDialogOptions(uri, props, 'Save'), buttonLabel, defaultPath };
160
- }
161
145
 
162
- }
163
-
164
- export namespace electron {
165
-
166
- /**
167
- * Common "super" interface of the `electron.SaveDialogOptions` and `electron.OpenDialogOptions` types.
168
- */
169
- export interface FileDialogProps {
170
-
171
- /**
172
- * The dialog title.
173
- */
174
- readonly title?: string;
175
-
176
- /**
177
- * The default path, where the dialog opens. Requires an FS path.
178
- */
179
- readonly defaultPath?: string;
180
-
181
- /**
182
- * Resource filter.
183
- */
184
- readonly filters?: FileFilter[];
146
+ const result: SaveDialogOptions = {
147
+ path: FileUri.fsPath(uri)
148
+ };
185
149
 
186
- }
150
+ result.title = props.title;
151
+ result.buttonLabel = props.saveLabel;
152
+ result.maxWidth = props.maxWidth;
153
+ result.modal = props.modal;
187
154
 
188
- export namespace dialog {
189
-
190
- /**
191
- * Converts the Theia specific `OpenFileDialogProps` into an electron specific array.
192
- *
193
- * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector,
194
- * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown.
195
- *
196
- * See: https://github.com/electron/electron/issues/10252#issuecomment-322012159
197
- */
198
- export function toDialogProperties(props: OpenFileDialogProps): Array<DialogProperties> {
199
- if (!isOSX && props.canSelectFiles !== false && props.canSelectFolders === true) {
200
- console.warn(`Cannot have 'canSelectFiles' and 'canSelectFolders' at the same time. Fallback to 'folder' dialog. \nProps was: ${JSON.stringify(props)}.`);
201
-
202
- // Given that both props are set, fallback to using a `folder` dialog.
203
- props.canSelectFiles = false;
204
- props.canSelectFolders = true;
155
+ if (props.filters) {
156
+ result.filters = [];
157
+ const filters = Object.entries(props.filters);
158
+ for (const [label, extensions] of filters) {
159
+ result.filters.push({ name: label, extensions: extensions });
205
160
  }
206
- const properties: Array<DialogProperties> = [];
207
- if (!isOSX) {
208
- if (props.canSelectFiles !== false && props.canSelectFolders !== true) {
209
- properties.push('openFile');
210
- }
211
- if (props.canSelectFolders === true && props.canSelectFiles === false) {
212
- properties.push('openDirectory');
213
- }
214
- } else {
215
- if (props.canSelectFiles !== false) {
216
- properties.push('openFile');
217
- }
218
- if (props.canSelectFolders === true) {
219
- properties.push('openDirectory');
220
- properties.push('createDirectory');
221
- }
222
- }
223
- if (props.canSelectMany === true) {
224
- properties.push('multiSelections');
225
- }
226
- return properties;
227
161
  }
162
+
163
+ return result;
228
164
  }
165
+
229
166
  }
@@ -0,0 +1,30 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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
+ import { CHANNEL_SHOW_OPEN, CHANNEL_SHOW_SAVE, OpenDialogOptions, SaveDialogOptions, TheiaFilesystemAPI } from '../electron-common/electron-api';
17
+
18
+ // eslint-disable-next-line import/no-extraneous-dependencies
19
+ import { ipcRenderer, contextBridge } from '@theia/core/electron-shared/electron';
20
+
21
+ const api: TheiaFilesystemAPI = {
22
+ showOpenDialog: (options: OpenDialogOptions) => ipcRenderer.invoke(CHANNEL_SHOW_OPEN, options),
23
+ showSaveDialog: (options: SaveDialogOptions) => ipcRenderer.invoke(CHANNEL_SHOW_SAVE, options),
24
+ };
25
+
26
+ export function preload(): void {
27
+ console.log('exposing theia filesystem electron api');
28
+
29
+ contextBridge.exposeInMainWorld('electronTheiaFilesystem', api);
30
+ }
@@ -0,0 +1,55 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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
+ export interface FileFilter {
18
+ name: string;
19
+ extensions: string[];
20
+ }
21
+
22
+ export interface OpenDialogOptions {
23
+ title?: string,
24
+ maxWidth?: number,
25
+ path: string,
26
+ buttonLabel?: string,
27
+ modal?: boolean,
28
+ openFiles?: boolean,
29
+ openFolders?: boolean;
30
+ selectMany?: boolean;
31
+ filters?: FileFilter[];
32
+ }
33
+
34
+ export interface SaveDialogOptions {
35
+ title?: string,
36
+ maxWidth?: number,
37
+ path: string,
38
+ buttonLabel?: string,
39
+ modal?: boolean,
40
+ filters?: FileFilter[];
41
+ }
42
+
43
+ export interface TheiaFilesystemAPI {
44
+ showOpenDialog(options: OpenDialogOptions): Promise<string[] | undefined>;
45
+ showSaveDialog(options: SaveDialogOptions): Promise<string | undefined>;
46
+ }
47
+
48
+ declare global {
49
+ interface Window {
50
+ electronTheiaFilesystem: TheiaFilesystemAPI
51
+ }
52
+ }
53
+
54
+ export const CHANNEL_SHOW_OPEN = 'ShowOpenDialog';
55
+ export const CHANNEL_SHOW_SAVE = 'ShowSaveDialog';
@@ -0,0 +1,78 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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 { injectable } from '@theia/core/shared/inversify';
18
+
19
+ import { ElectronMainApplication, ElectronMainApplicationContribution } from '@theia/core/lib/electron-main/electron-main-application';
20
+ import { MaybePromise } from '@theia/core';
21
+ import { CHANNEL_SHOW_OPEN, CHANNEL_SHOW_SAVE, OpenDialogOptions, SaveDialogOptions } from '../electron-common/electron-api';
22
+ import { ipcMain, OpenDialogOptions as ElectronOpenDialogOptions, SaveDialogOptions as ElectronSaveDialogOptions, BrowserWindow, dialog }
23
+ from '@theia/core/electron-shared/electron';
24
+
25
+ @injectable()
26
+ export class ElectronApi implements ElectronMainApplicationContribution {
27
+ onStart(application: ElectronMainApplication): MaybePromise<void> {
28
+ // dialogs
29
+ ipcMain.handle(CHANNEL_SHOW_OPEN, async (event, options: OpenDialogOptions) => {
30
+ const properties: ElectronOpenDialogOptions['properties'] = [];
31
+
32
+ // checking proper combination of file/dir opening is done on the renderer side
33
+ if (options.openFiles) {
34
+ properties.push('openFile');
35
+ }
36
+ if (options.openFolders) {
37
+ properties.push('openDirectory');
38
+ }
39
+
40
+ if (options.selectMany === true) {
41
+ properties.push('multiSelections');
42
+ }
43
+
44
+ const dialogOpts: ElectronOpenDialogOptions = {
45
+ defaultPath: options.path,
46
+ buttonLabel: options.buttonLabel,
47
+ filters: options.filters,
48
+ title: options.title,
49
+ properties: properties
50
+ };
51
+
52
+ if (options.modal) {
53
+ const win = BrowserWindow.fromWebContents(event.sender);
54
+ if (win) {
55
+ return (await dialog.showOpenDialog(win, dialogOpts)).filePaths;
56
+ }
57
+ }
58
+ return (await dialog.showOpenDialog(dialogOpts)).filePaths;
59
+ });
60
+
61
+ ipcMain.handle(CHANNEL_SHOW_SAVE, async (event, options: SaveDialogOptions) => {
62
+ const dialogOpts: ElectronSaveDialogOptions = {
63
+ defaultPath: options.path,
64
+ buttonLabel: options.buttonLabel,
65
+ filters: options.filters,
66
+ title: options.title
67
+ };
68
+ if (options.modal) {
69
+ const win = BrowserWindow.fromWebContents(event.sender);
70
+ if (win) {
71
+ return (await dialog.showSaveDialog(win, dialogOpts)).filePath;
72
+ }
73
+ }
74
+ return (await dialog.showSaveDialog(dialogOpts)).filePath;
75
+ });
76
+
77
+ }
78
+ }
@@ -0,0 +1,23 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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
+ import { ContainerModule } from '@theia/core/shared/inversify';
17
+ import { ElectronMainApplicationContribution } from '@theia/core/lib/electron-main/electron-main-application';
18
+ import { ElectronApi } from './electron-api-main';
19
+
20
+ export default new ContainerModule(bind => {
21
+ bind(ElectronApi).toSelf().inSingletonScope();
22
+ bind(ElectronMainApplicationContribution).toService(ElectronApi);
23
+ });