mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
refactor(imports): replace relative imports with path aliases (#2741)
This commit is contained in:
@@ -33,46 +33,6 @@ const electronExternals = [
|
||||
'@fluxer/webauthn',
|
||||
'hunspell-asm',
|
||||
];
|
||||
const pathAliasPlugin = {
|
||||
name: 'path-alias',
|
||||
setup(build) {
|
||||
build.onResolve({filter: /^@electron\//}, (args) => {
|
||||
const relativePath = args.path.replace(/^@electron\//, '');
|
||||
const absolutePath = path.join(SRC_DIR, relativePath);
|
||||
const extensions = ['.tsx', '.ts', '.js', '.jsx'];
|
||||
for (const ext of extensions) {
|
||||
const fullPath = absolutePath + ext;
|
||||
if (fs.existsSync(fullPath)) {
|
||||
return {path: fullPath};
|
||||
}
|
||||
}
|
||||
for (const ext of extensions) {
|
||||
const indexPath = path.join(absolutePath, `index${ext}`);
|
||||
if (fs.existsSync(indexPath)) {
|
||||
return {path: indexPath};
|
||||
}
|
||||
}
|
||||
return {path: `${absolutePath}.tsx`};
|
||||
});
|
||||
build.onResolve({filter: /^@fluxer\/voice_engine_v2(?:\/.*)?$/}, (args) => {
|
||||
const packageSrcDir = path.join(ROOT_DIR, '..', 'packages', 'voice_engine_v2', 'src');
|
||||
if (args.path === '@fluxer/voice_engine_v2') {
|
||||
return {path: path.join(packageSrcDir, 'index.ts')};
|
||||
}
|
||||
const relativePath = args.path.replace(/^@fluxer\/voice_engine_v2\//, '');
|
||||
const directTsPath = path.join(packageSrcDir, `${relativePath}.ts`);
|
||||
if (fs.existsSync(directTsPath)) {
|
||||
return {path: directTsPath};
|
||||
}
|
||||
const indexTsPath = path.join(packageSrcDir, relativePath, 'index.ts');
|
||||
if (fs.existsSync(indexTsPath)) {
|
||||
return {path: indexTsPath};
|
||||
}
|
||||
return {path: path.join(packageSrcDir, relativePath)};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
function findNodeBinary(rootDir) {
|
||||
const matches = [];
|
||||
for (const entry of fs.readdirSync(rootDir)) {
|
||||
@@ -609,7 +569,6 @@ async function buildMain() {
|
||||
minify: isProduction,
|
||||
sourcemap: true,
|
||||
external: electronExternals,
|
||||
plugins: [pathAliasPlugin],
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'),
|
||||
...publicBuildDefines,
|
||||
@@ -628,7 +587,6 @@ async function buildMain() {
|
||||
minify: isProduction,
|
||||
sourcemap: true,
|
||||
external: electronExternals,
|
||||
plugins: [pathAliasPlugin],
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'),
|
||||
...publicBuildDefines,
|
||||
@@ -653,7 +611,6 @@ async function buildPreload() {
|
||||
minify: isProduction,
|
||||
sourcemap: true,
|
||||
external: electronExternals,
|
||||
plugins: [pathAliasPlugin],
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'),
|
||||
...publicBuildDefines,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {BrowserWindow, desktopCapturer, ipcMain, screen} from 'electron';
|
||||
import log from 'electron-log';
|
||||
import {
|
||||
isListOnlyDesktopSourcesOption,
|
||||
isValidDesktopSourceId,
|
||||
isValidDisplayMediaRequestId,
|
||||
normalizeDesktopSourceTypes,
|
||||
shouldHonorSelectedAudio,
|
||||
} from './DisplayMediaValidation';
|
||||
import {startWindowsScreenCaptureGuardForSource} from './WindowsScreenCaptureGuard';
|
||||
} from '@electron/main/DisplayMediaValidation';
|
||||
import {startWindowsScreenCaptureGuardForSource} from '@electron/main/WindowsScreenCaptureGuard';
|
||||
import {BrowserWindow, desktopCapturer, ipcMain, screen} from 'electron';
|
||||
import log from 'electron-log';
|
||||
|
||||
type DisplayMediaPortalSurfacePreference = 'window' | 'monitor';
|
||||
|
||||
|
||||
@@ -10,21 +10,21 @@ import type {
|
||||
VirtmicRoutingGraphResult,
|
||||
VirtmicUnavailableReason,
|
||||
} from '@electron/common/Types';
|
||||
import {buildFluxerAudioExcludePatterns, isFluxerAudioNode} from '@electron/main/FluxerAudioIdentity';
|
||||
import {getLinuxPortalsMode, getNativeAudioMode} from '@electron/main/LaunchOptions';
|
||||
import {app, ipcMain} from 'electron';
|
||||
import {buildFluxerAudioExcludePatterns, isFluxerAudioNode} from './FluxerAudioIdentity';
|
||||
import {
|
||||
isDBusObjectPathSegment,
|
||||
isWaylandSessionEnv,
|
||||
isX11SessionEnv,
|
||||
isX11WindowToken,
|
||||
parseWindowSourceToken,
|
||||
} from './LinuxAudioCaptureHelpers';
|
||||
} from '@electron/main/LinuxAudioCaptureHelpers';
|
||||
import {
|
||||
isValidVirtmicLinkOptions,
|
||||
isValidVirtmicNodeList,
|
||||
isValidVirtmicSystemLinkOptions,
|
||||
} from './NativeAudioValidation';
|
||||
} from '@electron/main/NativeAudioValidation';
|
||||
import {app, ipcMain} from 'electron';
|
||||
|
||||
const logger = createChildLogger('LinuxAudioCapture');
|
||||
const requireModule = createRequire(import.meta.url);
|
||||
|
||||
@@ -14,19 +14,19 @@ import type {
|
||||
VirtmicNode,
|
||||
VirtmicRoutingGraph,
|
||||
} from '@electron/common/Types';
|
||||
import {buildFluxerAudioExcludePatterns, isKnownFluxerAudioProcessPid} from '@electron/main/FluxerAudioIdentity';
|
||||
import {getNativeAudioMode} from '@electron/main/LaunchOptions';
|
||||
import {ipcMain} from 'electron';
|
||||
import {buildFluxerAudioExcludePatterns, isKnownFluxerAudioProcessPid} from './FluxerAudioIdentity';
|
||||
import {resolveVirtmicWindowPid} from './LinuxAudioCapture';
|
||||
import {parseWindowSourceToken as parseDesktopWindowSourceToken} from './LinuxAudioCaptureHelpers';
|
||||
import {getTccStatus} from './MacTcc';
|
||||
import {resolveVirtmicWindowPid} from '@electron/main/LinuxAudioCapture';
|
||||
import {parseWindowSourceToken as parseDesktopWindowSourceToken} from '@electron/main/LinuxAudioCaptureHelpers';
|
||||
import {getTccStatus} from '@electron/main/MacTcc';
|
||||
import {
|
||||
audioFrameDebugDetails,
|
||||
isValidAudioFrame,
|
||||
isValidLinuxRule,
|
||||
isValidTargetPid,
|
||||
normalizeTimestampUs,
|
||||
} from './NativeAudioValidation';
|
||||
} from '@electron/main/NativeAudioValidation';
|
||||
import {ipcMain} from 'electron';
|
||||
|
||||
const logger = createChildLogger('NativeAudio');
|
||||
const requireModule = createRequire(import.meta.url);
|
||||
|
||||
@@ -141,16 +141,16 @@ function loadNativeScreenCapture({platform = 'linux', addon, tccStatus = 'not-de
|
||||
},
|
||||
};
|
||||
}
|
||||
if (specifier === './MacTcc') {
|
||||
if (specifier === '@electron/main/MacTcc') {
|
||||
return {getTccStatus: () => tccStatus};
|
||||
}
|
||||
if (specifier === './NativeScreenCaptureValidation') {
|
||||
if (specifier === '@electron/main/NativeScreenCaptureValidation') {
|
||||
return {
|
||||
isValidStartOptions: () => true,
|
||||
normalizeScreenCaptureDimension: (value) => value,
|
||||
};
|
||||
}
|
||||
if (specifier === './PrivilegedRendererDocuments') {
|
||||
if (specifier === '@electron/main/PrivilegedRendererDocuments') {
|
||||
return {requirePrivilegedRendererDocumentSender: () => {}};
|
||||
}
|
||||
throw new Error(`Unexpected import: ${specifier}`);
|
||||
|
||||
@@ -16,10 +16,10 @@ import type {
|
||||
NativeScreenCaptureStartResult,
|
||||
WindowsHagsState,
|
||||
} from '@electron/common/Types';
|
||||
import {getTccStatus} from '@electron/main/MacTcc';
|
||||
import {isValidStartOptions, normalizeScreenCaptureDimension} from '@electron/main/NativeScreenCaptureValidation';
|
||||
import {requirePrivilegedRendererDocumentSender} from '@electron/main/PrivilegedRendererDocuments';
|
||||
import {ipcMain} from 'electron';
|
||||
import {getTccStatus} from './MacTcc';
|
||||
import {isValidStartOptions, normalizeScreenCaptureDimension} from './NativeScreenCaptureValidation';
|
||||
import {requirePrivilegedRendererDocumentSender} from './PrivilegedRendererDocuments';
|
||||
|
||||
const logger = createChildLogger('NativeScreenCapture');
|
||||
const requireModule = createRequire(import.meta.url);
|
||||
|
||||
@@ -116,7 +116,7 @@ function loadStreamingPriority({
|
||||
if (specifier === 'node:os') return osModule;
|
||||
if (specifier === 'electron') return {app, powerSaveBlocker};
|
||||
if (specifier === 'electron-log') return log;
|
||||
if (specifier === './WindowsScreenCaptureGuard') return guard;
|
||||
if (specifier === '@electron/main/WindowsScreenCaptureGuard') return guard;
|
||||
throw new Error(`Unexpected import: ${specifier}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
import {createRequire} from 'node:module';
|
||||
import os from 'node:os';
|
||||
import {retainWindowsScreenCaptureGuard, stopWindowsScreenCaptureGuard} from '@electron/main/WindowsScreenCaptureGuard';
|
||||
import {app, powerSaveBlocker} from 'electron';
|
||||
import log from 'electron-log';
|
||||
import {retainWindowsScreenCaptureGuard, stopWindowsScreenCaptureGuard} from './WindowsScreenCaptureGuard';
|
||||
|
||||
const STREAMING_PRIORITY = os.constants?.priority?.PRIORITY_ABOVE_NORMAL ?? -7;
|
||||
const CAN_ELEVATE_PROCESS_PRIORITY = process.platform === 'win32';
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"paths": {
|
||||
"@electron/*": ["./src/*"],
|
||||
"@fluxer/voice_engine_v2": ["../packages/voice_engine_v2/src/index.ts"],
|
||||
"@fluxer/voice_engine_v2/*": ["../packages/voice_engine_v2/src/*"]
|
||||
"@fluxer/voice_engine_v2/*": ["../packages/voice_engine_v2/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*", "../packages/voice_engine_v2/src/**/*"],
|
||||
|
||||
Reference in New Issue
Block a user