state:State = (new Proxy(overlay, {/** Give defaults if overlay doesn't have the key */get(target, property) {if (property in target) {return target[property]} else {return defaults[property]}},/** Persist sets to storage "immediately" */set(target, property, value) {locks.withlock("state", async () => {logger.debug("State changed!", property, value)target[property] = valuebrowser.storage.local.set({ state: target } as any)// Wait for reply from each script to say that they have updated their own stateawait Promise.all([// dispatch message to all content state.ts'smessaging.messageAllTabs("state", "stateUpdate", [{state: target}]),// Ideally this V would use Farnoy's typed messages but// I haven't had time to get my head around thembrowser.runtime.sendMessage({type: "state", command: "stateUpdate", args: [{state: target}]}),])})return true},}))