@holochain/hc-spin 0.200.6 → 0.200.7
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/dist/main/index.js +21 -7
- package/package.json +1 -1
- package/src/main/index.ts +5 -5
- package/src/main/validateArgs.ts +3 -0
- package/src/main/windows.ts +14 -1
package/dist/main/index.js
CHANGED
|
@@ -61,7 +61,7 @@ function nanoid(size = 21) {
|
|
|
61
61
|
}
|
|
62
62
|
return id;
|
|
63
63
|
}
|
|
64
|
-
const createHappWindow = async (uiSource, happOrWebhappPath, appId, agentNum, appPort, appDataRootDir) => {
|
|
64
|
+
const createHappWindow = async (uiSource, happOrWebhappPath, appId, agentNum, appPort, appDataRootDir, openDevtools) => {
|
|
65
65
|
if (!appPort)
|
|
66
66
|
throw new Error("App port not defined.");
|
|
67
67
|
const partition = `persist:${agentNum}:${appId}`;
|
|
@@ -127,7 +127,19 @@ electron.contextBridge.exposeInMainWorld("__HC_LAUNCHER_ENV__", {
|
|
|
127
127
|
happWindow.on("page-title-updated", (evt) => {
|
|
128
128
|
evt.preventDefault();
|
|
129
129
|
});
|
|
130
|
-
|
|
130
|
+
if (openDevtools)
|
|
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
|
+
});
|
|
131
143
|
if (uiSource.type === "port") {
|
|
132
144
|
try {
|
|
133
145
|
await electron.net.fetch(`http://127.0.0.1:${uiSource.port}/index.html`);
|
|
@@ -11739,12 +11751,13 @@ function validateCliArgs(cliArgs, cliOpts, appDataRootDir) {
|
|
|
11739
11751
|
uiSource: cliOpts.uiPath ? { type: "path", path: cliOpts.uiPath } : cliOpts.uiPort ? { type: "port", port: cliOpts.uiPort } : { type: "path", path: path.join(appDataRootDir, "apps", appId, "ui") },
|
|
11740
11752
|
singalingUrl: cliOpts.signalingUrl,
|
|
11741
11753
|
bootstrapUrl: cliOpts.bootstrapUrl,
|
|
11742
|
-
happOrWebhappPath: isHapp ? { type: "happ", path: happOrWebhappPath } : { type: "webhapp", path: happOrWebhappPath }
|
|
11754
|
+
happOrWebhappPath: isHapp ? { type: "happ", path: happOrWebhappPath } : { type: "webhapp", path: happOrWebhappPath },
|
|
11755
|
+
openDevtools: cliOpts.openDevtools ? true : false
|
|
11743
11756
|
};
|
|
11744
11757
|
}
|
|
11745
11758
|
const rustUtils = require("@holochain/hc-spin-rust-utils");
|
|
11746
11759
|
const cli = new commander.Command();
|
|
11747
|
-
cli.name("hc-spin").description("CLI to run Holochain aps during development.").version(`0.200.
|
|
11760
|
+
cli.name("hc-spin").description("CLI to run Holochain aps during development.").version(`0.200.7 (for holochain 0.2.x)`).argument(
|
|
11748
11761
|
"<path>",
|
|
11749
11762
|
"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"
|
|
11750
11763
|
).option(
|
|
@@ -11763,7 +11776,7 @@ cli.name("hc-spin").description("CLI to run Holochain aps during development.").
|
|
|
11763
11776
|
).option(
|
|
11764
11777
|
"--signaling-url <url>",
|
|
11765
11778
|
"Url of the signaling server to use. By default, hc spin spins up a local development signaling server for you but this argument allows you to specify a custom one."
|
|
11766
|
-
);
|
|
11779
|
+
).option("--open-devtools", "Automatically open the devtools on startup.");
|
|
11767
11780
|
cli.parse();
|
|
11768
11781
|
const rl = require("readline").createInterface({
|
|
11769
11782
|
input: process.stdin,
|
|
@@ -11954,7 +11967,7 @@ electron.app.whenReady().then(async () => {
|
|
|
11954
11967
|
}
|
|
11955
11968
|
});
|
|
11956
11969
|
SANDBOX_PROCESSES.push(sandboxHandle);
|
|
11957
|
-
for (var i = 0; i <
|
|
11970
|
+
for (var i = 0; i < CLI_OPTS.numAgents; i++) {
|
|
11958
11971
|
const zomeCallSigner = await rustUtils.ZomeCallSigner.connect(lairUrls[i], "pass");
|
|
11959
11972
|
const appPort = portsInfo[i].app_ports[0];
|
|
11960
11973
|
const appWs = await AppWebsocket.connect(new URL(`ws://127.0.0.1:${appPort}`));
|
|
@@ -11965,7 +11978,8 @@ electron.app.whenReady().then(async () => {
|
|
|
11965
11978
|
CLI_OPTS.appId,
|
|
11966
11979
|
i + 1,
|
|
11967
11980
|
appPort,
|
|
11968
|
-
DATA_ROOT_DIR
|
|
11981
|
+
DATA_ROOT_DIR,
|
|
11982
|
+
CLI_OPTS.openDevtools
|
|
11969
11983
|
);
|
|
11970
11984
|
WINDOW_INFO_MAP[happWindow.webContents.id] = {
|
|
11971
11985
|
agentPubKey: appInfo.agent_pub_key,
|
package/package.json
CHANGED
package/src/main/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ const cli = new Command();
|
|
|
27
27
|
cli
|
|
28
28
|
.name('hc-spin')
|
|
29
29
|
.description('CLI to run Holochain aps during development.')
|
|
30
|
-
.version(`0.200.
|
|
30
|
+
.version(`0.200.7 (for holochain 0.2.x)`)
|
|
31
31
|
.argument(
|
|
32
32
|
'<path>',
|
|
33
33
|
'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',
|
|
@@ -55,7 +55,8 @@ cli
|
|
|
55
55
|
.option(
|
|
56
56
|
'--signaling-url <url>',
|
|
57
57
|
'Url of the signaling server to use. By default, hc spin spins up a local development signaling server for you but this argument allows you to specify a custom one.',
|
|
58
|
-
)
|
|
58
|
+
)
|
|
59
|
+
.option('--open-devtools', 'Automatically open the devtools on startup.');
|
|
59
60
|
|
|
60
61
|
cli.parse();
|
|
61
62
|
// console.log('Got CLI opts: ', cli.opts());
|
|
@@ -317,11 +318,9 @@ app.whenReady().then(async () => {
|
|
|
317
318
|
|
|
318
319
|
SANDBOX_PROCESSES.push(sandboxHandle);
|
|
319
320
|
|
|
320
|
-
// console.log('Got CLI_OPTS: ', CLI_OPTS);
|
|
321
|
-
|
|
322
321
|
// open browser window for each sandbox
|
|
323
322
|
//
|
|
324
|
-
for (var i = 0; i <
|
|
323
|
+
for (var i = 0; i < CLI_OPTS.numAgents; i++) {
|
|
325
324
|
const zomeCallSigner = await rustUtils.ZomeCallSigner.connect(lairUrls[i], 'pass');
|
|
326
325
|
|
|
327
326
|
const appPort = portsInfo[i].app_ports[0];
|
|
@@ -334,6 +333,7 @@ app.whenReady().then(async () => {
|
|
|
334
333
|
i + 1,
|
|
335
334
|
appPort,
|
|
336
335
|
DATA_ROOT_DIR,
|
|
336
|
+
CLI_OPTS.openDevtools,
|
|
337
337
|
);
|
|
338
338
|
WINDOW_INFO_MAP[happWindow.webContents.id] = {
|
|
339
339
|
agentPubKey: appInfo.agent_pub_key,
|
package/src/main/validateArgs.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type CliOpts = {
|
|
|
11
11
|
uiPort?: number;
|
|
12
12
|
signalingUrl?: string;
|
|
13
13
|
bootstrapUrl?: string;
|
|
14
|
+
openDevtools?: boolean;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export type CliOptsValidated = {
|
|
@@ -22,6 +23,7 @@ export type CliOptsValidated = {
|
|
|
22
23
|
singalingUrl: string | undefined;
|
|
23
24
|
bootstrapUrl: string | undefined;
|
|
24
25
|
happOrWebhappPath: HappOrWebhappPath;
|
|
26
|
+
openDevtools: boolean;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export type HappOrWebhappPath = {
|
|
@@ -86,5 +88,6 @@ export function validateCliArgs(
|
|
|
86
88
|
happOrWebhappPath: isHapp
|
|
87
89
|
? { type: 'happ', path: happOrWebhappPath }
|
|
88
90
|
: { type: 'webhapp', path: happOrWebhappPath },
|
|
91
|
+
openDevtools: cliOpts.openDevtools ? true : false,
|
|
89
92
|
};
|
|
90
93
|
}
|
package/src/main/windows.ts
CHANGED
|
@@ -23,6 +23,7 @@ export const createHappWindow = async (
|
|
|
23
23
|
agentNum: number,
|
|
24
24
|
appPort: number,
|
|
25
25
|
appDataRootDir: string,
|
|
26
|
+
openDevtools: boolean,
|
|
26
27
|
): Promise<BrowserWindow> => {
|
|
27
28
|
// TODO create mapping between installed-app-id's and window ids
|
|
28
29
|
if (!appPort) throw new Error('App port not defined.');
|
|
@@ -104,7 +105,19 @@ electron.contextBridge.exposeInMainWorld("__HC_LAUNCHER_ENV__", {
|
|
|
104
105
|
evt.preventDefault();
|
|
105
106
|
});
|
|
106
107
|
|
|
107
|
-
happWindow.webContents.openDevTools();
|
|
108
|
+
if (openDevtools) happWindow.webContents.openDevTools();
|
|
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
|
+
});
|
|
108
121
|
|
|
109
122
|
if (uiSource.type === 'port') {
|
|
110
123
|
try {
|