bunmicro 0.9.30 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.2] - 2026-06-24
4
+ - Added startup profiling flags
5
+ * -profile / --profile
6
+ - Added docs flags
7
+ * --changelog alongside --docs / --readme
8
+ - Disabled OSC 52 probing
9
+ * clipboard now treats OSC 52 as available without detection
10
+ - Added hex3 aliases
11
+ * --xxd / --hexdump => --cat -encoding hex3
12
+ * --hex3 => -encoding hex3
13
+ - Fixed stdin encoding handling
14
+ * hex3 now applies when reading from stdin
15
+ - Parallelized startup loading
16
+ * Lua, JS, and buffer init now run in parallel with safe degradation
17
+ * startup performance improves a lot
18
+
19
+ ## [1.0.0] - 2026-06-22
20
+ - Changed command -v to Bun.which
21
+ * for performance improvement
22
+ - Added experimental CDP support
23
+ * Chrome DevTools Protocol server (Ctrl+E cdp [port])
24
+ * Allows automation via Playwright or Bun.WebView
25
+ * --remote-debugging-port=PORT flag to auto-start at launch
26
+ - Fixed Escape action now routes through full input pipeline
27
+ * Correctly handles terminal pane, TTS, and mark selection
28
+
3
29
  ## [0.9.30] - 2026-06-13
4
30
  - Fixed binary edit hex3 regression
5
31
  * see readme
package/README.md CHANGED
@@ -61,6 +61,19 @@
61
61
  - No native bindings
62
62
  - No recompilation
63
63
  - Just Copy folder -> Run with Bun
64
+ ## CDP — Chrome DevTools Protocol (experimental)
65
+ - Control bunmicro like a browser from an external script
66
+ - Start from command prompt: `Ctrl-E cdp` (default port 9222) or `Ctrl-E cdp 9000`
67
+ - Or launch with: `bunmicro --remote-debugging-port=9222 file.txt`
68
+ - Once running, connect with Bun.WebView or Playwright:
69
+ ```js
70
+ const view = new Bun.WebView({ backend: { type: "chrome", url: "ws://127.0.0.1:9222" } });
71
+ await view.navigate("file.txt");
72
+ await view.type("hello");
73
+ await view.press("Enter");
74
+ ```
75
+ - Supports: navigate, type, press, click(x,y), scroll(dx,dy), scrollTo, evaluate, goBack, goForward
76
+ - Full client example: `Ctrl-E help cdp`
64
77
  ## Version shows backends
65
78
  - bunmicro --version shows http/clipboard/tts backends
66
79
 
package/hlw.md CHANGED
@@ -1,3 +1,4 @@
1
+ # bunmicro
1
2
  # hello
2
3
  - world
3
4
  - 你好 世界 😅
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunmicro",
3
- "version": "0.9.30",
3
+ "version": "1.0.2",
4
4
  "description": "Bun JavaScript rewrite of the micro editor originally in Golang",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env bun
