cmux 0.1.1 → 0.1.2

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/src/types.ts ADDED
@@ -0,0 +1,92 @@
1
+ export type Json = null | boolean | number | string | Json[] | { [key: string]: Json };
2
+ export type JsonObject = { [key: string]: Json };
3
+
4
+ export interface IdentifyResult {
5
+ app: string;
6
+ version: string;
7
+ protocol: number;
8
+ session: string;
9
+ pid: number;
10
+ }
11
+
12
+ export interface EmptyResult {}
13
+ export interface SurfaceResult { surface: number }
14
+ export interface ReadScreenResult { text: string }
15
+ export interface VtStateResult { cols: number; rows: number; data: string }
16
+ export interface Size { cols: number; rows: number }
17
+
18
+ export type Layout =
19
+ | { type: "leaf"; pane: number }
20
+ | { type: "split"; dir: "right" | "down"; ratio: number; a: Layout; b: Layout };
21
+
22
+ export type Pane =
23
+ | { id: number; name: string | null; active_tab: number; tabs: Tab[]; dead?: false }
24
+ | { id: number; dead: true; name?: null; active_tab?: 0; tabs?: [] };
25
+
26
+ export interface Tab {
27
+ surface: number;
28
+ kind: "pty" | "browser" | string;
29
+ browser_source: "external" | "launched" | null | string;
30
+ name: string | null;
31
+ title: string;
32
+ size: Size | null;
33
+ dead: boolean;
34
+ }
35
+
36
+ export interface Screen {
37
+ id: number;
38
+ name: string | null;
39
+ active: boolean;
40
+ active_pane: number;
41
+ layout: Layout;
42
+ panes: Pane[];
43
+ }
44
+
45
+ export interface Workspace {
46
+ id: number;
47
+ name: string;
48
+ active: boolean;
49
+ screens: Screen[];
50
+ }
51
+
52
+ export interface Tree {
53
+ workspaces: Workspace[];
54
+ }
55
+
56
+ export type SubscribeEvent =
57
+ | { event: "tree-changed" }
58
+ | { event: "surface-output"; surface: number }
59
+ | { event: "surface-resized"; surface: number; cols: number; rows: number }
60
+ | { event: "surface-exited"; surface: number }
61
+ | { event: "title-changed"; surface: number }
62
+ | { event: "bell"; surface: number }
63
+ | { event: "empty" }
64
+ | UnknownEvent;
65
+
66
+ export type AttachEvent =
67
+ | { event: "vt-state"; surface: number; cols: number; rows: number; data: string }
68
+ | { event: "output"; surface: number; data: string }
69
+ | { event: "resized"; surface: number; cols: number; rows: number; replay: string }
70
+ | { event: "detached"; surface: number }
71
+ | UnknownEvent;
72
+
73
+ export interface UnknownEvent {
74
+ event: string;
75
+ [key: string]: unknown;
76
+ }
77
+
78
+ export interface ClientOptions {
79
+ socketPath?: string;
80
+ session?: string;
81
+ timeoutMs?: number;
82
+ allowProtocolV6Attach?: boolean;
83
+ }
84
+
85
+ export interface NewTabOptions { pane?: number; cwd?: string; cols?: number; rows?: number }
86
+ export interface NewBrowserTabOptions { pane?: number; cols?: number; rows?: number }
87
+ export interface NewWorkspaceOptions { name?: string; cols?: number; rows?: number }
88
+ export interface NewScreenOptions { workspace?: number; cols?: number; rows?: number }
89
+ export interface SplitOptions { cols?: number; rows?: number }
90
+ export interface SendOptions { text?: string; bytes?: string | Uint8Array }
91
+ export interface SelectOptions { index?: number; delta?: number }
92
+ export interface SelectTabOptions extends SelectOptions { pane?: number }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "CommonJS",
5
+ "moduleResolution": "Node",
6
+ "strict": true,
7
+ "declaration": true,
8
+ "outDir": "dist",
9
+ "rootDir": ".",
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["src/**/*.ts", "e2e/**/*.ts"]
13
+ }
package/dist/cli.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const index_js_1 = require("./index.js");
9
- const path_1 = __importDefault(require("path"));
10
- const program = new commander_1.Command();
11
- program
12
- .name('cmux')
13
- .description('Socket.IO and static file server')
14
- .version('0.1.1')
15
- .option('-p, --port <port>', 'port to listen on', '2689')
16
- .option('-d, --dir <directory>', 'static files directory', './public')
17
- .option('-c, --cors <origin>', 'CORS origin configuration', 'true')
18
- .action((options) => {
19
- const port = parseInt(options.port);
20
- const staticDir = path_1.default.resolve(options.dir);
21
- const corsOrigin = options.cors === 'true' ? true : options.cors === 'false' ? false : options.cors;
22
- (0, index_js_1.startServer)({
23
- port,
24
- staticDir,
25
- corsOrigin
26
- });
27
- process.on('SIGINT', () => {
28
- console.log('\nShutting down server...');
29
- process.exit(0);
30
- });
31
- process.on('SIGTERM', () => {
32
- console.log('\nShutting down server...');
33
- process.exit(0);
34
- });
35
- });
36
- program.parse();
37
- //# sourceMappingURL=cli.js.map
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,yCAAyC;AACzC,gDAAwB;AAExB,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,kCAAkC,CAAC;KAC/C,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,CAAC;KACxD,MAAM,CAAC,uBAAuB,EAAE,wBAAwB,EAAE,UAAU,CAAC;KACrE,MAAM,CAAC,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,CAAC;KAClE,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;IAClB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAEpG,IAAA,sBAAW,EAAC;QACV,IAAI;QACJ,SAAS;QACT,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import { Server } from 'socket.io';
2
- export interface CmuxOptions {
3
- port?: number;
4
- staticDir?: string;
5
- corsOrigin?: string | string[] | boolean;
6
- }
7
- export declare function createCmuxServer(options?: CmuxOptions): {
8
- app: import("express-serve-static-core").Express;
9
- io: Server<import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, any>;
10
- httpServer: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
11
- start: () => Promise<void>;
12
- stop: () => Promise<void>;
13
- };
14
- export declare function startServer(options?: CmuxOptions): {
15
- app: import("express-serve-static-core").Express;
16
- io: Server<import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, import("socket.io").DefaultEventsMap, any>;
17
- httpServer: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
18
- start: () => Promise<void>;
19
- stop: () => Promise<void>;
20
- };
21
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAKnC,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;CAC1C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,WAAgB;;;;;;EAiEzD;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW;;;;;;EAIhD"}
package/dist/index.js DELETED
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createCmuxServer = createCmuxServer;
7
- exports.startServer = startServer;
8
- const express_1 = __importDefault(require("express"));
9
- const http_1 = require("http");
10
- const socket_io_1 = require("socket.io");
11
- const cors_1 = __importDefault(require("cors"));
12
- const path_1 = __importDefault(require("path"));
13
- function createCmuxServer(options = {}) {
14
- const { port = 2689, staticDir = path_1.default.join(process.cwd(), 'public'), corsOrigin = true } = options;
15
- const app = (0, express_1.default)();
16
- const httpServer = (0, http_1.createServer)(app);
17
- const io = new socket_io_1.Server(httpServer, {
18
- cors: {
19
- origin: corsOrigin,
20
- methods: ['GET', 'POST']
21
- }
22
- });
23
- app.use((0, cors_1.default)({
24
- origin: corsOrigin
25
- }));
26
- app.use(express_1.default.static(staticDir));
27
- app.get('*', (req, res) => {
28
- res.sendFile(path_1.default.join(staticDir, 'index.html'));
29
- });
30
- io.on('connection', (socket) => {
31
- console.log('Client connected:', socket.id);
32
- socket.on('disconnect', () => {
33
- console.log('Client disconnected:', socket.id);
34
- });
35
- socket.on('message', (data) => {
36
- console.log('Message received:', data);
37
- socket.emit('message', { echo: data });
38
- });
39
- });
40
- const start = () => {
41
- return new Promise((resolve) => {
42
- httpServer.listen(port, () => {
43
- console.log(`Cmux server running on port ${port}`);
44
- console.log(`Serving static files from: ${staticDir}`);
45
- resolve();
46
- });
47
- });
48
- };
49
- const stop = () => {
50
- return new Promise((resolve) => {
51
- httpServer.close(() => {
52
- console.log('Cmux server stopped');
53
- resolve();
54
- });
55
- });
56
- };
57
- return {
58
- app,
59
- io,
60
- httpServer,
61
- start,
62
- stop
63
- };
64
- }
65
- function startServer(options) {
66
- const server = createCmuxServer(options);
67
- server.start();
68
- return server;
69
- }
70
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAaA,4CAiEC;AAED,kCAIC;AApFD,sDAA8B;AAC9B,+BAAoC;AACpC,yCAAmC;AACnC,gDAAwB;AACxB,gDAAwB;AASxB,SAAgB,gBAAgB,CAAC,UAAuB,EAAE;IACxD,MAAM,EACJ,IAAI,GAAG,IAAI,EACX,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,EAC9C,UAAU,GAAG,IAAI,EAClB,GAAG,OAAO,CAAC;IAEZ,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IACtB,MAAM,UAAU,GAAG,IAAA,mBAAY,EAAC,GAAG,CAAC,CAAC;IACrC,MAAM,EAAE,GAAG,IAAI,kBAAM,CAAC,UAAU,EAAE;QAChC,IAAI,EAAE;YACJ,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;SACzB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,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;gBACpB,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;gBACnC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG;QACH,EAAE;QACF,UAAU;QACV,KAAK;QACL,IAAI;KACL,CAAC;AACJ,CAAC;AAED,SAAgB,WAAW,CAAC,OAAqB;IAC/C,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/public/index.html DELETED
@@ -1,19 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Cmux Server</title>
7
- </head>
8
- <body>
9
- <h1>Cmux Server Running</h1>
10
- <p>Socket.IO server is ready at port 2689</p>
11
- <script src="/socket.io/socket.io.js"></script>
12
- <script>
13
- const socket = io();
14
- socket.on('connect', () => {
15
- console.log('Connected to server');
16
- });
17
- </script>
18
- </body>
19
- </html>