Skip to content

Commit

Permalink
Revert Electron, Attempt #1
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Apr 1, 2024
1 parent 9229b6d commit b3961a4
Show file tree
Hide file tree
Showing 38 changed files with 49 additions and 53 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ npm install
Outline clients share the same web app across all platforms. This code is located in the src/www directory. If you are making changes to the shared web app and do not need to test platform-specific functionality, you can test in a desktop browser by running:

```sh
npm run action src/www/start
npm run action client/src/www/start
```

The latter command will open a browser instance running the app. Browser platform development will use fake servers to test successful and unsuccessful connections.

The app logic is located in [src/www/app](src/www/app). UI components are located in [src/www/ui_components](src/www/ui_components). If you want to work specifically on an individual UI element, try the storybook!:

```sh
npm run action src/www/storybook
npm run action client/src/www/storybook
```

> [!NOTE]
Expand All @@ -75,7 +75,7 @@ npm run action src/www/storybook
Certain actions take configuration flags - but since we're running them through `npm`, you'll have to use the `--` seperator to funnel them through to the underlying process. For example, to set up a MacOS project in release mode, you'd run:
```sh
SENTRY_DSN=<your sentry dsn> npm run action cordova/setup macos -- --buildMode=release --versionName=<your version name>
SENTRY_DSN=<your sentry dsn> npm run action client/src/cordova/setup macos -- --buildMode=release --versionName=<your version name>
```
#### Life of a Packet
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/electron_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// <reference path="../../electron/preload.d.ts" />
/// <reference path="../../../../src/electron/preload.d.ts" />

import 'web-animations-js/web-animations-next-lite.min.js';
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
Expand Down
3 changes: 2 additions & 1 deletion client/src/electron/README.md → src/electron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ brew install podman
podman machine init
sudo ln -s $(which podman) /usr/local/bin/docker
sudo /opt/homebrew/Cellar/podman/<podman version>/bin/podman-mac-helper install
podman machine set --rootful podman-machine-default
podman machine start
```

> You may run into the error: `/var/folders/<path>/xgo-cache: no such file or directory`. If so, simply create that directory with `mkdir -p /var/folders/<path>/xgo-cache` and try again.
To build the Electron clients, run (it will also package an installer executable into `build/dist`):

```sh
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
// limitations under the License.

import minimist from 'minimist';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {runAction} from '../build/run_action.mjs';
import {getBuildParameters} from '../../client/src/build/get_build_parameters.mjs';
import {runAction} from '../../client/src/build/run_action.mjs';
import electron, {Platform} from 'electron-builder';
import copydir from 'copy-dir';
import fs from 'fs/promises';
import url from 'url';
import {getRootDir} from '../build/get_root_dir.mjs';
import {getRootDir} from '../../client/src/build/get_root_dir.mjs';
import path from 'path';

const ELECTRON_BUILD_DIR = 'output';
const ELECTRON_BUILD_DIR = 'build';
const ELECTRON_PLATFORMS = ['linux', 'windows'];

