@holochain/hc-spin 0.300.2 → 0.400.0-dev.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.
- package/cli/cli.js +17 -10
- package/dist/cli.js +17 -10
- package/dist/main/index.js +9993 -8750
- package/package.json +4 -3
- package/src/main/index.ts +29 -3
- package/src/main/windows.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/hc-spin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.400.0-dev.1",
|
|
4
|
+
"holochainVersion": "0.4.0-dev.1",
|
|
4
5
|
"description": "CLI to run Holochain aps during development.",
|
|
5
6
|
"author": "matthme",
|
|
6
7
|
"homepage": "https://developer.holochain.org",
|
|
@@ -34,9 +35,10 @@
|
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@electron-toolkit/preload": "^3.0.0",
|
|
36
37
|
"@electron-toolkit/utils": "^3.0.0",
|
|
37
|
-
"@holochain/client": "
|
|
38
|
+
"@holochain/client": "0.18.0-dev.0",
|
|
38
39
|
"@holochain/hc-spin-rust-utils": "^0.300.1",
|
|
39
40
|
"@msgpack/msgpack": "^2.8.0",
|
|
41
|
+
"bufferutil": "4.0.8",
|
|
40
42
|
"commander": "11.1.0",
|
|
41
43
|
"electron": "^28.1.1",
|
|
42
44
|
"electron-context-menu": "3.6.1",
|
|
@@ -49,7 +51,6 @@
|
|
|
49
51
|
"@electron-toolkit/eslint-config-ts": "^1.0.1",
|
|
50
52
|
"@electron-toolkit/tsconfig": "^1.0.1",
|
|
51
53
|
"@types/node": "^18.19.5",
|
|
52
|
-
"bufferutil": "4.0.8",
|
|
53
54
|
"electron-builder": "^24.9.1",
|
|
54
55
|
"electron-vite": "https://github.com/matthme/electron-vite.git#forward-cli-args-dist",
|
|
55
56
|
"eslint": "^8.56.0",
|
package/src/main/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ZomeCallNapi, ZomeCallSigner, ZomeCallUnsignedNapi } from '@holochain/h
|
|
|
10
10
|
import { createHappWindow } from './windows';
|
|
11
11
|
import getPort from 'get-port';
|
|
12
12
|
import {
|
|
13
|
+
AdminWebsocket,
|
|
13
14
|
AgentPubKey,
|
|
14
15
|
AppWebsocket,
|
|
15
16
|
CallZomeRequest,
|
|
@@ -23,12 +24,15 @@ import { menu } from './menu';
|
|
|
23
24
|
|
|
24
25
|
const rustUtils = require('@holochain/hc-spin-rust-utils');
|
|
25
26
|
|
|
27
|
+
const cliPackageJsonPath = path.resolve(path.join(app.getAppPath(), '../../package.json'));
|
|
28
|
+
const cliPackageJson = require(cliPackageJsonPath);
|
|
29
|
+
|
|
26
30
|
const cli = new Command();
|
|
27
31
|
|
|
28
32
|
cli
|
|
29
33
|
.name('hc-spin')
|
|
30
34
|
.description('CLI to run Holochain aps during development.')
|
|
31
|
-
.version(
|
|
35
|
+
.version(`${cliPackageJson.version} (built for holochain ${cliPackageJson.holochainVersion})`)
|
|
32
36
|
.argument(
|
|
33
37
|
'<path>',
|
|
34
38
|
'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',
|
|
@@ -326,15 +330,37 @@ app.whenReady().then(async () => {
|
|
|
326
330
|
for (var i = 0; i < CLI_OPTS.numAgents; i++) {
|
|
327
331
|
const zomeCallSigner = await rustUtils.ZomeCallSigner.connect(lairUrls[i], 'pass');
|
|
328
332
|
|
|
333
|
+
const adminPort = portsInfo[i].admin_port;
|
|
334
|
+
const adminWs = await AdminWebsocket.connect({
|
|
335
|
+
url: new URL(`ws://localhost:${adminPort}`),
|
|
336
|
+
wsClientOptions: {
|
|
337
|
+
origin: 'hc-spin',
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const appAuthTokenResponse = await adminWs.issueAppAuthenticationToken({
|
|
342
|
+
installed_app_id: CLI_OPTS.appId,
|
|
343
|
+
single_use: false,
|
|
344
|
+
expiry_seconds: 999999,
|
|
345
|
+
});
|
|
346
|
+
|
|
329
347
|
const appPort = portsInfo[i].app_ports[0];
|
|
330
|
-
const appWs = await AppWebsocket.connect(
|
|
331
|
-
|
|
348
|
+
const appWs = await AppWebsocket.connect({
|
|
349
|
+
url: new URL(`ws://localhost:${appPort}`),
|
|
350
|
+
wsClientOptions: {
|
|
351
|
+
origin: 'hc-spin',
|
|
352
|
+
},
|
|
353
|
+
token: appAuthTokenResponse.token,
|
|
354
|
+
});
|
|
355
|
+
const appInfo = await appWs.appInfo();
|
|
356
|
+
if (!appInfo) throw new Error('AppInfo is null.');
|
|
332
357
|
const happWindow = await createHappWindow(
|
|
333
358
|
CLI_OPTS.uiSource,
|
|
334
359
|
CLI_OPTS.happOrWebhappPath,
|
|
335
360
|
CLI_OPTS.appId,
|
|
336
361
|
i + 1,
|
|
337
362
|
appPort,
|
|
363
|
+
appAuthTokenResponse.token,
|
|
338
364
|
DATA_ROOT_DIR,
|
|
339
365
|
CLI_OPTS.openDevtools,
|
|
340
366
|
);
|
package/src/main/windows.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import url from 'url';
|
|
4
|
-
import { InstalledAppId } from '@holochain/client';
|
|
4
|
+
import { AppAuthenticationToken, InstalledAppId } from '@holochain/client';
|
|
5
5
|
import { BrowserWindow, NativeImage, nativeImage, net, session, shell } from 'electron';
|
|
6
6
|
import { is } from '@electron-toolkit/utils';
|
|
7
7
|
import { HappOrWebhappPath } from './validateArgs';
|
|
@@ -22,6 +22,7 @@ export const createHappWindow = async (
|
|
|
22
22
|
appId: InstalledAppId,
|
|
23
23
|
agentNum: number,
|
|
24
24
|
appPort: number,
|
|
25
|
+
appAuthToken: AppAuthenticationToken,
|
|
25
26
|
appDataRootDir: string,
|
|
26
27
|
openDevtools: boolean,
|
|
27
28
|
): Promise<BrowserWindow> => {
|
|
@@ -47,7 +48,7 @@ export const createHappWindow = async (
|
|
|
47
48
|
electron.contextBridge.exposeInMainWorld("__HC_LAUNCHER_ENV__", {
|
|
48
49
|
APP_INTERFACE_PORT: ${appPort},
|
|
49
50
|
INSTALLED_APP_ID: "${appId}",
|
|
50
|
-
|
|
51
|
+
APP_INTERFACE_TOKEN: [${appAuthToken}],
|
|
51
52
|
});
|
|
52
53
|
`;
|
|
53
54
|
|