@bobfrankston/msger 0.1.30 → 0.1.32

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 CHANGED
@@ -6,7 +6,7 @@ This package provides a TypeScript/JavaScript API that wraps the native Rust imp
6
6
  - **10-20x faster startup** (~50-200ms vs ~2-3s)
7
7
  - **50x smaller binary** (~2-5MB vs ~100MB)
8
8
  - **5x less memory** (~20-50MB vs ~100-200MB)
9
- - **Cross-platform**: Windows (WebView2), macOS (WebKit), Linux (WebKitGTK)
9
+ - **Cross-platform**: Windows (WebView2), Linux x86_64 (WebKitGTK), Linux ARM64/Raspberry Pi (WebKitGTK)
10
10
 
11
11
  ## Installation
12
12
 
@@ -19,6 +19,13 @@ For global CLI usage:
19
19
  npm install -g @bobfrankston/msger
20
20
  ```
21
21
 
22
+ **Platform Support:**
23
+ - Windows (x64) - Uses WebView2
24
+ - Linux x86_64 - Uses WebKitGTK 4.0
25
+ - Linux ARM64/Raspberry Pi - Uses WebKitGTK 4.0
26
+
27
+ The correct binary is automatically selected based on your platform and architecture.
28
+
22
29
  ## Usage
23
30
 
24
31
  ### As a Library (Recommended)
@@ -43,13 +50,23 @@ if (result.value) {
43
50
 
44
51
  ```bash
45
52
  # Simple message
46
- msger "Hello, World!"
53
+ msger -t "Hello" -m "Hello, World!"
47
54
 
48
55
  # With HTML content
49
- msger "Enter your name:" "<p>Please provide your <strong>full name</strong></p>"
56
+ msger -t "Welcome" -html "<h1>Welcome!</h1><p>This is <strong>HTML</strong></p>"
57
+
58
+ # Load a URL (web page or local file)
59
+ msger -url "https://example.com"
60
+ msger -url "file:///path/to/page.html"
61
+
62
+ # With custom size
63
+ msger -t "Big Window" -m "Hello" -w 800 -h 600
64
+
65
+ # With timeout (auto-close after 5 seconds)
66
+ msger -t "Notification" -m "This will close in 5 seconds" -timeout 5
50
67
 
51
- # From JSON stdin
52
- echo '{"message":"Test","buttons":["Cancel","OK"]}' | msger
68
+ # See all options
69
+ msger --help
53
70
  ```
54
71
 
55
72
  ## API
@@ -62,14 +79,25 @@ Display a message box dialog and wait for user response.
62
79
 
63
80
  ```typescript
64
81
  interface MessageBoxOptions {
65
- title?: string; // Window title (default: "Message")
66
- message: string; // Plain text message (required)
67
- html?: string; // HTML content (overrides message display)
68
- width?: number; // Window width in pixels (default: 600)
69
- height?: number; // Window height in pixels (default: 400)
70
- buttons?: string[]; // Button labels (default: ["OK"])
71
- defaultValue?: string; // Default input value
72
- allowInput?: boolean; // Show input field (default: false)
82
+ title?: string; // Window title (default: "Message")
83
+ message?: string; // Plain text message (optional if url or html provided)
84
+ html?: string; // HTML content to display
85
+ url?: string; // URL to load (web URL or file:// path)
86
+ size?: { // Window size in pixels
87
+ width: number; // Window width (default: 600)
88
+ height: number; // Window height (default: 400)
89
+ };
90
+ buttons?: string[]; // Button labels (default: ["OK"])
91
+ defaultValue?: string; // Default input value
92
+ allowInput?: boolean; // Show input field (default: false)
93
+ timeout?: number; // Auto-close after N seconds
94
+ detach?: boolean; // Launch detached from parent process
95
+
96
+ // Not yet implemented:
97
+ // fullPage?: boolean; // Display HTML as complete page without wrapping
98
+ // pos?: { x: number; y: number; screen?: number }; // Window position
99
+ // zoomPercent?: number; // Initial zoom level (100=100%, 150=150%)
100
+ // devTools?: boolean; // Open DevTools for debugging
73
101
  }
74
102
  ```
75
103
 
@@ -77,10 +105,12 @@ interface MessageBoxOptions {
77
105
 
78
106
  ```typescript
