@holochain/hc-spin 0.400.0-dev.1 → 0.400.0-dev.3
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 +28 -13
- package/dist/cli.js +28 -13
- package/dist/main/index.js +8 -2
- package/package.json +4 -4
- package/scripts/replace-electron-version.js +11 -0
- package/src/main/index.ts +8 -2
package/cli/cli.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require('child_process');
|
|
2
|
+
const { spawn, spawnSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
6
|
let electronBinary = process.env.ELECTRON_BINARY;
|
|
7
7
|
|
|
8
8
|
if (!electronBinary) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (fs.existsSync(maybeElectronBinary)) {
|
|
18
|
-
electronBinary = maybeElectronBinary;
|
|
19
|
-
break;
|
|
9
|
+
// Check whether electron is installed globally and compare with the expected version
|
|
10
|
+
const electronHandleTemp = spawnSync('electron', ['--version']);
|
|
11
|
+
|
|
12
|
+
if (electronHandleTemp.stdout) {
|
|
13
|
+
if (!electronHandleTemp.stdout.toString().startsWith('v###REPLACE_AT_BUILD_TIME###')) {
|
|
14
|
+
console.warn(
|
|
15
|
+
'WARNING: Found a globally installed electron version but it does not match the version requirements of hc-spin (v29.x). The electron binary from node_modules will be used instead.',
|
|
16
|
+
);
|
|
20
17
|
} else {
|
|
21
|
-
|
|
18
|
+
electronBinary = 'electron';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!electronBinary) {
|
|
23
|
+
let pathStr =
|
|
24
|
+
process.platform === 'win32'
|
|
25
|
+
? '../node_modules/electron/dist/electron.exe'
|
|
26
|
+
: '../node_modules/.bin/electron';
|
|
27
|
+
|
|
28
|
+
// recursively look for electron binary in node_modules folder
|
|
29
|
+
for (let i = 0; i < 7; i++) {
|
|
30
|
+
const maybeElectronBinary = path.resolve(__dirname, pathStr);
|
|
31
|
+
if (fs.existsSync(maybeElectronBinary)) {
|
|
32
|
+
electronBinary = maybeElectronBinary;
|
|
33
|
+
break;
|
|
34
|
+
} else {
|
|
35
|
+
pathStr = '../' + pathStr;
|
|
36
|
+
}
|
|
22
37
|
}
|
|
23
38
|
}
|
|
24
39
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require('child_process');
|
|
2
|
+
const { spawn, spawnSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
6
|
let electronBinary = process.env.ELECTRON_BINARY;
|
|
7
7
|
|
|
8
8
|
if (!electronBinary) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (fs.existsSync(maybeElectronBinary)) {
|
|
18
|
-
electronBinary = maybeElectronBinary;
|
|
19
|
-
break;
|
|
9
|
+
// Check whether electron is installed globally and compare with the expected version
|
|
10
|
+
const electronHandleTemp = spawnSync('electron', ['--version']);
|
|
11
|
+
|
|
12
|
+
if (electronHandleTemp.stdout) {
|
|
13
|
+
if (!electronHandleTemp.stdout.toString().startsWith('v29.')) {
|
|
14
|
+
console.warn(
|
|
15
|
+
'WARNING: Found a globally installed electron version but it does not match the version requirements of hc-spin (v29.x). The electron binary from node_modules will be used instead.',
|
|
16
|
+
);
|
|
20
17
|
} else {
|
|
21
|
-
|
|
18
|
+
electronBinary = 'electron';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!electronBinary) {
|
|
23
|
+
let pathStr =
|
|
24
|
+
process.platform === 'win32'
|
|
25
|
+
? '../node_modules/electron/dist/electron.exe'
|
|
26
|
+
: '../node_modules/.bin/electron';
|
|
27
|
+
|
|
28
|
+
// recursively look for electron binary in node_modules folder
|
|
29
|
+
for (let i = 0; i < 7; i++) {
|
|
30
|
+
const maybeElectronBinary = path.resolve(__dirname, pathStr);
|
|
31
|
+
if (fs.existsSync(maybeElectronBinary)) {
|
|
32
|
+
electronBinary = maybeElectronBinary;
|
|
33
|
+
break;
|
|
34
|
+
} else {
|
|
35
|
+
pathStr = '../' + pathStr;
|
|
36
|
+
}
|
|
22
37
|
}
|
|
23
38
|
}
|
|
24
39
|
}
|
package/dist/main/index.js
CHANGED
|
@@ -13075,13 +13075,19 @@ const WINDOW_INFO_MAP = {};
|
|
|
13075
13075
|
electron.protocol.registerSchemesAsPrivileged([
|
|
13076
13076
|
{
|
|
13077
13077
|
scheme: "webhapp",
|
|
13078
|
-
privileges: { standard: true }
|
|
13078
|
+
privileges: { standard: true, secure: true, stream: true }
|
|
13079
13079
|
}
|
|
13080
13080
|
]);
|
|
13081
13081
|
contextMenu({
|
|
13082
13082
|
showSaveImageAs: true,
|
|
13083
13083
|
showSearchWithGoogle: false,
|
|
13084
|
-
showInspectElement: true
|
|
13084
|
+
showInspectElement: true,
|
|
13085
|
+
append: (_defaultActions, _parameters, browserWindow) => [
|
|
13086
|
+
{
|
|
13087
|
+
label: "Reload",
|
|
13088
|
+
click: () => browserWindow.reload()
|
|
13089
|
+
}
|
|
13090
|
+
]
|
|
13085
13091
|
});
|
|
13086
13092
|
const handleSignZomeCall = async (e, request) => {
|
|
13087
13093
|
const windowInfo = WINDOW_INFO_MAP[e.sender.id];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/hc-spin",
|
|
3
|
-
"version": "0.400.0-dev.
|
|
4
|
-
"holochainVersion": "0.4.0-dev.
|
|
3
|
+
"version": "0.400.0-dev.3",
|
|
4
|
+
"holochainVersion": "0.4.0-dev.16",
|
|
5
5
|
"description": "CLI to run Holochain aps during development.",
|
|
6
6
|
"author": "matthme",
|
|
7
7
|
"homepage": "https://developer.holochain.org",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
|
31
31
|
"start": "electron-vite preview",
|
|
32
32
|
"dev": "electron-vite dev",
|
|
33
|
-
"build": "rimraf dist && npm run typecheck && electron-vite build && mv ./out ./dist && cp ./cli/cli.js ./dist/cli.js"
|
|
33
|
+
"build": "rimraf dist && npm run typecheck && electron-vite build && mv ./out ./dist && cp ./cli/cli.js ./dist/cli.js && node ./scripts/replace-electron-version.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@electron-toolkit/preload": "^3.0.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@msgpack/msgpack": "^2.8.0",
|
|
41
41
|
"bufferutil": "4.0.8",
|
|
42
42
|
"commander": "11.1.0",
|
|
43
|
-
"electron": "^
|
|
43
|
+
"electron": "^29.3.1",
|
|
44
44
|
"electron-context-menu": "3.6.1",
|
|
45
45
|
"get-port": "7.0.0",
|
|
46
46
|
"nanoid": "5.0.4",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
const packageJsonString = fs.readFileSync('package.json');
|
|
4
|
+
const packageJson = JSON.parse(packageJsonString);
|
|
5
|
+
const electronVersion = packageJson.dependencies.electron;
|
|
6
|
+
const majorElectronVersion = electronVersion.replace('^', '').slice(0, 3);
|
|
7
|
+
console.log('electron version: ', majorElectronVersion);
|
|
8
|
+
|
|
9
|
+
const cliJs = fs.readFileSync('./dist/cli.js', 'utf-8');
|
|
10
|
+
const modifiedCliJs = cliJs.replace('###REPLACE_AT_BUILD_TIME###', majorElectronVersion);
|
|
11
|
+
fs.writeFileSync('./dist/cli.js', modifiedCliJs);
|
package/src/main/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { app, IpcMainInvokeEvent, ipcMain, protocol, Menu } from 'electron';
|
|
1
|
+
import { app, IpcMainInvokeEvent, ipcMain, protocol, Menu, BrowserWindow } from 'electron';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { nanoid } from 'nanoid';
|
|
@@ -112,7 +112,7 @@ const WINDOW_INFO_MAP: Record<
|
|
|
112
112
|
protocol.registerSchemesAsPrivileged([
|
|
113
113
|
{
|
|
114
114
|
scheme: 'webhapp',
|
|
115
|
-
privileges: { standard: true },
|
|
115
|
+
privileges: { standard: true, secure: true, stream: true },
|
|
116
116
|
},
|
|
117
117
|
]);
|
|
118
118
|
|
|
@@ -120,6 +120,12 @@ contextMenu({
|
|
|
120
120
|
showSaveImageAs: true,
|
|
121
121
|
showSearchWithGoogle: false,
|
|
122
122
|
showInspectElement: true,
|
|
123
|
+
append: (_defaultActions, _parameters, browserWindow) => [
|
|
124
|
+
{
|
|
125
|
+
label: 'Reload',
|
|
126
|
+
click: () => (browserWindow as BrowserWindow).reload(),
|
|
127
|
+
},
|
|
128
|
+
],
|
|
123
129
|
});
|
|
124
130
|
|
|
125
131
|
const handleSignZomeCall = async (e: IpcMainInvokeEvent, request: CallZomeRequest) => {
|