2
+
3
+ // ─── CDP (Chrome DevTools Protocol) ────────────────────────────────────────
4
+ //
5
+ // bunmicro can act as a CDP target, letting external scripts control it
6
+ // the same way Playwright or Bun.WebView controls a browser.
7
+ //
8
+ // ── Starting the server ────────────────────────────────────────────────────
9
+ //
10
+ // Inside the editor:
11
+ // Ctrl-E cdp → 127.0.0.1:9222
12
+ // Ctrl-E cdp 9000 → 127.0.0.1:9000
13
+ // Ctrl-E cdp --public → 0.0.0.0:9222
14
+ // Ctrl-E cdp 9000 --public → 0.0.0.0:9000
15
+ // Ctrl-E cdp --address=192.168.1.1 → 192.168.1.1:9222
16
+ // Ctrl-E cdp 9000 --address=192.168.1.1 → 192.168.1.1:9000
17
+ //
18
+ // From the command line (Chrome-style):
19
+ // bunmicro --remote-debugging-port=9222 file.txt
20
+ // bunmicro --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 file.txt
21
+ //
22
+ // Once running, status bar shows: CDP@<port> server running
23
+ // Running cdp again shows: CDP@<port> already running
24
+ //
25
+ // ── Connecting ─────────────────────────────────────────────────────────────
26
+ //
27
+ // Bun.WebView:
28
+ // const view = new Bun.WebView({
29
+ // backend: { type: "chrome", url: "ws://127.0.0.1:9222" }
30
+ // });
31
+ //
32
+ // Playwright (Node/Bun):
33
+ // const browser = await chromium.connectOverCDP("http://127.0.0.1:9222");
34
+ //
35
+ // ── Available methods ───────────────────────────────────────────────────────
36
+ //
37
+ // view.navigate(url) open file or URL in editor (Ctrl-E open)
38
+ // view.type(text) insert text at cursor
39
+ // view.press(key, opts?) send a key press
40
+ // key: "Enter","Backspace","Tab","Escape",
41
+ // "ArrowUp/Down/Left/Right",
42
+ // "Home","End","PageUp","PageDown",
43
+ // or single char "a"
44
+ // opts: { modifiers: bitmask }
45
+ // Alt=1 Ctrl=2 Meta=4 Shift=8
46
+ // view.click(x, y) move cursor to column x, line y (1-based)
47
+ // view.scroll(dx, dy) move cursor by dx cols and dy lines
48
+ // view.scrollTo(selector) find text or #anchor and jump to it
49
+ // view.evaluate(jsCode) run JS inside bunmicro's plugin context
50
+ // e.g. "micro.cmd.save()"
51
+ // view.goBack() switch to previous tab (PrevTab)
52
+ // view.goForward() switch to next tab (NextTab)
53
+ // view.resize(w, h) accepted by protocol but not yet implemented
54
+ //
55
+ // ── Example script below ───────────────────────────────────────────────────
56
+ // ctrl-a ctrl-c = select+copy all
57
+ // ctrl-t = new tab
58
+ // ctrl-v = paste
59
+ // ctrl-s filename.js enter
60
+ // run with bun filename.js
61
+
62
+ const cdpUrl = "ws://127.0.0.1:9222";
63
+
64
+ const view = new Bun.WebView({
65
+ backend: {
66
+ type: "chrome",
67
+ url: cdpUrl,
68
+ },
69
+ });
70
+
71
+ view.onNavigated = (url, title) => {
72
+ console.log(`[navigated] ${title || "(no title)"} — ${url.slice(0, 80)}`);
73
+ };
74
+
75
+ const delay = Bun.sleep
76
+ const startInterval = 1000
77
+ const interval = 500
78
+
79
+ try {
80
+
81
+ await delay(startInterval);
82
+
83
+ await view.navigate("https://raw.githubusercontent.com/jjtseng93/bunmicro/refs/heads/main/hlw.md");
84
+ await delay(interval);
85
+
86
+ await view.evaluate(
87
+ "micro.cmd.tab()"
88
+ );
89
+ await delay(interval);
90
+
91
+ await view.goBack();
92
+ await delay(interval);
93
+
94
+ //await view.goForward();
95
+ //await delay(interval);
96
+
97
+ await view.scrollTo("#hello");
98
+ await view.evaluate('micro.action.StartOfLine()');
99
+ await delay(interval);
100
+
101
+ await view.type("# Bun is great");
102
+ await delay(interval);
103
+
104
+ await view.press("Enter");
105
+ await delay(interval);
106
+
107
+ await view.click(3,3);
108
+ await delay(interval);
109
+ await view.scroll(4,3);
110
+
111
+ await view.resize(1280, 720);
112
+ await delay(interval);
113
+
114
+ console.log(
115
+ Bun.markdown.ansi('### All done')
116
+ )
117
+ } finally {
118
+ view.close();
119
+ }