mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-03-25 16:48:50 +08:00
feat(native): windows audio monitoring & recording (#12615)
fix AF-2692 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added comprehensive Windows support for audio and application capture, including real-time microphone usage detection, combined microphone and system audio recording, and application state monitoring. - The "meetings" setting is now enabled on Windows as well as macOS. - Conditional UI styling and attributes introduced for Windows environments in the Electron renderer. - **Bug Fixes** - Enhanced file path handling and validation for Windows in Electron file requests. - **Refactor** - Unified application info handling across platforms by consolidating types into a single `ApplicationInfo` structure. - Updated native module APIs by removing deprecated types, refining method signatures, and improving error messages. - Streamlined audio tapping APIs to use process IDs and consistent callback types. - **Documentation** - Added detailed documentation for the Windows-specific audio recording and microphone listener modules. - **Chores** - Updated development dependencies in multiple packages. - Reorganized and added platform-specific dependencies and configuration for Windows support. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #12615** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) --------- Co-authored-by: LongYinan <lynweklm@gmail.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { join } from 'node:path';
|
||||
import path, { join } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
import { app, net, protocol, session } from 'electron';
|
||||
import cookieParser from 'set-cookie-parser';
|
||||
|
||||
import { resourcesPath } from '../shared/utils';
|
||||
import { isWindows, resourcesPath } from '../shared/utils';
|
||||
import { anotherHost, mainHost } from './constants';
|
||||
import { logger } from './logger';
|
||||
|
||||
@@ -77,17 +78,23 @@ async function handleFileRequest(request: Request) {
|
||||
}
|
||||
} else {
|
||||
filepath = decodeURIComponent(urlObject.pathname);
|
||||
// on windows, the path could be start with '/'
|
||||
if (isWindows()) {
|
||||
filepath = path.resolve(filepath.replace(/^\//, ''));
|
||||
}
|
||||
// security check if the filepath is within app.getPath('sessionData')
|
||||
const sessionDataPath = app.getPath('sessionData');
|
||||
const tempPath = app.getPath('temp');
|
||||
const sessionDataPath = path
|
||||
.resolve(app.getPath('sessionData'))
|
||||
.toLowerCase();
|
||||
const tempPath = path.resolve(app.getPath('temp')).toLowerCase();
|
||||
if (
|
||||
!filepath.startsWith(sessionDataPath) &&
|
||||
!filepath.startsWith(tempPath)
|
||||
!filepath.toLowerCase().startsWith(sessionDataPath) &&
|
||||
!filepath.toLowerCase().startsWith(tempPath)
|
||||
) {
|
||||
throw new Error('Invalid filepath');
|
||||
}
|
||||
}
|
||||
return net.fetch('file://' + filepath, clonedRequest);
|
||||
return net.fetch(pathToFileURL(filepath).toString(), clonedRequest);
|
||||
}
|
||||
|
||||
export function registerProtocol() {
|
||||
|
||||
Reference in New Issue
Block a user