@tui-sandbox/library 7.1.0 → 7.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/CHANGELOG.md +7 -0
- package/dist/browser/assets/{index-CEBvAIkI.js → index-D3uBGfVO.js} +3 -3
- package/dist/browser/index.html +1 -1
- package/dist/src/browser/neovim-client.d.ts +3 -2
- package/dist/src/browser/neovim-client.js +3 -0
- package/dist/src/client/terminal-client.d.ts +3 -2
- package/dist/src/client/terminal-client.js +7 -0
- package/dist/src/server/cypress-support/contents.js +16 -3
- package/dist/src/server/cypress-support/contents.test.js +15 -1
- package/dist/src/server/neovim/index.d.ts +3 -2
- package/dist/src/server/neovim/index.js +18 -0
- package/dist/src/server/server.d.ts +31 -0
- package/dist/src/server/server.js +4 -0
- package/dist/src/server/types.d.ts +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/browser/neovim-client.ts +7 -1
- package/src/client/terminal-client.ts +15 -1
- package/src/server/cypress-support/contents.test.ts +15 -1
- package/src/server/cypress-support/contents.ts +16 -3
- package/src/server/neovim/index.ts +28 -1
- package/src/server/server.ts +8 -0
- package/src/server/types.ts +2 -0
package/dist/browser/index.html
CHANGED
|
@@ -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-
|
|
6
|
+
<script type="module" crossorigin src="/assets/index-D3uBGfVO.js"></script>
|
|
7
7
|
<link rel="stylesheet" crossorigin href="/assets/index-D6fBrqAi.css">
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { BlockingCommandClientInput, LuaCodeClientInput } from "../server/server.js";
|
|
2
|
-
import type { BlockingShellCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../server/types.js";
|
|
1
|
+
import type { BlockingCommandClientInput, ExCommandClientInput, LuaCodeClientInput } from "../server/server.js";
|
|
2
|
+
import type { BlockingShellCommandOutput, RunExCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../server/types.js";
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
5
|
startNeovim(startArguments?: StartNeovimGenericArguments): Promise<TestDirectory>;
|
|
6
6
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>;
|
|
7
7
|
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>;
|
|
8
|
+
runExCommand(input: ExCommandClientInput): Promise<RunExCommandOutput>;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@xterm/xterm/css/xterm.css";
|
|
2
|
-
import type { BlockingCommandClientInput, LuaCodeClientInput } from "../server/server.js";
|
|
3
|
-
import type { BlockingShellCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../server/types.js";
|
|
2
|
+
import type { BlockingCommandClientInput, ExCommandClientInput, LuaCodeClientInput } from "../server/server.js";
|
|
3
|
+
import type { BlockingShellCommandOutput, RunExCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../server/types.js";
|
|
4
4
|
import "./style.css";
|
|
5
5
|
/** Manages the terminal state in the browser as well as the (browser's)
|
|
6
6
|
* connection to the server side terminal application api. */
|
|
@@ -13,4 +13,5 @@ export declare class TerminalClient {
|
|
|
13
13
|
startNeovim(args: StartNeovimGenericArguments): Promise<TestDirectory>;
|
|
14
14
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>;
|
|
15
15
|
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>;
|
|
16
|
+
runExCommand(input: ExCommandClientInput): Promise<RunExCommandOutput>;
|
|
16
17
|
}
|
|
@@ -4,14 +4,18 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
4
4
|
export async function createCypressSupportFileContents() {
|
|
5
5
|
// this is the interface of tui-sandbox as far as cypress in the user's
|
|
6
6
|
// application is concerned
|
|
7
|
-
let text =
|
|
8
|
-
/// <reference types="cypress" />
|
|
7
|
+
let text = `/// <reference types="cypress" />
|
|
9
8
|
//
|
|
10
9
|
// This file is autogenerated by tui-sandbox. Do not edit it directly.
|
|
11
10
|
//
|
|
12
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
BlockingCommandClientInput,
|
|
13
|
+
ExCommandClientInput,
|
|
14
|
+
LuaCodeClientInput,
|
|
15
|
+
} from "@tui-sandbox/library/dist/src/server/server"
|
|
13
16
|
import type {
|
|
14
17
|
BlockingShellCommandOutput,
|
|
18
|
+
RunExCommandOutput,
|
|
15
19
|
RunLuaCodeOutput,
|
|
16
20
|
StartNeovimGenericArguments,
|
|
17
21
|
} from "@tui-sandbox/library/dist/src/server/types"
|
|
@@ -28,6 +32,7 @@ declare global {
|
|
|
28
32
|
startNeovim(startArguments?: MyStartNeovimServerArguments): Promise<NeovimContext>
|
|
29
33
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>
|
|
30
34
|
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>
|
|
35
|
+
runExCommand(input: ExCommandClientInput): Promise<RunExCommandOutput>
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -64,6 +69,12 @@ Cypress.Commands.add("runLuaCode", (input: LuaCodeClientInput) => {
|
|
|
64
69
|
})
|
|
65
70
|
})
|
|
66
71
|
|
|
72
|
+
Cypress.Commands.add("runExCommand", (input: ExCommandClientInput) => {
|
|
73
|
+
cy.window().then(async win => {
|
|
74
|
+
return await win.runExCommand(input)
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
67
78
|
before(function () {
|
|
68
79
|
// disable Cypress's default behavior of logging all XMLHttpRequests and
|
|
69
80
|
// fetches to the Command Log
|
|
@@ -85,6 +96,8 @@ declare global {
|
|
|
85
96
|
runBlockingShellCommand(input: BlockingCommandClientInput): Chainable<BlockingShellCommandOutput>
|
|
86
97
|
|
|
87
98
|
runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
|
|
99
|
+
|
|
100
|
+
runExCommand(input: ExCommandClientInput): Chainable<RunExCommandOutput>
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
}
|
|
@@ -6,9 +6,14 @@ it("should return the expected contents", async () => {
|
|
|
6
6
|
//
|
|
7
7
|
// This file is autogenerated by tui-sandbox. Do not edit it directly.
|
|
8
8
|
//
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
BlockingCommandClientInput,
|
|
11
|
+
ExCommandClientInput,
|
|
12
|
+
LuaCodeClientInput,
|
|
13
|
+
} from "@tui-sandbox/library/dist/src/server/server"
|
|
10
14
|
import type {
|
|
11
15
|
BlockingShellCommandOutput,
|
|
16
|
+
RunExCommandOutput,
|
|
12
17
|
RunLuaCodeOutput,
|
|
13
18
|
StartNeovimGenericArguments,
|
|
14
19
|
} from "@tui-sandbox/library/dist/src/server/types"
|
|
@@ -25,6 +30,7 @@ it("should return the expected contents", async () => {
|
|
|
25
30
|
startNeovim(startArguments?: MyStartNeovimServerArguments): Promise<NeovimContext>
|
|
26
31
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>
|
|
27
32
|
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>
|
|
33
|
+
runExCommand(input: ExCommandClientInput): Promise<RunExCommandOutput>
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -61,6 +67,12 @@ it("should return the expected contents", async () => {
|
|
|
61
67
|
})
|
|
62
68
|
})
|
|
63
69
|
|
|
70
|
+
Cypress.Commands.add("runExCommand", (input: ExCommandClientInput) => {
|
|
71
|
+
cy.window().then(async win => {
|
|
72
|
+
return await win.runExCommand(input)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
64
76
|
before(function () {
|
|
65
77
|
// disable Cypress's default behavior of logging all XMLHttpRequests and
|
|
66
78
|
// fetches to the Command Log
|
|
@@ -82,6 +94,8 @@ it("should return the expected contents", async () => {
|
|
|
82
94
|
runBlockingShellCommand(input: BlockingCommandClientInput): Chainable<BlockingShellCommandOutput>
|
|
83
95
|
|
|
84
96
|
runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
|
|
97
|
+
|
|
98
|
+
runExCommand(input: ExCommandClientInput): Chainable<RunExCommandOutput>
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "core-js/proposals/async-explicit-resource-management.js";
|
|
2
|
-
import type { BlockingCommandInput, LuaCodeInput } from "../server.js";
|
|
3
|
-
import type { BlockingShellCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../types.js";
|
|
2
|
+
import type { BlockingCommandInput, ExCommandInput, LuaCodeInput } from "../server.js";
|
|
3
|
+
import type { BlockingShellCommandOutput, RunExCommandOutput, RunLuaCodeOutput, StartNeovimGenericArguments, TestDirectory } from "../types.js";
|
|
4
4
|
import type { TestServerConfig } from "../updateTestdirectorySchemaFile.js";
|
|
5
5
|
import type { TabId } from "../utilities/tabId.js";
|
|
6
6
|
import type { TerminalDimensions } from "./NeovimApplication.js";
|
|
@@ -14,3 +14,4 @@ export declare function sendStdin(options: {
|
|
|
14
14
|
}): Promise<void>;
|
|
15
15
|
export declare function runBlockingShellCommand(signal: AbortSignal | undefined, input: BlockingCommandInput, allowFailure: boolean): Promise<BlockingShellCommandOutput>;
|
|
16
16
|
export declare function runLuaCode(options: LuaCodeInput): Promise<RunLuaCodeOutput>;
|
|
17
|
+
export declare function runExCommand(options: ExCommandInput): Promise<RunExCommandOutput>;
|
|
@@ -88,3 +88,21 @@ export async function runLuaCode(options) {
|
|
|
88
88
|
throw new Error(`Error running Lua code: ${options.luaCode}`, { cause: e });
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
export async function runExCommand(options) {
|
|
92
|
+
const neovim = neovims.get(options.tabId.tabId);
|
|
93
|
+
assert(neovim !== undefined, `Neovim instance for clientId not found - cannot runExCommand. Maybe neovim's not started yet?`);
|
|
94
|
+
assert(neovim.application, `Neovim application not found for client id ${options.tabId.tabId}. Maybe it's not started yet?`);
|
|
95
|
+
const api = await neovim.state?.client.get();
|
|
96
|
+
if (!api) {
|
|
97
|
+
throw new Error(`Neovim API not available for client id ${options.tabId.tabId}. Maybe it's not started yet?`);
|
|
98
|
+
}
|
|
99
|
+
console.log(`Neovim ${neovim.application.processId()} running Ex command: ${options.command}`);
|
|
100
|
+
try {
|
|
101
|
+
const output = await api.commandOutput(options.command);
|
|
102
|
+
return { value: output };
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
console.warn(`Error running Ex command: ${options.command}`, e);
|
|
106
|
+
throw new Error(`Error running Ex command: ${options.command}`, { cause: e });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -66,6 +66,28 @@ declare const luaCodeInputSchema: z.ZodObject<{
|
|
|
66
66
|
}>;
|
|
67
67
|
export type LuaCodeClientInput = Except<LuaCodeInput, "tabId">;
|
|
68
68
|
export type LuaCodeInput = z.infer<typeof luaCodeInputSchema>;
|
|
69
|
+
declare const exCommandInputSchema: z.ZodObject<{
|
|
70
|
+
tabId: z.ZodObject<{
|
|
71
|
+
tabId: z.ZodString;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
tabId: string;
|
|
74
|
+
}, {
|
|
75
|
+
tabId: string;
|
|
76
|
+
}>;
|
|
77
|
+
command: z.ZodString;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
command: string;
|
|
80
|
+
tabId: {
|
|
81
|
+
tabId: string;
|
|
82
|
+
};
|
|
83
|
+
}, {
|
|
84
|
+
command: string;
|
|
85
|
+
tabId: {
|
|
86
|
+
tabId: string;
|
|
87
|
+
};
|
|
88
|
+
}>;
|
|
89
|
+
export type ExCommandClientInput = Except<ExCommandInput, "tabId">;
|
|
90
|
+
export type ExCommandInput = z.infer<typeof exCommandInputSchema>;
|
|
69
91
|
/** @private */
|
|
70
92
|
export declare function createAppRouter(config: TestServerConfig): Promise<import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
71
93
|
ctx: object;
|
|
@@ -139,6 +161,15 @@ export declare function createAppRouter(config: TestServerConfig): Promise<impor
|
|
|
139
161
|
};
|
|
140
162
|
output: import("./types.js").RunLuaCodeOutput;
|
|
141
163
|
}>;
|
|
164
|
+
runExCommand: import("@trpc/server").TRPCMutationProcedure<{
|
|
165
|
+
input: {
|
|
166
|
+
command: string;
|
|
167
|
+
tabId: {
|
|
168
|
+
tabId: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
output: import("./types.js").RunExCommandOutput;
|
|
172
|
+
}>;
|
|
142
173
|
}>;
|
|
143
174
|
}>>>;
|
|
144
175
|
export type AppRouter = Awaited<ReturnType<typeof createAppRouter>>;
|
|
@@ -17,6 +17,7 @@ const blockingCommandInputSchema = z.object({
|
|
|
17
17
|
envOverrides: z.record(z.string()).optional(),
|
|
18
18
|
});
|
|
19
19
|
const luaCodeInputSchema = z.object({ tabId: tabIdSchema, luaCode: z.string() });
|
|
20
|
+
const exCommandInputSchema = z.object({ tabId: tabIdSchema, command: z.string() });
|
|
20
21
|
/** @private */
|
|
21
22
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
22
23
|
export async function createAppRouter(config) {
|
|
@@ -58,6 +59,9 @@ export async function createAppRouter(config) {
|
|
|
58
59
|
runLuaCode: trpc.procedure.input(luaCodeInputSchema).mutation(options => {
|
|
59
60
|
return neovim.runLuaCode(options.input);
|
|
60
61
|
}),
|
|
62
|
+
runExCommand: trpc.procedure.input(exCommandInputSchema).mutation(options => {
|
|
63
|
+
return neovim.runExCommand(options.input);
|
|
64
|
+
}),
|
|
61
65
|
}),
|
|
62
66
|
});
|
|
63
67
|
return appRouter;
|