@devframes/plugin-code-server 0.9.8 → 0.9.10
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/README.md +10 -10
- package/bin.mjs +1 -1
- package/dist/{constants-DtQz38ex.d.mts → constants-DTS2klFC.d.mts} +2 -2
- package/dist/{cli.d.mts → node/cli.d.mts} +3 -3
- package/dist/{cli.mjs → node/cli.mjs} +4 -4
- package/dist/{constants.d.mts → node/constants.d.mts} +1 -1
- package/dist/{constants.mjs → node/constants.mjs} +2 -2
- package/dist/node/index.d.mts +15 -473
- package/dist/node/index.mjs +3 -761
- package/dist/{rpc → node/rpc}/index.d.mts +1 -1
- package/dist/node/rpc/index.mjs +2 -0
- package/dist/node/setup.d.mts +501 -0
- package/dist/node/setup.mjs +801 -0
- package/dist/{types.d.mts → node/types.d.mts} +10 -10
- package/dist/{vite.d.mts → node/vite.d.mts} +1 -1
- package/dist/{vite.mjs → node/vite.mjs} +2 -2
- package/dist/{src-CNJYQ3UQ.mjs → node-C_wU5QYh.mjs} +20 -5
- package/dist/{rpc-EXj5vBYf.mjs → rpc-Df9IRgPd.mjs} +3 -3
- package/package.json +22 -18
- package/dist/client/index.d.mts +0 -13
- package/dist/client/index.mjs +0 -21
- package/dist/index.d.mts +0 -23
- package/dist/index.mjs +0 -3
- package/dist/rpc/index.mjs +0 -2
- /package/dist/{types.mjs → node/types.mjs} +0 -0
package/README.md
CHANGED
|
@@ -11,13 +11,13 @@ auto-authenticated `<iframe>`. The launcher is a **Vue** SPA built on the shared
|
|
|
11
11
|
|
|
12
12
|
## How it works
|
|
13
13
|
|
|
14
|
-
- **Detection
|
|
14
|
+
- **Detection**: on startup it probes the resolved binary with `--version`.
|
|
15
15
|
When none is found, the launcher renders install instructions instead of a
|
|
16
16
|
launch button.
|
|
17
|
-
- **Launch
|
|
17
|
+
- **Launch**: the launcher's button starts the editor as a managed child
|
|
18
18
|
process bound to a free port, scoped to the workspace. Readiness is probed
|
|
19
19
|
before the iframe loads.
|
|
20
|
-
- **Auto-auth
|
|
20
|
+
- **Auto-auth**: the devframe generates fresh auth material per launch and hands
|
|
21
21
|
it to the already-authorized devframe client, so the editor opens already
|
|
22
22
|
signed in. `code-server` uses a session cookie (`HASHED_PASSWORD`);
|
|
23
23
|
`code serve-web` uses a connection token on the URL (`?tkn=`).
|
|
@@ -50,12 +50,12 @@ pnpx @devframes/plugin-code-server # dev server + launcher
|
|
|
50
50
|
import { createCodeServerDevframe } from '@devframes/plugin-code-server'
|
|
51
51
|
|
|
52
52
|
export default createCodeServerDevframe({
|
|
53
|
-
// backend: 'code-server'
|
|
54
|
-
// mode: 'local'
|
|
55
|
-
// serverPort: 8080
|
|
56
|
-
// startOnBoot: true
|
|
57
|
-
// reuseExistingServer: true
|
|
58
|
-
// tunnel: { name: 'my-box' }
|
|
53
|
+
// backend: 'code-server' | 'ms-code-serve-web' (default: auto)
|
|
54
|
+
// mode: 'local' | 'tunnel'
|
|
55
|
+
// serverPort: 8080 (default: free port near 8080)
|
|
56
|
+
// startOnBoot: true (default: on demand)
|
|
57
|
+
// reuseExistingServer: true (adopt a server on the port)
|
|
58
|
+
// tunnel: { name: 'my-box' }
|
|
59
59
|
})
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -84,7 +84,7 @@ Status (minus the connect descriptor) is mirrored into the
|
|
|
84
84
|
## UI
|
|
85
85
|
|
|
86
86
|
The launcher is a Vue SPA (`src/spa`). `LauncherView.vue` is a pure,
|
|
87
|
-
state-driven view decoupled from RPC
|
|
87
|
+
state-driven view decoupled from RPC, so every phase renders in isolation and has
|
|
88
88
|
a Storybook story; `App.vue` wires the live connection to it and mounts the
|
|
89
89
|
editor in a full-bleed, auto-authenticated iframe (`EditorFrame.vue`).
|
|
90
90
|
|
package/bin.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//#region src/constants.d.ts
|
|
1
|
+
//#region src/node/constants.d.ts
|
|
2
2
|
/** Stable devframe id for the code-server plugin. */
|
|
3
3
|
declare const PLUGIN_ID = "devframes_plugin_code-server";
|
|
4
4
|
/**
|
|
5
5
|
* Shared-state key holding the serializable, secret-free server status and
|
|
6
|
-
* detection result. Authentication material is never published here
|
|
6
|
+
* detection result. Authentication material is never published here; it is
|
|
7
7
|
* returned only from the `start` / `status` RPCs to the already-authorized
|
|
8
8
|
* client (see {@link import('./types').CodeServerConnect}).
|
|
9
9
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CodeServerOptions } from "./types.mjs";
|
|
2
2
|
import { CacHandle, CreateCacOptions } from "devframe/adapters/cac";
|
|
3
|
-
//#region src/cli.d.ts
|
|
3
|
+
//#region src/node/cli.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Build a standalone CLI for the code-server panel
|
|
6
|
-
* subcommands, backed by {@link createCodeServerDevframe}. Used by the package
|
|
5
|
+
* Build a standalone CLI for the code-server panel, exposing `dev` / `build` /
|
|
6
|
+
* `mcp` subcommands, backed by {@link createCodeServerDevframe}. Used by the package
|
|
7
7
|
* `bin` (`devframe-code-server`).
|
|
8
8
|
*/
|
|
9
9
|
declare function createCodeServerCli(options?: CodeServerOptions, cliOptions?: CreateCacOptions): CacHandle;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as createCodeServerDevframe } from "
|
|
1
|
+
import { t as createCodeServerDevframe } from "../node-C_wU5QYh.mjs";
|
|
2
2
|
import { createCac } from "devframe/adapters/cac";
|
|
3
|
-
//#region src/cli.ts
|
|
3
|
+
//#region src/node/cli.ts
|
|
4
4
|
/**
|
|
5
|
-
* Build a standalone CLI for the code-server panel
|
|
6
|
-
* subcommands, backed by {@link createCodeServerDevframe}. Used by the package
|
|
5
|
+
* Build a standalone CLI for the code-server panel, exposing `dev` / `build` /
|
|
6
|
+
* `mcp` subcommands, backed by {@link createCodeServerDevframe}. Used by the package
|
|
7
7
|
* `bin` (`devframe-code-server`).
|
|
8
8
|
*/
|
|
9
9
|
function createCodeServerCli(options = {}, cliOptions = {}) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SESSION_COOKIE_BASE, c as TERMINAL_SESSION_TITLE, i as PLUGIN_ID, l as getCookieSessionName, n as DEFAULT_PORT, o as STATE_KEY, r as DEFAULT_START_TIMEOUT, s as TERMINAL_SESSION_ICON, t as DEFAULT_CODE_SERVER_PORT } from "
|
|
1
|
+
import { a as SESSION_COOKIE_BASE, c as TERMINAL_SESSION_TITLE, i as PLUGIN_ID, l as getCookieSessionName, n as DEFAULT_PORT, o as STATE_KEY, r as DEFAULT_START_TIMEOUT, s as TERMINAL_SESSION_ICON, t as DEFAULT_CODE_SERVER_PORT } from "../constants-DTS2klFC.mjs";
|
|
2
2
|
export { DEFAULT_CODE_SERVER_PORT, DEFAULT_PORT, DEFAULT_START_TIMEOUT, PLUGIN_ID, SESSION_COOKIE_BASE, STATE_KEY, TERMINAL_SESSION_ICON, TERMINAL_SESSION_TITLE, getCookieSessionName };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//#region src/constants.ts
|
|
1
|
+
//#region src/node/constants.ts
|
|
2
2
|
/** Stable devframe id for the code-server plugin. */
|
|
3
3
|
const PLUGIN_ID = "devframes_plugin_code-server";
|
|
4
4
|
/**
|
|
5
5
|
* Shared-state key holding the serializable, secret-free server status and
|
|
6
|
-
* detection result. Authentication material is never published here
|
|
6
|
+
* detection result. Authentication material is never published here; it is
|
|
7
7
|
* returned only from the `start` / `status` RPCs to the already-authorized
|
|
8
8
|
* client (see {@link import('./types').CodeServerConnect}).
|
|
9
9
|
*/
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,481 +1,23 @@
|
|
|
1
|
-
import { CodeServerBackend, CodeServerConnect, CodeServerDetection, CodeServerLogin, CodeServerMode, CodeServerOptions, CodeServerStartRequest, CodeServerStartResult, CodeServerStatusResult } from "
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Owns the lifecycle of a single editor child process. Resolves a launch
|
|
6
|
-
* {@link CodeServerProfile} (Coder `code-server`, Microsoft `code serve-web`,
|
|
7
|
-
* or `code tunnel`), detects the binary, launches it with freshly generated
|
|
8
|
-
* auth material, waits for readiness, and mirrors a secret-free status into
|
|
9
|
-
* shared state. The connect descriptor (session cookie / connection token /
|
|
10
|
-
* tunnel URL) is handed back only through `start()` / `status()` so the
|
|
11
|
-
* already-authorized client can open the editor without a login page.
|
|
12
|
-
*
|
|
13
|
-
* Depends only on the core devframe context (shared state), not on the hub.
|
|
14
|
-
*/
|
|
15
|
-
declare class CodeServerSupervisor {
|
|
16
|
-
private readonly ctx;
|
|
17
|
-
private readonly mode;
|
|
18
|
-
private readonly explicitBackend?;
|
|
19
|
-
private readonly explicitBin?;
|
|
20
|
-
private readonly workspace;
|
|
21
|
-
private readonly host;
|
|
22
|
-
private readonly forcedPort?;
|
|
23
|
-
private readonly extraArgs;
|
|
24
|
-
private readonly extraEnv;
|
|
25
|
-
private readonly cookieSuffix?;
|
|
26
|
-
private readonly cookieName;
|
|
27
|
-
private readonly startTimeout;
|
|
28
|
-
private readonly reuseExistingServer;
|
|
29
|
-
private readonly tunnelName;
|
|
30
|
-
/** Resolved after the first detection. */
|
|
31
|
-
private backend;
|
|
32
|
-
private bin;
|
|
33
|
-
private profile;
|
|
34
|
-
private state?;
|
|
35
|
-
private detection;
|
|
36
|
-
private server;
|
|
37
|
-
private proc?;
|
|
38
|
-
/** Context of the live launch, used to compute the client connect descriptor. */
|
|
39
|
-
private launchCtx?;
|
|
40
|
-
/** Whether the running server was adopted (reused) rather than launched. */
|
|
41
|
-
private adopted;
|
|
42
|
-
/** Captured `vscode.dev` URL for a running tunnel. */
|
|
43
|
-
private readyUrl?;
|
|
44
|
-
private logBuffer;
|
|
45
|
-
private exitHandler?;
|
|
46
|
-
/** Stable id of the hub terminal session, reused across start/stop. */
|
|
47
|
-
private readonly sessionId;
|
|
48
|
-
/** The live hub terminal session when launched through `ctx.terminals`. */
|
|
49
|
-
private session?;
|
|
50
|
-
constructor(ctx: DevframeNodeContext, options?: CodeServerOptions);
|
|
51
|
-
/** Resolve shared state, register process-exit cleanup, run first detection. */
|
|
52
|
-
init(): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Probe for a usable editor binary and publish the result. Resolves the
|
|
55
|
-
* backend + binary when the caller left them implicit: tunnel mode always
|
|
56
|
-
* uses `code`; an explicit backend or `bin` is honored as-is; otherwise the
|
|
57
|
-
* plugin tries each {@link AUTO_DETECT_ORDER} candidate and keeps the first
|
|
58
|
-
* that is installed.
|
|
59
|
-
*/
|
|
60
|
-
detect(): Promise<CodeServerDetection>;
|
|
61
|
-
/** Current status (+ connect info when running) for the launcher UI. */
|
|
62
|
-
status(): CodeServerStatusResult;
|
|
63
|
-
/**
|
|
64
|
-
* Launch the editor (if not already up) and resolve once it is reachable.
|
|
65
|
-
* Idempotent while starting/running — returns the live status instead of
|
|
66
|
-
* spawning a second process. In tunnel mode it resolves as soon as either
|
|
67
|
-
* the `vscode.dev` URL or a device-login prompt is seen, so the action never
|
|
68
|
-
* blocks on interactive authentication.
|
|
69
|
-
*/
|
|
70
|
-
start(req?: CodeServerStartRequest): Promise<CodeServerStartResult>;
|
|
71
|
-
/** Stop the editor process and reset to `stopped`. */
|
|
72
|
-
stop(): CodeServerStatusResult;
|
|
73
|
-
/** Kill the process on host shutdown / test teardown. */
|
|
74
|
-
dispose(): void;
|
|
75
|
-
/** Resolved backend for tests / callers. */
|
|
76
|
-
get resolvedBackend(): CodeServerBackend;
|
|
77
|
-
private setResolved;
|
|
78
|
-
private baseCtx;
|
|
79
|
-
/** Clear per-launch process state (keeps `server`/`detection`). */
|
|
80
|
-
private reset;
|
|
81
|
-
/**
|
|
82
|
-
* Resolve start() for a tunnel: succeed as soon as the `vscode.dev` URL
|
|
83
|
-
* appears (→ running) or a device-login prompt is seen (→ starting, so the
|
|
84
|
-
* user can authenticate while the log stream continues to a running URL).
|
|
85
|
-
*/
|
|
86
|
-
private awaitTunnel;
|
|
87
|
-
private connectInfo;
|
|
88
|
-
private terminate;
|
|
89
|
-
/**
|
|
90
|
-
* Resolve the hub's terminals subsystem when this devframe is mounted in a
|
|
91
|
-
* hub. `ctx.terminals` only exists on a `DevframeHubContext`, so it is
|
|
92
|
-
* duck-typed — standalone runtimes (CLI / Vite / build) have no such property
|
|
93
|
-
* and fall back to a direct child process.
|
|
94
|
-
*/
|
|
95
|
-
private resolveHubTerminals;
|
|
96
|
-
/** Update the mirrored hub terminal session's status, when one exists. */
|
|
97
|
-
private reflectHub;
|
|
98
|
-
/**
|
|
99
|
-
* Launch the editor binary. In a hub, spawn it through `ctx.terminals` so it
|
|
100
|
-
* shows up as a read-only terminal session (proper icon + name) whose output
|
|
101
|
-
* the hub streams to its terminals panel; standalone, spawn it directly.
|
|
102
|
-
* Either way, return the underlying {@link ChildProcess} so the shared
|
|
103
|
-
* readiness / port / log wiring in `start()` is identical.
|
|
104
|
-
*/
|
|
105
|
-
private launchProcess;
|
|
106
|
-
private appendLog;
|
|
107
|
-
private lastLog;
|
|
108
|
-
private publish;
|
|
109
|
-
/**
|
|
110
|
-
* Poll the server's readiness path until it responds or the timeout elapses.
|
|
111
|
-
* Returns false if the process exits first.
|
|
112
|
-
*/
|
|
113
|
-
private waitForReady;
|
|
114
|
-
private registerCleanup;
|
|
115
|
-
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/node/backends.d.ts
|
|
118
|
-
/**
|
|
119
|
-
* The internal launch profile the supervisor drives. One of three "kinds":
|
|
120
|
-
* the two local {@link CodeServerBackend}s plus the `code tunnel` profile
|
|
121
|
-
* selected by `mode: 'tunnel'`. Each profile owns the backend-specific pieces
|
|
122
|
-
* — binary, arguments, auth env, readiness detection, and how the client
|
|
123
|
-
* ultimately reaches the editor — while the supervisor owns the shared
|
|
124
|
-
* spawn / log / publish lifecycle.
|
|
125
|
-
*/
|
|
126
|
-
type CodeServerProfileKind = 'code-server' | 'serve-web' | 'tunnel';
|
|
127
|
-
/** Everything a profile needs to build a launch and the client's connect info. */
|
|
128
|
-
interface ProfileContext {
|
|
129
|
-
host: string;
|
|
130
|
-
/** Resolved local port (0 until dynamically allocated). Unused by tunnel. */
|
|
131
|
-
port: number;
|
|
132
|
-
folder: string;
|
|
133
|
-
/** Fresh per-launch secret (session token / connection token). */
|
|
134
|
-
secret: string;
|
|
135
|
-
/** Session cookie name for the `code-server` backend. */
|
|
136
|
-
cookieName: string;
|
|
137
|
-
extraArgs: string[];
|
|
138
|
-
/** Machine name for the tunnel profile. */
|
|
139
|
-
tunnelName: string;
|
|
140
|
-
}
|
|
141
|
-
interface CodeServerProfile {
|
|
142
|
-
kind: CodeServerProfileKind;
|
|
143
|
-
/** Public backend id (tunnel reports `ms-code-serve-web`'s sibling `code` binary). */
|
|
144
|
-
backend: CodeServerBackend;
|
|
145
|
-
/** Default binary when the caller doesn't override `bin`. */
|
|
146
|
-
defaultBin: string;
|
|
147
|
-
/** Build the argv passed to the binary. */
|
|
148
|
-
buildArgs: (c: ProfileContext) => string[];
|
|
149
|
-
/** Merge auth material into the child environment. */
|
|
150
|
-
buildEnv: (c: ProfileContext, base: Record<string, string>) => Record<string, string>;
|
|
151
|
-
/** Local readiness path polled over HTTP, or `null` for log-driven (tunnel). */
|
|
152
|
-
healthPath: string | null;
|
|
153
|
-
/** Parse a log line for a dynamically-bound local port. */
|
|
154
|
-
matchPort?: (line: string) => number | undefined;
|
|
155
|
-
/** Parse a log line for the tunnel's `vscode.dev` URL (marks it ready). */
|
|
156
|
-
matchReadyUrl?: (line: string) => string | undefined;
|
|
157
|
-
/** Parse a log line for a device-login prompt. */
|
|
158
|
-
matchLogin?: (line: string) => CodeServerLogin | undefined;
|
|
159
|
-
/** Compute the client connect descriptor for a freshly launched server. */
|
|
160
|
-
connect: (c: ProfileContext & {
|
|
161
|
-
readyUrl?: string;
|
|
162
|
-
}) => CodeServerConnect;
|
|
163
|
-
/** Connect descriptor for an adopted (reused) server we didn't launch. */
|
|
164
|
-
connectReused: (c: {
|
|
165
|
-
port: number;
|
|
166
|
-
}) => CodeServerConnect;
|
|
167
|
-
}
|
|
168
|
-
/** Resolve the launch profile for a mode + backend. */
|
|
169
|
-
declare function resolveProfile(mode: CodeServerMode, backend: CodeServerBackend): CodeServerProfile;
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/node/context.d.ts
|
|
172
|
-
declare function setCodeServerSupervisor(ctx: DevframeNodeContext, supervisor: CodeServerSupervisor): void;
|
|
173
|
-
declare function getCodeServerSupervisor(ctx: DevframeNodeContext): CodeServerSupervisor;
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/node/detect.d.ts
|
|
176
|
-
interface DetectCodeServerResult {
|
|
177
|
-
installed: boolean;
|
|
178
|
-
version?: string;
|
|
179
|
-
bin: string;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Probe the host for a usable code-server binary by running
|
|
183
|
-
* `<bin> --version`. Resolves to `installed: false` when the binary is
|
|
184
|
-
* missing (ENOENT), errors, or exits non-zero — never throws — so the
|
|
185
|
-
* launcher can fall back to install instructions.
|
|
186
|
-
*
|
|
187
|
-
* `code-server --version` prints e.g. `4.96.4 abc123 with Code 1.96.4`; the
|
|
188
|
-
* first semver-looking token is taken as the version. Matching a semver
|
|
189
|
-
* pattern (rather than the leading whitespace token) keeps cold-start i18n
|
|
190
|
-
* noise — e.g. an `i18next: …` initialization line printed before the version
|
|
191
|
-
* — from leaking into the reported version.
|
|
192
|
-
*/
|
|
193
|
-
declare function detectCodeServer(bin?: string, timeoutMs?: number): Promise<DetectCodeServerResult>;
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region ../../node_modules/.pnpm/nostics@1.2.0/node_modules/nostics/dist/diagnostic-wduO7saY.d.mts
|
|
196
|
-
//#region src/utils.d.ts
|
|
197
|
-
/**
|
|
198
|
-
* A value of type T, or a function that resolves T from a single params object.
|
|
199
|
-
*
|
|
200
|
-
* @internal
|
|
201
|
-
*/
|
|
202
|
-
type ValueOrFn<T, P = any> = T | ((params: P) => T);
|
|
203
|
-
/**
|
|
204
|
-
* Extracts the param type from a single-arg function, or `never` for
|
|
205
|
-
* non-function inputs. Pairs with {@link ValueOrFn}.
|
|
206
|
-
*
|
|
207
|
-
* @internal
|
|
208
|
-
*/
|
|
209
|
-
type ExtractFnParam<T> = T extends ((params: infer P) => any) ? P : never;
|
|
210
|
-
/**
|
|
211
|
-
* Converts a union of types to their intersection.
|
|
212
|
-
*
|
|
213
|
-
* @internal
|
|
214
|
-
*/
|
|
215
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
216
|
-
/**
|
|
217
|
-
* `true` when `T` is the `any` type.
|
|
218
|
-
*
|
|
219
|
-
* @internal
|
|
220
|
-
*/
|
|
221
|
-
type IsAny<Type> = 0 extends 1 & Type ? true : false;
|
|
222
|
-
/**
|
|
223
|
-
* `true` when `T` is the `unknown` type (and not `any`).
|
|
224
|
-
*
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
type IsUnknown<Type> = IsAny<Type> extends true ? false : unknown extends Type ? true : false;
|
|
228
|
-
/**
|
|
229
|
-
* Expands a type to its property listing so editor hovers show the resolved
|
|
230
|
-
* shape instead of a chain of aliases / intersections.
|
|
231
|
-
*
|
|
232
|
-
* @internal
|
|
233
|
-
*/
|
|
234
|
-
type Prettify<Type> = { [Key in keyof Type]: Type[Key]; };
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/diagnostic.d.ts
|
|
237
|
-
/**
|
|
238
|
-
* Define-time shape of a diagnostic. Each field can be a static value or a
|
|
239
|
-
* function that resolves it from a shared `params` object passed at call
|
|
240
|
-
* time. Runtime-only fields (`cause`, `sources`) from {@link DiagnosticInit}
|
|
241
|
-
* are intentionally omitted: they're only meaningful at the call site.
|
|
242
|
-
*/
|
|
243
|
-
interface DiagnosticDefinition<P = any> {
|
|
244
|
-
/**
|
|
245
|
-
* The error message: why this failed. String, or a function of `params`.
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```ts
|
|
249
|
-
* why: (p: { name: string }) => `module "${p.name}" failed to load`
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
why: ValueOrFn<string, P>;
|
|
253
|
-
/**
|
|
254
|
-
* Actionable instructions on how to resolve the problem. String, or a
|
|
255
|
-
* function of `params`.
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* ```ts
|
|
259
|
-
* fix: (p: { name: string }) => `run "npm install ${p.name}"`
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
fix?: ValueOrFn<string, P>;
|
|
263
|
-
/**
|
|
264
|
-
* Per-code docs URL. A string overrides
|
|
265
|
-
* {@link DefineDiagnosticsOptions.docsBase} for this code; `false` opts this
|
|
266
|
-
* code out entirely, even when `docsBase` is set. When omitted, the URL is
|
|
267
|
-
* derived from `docsBase`.
|
|
268
|
-
*/
|
|
269
|
-
docs?: string | false;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Runtime-only fields that can be passed alongside the interpolation params
|
|
273
|
-
* at call time. Merged into the same object so callers pass everything in
|
|
274
|
-
* one place.
|
|
275
|
-
*/
|
|
276
|
-
interface DiagnosticCallParams {
|
|
277
|
-
/**
|
|
278
|
-
* Original error or exception that triggered this diagnostic. Pass it
|
|
279
|
-
* through when re-throwing so the original stack trace is preserved.
|
|
280
|
-
*/
|
|
281
|
-
cause?: unknown;
|
|
282
|
-
/**
|
|
283
|
-
* Locations in user code that contributed to this diagnostic, in
|
|
284
|
-
* `file:line:column` format. Useful for compilers and other tools where the
|
|
285
|
-
* JS stack trace doesn't reflect the user's source.
|
|
286
|
-
*/
|
|
287
|
-
sources?: string[];
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Structured initializer for a {@link Diagnostic}. `why` is the only required
|
|
291
|
-
* field: it becomes the {@link Diagnostic.message}. The remaining fields are
|
|
292
|
-
* optional metadata that reporters and consumers can render or forward.
|
|
293
|
-
*/
|
|
294
|
-
interface DiagnosticInit extends DiagnosticCallParams {
|
|
295
|
-
/**
|
|
296
|
-
* The diagnostic code, e.g. `MATH_E001`. Appear as {@link Diagnostic.name}.
|
|
297
|
-
*/
|
|
298
|
-
code: string;
|
|
299
|
-
/**
|
|
300
|
-
* The actual error message: why this failed.
|
|
301
|
-
* Mirrored to `Error.message`.
|
|
302
|
-
*/
|
|
303
|
-
why: string;
|
|
304
|
-
/**
|
|
305
|
-
* Optional actionable instructions on how to resolve the problem.
|
|
306
|
-
*/
|
|
307
|
-
fix?: string;
|
|
308
|
-
/**
|
|
309
|
-
* URL to extended documentation for this diagnostic.
|
|
310
|
-
*/
|
|
311
|
-
docs?: string;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Permissive reporter constraint used internally so reporters with 1 arg,
|
|
315
|
-
* required options, or optional options all satisfy the array constraint.
|
|
316
|
-
*
|
|
317
|
-
* @internal
|
|
318
|
-
*/
|
|
319
|
-
type AnyDiagnosticReporter = (diagnostic: Diagnostic, options: any) => void;
|
|
320
|
-
/**
|
|
321
|
-
* Resolves the `params` type a code expects from the intersection of params
|
|
322
|
-
* across all function-typed fields, falling back to `{}` when every field is
|
|
323
|
-
* static. Merged with {@link DiagnosticCallParams} at the call site.
|
|
324
|
-
*
|
|
325
|
-
* @internal
|
|
326
|
-
*/
|
|
327
|
-
type InferCodeParams<Def> = [ExtractFnParam<Def[keyof Def]>] extends [never] ? {} : UnionToIntersection<ExtractFnParam<Def[keyof Def]>>;
|
|
328
|
-
/**
|
|
329
|
-
* The first positional argument of a {@link DiagnosticHandle} call:
|
|
330
|
-
* interpolation params merged with the runtime-only call-site fields
|
|
331
|
-
* (`cause`, `sources`).
|
|
332
|
-
*
|
|
333
|
-
* @internal
|
|
334
|
-
*/
|
|
335
|
-
type CallSiteParams<Params> = Params & DiagnosticCallParams;
|
|
1
|
+
import { CodeServerBackend, CodeServerConnect, CodeServerDetection, CodeServerLogin, CodeServerMode, CodeServerOptions, CodeServerServerInfo, CodeServerSharedState, CodeServerStartRequest, CodeServerStartResult, CodeServerStatus, CodeServerStatusResult, CodeServerTunnelOptions } from "./types.mjs";
|
|
2
|
+
import { i as PLUGIN_ID, l as getCookieSessionName, n as DEFAULT_PORT, o as STATE_KEY, t as DEFAULT_CODE_SERVER_PORT } from "../constants-DTS2klFC.mjs";
|
|
3
|
+
import { DevframeDefinition } from "devframe";
|
|
4
|
+
//#region src/node/index.d.ts
|
|
336
5
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* omitted entirely.
|
|
6
|
+
* Build a {@link DevframeDefinition} for the code-server panel. The same
|
|
7
|
+
* definition runs standalone (`createCac`), mounts into a Vite host
|
|
8
|
+
* (`/vite`), or docks inside a hub, since its `setup` only relies on the core
|
|
9
|
+
* devframe RPC + shared-state surface.
|
|
342
10
|
*
|
|
343
|
-
* @
|
|
344
|
-
|
|
345
|
-
type ActionArgs<Params, ReporterOpts> = keyof ReporterOpts extends never ? {} extends Params ? [params?: CallSiteParams<Params>] : [params: CallSiteParams<Params>] : {} extends ReporterOpts ? {} extends Params ? [params?: CallSiteParams<Params>, reporterOptions?: ReporterOpts] : [params: CallSiteParams<Params>, reporterOptions?: ReporterOpts] : {} extends Params ? [params: CallSiteParams<Params> | undefined, reporterOptions: ReporterOpts] : [params: CallSiteParams<Params>, reporterOptions: ReporterOpts];
|
|
346
|
-
/**
|
|
347
|
-
* Per-code handle exposed by {@link defineDiagnostics}. Each code is a
|
|
348
|
-
* callable: invoke it to build the diagnostic and run every reporter, or
|
|
349
|
-
* prefix the call with `throw` to raise it.
|
|
11
|
+
* @experimental This plugin is experimental and may change without a major
|
|
12
|
+
* version bump until it stabilizes.
|
|
350
13
|
*
|
|
351
14
|
* @example
|
|
352
15
|
* ```ts
|
|
353
|
-
*
|
|
354
|
-
* throw diagnostics.MATH_E001({ name: 'x' }) // throw
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
interface DiagnosticHandle<Params, ReporterOpts> {
|
|
358
|
-
/**
|
|
359
|
-
* Builds the diagnostic, runs every reporter, and returns the diagnostic
|
|
360
|
-
* instance. The returned diagnostic can be inspected, attached as `cause`,
|
|
361
|
-
* or thrown with `throw`.
|
|
362
|
-
*/
|
|
363
|
-
(...args: ActionArgs<Params, ReporterOpts>): Diagnostic;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Return type of {@link defineDiagnostics}.
|
|
367
|
-
*/
|
|
368
|
-
type Diagnostics<Codes extends Record<string, DiagnosticDefinition>, Reporters extends readonly AnyDiagnosticReporter[]> = { [Code in keyof Codes]: DiagnosticHandle<InferCodeParams<Codes[Code]>, Prettify<ExtractReportersOptions<Reporters>>>; };
|
|
369
|
-
declare class Diagnostic extends Error {
|
|
370
|
-
name: string;
|
|
371
|
-
/**
|
|
372
|
-
* The diagnostic code, e.g. `MATH_E001`.
|
|
373
|
-
* Also appears as the `name` property.
|
|
374
|
-
*/
|
|
375
|
-
code: string;
|
|
376
|
-
/**
|
|
377
|
-
* URL to extended documentation for this diagnostic code.
|
|
378
|
-
* Auto-generated from {@link DefineDiagnosticsOptions.docsBase}.
|
|
379
|
-
*/
|
|
380
|
-
docs?: string;
|
|
381
|
-
/**
|
|
382
|
-
* Optional actionable instructions on how to resolve the problem.
|
|
383
|
-
*/
|
|
384
|
-
fix?: string;
|
|
385
|
-
/**
|
|
386
|
-
* Locations in user code that contributed to this diagnostic, in
|
|
387
|
-
* `file:line:column` format. Relevant when the stack trace doesn't reflect
|
|
388
|
-
* the user's source (e.g. compilers, bundlers), otherwise redundant with the
|
|
389
|
-
* stack and should be omitted.
|
|
390
|
-
*/
|
|
391
|
-
sources?: string[];
|
|
392
|
-
/**
|
|
393
|
-
* Alias for {@link Error.message}: the reason this diagnostic was raised.
|
|
394
|
-
*/
|
|
395
|
-
get why(): string;
|
|
396
|
-
/**
|
|
397
|
-
* @param init structured initializer; `why` is required
|
|
398
|
-
* @param captureFrom V8 stack-cutoff frame. Defaults to {@link Diagnostic}
|
|
399
|
-
* so the top of the trace is the `new Diagnostic(...)` call site.
|
|
400
|
-
* `defineDiagnostics` passes its action method to strip its own frames too.
|
|
401
|
-
* Ignored on engines without `Error.captureStackTrace`.
|
|
402
|
-
*/
|
|
403
|
-
constructor(init: DiagnosticInit, captureFrom?: Function);
|
|
404
|
-
/**
|
|
405
|
-
* Converts the diagnostic into a serializable structured object.
|
|
406
|
-
*/
|
|
407
|
-
toJSON(): object;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Extracts the options object a reporter accepts as its 2nd argument. Returns
|
|
411
|
-
* `{}` when the reporter has no 2nd arg (so it contributes nothing to the
|
|
412
|
-
* merged shape).
|
|
413
|
-
*/
|
|
414
|
-
type ExtractSingleReporterOptions<Reporter> = Reporter extends ((diagnostic: Diagnostic, options: infer ReporterOpts) => any) ? IsUnknown<ReporterOpts> extends true ? {} : Exclude<ReporterOpts, undefined> : {};
|
|
415
|
-
/**
|
|
416
|
-
* Intersects every reporter's options shape into a single object. If any
|
|
417
|
-
* reporter has a required field, the merged shape has a required field, and
|
|
418
|
-
* {@link ActionArgs} flips `reporterOptions` from optional to required via
|
|
419
|
-
* `{} extends Merged`.
|
|
420
|
-
*/
|
|
421
|
-
type ExtractReportersOptions<Reporters extends readonly any[]> = Reporters extends readonly [infer First, ...infer Rest] ? ExtractSingleReporterOptions<First> & ExtractReportersOptions<Rest> : {};
|
|
422
|
-
//#endregion
|
|
423
|
-
//#region src/node/diagnostics.d.ts
|
|
424
|
-
/**
|
|
425
|
-
* Structured diagnostics for the code-server plugin. Uses the plugin's own
|
|
426
|
-
* `DP_CODE_SERVER_` prefix per the built-in plugin convention, keeping it
|
|
427
|
-
* collision-free with devframe core (`DF`) and the hub (`DF8xxx`).
|
|
428
|
-
*/
|
|
429
|
-
declare const diagnostics: Diagnostics<{
|
|
430
|
-
readonly DP_CODE_SERVER_0001: {
|
|
431
|
-
readonly why: (p: {
|
|
432
|
-
bin: string;
|
|
433
|
-
}) => string;
|
|
434
|
-
readonly fix: "Install Coder code-server (`curl -fsSL https://code-server.dev/install.sh | sh`) or the Microsoft `code` CLI, or set the `bin` option to its path. See https://coder.com/docs/code-server/latest/install";
|
|
435
|
-
};
|
|
436
|
-
readonly DP_CODE_SERVER_0002: {
|
|
437
|
-
readonly why: (p: {
|
|
438
|
-
port: number;
|
|
439
|
-
timeout: number;
|
|
440
|
-
}) => string;
|
|
441
|
-
readonly fix: "Check the editor logs for startup errors, raise `startTimeout`, or free the port.";
|
|
442
|
-
};
|
|
443
|
-
readonly DP_CODE_SERVER_0003: {
|
|
444
|
-
readonly why: (p: {
|
|
445
|
-
bin: string;
|
|
446
|
-
reason: string;
|
|
447
|
-
}) => string;
|
|
448
|
-
};
|
|
449
|
-
readonly DP_CODE_SERVER_0004: {
|
|
450
|
-
readonly why: "code-server supervisor is not initialised on this context";
|
|
451
|
-
readonly fix: "Call setupCodeServer(ctx) (or use createCodeServerDevframe) before invoking the code-server RPCs.";
|
|
452
|
-
};
|
|
453
|
-
readonly DP_CODE_SERVER_0005: {
|
|
454
|
-
readonly why: (p: {
|
|
455
|
-
code: number;
|
|
456
|
-
}) => string;
|
|
457
|
-
readonly fix: "Inspect the captured output in the launcher and re-launch.";
|
|
458
|
-
};
|
|
459
|
-
readonly DP_CODE_SERVER_0006: {
|
|
460
|
-
readonly why: (p: {
|
|
461
|
-
timeout: number;
|
|
462
|
-
}) => string;
|
|
463
|
-
readonly fix: "Check the tunnel logs, ensure the `code` CLI is signed in, or raise `startTimeout`.";
|
|
464
|
-
};
|
|
465
|
-
}, readonly [(d: Diagnostic, { method }?: {
|
|
466
|
-
method?: "log" | "warn" | "error";
|
|
467
|
-
}) => void]>;
|
|
468
|
-
//#endregion
|
|
469
|
-
//#region src/node/index.d.ts
|
|
470
|
-
/**
|
|
471
|
-
* Wire the code-server subsystem onto a devframe node context: create the
|
|
472
|
-
* {@link CodeServerSupervisor}, run the initial binary detection, publish
|
|
473
|
-
* status into shared state, and register the control RPC functions. Returns
|
|
474
|
-
* the supervisor so callers can launch/stop or dispose it on shutdown.
|
|
16
|
+
* import { createCodeServerDevframe } from '@devframes/plugin-code-server'
|
|
475
17
|
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
18
|
+
* export default createCodeServerDevframe({ serverPort: 8080 })
|
|
19
|
+
* ```
|
|
478
20
|
*/
|
|
479
|
-
declare function
|
|
21
|
+
declare function createCodeServerDevframe(options?: CodeServerOptions): DevframeDefinition;
|
|
480
22
|
//#endregion
|
|
481
|
-
export { type
|
|
23
|
+
export { type CodeServerBackend, type CodeServerConnect, type CodeServerDetection, type CodeServerLogin, type CodeServerMode, type CodeServerOptions, type CodeServerServerInfo, type CodeServerSharedState, type CodeServerStartRequest, type CodeServerStartResult, type CodeServerStatus, type CodeServerStatusResult, type CodeServerTunnelOptions, DEFAULT_CODE_SERVER_PORT, DEFAULT_PORT, PLUGIN_ID, STATE_KEY, createCodeServerDevframe, createCodeServerDevframe as default, getCookieSessionName };
|