export async function main(...parameters) {
Expand Down Expand Up @@ -50,9 +50,7 @@ export async function main(...parameters) {

await runAction('client/src/www/build', ...parameters);
await runAction('client/src/tun2socks/build', ...parameters);
await runAction('client/src/electron/build_main', ...parameters);

await fs.mkdir(path.join(getRootDir(), ELECTRON_BUILD_DIR, 'icons'), {recursive: true});
await runAction('src/electron/build_main', ...parameters);

await copydir.sync(
path.join(getRootDir(), 'src', 'electron', 'icons'),
Expand All @@ -66,7 +64,6 @@ export async function main(...parameters) {
// build electron binary
await electron.build({
publish: buildMode === 'release' ? 'always' : 'never',
projectDir: getRootDir(),
targets: Platform[platform.toLocaleUpperCase()].createTarget(),
config: {
...electronConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {getWebpackBuildMode} from '../build/get_webpack_build_mode.mjs';
import {runAction} from '../build/run_action.mjs';
import {runWebpack} from '../build/run_webpack.mjs';
import {getBuildParameters} from '../../client/src/build/get_build_parameters.mjs';
import {getWebpackBuildMode} from '../../client/src/build/get_webpack_build_mode.mjs';
import {runAction} from '../../client/src/build/run_action.mjs';
import {runWebpack} from '../../client/src/build/run_webpack.mjs';
import electronMainWebpackConfigs from './webpack_electron_main.mjs';
import fs from 'fs/promises';
import path from 'path';
import url from 'url';
import {getRootDir} from '../build/get_root_dir.mjs';

const ELECTRON_BUILD_DIR = 'output';
const ELECTRON_BUILD_DIR = 'build';
const ELECTRON_PLATFORMS = ['linux', 'windows'];

export async function main(...parameters) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ ${StrRep}
File /r "${PROJECT_DIR}\third_party\tap-windows6\bin\i386\*"
${EndIf}
SetOutPath -
File "${PROJECT_DIR}\client\src\electron\add_tap_device.bat"
File "${PROJECT_DIR}\client\src\electron\find_tap_device_name.bat"
File "${PROJECT_DIR}\src\electron\add_tap_device.bat"
File "${PROJECT_DIR}\src\electron\find_tap_device_name.bat"

; OutlineService files, stopping the service first in case it's still running.
nsExec::Exec "$SYSDIR\net stop OutlineService"
File "${PROJECT_DIR}\client\tools\OutlineService\OutlineService\bin\OutlineService.exe"
File "${PROJECT_DIR}\client\tools\smartdnsblock\bin\smartdnsblock.exe"
File "${PROJECT_DIR}\tools\OutlineService\OutlineService\bin\OutlineService.exe"
File "${PROJECT_DIR}\tools\smartdnsblock\bin\smartdnsblock.exe"
File "${PROJECT_DIR}\third_party\newtonsoft\Newtonsoft.Json.dll"
File "${PROJECT_DIR}\client\src\electron\install_windows_service.bat"
File "${PROJECT_DIR}\src\electron\install_windows_service.bat"

; ExecToStack captures both stdout and stderr from the script, in the order output.
; Set a (long) timeout in case the device never becomes visible to netsh.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"files": ["output/electron", "www", "resources/tray", "!node_modules/electron"],
"asarUnpack": ["../third_party", "tools"],
"files": ["build/electron", "www", "resources/tray", "!node_modules/electron"],
"asarUnpack": ["output", "tools"],
"artifactName": "Outline-Client.${ext}",
"directories": {
"output": "output/dist"
"output": "output/build/dist"
},
"linux": {
"target": {
"target": "AppImage",
"arch": ["x64"]
},
"files": ["output/icons/png", "output/build/linux", "tools/outline_proxy_controller/dist"],
"icon": "output/icons/png",
"files": ["build/icons/png", "output/build/linux", "tools/outline_proxy_controller/dist"],
"icon": "build/icons/png",
"category": "Network"
},
"win": {
Expand All @@ -22,8 +22,8 @@
}
],
"files": ["output/build/windows"],
"icon": "output/icons/win/icon.ico",
"sign": "client/src/electron/windows/electron_builder_signing_plugin.cjs",
"icon": "build/icons/win/icon.ico",
"sign": "src/electron/windows/electron_builder_signing_plugin.cjs",
"signingHashAlgorithms": ["sha256"]
},
"nsis": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class GoTun2socks {
private readonly process: ChildProcessHelper;

constructor(private readonly config: ShadowsocksSessionConfig) {
this.process = new ChildProcessHelper(pathToEmbeddedBinary('outline-go-tun2socks', 'tun2socks'));
this.process = new ChildProcessHelper(pathToEmbeddedBinary('tun2socks'));
}

async start(isUdpEnabled: boolean): Promise<void> {
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ async function installLinuxRoutingServices(): Promise<void> {
const src = path.join(srcFolderPath, descriptor.filename);

const srcContent = await fsextra.readFile(src);
descriptor.sha256 = createHash('sha256').update(srcContent).digest('hex');
descriptor.sha256 = createHash('sha256')
.update(srcContent)
.digest('hex');

const dest = path.join(tmp, descriptor.filename);
await fsextra.copy(src, dest, {overwrite: true});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import url from 'url';
import electron from 'electron';

import {runAction} from '../build/run_action.mjs';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {getRootDir} from '../build/get_root_dir.mjs';
import {spawnStream} from '../build/spawn_stream.mjs';
import {runAction} from '../../client/src/build/run_action.mjs';
import {getBuildParameters} from '../../client/src/build/get_build_parameters.mjs';
import {getRootDir} from '../../client/src/build/get_root_dir.mjs';
import {spawnStream} from '../../client/src/build/spawn_stream.mjs';

/**
* @description Builds and starts the electron application.
Expand All @@ -28,9 +28,9 @@ import {spawnStream} from '../build/spawn_stream.mjs';
export async function main(...parameters) {
const {platform, buildMode} = getBuildParameters(parameters);

await runAction('client/src/www/build', platform, `--buildMode=${buildMode}`);
await runAction('client/src/electron/build_main', ...parameters);
await runAction('client/src/electron/build', platform, `--buildMode=${buildMode}`);
await runAction('www/build', platform, `--buildMode=${buildMode}`);
await runAction('electron/build_main', ...parameters);
await runAction('electron/build', platform, `--buildMode=${buildMode}`);

process.env.OUTLINE_DEBUG = buildMode === 'debug';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../www/tsconfig.json",
"extends": "../../client/src/www/tsconfig.json",
"compilerOptions": {
"outDir": "../../build/electron"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const __dirname = path.dirname(__filename);

export default ({sentryDsn, appVersion}) => [
{
entry: './client/src/electron/index.ts',
entry: './src/electron/index.ts',
target: 'electron-main',
node: {
__dirname: false,
Expand All @@ -49,11 +49,11 @@ export default ({sentryDsn, appVersion}) => [
],
output: {
filename: 'index.js',
path: path.resolve(__dirname, '..', '..', 'output', 'electron'),
path: path.resolve(__dirname, '..', '..', 'build', 'electron', 'electron'),
},
},
{
entry: './client/src/electron/preload.ts',
entry: './src/electron/preload.ts',
target: 'electron-preload',
devtool: 'inline-source-map',
module: {
Expand All @@ -70,7 +70,7 @@ export default ({sentryDsn, appVersion}) => [
},
output: {
filename: 'preload.js',
path: path.resolve(__dirname, '..', '..', 'output', 'electron'),
path: path.resolve(__dirname, '..', '..', 'build', 'electron', 'electron'),
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

// CommonJS module is required, ES6 module is not supported by electron-builder:
// /outline-apps/node_modules/app-builder-lib/out/platformPackager.js:597
// /outline-client/node_modules/app-builder-lib/out/platformPackager.js:597
// const m = require(p);
// ^
// Error [ERR_REQUIRE_ESM]: require() of ES Module .../electron_builder_signing_plugin.mjs not supported.
Expand All @@ -30,13 +30,9 @@
*/
async function electronBuilderEntryPoint(configuration) {
const {runAction} = await import('../../build/run_action.mjs');
await runAction(
'src/electron/windows/sign_windows_executable',
'--target',
configuration.path,
'--algorithm',
configuration.hash
);
await runAction('src/electron/windows/sign_windows_executable',
'--target', configuration.path,
'--algorithm', configuration.hash);
}

exports.default = electronBuilderEntryPoint;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {dirname, resolve} from 'path';
import {fileURLToPath, pathToFileURL} from 'url';
import {format} from 'util';

import {jsign} from '../../../../third_party/jsign/index.mjs';
import {jsign} from '../../../third_party/jsign/index.mjs';

/**
* Get the parent folder path of this script.
Expand Down

0 comments on commit b3961a4

Please sign in to comment.