79
107
  interface MessageBoxResult {
80
- button: string; // Label of clicked button
81
- value?: string; // Input value (if allowInput was true)
82
- closed?: boolean; // True if window was closed
83
- dismissed?: boolean; // True if dismissed with Escape
108
+ button: string; // Label of clicked button
109
+ value?: string; // Input value (if allowInput was true)
110
+ form?: object; // Form data (if form elements present)
111
+ closed?: boolean; // True if window was closed
112
+ dismissed?: boolean; // True if dismissed with Escape
113
+ timeout?: boolean; // True if auto-closed by timeout
84
114
  }
85
115
  ```
86
116
 
@@ -121,7 +151,6 @@ if (result.button === 'OK') {
121
151
  ```typescript
122
152
  const result = await showMessageBox({
123
153
  title: 'Welcome',
124
- message: 'Welcome message',
125
154
  html: `
126
155
  <div style="font-family: sans-serif;">
127
156
  <h2 style="color: #2563eb;">Welcome!</h2>
@@ -133,75 +162,163 @@ const result = await showMessageBox({
133
162
  </ul>
134
163
  </div>
135
164
  `,
136
- width: 700,
137
- height: 500,
165
+ size: { width: 700, height: 500 },
138
166
  buttons: ['Close']
139
167
  });
140
168
  ```
141
169
 
170
+ ### Display a Web Page
171
+
172
+ ```typescript
173
+ // Load external website
174
+ await showMessageBox({
175
+ title: 'Documentation',
176
+ url: 'https://github.com/BobFrankston/msger',
177
+ size: { width: 1024, height: 768 }
178
+ });
179
+
180
+ // Load local HTML file
181
+ await showMessageBox({
182
+ title: 'Help',
183
+ url: 'file:///path/to/help.html',
184
+ size: { width: 800, height: 600 }
185
+ });
186
+ ```
187
+
188
+ ### Auto-Close with Timeout
189
+
190
+ ```typescript
191
+ // Show notification that auto-closes after 3 seconds
192
+ const result = await showMessageBox({
193
+ title: 'Notification',
194
+ message: 'File saved successfully!',
195
+ timeout: 3,
196
+ buttons: ['OK']
197
+ });
198
+
199
+ if (result.timeout) {
200
+ console.log('Notification auto-closed');
201
+ }
202
+ ```
203
+
142
204
  ## Architecture
143
205
 
144
206
  ```
145
207
  @bobfrankston/msger (TypeScript wrapper)
146
- ↓ spawns with JSON via stdin
147
- @bobfrankston/msger-native (Rust binary)
208
+ ↓ spawns native binary with JSON via stdin
209
+ @bobfrankston/msger-native (Rust binary - platform-specific)
148
210
  ↓ creates native window with webview
149
- ↓ displays HTML message with buttons
211
+ ↓ displays HTML/URL content with buttons
150
212
  ↓ outputs JSON result to stdout
151
- TypeScript wrapper returns Promise
213
+ TypeScript wrapper returns Promise<MessageBoxResult>
152
214
  ```
153
215
 
216
+ **Platform-specific binaries:**
217
+ - `msgernative.exe` - Windows x64 (WebView2)
218
+ - `msgernative` - Linux x86_64 (WebKitGTK)
219
+ - `msgernative-arm64` - Linux ARM64/Raspberry Pi (WebKitGTK)
220
+
221
+ The correct binary is automatically selected based on `process.platform` and `process.arch`.
222
+
154
223
  ## Building from Source
155
224
 
156
225
  ```bash
157
- # Build both Rust binary and TypeScript wrapper
226
+ # Build everything (TypeScript + all native binaries)
158
227
  npm run build
159
228
 
160
- # Build only TypeScript (assumes Rust binary exists)
229
+ # Build only TypeScript wrapper
161
230
  npm run build:ts
162
231
 
163
- # Build only Rust binary
232
+ # Build Windows binary
164
233
  npm run build:native
165
234
 
235
+ # Build Linux x64 binary (via WSL)
236
+ npm run build:native:wsl
237
+
238
+ # Build ARM64 binary (via SSH to Raspberry Pi)
239
+ npm run build:native:pi
240
+
241
+ # Build all native binaries
242
+ npm run build:native:all
243
+
166
244
  # Watch mode for TypeScript development
167
245
  npm run watch
