@tui-sandbox/library 11.2.1 → 11.3.1

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/browser/assets/{index-VJaZoTqH.js → index-DXraucSs.js} +1 -1
  3. package/dist/browser/index.html +1 -1
  4. package/dist/src/browser/neovim-client.d.ts +3 -2
  5. package/dist/src/browser/neovim-client.js +3 -0
  6. package/dist/src/browser/neovim-client.js.map +1 -1
  7. package/dist/src/client/neovim-terminal-client.d.ts +2 -1
  8. package/dist/src/client/neovim-terminal-client.js +9 -1
  9. package/dist/src/client/neovim-terminal-client.js.map +1 -1
  10. package/dist/src/client/{websocket-client.js → startTerminal.js} +1 -1
  11. package/dist/src/client/startTerminal.js.map +1 -0
  12. package/dist/src/client/terminal-config.d.ts +1 -1
  13. package/dist/src/client/terminal-terminal-client.d.ts +1 -1
  14. package/dist/src/client/terminal-terminal-client.js +1 -1
  15. package/dist/src/client/terminal-terminal-client.js.map +1 -1
  16. package/dist/src/server/applications/neovim/neovimRouter.d.ts +9 -0
  17. package/dist/src/server/applications/neovim/neovimRouter.js +5 -0
  18. package/dist/src/server/applications/neovim/neovimRouter.js.map +1 -1
  19. package/dist/src/server/cypress-support/contents.js +15 -0
  20. package/dist/src/server/cypress-support/contents.js.map +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +5 -7
  23. package/src/browser/neovim-client.ts +6 -1
  24. package/src/client/neovim-terminal-client.ts +11 -1
  25. package/src/client/terminal-config.ts +1 -1
  26. package/src/client/terminal-terminal-client.ts +2 -2
  27. package/src/server/applications/neovim/neovimRouter.ts +8 -0
  28. package/src/server/cypress-support/contents.ts +15 -0
  29. package/dist/src/client/websocket-client.js.map +0 -1
  30. package/dist/src/server/utilities/applicationAvailable.d.ts +0 -1
  31. package/dist/src/server/utilities/applicationAvailable.js +0 -5
  32. package/dist/src/server/utilities/applicationAvailable.js.map +0 -1
  33. package/dist/src/server/utilities/applicationAvailable.test.d.ts +0 -1
  34. package/dist/src/server/utilities/applicationAvailable.test.js +0 -13
  35. package/dist/src/server/utilities/applicationAvailable.test.js.map +0 -1
  36. package/src/server/utilities/applicationAvailable.test.ts +0 -14
  37. package/src/server/utilities/applicationAvailable.ts +0 -5
  38. /package/dist/src/client/{websocket-client.d.ts → startTerminal.d.ts} +0 -0
  39. /package/src/client/{websocket-client.ts → startTerminal.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tui-sandbox/library",
3
- "version": "11.2.1",
3
+ "version": "11.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mikavilpas/tui-sandbox"
@@ -14,19 +14,17 @@
14
14
  "@catppuccin/palette": "1.7.1",
15
15
  "@trpc/client": "11.4.3",
16
16
  "@trpc/server": "11.4.3",
17
- "@xterm/addon-attach": "0.11.0",
18
17
  "@xterm/addon-fit": "0.10.0",
19
18
  "@xterm/xterm": "5.5.0",
20
- "command-exists": "1.2.9",
21
19
  "cors": "2.8.5",
22
20
  "dree": "5.1.5",
23
21
  "express": "5.1.0",
24
22
  "neovim": "5.3.0",
25
23
  "node-pty": "1.0.0",
26
24
  "prettier": "3.6.2",
27
- "tsx": "4.20.3",
28
25
  "type-fest": "4.41.0",
29
- "winston": "3.17.0"
26
+ "winston": "3.17.0",
27
+ "zod": "4.0.14"
30
28
  },
