handset 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jordan Neill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Handset
2
+
3
+ A frameless, always-on-top mobile viewport browser. Open any URL in a 465x722 window that emulates an iPhone — perfect for demos and presentations.
4
+
5
+ ## Install & Run
6
+
7
+ ```bash
8
+ # Run directly (no install needed)
9
+ npx handset
10
+
11
+ # Open a specific URL
12
+ npx handset example.com
13
+
14
+ # Install globally
15
+ npm install -g handset
16
+ handset
17
+ handset example.com
18
+ ```
19
+
20
+ ## Keyboard Shortcuts
21
+
22
+ | Shortcut | Action |
23
+ |---|---|
24
+ | `Cmd+L` | Change URL |
25
+ | `Cmd+R` | Reload |
26
+ | `Cmd+Shift+R` | Clear all cache & data, then reload |
27
+ | `Cmd+0` | Reset window to default size (465x722) |
28
+ | `Cmd+Shift+I` | Toggle DevTools |
29
+
30
+ ## Menu Options
31
+
32
+ All options are available from the macOS menu bar:
33
+
34
+ - **Navigate > Change URL...** — Enter a new URL to display
35
+ - **Navigate > Reload** — Refresh the current page
36
+ - **View > Always on Top** — Toggle window floating (default: on)
37
+ - **View > Reset Window Size** — Snap back to 465x722
38
+ - **View > Clear Cache & Data** — Wipe cookies, localStorage, cache, and reload
39
+
40
+ ## Features
41
+
42
+ - Frameless window — no chrome, just content
43
+ - Mobile user agent (iPhone Safari) — sites serve their mobile layout
44
+ - URL persisted between sessions
45
+ - Resizable window with one-click reset
46
+ - Always-on-top by default for overlay during presentations
47
+
48
+ ## License
49
+
50
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const electron = require('electron');
6
+
7
+ const mainPath = path.join(__dirname, '..', 'src', 'main.js');
8
+
9
+ // Pass optional URL argument to Electron via environment variable
10
+ const url = process.argv[2];
11
+ const env = { ...process.env };
12
+ if (url) {
13
+ env.HANDSET_URL = url;
14
+ }
15
+
16
+ const child = spawn(electron, [mainPath], {
17
+ stdio: 'inherit',
18
+ windowsHide: false,
19
+ env
20
+ });
21
+
22
+ child.on('close', (code) => {
23
+ process.exit(code);
24
+ });
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "handset",
3
+ "version": "1.0.0",
4
+ "description": "A frameless mobile-viewport browser window for demos",
5
+ "main": "src/main.js",
6
+ "bin": {
7
+ "handset": "./bin/cli.js"
8
+ },
9
+ "scripts": {
10
+ "start": "electron ."
11
+ },
12
+ "keywords": ["electron", "mobile", "demo", "browser", "viewport", "handset"],
13
+ "author": "Jordan Neill",
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/jneill/handset.git"
18
+ },
19
+ "homepage": "https://github.com/jneill/handset#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/jneill/handset/issues"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.0.0"
25
+ },
26
+ "files": [
27
+ "bin/",
28
+ "src/",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "dependencies": {
33
+ "electron": "^35.0.0",
34
+ "electron-store": "^10.0.0"
35
+ }
36
+ }
package/src/index.html ADDED
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Handset</title>
7
+ <link rel="stylesheet" href="styles.css">
8
+ </head>
9
+ <body>
10
+ <div id="drag-region"></div>
11
+ <webview id="webview" allowpopups></webview>
12
+
13
+ <div id="url-overlay" class="overlay hidden">
14
+ <div class="overlay-box">
15
+ <label for="url-input">Enter URL</label>
16
+ <input type="url" id="url-input" placeholder="https://example.com" spellcheck="false">
17
+ <div class="overlay-buttons">
18
+ <button id="url-cancel">Cancel</button>
19
+ <button id="url-ok">OK</button>
20
+ </div>
21
+ </div>
22
+ </div>
23
+
24
+ <script src="renderer.js"></script>
25
+ </body>
26
+ </html>
package/src/main.js ADDED
@@ -0,0 +1,179 @@
1
+ const { app, BrowserWindow, Menu, session, ipcMain, shell } = require('electron');
2
+ const path = require('path');
3
+
4
+ const MOBILE_UA =
5
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) ' +
6
+ 'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1';
7
+
8
+ let win;
9
+ let store;
10
+
11
+ async function initStore() {
12
+ const Store = (await import('electron-store')).default;
13
+ store = new Store({
14
+ defaults: {
15
+ url: ''
16
+ }
17
+ });
18
+ }
19
+
20
+ function createWindow() {
21
+ win = new BrowserWindow({
22
+ width: 465,
23
+ height: 722,
24
+ frame: false,
25
+ resizable: true,
26
+ alwaysOnTop: true,
27
+ backgroundColor: '#000000',
28
+ webPreferences: {
29
+ preload: path.join(__dirname, 'preload.js'),
30
+ contextIsolation: true,
31
+ nodeIntegration: false,
32
+ webviewTag: true
33
+ }
34
+ });
35
+
36
+ win.loadFile(path.join(__dirname, 'index.html'));
37
+
38
+ win.on('closed', () => {
39
+ win = null;
40
+ });
41
+
42
+ buildMenu();
43
+ }
44
+
45
+ function buildMenu() {
46
+ const template = [
47
+ {
48
+ label: 'Handset',
49
+ submenu: [
50
+ { role: 'about' },
51
+ { type: 'separator' },
52
+ { role: 'quit' }
53
+ ]
54
+ },
55
+ {
56
+ label: 'Navigate',
57
+ submenu: [
58
+ {
59
+ label: 'Change URL…',
60
+ accelerator: 'CmdOrCtrl+L',
61
+ click: () => {
62
+ if (win) win.webContents.send('show-url-prompt');
63
+ }
64
+ },
65
+ {
66
+ label: 'Reload',
67
+ accelerator: 'CmdOrCtrl+R',
68
+ click: () => {
69
+ if (win) win.webContents.send('reload-webview');
70
+ }
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ label: 'View',
76
+ submenu: [
77
+ {
78
+ label: 'Always on Top',
79
+ type: 'checkbox',
80
+ checked: true,
81
+ click: (menuItem) => {
82
+ if (win) win.setAlwaysOnTop(menuItem.checked);
83
+ }
84
+ },
85
+ {
86
+ label: 'Reset Window Size',
87
+ accelerator: 'CmdOrCtrl+0',
88
+ click: () => {
89
+ if (win) win.setSize(465, 722);
90
+ }
91
+ },
92
+ { type: 'separator' },
93
+ {
94
+ label: 'Clear Cache & Data',
95
+ accelerator: 'CmdOrCtrl+Shift+R',
96
+ click: async () => {
97
+ const ses = session.defaultSession;
98
+ await ses.clearCache();
99
+ await ses.clearStorageData({
100
+ storages: [
101
+ 'cookies', 'filesystem', 'indexdb', 'localstorage',
102
+ 'shadercache', 'websql', 'serviceworkers', 'cachestorage'
103
+ ]
104
+ });
105
+ if (win) win.webContents.send('reload-webview');
106
+ }
107
+ },
108
+ { type: 'separator' },
109
+ {
110
+ label: 'Toggle DevTools',
111
+ accelerator: 'CmdOrCtrl+Shift+I',
112
+ click: () => {
113
+ if (win) win.webContents.toggleDevTools();
114
+ }
115
+ }
116
+ ]
117
+ }
118
+ ];
119
+
120
+ const menu = Menu.buildFromTemplate(template);
121
+ Menu.setApplicationMenu(menu);
122
+ }
123
+
124
+ // Resolve initial URL: CLI arg > stored URL > empty (prompt)
125
+ function getInitialUrl() {
126
+ const cliUrl = process.env.HANDSET_URL;
127
+ if (cliUrl) {
128
+ let url = cliUrl.trim();
129
+ if (!/^https?:\/\//i.test(url)) {
130
+ url = url.includes('localhost') ? `http://${url}` : `https://${url}`;
131
+ }
132
+ store.set('url', url);
133
+ return url;
134
+ }
135
+ return store.get('url');
136
+ }
137
+
138
+ // IPC handlers
139
+ ipcMain.handle('get-current-url', () => {
140
+ return getInitialUrl();
141
+ });
142
+
143
+ ipcMain.handle('set-url', (_event, url) => {
144
+ store.set('url', url);
145
+ return true;
146
+ });
147
+
148
+ ipcMain.handle('clear-all-data', async () => {
149
+ const ses = session.defaultSession;
150
+ await ses.clearCache();
151
+ await ses.clearStorageData({
152
+ storages: [
153
+ 'cookies', 'filesystem', 'indexdb', 'localstorage',
154
+ 'shadercache', 'websql', 'serviceworkers', 'cachestorage'
155
+ ]
156
+ });
157
+ return true;
158
+ });
159
+
160
+ ipcMain.handle('open-external', (_event, url) => {
161
+ shell.openExternal(url);
162
+ });
163
+
164
+ // App lifecycle
165
+ app.whenReady().then(async () => {
166
+ await initStore();
167
+ session.defaultSession.setUserAgent(MOBILE_UA);
168
+ createWindow();
169
+ });
170
+
171
+ app.on('window-all-closed', () => {
172
+ app.quit();
173
+ });
174
+
175
+ app.on('activate', () => {
176
+ if (BrowserWindow.getAllWindows().length === 0) {
177
+ createWindow();
178
+ }
179
+ });
package/src/preload.js ADDED
@@ -0,0 +1,15 @@
1
+ const { contextBridge, ipcRenderer } = require('electron');
2
+
3
+ contextBridge.exposeInMainWorld('demoAPI', {
4
+ getCurrentUrl: () => ipcRenderer.invoke('get-current-url'),
5
+ setUrl: (url) => ipcRenderer.invoke('set-url', url),
6
+ clearAllData: () => ipcRenderer.invoke('clear-all-data'),
7
+ openExternal: (url) => ipcRenderer.invoke('open-external', url),
8
+
9
+ onShowUrlPrompt: (callback) => {
10
+ ipcRenderer.on('show-url-prompt', () => callback());
11
+ },
12
+ onReloadWebview: (callback) => {
13
+ ipcRenderer.on('reload-webview', () => callback());
14
+ }
15
+ });
@@ -0,0 +1,70 @@
1
+ const webview = document.getElementById('webview');
2
+ const overlay = document.getElementById('url-overlay');
3
+ const urlInput = document.getElementById('url-input');
4
+ const okBtn = document.getElementById('url-ok');
5
+ const cancelBtn = document.getElementById('url-cancel');
6
+
7
+ let currentUrl = '';
8
+
9
+ // Initialize: show URL prompt if no stored URL, otherwise load it
10
+ window.addEventListener('DOMContentLoaded', async () => {
11
+ currentUrl = await window.demoAPI.getCurrentUrl();
12
+ if (currentUrl) {
13
+ webview.src = currentUrl;
14
+ } else {
15
+ overlay.classList.remove('hidden');
16
+ urlInput.focus();
17
+ }
18
+ });
19
+
20
+ // Menu: Change URL
21
+ window.demoAPI.onShowUrlPrompt(() => {
22
+ urlInput.value = currentUrl;
23
+ overlay.classList.remove('hidden');
24
+ urlInput.select();
25
+ urlInput.focus();
26
+ });
27
+
28
+ // Menu: Reload
29
+ window.demoAPI.onReloadWebview(() => {
30
+ webview.reload();
31
+ });
32
+
33
+ // URL overlay: OK
34
+ function submitUrl() {
35
+ let url = urlInput.value.trim();
36
+ if (!url) return;
37
+
38
+ // Add protocol if missing
39
+ if (!/^https?:\/\//i.test(url)) {
40
+ url = url.includes('localhost') ? `http://${url}` : `https://${url}`;
41
+ }
42
+
43
+ currentUrl = url;
44
+ webview.src = url;
45
+ window.demoAPI.setUrl(url);
46
+ overlay.classList.add('hidden');
47
+ }
48
+
49
+ okBtn.addEventListener('click', submitUrl);
50
+
51
+ urlInput.addEventListener('keydown', (e) => {
52
+ if (e.key === 'Enter') submitUrl();
53
+ if (e.key === 'Escape') overlay.classList.add('hidden');
54
+ });
55
+
56
+ // URL overlay: Cancel
57
+ cancelBtn.addEventListener('click', () => {
58
+ overlay.classList.add('hidden');
59
+ });
60
+
61
+ // Close overlay on backdrop click
62
+ overlay.addEventListener('click', (e) => {
63
+ if (e.target === overlay) overlay.classList.add('hidden');
64
+ });
65
+
66
+ // Open external links in system browser
67
+ webview.addEventListener('new-window', (e) => {
68
+ e.preventDefault();
69
+ window.demoAPI.openExternal(e.url);
70
+ });
package/src/styles.css ADDED
@@ -0,0 +1,109 @@
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ html, body {
8
+ width: 100%;
9
+ height: 100%;
10
+ overflow: hidden;
11
+ background: #000;
12
+ }
13
+
14
+ #drag-region {
15
+ position: fixed;
16
+ top: 0;
17
+ left: 33.3333%;
18
+ width: 33.3333%;
19
+ height: 50px;
20
+ -webkit-app-region: drag;
21
+ z-index: 100;
22
+ }
23
+
24
+ #webview {
25
+ width: 100%;
26
+ height: 100%;
27
+ }
28
+
29
+ /* URL input overlay */
30
+ .overlay {
31
+ position: fixed;
32
+ top: 0;
33
+ left: 0;
34
+ width: 100%;
35
+ height: 100%;
36
+ background: rgba(0, 0, 0, 0.6);
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ z-index: 1000;
41
+ }
42
+
43
+ .overlay.hidden {
44
+ display: none;
45
+ }
46
+
47
+ .overlay-box {
48
+ background: #1e1e1e;
49
+ border: 1px solid #444;
50
+ border-radius: 8px;
51
+ padding: 20px;
52
+ width: 400px;
53
+ max-width: 90%;
54
+ }
55
+
56
+ .overlay-box label {
57
+ display: block;
58
+ color: #ccc;
59
+ font-family: -apple-system, BlinkMacSystemFont, sans-serif;
60
+ font-size: 13px;
61
+ margin-bottom: 8px;
62
+ }
63
+
64
+ .overlay-box input {
65
+ width: 100%;
66
+ padding: 8px 10px;
67
+ font-size: 14px;
68
+ font-family: -apple-system, BlinkMacSystemFont, monospace;
69
+ background: #2a2a2a;
70
+ border: 1px solid #555;
71
+ border-radius: 4px;
72
+ color: #fff;
73
+ outline: none;
74
+ }
75
+
76
+ .overlay-box input:focus {
77
+ border-color: #6bf;
78
+ }
79
+
80
+ .overlay-buttons {
81
+ display: flex;
82
+ justify-content: flex-end;
83
+ gap: 8px;
84
+ margin-top: 14px;
85
+ }
86
+
87
+ .overlay-buttons button {
88
+ padding: 6px 16px;
89
+ font-size: 13px;
90
+ font-family: -apple-system, BlinkMacSystemFont, sans-serif;
91
+ border: 1px solid #555;
92
+ border-radius: 4px;
93
+ cursor: pointer;
94
+ background: #333;
95
+ color: #fff;
96
+ }
97
+
98
+ .overlay-buttons button:hover {
99
+ background: #444;
100
+ }
101
+
102
+ #url-ok {
103
+ background: #2563eb;
104
+ border-color: #2563eb;
105
+ }
106
+
107
+ #url-ok:hover {
108
+ background: #1d4ed8;
109
+ }