cc4-embedded-system 3.1.4 → 3.1.5

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 (2) hide show
  1. package/dist/gui.js +30 -8
  2. package/package.json +2 -2
package/dist/gui.js CHANGED
@@ -121,6 +121,30 @@ const runDialogCommand = (command, args) => {
121
121
  });
122
122
  });
123
123
  };
124
+ const buildWindowsDialogScript = (dialogLines) => {
125
+ return [
126
+ 'Add-Type -AssemblyName System.Windows.Forms',
127
+ 'Add-Type -AssemblyName System.Drawing',
128
+ '$screen = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea',
129
+ '$owner = New-Object System.Windows.Forms.Form',
130
+ '$owner.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual',
131
+ '$owner.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::None',
132
+ '$owner.ShowInTaskbar = $false',
133
+ '$owner.TopMost = $true',
134
+ '$owner.Width = 1',
135
+ '$owner.Height = 1',
136
+ '$owner.Left = $screen.Left + [int]($screen.Width / 2)',
137
+ '$owner.Top = $screen.Top + [int]($screen.Height / 2)',
138
+ '$owner.Opacity = 0',
139
+ '$null = $owner.Show()',
140
+ '$null = $owner.Activate()',
141
+ '$owner.BringToFront()',
142
+ '[System.Windows.Forms.Application]::DoEvents()',
143
+ ...dialogLines,
144
+ '$owner.Close()',
145
+ '$owner.Dispose()'
146
+ ].join('\n');
147
+ };
124
148
  app.get('/api/version', (_req, res) => {
125
149
  cancelShutdown();
126
150
  res.json({ version: getPackageVersion() });
@@ -204,25 +228,23 @@ app.get('/api/browse', async (req, res) => {
204
228
  let result = '';
205
229
  if (platform === 'win32') {
206
230
  const script = isDir
207
- ? [
208
- 'Add-Type -AssemblyName System.Windows.Forms',
231
+ ? buildWindowsDialogScript([
209
232
  '$dialog = New-Object System.Windows.Forms.FolderBrowserDialog',
210
233
  '$dialog.Description = "Select Input Directory"',
211
- 'if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {',
234
+ 'if ($dialog.ShowDialog($owner) -eq [System.Windows.Forms.DialogResult]::OK) {',
212
235
  ' $dialog.SelectedPath',
213
236
  '}'
214
- ].join('\n')
215
- : [
216
- 'Add-Type -AssemblyName System.Windows.Forms',
237
+ ])
238
+ : buildWindowsDialogScript([
217
239
  '$dialog = New-Object System.Windows.Forms.SaveFileDialog',
218
240
  '$dialog.Filter = "C Files (*.c)|*.c|All Files (*.*)|*.*"',
219
241
  '$dialog.DefaultExt = "c"',
220
242
  '$dialog.AddExtension = $true',
221
243
  '$dialog.OverwritePrompt = $true',
222
- 'if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {',
244
+ 'if ($dialog.ShowDialog($owner) -eq [System.Windows.Forms.DialogResult]::OK) {',
223
245
  ' $dialog.FileName',
224
246
  '}'
225
- ].join('\n');
247
+ ]);
226
248
  result = await runDialogCommand('powershell.exe', buildPowerShellArgs(script));
227
249
  }
228
250
  else if (platform === 'darwin') {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "cc4-embedded-system",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "A modern typescript version of makefsdata based on html-minifier-next and lwIP v1.3.1",
5
5
  "bin": {
6
- "cc4es": "./dist/gui.js"
6
+ "cc4es": "dist/gui.js"
7
7
  },
8
8
  "type": "module",
9
9
  "scripts": {