@geometra/cli 1.13.1 → 1.13.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/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +39 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/viewer.d.ts +16 -0
- package/dist/viewer.d.ts.map +1 -0
- package/dist/viewer.js +63 -0
- package/dist/viewer.js.map +1 -0
- package/package.json +4 -4
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { viewInTerminal } from './viewer.js';
|
|
3
|
+
const url = process.argv[2];
|
|
4
|
+
if (!url) {
|
|
5
|
+
console.error('Usage: geometra <url>');
|
|
6
|
+
console.error('');
|
|
7
|
+
console.error(' View any Geometra-powered site in the terminal.');
|
|
8
|
+
console.error('');
|
|
9
|
+
console.error('Examples:');
|
|
10
|
+
console.error(' geometra https://artemis-two.razroo.com/');
|
|
11
|
+
console.error(' geometra http://localhost:5173/');
|
|
12
|
+
console.error(' geometra ws://localhost:8080/geometra-ws');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
// Resolve WebSocket URL from input
|
|
16
|
+
let wsUrl;
|
|
17
|
+
if (url.startsWith('ws://') || url.startsWith('wss://')) {
|
|
18
|
+
// Direct WebSocket URL
|
|
19
|
+
wsUrl = url;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// HTTP(S) URL — derive WebSocket endpoint
|
|
23
|
+
const parsed = new URL(url);
|
|
24
|
+
const wsProto = parsed.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
25
|
+
// Default Geometra WS path
|
|
26
|
+
wsUrl = `${wsProto}//${parsed.host}/geometra-ws`;
|
|
27
|
+
}
|
|
28
|
+
console.error(`Connecting to ${wsUrl}...`);
|
|
29
|
+
const viewer = viewInTerminal({ url: wsUrl });
|
|
30
|
+
// Clean exit on Ctrl+C
|
|
31
|
+
process.on('SIGINT', () => {
|
|
32
|
+
viewer.close();
|
|
33
|
+
process.exit(0);
|
|
34
|
+
});
|
|
35
|
+
process.on('SIGTERM', () => {
|
|
36
|
+
viewer.close();
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAE3B,IAAI,CAAC,GAAG,EAAE,CAAC;IACT,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACjB,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAA;IAClE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACjB,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IAC1B,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAA;IAC3D,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;IAClD,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAA;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,mCAAmC;AACnC,IAAI,KAAa,CAAA;AAEjB,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxD,uBAAuB;IACvB,KAAK,GAAG,GAAG,CAAA;AACb,CAAC;KAAM,CAAC;IACN,0CAA0C;IAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAA;IAC7D,2BAA2B;IAC3B,KAAK,GAAG,GAAG,OAAO,KAAK,MAAM,CAAC,IAAI,cAAc,CAAA;AAClD,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC,CAAA;AAE1C,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;AAE7C,uBAAuB;AACvB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,MAAM,CAAC,KAAK,EAAE,CAAA;IACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,KAAK,EAAE,CAAA;IACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/viewer.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ViewOptions {
|
|
2
|
+
/** WebSocket URL to connect to. */
|
|
3
|
+
url: string;
|
|
4
|
+
/** Terminal columns (default: stdout columns). */
|
|
5
|
+
width?: number;
|
|
6
|
+
/** Terminal rows (default: stdout rows). */
|
|
7
|
+
height?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Connect to a Geometra server WebSocket and render in the terminal.
|
|
11
|
+
* Returns a cleanup function to close the connection.
|
|
12
|
+
*/
|
|
13
|
+
export declare function viewInTerminal(options: ViewOptions): {
|
|
14
|
+
close: () => void;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CA4C1E"}
|
package/dist/viewer.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TerminalRenderer } from '@geometra/renderer-terminal';
|
|
2
|
+
import WebSocket from 'ws';
|
|
3
|
+
function applyPatches(layout, patches) {
|
|
4
|
+
for (const patch of patches) {
|
|
5
|
+
let node = layout;
|
|
6
|
+
for (const idx of patch.path) {
|
|
7
|
+
node = node.children[idx];
|
|
8
|
+
}
|
|
9
|
+
if (patch.x !== undefined)
|
|
10
|
+
node.x = patch.x;
|
|
11
|
+
if (patch.y !== undefined)
|
|
12
|
+
node.y = patch.y;
|
|
13
|
+
if (patch.width !== undefined)
|
|
14
|
+
node.width = patch.width;
|
|
15
|
+
if (patch.height !== undefined)
|
|
16
|
+
node.height = patch.height;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Connect to a Geometra server WebSocket and render in the terminal.
|
|
21
|
+
* Returns a cleanup function to close the connection.
|
|
22
|
+
*/
|
|
23
|
+
export function viewInTerminal(options) {
|
|
24
|
+
const renderer = new TerminalRenderer({
|
|
25
|
+
width: options.width,
|
|
26
|
+
height: options.height,
|
|
27
|
+
});
|
|
28
|
+
let layout = null;
|
|
29
|
+
let tree = null;
|
|
30
|
+
const ws = new WebSocket(options.url);
|
|
31
|
+
ws.on('message', (data) => {
|
|
32
|
+
try {
|
|
33
|
+
const msg = JSON.parse(data.toString());
|
|
34
|
+
if (msg.type === 'frame') {
|
|
35
|
+
const frame = msg;
|
|
36
|
+
layout = frame.layout;
|
|
37
|
+
tree = frame.tree;
|
|
38
|
+
renderer.render(layout, tree);
|
|
39
|
+
}
|
|
40
|
+
else if (msg.type === 'patch' && layout && tree) {
|
|
41
|
+
applyPatches(layout, msg.patches);
|
|
42
|
+
renderer.render(layout, tree);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// ignore parse errors
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
ws.on('error', (err) => {
|
|
50
|
+
process.stderr.write(`\x1b[31mConnection error: ${err.message}\x1b[0m\n`);
|
|
51
|
+
});
|
|
52
|
+
ws.on('close', () => {
|
|
53
|
+
renderer.destroy();
|
|
54
|
+
process.stderr.write('Disconnected.\n');
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
close() {
|
|
58
|
+
ws.close();
|
|
59
|
+
renderer.destroy();
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=viewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["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.2",
|
|
4
4
|
"description": "CLI to view any Geometra-powered site in the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"check": "tsc --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@geometra/core": "^1.13.
|
|
39
|
-
"@geometra/renderer-terminal": "^1.13.
|
|
40
|
-
"textura": "^1.13.
|
|
38
|
+
"@geometra/core": "^1.13.2",
|
|
39
|
+
"@geometra/renderer-terminal": "^1.13.2",
|
|
40
|
+
"textura": "^1.13.2",
|
|
41
41
|
"ws": "^8.18.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|