aegis-desktop 0.8.23 → 0.8.24
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.
- package/package.json +1 -1
- package/vendor/platform.js +54 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegis-desktop",
|
|
3
3
|
"productName": "AEGIS Desktop",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.24",
|
|
5
5
|
"description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|
package/vendor/platform.js
CHANGED
|
@@ -493,17 +493,56 @@ function hasPosixModes(options = {}) {
|
|
|
493
493
|
return !win32;
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
+
/**
|
|
497
|
+
* Windows' own answer for "where is this user's Desktop", straight from the
|
|
498
|
+
* registry key Explorer itself reads and OneDrive itself rewrites when it
|
|
499
|
+
* redirects a folder. This is the one source immune to BOTH ways `~/Desktop`
|
|
500
|
+
* guesses wrong at once: it already names the OneDrive path when redirection
|
|
501
|
+
* is active, and it already names the LOCALISED folder — Swedish "Skrivbord",
|
|
502
|
+
* French "Bureau", whatever the session's physical folder is actually called
|
|
503
|
+
* — because it is Windows' own record of a real path, not an English-language
|
|
504
|
+
* guess with a `?` for an ending. Guessing per-language folder names instead
|
|
505
|
+
* would mean enumerating every language Windows ships, forever one behind;
|
|
506
|
+
* asking Windows is both simpler and exact.
|
|
507
|
+
*
|
|
508
|
+
* "Shell Folders" (not "User Shell Folders") is the one queried, because it
|
|
509
|
+
* holds the already-expanded absolute path — "User Shell Folders" is allowed
|
|
510
|
+
* to hold `%USERPROFILE%`-relative values, and this function has no reason to
|
|
511
|
+
* carry its own copy of Windows' expansion rules when the other key already
|
|
512
|
+
* did that work.
|
|
513
|
+
*
|
|
514
|
+
* Returns `''` on anything but a clean hit: `reg.exe` missing, a non-zero
|
|
515
|
+
* exit, unparsable output, or a path the filesystem does not actually have —
|
|
516
|
+
* each of those falls through to the candidate-guessing list in desktopDir()
|
|
517
|
+
* below, which is where this function's absence has always been tolerated.
|
|
518
|
+
*/
|
|
519
|
+
function winShellFolderDesktop(probe, dirExists) {
|
|
520
|
+
const out = probe('reg', [
|
|
521
|
+
'query',
|
|
522
|
+
'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders',
|
|
523
|
+
'/v', 'Desktop',
|
|
524
|
+
]);
|
|
525
|
+
if (!out) return '';
|
|
526
|
+
const m = /^\s*Desktop\s+REG_(?:EXPAND_)?SZ\s+(.+)$/im.exec(out);
|
|
527
|
+
const value = m && m[1].trim();
|
|
528
|
+
return value && dirExists(value) ? value : '';
|
|
529
|
+
}
|
|
530
|
+
|
|
496
531
|
/**
|
|
497
532
|
* This user's real Desktop directory, or `''` when none can be found.
|
|
498
533
|
*
|
|
499
534
|
* `~/Desktop` is a GUESS, and it is wrong on both of the hosts this function was
|
|
500
535
|
* added for:
|
|
501
536
|
*
|
|
502
|
-
* - Windows with OneDrive. Folder redirection moves
|
|
503
|
-
* `%USERPROFILE%\OneDrive\Desktop`
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
537
|
+
* - Windows with OneDrive, or a localised session. Folder redirection moves
|
|
538
|
+
* the live Desktop to `%USERPROFILE%\OneDrive\Desktop` (or renames it
|
|
539
|
+
* entirely, e.g. Swedish "Skrivbord"), and commonly leaves an empty
|
|
540
|
+
* `%USERPROFILE%\Desktop` behind, so a write to the obvious English path
|
|
541
|
+
* lands in a directory the user is not looking at — or at a name that
|
|
542
|
+
* does not exist on their machine at all. `winShellFolderDesktop()` above
|
|
543
|
+
* asks Windows directly and settles both cases at once; the `%OneDrive%`-
|
|
544
|
+
* and `home`-based guesses below only run when that lookup comes back
|
|
545
|
+
* empty (no `reg.exe`, or the path it names no longer exists).
|
|
507
546
|
* - A localised Linux desktop. XDG translates the directory ITSELF, not just
|
|
508
547
|
* its label: a Swedish session has `~/Skrivbord` and no `~/Desktop` at all.
|
|
509
548
|
* `$XDG_DESKTOP_DIR` answers it, and `~/.config/user-dirs.dirs` is where
|
|
@@ -513,15 +552,22 @@ function hasPosixModes(options = {}) {
|
|
|
513
552
|
*
|
|
514
553
|
* Seams: `dirExists` (default: a real statSync isDirectory probe), `dirNonEmpty`
|
|
515
554
|
* (default: a real readdirSync length check, used only to break the win32
|
|
516
|
-
* OneDrive-vs-plain
|
|
517
|
-
* `
|
|
555
|
+
* OneDrive-vs-plain guess below when the registry lookup did not settle it),
|
|
556
|
+
* `probe` (default: a real `reg.exe` spawn, `null` on any failure) and
|
|
557
|
+
* `readText` (default: a real utf8 read, `null` on any failure), so every
|
|
558
|
+
* branch is exercised on one host.
|
|
518
559
|
*/
|
|
519
560
|
function desktopDir(options = {}) {
|
|
520
|
-
const { platform, env, win32, o } = seams(options);
|
|
561
|
+
const { platform, env, win32, probe, o } = seams(options);
|
|
521
562
|
const P = win32 ? path.win32 : path.posix;
|
|
522
563
|
const home = homeDir(options);
|
|
523
564
|
const dirExists = typeof o.dirExists === 'function' ? o.dirExists : defaultDirExists;
|
|
524
565
|
const dirNonEmpty = typeof o.dirNonEmpty === 'function' ? o.dirNonEmpty : defaultDirNonEmpty;
|
|
566
|
+
|
|
567
|
+
if (win32) {
|
|
568
|
+
const fromRegistry = winShellFolderDesktop(probe, dirExists);
|
|
569
|
+
if (fromRegistry) return fromRegistry;
|
|
570
|
+
}
|
|
525
571
|
const readText = typeof o.readText === 'function' ? o.readText : defaultReadText;
|
|
526
572
|
|
|
527
573
|
const candidates = [];
|