@acryldev/launcher-desktop 0.1.5 → 0.1.7

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/lib/index.js CHANGED
@@ -172,14 +172,18 @@ async function readBlends(fetchImpl = (input, init) => fetch(input, init), url =
172
172
  const source = text$2(entry.source);
173
173
  if (!BLEND_SOURCE.test(source)) continue;
174
174
  ids.add(entry.id);
175
+ const placement = record$1(entry.placement);
176
+ const category = text$2(placement?.category) === "" ? text$2(entry.category) : [text$2(placement?.category), text$2(placement?.subcategory)].filter(Boolean).join(" › ");
177
+ const publisher = text$2(entry.publisher);
175
178
  blends.push({
176
179
  id: entry.id,
177
180
  name: text$2(entry.name) || entry.id,
178
181
  version: text$2(entry.version),
179
- category: text$2(entry.category),
182
+ category,
180
183
  description: text$2(entry.description),
181
184
  origin: "community",
182
- source
185
+ source,
186
+ ...publisher === "" ? {} : { publisher }
183
187
  });
184
188
  }
185
189
  return blends.sort((a, b) => a.name.localeCompare(b.name));
@@ -449,6 +453,31 @@ function appEnvironment(base, platform = process.platform) {
449
453
  }
450
454
  return env;
451
455
  }
456
+ /**
457
+ * What a child of the Electron main process inherits. On Linux Chromium opens its DevTools port (`--remote-debugging-port`), its sockets and its files without
458
+ * close-on-exec and Node's spawn passes every one on, so an app started from here kept the port bound after this app quit. macOS closes all but the standard streams
459
+ * when it starts a process, and Windows does not inherit a socket, so only Linux needs it. bash's `exec 12>&-` closes a descriptor of any number (dash takes one
460
+ * digit); the command then replaces bash, so the process id and group stay the child's. The same text is in plugins/desktop-shell/inherited.ts; keep them equal.
461
+ */
462
+ const CLOSE_AND_RUN = "for f in /proc/self/fd/*; do n=${f##*/}; if [ \"$n\" -gt 2 ]; then eval \"exec $n>&-\"; fi; done; exec \"$@\"";
463
+ const BASH = "/bin/bash";
464
+ /** The program and arguments to spawn so the child holds no descriptor above 2: the command itself where that is already so, or where bash is not there. */
465
+ function withoutInheritedDescriptors(program, args, platform = process.platform, hasBash = existsSync(BASH)) {
466
+ if (platform !== "linux" || !hasBash) return {
467
+ program,
468
+ args
469
+ };
470
+ return {
471
+ program: BASH,
472
+ args: [
473
+ "-c",
474
+ CLOSE_AND_RUN,
475
+ "acryl-spawn",
476
+ program,
477
+ ...args
478
+ ]
479
+ };
480
+ }
452
481
  /** Stop a command and everything it started: a process group on Unix, `taskkill /t` on Windows. */
453
482
  function stopTree(pid, platform) {
454
483
  try {
@@ -463,7 +492,11 @@ function stopTree(pid, platform) {
463
492
  }
464
493
  const spawnRunner = (command) => {
465
494
  const win = process.platform === "win32";
466
- const child = spawn(command.program, [...command.args], {
495
+ const start = win ? {
496
+ program: command.program,
497
+ args: command.args
498
+ } : withoutInheritedDescriptors(command.program, command.args);
499
+ const child = spawn(start.program, [...start.args], {
467
500
  cwd: command.cwd,
468
501
  env: command.env,
469
502
  shell: win,