@tui-sandbox/library 4.1.0 → 4.2.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.
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <title>tui-sandbox integration tests</title>
6
- <script type="module" crossorigin src="/assets/index-BckJD5M_.js"></script>
6
+ <script type="module" crossorigin src="/assets/index-BP1DuSB-.js"></script>
7
7
  <link rel="stylesheet" crossorigin href="/assets/index-Bf37MeF1.css">
8
8
  </head>
9
9
  <body>
@@ -7,6 +7,7 @@ const client = new NeovimClient(app);
7
7
  /** Entrypoint for the test runner (cypress) */
8
8
  window.startNeovim = async function (startArgs) {
9
9
  const testDirectory = await client.startNeovim({
10
+ additionalEnvironmentVariables: startArgs?.additionalEnvironmentVariables,
10
11
  filename: startArgs?.filename ?? "initial-file.txt",
11
12
  startupScriptModifications: startArgs?.startupScriptModifications ?? [],
12
13
  });
@@ -1,5 +1,4 @@
1
1
  import "@xterm/xterm/css/xterm.css";
2
- import type { Except } from "type-fest";
3
2
  import type { StartNeovimGenericArguments } from "../server/neovim/NeovimApplication.ts";
4
3
  import type { TestDirectory } from "../server/types.ts";
5
4
  import "./style.css";
@@ -9,5 +8,5 @@ export declare class NeovimClient {
9
8
  private readonly terminal;
10
9
  private readonly trpc;
11
10
  constructor(app: HTMLElement);
12
- startNeovim(args: Except<StartNeovimGenericArguments, "terminalDimensions">): Promise<TestDirectory>;
11
+ startNeovim(args: StartNeovimGenericArguments): Promise<TestDirectory>;
13
12
  }
@@ -56,7 +56,8 @@ export class NeovimClient {
56
56
  await this.ready;
57
57
  const testDirectory = await this.trpc.neovim.start.mutate({
58
58
  startNeovimArguments: {
59
- ...args,
59
+ filename: args.filename,
60
+ additionalEnvironmentVariables: args.additionalEnvironmentVariables,
60
61
  terminalDimensions: {
61
62
  cols: this.terminal.cols,
62
63
  rows: this.terminal.rows,
@@ -3,14 +3,17 @@ import type { TestDirectory } from "../types.js";
3
3
  import { DisposableSingleApplication } from "../utilities/DisposableSingleApplication.js";
4
4
  export type StdoutMessage = "stdout";
5
5
  export type StartNeovimGenericArguments = {
6
- terminalDimensions: {
7
- cols: number;
8
- rows: number;
9
- };
10
6
  filename: string | {
11
7
  openInVerticalSplits: string[];
12
8
  };
13
9
  startupScriptModifications?: string[];
10
+ /** Additions to the environment variables for the Neovim process. These
11
+ * override any already existing environment variables. */
12
+ additionalEnvironmentVariables?: Record<string, string> | undefined;
13
+ };
14
+ export type TerminalDimensions = {
15
+ cols: number;
16
+ rows: number;
14
17
  };
15
18
  export declare class NeovimApplication {
16
19
  private readonly testEnvironmentPath;
@@ -21,6 +24,6 @@ export declare class NeovimApplication {
21
24
  /**
22
25
  * Kill the current application and start a new one with the given arguments.
23
26
  */
24
- startNextAndKillCurrent(testDirectory: TestDirectory, startArgs: StartNeovimGenericArguments): Promise<void>;
27
+ startNextAndKillCurrent(testDirectory: TestDirectory, startArgs: StartNeovimGenericArguments, terminalDimensions: TerminalDimensions): Promise<void>;
25
28
  [Symbol.asyncDispose](): Promise<void>;
26
29
  }
@@ -20,7 +20,7 @@ export class NeovimApplication {
20
20
  /**
21
21
  * Kill the current application and start a new one with the given arguments.
22
22
  */
23
- async startNextAndKillCurrent(testDirectory, startArgs) {
23
+ async startNextAndKillCurrent(testDirectory, startArgs, terminalDimensions) {
24
24
  await this[Symbol.asyncDispose]();
25
25
  assert(this.state === undefined, "NeovimApplication state should be undefined after disposing so that no previous state is reused.");
26
26
  const neovimArguments = ["-u", "test-setup.lua"];
@@ -53,12 +53,13 @@ export class NeovimApplication {
53
53
  neovimArguments.push("--listen", socketPath);
54
54
  const stdout = this.events;
55
55
  await this.application.startNextAndKillCurrent(async () => {
56
+ const env = { ...process.env, ...startArgs.additionalEnvironmentVariables };
56
57
  return TerminalApplication.start({
57
58
  command: "nvim",
58
59
  args: neovimArguments,
59
60
  cwd: this.testEnvironmentPath,
60
- env: process.env,
61
- dimensions: startArgs.terminalDimensions,
61
+ env: env,
62
+ dimensions: terminalDimensions,
62
63
  onStdoutOrStderr(data) {
63
64
  data;
64
65
  stdout.emit("stdout", data);
@@ -1,11 +1,11 @@
1
1
  import type { TestDirectory } from "../types.js";
2
2
  import type { TestServerConfig } from "../updateTestdirectorySchemaFile.js";
3
3
  import type { TabId } from "../utilities/tabId.js";
4
- import type { StartNeovimGenericArguments } from "./NeovimApplication.js";
4
+ import type { StartNeovimGenericArguments, TerminalDimensions } from "./NeovimApplication.js";
5
5
  export declare function onStdout(options: {
6
6
  client: TabId;
7
7
  }, signal: AbortSignal | undefined, testEnvironmentPath: string): Promise<AsyncGenerator<string, void, unknown>>;
8
- export declare function start(options: StartNeovimGenericArguments, tabId: TabId, config: TestServerConfig): Promise<TestDirectory>;
8
+ export declare function start(options: StartNeovimGenericArguments, terminalDimensions: TerminalDimensions, tabId: TabId, config: TestServerConfig): Promise<TestDirectory>;
9
9
  export declare function sendStdin(options: {
10
10
  tabId: TabId;
11
11
  data: string;
@@ -19,11 +19,11 @@ export async function onStdout(options, signal, testEnvironmentPath) {
19
19
  }
20
20
  return stdout;
21
21
  }
22
- export async function start(options, tabId, config) {
22
+ export async function start(options, terminalDimensions, tabId, config) {
23
23
  const neovim = neovims.get(tabId.tabId);
24
24
  assert(neovim, `Neovim instance not found for client id ${tabId.tabId}`);
25
25
  const testDirectory = await createTempDir(config);
26
- await neovim.startNextAndKillCurrent(testDirectory, options);
26
+ await neovim.startNextAndKillCurrent(testDirectory, options, terminalDimensions);
27
27
  return testDirectory;
28
28
  }
29
29
  export async function sendStdin(options) {
@@ -33,6 +33,7 @@ export declare function createAppRouter(config: TestServerConfig): Promise<impor
33
33
  rows: number;
34
34
  };
35
35
  startupScriptModifications?: string[] | undefined;
36
+ additionalEnvironmentVariables?: Record<string, string> | undefined;
36
37
  };
37
38
  };
38
39
  output: import("./types.js").TestDirectory;
@@ -81,10 +81,11 @@ export async function createAppRouter(config) {
81
81
  cols: z.number(),
82
82
  rows: z.number(),
83
83
  }),
84
+ additionalEnvironmentVariables: z.record(z.string()).optional(),
84
85
  }),
85
86
  }))
86
87
  .mutation(options => {
87
- return neovim.start(options.input.startNeovimArguments, options.input.tabId, config);
88
+ return neovim.start(options.input.startNeovimArguments, options.input.startNeovimArguments.terminalDimensions, options.input.tabId, config);
88
89
  }),
89
90
  onStdout: trpc.procedure.input(z.object({ client: tabIdSchema })).subscription(options => {
90
91
  return neovim.onStdout(options.input, options.signal, config.testEnvironmentPath);