@codingame/monaco-vscode-dialogs-service-override 25.1.2 → 26.0.0

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.
@@ -28,11 +28,10 @@ class FileDialogService extends AbstractFileDialogService {
28
28
  if (this.shouldUseSimplified(schema)) {
29
29
  return super.pickFileFolderAndOpenSimplified(schema, options, false);
30
30
  }
31
- throw ( new Error(( localize(13855, "Can't open folders, try adding a folder to the workspace instead."))));
31
+ throw ( new Error(( localize(14242, "Can't open folders, try adding a folder to the workspace instead."))));
32
32
  }
33
33
  addFileSchemaIfNeeded(schema, isFolder) {
34
- return (schema === Schemas.untitled) ? [Schemas.file]
35
- : (((schema !== Schemas.file) && (!isFolder || (schema !== Schemas.vscodeRemote))) ? [schema, Schemas.file] : [schema]);
34
+ return (schema === Schemas.untitled) ? [Schemas.file] : (((schema !== Schemas.file) && (!isFolder || (schema !== Schemas.vscodeRemote))) ? [schema, Schemas.file] : [schema]);
36
35
  }
37
36
  async pickFileAndOpen(options) {
38
37
  const schema = this.getFileSystemSchema(options);
@@ -44,13 +43,14 @@ class FileDialogService extends AbstractFileDialogService {
44
43
  }
45
44
  const activeWindow = getActiveWindow();
46
45
  if (!WebFileSystemAccess.supported(activeWindow)) {
47
- return this.showUnsupportedBrowserWarning('open');
46
+ return this.showUnsupportedBrowserWarning("open");
48
47
  }
49
48
  let fileHandle = undefined;
50
49
  try {
51
- ([fileHandle] = await activeWindow.showOpenFilePicker({ multiple: false }));
52
- }
53
- catch (error) {
50
+ ([fileHandle] = await activeWindow.showOpenFilePicker({
51
+ multiple: false
52
+ }));
53
+ } catch (error) {
54
54
  return;
55
55
  }
56
56
  if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
@@ -58,7 +58,12 @@ class FileDialogService extends AbstractFileDialogService {
58
58
  }
59
59
  const uri = await this.fileSystemProvider.registerFileHandle(fileHandle);
60
60
  this.addFileToRecentlyOpened(uri);
61
- await this.openerService.open(uri, { fromUserGesture: true, editorOptions: { pinned: true } });
61
+ await this.openerService.open(uri, {
62
+ fromUserGesture: true,
63
+ editorOptions: {
64
+ pinned: true
65
+ }
66
+ });
62
67
  }
