Skip to content

Commit

Permalink
Merge pull request #318 from viktor44/windows-7
Browse files Browse the repository at this point in the history
Station for Windows 7
  • Loading branch information
viktor44 authored Jan 20, 2024
2 parents f86cc57 + 96ef394 commit a5b101f
Show file tree
Hide file tree
Showing 24 changed files with 503 additions and 852 deletions.
61 changes: 4 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,6 @@ on:
branches:
- release
jobs:
Linux:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
cache: "yarn"
# See https://github.com/nodejs/node-gyp/blob/main/docs/Force-npm-to-use-global-node-gyp.md
# https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md
# - name: Update node-gyp
# run: |
# npm install --global [email protected]
# npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
- name: Install dependencies
run: yarn install --frozen-lockfile && yarn run rebuild-all-native
- name: Build and Release
run: yarn run release

MacOs:
runs-on: macos-13
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
cache: "yarn"
- name: Configure Node
run: |
# npm v9 doesn't allow custom config parameters (i.e. node_gyp) anymode, so we have to downgrade it to v8
npm install -g npm@8
npm install -g node-gyp@latest
npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
- name: Install dependencies
run: yarn install --frozen-lockfile && yarn run rebuild-all-native
- name: Build and Release
run: yarn run release

Windows:
runs-on: windows-2019
env:
Expand All @@ -67,18 +16,16 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
node-version: "16"
- name: Configure Node
shell: powershell
run: |
# npm v9 doesn't allow custom config parameters (i.e. node_gyp) anymode, so we have to downgrade it to v8
npm install -g npm@8
npm install -g node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
# npm install --global [email protected]
# npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
npm config set registry "http://registry.npmjs.org"
yarn config set registry "http://registry.npmjs.org"
yarn config set network-timeout 300000
- name: Install dependencies
run: yarn install --frozen-lockfile && yarn run rebuild-all-native
- name: Build and Release
run: yarn run release
run: yarn run release
54 changes: 3 additions & 51 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,6 @@ on:
- "README.md"
- "CHANGELOG.md"
jobs:
Linux:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
cache: "yarn"
# - name: Update node-gyp
# run: |
# npm install --global [email protected]
# npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline && yarn run rebuild-all-native
# - name: Lint
# run: yarn run lint:ci
- name: Build
run: yarn run build

MacOs:
runs-on: macos-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
cache: "yarn"
- name: Configure Node
run: |
# npm v9 doesn't allow custom config parameters (i.e. node_gyp) anymode, so we have to downgrade it to v8
npm install -g npm@8
npm install -g node-gyp@latest
npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline && yarn run rebuild-all-native
# - name: Lint
# run: yarn run lint:ci
- name: Tests
run: yarn run test
- name: Build
run: yarn run build

