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 +26 -0
- package/README.md +13 -0
- package/hlw.md +1 -0
- package/package.json +1 -1
- package/runtime/help/cdp.md +119 -0
- package/runtime/jsplugins/cdp/cdp-server.js +1161 -0
- package/runtime/jsplugins/cdp/cdp.js +192 -0
- package/src/highlight/parser.js +20 -11
- package/src/index.js +267 -36
- package/src/platform/clipboard.js +3 -0
- package/src/platform/commands.js +1 -4
- package/src/plugins/js-bridge.js +5 -5
- package/tests/wv-client.js +96 -0
|
@@ -256,6 +256,9 @@ export function osc52Clipboard(stdout) {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
export async function probeOSC52(ttyIn, ttyOut, timeoutMs) {
|
|
259
|
+
return true;
|
|
260
|
+
// Almost no terminal reliably supports probing OSC 52, so treat it as
|
|
261
|
+
// available and let the actual write path fail or work on its own.
|
|
259
262
|
if (process.env.TMUX) return true;
|
|
260
263
|
return new Promise((resolve) => {
|
|
261
264
|
let done = false;
|
package/src/platform/commands.js
CHANGED
|
@@ -118,10 +118,7 @@ export async function runBytes(command, options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export function hasCommand(name) {
|
|
121
|
-
|
|
122
|
-
return runSync(["where.exe", name], { stdout: "ignore", stderr: "ignore" }).ok;
|
|
123
|
-
}
|
|
124
|
-
return runSync(["sh", "-c", `command -v ${shellQuote(name)}`], { stdout: "ignore", stderr: "ignore" }).ok;
|
|
121
|
+
return Bun.which(name);
|
|
125
122
|
}
|
|
126
123
|
|
|
127
124
|
export function firstCommand(names) {
|
package/src/plugins/js-bridge.js
CHANGED
|
@@ -455,10 +455,7 @@ function registerBuiltinActions() {
|
|
|
455
455
|
if (pane?.buffer?.modified) try { await pane.buffer.save?.(); } catch {}
|
|
456
456
|
await app.stop?.(0);
|
|
457
457
|
});
|
|
458
|
-
reg("Escape", (app) =>
|
|
459
|
-
if (app.pane) app.pane.selection = null;
|
|
460
|
-
if (app.buffer) app.buffer.searchPattern = "";
|
|
461
|
-
});
|
|
458
|
+
reg("Escape", (app) => app._dispatchInput?.(new TextEncoder().encode("\x1b")));
|
|
462
459
|
|
|
463
460
|
// Toggle settings
|
|
464
461
|
reg("ToggleDiffGutter", (app) => {
|
|
@@ -768,7 +765,9 @@ export function buildMicroGlobal(jsManager) {
|
|
|
768
765
|
return async (...args) => {
|
|
769
766
|
const app = getApp();
|
|
770
767
|
if (!app) return;
|
|
771
|
-
|
|
768
|
+
const result = await app.handleCommand(buildCmdString(name, args));
|
|
769
|
+
app.render?.();
|
|
770
|
+
return result;
|
|
772
771
|
};
|
|
773
772
|
},
|
|
774
773
|
}),
|
|
@@ -872,6 +871,7 @@ function _makePaneAPI(buffer, app) {
|
|
|
872
871
|
EndOfLine: () => buffer.moveEnd(),
|
|
873
872
|
InsertNewline: () => buffer.newline(),
|
|
874
873
|
InsertTab: () => buffer.insertTab(),
|
|
874
|
+
Insert: (text) => { buffer.pushUndo?.(); buffer.insert(text); app?.render?.(); },
|
|
875
875
|
HandleCommand: (cmd) => app?.handleCommand?.(cmd),
|
|
876
876
|
|
|
877
877
|
// Run a named action on this pane
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const cdpUrl = Bun.argv[2] ?? "ws://127.0.0.1:9222";
|
|
2
|
+
|
|
3
|
+
const view = new Bun.WebView({
|
|
4
|
+
backend: {
|
|
5
|
+
type: "chrome",
|
|
6
|
+
url: cdpUrl,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
view.onNavigated = (url, title) => {
|
|
11
|
+
console.log(`[navigated] ${title || "(no title)"} — ${url.slice(0, 80)}`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const delay = Bun.sleep
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
|
|
18
|
+
await delay(2000);
|
|
19
|
+
|
|
20
|
+
// 1. navigate to first page
|
|
21
|
+
console.log("\n--- navigate: https://example.com ---");
|
|
22
|
+
await view.navigate("https://example.com");
|
|
23
|
+
await delay(2000);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// 2. navigate to second page
|
|
27
|
+
console.log("\n--- evaluate: micro.cmd.tab() ---");
|
|
28
|
+
await view.evaluate("micro.cmd.tab()");
|
|
29
|
+
await delay(500);
|
|
30
|
+
|
|
31
|
+
console.log("\n--- navigate: github bunmicro hlw.md ---");
|
|
32
|
+
await view.navigate("https://raw.githubusercontent.com/jjtseng93/bunmicro/refs/heads/main/hlw.md");
|
|
33
|
+
await delay(2000);
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// 3. navigate to third page
|
|
37
|
+
console.log("\n--- evaluate: micro.cmd.tab() ---");
|
|
38
|
+
await view.evaluate("micro.cmd.tab()");
|
|
39
|
+
await delay(500);
|
|
40
|
+
|
|
41
|
+
console.log("\n--- navigate: https://bun.sh/docs dns ---");
|
|
42
|
+
await view.navigate("https://bun.com/docs/runtime/networking/dns");
|
|
43
|
+
await delay(2000);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// 4. go back twice
|
|
47
|
+
console.log("\n--- goBack (dns → hlw) ---");
|
|
48
|
+
await view.goBack();
|
|
49
|
+
await delay(2000);
|
|
50
|
+
|
|
51
|
+
console.log("\n--- goBack (hlw → example.com) ---");
|
|
52
|
+
await view.goBack();
|
|
53
|
+
await delay(2000);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// 5. go forward
|
|
57
|
+
console.log("\n--- goForward (example.com → hlw) ---");
|
|
58
|
+
await view.goForward();
|
|
59
|
+
await delay(2000);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
// 6. type before # hello & click
|
|
63
|
+
console.log("\n--- click #hello to focus ---");
|
|
64
|
+
await view.scrollTo("#hello");
|
|
65
|
+
await view.evaluate('micro.action.StartOfLine()');
|
|
66
|
+
await delay(2000);
|
|
67
|
+
|
|
68
|
+
console.log("\n--- type: '# Bun is great' ---");
|
|
69
|
+
await view.type("# Bun is great");
|
|
70
|
+
await delay(2000);
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
console.log("\n--- press Enter ---");
|
|
74
|
+
await view.press("Enter");
|
|
75
|
+
await delay(2000);
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
console.log("\n--- Click 3,3 ---");
|
|
79
|
+
await view.click(3,3); //點33
|
|
80
|
+
await delay(2000);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
// 7. resize
|
|
84
|
+
console.log("\n--- resize 1280x720 ---");
|
|
85
|
+
await view.resize(1280, 720);
|
|
86
|
+
await delay(2000);
|
|
87
|
+
|
|
88
|
+
// 8. go forward to dns
|
|
89
|
+
console.log("\n--- goForward (hlw → dns) ---");
|
|
90
|
+
await view.goForward();
|
|
91
|
+
await delay(2000);
|
|
92
|
+
|
|
93
|
+
console.log("\nAll done.");
|
|
94
|
+
} finally {
|
|
95
|
+
view.close();
|
|
96
|
+
}
|