@overwolf/ow-electron 39.8.12 → 42.7.1-beta.0

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/index.js CHANGED
@@ -1,9 +1,28 @@
1
+ const { spawnSync } = require('child_process');
1
2
  const fs = require('fs');
2
3
  const path = require('path');
3
4
 
4
5
  const pathFile = path.join(__dirname, 'path.txt');
5
6
 
6
- function getElectronPath () {
7
+ function downloadElectron() {
8
+ console.log('Downloading ow-electron binary...');
9
+ const result = spawnSync(process.execPath, [path.join(__dirname, 'install.js')], {
10
+ stdio: 'inherit'
11
+ });
12
+ if (result.status !== 0) {
13
+ throw new Error(
14
+ 'Electron failed to install correctly. Please delete `node_modules/@overwolf/ow-electron` and run "npx install-ow-electron --no" manually.'
15
+ );
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Fetches the path to the Electron executable to use in development mode.
21
+ * If the executable is missing, attempt to download it first.
22
+ *
23
+ * @returns the path to the Electron executable to run
24
+ */
25
+ function getElectronPath() {
7
26
  let executablePath;
8
27
  if (fs.existsSync(pathFile)) {
9
28
  executablePath = fs.readFileSync(pathFile, 'utf-8');
@@ -12,9 +31,21 @@ function getElectronPath () {
12
31
  return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
13
32
  }
14
33
  if (executablePath) {
15
- return path.join(__dirname, 'dist', executablePath);
34
+ const fullPath = path.join(__dirname, 'dist', executablePath);
35
+ if (!fs.existsSync(fullPath)) {
36
+ downloadElectron();
37
+ }
38
+ return fullPath;
16
39
  } else {
17
- throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
40
+ try {
41
+ downloadElectron();
42
+ } catch {
43
+ throw new Error(
44
+ 'Electron failed to install correctly. Please delete `node_modules/@overwolf/ow-electron` and run "npx install-ow-electron --no" manually.'
45
+ );
46
+ }
47
+ executablePath = fs.readFileSync(pathFile, 'utf-8');
48
+ return path.join(__dirname, 'dist', executablePath);
18
49
  }
19
50
  }
20
51
 
package/install.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const { downloadArtifact } = require('@electron/get');
4
4
 
5
5
  const { owElectronVersion } = require('./package');
6
- const extract = require('extract-zip');
6
+ const { extract } = require('@electron-internal/extract-zip');
7
7
 
8
8
  const childProcess = require('child_process');
9
9
  const fs = require('fs');
@@ -12,21 +12,21 @@ const path = require('path');
12
12
 
13
13
  const { version } = require('./package');
14
14
 
15
- if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) {
16
- process.exit(0);
17
- }
18
-
19
15
  const platformPath = getPlatformPath();
20
16
 
21
17
  if (isInstalled()) {
22
18
  process.exit(0);
23
19
  }
24
20
 
25
- const platform = process.env.npm_config_platform || process.platform;
26
- let arch = process.env.npm_config_arch || process.arch;
21
+ const platform = process.env.ELECTRON_INSTALL_PLATFORM || process.env.npm_config_platform || process.platform;
22
+ let arch = process.env.ELECTRON_INSTALL_ARCH || process.env.npm_config_arch || process.arch;
27
23
 
28
- if (platform === 'darwin' && process.platform === 'darwin' && arch === 'x64' &&
29
- process.env.npm_config_arch === undefined) {
24
+ if (
25
+ platform === 'darwin' &&
26
+ process.platform === 'darwin' &&
27
+ arch === 'x64' &&
28
+ process.env.npm_config_arch === undefined
29
+ ) {
30
30
  // When downloading for macOS ON macOS and we think we need x64 we should
31
31
  // check if we're running under rosetta and download the arm64 version if appropriate
32
32
  try {
@@ -49,15 +49,20 @@ downloadArtifact({
49
49
  artifactName: 'ow-electron',
50
50
  force: process.env.force_no_cache === 'true',
51
51
  cacheRoot: process.env.electron_config_cache,
52
- checksums: process.env.electron_use_remote_checksums ? undefined : require('./checksums.json'),
52
+ checksums:
53
+ process.env.electron_use_remote_checksums || process.env.npm_config_electron_use_remote_checksums
54
+ ? undefined
55
+ : require('./checksums.json'),
53
56
  platform,
54
57
  arch
55
- }).then(extractFile).catch(err => {
56
- console.error(err.stack);
57
- process.exit(1);
58
- });
58
+ })
59
+ .then(extractFile)
60
+ .catch((err) => {
61
+ console.error(err.stack);
62
+ process.exit(1);
63
+ });
59
64
 
60
- function isInstalled () {
65
+ function isInstalled() {
61
66
  try {
62
67
  if (fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '') !== owElectronVersion) {
63
68
  return false;
@@ -76,7 +81,7 @@ function isInstalled () {
76
81
  }
77
82
 
78
83
  // unzips and makes path.txt point at the correct executable
79
- function extractFile (zipPath) {
84
+ function extractFile(zipPath) {
80
85
  const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
81
86
 
82
87
  return extract(zipPath, { dir: path.join(__dirname, 'dist') }).then(() => {
@@ -103,8 +108,8 @@ function extractFile (zipPath) {
103
108
  });
104
109
  }
105
110
 
106
- function getPlatformPath () {
107
- const platform = process.env.npm_config_platform || os.platform();
111
+ function getPlatformPath() {
112
+ const platform = process.env.ELECTRON_INSTALL_PLATFORM || process.env.npm_config_platform || os.platform();
108
113
 
109
114
  switch (platform) {
110
115
  case 'mas':
@@ -1,4 +1,4 @@
1
- // Type definitions for ow-electron 39.8.10 - "mix" entry.
1
+ // Type definitions for ow-electron 42.7.1-beta.0 - "mix" entry.
2
2
  //
3
3
  // Use this entry when your project ALSO has the `electron` package installed.
4
4
  // Unlike ow-electron.d.ts, it does NOT bundle a copy of Electron's types - it
package/ow-electron.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for ow-electron 39.8.12
1
+ // Type definitions for ow-electron 42.7.1-beta.0
2
2
  //
3
3
  // Default, self-contained entry: bundles Electron's own type definitions, for
4
4
  // projects that do NOT have the `electron` package installed.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@overwolf/ow-electron",
3
- "version": "39.8.12",
4
- "owElectronVersion": "39.8.12",
5
- "electronVersion": "39.8.10",
3
+ "version": "42.7.1-beta.0",
4
+ "owElectronVersion": "42.7.1-beta.0",
5
+ "electronVersion": "42.7.1",
6
6
  "repository": "https://github.com/electron/electron",
7
7
  "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
8
8
  "license": "MIT",
@@ -21,14 +21,13 @@
21
21
  }
22
22
  },
23
23
  "bin": {
24
- "ow-electron": "cli.js"
25
- },
26
- "scripts": {
27
- "postinstall": "node install.js"
24
+ "ow-electron": "cli.js",
25
+ "install-ow-electron": "install.js"
28
26
  },
29
27
  "files": [
30
28
  "LICENSE",
31
29
  "README.md",
30
+ "abi_version",
32
31
  "checksums.json",
33
32
  "cli.js",
34
33
  "electron.d.ts",
@@ -39,11 +38,14 @@
39
38
  "install.js"
40
39
  ],
41
40
  "dependencies": {
42
- "@electron/get": "^2.0.0",
43
- "@types/node": "^22.7.7",
44
- "extract-zip": "^2.0.1"
41
+ "@electron-internal/extract-zip": "^1.0.1",
42
+ "@electron/get": "^5.0.0",
43
+ "@types/node": "^24.9.0"
45
44
  },
46
45
  "engines": {
47
- "node": ">= 12.20.55"
46
+ "node": ">= 22.12.0"
47
+ },
48
+ "publishConfig": {
49
+ "tag": "beta"
48
50
  }
49
51
  }