@tui-sandbox/library 3.0.0 → 4.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 +18 -0
- package/dist/browser/assets/DejaVuSansMNerdFontMono-Regular-CRJgiq0O.ttf +0 -0
- package/dist/browser/assets/index-BckJD5M_.js +9 -0
- package/dist/browser/assets/index-Bf37MeF1.css +32 -0
- package/dist/browser/index.html +12 -0
- package/dist/src/browser/neovim-client.d.ts +7 -0
- package/dist/src/browser/neovim-client.js +14 -0
- package/dist/src/client/color-utilities.d.ts +6 -0
- package/dist/src/client/color-utilities.js +5 -0
- package/dist/src/client/color-utilities.test.d.ts +1 -0
- package/dist/src/client/color-utilities.test.js +7 -0
- package/dist/src/client/index.d.ts +2 -1
- package/dist/src/client/index.js +2 -1
- package/dist/src/client/neovim-client.js +4 -4
- package/dist/src/client/websocket-client.js +1 -1
- package/dist/src/scripts/tui.d.ts +1 -0
- package/dist/src/scripts/tui.js +25 -0
- package/dist/src/server/TestServer.d.ts +6 -4
- package/dist/src/server/TestServer.js +35 -11
- package/dist/src/server/dirtree/index.js +1 -1
- package/dist/src/server/dirtree/index.test.js +2 -2
- package/dist/src/server/index.d.ts +4 -4
- package/dist/src/server/index.js +3 -3
- package/dist/src/server/neovim/NeovimApplication.d.ts +2 -2
- package/dist/src/server/neovim/NeovimApplication.js +3 -3
- package/dist/src/server/neovim/NeovimJavascriptApiClient.d.ts +1 -1
- package/dist/src/server/neovim/NeovimJavascriptApiClient.js +1 -1
- package/dist/src/server/neovim/NeovimJavascriptApiClient.test.js +1 -1
- package/dist/src/server/neovim/environment/createTempDir.d.ts +2 -2
- package/dist/src/server/neovim/environment/createTempDir.js +2 -2
- package/dist/src/server/neovim/environment/createTempDir.test.js +75 -11
- package/dist/src/server/neovim/index.d.ts +4 -4
- package/dist/src/server/neovim/index.js +3 -3
- package/dist/src/server/server.d.ts +4 -3
- package/dist/src/server/server.js +80 -12
- package/dist/src/server/server.test.js +2 -2
- package/dist/src/server/updateTestdirectorySchemaFile.d.ts +0 -1
- package/dist/src/server/updateTestdirectorySchemaFile.js +1 -2
- package/dist/src/server/updateTestdirectorySchemaFile.test.js +2 -2
- package/dist/src/server/utilities/DisposableSingleApplication.d.ts +1 -1
- package/dist/src/server/utilities/DisposableSingleApplication.test.js +1 -1
- package/dist/src/server/utilities/TerminalApplication.d.ts +1 -1
- package/dist/src/server/utilities/applicationAvailable.test.js +1 -1
- package/dist/src/server/utilities/generator.test.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.html +11 -0
- package/package.json +15 -5
- package/src/browser/neovim-client.ts +26 -0
- package/src/client/color-utilities.test.ts +8 -0
- package/src/client/color-utilities.ts +9 -0
- package/src/client/index.ts +2 -1
- package/src/client/neovim-client.ts +4 -4
- package/src/client/websocket-client.ts +1 -1
- package/src/scripts/tui.ts +29 -0
- package/src/server/TestServer.ts +50 -15
- package/src/server/dirtree/index.test.ts +2 -2
- package/src/server/dirtree/index.ts +1 -1
- package/src/server/index.ts +4 -5
- package/src/server/neovim/NeovimApplication.ts +5 -5
- package/src/server/neovim/NeovimJavascriptApiClient.test.ts +2 -2
- package/src/server/neovim/NeovimJavascriptApiClient.ts +1 -1
- package/src/server/neovim/environment/createTempDir.test.ts +2 -2
- package/src/server/neovim/environment/createTempDir.ts +4 -4
- package/src/server/neovim/index.ts +7 -7
- package/src/server/server.test.ts +2 -2
- package/src/server/server.ts +10 -7
- package/src/server/updateTestdirectorySchemaFile.test.ts +3 -3
- package/src/server/updateTestdirectorySchemaFile.ts +1 -2
- package/src/server/utilities/DisposableSingleApplication.test.ts +2 -2
- package/src/server/utilities/DisposableSingleApplication.ts +1 -1
- package/src/server/utilities/TerminalApplication.ts +1 -1
- package/src/server/utilities/applicationAvailable.test.ts +1 -1
- package/src/server/utilities/generator.test.ts +1 -1
- package/tsconfig.json +10 -4
- package/vite.config.js +26 -0
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -8
- package/vitest.config.ts +0 -9
package/index.html
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tui-sandbox/library",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tui": "dist/src/scripts/tui.js"
|
|
8
|
+
},
|
|
6
9
|
"dependencies": {
|
|
7
10
|
"@catppuccin/palette": "1.7.1",
|
|
8
|
-
"@trpc/client": "11.0.0-rc.
|
|
9
|
-
"@trpc/server": "11.0.0-rc.
|
|
11
|
+
"@trpc/client": "11.0.0-rc.630",
|
|
12
|
+
"@trpc/server": "11.0.0-rc.630",
|
|
10
13
|
"@xterm/addon-attach": "0.11.0",
|
|
11
14
|
"@xterm/addon-fit": "0.10.0",
|
|
12
15
|
"@xterm/xterm": "5.5.0",
|
|
@@ -14,23 +17,30 @@
|
|
|
14
17
|
"core-js": "3.39.0",
|
|
15
18
|
"cors": "2.8.5",
|
|
16
19
|
"dree": "5.1.5",
|
|
20
|
+
"express": "4.21.1",
|
|
17
21
|
"neovim": "5.3.0",
|
|
18
22
|
"node-pty": "1.0.0",
|
|
19
23
|
"prettier": "3.3.3",
|
|
24
|
+
"tsx": "4.19.2",
|
|
20
25
|
"type-fest": "4.26.1",
|
|
21
|
-
"winston": "3.
|
|
26
|
+
"winston": "3.17.0",
|
|
22
27
|
"zod": "3.23.8"
|
|
23
28
|
},
|
|
24
29
|
"devDependencies": {
|
|
25
30
|
"@runtyping/zod": "2.1.1",
|
|
26
31
|
"@types/command-exists": "1.2.3",
|
|
27
32
|
"@types/cors": "2.8.17",
|
|
33
|
+
"@types/express": "5.0.0",
|
|
28
34
|
"@types/node": "22.9.0",
|
|
29
35
|
"nodemon": "3.1.7",
|
|
36
|
+
"vite": "5.4.11",
|
|
30
37
|
"vitest": "2.1.4"
|
|
31
38
|
},
|
|
32
39
|
"scripts": {
|
|
33
|
-
"build": "tsc",
|
|
40
|
+
"build": "concurrently --names 'vite,tsc' 'vite build' 'tsc' --prefix-colors blue,green",
|
|
41
|
+
"dev": "concurrently --names 'client,server' 'pnpm dev:client' 'pnpm dev:server' --prefix-colors blue,green",
|
|
42
|
+
"dev:client": "vite",
|
|
43
|
+
"dev:server": "cd ../integration-tests/ && nodemon --watch ../library --ext '*' --exec 'tsx ../library/src/scripts/tui.ts start'",
|
|
34
44
|
"test": "vitest"
|
|
35
45
|
}
|
|
36
46
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NeovimClient } from "../client/index.js"
|
|
2
|
+
import type { StartNeovimGenericArguments } from "../server/neovim/NeovimApplication.js"
|
|
3
|
+
import type { TestDirectory } from "../server/types.js"
|
|
4
|
+
|
|
5
|
+
const app = document.querySelector<HTMLElement>("#app")
|
|
6
|
+
if (!app) {
|
|
7
|
+
throw new Error("No app element found")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const client = new NeovimClient(app)
|
|
11
|
+
|
|
12
|
+
/** Entrypoint for the test runner (cypress) */
|
|
13
|
+
window.startNeovim = async function (startArgs?: StartNeovimGenericArguments): Promise<TestDirectory> {
|
|
14
|
+
const testDirectory = await client.startNeovim({
|
|
15
|
+
filename: startArgs?.filename ?? "initial-file.txt",
|
|
16
|
+
startupScriptModifications: startArgs?.startupScriptModifications ?? [],
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return testDirectory
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface Window {
|
|
24
|
+
startNeovim(startArguments?: StartNeovimGenericArguments): Promise<TestDirectory>
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { flavors } from "@catppuccin/palette"
|
|
2
|
+
|
|
3
|
+
type RgbColor = (typeof flavors.macchiato.colors)["surface0"]["rgb"]
|
|
4
|
+
|
|
5
|
+
/** Convert a catppuccin RGB color to a CSS color string. This way you can
|
|
6
|
+
* assert that text that's visible on the screen has a specific color. */
|
|
7
|
+
export function rgbify(color: RgbColor): string {
|
|
8
|
+
return `rgb(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()})`
|
|
9
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -20,10 +20,10 @@ export class NeovimClient {
|
|
|
20
20
|
splitLink({
|
|
21
21
|
condition: operation => operation.type === "subscription",
|
|
22
22
|
true: unstable_httpSubscriptionLink({
|
|
23
|
-
url: "
|
|
23
|
+
url: "/trpc",
|
|
24
24
|
}),
|
|
25
25
|
false: httpBatchLink({
|
|
26
|
-
url: "
|
|
26
|
+
url: "/trpc",
|
|
27
27
|
}),
|
|
28
28
|
}),
|
|
29
29
|
],
|
|
@@ -69,7 +69,7 @@ export class NeovimClient {
|
|
|
69
69
|
public async startNeovim(args: Except<StartNeovimGenericArguments, "terminalDimensions">): Promise<TestDirectory> {
|
|
70
70
|
await this.ready
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const testDirectory = await this.trpc.neovim.start.mutate({
|
|
73
73
|
startNeovimArguments: {
|
|
74
74
|
...args,
|
|
75
75
|
terminalDimensions: {
|
|
@@ -80,6 +80,6 @@ export class NeovimClient {
|
|
|
80
80
|
tabId: this.tabId,
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
-
return
|
|
83
|
+
return testDirectory
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -5,7 +5,7 @@ import "@xterm/xterm/css/xterm.css"
|
|
|
5
5
|
import z from "zod"
|
|
6
6
|
import type { TabId } from "../server/utilities/tabId.ts"
|
|
7
7
|
import "./style.css"
|
|
8
|
-
import { validateMouseEvent } from "./validateMouseEvent"
|
|
8
|
+
import { validateMouseEvent } from "./validateMouseEvent.js"
|
|
9
9
|
|
|
10
10
|
export type StartTerminalOptions = {
|
|
11
11
|
onMouseEvent: (data: string) => void
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { stat } from "node:fs/promises"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import { startTestServer } from "../server/index.js"
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// This is the main entrypoint to tui-sandbox
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
// the arguments passed to this script start at index 2
|
|
10
|
+
const args = process.argv.slice(2)
|
|
11
|
+
|
|
12
|
+
if (args[0] !== "start") {
|
|
13
|
+
throw new Error(`Usage: tui start`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The cwd in the user's directory when they are running this script. Not the
|
|
17
|
+
* cwd of the script itself. */
|
|
18
|
+
const cwd = process.cwd()
|
|
19
|
+
console.log(`🚀 Starting test server in ${cwd}`)
|
|
20
|
+
await stat(path.join(cwd, "MyTestDirectory.ts"))
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await startTestServer({
|
|
24
|
+
testEnvironmentPath: path.join(cwd, "test-environment/"),
|
|
25
|
+
outputFilePath: path.join(cwd, "MyTestDirectory.ts"),
|
|
26
|
+
})
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error(e)
|
|
29
|
+
}
|
package/src/server/TestServer.ts
CHANGED
|
@@ -1,36 +1,71 @@
|
|
|
1
1
|
import type { AnyTRPCRouter } from "@trpc/server"
|
|
2
|
-
import
|
|
3
|
-
import "core-js/proposals/async-explicit-resource-management"
|
|
2
|
+
import * as trpcExpress from "@trpc/server/adapters/express"
|
|
4
3
|
import cors from "cors"
|
|
5
4
|
import { once } from "events"
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import express from "express"
|
|
6
|
+
import { accessSync } from "fs"
|
|
7
|
+
import path from "path"
|
|
8
|
+
import { fileURLToPath } from "url"
|
|
9
|
+
import type { TestServerConfig } from "./updateTestdirectorySchemaFile.js"
|
|
10
|
+
import { updateTestdirectorySchemaFile } from "./updateTestdirectorySchemaFile.js"
|
|
11
|
+
|
|
12
|
+
export type TestServerSettings = {
|
|
13
|
+
port: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
17
|
+
const __dirname = path.dirname(__filename)
|
|
8
18
|
|
|
9
19
|
export class TestServer {
|
|
10
|
-
public constructor(private readonly
|
|
20
|
+
public constructor(private readonly settings: TestServerSettings) {}
|
|
11
21
|
|
|
12
22
|
public async startAndRun(appRouter: AnyTRPCRouter, config: TestServerConfig): Promise<void> {
|
|
13
23
|
console.log("🚀 Server starting")
|
|
14
24
|
|
|
15
25
|
await updateTestdirectorySchemaFile(config)
|
|
16
26
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
const app = express()
|
|
28
|
+
app.use(
|
|
29
|
+
"/trpc",
|
|
30
|
+
trpcExpress.createExpressMiddleware({
|
|
31
|
+
router: appRouter,
|
|
32
|
+
createContext: () => ({}),
|
|
33
|
+
middleware: cors({
|
|
34
|
+
origin: "*",
|
|
35
|
+
}),
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
const publicPath = path.resolve(__dirname, "..", "..", "browser")
|
|
41
|
+
try {
|
|
42
|
+
accessSync(publicPath)
|
|
43
|
+
} catch (e) {
|
|
44
|
+
// This is normal when developing the tui-sandbox library locally. It
|
|
45
|
+
// should always exist when using it as an npm package, however.
|
|
46
|
+
console.log(`⚠️ Warning: the tui-sandbox root contents directory is not accessible at: ${publicPath}`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line import-x/no-named-as-default-member
|
|
50
|
+
app.use(express.static(publicPath))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
app.use("/ping", (_, res) => {
|
|
54
|
+
console.log("🏓 received /ping")
|
|
55
|
+
res.send("pong")
|
|
23
56
|
})
|
|
24
57
|
|
|
25
|
-
server.listen(this.port)
|
|
58
|
+
const server = app.listen(this.settings.port, "0.0.0.0")
|
|
59
|
+
|
|
26
60
|
server.on("connection", socket => {
|
|
27
|
-
|
|
61
|
+
const connectionInfo = `${socket.remoteAddress}:${socket.remotePort}`
|
|
62
|
+
console.log(`➕➕ Connection from ${connectionInfo}`)
|
|
28
63
|
socket.once("close", () => {
|
|
29
|
-
console.log(`➖➖ Connection`)
|
|
64
|
+
console.log(`➖➖ Connection from ${connectionInfo}`)
|
|
30
65
|
})
|
|
31
66
|
})
|
|
32
67
|
|
|
33
|
-
console.log(`✅ Server listening on
|
|
68
|
+
console.log(`✅ Server listening on port ${this.settings.port}`)
|
|
34
69
|
|
|
35
70
|
await Promise.race([once(process, "SIGTERM"), once(process, "SIGINT")])
|
|
36
71
|
console.log("Shutting down...")
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
2
|
import path from "path"
|
|
3
3
|
import { describe, expect, it } from "vitest"
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Lazy } from "../utilities/Lazy.js"
|
|
5
|
+
import { buildSchemaForDirectoryTree, getDirectoryTree } from "./index.js"
|
|
6
6
|
|
|
7
7
|
describe("dirtree", () => {
|
|
8
8
|
const output = new Lazy(() =>
|
|
@@ -3,7 +3,7 @@ import type { Dree } from "dree"
|
|
|
3
3
|
import { scan, Type } from "dree"
|
|
4
4
|
import { format, resolveConfig } from "prettier"
|
|
5
5
|
import { fileURLToPath } from "url"
|
|
6
|
-
import { jsonToZod } from "./json-to-zod"
|
|
6
|
+
import { jsonToZod } from "./json-to-zod.js"
|
|
7
7
|
|
|
8
8
|
type TreeResult = { dree: Dree; allFiles: Dree[] }
|
|
9
9
|
|
package/src/server/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import "core-js/proposals/async-explicit-resource-management"
|
|
2
|
-
|
|
3
1
|
// This is the public server api. Semantic versioning will be applied to this.
|
|
4
2
|
|
|
5
|
-
export { startTestServer } from "./server"
|
|
6
|
-
export { updateTestdirectorySchemaFile } from "./updateTestdirectorySchemaFile"
|
|
7
|
-
export type { TestServerConfig } from "./updateTestdirectorySchemaFile"
|
|
3
|
+
export { startTestServer } from "./server.js"
|
|
4
|
+
export { updateTestdirectorySchemaFile } from "./updateTestdirectorySchemaFile.js"
|
|
5
|
+
export type { TestServerConfig } from "./updateTestdirectorySchemaFile.js"
|
|
6
|
+
import "core-js/proposals/async-explicit-resource-management.js"
|
|
@@ -5,11 +5,11 @@ import { access } from "fs/promises"
|
|
|
5
5
|
import type { NeovimClient as NeovimApiClient } from "neovim"
|
|
6
6
|
import { tmpdir } from "os"
|
|
7
7
|
import path from "path"
|
|
8
|
-
import type { TestDirectory } from "../types"
|
|
9
|
-
import { DisposableSingleApplication } from "../utilities/DisposableSingleApplication"
|
|
10
|
-
import type { Lazy } from "../utilities/Lazy"
|
|
11
|
-
import { TerminalApplication } from "../utilities/TerminalApplication"
|
|
12
|
-
import { connectNeovimApi } from "./NeovimJavascriptApiClient"
|
|
8
|
+
import type { TestDirectory } from "../types.js"
|
|
9
|
+
import { DisposableSingleApplication } from "../utilities/DisposableSingleApplication.js"
|
|
10
|
+
import type { Lazy } from "../utilities/Lazy.js"
|
|
11
|
+
import { TerminalApplication } from "../utilities/TerminalApplication.js"
|
|
12
|
+
import { connectNeovimApi } from "./NeovimJavascriptApiClient.js"
|
|
13
13
|
|
|
14
14
|
/*
|
|
15
15
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { access } from "fs/promises"
|
|
2
2
|
import { attach } from "neovim"
|
|
3
|
-
import type { PollingInterval } from "./NeovimJavascriptApiClient"
|
|
4
|
-
import { connectNeovimApi } from "./NeovimJavascriptApiClient"
|
|
3
|
+
import type { PollingInterval } from "./NeovimJavascriptApiClient.js"
|
|
4
|
+
import { connectNeovimApi } from "./NeovimJavascriptApiClient.js"
|
|
5
5
|
|
|
6
6
|
vi.mock("neovim")
|
|
7
7
|
vi.mock("fs/promises")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { access } from "fs/promises"
|
|
2
2
|
import type { NeovimClient as NeovimApiClient } from "neovim"
|
|
3
3
|
import { attach } from "neovim"
|
|
4
|
-
import { Lazy } from "../utilities/Lazy"
|
|
4
|
+
import { Lazy } from "../utilities/Lazy.js"
|
|
5
5
|
|
|
6
6
|
export type NeovimJavascriptApiClient = NeovimApiClient
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs, { rmdirSync } from "fs"
|
|
2
2
|
import nodePath from "path"
|
|
3
3
|
import { expect, it } from "vitest"
|
|
4
|
-
import type { TestDirsPath } from "./createTempDir"
|
|
5
|
-
import { createTempDir } from "./createTempDir"
|
|
4
|
+
import type { TestDirsPath } from "./createTempDir.js"
|
|
5
|
+
import { createTempDir } from "./createTempDir.js"
|
|
6
6
|
|
|
7
7
|
vi.spyOn(console, "log").mockImplementation(vi.fn())
|
|
8
8
|
|
|
@@ -4,10 +4,10 @@ import { Type } from "dree"
|
|
|
4
4
|
import { constants, readdirSync } from "fs"
|
|
5
5
|
import { access, mkdir, mkdtemp } from "fs/promises"
|
|
6
6
|
import path from "path"
|
|
7
|
-
import { convertDree, getDirectoryTree } from "../../dirtree"
|
|
8
|
-
import type { TestDirectory } from "../../types"
|
|
9
|
-
import type { TestServerConfig } from "../../updateTestdirectorySchemaFile"
|
|
10
|
-
import { updateTestdirectorySchemaFile } from "../../updateTestdirectorySchemaFile"
|
|
7
|
+
import { convertDree, getDirectoryTree } from "../../dirtree/index.js"
|
|
8
|
+
import type { TestDirectory } from "../../types.js"
|
|
9
|
+
import type { TestServerConfig } from "../../updateTestdirectorySchemaFile.js"
|
|
10
|
+
import { updateTestdirectorySchemaFile } from "../../updateTestdirectorySchemaFile.js"
|
|
11
11
|
|
|
12
12
|
export async function createTempDir(config: TestServerConfig): Promise<TestDirectory> {
|
|
13
13
|
try {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
|
-
import type { TestDirectory } from "../types"
|
|
3
|
-
import type { TestServerConfig } from "../updateTestdirectorySchemaFile"
|
|
4
|
-
import { convertEventEmitterToAsyncGenerator } from "../utilities/generator"
|
|
5
|
-
import type { TabId } from "../utilities/tabId"
|
|
6
|
-
import { createTempDir } from "./environment/createTempDir"
|
|
7
|
-
import type { StartNeovimGenericArguments } from "./NeovimApplication"
|
|
8
|
-
import { NeovimApplication } from "./NeovimApplication"
|
|
2
|
+
import type { TestDirectory } from "../types.js"
|
|
3
|
+
import type { TestServerConfig } from "../updateTestdirectorySchemaFile.js"
|
|
4
|
+
import { convertEventEmitterToAsyncGenerator } from "../utilities/generator.js"
|
|
5
|
+
import type { TabId } from "../utilities/tabId.js"
|
|
6
|
+
import { createTempDir } from "./environment/createTempDir.js"
|
|
7
|
+
import type { StartNeovimGenericArguments } from "./NeovimApplication.js"
|
|
8
|
+
import { NeovimApplication } from "./NeovimApplication.js"
|
|
9
9
|
|
|
10
10
|
const neovims = new Map<TabId["tabId"], NeovimApplication>()
|
|
11
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createAppRouter } from "./server"
|
|
2
|
-
import { applicationAvailable } from "./utilities/applicationAvailable"
|
|
1
|
+
import { createAppRouter } from "./server.js"
|
|
2
|
+
import { applicationAvailable } from "./utilities/applicationAvailable.js"
|
|
3
3
|
|
|
4
4
|
vi.mock("./utilities/applicationAvailable")
|
|
5
5
|
|
package/src/server/server.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { inferRouterInputs } from "@trpc/server"
|
|
2
|
+
import "core-js/proposals/async-explicit-resource-management.js"
|
|
2
3
|
import { z } from "zod"
|
|
3
|
-
import { trpc } from "./connection/trpc"
|
|
4
|
-
import * as neovim from "./neovim"
|
|
5
|
-
import { TestServer } from "./TestServer"
|
|
6
|
-
import type { TestServerConfig } from "./updateTestdirectorySchemaFile"
|
|
7
|
-
import { applicationAvailable } from "./utilities/applicationAvailable"
|
|
8
|
-
import { tabIdSchema } from "./utilities/tabId"
|
|
4
|
+
import { trpc } from "./connection/trpc.js"
|
|
5
|
+
import * as neovim from "./neovim/index.js"
|
|
6
|
+
import { TestServer } from "./TestServer.js"
|
|
7
|
+
import type { TestServerConfig } from "./updateTestdirectorySchemaFile.js"
|
|
8
|
+
import { applicationAvailable } from "./utilities/applicationAvailable.js"
|
|
9
|
+
import { tabIdSchema } from "./utilities/tabId.js"
|
|
9
10
|
|
|
10
11
|
/** Stack for managing resources that need to be disposed of when the server
|
|
11
12
|
* shuts down */
|
|
@@ -62,7 +63,9 @@ export type AppRouter = Awaited<ReturnType<typeof createAppRouter>>
|
|
|
62
63
|
export type RouterInput = inferRouterInputs<AppRouter>
|
|
63
64
|
|
|
64
65
|
export async function startTestServer(config: TestServerConfig): Promise<TestServer> {
|
|
65
|
-
const testServer = new TestServer(
|
|
66
|
+
const testServer = new TestServer({
|
|
67
|
+
port: 3000,
|
|
68
|
+
})
|
|
66
69
|
const appRouter = await createAppRouter(config)
|
|
67
70
|
await testServer.startAndRun(appRouter, config)
|
|
68
71
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "fs"
|
|
2
|
-
import { buildTestDirectorySchema } from "./dirtree"
|
|
3
|
-
import type { UpdateTestdirectorySchemaFileResult } from "./updateTestdirectorySchemaFile"
|
|
4
|
-
import { updateTestdirectorySchemaFile } from "./updateTestdirectorySchemaFile"
|
|
2
|
+
import { buildTestDirectorySchema } from "./dirtree/index.js"
|
|
3
|
+
import type { UpdateTestdirectorySchemaFileResult } from "./updateTestdirectorySchemaFile.js"
|
|
4
|
+
import { updateTestdirectorySchemaFile } from "./updateTestdirectorySchemaFile.js"
|
|
5
5
|
|
|
6
6
|
vi.mock("fs")
|
|
7
7
|
vi.mock("./dirtree")
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "core-js/proposals/async-explicit-resource-management"
|
|
2
1
|
import { readFileSync, writeFileSync } from "fs"
|
|
3
|
-
import { buildTestDirectorySchema } from "./dirtree"
|
|
2
|
+
import { buildTestDirectorySchema } from "./dirtree/index.js"
|
|
4
3
|
|
|
5
4
|
export type TestServerConfig = {
|
|
6
5
|
testEnvironmentPath: string
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StartableApplication } from "./DisposableSingleApplication"
|
|
2
|
-
import { DisposableSingleApplication } from "./DisposableSingleApplication"
|
|
1
|
+
import type { StartableApplication } from "./DisposableSingleApplication.js"
|
|
2
|
+
import { DisposableSingleApplication } from "./DisposableSingleApplication.js"
|
|
3
3
|
|
|
4
4
|
vi.spyOn(console, "log").mockImplementation(vi.fn())
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "assert"
|
|
2
|
-
import type { TerminalApplication } from "./TerminalApplication"
|
|
2
|
+
import type { TerminalApplication } from "./TerminalApplication.js"
|
|
3
3
|
|
|
4
4
|
export type StartableApplication = Pick<TerminalApplication, "write" | "processId" | "killAndWait">
|
|
5
5
|
|
|
@@ -4,7 +4,7 @@ import { createLogger, format, transports } from "winston"
|
|
|
4
4
|
import type { ITerminalDimensions } from "@xterm/addon-fit"
|
|
5
5
|
import type { IPty } from "node-pty"
|
|
6
6
|
import pty from "node-pty"
|
|
7
|
-
import type { StartableApplication } from "./DisposableSingleApplication"
|
|
7
|
+
import type { StartableApplication } from "./DisposableSingleApplication.js"
|
|
8
8
|
|
|
9
9
|
// NOTE separating stdout and stderr is not supported by node-pty
|
|
10
10
|
// https://github.com/microsoft/node-pty/issues/71
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "stream"
|
|
2
|
-
import { convertEventEmitterToAsyncGenerator } from "./generator"
|
|
2
|
+
import { convertEventEmitterToAsyncGenerator } from "./generator.js"
|
|
3
3
|
|
|
4
4
|
describe("when a listener is attached", () => {
|
|
5
5
|
it("forwards events from an EventEmitter to an async generator", async () => {
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"skipLibCheck": true,
|
|
4
|
-
"module": "
|
|
4
|
+
"module": "NodeNext",
|
|
5
5
|
"noImplicitOverride": true,
|
|
6
6
|
"noPropertyAccessFromIndexSignature": true,
|
|
7
7
|
"noUncheckedIndexedAccess": true,
|
|
8
|
-
"moduleResolution": "
|
|
9
|
-
"target": "
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
9
|
+
"target": "ES2022",
|
|
10
10
|
"isolatedModules": true,
|
|
11
11
|
"esModuleInterop": true,
|
|
12
|
+
"allowJs": true,
|
|
12
13
|
"outDir": "dist",
|
|
13
14
|
"lib": ["ES2023", "ESNext.Disposable"],
|
|
14
15
|
"types": ["node", "vitest/globals"],
|
|
@@ -21,5 +22,10 @@
|
|
|
21
22
|
"noFallthroughCasesInSwitch": true
|
|
22
23
|
},
|
|
23
24
|
|
|
24
|
-
"include": [
|
|
25
|
+
"include": [
|
|
26
|
+
//
|
|
27
|
+
"./src/",
|
|
28
|
+
"src/scripts/tui.ts",
|
|
29
|
+
"./src/scripts/server.ts"
|
|
30
|
+
]
|
|
25
31
|
}
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from "vite"
|
|
2
|
+
|
|
3
|
+
// https://vitejs.dev/config/
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
server: {
|
|
6
|
+
host: "127.0.0.1",
|
|
7
|
+
https: false,
|
|
8
|
+
strictPort: true,
|
|
9
|
+
proxy: {
|
|
10
|
+
// inside @tui-sandbox/library, a vite development server can be used. It
|
|
11
|
+
// will proxy requests to the backend.
|
|
12
|
+
//
|
|
13
|
+
// When running in production, the backend starts its own static file
|
|
14
|
+
// server that is used (in development, it's just ignored).
|
|
15
|
+
"/trpc": "http://localhost:3000",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
build: {
|
|
19
|
+
outDir: "./dist/browser/",
|
|
20
|
+
},
|
|
21
|
+
test: {
|
|
22
|
+
globals: true, // This will make describe, it, etc. available globally
|
|
23
|
+
environment: "node",
|
|
24
|
+
mockReset: true,
|
|
25
|
+
},
|
|
26
|
+
})
|
package/dist/vitest.config.d.ts
DELETED
package/dist/vitest.config.js
DELETED