@tui-sandbox/library 7.0.1 → 7.1.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 +12 -0
- package/dist/browser/assets/{index-Bup5cvb2.js → index-CEBvAIkI.js} +7 -7
- package/dist/browser/assets/{index-Bf37MeF1.css → index-D6fBrqAi.css} +1 -1
- package/dist/browser/index.html +2 -2
- 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 +12 -2
- package/dist/src/server/cypress-support/contents.test.js +11 -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 +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/browser/neovim-client.ts +12 -2
- package/src/client/style.css +6 -0
- package/src/client/terminal-client.ts +15 -2
- package/src/server/cypress-support/contents.test.ts +11 -1
- package/src/server/cypress-support/contents.ts +12 -2
- package/src/server/neovim/index.ts +33 -2
- package/src/server/server.ts +8 -0
- package/src/server/types.ts +7 -0
- package/tsconfig.json +1 -2
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
* The original design remains. The terminal itself
|
|
30
30
|
* has been extended to include xterm CSI codes, among
|
|
31
31
|
* other features.
|
|
32
|
-
*/.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}@font-face{font-family:DejaVuSansMNerdFontMono;src:url(/assets/DejaVuSansMNerdFontMono-Regular-CRJgiq0O.ttf);font-weight:400;font-style:normal}:root{color-scheme:dark;background-color:#000}#app{display:flex;height:100vh;width:100vw}*{font-family:DejaVuSansMNerdFontMono,monospace}body{overflow-y:hidden;overflow-x:hidden}
|
|
32
|
+
*/.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}@font-face{font-family:DejaVuSansMNerdFontMono;src:url(/assets/DejaVuSansMNerdFontMono-Regular-CRJgiq0O.ttf);font-weight:400;font-style:normal}:root{color-scheme:dark;background-color:#000}#app{display:flex;height:100vh;width:100vw}*{font-family:DejaVuSansMNerdFontMono,monospace}.xterm .xterm-viewport{overflow-y:hidden}body{overflow-y:hidden;overflow-x:hidden;margin:0}
|
package/dist/browser/index.html
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
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-
|
|
7
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
6
|
+
<script type="module" crossorigin src="/assets/index-CEBvAIkI.js"></script>
|
|
7
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D6fBrqAi.css">
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<div id="app"></div>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { BlockingCommandClientInput } from "../server/server.js";
|
|
2
|
-
import type { BlockingShellCommandOutput, StartNeovimGenericArguments, TestDirectory } from "../server/types.js";
|
|
1
|
+
import type { BlockingCommandClientInput, LuaCodeClientInput } from "../server/server.js";
|
|
2
|
+
import type { BlockingShellCommandOutput, 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
|
+
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>;
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@xterm/xterm/css/xterm.css";
|
|
2
|
-
import type { BlockingCommandClientInput } from "../server/server.js";
|
|
3
|
-
import type { BlockingShellCommandOutput, StartNeovimGenericArguments, TestDirectory } from "../server/types.js";
|
|
2
|
+
import type { BlockingCommandClientInput, LuaCodeClientInput } from "../server/server.js";
|
|
3
|
+
import type { BlockingShellCommandOutput, 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. */
|
|
@@ -12,4 +12,5 @@ export declare class TerminalClient {
|
|
|
12
12
|
constructor(app: HTMLElement);
|
|
13
13
|
startNeovim(args: StartNeovimGenericArguments): Promise<TestDirectory>;
|
|
14
14
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>;
|
|
15
|
+
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>;
|
|
15
16
|
}
|
|
@@ -4,14 +4,15 @@ 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 = `
|
|
7
|
+
let text = `
|
|
8
8
|
/// <reference types="cypress" />
|
|
9
9
|
//
|
|
10
10
|
// This file is autogenerated by tui-sandbox. Do not edit it directly.
|
|
11
11
|
//
|
|
12
|
-
import type { BlockingCommandClientInput } from "@tui-sandbox/library/dist/src/server/server"
|
|
12
|
+
import type { BlockingCommandClientInput, LuaCodeClientInput } from "@tui-sandbox/library/dist/src/server/server"
|
|
13
13
|
import type {
|
|
14
14
|
BlockingShellCommandOutput,
|
|
15
|
+
RunLuaCodeOutput,
|
|
15
16
|
StartNeovimGenericArguments,
|
|
16
17
|
} from "@tui-sandbox/library/dist/src/server/types"
|
|
17
18
|
import type { OverrideProperties } from "type-fest"
|
|
@@ -26,6 +27,7 @@ declare global {
|
|
|
26
27
|
interface Window {
|
|
27
28
|
startNeovim(startArguments?: MyStartNeovimServerArguments): Promise<NeovimContext>
|
|
28
29
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>
|
|
30
|
+
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -56,6 +58,12 @@ Cypress.Commands.add("typeIntoTerminal", (text: string, options?: Partial<Cypres
|
|
|
56
58
|
cy.get("textarea").focus().type(text, options)
|
|
57
59
|
})
|
|
58
60
|
|
|
61
|
+
Cypress.Commands.add("runLuaCode", (input: LuaCodeClientInput) => {
|
|
62
|
+
cy.window().then(async win => {
|
|
63
|
+
return await win.runLuaCode(input)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
59
67
|
before(function () {
|
|
60
68
|
// disable Cypress's default behavior of logging all XMLHttpRequests and
|
|
61
69
|
// fetches to the Command Log
|
|
@@ -75,6 +83,8 @@ declare global {
|
|
|
75
83
|
/** Runs a shell command in a blocking manner, waiting for the command to
|
|
76
84
|
* finish before returning. Requires neovim to be running. */
|
|
77
85
|
runBlockingShellCommand(input: BlockingCommandClientInput): Chainable<BlockingShellCommandOutput>
|
|
86
|
+
|
|
87
|
+
runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
}
|
|
@@ -6,9 +6,10 @@ 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 { BlockingCommandClientInput } from "@tui-sandbox/library/dist/src/server/server"
|
|
9
|
+
import type { BlockingCommandClientInput, LuaCodeClientInput } from "@tui-sandbox/library/dist/src/server/server"
|
|
10
10
|
import type {
|
|
11
11
|
BlockingShellCommandOutput,
|
|
12
|
+
RunLuaCodeOutput,
|
|
12
13
|
StartNeovimGenericArguments,
|
|
13
14
|
} from "@tui-sandbox/library/dist/src/server/types"
|
|
14
15
|
import type { OverrideProperties } from "type-fest"
|
|
@@ -23,6 +24,7 @@ it("should return the expected contents", async () => {
|
|
|
23
24
|
interface Window {
|
|
24
25
|
startNeovim(startArguments?: MyStartNeovimServerArguments): Promise<NeovimContext>
|
|
25
26
|
runBlockingShellCommand(input: BlockingCommandClientInput): Promise<BlockingShellCommandOutput>
|
|
27
|
+
runLuaCode(input: LuaCodeClientInput): Promise<RunLuaCodeOutput>
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -53,6 +55,12 @@ it("should return the expected contents", async () => {
|
|
|
53
55
|
cy.get("textarea").focus().type(text, options)
|
|
54
56
|
})
|
|
55
57
|
|
|
58
|
+
Cypress.Commands.add("runLuaCode", (input: LuaCodeClientInput) => {
|
|
59
|
+
cy.window().then(async win => {
|
|
60
|
+
return await win.runLuaCode(input)
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
56
64
|
before(function () {
|
|
57
65
|
// disable Cypress's default behavior of logging all XMLHttpRequests and
|
|
58
66
|
// fetches to the Command Log
|
|
@@ -72,6 +80,8 @@ it("should return the expected contents", async () => {
|
|
|
72
80
|
/** Runs a shell command in a blocking manner, waiting for the command to
|
|
73
81
|
* finish before returning. Requires neovim to be running. */
|
|
74
82
|
runBlockingShellCommand(input: BlockingCommandClientInput): Chainable<BlockingShellCommandOutput>
|
|
83
|
+
|
|
84
|
+
runLuaCode(input: LuaCodeClientInput): Chainable<RunLuaCodeOutput>
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "core-js/proposals/async-explicit-resource-management.js";
|
|
2
|
-
import type { BlockingCommandInput } from "../server.js";
|
|
3
|
-
import type { BlockingShellCommandOutput, StartNeovimGenericArguments, TestDirectory } from "../types.js";
|
|
2
|
+
import type { BlockingCommandInput, LuaCodeInput } from "../server.js";
|
|
3
|
+
import type { BlockingShellCommandOutput, 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";
|
|
@@ -13,3 +13,4 @@ export declare function sendStdin(options: {
|
|
|
13
13
|
data: string;
|
|
14
14
|
}): Promise<void>;
|
|
15
15
|
export declare function runBlockingShellCommand(signal: AbortSignal | undefined, input: BlockingCommandInput, allowFailure: boolean): Promise<BlockingShellCommandOutput>;
|
|
16
|
+
export declare function runLuaCode(options: LuaCodeInput): Promise<RunLuaCodeOutput>;
|
|
@@ -70,3 +70,21 @@ export async function runBlockingShellCommand(signal, input, allowFailure) {
|
|
|
70
70
|
throw new Error(`Error running shell blockingCommand (${input.command})`, { cause: e });
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
export async function runLuaCode(options) {
|
|
74
|
+
const neovim = neovims.get(options.tabId.tabId);
|
|
75
|
+
assert(neovim !== undefined, `Neovim instance for clientId not found - cannot run Lua code. Maybe neovim's not started yet?`);
|
|
76
|
+
assert(neovim.application, `Neovim application not found for client id ${options.tabId.tabId}. Maybe it's not started yet?`);
|
|
77
|
+
const api = await neovim.state?.client.get();
|
|
78
|
+
if (!api) {
|
|
79
|
+
throw new Error(`Neovim API not available for client id ${options.tabId.tabId}. Maybe it's not started yet?`);
|
|
80
|
+
}
|
|
81
|
+
console.log(`Neovim ${neovim.application.processId()} running Lua code: ${options.luaCode}`);
|
|
82
|
+
try {
|
|
83
|
+
const value = await api.lua(options.luaCode);
|
|
84
|
+
return { value };
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
console.warn(`Error running Lua code: ${options.luaCode}`, e);
|
|
88
|
+
throw new Error(`Error running Lua code: ${options.luaCode}`, { cause: e });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -44,6 +44,28 @@ declare const blockingCommandInputSchema: z.ZodObject<{
|
|
|
44
44
|
}>;
|
|
45
45
|
export type BlockingCommandClientInput = Except<BlockingCommandInput, "tabId">;
|
|
46
46
|
export type BlockingCommandInput = z.infer<typeof blockingCommandInputSchema>;
|
|
47
|
+
declare const luaCodeInputSchema: z.ZodObject<{
|
|
48
|
+
tabId: z.ZodObject<{
|
|
49
|
+
tabId: z.ZodString;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
tabId: string;
|
|
52
|
+
}, {
|
|
53
|
+
tabId: string;
|
|
54
|
+
}>;
|
|
55
|
+
luaCode: z.ZodString;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
tabId: {
|
|
58
|
+
tabId: string;
|
|
59
|
+
};
|
|
60
|
+
luaCode: string;
|
|
61
|
+
}, {
|
|
62
|
+
tabId: {
|
|
63
|
+
tabId: string;
|
|
64
|
+
};
|
|
65
|
+
luaCode: string;
|
|
66
|
+
}>;
|
|
67
|
+
export type LuaCodeClientInput = Except<LuaCodeInput, "tabId">;
|
|
68
|
+
export type LuaCodeInput = z.infer<typeof luaCodeInputSchema>;
|
|
47
69
|
/** @private */
|
|
48
70
|
export declare function createAppRouter(config: TestServerConfig): Promise<import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
49
71
|
ctx: object;
|
|
@@ -108,6 +130,15 @@ export declare function createAppRouter(config: TestServerConfig): Promise<impor
|
|
|
108
130
|
};
|
|
109
131
|
output: import("./types.js").BlockingShellCommandOutput;
|
|
110
132
|
}>;
|
|
133
|
+
runLuaCode: import("@trpc/server").TRPCMutationProcedure<{
|
|
134
|
+
input: {
|
|
135
|
+
tabId: {
|
|
136
|
+
tabId: string;
|
|
137
|
+
};
|
|
138
|
+
luaCode: string;
|
|
139
|
+
};
|
|
140
|
+
output: import("./types.js").RunLuaCodeOutput;
|
|
141
|
+
}>;
|
|
111
142
|
}>;
|
|
112
143
|
}>>>;
|
|
113
144
|
export type AppRouter = Awaited<ReturnType<typeof createAppRouter>>;
|
|
@@ -16,6 +16,7 @@ const blockingCommandInputSchema = z.object({
|
|
|
16
16
|
cwd: z.string().optional(),
|
|
17
17
|
envOverrides: z.record(z.string()).optional(),
|
|
18
18
|
});
|
|
19
|
+
const luaCodeInputSchema = z.object({ tabId: tabIdSchema, luaCode: z.string() });
|
|
19
20
|
/** @private */
|
|
20
21
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
21
22
|
export async function createAppRouter(config) {
|
|
@@ -54,6 +55,9 @@ export async function createAppRouter(config) {
|
|
|
54
55
|
runBlockingShellCommand: trpc.procedure.input(blockingCommandInputSchema).mutation(async (options) => {
|
|
55
56
|
return neovim.runBlockingShellCommand(options.signal, options.input, options.input.allowFailure ?? false);
|
|
56
57
|
}),
|
|
58
|
+
runLuaCode: trpc.procedure.input(luaCodeInputSchema).mutation(options => {
|
|
59
|
+
return neovim.runLuaCode(options.input);
|
|
60
|
+
}),
|
|
57
61
|
}),
|
|
58
62
|
});
|
|
59
63
|
return appRouter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VimValue } from "neovim/lib/types/VimValue.js";
|
|
1
2
|
/** Describes the contents of the test directory, which is a blueprint for
|
|
2
3
|
* files and directories. Tests can create a unique, safe environment for
|
|
3
4
|
* interacting with the contents of such a directory.
|
|
@@ -33,3 +34,6 @@ export type BlockingShellCommandOutput = {
|
|
|
33
34
|
} | {
|
|
34
35
|
type: "failed";
|
|
35
36
|
};
|
|
37
|
+
export type RunLuaCodeOutput = {
|
|
38
|
+
value?: VimValue;
|
|
39
|
+
};
|