@tui-sandbox/library 11.2.1 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/browser/assets/{index-VJaZoTqH.js → index-DXraucSs.js} +1 -1
- package/dist/browser/index.html +1 -1
- package/dist/src/browser/neovim-client.d.ts +2 -1
- package/dist/src/browser/neovim-client.js +3 -0
- package/dist/src/browser/neovim-client.js.map +1 -1
- package/dist/src/client/neovim-terminal-client.d.ts +2 -1
- package/dist/src/client/neovim-terminal-client.js +8 -0
- package/dist/src/client/neovim-terminal-client.js.map +1 -1
- package/dist/src/server/applications/neovim/neovimRouter.d.ts +9 -0
- package/dist/src/server/applications/neovim/neovimRouter.js +5 -0
- package/dist/src/server/applications/neovim/neovimRouter.js.map +1 -1
- package/dist/src/server/cypress-support/contents.js +15 -0
- package/dist/src/server/cypress-support/contents.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/browser/neovim-client.ts +5 -0
- package/src/client/neovim-terminal-client.ts +10 -0
- package/src/server/applications/neovim/neovimRouter.ts +8 -0
- package/src/server/cypress-support/contents.ts +15 -0
package/package.json
CHANGED
|
@@ -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
|
},
|
|
@@ -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 {
|
|
@@ -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.
|