mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fixed the rendering
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
GOOSE_SESSION_PARTITION,
|
||||
PACKAGED_RENDERER_ORIGIN,
|
||||
packagedRendererUrl,
|
||||
rendererContentType,
|
||||
@@ -10,6 +11,7 @@ import {
|
||||
describe('appProtocol', () => {
|
||||
it('uses the packaged renderer app origin', () => {
|
||||
expect(PACKAGED_RENDERER_ORIGIN).toBe('goose-app://goose');
|
||||
expect(GOOSE_SESSION_PARTITION).toBe('persist:goose');
|
||||
expect(packagedRendererUrl().toString()).toBe('goose-app://goose/index.html');
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import path from 'node:path';
|
||||
export const PACKAGED_RENDERER_PROTOCOL = 'goose-app';
|
||||
export const PACKAGED_RENDERER_HOST = 'goose';
|
||||
export const PACKAGED_RENDERER_ORIGIN = `${PACKAGED_RENDERER_PROTOCOL}://${PACKAGED_RENDERER_HOST}`;
|
||||
export const GOOSE_SESSION_PARTITION = 'persist:goose';
|
||||
|
||||
export function packagedRendererUrl(): URL {
|
||||
return new URL(`${PACKAGED_RENDERER_ORIGIN}/index.html`);
|
||||
|
||||
+22
-19
@@ -56,6 +56,7 @@ import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-insta
|
||||
import { BLOCKED_PROTOCOLS, WEB_PROTOCOLS } from './utils/urlSecurity';
|
||||
import { buildCSP } from './utils/csp';
|
||||
import {
|
||||
GOOSE_SESSION_PARTITION,
|
||||
PACKAGED_RENDERER_ORIGIN,
|
||||
PACKAGED_RENDERER_PROTOCOL,
|
||||
packagedRendererUrl,
|
||||
@@ -848,23 +849,25 @@ function registerPackagedRendererProtocol() {
|
||||
return;
|
||||
}
|
||||
|
||||
protocol.handle(PACKAGED_RENDERER_PROTOCOL, async (request) => {
|
||||
const filePath = resolvePackagedRendererPath(request.url, getPackagedRendererRoot());
|
||||
if (!filePath) {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
session
|
||||
.fromPartition(GOOSE_SESSION_PARTITION)
|
||||
.protocol.handle(PACKAGED_RENDERER_PROTOCOL, async (request) => {
|
||||
const filePath = resolvePackagedRendererPath(request.url, getPackagedRendererRoot());
|
||||
if (!filePath) {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await fs.readFile(filePath);
|
||||
return new Response(new Uint8Array(data), {
|
||||
headers: {
|
||||
'Content-Type': rendererContentType(filePath),
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
});
|
||||
try {
|
||||
const data = await fs.readFile(filePath);
|
||||
return new Response(new Uint8Array(data), {
|
||||
headers: {
|
||||
'Content-Type': rendererContentType(filePath),
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
});
|
||||
packagedRendererProtocolRegistered = true;
|
||||
}
|
||||
|
||||
@@ -1316,7 +1319,7 @@ const createChat = async (
|
||||
process.env.SECURITY_COMMAND_CLASSIFIER_ENABLED_OVERRIDE,
|
||||
}),
|
||||
],
|
||||
partition: 'persist:goose',
|
||||
partition: GOOSE_SESSION_PARTITION,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -1582,7 +1585,7 @@ const createLauncher = () => {
|
||||
GOOSE_LOCALE: getConfiguredGooseLocale(),
|
||||
}),
|
||||
],
|
||||
partition: 'persist:goose',
|
||||
partition: GOOSE_SESSION_PARTITION,
|
||||
},
|
||||
skipTaskbar: true,
|
||||
alwaysOnTop: true,
|
||||
@@ -3048,7 +3051,7 @@ async function appMain() {
|
||||
GOOSE_VERSION: version,
|
||||
}),
|
||||
],
|
||||
partition: 'persist:goose',
|
||||
partition: GOOSE_SESSION_PARTITION,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user