31
29
  "devDependencies": {
32
30
  "@types/command-exists": "1.2.3",
@@ -34,9 +32,9 @@
34
32
  "@types/express": "5.0.3",
35
33
  "@types/node": "24.1.0",
36
34
  "nodemon": "3.1.10",
35
+ "tsx": "4.20.3",
37
36
  "vite": "7.0.6",
38
- "vitest": "3.2.4",
39
- "zod": "4.0.14"
37
+ "vitest": "3.2.4"
40
38
  },
41
39
  "peerDependencies": {
42
40
  "cypress": "^13 || ^14",
@@ -1,11 +1,12 @@
1
1
  import type { Terminal } from "@xterm/xterm"
2
2
  import { TerminalClient as NeovimTerminalClient } from "../client/index.js"
3
+ import type { TuiTerminalApi } from "../client/startTerminal.js"
3
4
  import { TerminalTerminalClient } from "../client/terminal-terminal-client.js"
4
- import type { TuiTerminalApi } from "../client/websocket-client.js"
5
5
  import type {
6
6
  ExCommandClientInput,
7
7
  LuaCodeClientInput,
8
8
  PollLuaCodeClientInput,
9
+ RunLuaFileClientInput,
9
10
  } from "../server/applications/neovim/neovimRouter.js"
10
11
  import type { StartTerminalGenericArguments } from "../server/applications/terminal/TerminalTestApplication.js"
11
12
  import type { BlockingCommandClientInput } from "../server/blockingCommandInputSchema.js"
@@ -31,6 +32,7 @@ const terminalClient = new Lazy(() => new TerminalTerminalClient(app))
31
32
  export type GenericNeovimBrowserApi = {
32
33
  runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>
33
34
  runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>
35
+ doFile(input: RunLuaFileClientInput): Promise<RunLuaCodeOutput>
34
36
  waitForLuaCode(input: PollLuaCodeClientInput): Promise<RunLuaCodeOutput>
35
37
  runExCommand(input: ExCommandClientInput): Promise<RunExCommandOutput>
36
38
  dir: TestDirectory
@@ -54,6 +56,9 @@ window.startNeovim = async function (startArgs?: StartNeovimGenericArguments): P
54
56
  runLuaCode(input) {
55
57
  return neovim.runLuaCode(input)
56
58
  },
59
+ doFile(input) {
60
+ return neovim.doFile(input)
61
+ },
57
62
  waitForLuaCode(input) {
58
63
  return neovim.waitForLuaCode(input)
59
64
  },
@@ -5,6 +5,7 @@ import type {
5
5
  ExCommandClientInput,
6
6
  LuaCodeClientInput,
7
7
  PollLuaCodeClientInput,
8
+ RunLuaFileClientInput,
8
9
  } from "../server/applications/neovim/neovimRouter.js"
9
10
  import type { BlockingCommandClientInput } from "../server/blockingCommandInputSchema.js"
10
11
  import type { AppRouter } from "../server/server.js"
@@ -15,8 +16,8 @@ import type {
15
16
  StartNeovimGenericArguments,
16
17
  TestDirectory,
17
18
  } from "../server/types.js"
19
+ import { getTabId, startTerminal } from "./startTerminal.js"
18
20
  import "./style.css"
19
- import { getTabId, startTerminal } from "./websocket-client.js"
20
21
 
21
22
  /** Manages the terminal state in the browser as well as the (browser's)
22
23
  * connection to the server side terminal application api. */
@@ -108,6 +109,15 @@ export class NeovimTerminalClient {
108
109
  return this.trpc.neovim.runLuaCode.mutate({ ...input, tabId: this.tabId })
109
110
  }
110
111
 
112
+ public async doFile(input: RunLuaFileClientInput): Promise<RunExCommandOutput> {
113
+ await this.ready
114
+ return this.trpc.neovim.runExCommand.mutate({
115
+ ...input,
116
+ tabId: this.tabId,
117
+ command: `lua dofile("${input.luaFile}")`,
118
+ })
119
+ }
120
+
111
121
  public async waitForLuaCode(input: PollLuaCodeClientInput): Promise<RunLuaCodeOutput> {
112
122
  await this.ready
113
123
  try {
@@ -1,5 +1,5 @@
1
1
  import type { Terminal } from "@xterm/xterm"
2
- import type { TuiTerminalApi } from "./websocket-client.js"
2
+ import type { TuiTerminalApi } from "./startTerminal.js"
3
3
 
4
4
  /** DA1—Primary Device Attributes
5
5
  * In this DA exchange, the host asks for the terminal's architectural class and basic attributes.
@@ -5,10 +5,10 @@ import type { StartTerminalBrowserArguments } from "../browser/neovim-client.js"
5
5
  import type { BlockingCommandClientInput } from "../server/blockingCommandInputSchema.js"
6
6
  import type { AppRouter } from "../server/server.js"
7
7
  import type { BlockingShellCommandOutput, TestDirectory } from "../server/types.js"
8
+ import type { TuiTerminalApi } from "./startTerminal.js"
9
+ import { getTabId, startTerminal } from "./startTerminal.js"
8
10
  import "./style.css"
9
11
  import { supportDA1 } from "./terminal-config.js"
10
- import type { TuiTerminalApi } from "./websocket-client.js"
11
- import { getTabId, startTerminal } from "./websocket-client.js"
12
12
 
13
13
  /** Manages the terminal state in the browser as well as the (browser's)
14
14
  * connection to the server side terminal application api. */
@@ -26,6 +26,14 @@ const exCommandInputSchema = z.object({
26
26
  export type ExCommandClientInput = Except<ExCommandInput, "tabId">
27
27
  export type ExCommandInput = z.infer<typeof exCommandInputSchema>
28
28
 
29
+ const runLuaFileInputSchema = z.object({
30
+ tabId: tabIdSchema,
31
+ luaFile: z.string(),
32
+ log: z.boolean().optional(),
33
+ })
34
+ export type RunLuaFileInput = z.output<typeof runLuaFileInputSchema>
35
+ export type RunLuaFileClientInput = Except<RunLuaFileInput, "tabId">
36
+
29
37
  // let trpc infer the type as that is what it is designed to do
30
38
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
31
39
  export function createNeovimRouter(config: DirectoriesConfig) {
@@ -28,6 +28,7 @@ import type {
28
28
  ExCommandClientInput,
29
29
  LuaCodeClientInput,
30
30
  PollLuaCodeClientInput,
31
+ RunLuaFileClientInput,
31
32
  } from "@tui-sandbox/library/src/server/applications/neovim/neovimRouter"
32
33
  import type { StartTerminalGenericArguments } from "@tui-sandbox/library/src/server/applications/terminal/TerminalTestApplication"
33
34
  import type { BlockingCommandClientInput } from "@tui-sandbox/library/src/server/blockingCommandInputSchema"
@@ -61,6 +62,13 @@ export type NeovimContext = {
61
62
  * finish before returning. Requires neovim to be running. */
62
63
  runLuaCode(input: LuaCodeClientInput): Cypress.Chainable<RunLuaCodeOutput>
63
64
 
65
+ /** Runs a Lua file in neovim after it has started. Can be used to keep
66
+ * complex lua logic in a separate file, still being able to run it after
67
+ * startup. This way additional tools like lua LSP servers, linters, etc. can
68
+ * be used to ensure the code is correct.
69
+ */
70
+ doFile(input: MyRunLuaFileClientInput): Cypress.Chainable<RunExCommandOutput>
71
+
64
72
  /**
65
73
  * Like runLuaCode, but waits until the given code (maybe using lua's return
66
74
  * assert()) does not raise an error, and returns the first successful result.
@@ -90,6 +98,8 @@ export type MyStartNeovimServerArguments = OverrideProperties<
90
98
  }
91
99
  >
92
100
 
101
+ export type MyRunLuaFileClientInput = OverrideProperties<RunLuaFileClientInput, { luaFile: MyTestDirectoryFile }>
102
+
93
103
  Cypress.Commands.add("startNeovim", (startArguments?: MyStartNeovimServerArguments) => {
94
104
  cy.window().then(async win => {
95
105
  const underlyingNeovim: GenericNeovimBrowserApi = await win.startNeovim(
@@ -103,6 +113,7 @@ Cypress.Commands.add("startNeovim", (startArguments?: MyStartNeovimServerArgumen
103
113
  nvim_runExCommand: underlyingNeovim.runExCommand,
104
114
  nvim_runLuaCode: underlyingNeovim.runLuaCode,
105
115
  nvim_waitForLuaCode: underlyingNeovim.waitForLuaCode,
116
+ nvim_doFile: underlyingNeovim.doFile,
106
117
  })
107
118
 
108
119
  const api: NeovimContext = {
@@ -115,6 +126,9 @@ Cypress.Commands.add("startNeovim", (startArguments?: MyStartNeovimServerArgumen
115
126
  runLuaCode(input) {
116
127
  return cy.nvim_runLuaCode(input)
117
128
  },
129
+ doFile(input) {
130
+ return cy.nvim_doFile(input)
131
+ },
118
132
  waitForLuaCode(input) {
119
133
  return cy.nvim_waitForLuaCode(input)
120
134
  },
@@ -201,6 +215,7 @@ declare global {
201
215
  nvim_runBlockingShellCommand(input: MyBlockingCommandClientInput): Chainable<BlockingShellCommandOutput>
202
216
 
203
217
  nvim_runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
218
+ nvim_doFile(input: MyRunLuaFileClientInput): Chainable<RunExCommandOutput>
204
219
  nvim_waitForLuaCode(input: PollLuaCodeClientInput): Chainable<RunLuaCodeOutput>
205
220
 
206
221
  /** Run an ex command in neovim.
@@ -1 +0,0 @@
1
- {"version":3,"file":"websocket-client.js","sourceRoot":"","sources":["../../../src/client/websocket-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,4BAA4B,CAAA;AACnC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB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}
@@ -1 +0,0 @@
1
- export declare function applicationAvailable(command: string): Promise<string | null>;
@@ -1,5 +0,0 @@
1
- import commandExists from "command-exists";
2
- export async function applicationAvailable(command) {
3
- return commandExists(command);
4
- }
5
- //# sourceMappingURL=applicationAvailable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"applicationAvailable.js","sourceRoot":"","sources":["../../../../src/server/utilities/applicationAvailable.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAE1C,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAe;IACxD,OAAO,aAAa,CAAC,OAAO,CAAC,CAAA;AAC/B,CAAC"}
@@ -1,13 +0,0 @@
1
- import { applicationAvailable } from "./applicationAvailable.js";
2
- describe("sanity checks for mocking", () => {
3
- // because it makes no sense to mock the actual implementation if we don't
4
- // know what it does in the current version, we better check what it's
5
- // expected to do
6
- it("can find neovim using the actual implementation", async () => {
7
- await expect(applicationAvailable("nvim")).resolves.toBe("nvim");
8
- });
9
- it("complains when a nonexistent command is checked", async () => {
10
- await expect(applicationAvailable("thisCommandDoesNotExist")).rejects.toBe(null);
11
- });
12
- });
13
- //# sourceMappingURL=applicationAvailable.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"applicationAvailable.test.js","sourceRoot":"","sources":["../../../../src/server/utilities/applicationAvailable.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,0EAA0E;IAC1E,sEAAsE;IACtE,iBAAiB;IACjB,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,MAAM,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,14 +0,0 @@
1
- import { applicationAvailable } from "./applicationAvailable.js"
2
-
3
- describe("sanity checks for mocking", () => {
4
- // because it makes no sense to mock the actual implementation if we don't
5
- // know what it does in the current version, we better check what it's
6
- // expected to do
7
- it("can find neovim using the actual implementation", async () => {
8
- await expect(applicationAvailable("nvim")).resolves.toBe("nvim")
9
- })
10
-
11
- it("complains when a nonexistent command is checked", async () => {
12
- await expect(applicationAvailable("thisCommandDoesNotExist")).rejects.toBe(null)
13
- })
14
- })
@@ -1,5 +0,0 @@
1
- import commandExists from "command-exists"
2
-
3
- export async function applicationAvailable(command: string): Promise<string | null> {
4
- return commandExists(command)
5
- }