@@ -12,25 +12,24 @@ import {
1212 TASK_EXTRACTION_PROMPT ,
1313} from "./transcription-prompts.js" ;
1414
15- let FileConstructor : typeof File ;
16- try {
17- const { File : NodeFile } = await import ( "node:buffer" ) ;
18- FileConstructor = NodeFile as typeof File ;
19- } catch {
20- FileConstructor = class File extends Blob {
21- name : string ;
22- lastModified : number ;
23-
24- constructor ( bits : BlobPart [ ] , name : string , options ?: FilePropertyBag ) {
25- super ( bits , options ) ;
26- this . name = name ;
27- this . lastModified = options ?. lastModified ?? Date . now ( ) ;
28- }
29- } as typeof File ;
30- }
15+ async function ensureFileConstructor ( ) : Promise < void > {
16+ if ( globalThis . File ) return ;
3117
32- if ( ! globalThis . File ) {
33- globalThis . File = FileConstructor ;
18+ try {
19+ const { File : NodeFile } = await import ( "node:buffer" ) ;
20+ globalThis . File = NodeFile as typeof File ;
21+ } catch {
22+ globalThis . File = class File extends Blob {
23+ name : string ;
24+ lastModified : number ;
25+
26+ constructor ( bits : BlobPart [ ] , name : string , options ?: FilePropertyBag ) {
27+ super ( bits , options ) ;
28+ this . name = name ;
29+ this . lastModified = options ?. lastModified ?? Date . now ( ) ;
30+ }
31+ } as typeof File ;
32+ }
3433}
3534
3635interface RecordingSession {
@@ -139,6 +138,8 @@ function safeLog(...args: unknown[]): void {
139138}
140139
141140export function registerRecordingIpc ( ) : void {
141+ ensureFileConstructor ( ) ;
142+
142143 ipcMain . handle (
143144 "desktop-capturer:get-sources" ,
144145 async ( _event , options : { types : ( "screen" | "window" ) [ ] } ) => {
0 commit comments