@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tui-sandbox/library",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@catppuccin/palette": "1.7.1",
11
- "@trpc/client": "11.0.0-rc.630",
12
- "@trpc/server": "11.0.0-rc.630",
11
+ "@trpc/client": "11.0.0-rc.633",
12
+ "@trpc/server": "11.0.0-rc.633",
13
13
  "@xterm/addon-attach": "0.11.0",
14
14
  "@xterm/addon-fit": "0.10.0",
15
15
  "@xterm/xterm": "5.5.0",
@@ -34,7 +34,7 @@
34
34
  "@types/node": "22.9.0",
35
35
  "nodemon": "3.1.7",
36
36
  "vite": "5.4.11",
37
- "vitest": "2.1.4"
37
+ "vitest": "2.1.5"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "concurrently --names 'vite,tsc' 'vite build' 'tsc' --prefix-colors blue,green",
@@ -12,6 +12,7 @@ const client = new NeovimClient(app)
12
12
  /** Entrypoint for the test runner (cypress) */
13
13
  window.startNeovim = async function (startArgs?: StartNeovimGenericArguments): Promise<TestDirectory> {
14
14
  const testDirectory = await client.startNeovim({
15
+ additionalEnvironmentVariables: startArgs?.additionalEnvironmentVariables,
15
16
  filename: startArgs?.filename ?? "initial-file.txt",
16
17
  startupScriptModifications: startArgs?.startupScriptModifications ?? [],
17
18
  })
@@ -1,7 +1,6 @@
1
1
  import { createTRPCClient, httpBatchLink, splitLink, unstable_httpSubscriptionLink } from "@trpc/client"
2
2
  import type { Terminal } from "@xterm/xterm"
3
3
  import "@xterm/xterm/css/xterm.css"
4
- import type { Except } from "type-fest"
5
4
  import type { StartNeovimGenericArguments } from "../server/neovim/NeovimApplication.ts"
6
5
  import type { AppRouter } from "../server/server.ts"
7
6
  import type { TestDirectory } from "../server/types.ts"
@@ -66,12 +65,13 @@ export class NeovimClient {
66
65
  })
67
66
  }
68
67
 
69
- public async startNeovim(args: Except<StartNeovimGenericArguments, "terminalDimensions">): Promise<TestDirectory> {
68
+ public async startNeovim(args: StartNeovimGenericArguments): Promise<TestDirectory> {
70
69
  await this.ready
71
70
 
72
71
  const testDirectory = await this.trpc.neovim.start.mutate({
73
72
  startNeovimArguments: {
74
- ...args,
73
+ filename: args.filename,
74
+ additionalEnvironmentVariables: args.additionalEnvironmentVariables,
75
75
  terminalDimensions: {
76
76
  cols: this.terminal.cols,
77
77
  rows: this.terminal.rows,
@@ -59,11 +59,16 @@ Run "nvim -V1 -v" for more info
59
59
  export type StdoutMessage = "stdout"
60
60
 
61
61
  export type StartNeovimGenericArguments = {
62
- terminalDimensions: { cols: number; rows: number }
63
62
  filename: string | { openInVerticalSplits: string[] }
64
63
  startupScriptModifications?: string[]
64
+
65
+ /** Additions to the environment variables for the Neovim process. These
66
+ * override any already existing environment variables. */
67
+ additionalEnvironmentVariables?: Record<string, string> | undefined
65
68
  }
66
69
 
70
+ export type TerminalDimensions = { cols: number; rows: number }
71
+
67
72
  type ResettableState = {
68
73
  testDirectory: TestDirectory
69
74
  socketPath: string
@@ -86,7 +91,8 @@ export class NeovimApplication {
86
91
  */
87
92
  public async startNextAndKillCurrent(
88
93
  testDirectory: TestDirectory,
89
- startArgs: StartNeovimGenericArguments
94
+ startArgs: StartNeovimGenericArguments,
95
+ terminalDimensions: TerminalDimensions
90
96
  ): Promise<void> {
91
97
  await this[Symbol.asyncDispose]()
92
98
  assert(
@@ -129,13 +135,14 @@ export class NeovimApplication {
129
135
  const stdout = this.events
130
136
 
131
137
  await this.application.startNextAndKillCurrent(async () => {
138
+ const env = { ...process.env, ...startArgs.additionalEnvironmentVariables }
132
139
  return TerminalApplication.start({
133
140
  command: "nvim",
134
141
  args: neovimArguments,
135
142
 
136
143
  cwd: this.testEnvironmentPath,
137
- env: process.env,
138
- dimensions: startArgs.terminalDimensions,
144
+ env: env,
145
+ dimensions: terminalDimensions,
139
146
 
140
147
  onStdoutOrStderr(data) {
141
148
  data satisfies string
@@ -4,7 +4,7 @@ import type { TestServerConfig } from "../updateTestdirectorySchemaFile.js"
4
4
  import { convertEventEmitterToAsyncGenerator } from "../utilities/generator.js"
5
5
  import type { TabId } from "../utilities/tabId.js"
6
6
  import { createTempDir } from "./environment/createTempDir.js"
7
- import type { StartNeovimGenericArguments } from "./NeovimApplication.js"
7
+ import type { StartNeovimGenericArguments, TerminalDimensions } from "./NeovimApplication.js"
8
8
  import { NeovimApplication } from "./NeovimApplication.js"
9
9
 
10
10
  const neovims = new Map<TabId["tabId"], NeovimApplication>()
@@ -34,6 +34,7 @@ export async function onStdout(
34
34
 
35
35
  export async function start(
36
36
  options: StartNeovimGenericArguments,
37
+ terminalDimensions: TerminalDimensions,
37
38
  tabId: TabId,
38
39
  config: TestServerConfig
39
40
  ): Promise<TestDirectory> {
@@ -41,7 +42,7 @@ export async function start(
41
42
  assert(neovim, `Neovim instance not found for client id ${tabId.tabId}`)
42
43
 
43
44
  const testDirectory = await createTempDir(config)
44
- await neovim.startNextAndKillCurrent(testDirectory, options)
45
+ await neovim.startNextAndKillCurrent(testDirectory, options, terminalDimensions)
45
46
 
46
47
  return testDirectory
47
48
  }
@@ -41,11 +41,17 @@ export async function createAppRouter(config: TestServerConfig) {
41
41
  cols: z.number(),
42
42
  rows: z.number(),
43
43
  }),
44
+ additionalEnvironmentVariables: z.record(z.string()).optional(),
44
45
  }),
45
46
  })
46
47
  )
47
48
  .mutation(options => {
48
- return neovim.start(options.input.startNeovimArguments, options.input.tabId, config)
49
+ return neovim.start(
50
+ options.input.startNeovimArguments,
51
+ options.input.startNeovimArguments.terminalDimensions,
52
+ options.input.tabId,
53
+ config
54
+ )
49
55
  }),
50
56
  onStdout: trpc.procedure.input(z.object({ client: tabIdSchema })).subscription(options => {
51
57
  return neovim.onStdout(options.input, options.signal, config.testEnvironmentPath)