diff --git a/src/bundle/rewriters/headers.ts b/src/bundle/rewriters/headers.ts index 020e1e6..cef1044 100644 --- a/src/bundle/rewriters/headers.ts +++ b/src/bundle/rewriters/headers.ts @@ -18,6 +18,9 @@ const cspHeaders = [ "x-permitted-cross-domain-policies", "x-powered-by", "x-xss-protection", + // This needs to be emulated, but for right now it isn't that important of a feature to be worried about + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data + "clear-site-data" ]; const urlHeaders = [ diff --git a/src/client/storage.ts b/src/client/storage.ts index 9d6511f..bcec057 100644 --- a/src/client/storage.ts +++ b/src/client/storage.ts @@ -1,12 +1,16 @@ import IDBMapSync from "@webreflection/idb-map/sync"; +const store = new IDBMapSync(window.__location.host, { + prefix: "Storage", + durability: "relaxed" +}); + +await store.sync(); + function storageProxy(scope: Storage): Storage { - const store = new IDBMapSync(window.__location.host); return new Proxy(scope, { - async get(target, prop) { - await store.sync(); - + get(target, prop) { switch (prop) { case "getItem": return (key: string) => { @@ -35,11 +39,14 @@ function storageProxy(scope: Storage): Storage { case "length": return store.size; + + default: + return store.get(prop); } }, defineProperty(target, property, attributes) { - target.setItem(property as string, attributes.value); + store.set(property as string, attributes.value); return true; }, diff --git a/tsconfig.json b/tsconfig.json index 7ac7e40..63f534f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,9 @@ // "allowJs": true, "allowImportingTsExtensions": true, "rootDir": "./src", - "target": "ES2020", + "target": "ES2022", "moduleResolution": "Bundler", + "module": "ES2022", "noEmit": true } } \ No newline at end of file