@holochain/hc-spin 0.200.7 → 0.200.8

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.
@@ -129,17 +129,6 @@ electron.contextBridge.exposeInMainWorld("__HC_LAUNCHER_ENV__", {
129
129
  });
130
130
  if (openDevtools)
131
131
  happWindow.webContents.openDevTools();
132
- happWindow.webContents.on("before-input-event", (e, input) => {
133
- if (input.code === "F12") {
134
- e.preventDefault();
135
- if (happWindow.webContents.isDevToolsOpened()) {
136
- happWindow.webContents.closeDevTools();
137
- } else {
138
- happWindow.webContents.openDevTools();
139
- happWindow.webContents.focus();
140
- }
141
- }
142
- });
143
132
  if (uiSource.type === "port") {
144
133
  try {
145
134
  await electron.net.fetch(`http://127.0.0.1:${uiSource.port}/index.html`);
@@ -11755,9 +11744,58 @@ function validateCliArgs(cliArgs, cliOpts, appDataRootDir) {
11755
11744
  openDevtools: cliOpts.openDevtools ? true : false
11756
11745
  };
11757
11746
  }
11747
+ const menu = electron.Menu.buildFromTemplate([
11748
+ {
11749
+ label: "Options",
11750
+ submenu: [
11751
+ {
11752
+ label: "toggle dev tools (F12)",
11753
+ click: () => {
11754
+ const focusedWindow = electron.BrowserWindow.getFocusedWindow();
11755
+ if (focusedWindow) {
11756
+ focusedWindow.webContents.toggleDevTools();
11757
+ }
11758
+ },
11759
+ accelerator: "F12"
11760
+ },
11761
+ {
11762
+ label: "toggle dev tools (Ctrl+Shift+I)",
11763
+ click: () => {
11764
+ const focusedWindow = electron.BrowserWindow.getFocusedWindow();
11765
+ if (focusedWindow) {
11766
+ focusedWindow.webContents.toggleDevTools();
11767
+ }
11768
+ },
11769
+ visible: false,
11770
+ accelerator: "CommandOrControl+Shift+I"
11771
+ },
11772
+ {
11773
+ label: "Reload (F5)",
11774
+ click: () => {
11775
+ const focusedWindow = electron.BrowserWindow.getFocusedWindow();
11776
+ if (focusedWindow) {
11777
+ focusedWindow.webContents.reload();
11778
+ }
11779
+ },
11780
+ accelerator: "F5"
11781
+ },
11782
+ {
11783
+ label: "Reload (Ctrl+R)",
11784
+ click: () => {
11785
+ const focusedWindow = electron.BrowserWindow.getFocusedWindow();
11786
+ if (focusedWindow) {
11787
+ focusedWindow.webContents.reload();
11788
+ }
11789
+ },
11790
+ visible: false,
11791
+ accelerator: "CommandOrControl+R"
11792
+ }
11793
+ ]
11794
+ }
11795
+ ]);
11758
11796
  const rustUtils = require("@holochain/hc-spin-rust-utils");
11759
11797
  const cli = new commander.Command();
11760
- cli.name("hc-spin").description("CLI to run Holochain aps during development.").version(`0.200.7 (for holochain 0.2.x)`).argument(
11798
+ cli.name("hc-spin").description("CLI to run Holochain aps during development.").version(`0.200.8 (for holochain 0.2.x)`).argument(
11761
11799
  "<path>",
11762
11800
  "Path to .webhapp or .happ file to launch. If a .happ file is passed, either a UI path must be specified via --ui-path or a port pointing to a localhost server via --ui-port"
11763
11801
  ).option(
@@ -11799,6 +11837,7 @@ for (const folder of hcSpinFolders) {
11799
11837
  }
11800
11838
  const DATA_ROOT_DIR = path.join(electron.app.getPath("temp"), `hc-spin-${nanoid(8)}`);
11801
11839
  electron.app.setPath("userData", path.join(DATA_ROOT_DIR, "electron"));
11840
+ electron.Menu.setApplicationMenu(menu);
11802
11841
  const CLI_OPTS = validateCliArgs(cli.args, cli.opts(), DATA_ROOT_DIR);
11803
11842
  const SANDBOX_PROCESSES = [];
11804
11843
  const WINDOW_INFO_MAP = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/hc-spin",
3
- "version": "0.200.7",
3
+ "version": "0.200.8",
4
4
  "description": "CLI to run Holochain aps during development.",
5
5
  "author": "matthme",
6
6
  "homepage": "https://developer.holochain.org",
@@ -35,7 +35,7 @@
35
35
  "@electron-toolkit/preload": "^3.0.0",
36
36
  "@electron-toolkit/utils": "^3.0.0",
37
37
  "@holochain/client": "^0.16.3",
38
- "@holochain/hc-spin-rust-utils": "0.200.2",
38
+ "@holochain/hc-spin-rust-utils": "^0.200.3",
39
39
  "@msgpack/msgpack": "^2.8.0",
40
40
  "commander": "11.1.0",
41
41
  "electron": "^28.1.1",
package/src/main/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { app, IpcMainInvokeEvent, ipcMain, protocol } from 'electron';
1
+ import { app, IpcMainInvokeEvent, ipcMain, protocol, Menu } from 'electron';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { nanoid } from 'nanoid';
@@ -19,6 +19,7 @@ import {
19
19
  } from '@holochain/client';
20
20
  import { validateCliArgs } from './validateArgs';
21
21
  import { encode } from '@msgpack/msgpack';
22
+ import { menu } from './menu';
22
23
 
23
24
  const rustUtils = require('@holochain/hc-spin-rust-utils');
24
25
 
@@ -27,7 +28,7 @@ const cli = new Command();
27
28
  cli
28
29
  .name('hc-spin')
29
30
  .description('CLI to run Holochain aps during development.')
30
- .version(`0.200.7 (for holochain 0.2.x)`)
31
+ .version(`0.200.8 (for holochain 0.2.x)`)
31
32
  .argument(
32
33
  '<path>',
33
34
  'Path to .webhapp or .happ file to launch. If a .happ file is passed, either a UI path must be specified via --ui-path or a port pointing to a localhost server via --ui-port',
@@ -93,6 +94,8 @@ const DATA_ROOT_DIR = path.join(app.getPath('temp'), `hc-spin-${nanoid(8)}`);
93
94
 
94
95
  app.setPath('userData', path.join(DATA_ROOT_DIR, 'electron'));
95
96
 
97
+ Menu.setApplicationMenu(menu);
98
+
96
99
  const CLI_OPTS = validateCliArgs(cli.args, cli.opts(), DATA_ROOT_DIR);
97
100
 
98
101
  // const SANDBOX_DIRECTORIES: Array<string> = [];
@@ -0,0 +1,51 @@
1
+ import { BrowserWindow, Menu } from 'electron';
2
+
3
+ export const menu = Menu.buildFromTemplate([
4
+ {
5
+ label: 'Options',
6
+ submenu: [
7
+ {
8
+ label: 'toggle dev tools (F12)',
9
+ click: () => {
10
+ const focusedWindow = BrowserWindow.getFocusedWindow();
11
+ if (focusedWindow) {
12
+ focusedWindow.webContents.toggleDevTools();
13
+ }
14
+ },
15
+ accelerator: 'F12',
16
+ },
17
+ {
18
+ label: 'toggle dev tools (Ctrl+Shift+I)',
19
+ click: () => {
20
+ const focusedWindow = BrowserWindow.getFocusedWindow();
21
+ if (focusedWindow) {
22
+ focusedWindow.webContents.toggleDevTools();
23
+ }
24
+ },
25
+ visible: false,
26
+ accelerator: 'CommandOrControl+Shift+I',
27
+ },
28
+ {
29
+ label: 'Reload (F5)',
30
+ click: () => {
31
+ const focusedWindow = BrowserWindow.getFocusedWindow();
32
+ if (focusedWindow) {
33
+ focusedWindow.webContents.reload();
34
+ }
35
+ },
36
+ accelerator: 'F5',
37
+ },
38
+ {
39
+ label: 'Reload (Ctrl+R)',
40
+ click: () => {
41
+ const focusedWindow = BrowserWindow.getFocusedWindow();
42
+ if (focusedWindow) {
43
+ focusedWindow.webContents.reload();
44
+ }
45
+ },
46
+ visible: false,
47
+ accelerator: 'CommandOrControl+R',
48
+ },
49
+ ],
50
+ },
51
+ ]);
@@ -107,18 +107,6 @@ electron.contextBridge.exposeInMainWorld("__HC_LAUNCHER_ENV__", {
107
107
 
108
108
  if (openDevtools) happWindow.webContents.openDevTools();
109
109
 
110
- happWindow.webContents.on('before-input-event', (e, input) => {
111
- if (input.code === 'F12') {
112
- e.preventDefault();
113
- if (happWindow.webContents.isDevToolsOpened()) {
114
- happWindow.webContents.closeDevTools();
115
- } else {
116
- happWindow.webContents.openDevTools();
117
- happWindow.webContents.focus();
118
- }
119
- }
120
- });
121
-
122
110
  if (uiSource.type === 'port') {
123
111
  try {
124
112
  // Check whether dev server is responsive and index.html exists