@cplieger/web-terminal-engine 2.5.0 → 2.7.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/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cplieger/web-terminal-engine",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "exports": {
5
5
  ".": "./src/index.ts"
6
6
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cplieger/web-terminal-engine",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "typecheck": "tsc -p tsconfig.json",
@@ -24,7 +24,7 @@
24
24
  "pngjs": "7.0.0",
25
25
  "prettier": "3.9.5",
26
26
  "typescript": "npm:@typescript/typescript6@6.0.2",
27
- "typescript-eslint": "8.63.0",
27
+ "typescript-eslint": "8.64.0",
28
28
  "vitest": "4.1.10"
29
29
  },
30
30
  "description": "Browser terminal engine: VT500 screen buffer, DOM renderer, and binary wire protocol",
package/src/connection.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  // without bound.
23
23
 
24
24
  import { wsURL } from "./wsurl.js";
25
+ import { WS_PATH } from "./routes.js";
25
26
  import { controlFrame } from "./wire.js";
26
27
  import { decodeWireBinary, WIRE_PROTOCOL_VERSION } from "./wire-binary.js";
27
28
  import * as modes from "./modes.js";
@@ -45,7 +46,7 @@ let connState: ConnState = { status: "disconnected" };
45
46
  let reconnectDelay = INITIAL_DELAY_MS;
46
47
  let lastSentCols = 0;
47
48
  let lastSentRows = 0;
48
- let wsPath = "/ws";
49
+ let wsPath: string = WS_PATH;
49
50
 
50
51
  // --- Per-session resume state (the switching cache's connection half) ---
51
52
  //
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export * as connection from "./connection.js";
10
10
  export { decodeWireBinary } from "./wire-binary.js";
11
11
  export { controlFrame, CONTROL_FRAME_PREFIX } from "./wire.js";
12
12
  export { wsURL } from "./wsurl.js";
13
+ export { WS_PATH, SESSIONS_PATH, SESSION_EVENTS_PATH } from "./routes.js";
13
14
  export { connectStatusStream } from "./status-stream.js";
14
15
  export type {
15
16
  SessionStatus,
package/src/routes.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Session-route path contract, TS half. These mirror the Go terminal
2
+ // package's exported constants (WSPath, SessionsPath, SessionEventsPath),
3
+ // whose MountSessionRoutes wires exactly this topology on the server — one
4
+ // name per path on each side of the wire, so a consumer composing its own
5
+ // URLs (or overriding a default) references the contract instead of
6
+ // restating a literal that could drift. Any addition here is an addition to
7
+ // the server mount contract and is release-noted on both halves.
8
+
9
+ /** WS_PATH is the terminal WebSocket route; the client connects per session
10
+ * with `?session=<id>`. Mirrors Go `terminal.WSPath`. */
11
+ export const WS_PATH = "/ws";
12
+
13
+ /** SESSIONS_PATH is the session REST route (POST create, GET list; DELETE and
14
+ * PUT title live under its subtree). Mirrors Go `terminal.SessionsPath`. */
15
+ export const SESSIONS_PATH = "/api/sessions";
16
+
17
+ /** SESSION_EVENTS_PATH is the session status stream (SSE). Mirrors Go
18
+ * `terminal.SessionEventsPath`. */
19
+ export const SESSION_EVENTS_PATH = "/api/sessions/events";
package/src/wsurl.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { WS_PATH } from "./routes.js";
2
+
1
3
  // Pure URL helper, no DOM / terminal / WebSocket dependencies.
2
4
  // Kept in a dedicated module so it can be property-tested without
3
5
  // touching `location`. The caller threads the live `location.*` through.
@@ -9,10 +11,10 @@
9
11
  *
10
12
  * @param pageProtocol `location.protocol` (e.g. `"https:"`).
11
13
  * @param pageHost `location.host` (host[:port]).
12
- * @param path WebSocket endpoint path; defaults to `"/ws"`.
14
+ * @param path WebSocket endpoint path; defaults to `WS_PATH` (`"/ws"`).
13
15
  * @returns A parseable `ws://`/`wss://` URL.
14
16
  */
15
- export function wsURL(pageProtocol: string, pageHost: string, path = "/ws"): string {
17
+ export function wsURL(pageProtocol: string, pageHost: string, path = WS_PATH): string {
16
18
  const wsProto = pageProtocol === "https:" ? "wss:" : "ws:";
17
19
  const normalizedPath = path.startsWith("/") ? path : `/${path}`;
18
20
  return `${wsProto}//${pageHost}${normalizedPath}`;