termweb 0.9.2 → 0.9.6
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.md +12 -11
- package/lib/index.js +140 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,13 +8,12 @@ Web browser in your terminal using Kitty graphics protocol.
|
|
|
8
8
|
|
|
9
9
|
## Demo: CLI - browsing the web in terminal
|
|
10
10
|
|
|
11
|
-
https://github.com/user-attachments/assets/
|
|
11
|
+
https://github.com/user-attachments/assets/70b86b29-19b4-458b-8d5d-683f5e139908
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
## Demo: SDK: building apps with termweb as render engine
|
|
15
15
|
|
|
16
|
-
https://github.com/user-attachments/assets/
|
|
17
|
-
|
|
16
|
+
https://github.com/user-attachments/assets/12183bb7-de8b-4e44-b884-216e304ab8ce
|
|
18
17
|
|
|
19
18
|
## Features
|
|
20
19
|
|
|
@@ -24,8 +23,7 @@ https://github.com/user-attachments/assets/806cac11-3348-48b7-95a0-0c98fd61c873
|
|
|
24
23
|
- **Tab Management** - Multiple tabs with native OS dialog picker (Cmd+click or Tab button)
|
|
25
24
|
- **Clipboard Integration** - Ctrl+C/X/V for copy/cut/paste (uses system clipboard)
|
|
26
25
|
- **URL Navigation** - Press Ctrl+L to focus address bar
|
|
27
|
-
- **
|
|
28
|
-
- **Zoom Control** - Adjust page scale with `--scale` option
|
|
26
|
+
- **Hint Mode** - Vimium-style keyboard navigation (Ctrl+H)
|
|
29
27
|
|
|
30
28
|
## Requirements
|
|
31
29
|
|
|
@@ -67,11 +65,14 @@ zig build
|
|
|
67
65
|
# Open a URL
|
|
68
66
|
termweb open https://example.com
|
|
69
67
|
|
|
70
|
-
#
|
|
71
|
-
termweb open https://example.com --
|
|
68
|
+
# Clone Chrome profile (use existing logins, extensions, settings)
|
|
69
|
+
termweb open https://example.com --profile Default
|
|
70
|
+
|
|
71
|
+
# App mode (hide navigation bar)
|
|
72
|
+
termweb open https://example.com --no-toolbar
|
|
72
73
|
|
|
73
|
-
#
|
|
74
|
-
termweb open https://example.com --
|
|
74
|
+
# SSH-optimized (lower frame rate)
|
|
75
|
+
termweb open https://example.com --fps 12
|
|
75
76
|
|
|
76
77
|
# Show help
|
|
77
78
|
termweb help
|
|
@@ -89,9 +90,7 @@ termweb.open('https://example.com');
|
|
|
89
90
|
|
|
90
91
|
// With options
|
|
91
92
|
termweb.open('https://vscode.dev', {
|
|
92
|
-
mobile: false, // Mobile viewport
|
|
93
93
|
toolbar: false, // Hide navigation toolbar
|
|
94
|
-
scale: 0.8, // Page zoom
|
|
95
94
|
});
|
|
96
95
|
|
|
97
96
|
// Check availability
|
|
@@ -144,6 +143,8 @@ Extensions can provide:
|
|
|
144
143
|
| `Ctrl+[` | Go back |
|
|
145
144
|
| `Ctrl+]` | Go forward |
|
|
146
145
|
| `Ctrl+.` | Stop loading |
|
|
146
|
+
| `Ctrl+N` | New tab (about:blank) |
|
|
147
|
+
| `Ctrl+W` | Close tab (quit if last tab) |
|
|
147
148
|
| `Ctrl+T` | Show tab picker |
|
|
148
149
|
| `Ctrl+C` | Copy selection |
|
|
149
150
|
| `Ctrl+X` | Cut selection |
|
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ for (const modulePath of searchPaths) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Open a URL in termweb
|
|
39
|
+
* Open a URL in termweb (blocking)
|
|
40
40
|
* @param {string} url - URL to open
|
|
41
41
|
* @param {Object} [options] - Options
|
|
42
42
|
* @param {boolean} [options.toolbar=true] - Show navigation toolbar
|
|
@@ -62,6 +62,135 @@ function open(url, options = {}) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Open a URL in termweb (non-blocking)
|
|
67
|
+
* Returns immediately, viewer runs in background
|
|
68
|
+
* @param {string} url - URL to open
|
|
69
|
+
* @param {Object} [options] - Same options as open()
|
|
70
|
+
* @returns {void}
|
|
71
|
+
*/
|
|
72
|
+
function openAsync(url, options = {}) {
|
|
73
|
+
if (!native) {
|
|
74
|
+
throw new Error('Native module not found. Build with: zig build');
|
|
75
|
+
}
|
|
76
|
+
native.openAsync(url, options);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Evaluate JavaScript in the active viewer
|
|
81
|
+
* @param {string} script - JavaScript code to execute
|
|
82
|
+
* @returns {boolean} - true if successful
|
|
83
|
+
*/
|
|
84
|
+
function evalJS(script) {
|
|
85
|
+
if (!native) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return native.evalJS(script);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Close the active viewer
|
|
93
|
+
* @returns {boolean} - true if there was a viewer to close
|
|
94
|
+
*/
|
|
95
|
+
function close() {
|
|
96
|
+
if (!native) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return native.close();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Check if a viewer is currently open
|
|
104
|
+
* @returns {boolean}
|
|
105
|
+
*/
|
|
106
|
+
function isOpen() {
|
|
107
|
+
if (!native) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return native.isOpen();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Register a callback to be called when the viewer closes
|
|
115
|
+
* @param {Function} callback - Function to call on close
|
|
116
|
+
*/
|
|
117
|
+
function onClose(callback) {
|
|
118
|
+
if (!native) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
native.onClose(callback);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Register a callback to receive IPC messages from the browser
|
|
126
|
+
* Browser sends messages via: console.log('__TERMWEB_IPC__:' + yourMessage)
|
|
127
|
+
* @param {Function} callback - Function to call with the message string
|
|
128
|
+
*/
|
|
129
|
+
function onMessage(callback) {
|
|
130
|
+
if (!native) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
native.onMessage(callback);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Register a callback to receive key binding events
|
|
138
|
+
* Called when a key defined in keyBindings option is pressed
|
|
139
|
+
* @param {Function} callback - Function to call with (key, action)
|
|
140
|
+
*/
|
|
141
|
+
function onKeyBinding(callback) {
|
|
142
|
+
if (!native) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
native.onKeyBinding(callback);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Add a key binding dynamically
|
|
150
|
+
* @param {string} key - Single letter a-z
|
|
151
|
+
* @param {string} action - Action string to send when key is pressed
|
|
152
|
+
* @returns {boolean} - true if successful
|
|
153
|
+
*/
|
|
154
|
+
function addKeyBinding(key, action) {
|
|
155
|
+
if (!native) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return native.addKeyBinding(key, action);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Remove a key binding dynamically
|
|
163
|
+
* @param {string} key - Single letter a-z
|
|
164
|
+
* @returns {boolean} - true if successful
|
|
165
|
+
*/
|
|
166
|
+
function removeKeyBinding(key) {
|
|
167
|
+
if (!native) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return native.removeKeyBinding(key);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Send a message to the page via SDK IPC
|
|
175
|
+
* Page receives via: window.__termweb.onMessage(callback)
|
|
176
|
+
* @param {Object|string} message - Message to send (will be JSON serialized)
|
|
177
|
+
* @returns {boolean} - true if successful
|
|
178
|
+
*/
|
|
179
|
+
function sendToPage(message) {
|
|
180
|
+
if (!native) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
const json = typeof message === 'string' ? message : JSON.stringify(message);
|
|
184
|
+
// Escape for JavaScript string literal
|
|
185
|
+
const escaped = json.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
186
|
+
const script = `(function(){
|
|
187
|
+
if(window.__termweb && window.__termweb._receive){
|
|
188
|
+
window.__termweb._receive('${escaped}');
|
|
189
|
+
}
|
|
190
|
+
})()`;
|
|
191
|
+
return native.evalJS(script);
|
|
192
|
+
}
|
|
193
|
+
|
|
65
194
|
/**
|
|
66
195
|
* Get termweb version
|
|
67
196
|
* @returns {string}
|
|
@@ -94,6 +223,16 @@ function isAvailable() {
|
|
|
94
223
|
|
|
95
224
|
module.exports = {
|
|
96
225
|
open,
|
|
226
|
+
openAsync,
|
|
227
|
+
evalJS,
|
|
228
|
+
sendToPage,
|
|
229
|
+
close,
|
|
230
|
+
isOpen,
|
|
231
|
+
onClose,
|
|
232
|
+
onMessage,
|
|
233
|
+
onKeyBinding,
|
|
234
|
+
addKeyBinding,
|
|
235
|
+
removeKeyBinding,
|
|
97
236
|
version,
|
|
98
237
|
isSupported,
|
|
99
238
|
isAvailable,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "termweb",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "Web browser in your terminal using Kitty graphics protocol. SDK for building terminal apps with web technologies.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"cli",
|
|
25
25
|
"web"
|
|
26
26
|
],
|
|
27
|
-
"author": "
|
|
27
|
+
"author": "teamch",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|