@sanohiro/casty 0.5.0 → 0.5.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/README.ja.md CHANGED
@@ -39,7 +39,7 @@ Chrome (Headless Shell) casty Terminal
39
39
  ## 必要環境
40
40
 
41
41
  - **Kitty graphics protocol** 対応ターミナル
42
- - Node.js >= 22
42
+ - Node.js >= 18
43
43
 
44
44
  動作確認済み: **bcon**, **Ghostty**, **kitty**
45
45
 
package/README.md CHANGED
@@ -39,7 +39,7 @@ Chrome (Headless Shell) casty Terminal
39
39
  ## Requirements
40
40
 
41
41
  - **Kitty graphics protocol** compatible terminal
42
- - Node.js >= 22
42
+ - Node.js >= 18
43
43
 
44
44
  Tested on: **bcon**, **Ghostty**, **kitty**
45
45
 
package/bin/casty CHANGED
@@ -197,4 +197,4 @@ if needs_update; then
197
197
  fi
198
198
  fi
199
199
 
200
- exec node "$CASTY_DIR/bin/casty.js" "$@"
200
+ # Called from casty.js — just ensures Chrome is available
package/bin/casty.js CHANGED
@@ -1,6 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  // casty - TTY web browser using raw CDP and Kitty graphics protocol
3
3
 
4
+ import { execFileSync } from 'node:child_process';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { dirname, join } from 'node:path';
7
+
8
+ // Ensure Chrome is installed (runs shell script that handles download/update)
9
+ const __bin = dirname(fileURLToPath(import.meta.url));
10
+ try {
11
+ execFileSync('bash', [join(__bin, 'casty')], { stdio: 'inherit' });
12
+ } catch (err) {
13
+ // Shell script prints its own errors — exit if Chrome not available
14
+ if (err.status) process.exit(err.status);
15
+ }
16
+
4
17
  import { startBrowser, setupPage, startScreencast, stopScreencast } from '../lib/browser.js';
5
18
  import { sendFrame, resetFrameCache, clearScreen, hideCursor, showCursor, cleanup as cleanupTmp, transport } from '../lib/kitty.js';
6
19
  import { enableMouse, disableMouse, startInputHandling } from '../lib/input.js';
@@ -30,7 +43,8 @@ function calcZoom(cellWidth) {
30
43
  function queryTermPixelSize({ keepAlive = false } = {}) {
31
44
  if (!process.stdin.isTTY) return Promise.resolve(null);
32
45
 
33
- const { promise, resolve } = Promise.withResolvers();
46
+ let resolve;
47
+ const promise = new Promise(r => { resolve = r; });
34
48
  const wasRaw = process.stdin.isRaw;
35
49
  const timeout = setTimeout(() => {
36
50
  process.stdin.removeListener('data', onData);
package/lib/cdp.js CHANGED
@@ -44,7 +44,8 @@ export class CDPClient extends EventEmitter {
44
44
  // Send CDP command (with timeout to prevent forever-pending)
45
45
  send(method, params = {}) {
46
46
  const id = ++this._id;
47
- const { promise, resolve, reject } = Promise.withResolvers();
47
+ let resolve, reject;
48
+ const promise = new Promise((res, rej) => { resolve = res; reject = rej; });
48
49
  const timer = setTimeout(() => {
49
50
  this._pending.delete(id);
50
51
  reject(new Error(`CDP timeout: ${method}`));
package/lib/chrome.js CHANGED
@@ -132,7 +132,8 @@ export function launchChrome({ userDataDir, windowSize, args = [] } = {}) {
132
132
  });
133
133
 
134
134
  // Extract DevTools URL from stderr
135
- const { promise, resolve, reject } = Promise.withResolvers();
135
+ let resolve, reject;
136
+ const promise = new Promise((res, rej) => { resolve = res; reject = rej; });
136
137
  let stderr = '';
137
138
  const timeout = setTimeout(() => reject(new Error('Chrome startup timeout')), 15000);
138
139
 
package/lib/hints.js CHANGED
@@ -137,7 +137,8 @@ export class HintMode {
137
137
  this.active = true;
138
138
  this._forceCapture();
139
139
 
140
- const { promise, resolve } = Promise.withResolvers();
140
+ let resolve;
141
+ const promise = new Promise(r => { resolve = r; });
141
142
  this._resolve = resolve;
142
143
  return promise;
143
144
  }
package/lib/input.js CHANGED
@@ -217,7 +217,8 @@ function clipboardWrite(text) {
217
217
 
218
218
  // Read from clipboard via OSC 52
219
219
  function clipboardRead() {
220
- const { promise, resolve } = Promise.withResolvers();
220
+ let resolve;
221
+ const promise = new Promise(r => { resolve = r; });
221
222
  const timeout = setTimeout(() => {
222
223
  process.stdin.removeListener('data', onData);
223
224
  resolve(null);
package/lib/urlbar.js CHANGED
@@ -163,7 +163,8 @@ export class UrlBar {
163
163
  this.cursor = [...this.text].length;
164
164
  showCursor();
165
165
  this.render();
166
- const { promise, resolve } = Promise.withResolvers();
166
+ let resolve;
167
+ const promise = new Promise(r => { resolve = r; });
167
168
  this._resolve = resolve;
168
169
  return promise;
169
170
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@sanohiro/casty",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "TTY web browser using raw CDP and Kitty graphics protocol",
5
5
  "main": "bin/casty.js",
6
6
  "bin": {
7
- "casty": "bin/casty"
7
+ "casty": "bin/casty.js"
8
8
  },
9
9
  "files": [
10
10
  "bin/",
@@ -33,7 +33,7 @@
33
33
  "license": "MIT",
34
34
  "type": "module",
35
35
  "engines": {
36
- "node": ">=22.0.0"
36
+ "node": ">=18.0.0"
37
37
  },
38
38
  "dependencies": {
39
39
  "ws": "^8.0.0"