@holochain/hc-spin 0.200.10 → 0.200.12

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 CHANGED
@@ -4,7 +4,11 @@ const path = require('path');
4
4
  const fs = require('fs');
5
5
 
6
6
  let electronBinary;
7
- let pathStr = '../node_modules/.bin/electron';
7
+ let pathStr =
8
+ process.platform === 'win32'
9
+ ? '../node_modules/electron/dist/electron.exe'
10
+ : '../node_modules/.bin/electron';
11
+
8
12
  // recursively look for electron binary in node_modules folder
9
13
  for (let i = 0; i < 7; i++) {
10
14
  const maybeElectronBinary = path.resolve(__dirname, pathStr);
package/dist/cli.js CHANGED
@@ -4,7 +4,11 @@ const path = require('path');
4
4
  const fs = require('fs');
5
5
 
6
6
  let electronBinary;
7
- let pathStr = '../node_modules/.bin/electron';
7
+ let pathStr =
8
+ process.platform === 'win32'
9
+ ? '../node_modules/electron/dist/electron.exe'
10
+ : '../node_modules/.bin/electron';
11
+
8
12
  // recursively look for electron binary in node_modules folder
9
13
  for (let i = 0; i < 7; i++) {
10
14
  const maybeElectronBinary = path.resolve(__dirname, pathStr);
@@ -6314,8 +6314,10 @@ const randomByteArray = async (length) => {
6314
6314
  };
6315
6315
  const getNonceExpiration = () => (Date.now() + 5 * 60 * 1e3) * 1e3;
6316
6316
  const __HC_LAUNCHER_ENV__ = "__HC_LAUNCHER_ENV__";
6317
+ const __HC_ZOME_CALL_SIGNER__ = "__HC_ZOME_CALL_SIGNER__";
6317
6318
  const isLauncher = () => globalThis.window && __HC_LAUNCHER_ENV__ in globalThis.window;
6318
6319
  const getLauncherEnvironment = () => isLauncher() ? globalThis.window[__HC_LAUNCHER_ENV__] : void 0;
6320
+ const getHostZomeCallSigner = () => globalThis.window && globalThis.window[__HC_ZOME_CALL_SIGNER__];
6319
6321
  const signZomeCallTauri = async (request) => {
6320
6322
  const zomeCallUnsigned = {
6321
6323
  provenance: Array.from(request.provenance),
@@ -10849,7 +10851,7 @@ class AppWebsocket extends Emittery {
10849
10851
  static async connect(url2, defaultTimeout) {
10850
10852
  const env = getLauncherEnvironment();
10851
10853
  if (env?.APP_INTERFACE_PORT) {
10852
- url2 = new URL(`ws://127.0.0.1:${env.APP_INTERFACE_PORT}`);
10854
+ url2 = new URL(`ws://localhost:${env.APP_INTERFACE_PORT}`);
10853
10855
  }
10854
10856
  const wsClient = await WsClient.connect(url2);
10855
10857
  const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env?.INSTALLED_APP_ID);
@@ -10903,13 +10905,19 @@ const callZomeTransform = {
10903
10905
  if ("signature" in request) {
10904
10906
  return request;
10905
10907
  }
10906
- const env = getLauncherEnvironment();
10907
- if (!env) {
10908
- return signZomeCall(request);
10909
- } else if (env.FRAMEWORK === "electron") {
10910
- return signZomeCallElectron(request);
10908
+ const hostSigner = getHostZomeCallSigner();
10909
+ if (hostSigner) {
10910
+ return hostSigner.signZomeCall(request);
10911
+ } else {
10912
+ const env = getLauncherEnvironment();
10913
+ if (!env) {
10914
+ return signZomeCall(request);
10915
+ }
10916
+ if (env.FRAMEWORK === "electron") {
10917
+ return signZomeCallElectron(request);
10918
+ }
10919
+ return signZomeCallTauri(request);
10911
10920
  }
10912
- return signZomeCallTauri(request);
10913
10921
  },
10914
10922
  output: (response) => msgpack.decode(response)
10915
10923
  };
@@ -11794,8 +11802,10 @@ const menu = electron.Menu.buildFromTemplate([
11794
11802
  }
11795
11803
  ]);
11796
11804
  const rustUtils = require("@holochain/hc-spin-rust-utils");
11805
+ const cliPackageJsonPath = path.resolve(path.join(electron.app.getAppPath(), "../../package.json"));
11806
+ const cliPackageJson = require(cliPackageJsonPath);
11797
11807
  const cli = new commander.Command();
11798
- cli.name("hc-spin").description("CLI to run Holochain aps during development.").version(`0.200.10 (for holochain 0.2.x)`).argument(
11808
+ cli.name("hc-spin").description("CLI to run Holochain aps during development.").version(`${cliPackageJson.version} (holochain ${cliPackageJson.holochainVersion})`).argument(
11799
11809
  "<path>",
11800
11810
  "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"
11801
11811
  ).option(
@@ -12009,8 +12019,10 @@ electron.app.whenReady().then(async () => {
12009
12019
  for (var i = 0; i < CLI_OPTS.numAgents; i++) {
12010
12020
  const zomeCallSigner = await rustUtils.ZomeCallSigner.connect(lairUrls[i], "pass");
12011
12021
  const appPort = portsInfo[i].app_ports[0];
12012
- const appWs = await AppWebsocket.connect(new URL(`ws://127.0.0.1:${appPort}`));
12022
+ const appWs = await AppWebsocket.connect(new URL(`ws://localhost:${appPort}`));
12013
12023
  const appInfo = await appWs.appInfo({ installed_app_id: CLI_OPTS.appId });
12024
+ if (!appInfo)
12025
+ throw new Error("AppInfo undefined.");
12014
12026
  const happWindow = await createHappWindow(
12015
12027
  CLI_OPTS.uiSource,
12016
12028
  CLI_OPTS.happOrWebhappPath,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@holochain/hc-spin",
3
- "version": "0.200.10",
3
+ "version": "0.200.12",
4
+ "holochainVersion": "0.2.x",
4
5
  "description": "CLI to run Holochain aps during development.",
5
6
  "author": "matthme",
6
7
  "homepage": "https://developer.holochain.org",
@@ -34,7 +35,7 @@
34
35
  "dependencies": {
35
36
  "@electron-toolkit/preload": "^3.0.0",
36
37
  "@electron-toolkit/utils": "^3.0.0",
37
- "@holochain/client": "^0.16.3",
38
+ "@holochain/client": "^0.16.11",
38
39
  "@holochain/hc-spin-rust-utils": "^0.200.3",
39
40
  "@msgpack/msgpack": "^2.8.0",
40
41
  "commander": "11.1.0",
package/src/main/index.ts CHANGED
@@ -23,12 +23,15 @@ import { menu } from './menu';
23
23
 
24
24
  const rustUtils = require('@holochain/hc-spin-rust-utils');
25
25
 
26
+ const cliPackageJsonPath = path.resolve(path.join(app.getAppPath(), '../../package.json'));
27
+ const cliPackageJson = require(cliPackageJsonPath);
28
+
26
29
  const cli = new Command();
27
30
 
28
31
  cli
29
32
  .name('hc-spin')
30
33
  .description('CLI to run Holochain aps during development.')
31
- .version(`0.200.10 (for holochain 0.2.x)`)
34
+ .version(`${cliPackageJson.version} (holochain ${cliPackageJson.holochainVersion})`)
32
35
  .argument(
33
36
  '<path>',
34
37
  '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',
@@ -327,8 +330,9 @@ app.whenReady().then(async () => {
327
330
  const zomeCallSigner = await rustUtils.ZomeCallSigner.connect(lairUrls[i], 'pass');
328
331
 
329
332
  const appPort = portsInfo[i].app_ports[0];
330
- const appWs = await AppWebsocket.connect(new URL(`ws://127.0.0.1:${appPort}`));
333
+ const appWs = await AppWebsocket.connect(new URL(`ws://localhost:${appPort}`));
331
334
  const appInfo = await appWs.appInfo({ installed_app_id: CLI_OPTS.appId });
335
+ if (!appInfo) throw new Error('AppInfo undefined.');
332
336
  const happWindow = await createHappWindow(
333
337
  CLI_OPTS.uiSource,
334
338
  CLI_OPTS.happOrWebhappPath,