@writepanda/cli 1.220.0 → 1.222.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.
@@ -40,7 +40,7 @@ for (const stream of [process.stdout, process.stderr]) {
40
40
  });
41
41
  }
42
42
 
43
- const VERSION = "1.220.0";
43
+ const VERSION = "1.222.0";
44
44
 
45
45
  function configDir() {
46
46
  // PANDASTUDIO_CONFIG_DIR mirrors the override the main process
@@ -517,6 +517,9 @@ async function autoLaunchAndWait(opts, log) {
517
517
  detached: true,
518
518
  stdio: "ignore",
519
519
  env: appLaunchEnv(process.env),
520
+ // The desktop app's own window must show (windowsHide hides a GUI
521
+ // program's first window too).
522
+ windowsHide: false,
520
523
  });
521
524
  child.unref();
522
525
  } catch (err) {
@@ -702,14 +705,34 @@ async function main() {
702
705
  // into the `args` object — the value `--slots='{"a":1}'` becomes
703
706
  // `args.slots = {a:1}` thanks to parseScalar.
704
707
  const callBody = { command, args: resolved.args };
705
- const result = await fetchJson(creds.port, "/v1/call", {
706
- method: "POST",
707
- headers: {
708
- "Content-Type": "application/json",
709
- Authorization: `Bearer ${creds.token}`,
710
- },
711
- body: JSON.stringify(callBody),
712
- });
708
+ const send = (c) =>
709
+ fetchJson(c.port, "/v1/call", {
710
+ method: "POST",
711
+ headers: {
712
+ "Content-Type": "application/json",
713
+ Authorization: `Bearer ${c.token}`,
714
+ },
715
+ body: JSON.stringify(callBody),
716
+ });
717
+ let result;
718
+ try {
719
+ result = await send(creds);
720
+ } catch (err) {
721
+ // Refused: the app moved its automation server after we read the
722
+ // port (nothing reached it, so resending can't run the command
723
+ // twice). Re-read the files once and resend to the new address.
724
+ const code = err?.code ?? err?.cause?.code;
725
+ if (code !== "ECONNREFUSED" || opts.portOverride) throw err;
726
+ let fresh;
727
+ try {
728
+ fresh = await readCredentials(opts);
729
+ } catch {
730
+ throw err;
731
+ }
732
+ if (fresh.port === creds.port && fresh.token === creds.token) throw err;
733
+ creds = fresh;
734
+ result = await send(creds);
735
+ }
713
736
 
714
737
  return emit(result, opts);
715
738
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@writepanda/cli",
3
- "version": "1.220.0",
3
+ "version": "1.222.0",
4
4
  "description": "Drive PandaStudio (a desktop video editor for YouTube creators) from the command line. Talks to a localhost HTTP API the desktop app exposes.",
5
5
  "keywords": [
6
6
  "pandastudio",