@@ -35,8 +35,14 @@ if (!fs.existsSync(profilePath)) fs.mkdirSync(profilePath);
3535
3636
3737let server = null
38+ let localServerUrl = null ;
3839
3940function startLocalServer ( ) {
41+ // so this is needed because with file:// we get some shitty ass
42+ // issues. because i wrote this comment some time later i already forgot
43+ // the exact error, but it was shit like cors errors etc, which is resolved
44+ // by doing it this way.
45+
4046 return new Promise ( ( resolve ) => {
4147 const web = express ( )
4248 const publicDir = path . join ( __dirname , "web" )
@@ -48,7 +54,12 @@ function startLocalServer() {
4854
4955 server = web . listen ( 0 , "127.0.0.1" , ( ) => {
5056 const { port } = server . address ( )
51- resolve ( `http://127.0.0.1:${ port } ` )
57+ let address = `http://127.0.0.1:${ port } ` ;
58+
59+ // used later
60+ localServerUrl = address ;
61+
62+ resolve ( address )
5263 } )
5364 } )
5465}
@@ -78,11 +89,15 @@ function registerWindowBoundsPersistence(win) {
7889}
7990
8091async function createWindow ( width , height ) {
92+ let localUrl = await startLocalServer ( ) ;
93+
8194 // installing multiple packages
8295 const results = await FrontendLibs . installMultiple ( [
8396 { package : '@hackthedev/icons@latest' , path : libDir } ,
97+ { package : '@hackthedev/element-loader@latest' , path : libDir } ,
8498 { package : '@hackthedev/mobile-ui@latest' , path : libDir } ,
8599 { package : '@hackthedev/prompts@latest' , path : libDir } ,
100+ { package : '@hackthedev/file-manager' , path : libDir } ,
86101 { package : '@hackthedev/rich-editor' , path : libDir } ,
87102 { package : '@hackthedev/json-editor' , path : libDir } ,
88103 { package : '@hackthedev/chat-tools@1.0.0' , path : libDir } ,
@@ -111,7 +126,10 @@ async function createWindow(width, height) {
111126 sandbox : false ,
112127 devTools : true ,
113128 webviewTag : true ,
114- additionalArguments : [ "--appdata=" + applicationDataDir ] ,
129+ additionalArguments : [
130+ "--appdata=" + applicationDataDir ,
131+ "--localServerUrl=" + localServerUrl ,
132+ ] ,
115133 } ,
116134 } ) ;
117135
@@ -139,7 +157,6 @@ async function createWindow(width, height) {
139157 }
140158 )
141159
142- let localUrl = await startLocalServer ( ) ;
143160 await win . loadURL ( localUrl )
144161 //win.loadFile(path.join(__dirname, "web/index.html"));
145162}
@@ -172,6 +189,8 @@ app.commandLine.appendSwitch(
172189
173190app . whenReady ( ) . then ( async ( ) => {
174191 // Check for fucking update
192+
193+ /* Commented out for now as it needs a bit more work to work fine with linux too etc
175194 let updateCheck = await AppUpdater.check("https://dcts.community/app/electron", {
176195 includeOsUrl: true,
177196 version: app.getVersion()
@@ -226,10 +245,13 @@ app.whenReady().then(async () => {
226245 }
227246 }
228247
248+ */
249+
229250
230251 await Settings . initSettings ( applicationDataDir ) ;
231252
232- // youtube embed fix — header spoofing
253+ // youtube embed fix - header spoofing or some shit.
254+ // it semi works?? still need to figure this shit out more
233255 session . defaultSession . webRequest . onBeforeSendHeaders (
234256 { urls : [ '*://*.youtube-nocookie.com/*' , '*://*.youtube.com/*' , '*://*.googlevideo.com/*' , '*://*.ytimg.com/*' ] } ,
235257 ( details , callback ) => {
@@ -242,13 +264,19 @@ app.whenReady().then(async () => {
242264 const primaryDisplay = screen . getPrimaryDisplay ( ) ;
243265 const { width, height} = primaryDisplay . workAreaSize ;
244266
245- session . defaultSession . setDisplayMediaRequestHandler ( ( request , callback ) => {
246- desktopCapturer
247- . getSources ( { types : [ "window" , "screen" ] } )
248- . then ( ( sources ) => {
249- callback ( { video : sources [ 0 ] } ) ;
250- } ) ;
251- } )
267+ // until there is a better solution.
268+ // i had the idea of possibly adding some display fetching and selecting inside
269+ // the web frontend itself to then just tell the backend (electron) which screen
270+ // to use exactly. Just some idea for now tho.
271+ if ( isLinux ) {
272+ session . defaultSession . setDisplayMediaRequestHandler ( ( request , callback ) => {
273+ desktopCapturer
274+ . getSources ( { types : [ "window" , "screen" ] } )
275+ . then ( ( sources ) => {
276+ callback ( { video : sources [ 0 ] } ) ;
277+ } ) ;
278+ } )
279+ }
252280
253281 await createWindow (
254282 1080 ,
0 commit comments