handset 1.0.0 → 1.0.1

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.
Binary file
Binary file
package/bin/cli.js CHANGED
@@ -1,9 +1,42 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('child_process');
3
+ const { spawn, execSync } = require('child_process');
4
4
  const path = require('path');
5
- const electron = require('electron');
5
+ const fs = require('fs');
6
+
7
+ // On macOS, rename Electron.app to Handset.app and patch Info.plist
8
+ // so the dock and menu bar both show "Handset"
9
+ if (process.platform === 'darwin') {
10
+ const electronMod = path.join(__dirname, '..', 'node_modules', 'electron');
11
+ const distDir = path.join(electronMod, 'dist');
12
+ const electronApp = path.join(distDir, 'Electron.app');
13
+ const handsetApp = path.join(distDir, 'Handset.app');
14
+
15
+ try {
16
+ // Rename the .app bundle (no-op if already renamed)
17
+ if (fs.existsSync(electronApp)) {
18
+ fs.renameSync(electronApp, handsetApp);
19
+ fs.writeFileSync(path.join(electronMod, 'path.txt'), 'Handset.app/Contents/MacOS/Electron');
20
+ }
21
+
22
+ // Copy our icon into the app bundle
23
+ const icnsSource = path.join(__dirname, '..', 'assets', 'icon.icns');
24
+ const resourcesDir = path.join(handsetApp, 'Contents', 'Resources');
25
+ if (fs.existsSync(icnsSource)) {
26
+ fs.copyFileSync(icnsSource, path.join(resourcesDir, 'handset.icns'));
27
+ }
6
28
 
29
+ // Patch Info.plist — name + icon
30
+ const plistPath = path.join(handsetApp, 'Contents', 'Info.plist');
31
+ execSync(`plutil -replace CFBundleName -string "Handset" "${plistPath}"`, { stdio: 'ignore' });
32
+ execSync(`plutil -replace CFBundleDisplayName -string "Handset" "${plistPath}"`, { stdio: 'ignore' });
33
+ execSync(`plutil -replace CFBundleIconFile -string "handset.icns" "${plistPath}"`, { stdio: 'ignore' });
34
+ } catch (_) {
35
+ // Non-fatal — app still works, just shows "Electron" in dock
36
+ }
37
+ }
38
+
39
+ const electron = require('electron');
7
40
  const mainPath = path.join(__dirname, '..', 'src', 'main.js');
8
41
 
9
42
  // Pass optional URL argument to Electron via environment variable
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "handset",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A frameless mobile-viewport browser window for demos",
5
5
  "main": "src/main.js",
6
6
  "bin": {
7
7
  "handset": "./bin/cli.js"
8
8
  },
9
9
  "scripts": {
10
- "start": "electron ."
10
+ "start": "node bin/cli.js"
11
11
  },
12
- "keywords": ["electron", "mobile", "demo", "browser", "viewport", "handset"],
12
+ "keywords": [
13
+ "electron",
14
+ "mobile",
15
+ "demo",
16
+ "browser",
17
+ "viewport",
18
+ "handset"
19
+ ],
13
20
  "author": "Jordan Neill",
14
21
  "license": "MIT",
15
22
  "repository": {
@@ -26,6 +33,8 @@
26
33
  "files": [
27
34
  "bin/",
28
35
  "src/",
36
+ "assets/icon.png",
37
+ "assets/icon.icns",
29
38
  "README.md",
30
39
  "LICENSE"
31
40
  ],
package/src/main.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const { app, BrowserWindow, Menu, session, ipcMain, shell } = require('electron');
2
2
  const path = require('path');
3
3
 
4
+ const ICON_PATH = path.join(__dirname, '..', 'assets', 'icon.png');
5
+
4
6
  const MOBILE_UA =
5
7
  'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) ' +
6
8
  'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1';
@@ -25,6 +27,7 @@ function createWindow() {
25
27
  resizable: true,
26
28
  alwaysOnTop: true,
27
29
  backgroundColor: '#000000',
30
+ icon: ICON_PATH,
28
31
  webPreferences: {
29
32
  preload: path.join(__dirname, 'preload.js'),
30
33
  contextIsolation: true,
@@ -162,6 +165,8 @@ ipcMain.handle('open-external', (_event, url) => {
162
165
  });
163
166
 
164
167
  // App lifecycle
168
+ app.setName('Handset');
169
+
165
170
  app.whenReady().then(async () => {
166
171
  await initStore();
167
172
  session.defaultSession.setUserAgent(MOBILE_UA);