mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20:02 -04:00
add basic opfs support
This commit is contained in:
parent
3cd17070ab
commit
531cc7273c
1 changed files with 11 additions and 2 deletions
|
@ -3,9 +3,18 @@ import { ScramjetClient } from "../client";
|
||||||
export default function (client: ScramjetClient, self: Self) {
|
export default function (client: ScramjetClient, self: Self) {
|
||||||
client.Proxy("StorageManager.prototype.getDirectory", {
|
client.Proxy("StorageManager.prototype.getDirectory", {
|
||||||
apply(ctx) {
|
apply(ctx) {
|
||||||
const directory = ctx.call() as FileSystemDirectoryHandle;
|
const directoryPromise = ctx.call() as Promise<FileSystemDirectoryHandle>;
|
||||||
ctx.return(
|
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,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})()
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue