mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 15:40:02 -04:00
zoops
This commit is contained in:
parent
4ac0fce534
commit
8666196db3
2 changed files with 5 additions and 4 deletions
|
@ -45,6 +45,7 @@ export class ScramjetClient {
|
||||||
documentProxy: any;
|
documentProxy: any;
|
||||||
windowProxy: any;
|
windowProxy: any;
|
||||||
locationProxy: any;
|
locationProxy: any;
|
||||||
|
serviceWorker: ServiceWorkerContainer;
|
||||||
|
|
||||||
cookieStore = new CookieStore();
|
cookieStore = new CookieStore();
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ export class ScramjetClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
|
this.serviceWorker = navigator.serviceWorker;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const context = import.meta.webpackContext(".", {
|
const context = import.meta.webpackContext(".", {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { ScramjetClient } from "../client";
|
import { ScramjetClient } from "../client";
|
||||||
|
|
||||||
export default function (client: ScramjetClient, self: typeof window) {
|
export default function (client: ScramjetClient, self: typeof window) {
|
||||||
client.serviceworker.addEventListener("message", ({ data }) => {
|
client.serviceWorker.addEventListener("message", ({ data }) => {
|
||||||
if (!("scramjet$type" in data)) return;
|
if (!("scramjet$type" in data)) return;
|
||||||
|
|
||||||
if (data.scramjet$type === "cookie") {
|
if (data.scramjet$type === "cookie") {
|
||||||
this.cookieStore.setCookies([data.cookie], new URL(data.url));
|
client.cookieStore.setCookies([data.cookie], new URL(data.url));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -17,8 +17,7 @@ export default function (client: ScramjetClient, self: typeof window) {
|
||||||
set(ctx, value: string) {
|
set(ctx, value: string) {
|
||||||
client.cookieStore.setCookies([value], client.url);
|
client.cookieStore.setCookies([value], client.url);
|
||||||
|
|
||||||
// TODO hardcode because scoping whatever
|
client.serviceWorker.controller!.postMessage({
|
||||||
client.serviceworker.controller!.postMessage({
|
|
||||||
scramjet$type: "cookie",
|
scramjet$type: "cookie",
|
||||||
cookie: value,
|
cookie: value,
|
||||||
url: client.url.href,
|
url: client.url.href,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue