mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
chore: standardize tsconfig (#9568)
This commit is contained in:
@@ -10,6 +10,15 @@
|
||||
},
|
||||
"description": "AFFiNE Desktop App",
|
||||
"homepage": "https://github.com/toeverything/AFFiNE",
|
||||
"exports": {
|
||||
"./helper/exposed": "./src/helper/exposed.ts",
|
||||
"./main/exposed": "./src/main/exposed.ts",
|
||||
"./preload/electron-api": "./src/preload/electron-api.ts",
|
||||
"./preload/shared-storage": "./src/preload/shared-storage.ts",
|
||||
"./main/shared-state-schema": "./src/main/shared-state-schema.ts",
|
||||
"./main/updater/event": "./src/main/updater/event.ts",
|
||||
"./main/windows-manager": "./src/main/windows-manager/index.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"dev": "cross-env DEV_SERVER_URL=http://localhost:8080 node ./scripts/dev.ts",
|
||||
|
||||
@@ -106,7 +106,7 @@ export const uiHandlers = {
|
||||
link =
|
||||
'https://api.fxtwitter.com/status/' + /\/status\/(.*)/.exec(link)?.[1];
|
||||
try {
|
||||
const { tweet } = await fetch(link).then(res => res.json());
|
||||
const { tweet } = (await fetch(link).then(res => res.json())) as any;
|
||||
return {
|
||||
title: tweet.author.name,
|
||||
icon: tweet.author.avatar_url,
|
||||
|
||||
@@ -9,11 +9,14 @@ import {
|
||||
WebContentViewsManager,
|
||||
} from './tab-views';
|
||||
|
||||
export const showTabContextMenu = async (tabId: string, viewIndex: number) => {
|
||||
export const showTabContextMenu = async (
|
||||
tabId: string,
|
||||
viewIndex: number
|
||||
): Promise<TabAction | null> => {
|
||||
const workbenches = WebContentViewsManager.instance.tabViewsMeta.workbenches;
|
||||
const tabMeta = workbenches.find(w => w.id === tabId);
|
||||
if (!tabMeta) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const { resolve, promise } = Promise.withResolvers<TabAction | null>();
|
||||
@@ -93,7 +96,7 @@ export const showTabContextMenu = async (tabId: string, viewIndex: number) => {
|
||||
];
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
menu.popup();
|
||||
// eslint-disable-next-line prefer-const
|
||||
|
||||
let unsub: (() => void) | undefined;
|
||||
const subscription = WebContentViewsManager.instance.tabAction$.subscribe(
|
||||
action => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Please add modules to `external` in `rollupOptions` to avoid wrong bundling.
|
||||
import type { MessagePort } from 'node:worker_threads';
|
||||
|
||||
import type { EventBasedChannel } from 'async-call-rpc';
|
||||
import { AsyncCall } from 'async-call-rpc';
|
||||
import { ipcRenderer } from 'electron';
|
||||
@@ -135,12 +137,13 @@ const helperPort = new Promise<MessagePort>(resolve =>
|
||||
const createMessagePortChannel = (port: MessagePort): EventBasedChannel => {
|
||||
return {
|
||||
on(listener) {
|
||||
port.onmessage = e => {
|
||||
const listen = (e: MessageEvent) => {
|
||||
listener(e.data);
|
||||
};
|
||||
port.addEventListener('message', listen as any);
|
||||
port.start();
|
||||
return () => {
|
||||
port.onmessage = null;
|
||||
port.removeEventListener('message', listen as any);
|
||||
try {
|
||||
port.close();
|
||||
} catch (err) {
|
||||
@@ -246,10 +249,15 @@ export const events = {
|
||||
...helperAPIs.events,
|
||||
};
|
||||
|
||||
// Create MessagePort that can be used by web workers
|
||||
/**
|
||||
* Create MessagePort that can be used by web workers
|
||||
*
|
||||
* !!!
|
||||
* SHOULD ONLY BE USED IN RENDERER PROCESS
|
||||
* !!!
|
||||
*/
|
||||
export function requestWebWorkerPort() {
|
||||
const ch = new MessageChannel();
|
||||
|
||||
const localPort = ch.port1;
|
||||
const remotePort = ch.port2;
|
||||
|
||||
@@ -274,6 +282,7 @@ export function requestWebWorkerPort() {
|
||||
const portId = crypto.randomUUID();
|
||||
|
||||
setTimeout(() => {
|
||||
// @ts-expect-error this function should only be evaluated in the renderer process
|
||||
window.postMessage(
|
||||
{
|
||||
type: 'electron:request-api-port',
|
||||
|
||||
@@ -1,45 +1,16 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.json",
|
||||
"extends": "../../../../tsconfig.node.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"types": ["node", "affine__env"],
|
||||
"outDir": "lib",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"noImplicitOverride": true,
|
||||
"paths": {
|
||||
"@toeverything/infra/*": ["../../common/infra/src/*"]
|
||||
}
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["./src"],
|
||||
"exclude": ["renderer", "node_modules", "lib", "dist", "**/__tests__/**/*"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../../frontend/native"
|
||||
},
|
||||
{
|
||||
"path": "../../../common/infra"
|
||||
},
|
||||
{
|
||||
"path": "../../../common/env"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
},
|
||||
{
|
||||
"path": "../../../../tests/kit"
|
||||
},
|
||||
{
|
||||
"path": "../../../../tools/utils"
|
||||
}
|
||||
],
|
||||
"ts-node": {
|
||||
"esm": true,
|
||||
"experimentalSpecifierResolution": "node"
|
||||
}
|
||||
{ "path": "../../../../tests/kit" },
|
||||
{ "path": "../../../../tools/utils" },
|
||||
{ "path": "../../native" },
|
||||
{ "path": "../../../common/nbstore" },
|
||||
{ "path": "../../../common/infra" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.json",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noEmit": false,
|
||||
"outDir": "./lib/scripts",
|
||||
"types": ["node", "affine__env"],
|
||||
"allowJs": true
|
||||
"rootDir": ".",
|
||||
"outDir": "./lib",
|
||||
"tsBuildInfoFile": "./lib/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["./scripts"],
|
||||
"exclude": ["./renderer"],
|
||||
"ts-node": {
|
||||
"esm": true,
|
||||
"experimentalSpecifierResolution": "node"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../../../../tools/utils"
|
||||
}
|
||||
]
|
||||
"include": ["./test", "./scripts", "./vitest.config.ts"]
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"extends": "../../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noEmit": false,
|
||||
"outDir": "./lib/tests",
|
||||
"types": ["node", "affine__env"],
|
||||
"allowJs": true
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.json"
|
||||
}
|
||||
],
|
||||
"include": ["./test"]
|
||||
}
|
||||
Reference in New Issue
Block a user