168
246
  ```
169
247
 
248
+ ### Building ARM64 Binary
249
+
250
+ To build the ARM64 binary for Raspberry Pi:
251
+
252
+ 1. Update `PI_HOST` in `msger-native/build-pi.ts` with your Pi's hostname/IP
253
+ 2. Ensure SSH keys are set up: `ssh-copy-id pi@your-pi`
254
+ 3. Run: `npm run build:native:pi`
255
+
256
+ The script will automatically:
257
+ - Copy source files to the Pi via SSH
258
+ - Install Rust and build dependencies if needed
259
+ - Build the binary on the Pi
260
+ - Copy the binary back to your development machine
261
+
170
262
  ## Development
171
263
 
172
264
  The project consists of two parts:
173
265
 
174
- 1. **`msger-native/`** - Pure Rust binary (subdirectory)
175
- 2. **Root directory** - TypeScript wrapper (this project)
266
+ 1. **`msger-native/`** - Rust binary (subdirectory with its own Cargo.toml)
267
+ 2. **Root directory** - TypeScript wrapper and npm package
176
268
 
177
269
  When you run `npm run build`, it:
178
- 1. Builds the Rust binary in the `msger-native/` subdirectory
179
- 2. Copies the binary to `./bin/`
270
+ 1. Builds platform-specific Rust binaries
271
+ 2. Copies binaries to `msger-native/bin/`
180
272
  3. Compiles TypeScript to JavaScript
181
273
 
182
- The binary is bundled with the npm package, so users get everything in one install.
274
+ All binaries are bundled with the npm package, and the correct one is selected at runtime.
183
275
 
184
276
  ## Features
185
277
 
186
- - ✅ Cross-platform native webview
278
+ - ✅ Cross-platform native webview (Windows, Linux x64, Linux ARM64)
187
279
  - ✅ Full HTML/CSS support
280
+ - ✅ Load external URLs or local files
188
281
  - ✅ Customizable buttons
189
282
  - ✅ Input field support
283
+ - ✅ Auto-close with timeout
190
284
  - ✅ Keyboard shortcuts (Enter, Escape)
191
285
  - ✅ Window close detection
192
286
  - ✅ TypeScript type definitions
193
- - ✅ Small binary size (~2-5MB)
287
+ - ✅ Small binary size (~1-2MB per platform)
194
288
  - ✅ Fast startup (~50-200ms)
289
+ - ✅ Detached process mode
290
+ - ⏳ Coming soon: Window positioning, zoom control, DevTools
195
291
 
196
292
  ## Performance Comparison
197
293
 
198
294
  | | **Electron (msgview)** | **Rust (msger)** | **Improvement** |
199
295
  |---|---|---|---|
200
- | **Binary Size** | ~100MB | ~2-5MB | **50x smaller** |
296
+ | **Binary Size** | ~100MB | ~1-2MB per platform | **50-100x smaller** |
201
297
  | **Startup Time** | ~2-3 seconds | ~50-200ms | **10-20x faster** |
202
- | **Memory Usage** | ~100-200MB | ~20-50MB | **5x less** |
203
- | **Cross-Platform** | ✅ Win/Mac/Linux | ✅ Win/Mac/Linux | Same |
298
+ | **Memory Usage** | ~100-200MB | ~20-50MB | **3-5x less** |
299
+ | **Cross-Platform** | ✅ Win/Mac/Linux | ✅ Win/Linux x64/ARM64 | Similar |
204
300
  | **Full HTML/CSS** | ✅ Chromium | ✅ WebView2/WebKit | Same |
301
+ | **URL Loading** | ✅ | ✅ | Same |
302
+
303
+ ## CLI Options
304
+
305
+ ```
306
+ Usage: msger [options]
307
+
308
+ Options:
309
+ -t, --title <title> Window title
310
+ -m, --message <message> Plain text message
311
+ -html, --html <html> HTML content
312
+ -url, --url <url> URL to load (web or file://)
313
+ -w, --width <width> Window width in pixels (default: 600)
314
+ -h, --height <height> Window height in pixels (default: 400)
315
+ -b, --buttons <buttons> Comma-separated button labels (default: "OK")
316
+ -i, --allowInput Enable input field
317
+ -d, --defaultValue <value> Default input value
318
+ -timeout, --timeout <sec> Auto-close after N seconds
319
+ --help Show help
320
+ --version Show version
321
+ ```
205
322
 
206
323
  ## License
207
324
 
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/msger",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "Fast, lightweight, cross-platform message box - Rust-powered alternative to msgview",
5
5
  "type": "module",
6
6
  "main": "./index.js",