@tui-sandbox/library 11.2.0 → 11.3.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/browser/assets/{index-D4YBlffP.js → index-DXraucSs.js} +6 -6
  3. package/dist/browser/index.html +1 -1
  4. package/dist/src/browser/neovim-client.d.ts +2 -1
  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/MyNeovimConfigModification.test.js +1 -1
  8. package/dist/src/client/MyNeovimConfigModification.test.js.map +1 -1
  9. package/dist/src/client/neovim-terminal-client.d.ts +2 -1
  10. package/dist/src/client/neovim-terminal-client.js +8 -0
  11. package/dist/src/client/neovim-terminal-client.js.map +1 -1
  12. package/dist/src/client/websocket-client.js +1 -1
  13. package/dist/src/client/websocket-client.js.map +1 -1
  14. package/dist/src/server/applications/neovim/neovimRouter.d.ts +10 -1
  15. package/dist/src/server/applications/neovim/neovimRouter.js +6 -1
  16. package/dist/src/server/applications/neovim/neovimRouter.js.map +1 -1
  17. package/dist/src/server/applications/terminal/terminalRouter.d.ts +1 -1
  18. package/dist/src/server/applications/terminal/terminalRouter.js +1 -1
  19. package/dist/src/server/applications/terminal/terminalRouter.js.map +1 -1
  20. package/dist/src/server/blockingCommandInputSchema.d.ts +1 -1
  21. package/dist/src/server/blockingCommandInputSchema.js +1 -1
  22. package/dist/src/server/blockingCommandInputSchema.js.map +1 -1
  23. package/dist/src/server/cypress-support/contents.js +15 -0
  24. package/dist/src/server/cypress-support/contents.js.map +1 -1
  25. package/dist/src/server/dirtree/index.test.js +2 -2
  26. package/dist/src/server/dirtree/json-to-zod.js +1 -1
  27. package/dist/src/server/dirtree/json-to-zod.js.map +1 -1
  28. package/dist/src/server/utilities/tabId.d.ts +1 -1
  29. package/dist/src/server/utilities/tabId.js +1 -1
  30. package/dist/src/server/utilities/tabId.js.map +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +2 -2
  33. package/src/browser/neovim-client.ts +5 -0
  34. package/src/client/MyNeovimConfigModification.test.ts +1 -1
  35. package/src/client/neovim-terminal-client.ts +10 -0
  36. package/src/client/websocket-client.ts +1 -1
  37. package/src/server/applications/neovim/neovimRouter.ts +9 -1
  38. package/src/server/applications/terminal/terminalRouter.ts +1 -1
  39. package/src/server/blockingCommandInputSchema.ts +1 -1
  40. package/src/server/cypress-support/contents.ts +15 -0
  41. package/src/server/dirtree/index.test.ts +2 -2
  42. package/src/server/dirtree/json-to-zod.ts +1 -1
  43. package/src/server/utilities/tabId.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tui-sandbox/library",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mikavilpas/tui-sandbox"
@@ -36,7 +36,7 @@
36
36
  "nodemon": "3.1.10",
37
37
  "vite": "7.0.6",
38
38
  "vitest": "3.2.4",
39
- "zod": "4.0.10"
39
+ "zod": "4.0.14"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "cypress": "^13 || ^14",
@@ -6,6 +6,7 @@ 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
  },
@@ -1,4 +1,4 @@
1
- import { z } from "zod"
1
+ import * as z from "zod"
2
2
  import type { MyNeovimConfigModification } from "./MyNeovimConfigModification.js"
3
3
 
4
4
  const testDirectoryFiles = z.enum([
@@ -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"
@@ -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 {
@@ -2,7 +2,7 @@ import { flavors } from "@catppuccin/palette"
2
2
  import { FitAddon } from "@xterm/addon-fit"
3
3
  import { Terminal } from "@xterm/xterm"
4
4
  import "@xterm/xterm/css/xterm.css"
5
- import { z } from "zod"
5
+ import * as z from "zod"
6
6
  import type { TabId } from "../server/utilities/tabId.ts"
7
7
  import "./style.css"
8
8
  import { validateMouseEvent } from "./validateMouseEvent.js"
@@ -1,5 +1,5 @@
1
1
  import type { Except } from "type-fest"
2
- import { z } from "zod"
2
+ import * as z from "zod"
3
3
  import { blockingCommandInputSchema } from "../../blockingCommandInputSchema.js"
4
4
  import { trpc } from "../../connection/trpc.js"
5
5
  import type { DirectoriesConfig } from "../../updateTestdirectorySchemaFile.js"
@@ -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) {
@@ -1,4 +1,4 @@
1
- import { z } from "zod"
1
+ import * as z from "zod"
2
2
  import { blockingCommandInputSchema } from "../../blockingCommandInputSchema.js"
3
3
  import { trpc } from "../../connection/trpc.js"
4
4
  import type { DirectoriesConfig } from "../../updateTestdirectorySchemaFile.js"
@@ -1,5 +1,5 @@
1
1
  import type { Except } from "type-fest"
2
- import { z } from "zod"
2
+ import * as z from "zod"
3
3
  import { tabIdSchema } from "./utilities/tabId.js"
4
4
 
5
5
  export const blockingCommandInputSchema = z
@@ -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.
@@ -33,7 +33,7 @@ describe("dirtree", () => {
33
33
  // be written with confidence that the files and directories they expect are
34
34
  // actually found. Otherwise the tests are brittle and can break easily.
35
35
 
36
- import { z } from "zod"
36
+ import * as z from "zod"
37
37
 
38
38
  export const MyDirectoryTreeSchema = z.object({
39
39
  name: z.literal("test-environment/"),
@@ -220,7 +220,7 @@ describe("dirtree", () => {
220
220
  // be written with confidence that the files and directories they expect are
221
221
  // actually found. Otherwise the tests are brittle and can break easily.
222
222
 
223
- import { z } from "zod"
223
+ import * as z from "zod"
224
224
 
225
225
  export const MyDirectoryTreeSchema = z.object({
226
226
  type: z.literal("directory"),
@@ -52,7 +52,7 @@ export async function jsonToZod(object: unknown, name: string = "schema"): Promi
52
52
  }
53
53
  const prettierConfig = await resolveConfig(__filename)
54
54
 
55
- return format(`import {z} from "zod"\n\nexport const ${name}=${parse(object, [])}`, {
55
+ return format(`import * as z from "zod"\n\nexport const ${name}=${parse(object, [])}`, {
56
56
  ...(prettierConfig || {}),
57
57
  parser: "babel",
58
58
  plugins: [babelParser],
@@ -1,4 +1,4 @@
1
- import { z } from "zod"
1
+ import * as z from "zod"
2
2
 
3
3
  export type TabId = z.infer<typeof tabIdSchema>
4
4
  export const tabIdSchema = z.object({ tabId: z.string() })