mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
nuke getlocalstorage thing
This commit is contained in:
parent
0edb4fcecf
commit
e1d654472e
1 changed files with 0 additions and 47 deletions
|
@ -55,53 +55,6 @@ export class ScramjetServiceWorker extends EventTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLocalStorage(): Promise<Record<string, string>> {
|
|
||||||
let clients = await self.clients.matchAll();
|
|
||||||
clients = clients.filter(
|
|
||||||
(client) =>
|
|
||||||
client.type === "window" &&
|
|
||||||
!new URL(client.url).pathname.startsWith(this.config.prefix)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (clients.length === 0) throw new Error("No clients found");
|
|
||||||
|
|
||||||
const token = this.synctoken++;
|
|
||||||
for (const client of clients) {
|
|
||||||
client.postMessage({
|
|
||||||
scramjet$type: "getLocalStorage",
|
|
||||||
scramjet$token: token,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
this.syncPool[token] = resolve;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async setLocalStorage(data: Record<string, string>): Promise<void> {
|
|
||||||
let clients = await self.clients.matchAll();
|
|
||||||
clients = clients.filter(
|
|
||||||
(client) =>
|
|
||||||
client.type === "window" &&
|
|
||||||
!new URL(client.url).pathname.startsWith(this.config.prefix)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (clients.length === 0) throw new Error("No clients found");
|
|
||||||
|
|
||||||
const token = this.synctoken++;
|
|
||||||
for (const client of clients) {
|
|
||||||
client.postMessage({
|
|
||||||
scramjet$type: "setLocalStorage",
|
|
||||||
scramjet$token: token,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
this.syncPool[token] = resolve;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
route({ request }: FetchEvent) {
|
route({ request }: FetchEvent) {
|
||||||
if (request.url.startsWith(location.origin + this.config.prefix))
|
if (request.url.startsWith(location.origin + this.config.prefix))
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue