loong64-electron 31.7.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/LICENSE +21 -0
- package/README.md +115 -0
- package/checksums.json +12 -0
- package/cli.js +25 -0
- package/electron.d.ts +23652 -0
- package/index.js +21 -0
- package/install.js +109 -0
- package/package.json +28 -0
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const pathFile = path.join(__dirname, 'path.txt');
|
|
5
|
+
|
|
6
|
+
function getElectronPath () {
|
|
7
|
+
let executablePath;
|
|
8
|
+
if (fs.existsSync(pathFile)) {
|
|
9
|
+
executablePath = fs.readFileSync(pathFile, 'utf-8');
|
|
10
|
+
}
|
|
11
|
+
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
|
12
|
+
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
|
|
13
|
+
}
|
|
14
|
+
if (executablePath) {
|
|
15
|
+
return path.join(__dirname, 'dist', executablePath);
|
|
16
|
+
} else {
|
|
17
|
+
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getElectronPath();
|
package/install.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { downloadArtifact } = require('@electron/get');
|
|
4
|
+
|
|
5
|
+
const extract = require('extract-zip');
|
|
6
|
+
|
|
7
|
+
const childProcess = require('child_process');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
const { version } = require('./package');
|
|
13
|
+
|
|
14
|
+
if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) {
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const platformPath = getPlatformPath();
|
|
19
|
+
|
|
20
|
+
if (isInstalled()) {
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const platform = process.env.npm_config_platform || process.platform;
|
|
25
|
+
let arch = process.env.npm_config_arch || process.arch;
|
|
26
|
+
|
|
27
|
+
if (platform === 'darwin' && process.platform === 'darwin' && arch === 'x64' &&
|
|
28
|
+
process.env.npm_config_arch === undefined) {
|
|
29
|
+
// When downloading for macOS ON macOS and we think we need x64 we should
|
|
30
|
+
// check if we're running under rosetta and download the arm64 version if appropriate
|
|
31
|
+
try {
|
|
32
|
+
const output = childProcess.execSync('sysctl -in sysctl.proc_translated');
|
|
33
|
+
if (output.toString().trim() === '1') {
|
|
34
|
+
arch = 'arm64';
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
// Ignore failure
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// downloads if not cached
|
|
42
|
+
downloadArtifact({
|
|
43
|
+
version,
|
|
44
|
+
artifactName: 'electron',
|
|
45
|
+
force: process.env.force_no_cache === 'true',
|
|
46
|
+
cacheRoot: process.env.electron_config_cache,
|
|
47
|
+
checksums: process.env.electron_use_remote_checksums ?? process.env.npm_config_electron_use_remote_checksums ? undefined : require('./checksums.json'),
|
|
48
|
+
platform,
|
|
49
|
+
arch
|
|
50
|
+
}).then(extractFile).catch(err => {
|
|
51
|
+
console.error(err.stack);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function isInstalled () {
|
|
56
|
+
try {
|
|
57
|
+
if (fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '') !== version) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (fs.readFileSync(path.join(__dirname, 'path.txt'), 'utf-8') !== platformPath) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath);
|
|
69
|
+
|
|
70
|
+
return fs.existsSync(electronPath);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// unzips and makes path.txt point at the correct executable
|
|
74
|
+
function extractFile (zipPath) {
|
|
75
|
+
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
|
|
76
|
+
|
|
77
|
+
return extract(zipPath, { dir: path.join(__dirname, 'dist') }).then(() => {
|
|
78
|
+
// If the zip contains an "electron.d.ts" file,
|
|
79
|
+
// move that up
|
|
80
|
+
const srcTypeDefPath = path.join(distPath, 'electron.d.ts');
|
|
81
|
+
const targetTypeDefPath = path.join(__dirname, 'electron.d.ts');
|
|
82
|
+
const hasTypeDefinitions = fs.existsSync(srcTypeDefPath);
|
|
83
|
+
|
|
84
|
+
if (hasTypeDefinitions) {
|
|
85
|
+
fs.renameSync(srcTypeDefPath, targetTypeDefPath);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Write a "path.txt" file.
|
|
89
|
+
return fs.promises.writeFile(path.join(__dirname, 'path.txt'), platformPath);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function getPlatformPath () {
|
|
94
|
+
const platform = process.env.npm_config_platform || os.platform();
|
|
95
|
+
|
|
96
|
+
switch (platform) {
|
|
97
|
+
case 'mas':
|
|
98
|
+
case 'darwin':
|
|
99
|
+
return 'Electron.app/Contents/MacOS/Electron';
|
|
100
|
+
case 'freebsd':
|
|
101
|
+
case 'openbsd':
|
|
102
|
+
case 'linux':
|
|
103
|
+
return 'electron';
|
|
104
|
+
case 'win32':
|
|
105
|
+
return 'electron.exe';
|
|
106
|
+
default:
|
|
107
|
+
throw new Error('Electron builds are not available on platform: ' + platform);
|
|
108
|
+
}
|
|
109
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"main": "index.js",
|
|
3
|
+
"types": "electron.d.ts",
|
|
4
|
+
"bin": {
|
|
5
|
+
"electron": "cli.js"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"preinstall": "export ELECTRON_MIRROR=\"https://ftp.loongnix.cn/electron/LoongArch/\" && echo \"Using mirror: $ELECTRON_MIRROR\"",
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@electron/get": "^2.0.0",
|
|
13
|
+
"@types/node": "^20.9.0",
|
|
14
|
+
"extract-zip": "^2.0.1"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">= 12.20.55"
|
|
18
|
+
},
|
|
19
|
+
"name": "loong64-electron",
|
|
20
|
+
"repository": "https://github.com/electron/electron",
|
|
21
|
+
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Electron Community",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"electron"
|
|
26
|
+
],
|
|
27
|
+
"version": "31.7.7"
|
|
28
|
+
}
|