chore: bump electron version (#7922)

This commit is contained in:
pengx17 2024-08-19 14:24:34 +00:00
parent f3930a9262
commit 9d42db56ca
No known key found for this signature in database
GPG Key ID: 23F23D9E8B3971ED
16 changed files with 49 additions and 40 deletions

View File

@ -180,7 +180,7 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
electron-install: false
electron-install: true
full-cache: true
- name: Download affine.linux-x64-gnu.node

View File

@ -75,7 +75,7 @@
"@vitest/coverage-istanbul": "1.6.0",
"@vitest/ui": "1.6.0",
"cross-env": "^7.0.3",
"electron": "~30.2.0",
"electron": "^31.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import-x": "^0.5.0",

View File

@ -3,7 +3,7 @@ import type { DocCollection } from '@blocksuite/store';
declare global {
interface Window {
appInfo: {
__appInfo: {
electron: boolean;
schema: string;
windowName: string;
@ -14,7 +14,7 @@ declare global {
//#region runtime variables
export const isBrowser = typeof window !== 'undefined';
export const isServer = !isBrowser && typeof navigator === 'undefined';
export const isDesktop = isBrowser && !!window.appInfo?.electron;
export const isDesktop = isBrowser && !!window.__appInfo?.electron;
//#endregion
export const DEFAULT_WORKSPACE_NAME = 'Demo Workspace';
export const UNTITLED_WORKSPACE_NAME = 'Untitled';

View File

@ -1,5 +1,5 @@
import { AIProvider } from '@affine/core/blocksuite/presets/ai';
import { apis } from '@affine/electron-api';
import { apis, appInfo } from '@affine/electron-api';
import type { OAuthProviderType } from '@affine/graphql';
import {
ApplicationFocused,
@ -160,8 +160,8 @@ export class AuthService extends Service {
private buildRedirectUri(callbackUrl: string) {
const params: string[][] = [];
if (environment.isDesktop && window.appInfo.schema) {
params.push(['schema', window.appInfo.schema]);
if (environment.isDesktop && appInfo?.schema) {
params.push(['schema', appInfo.schema]);
}
const query =
params.length > 0

View File

@ -1,3 +1,4 @@
import { appInfo } from '@affine/electron-api';
import type {
CreateCheckoutSessionInput,
SubscriptionRecurring,
@ -27,8 +28,8 @@ const getDefaultSubscriptionSuccessCallbackLink = (
plan === SubscriptionPlan.AI ? '/ai-upgrade-success' : '/upgrade-success';
const urlString = getAffineCloudBaseUrl() + path;
const url = new URL(urlString);
if (environment.isDesktop) {
url.searchParams.set('schema', window.appInfo.schema);
if (environment.isDesktop && appInfo) {
url.searchParams.set('schema', appInfo.schema);
}
return url.toString();
};

View File

@ -9,6 +9,6 @@
},
"devDependencies": {
"@toeverything/infra": "workspace:*",
"electron": "~30.2.0"
"electron": "^31.0.0"
}
}

View File

@ -29,13 +29,13 @@ type ClientHandler = {
} & HelperHandlers;
type ClientEvents = MainEvents & HelperEvents;
export const appInfo = (globalThis as any).appInfo as
export const appInfo = (globalThis as any).__appInfo as
| typeof exposedAppInfo
| null;
export const apis = (globalThis as any).apis as ClientHandler | null;
export const events = (globalThis as any).events as ClientEvents | null;
export const apis = (globalThis as any).__apis as ClientHandler | null;
export const events = (globalThis as any).__events as ClientEvents | null;
export const sharedStorage = (globalThis as any).sharedStorage as
export const sharedStorage = (globalThis as any).__sharedStorage as
| typeof exposedSharedStorage
| null;

View File

@ -53,7 +53,7 @@
"builder-util-runtime": "^9.2.5-alpha.2",
"core-js": "^3.36.1",
"cross-env": "^7.0.3",
"electron": "~30.2.0",
"electron": "^31.0.0",
"electron-log": "^5.1.2",
"electron-squirrel-startup": "1.0.1",
"electron-window-state": "^5.0.3",

View File

@ -34,8 +34,8 @@ function main() {
// skip bootstrap setup for desktop onboarding
if (
window.appInfo?.windowName === 'onboarding' ||
window.appInfo?.windowName === 'theme-editor'
appInfo?.windowName === 'onboarding' ||
appInfo?.windowName === 'theme-editor'
) {
performanceMainLogger.info('skip setup');
} else {

View File

@ -1,4 +1,4 @@
import log from 'electron-log';
import log from 'electron-log/main';
export const logger = log.scope('helper');

View File

@ -1,8 +1,10 @@
import { app, shell } from 'electron';
import log from 'electron-log';
import log from 'electron-log/main';
export const logger = log.scope('main');
log.initialize();
log.initialize({
preload: false,
});
log.transports.file.level = 'info';

View File

@ -7,7 +7,7 @@ import { sharedStorage } from './shared-storage';
const { apis, events } = getElectronAPIs();
contextBridge.exposeInMainWorld('appInfo', appInfo);
contextBridge.exposeInMainWorld('apis', apis);
contextBridge.exposeInMainWorld('events', events);
contextBridge.exposeInMainWorld('sharedStorage', sharedStorage);
contextBridge.exposeInMainWorld('__appInfo', appInfo);
contextBridge.exposeInMainWorld('__apis', apis);
contextBridge.exposeInMainWorld('__events', events);
contextBridge.exposeInMainWorld('__sharedStorage', sharedStorage);

View File

@ -5,6 +5,7 @@ import './polyfill/request-idle-callback';
import '@affine/core/bootstrap/preload';
import { performanceLogger } from '@affine/core/shared';
import { appInfo } from '@affine/electron-api';
import { isDesktop } from '@affine/env/constant';
import {
init,
@ -27,7 +28,7 @@ function main() {
performanceMainLogger.info('start');
// skip bootstrap setup for desktop onboarding
if (isDesktop && window.appInfo?.windowName === 'onboarding') {
if (isDesktop && appInfo?.windowName === 'onboarding') {
performanceMainLogger.info('skip setup');
} else {
performanceMainLogger.info('setup start');

View File

@ -12,7 +12,7 @@ import fs from 'fs-extra';
declare global {
interface Window {
apis: typeof apis;
__apis: typeof apis;
}
}
@ -55,7 +55,7 @@ test('export then add', async ({ page, appInfo, workspace }) => {
// export db file to tmp folder
await page.evaluate(tmpPath => {
return window.apis?.dialog.setFakeDialogResult({
return window.__apis?.dialog.setFakeDialogResult({
filePath: tmpPath,
});
}, tmpPath);
@ -73,7 +73,7 @@ test('export then add', async ({ page, appInfo, workspace }) => {
await clickSideBarCurrentWorkspaceBanner(page);
await page.evaluate(tmpPath => {
return window.apis?.dialog.setFakeDialogResult({
return window.__apis?.dialog.setFakeDialogResult({
filePath: tmpPath,
});
}, tmpPath);

View File

@ -20,13 +20,13 @@ type RoutePath = 'setting';
const getPageId = async (page: Page) => {
return page.evaluate(() => {
return (window.appInfo as any)?.viewId as string;
return (window.__appInfo as any)?.viewId as string;
});
};
const isActivePage = async (page: Page) => {
return page.evaluate(async () => {
return await (window as any).apis?.ui.isActiveTab();
return await (window as any).__apis?.ui.isActiveTab();
});
};
@ -67,9 +67,14 @@ export const test = base.extend<{
},
page: async ({ electronApp }, use) => {
await expect
.poll(() => {
return electronApp.windows().length > 1;
})
.poll(
() => {
return electronApp.windows().length > 1;
},
{
timeout: 10000,
}
)
.toBeTruthy();
const page = await getActivePage(electronApp.windows());

View File

@ -512,7 +512,7 @@ __metadata:
resolution: "@affine/electron-api@workspace:packages/frontend/electron-api"
dependencies:
"@toeverything/infra": "workspace:*"
electron: "npm:~30.2.0"
electron: "npm:^31.0.0"
languageName: unknown
linkType: soft
@ -551,7 +551,7 @@ __metadata:
builder-util-runtime: "npm:^9.2.5-alpha.2"
core-js: "npm:^3.36.1"
cross-env: "npm:^7.0.3"
electron: "npm:~30.2.0"
electron: "npm:^31.0.0"
electron-log: "npm:^5.1.2"
electron-squirrel-startup: "npm:1.0.1"
electron-updater: "npm:^6.2.1"
@ -663,7 +663,7 @@ __metadata:
"@vitest/coverage-istanbul": "npm:1.6.0"
"@vitest/ui": "npm:1.6.0"
cross-env: "npm:^7.0.3"
electron: "npm:~30.2.0"
electron: "npm:^31.0.0"
eslint: "npm:^8.57.0"
eslint-config-prettier: "npm:^9.1.0"
eslint-plugin-import-x: "npm:^0.5.0"
@ -20002,16 +20002,16 @@ __metadata:
languageName: node
linkType: hard
"electron@npm:~30.2.0":
version: 30.2.0
resolution: "electron@npm:30.2.0"
"electron@npm:^31.0.0":
version: 31.4.0
resolution: "electron@npm:31.4.0"
dependencies:
"@electron/get": "npm:^2.0.0"
"@types/node": "npm:^20.9.0"
extract-zip: "npm:^2.0.1"
bin:
electron: cli.js
checksum: 10/e17fae57e538ca0b9af3bc4fe11005793e87f9948277e7da87a52caf6b57c783cac0db1a24320d3d4daf49932371e23fcbbe9d55fe5c1d67b3a407b516c14149
checksum: 10/445bf8b04f0f8fcc16da4832634507c01bbdd6733ef8236e2216f8f4667d070115d41b7bd28f73ca91f819a720a629e1cbea08b079fa7bde424fd24b6aef4499
languageName: node
linkType: hard