diff --git a/desktop/src/main.ts b/desktop/src/main.ts index 8526e2363..72e2b8233 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -132,12 +132,43 @@ const registerPrivilegedSchemes = () => { // TODO(MR): Remove the commented bits if we don't end up // needing them by the time the IPC refactoring is done. - // Prevent the insecure origin issues when fetching this + // standard: true, + // // Prevent the insecure origin issues when fetching this // secure: true, - // Allow the web fetch API in the renderer to use this scheme. - supportFetchAPI: true, - // Allow it to be used with video tags. + // // Allow the web fetch API in the renderer to use this scheme. + // supportFetchAPI: true, + // // Allow it to be used with video tags. // stream: true, + standard: true, + /** + * Default false. + */ + secure: true, + /** + * Default false. + */ + bypassCSP: true, + /** + * Default false. + */ + allowServiceWorkers: true, + /** + * Default false. + */ + supportFetchAPI: true, + /** + * Default false. + */ + corsEnabled: true, + /** + * Default false. + */ + stream: true, + /** + * Enable V8 code cache for the scheme, only works when `standard` is also set to + * true. Default false. + */ + codeCache: true, }, }, ]); diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 91934059b..0176a2b7c 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -15,6 +15,10 @@ * @param stream The stream which should be written into the file. * */ export const writeStream = async (path: string, stream: ReadableStream) => { + writeStream_1("/tmp/1.txt", testStream()); +}; + +export const writeStream_1 = async (path: string, stream: ReadableStream) => { // return writeStreamOneShot(path, stream) // The duplex parameter needs to be set to 'half' when streaming requests. @@ -26,7 +30,10 @@ export const writeStream = async (path: string, stream: ReadableStream) => { const req = new Request(`stream://write${path}`, { // GET can't have a body method: "POST", - headers: { "Content-Type": "application/octet-stream" }, + headers: { + "Content-Type": "application/octet-stream", + "Content-Length": "1128608", + }, body: stream, // @ts-expect-error TypeScript's libdom.d.ts does not include the // "duplex" parameter, e.g. see @@ -40,6 +47,38 @@ export const writeStream = async (path: string, stream: ReadableStream) => { ); }; +const testStream = () => { + return new ReadableStream({ + async start(controller) { + const send = (count: number, char: string) => + controller.enqueue( + new TextEncoder().encode(Array(count).fill(char).join("")), + ); + + send(65536, "1"); + send(65536, "2"); + send(65536, "3"); + send(65536, "4"); + send(65536, "5"); + send(65536, "6"); + send(65536, "7"); + send(65536, "8"); + send(65536, "9"); + send(65536, "1"); + send(65536, "2"); + send(65536, "3"); + send(65536, "4"); + send(65536, "5"); + send(65536, "6"); + send(65536, "7"); + send(65536, "8"); + send(14496, "9"); + + controller.close(); + }, + }); +}; + export const writeStreamOneShot = async ( path: string, stream: ReadableStream,