63
68
  async pickFolderAndOpen(options) {
64
69
  const schema = this.getFileSystemSchema(options);
@@ -68,7 +73,7 @@ class FileDialogService extends AbstractFileDialogService {
68
73
  if (this.shouldUseSimplified(schema)) {
69
74
  return super.pickFolderAndOpenSimplified(schema, options);
70
75
  }
71
- throw ( new Error(( localize(13855, "Can't open folders, try adding a folder to the workspace instead."))));
76
+ throw ( new Error(( localize(14242, "Can't open folders, try adding a folder to the workspace instead."))));
72
77
  }
73
78
  async pickWorkspaceAndOpen(options) {
74
79
  options.availableFileSystems = this.getWorkspaceAvailableFileSystems(options);
@@ -80,26 +85,34 @@ class FileDialogService extends AbstractFileDialogService {
80
85
  return super.pickWorkspaceAndOpenSimplified(schema, options);
81
86
  }
82
87
  throw ( new Error(( localize(
83
- 13856,
88
+ 14243,
84
89
  "Can't open workspaces, try adding a folder to the workspace instead."
85
90
  ))));
86
91
  }
87
92
  async pickFileToSave(defaultUri, availableFileSystems) {
88
- const schema = this.getFileSystemSchema({ defaultUri, availableFileSystems });
93
+ const schema = this.getFileSystemSchema({
94
+ defaultUri,
95
+ availableFileSystems
96
+ });
89
97
  const options = this.getPickFileToSaveDialogOptions(defaultUri, availableFileSystems);
90
98
  if (this.shouldUseSimplified(schema)) {
91
99
  return super.pickFileToSaveSimplified(schema, options);
92
100
  }
93
101
  const activeWindow = getActiveWindow();
94
102
  if (!WebFileSystemAccess.supported(activeWindow)) {
95
- return this.showUnsupportedBrowserWarning('save');
103
+ return this.showUnsupportedBrowserWarning("save");
96
104
  }
97
105
  let fileHandle = undefined;
98
106
  const startIn = Iterable.first(this.fileSystemProvider.directories);
99
107
  try {
100
- fileHandle = await activeWindow.showSaveFilePicker({ types: this.getFilePickerTypes(options.filters), ...{ suggestedName: basename(defaultUri), startIn } });
101
- }
102
- catch (error) {
108
+ fileHandle = await activeWindow.showSaveFilePicker({
109
+ types: this.getFilePickerTypes(options.filters),
110
+ ...{
111
+ suggestedName: basename(defaultUri),
112
+ startIn
113
+ }
114
+ });
115
+ } catch (error) {
103
116
  return;
104
117
  }
105
118
  if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
@@ -109,11 +122,13 @@ class FileDialogService extends AbstractFileDialogService {
109
122
  }
110
123
  getFilePickerTypes(filters) {
111
124
  return filters?.filter(filter => {
112
- return !((filter.extensions.length === 1) && ((filter.extensions[0] === '*') || filter.extensions[0] === ''));
113
- }).map((filter) => {
125
+ return !((filter.extensions.length === 1) && ((filter.extensions[0] === "*") || filter.extensions[0] === ""));
126
+ }).map(filter => {
114
127
  const accept = {};
115
- const extensions = filter.extensions.filter(ext => (ext.indexOf('-') < 0) && (ext.indexOf('*') < 0) && (ext.indexOf('_') < 0));
116
- accept[(getMediaOrTextMime(`fileName.${filter.extensions[0]}`) ?? 'text/plain')] = ( extensions.map(ext => ext.startsWith('.') ? ext : `.${ext}`));
128
+ const extensions = filter.extensions.filter(
129
+ ext => (ext.indexOf("-") < 0) && (ext.indexOf("*") < 0) && (ext.indexOf("_") < 0)
130
+ );
131
+ accept[(getMediaOrTextMime(`fileName.${filter.extensions[0]}`) ?? "text/plain")] = ( extensions.map(ext => ext.startsWith(".") ? ext : `.${ext}`));
117
132
  return {
118
133
  description: filter.name,
119
134
  accept
@@ -127,14 +142,21 @@ class FileDialogService extends AbstractFileDialogService {
127
142
  }
128
143
  const activeWindow = getActiveWindow();
129
144
  if (!WebFileSystemAccess.supported(activeWindow)) {
130
- return this.showUnsupportedBrowserWarning('save');
145
+ return this.showUnsupportedBrowserWarning("save");
131
146
  }
132
147
  let fileHandle = undefined;
133
148
  const startIn = Iterable.first(this.fileSystemProvider.directories);
134
149
  try {
135
- fileHandle = await activeWindow.showSaveFilePicker({ types: this.getFilePickerTypes(options.filters), ...(options.defaultUri ? { suggestedName: basename(options.defaultUri) } : undefined), ...{ startIn } });
136
- }
137
- catch (error) {
150
+ fileHandle = await activeWindow.showSaveFilePicker({
151
+ types: this.getFilePickerTypes(options.filters),
152
+ ...(options.defaultUri ? {
153
+ suggestedName: basename(options.defaultUri)
154
+ } : undefined),
155
+ ...{
156
+ startIn
157
+ }
158
+ });
159
+ } catch (error) {
138
160
  return undefined;
139
161
  }
140
162
  if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
@@ -149,50 +171,61 @@ class FileDialogService extends AbstractFileDialogService {
149
171
  }
150
172
  const activeWindow = getActiveWindow();
151
173
  if (!WebFileSystemAccess.supported(activeWindow)) {
152
- return this.showUnsupportedBrowserWarning('open');
174
+ return this.showUnsupportedBrowserWarning("open");
153
175
  }
154
176
  let uri;
155
- const startIn = Iterable.first(this.fileSystemProvider.directories) ?? 'documents';
177
+ const startIn = Iterable.first(this.fileSystemProvider.directories) ?? "documents";
156
178
  try {
157
179
  if (options.canSelectFiles) {
158
- const handle = await activeWindow.showOpenFilePicker({ multiple: false, types: this.getFilePickerTypes(options.filters), ...{ startIn } });
180
+ const handle = await activeWindow.showOpenFilePicker({
181
+ multiple: false,
182
+ types: this.getFilePickerTypes(options.filters),
183
+ ...{
184
+ startIn
185
+ }
186
+ });
159
187
  if (handle.length === 1 && WebFileSystemAccess.isFileSystemFileHandle(handle[0])) {
160
188
  uri = await this.fileSystemProvider.registerFileHandle(handle[0]);
161
189
  }
162
- }
163
- else {
164
- const handle = await activeWindow.showDirectoryPicker({ ...{ startIn } });
190
+ } else {
191
+ const handle = await activeWindow.showDirectoryPicker({
192
+ ...{
193
+ startIn
194
+ }
195
+ });
165
196
  uri = await this.fileSystemProvider.registerDirectoryHandle(handle);
166
197
  }
167
- }
168
- catch (error) {
169
- }
198
+ } catch (error) {}
170
199
  return uri ? [uri] : undefined;
171
200
  }
172
201
  async showUnsupportedBrowserWarning(context) {
173
- if (context === 'save') {
202
+ if (context === "save") {
174
203
  const activeCodeEditor = this.codeEditorService.getActiveCodeEditor();
175
204
  if (!(activeCodeEditor instanceof EmbeddedCodeEditorWidget)) {
176
205
  const activeTextModel = activeCodeEditor?.getModel();
177
206
  if (activeTextModel) {
178
- triggerDownload(VSBuffer.fromString(activeTextModel.getValue()).buffer, basename(activeTextModel.uri));
207
+ triggerDownload(
208
+ VSBuffer.fromString(activeTextModel.getValue()).buffer,
209
+ basename(activeTextModel.uri)
210
+ );
179
211
  return;
180
212
  }
181
213
  }
182
214
  }
183
- const buttons = [
184
- {
185
- label: ( localize(13857, "&&Open Remote...")),
186
- run: async () => { await this.commandService.executeCommand('workbench.action.remote.showMenu'); }
187
- },
188
- {
189
- label: ( localize(13858, "&&Learn More")),
190
- run: async () => { await this.openerService.open('https://aka.ms/VSCodeWebLocalFileSystemAccess'); }
215
+ const buttons = [{
216
+ label: ( localize(14244, "&&Open Remote...")),
217
+ run: async () => {
218
+ await this.commandService.executeCommand("workbench.action.remote.showMenu");
219
+ }
220
+ }, {
221
+ label: ( localize(14245, "&&Learn More")),
222
+ run: async () => {
223
+ await this.openerService.open("https://aka.ms/VSCodeWebLocalFileSystemAccess");
191
224
  }
192
- ];
193
- if (context === 'open') {
225
+ }];
226
+ if (context === "open") {
194
227
  buttons.push({
195
- label: ( localize(13859, "Open &&Files...")),
228
+ label: ( localize(14246, "Open &&Files...")),
196
229
  run: async () => {
197
230
  const files = await triggerUpload();
198
231
  if (files) {
@@ -202,7 +235,9 @@ class FileDialogService extends AbstractFileDialogService {
202
235
  return {
203
236
  resource: fileData.resource,
204
237
  contents: fileData.contents?.toString(),
205
- options: { pinned: true }
238
+ options: {
239
+ pinned: true
240
+ }
206
241
  };
207
242
  })));
208
243
  }
@@ -212,9 +247,9 @@ class FileDialogService extends AbstractFileDialogService {
212
247
  }
213
248
  await this.dialogService.prompt({
214
249
  type: Severity.Warning,
215
- message: ( localize(13860, "Opening Local Folders is Unsupported")),
250
+ message: ( localize(14247, "Opening Local Folders is Unsupported")),
216
251
  detail: ( localize(
217
- 13861,
252
+ 14248,
218
253
  "Your browser doesn't support opening local folders.\nYou can either open single files or open a remote repository."
219
254
  )),
220
255
  buttons
@@ -225,8 +260,6 @@ class FileDialogService extends AbstractFileDialogService {
225
260
  return ![Schemas.file, Schemas.vscodeUserData, Schemas.tmp].includes(scheme);
226
261
  }
227
262
  }
228
- FileDialogService.__decorator = ( __decorate([
229
- memoize
230
- ], FileDialogService.prototype, "fileSystemProvider", null));
263
+ FileDialogService.__decorator = ( __decorate([memoize], FileDialogService.prototype, "fileSystemProvider", null));
231
264
 
232
265
  export { FileDialogService };