From 531cc7273cbbb49f9fd6d595e8314335136ece98 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Sat, 15 Mar 2025 01:23:54 -0500 Subject: [PATCH] add basic opfs support --- src/client/shared/opfs.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/client/shared/opfs.ts b/src/client/shared/opfs.ts index 33f400e..81744f3 100644 --- a/src/client/shared/opfs.ts +++ b/src/client/shared/opfs.ts @@ -3,9 +3,18 @@ import { ScramjetClient } from "../client"; export default function (client: ScramjetClient, self: Self) { client.Proxy("StorageManager.prototype.getDirectory", { apply(ctx) { - const directory = ctx.call() as FileSystemDirectoryHandle; + const directoryPromise = ctx.call() as Promise; ctx.return( - directory.getDirectoryHandle(client.url.origin, { create: true }) + (async () => { + const directory = await directoryPromise; + + return directory.getDirectoryHandle( + `${client.url.hostname.replace(/\/|\s|\./g, "-")}`, + { + create: true, + } + ); + })() ); }, });