Windows:
runs-on: windows-2019
env:
Expand All @@ -65,15 +19,13 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
node-version: "16"
cache: "yarn"
- name: Configure Node
shell: powershell
run: |
# npm v9 doesn't allow custom config parameters (i.e. node_gyp) anymode, so we have to downgrade it to v8
npm install -g npm@8
npm install -g node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
# npm install --global [email protected]
# npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
npm config set registry "http://registry.npmjs.org"
yarn config set registry "http://registry.npmjs.org"
yarn config set network-timeout 300000
Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
runtime = electron
disturl = https://electronjs.org/headers
target = 25.9.8
target = 22.3.27
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.15.0
16.17.1
1 change: 0 additions & 1 deletion app/app-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class BrowserXAppMain extends EventEmitter {

initAppLifeCycle() {
app.on('ready', async () => {
enhanceSession(session.defaultSession);
// can register a onOpen function that should return a promise
if (typeof this.onOpen === 'function') {
await this.onOpen();
Expand Down
7 changes: 5 additions & 2 deletions app/services/services/auto-updater/lib.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { autoUpdater as autoUpdaterProd } from 'electron-updater';

import { isPackaged } from '../../../utils/env';
import { isWindows7 } from '../../../utils/process';
import AutoUpdaterMock from './AutoUpdaterMock';
import { autoUpdater as autoUpdaterProd } from 'electron-updater';

if (isPackaged) {
autoUpdaterProd.allowPrerelease = false;
}

export const autoUpdater = isPackaged ? autoUpdaterProd : new AutoUpdaterMock();
export const autoUpdater = isPackaged && !isWindows7() // Disable auto update for Windows
? autoUpdaterProd : new AutoUpdaterMock();
11 changes: 6 additions & 5 deletions app/services/services/tab-webcontents/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ export class TabWebContentsServiceImpl extends TabWebContentsService implements
this.askAutoLogin.subscribe(async (webContentsId: number) => {
const wc = await getWebContentsFromIdOrThrow(webContentsId);

const { account, canAutoSubmit } = await provider.getCredentials(wc.id);
if (account) {
wc.focus();
wc.send('autologin-value-retrieved', account, canAutoSubmit);
}
// vk: 18.01.2024 FIXME: TypeError: Cannot destructure property 'account' of '(intermediate value)' as it is null.
// const { account, canAutoSubmit } = await provider.getCredentials(wc.id);
// if (account) {
// wc.focus();
// wc.send('autologin-value-retrieved', account, canAutoSubmit);
// }
}),
shared.subscribe(wc => {
return fromEvent(wc, 'ipc-message', (_e, channel) => channel)
Expand Down
15 changes: 9 additions & 6 deletions app/session.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { Session, OnBeforeSendHeadersListenerDetails, OnHeadersReceivedListenerDetails,
HeadersReceivedResponse, BeforeSendResponse } from 'electron';
import { Session, OnBeforeSendHeadersListenerDetails, BeforeSendResponse } from 'electron';
import enhanceWebRequest from 'electron-better-web-request';

const defaultUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.289 Safari/537.36';
const defaultUserAgent = 'Chrome/114.0.5735.289';

const getUserAgentForApp = (url: string, currentUserAgent: string): string => {

if (url.startsWith('file://') || url.startsWith('http://localhost')) {
return currentUserAgent;
}
else if (url.startsWith('https://accounts.google.com')) {
return 'Chrome/87.0.4280.141';
}

return defaultUserAgent;
};
Expand Down Expand Up @@ -53,6 +49,13 @@ export const enhanceSession = (session: Session) => {

session.setUserAgent(defaultUserAgent);

// session.webRequest.onBeforeRequest(
// (details: OnBeforeRequestListenerDetails, callback: (response: CallbackResponse) => void) => {
// console.log('AAAAAA', details.url, ' ||| ', session.getStoragePath());
// callback({ cancel: false });
// }
// );

session.webRequest.onBeforeSendHeaders(
(details: OnBeforeSendHeadersListenerDetails, callback: (beforeSendResponse: BeforeSendResponse) => void) => {
details.requestHeaders['User-Agent'] = getUserAgentForApp(details.url, session.getUserAgent());
Expand Down
4 changes: 4 additions & 0 deletions app/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export const osName = (() => {
return process.platform;
}
})();

export const isWindows7 = () => {
return process.platform === 'win32' && process.getSystemVersion().startsWith('6.');
}
28 changes: 12 additions & 16 deletions app/webui/webUIHandler.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
import { net, protocol } from 'electron';
import { protocol } from 'electron';
import { dirname } from 'path';
import { pathToFileURL } from 'url';
import { parse } from 'url';
import { BX_PROTOCOL } from './const';
import handlers from './handlers';

protocol.registerSchemesAsPrivileged([
{
scheme: BX_PROTOCOL,
privileges: {
standard: true,
secure: true,
}
},
{ scheme: BX_PROTOCOL, privileges: { standard: true, secure: true } },
]);

export function start() {
protocol.handle(BX_PROTOCOL, (req: GlobalRequest) => {
const parsedUrl = new URL(req.url);
protocol.registerFileProtocol(BX_PROTOCOL, (req, callback) => {
const parsedUrl = parse(req.url);
const handler = handlers.find(h => h.hostname === parsedUrl.hostname);

if (!handler) {
return new Response(new Blob([`Handler not found for ${req.url}`]), { status: 404 });
// @ts-ignore
return callback(-6); // file not found
}

if (!parsedUrl.pathname) {
return new Response(new Blob([`Empty path in ${req.url}`]), { status: 404 });
// @ts-ignore
return callback(-6); // file not found
}

if (parsedUrl.pathname !== '/') {
const fileUrl = `${dirname(handler.filePath)}/${parsedUrl.pathname.substring(1)}`;
return net.fetch(pathToFileURL(fileUrl).toString());
return callback(`${dirname(handler.filePath)}/${parsedUrl.pathname.substr(1)}`);
}

return net.fetch(pathToFileURL(handler.filePath).toString());
return callback(handler.filePath);
});
}
2 changes: 0 additions & 2 deletions appstore/configs/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require('../../webpack.monkeypatch-crypto');

const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
Expand Down
6 changes: 3 additions & 3 deletions appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"main": "dist/app.js",
"scripts": {
"build": "yarn run build:app && yarn run build:storybook",
"build:app": "yarn run clean && yarn run gql-gen && cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config configs/webpack.config.js --env.build",
"build:storybook": "yarn run gql-gen && cross-env NODE_ENV=storybook NODE_OPTIONS=--openssl-legacy-provider build-storybook -o dist/__storybook --quiet ",
"build:app": "yarn run clean && yarn run gql-gen && cross-env webpack --config configs/webpack.config.js --env.build",
"build:storybook": "yarn run gql-gen && cross-env NODE_ENV=storybook build-storybook -o dist/__storybook --quiet ",
"clean": "rimraf dist storybook-static",
"dev": "yarn run gql-gen && webpack-dev-server --config configs/webpack.config.js --open --mode=development",
"test": "jest",
Expand Down Expand Up @@ -120,7 +120,7 @@
"typescript": "^3.9.4",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^3.11.3"
},
"resolutions": {
"aws-sdk": "2.180.0"
Expand Down
Loading

0 comments on commit a5b101f

Please sign in to comment.