@devframes/plugin-code-server 0.0.1

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.
@@ -0,0 +1,99 @@
1
+ //#region src/types.d.ts
2
+ /** Lifecycle state of the managed code-server process. */
3
+ type CodeServerStatus = 'stopped' | 'starting' | 'running' | 'error';
4
+ /**
5
+ * Result of probing the host for a usable `code-server` binary. Drives the
6
+ * launcher UI: when `installed` is false the SPA renders install instructions
7
+ * instead of a launch button.
8
+ */
9
+ interface CodeServerDetection {
10
+ /** Whether detection has run at least once on this context. */
11
+ checked: boolean;
12
+ /** Whether the `code-server` binary resolved and reported a version. */
13
+ installed: boolean;
14
+ /** Version string reported by `code-server --version`, when installed. */
15
+ version?: string;
16
+ /** The binary name / path probed (configurable via options). */
17
+ bin: string;
18
+ }
19
+ /** Serializable, secret-free description of the code-server process. */
20
+ interface CodeServerServerInfo {
21
+ status: CodeServerStatus;
22
+ /** Port code-server is bound to, when starting/running. */
23
+ port?: number;
24
+ /** Epoch ms the current process was started. */
25
+ startedAt?: number;
26
+ /** OS process id, when running. */
27
+ pid?: number;
28
+ /** Last error message, when `status === 'error'`. */
29
+ error?: string;
30
+ }
31
+ /**
32
+ * The full shared-state payload broadcast to subscribed clients. Deliberately
33
+ * carries no authentication material — see {@link CodeServerAuth}.
34
+ */
35
+ interface CodeServerSharedState {
36
+ detection: CodeServerDetection;
37
+ server: CodeServerServerInfo;
38
+ }
39
+ /**
40
+ * Auto-authentication handoff for the iframe. code-server runs with password
41
+ * auth (`HASHED_PASSWORD`); the valid session is the SHA-256 of a server-side
42
+ * token. The client sets `cookieName=cookieValue` for the current host before
43
+ * loading the iframe, so the editor loads already signed in — no login page.
44
+ *
45
+ * Returned only from the `start` / `status` RPCs (the connection is already
46
+ * authorized with devframe's auth), never published to shared state.
47
+ */
48
+ interface CodeServerAuth {
49
+ cookieName: string;
50
+ cookieValue: string;
51
+ }
52
+ /** Result of the `status` query — shared state plus auth when running. */
53
+ interface CodeServerStatusResult extends CodeServerSharedState {
54
+ auth?: CodeServerAuth;
55
+ }
56
+ /** Result of the `start` action — identical shape to {@link CodeServerStatusResult}. */
57
+ type CodeServerStartResult = CodeServerStatusResult;
58
+ /** Wire payload for the `start` RPC. */
59
+ interface CodeServerStartRequest {
60
+ /** Workspace folder to open. Defaults to the configured / context cwd. */
61
+ folder?: string;
62
+ }
63
+ /** Options accepted by {@link createCodeServerDevframe}. */
64
+ interface CodeServerOptions {
65
+ /** code-server binary to detect and launch. Defaults to `code-server` (PATH). */
66
+ bin?: string;
67
+ /** Workspace folder code-server opens. Defaults to `ctx.cwd`. */
68
+ cwd?: string;
69
+ /** Force a specific code-server port. Defaults to a free port near 8080. */
70
+ serverPort?: number;
71
+ /** Host code-server binds to. Defaults to `0.0.0.0` so the preview is reachable. */
72
+ host?: string;
73
+ /** Extra CLI arguments forwarded verbatim to code-server. */
74
+ args?: string[];
75
+ /** Environment variables merged into the code-server process. */
76
+ env?: Record<string, string>;
77
+ /**
78
+ * `--cookie-suffix` passed to code-server, isolating its session cookie from
79
+ * other local code-server instances. Supported on recent code-server only;
80
+ * left unset by default for compatibility.
81
+ */
82
+ cookieSuffix?: string;
83
+ /** Milliseconds to wait for code-server readiness before failing. */
84
+ startTimeout?: number;
85
+ /** Mount path override for the launcher SPA. */
86
+ basePath?: string;
87
+ /** Launcher SPA dist dir override. Defaults to the bundled SPA. */
88
+ distDir?: string;
89
+ /** CLI binary name. */
90
+ command?: string;
91
+ /** Preferred dev-server port for the launcher SPA. */
92
+ port?: number;
93
+ /** Port range for the launcher SPA dev server (e.g. `[9000, 9100]`). */
94
+ portRange?: [number, number];
95
+ /** Prefer a random port for the launcher SPA. */
96
+ random?: boolean;
97
+ }
98
+ //#endregion
99
+ export { CodeServerAuth, CodeServerDetection, CodeServerOptions, CodeServerServerInfo, CodeServerSharedState, CodeServerStartRequest, CodeServerStartResult, CodeServerStatus, CodeServerStatusResult };
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { CodeServerOptions } from "./types.mjs";
2
+ import { DevframeVitePlugin, ViteDevBridgeOptions } from "devframe/helpers/vite";
3
+
4
+ //#region src/vite.d.ts
5
+ interface CodeServerViteOptions extends CodeServerOptions {
6
+ /** Forwarded to the underlying `viteDevBridge` (mount base, etc.). */
7
+ vite?: ViteDevBridgeOptions;
8
+ }
9
+ /**
10
+ * Mount the code-server launcher into an existing Vite dev server. Returns two
11
+ * plugins: a bridge that starts the devframe RPC + WebSocket server (so the
12
+ * launcher can detect/start/stop code-server), and a static mount that serves
13
+ * the bundled SPA at the mount base. The bridge is listed first so its
14
+ * `__connection.json` route is matched ahead of the SPA fallback.
15
+ */
16
+ declare function codeServerVite(options?: CodeServerViteOptions): DevframeVitePlugin[];
17
+ //#endregion
18
+ export { CodeServerViteOptions, codeServerVite };
package/dist/vite.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import { n as createCodeServerDevframe } from "./src-BDRH3xta.mjs";
2
+ import { viteDevBridge } from "devframe/helpers/vite";
3
+ //#region src/vite.ts
4
+ /**
5
+ * Mount the code-server launcher into an existing Vite dev server. Returns two
6
+ * plugins: a bridge that starts the devframe RPC + WebSocket server (so the
7
+ * launcher can detect/start/stop code-server), and a static mount that serves
8
+ * the bundled SPA at the mount base. The bridge is listed first so its
9
+ * `__connection.json` route is matched ahead of the SPA fallback.
10
+ */
11
+ function codeServerVite(options = {}) {
12
+ const { vite, ...codeServerOptions } = options;
13
+ const definition = createCodeServerDevframe(codeServerOptions);
14
+ return [viteDevBridge(definition, {
15
+ ...vite,
16
+ devMiddleware: true
17
+ }), viteDevBridge(definition, vite)];
18
+ }
19
+ //#endregion
20
+ export { codeServerVite };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@devframes/plugin-code-server",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Run code-server (VS Code in the browser) as a devframe panel — detect a local install, launch it on demand, and embed the editor in an auto-authenticated iframe.",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/devframes/devframe#readme",
9
+ "repository": {
10
+ "directory": "plugins/code-server",
11
+ "type": "git",
12
+ "url": "git+https://github.com/devframes/devframe.git"
13
+ },
14
+ "bugs": "https://github.com/devframes/devframe/issues",
15
+ "keywords": [
16
+ "devframe",
17
+ "devframe-plugin",
18
+ "devtools",
19
+ "code-server",
20
+ "vscode"
21
+ ],
22
+ "sideEffects": false,
23
+ "exports": {
24
+ ".": "./dist/index.mjs",
25
+ "./client": "./dist/client/index.mjs",
26
+ "./cli": "./dist/cli.mjs",
27
+ "./constants": "./dist/constants.mjs",
28
+ "./node": "./dist/node/index.mjs",
29
+ "./rpc": "./dist/rpc/index.mjs",
30
+ "./types": "./dist/types.mjs",
31
+ "./vite": "./dist/vite.mjs",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "types": "./dist/index.d.mts",
35
+ "bin": {
36
+ "devframe-code-server": "./bin.mjs"
37
+ },
38
+ "files": [
39
+ "bin.mjs",
40
+ "dist"
41
+ ],
42
+ "peerDependencies": {
43
+ "vite": "^8.0.0",
44
+ "devframe": "0.5.4"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "vite": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "dependencies": {
52
+ "get-port-please": "^3.2.0",
53
+ "iframe-pane": "^1.1.0",
54
+ "nostics": "^1.1.4"
55
+ },
56
+ "devDependencies": {
57
+ "@antfu/design": "^0.2.1",
58
+ "@iconify-json/ph": "^1.2.0",
59
+ "@storybook/html-vite": "^10.4.6",
60
+ "@types/node": "^25.9.1",
61
+ "colorjs.io": "^0.6.0",
62
+ "h3": "2.0.1-rc.22",
63
+ "storybook": "^10.4.6",
64
+ "tsdown": "^0.22.0",
65
+ "unocss": "^66.0.0",
66
+ "vite": "^8.0.14",
67
+ "vitest": "^4.1.7",
68
+ "ws": "^8.21.0",
69
+ "devframe": "0.5.4"
70
+ },
71
+ "scripts": {
72
+ "build": "tsdown && vite build --config src/spa/vite.config.ts",
73
+ "watch": "tsdown --watch",
74
+ "typecheck": "tsc --noEmit",
75
+ "dev": "vite --config src/spa/vite.config.ts --host 0.0.0.0",
76
+ "storybook": "storybook dev -p 6013 --host 0.0.0.0",
77
+ "build-storybook": "storybook build",
78
+ "test": "vitest run"
79
+ }
80
+ }