summaryrefslogtreecommitdiff
path: root/source/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'source/helpers')
-rw-r--r--source/helpers/types.d.ts5
-rw-r--r--source/helpers/used-storage.ts10
2 files changed, 15 insertions, 0 deletions
diff --git a/source/helpers/types.d.ts b/source/helpers/types.d.ts
index 06f4cb80..e3224b49 100644
--- a/source/helpers/types.d.ts
+++ b/source/helpers/types.d.ts
@@ -15,4 +15,9 @@ declare global {
closest<S extends string>(selector: S | readonly S[]): StrictlyParseSelector<S, HTMLElement> | null;
matches(selectors: string | readonly string[]): boolean;
}
+
+ // This cannot be a regular import because it turns `globals.d.ts` in a "module definition", which it isn't
+ type Browser = import('webextension-polyfill').Browser;
+ const browser: Browser;
+
}
diff --git a/source/helpers/used-storage.ts b/source/helpers/used-storage.ts
new file mode 100644
index 00000000..8a95bf18
--- /dev/null
+++ b/source/helpers/used-storage.ts
@@ -0,0 +1,10 @@
+/** `getBytesInUse` polyfill */
+export default async function getStorageBytesInUse(area: 'local' | 'sync'): Promise<any> {
+ const storage = browser.storage[area];
+ // From https://bugzilla.mozilla.org/show_bug.cgi?id=1385832#c20
+ return 'getBytesInUse' in storage ? storage.getBytesInUse() : new TextEncoder().encode(
+ Object.entries(await storage.get())
+ .map(([key, value]) => key + JSON.stringify(value))
+ .join(''),
+ ).length;
+}
>feat/jsx-transform Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/examples/with-tailwindcss (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2021-11-19Version Packages (next) (#1881)astro@0.21.0-next.8@astrojs/renderer-vue@0.2.0-next.2Gravatar github-actions[bot] 1-1/+1
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2021-11-18Improve HMR (#1896)Gravatar Drew Powers 2-10/+18
2021-11-18update depsGravatar Fred K. Schott 5-352/+65
2021-11-18fix #1778Gravatar Fred K. Schott 2-1/+8
2021-11-18Update compiler (#1869)Gravatar Nate Moore 3-11/+6
* chore: update compiler * redeploy * fix(www): ensure www can build * chore: update compiler Co-authored-by: Fred K. Schott <fkschott@gmail.com>
2021-11-18remove unused remark dependency (#1894)Gravatar Fred K. Schott 2-245/+13
2021-11-18Improve error messages (#1875)Gravatar Drew Powers 39-61/+448
* Fix error handling in correct scope Also improve Vite IDs for better module graph lookups * Improve code frame * Add changeset * maybeLoc can be undefined * Add tests Co-authored-by: Matthew Phillips <matthew@skypack.dev>
2021-11-18pin astro compiler to older versionGravatar Fred K. Schott 2-5/+5
2021-11-18Update yarn.lock to reflect the state of the package.json files (#1892)Gravatar Jonathan Neal 5-1300/+1000
* update dependencies * update file to fix build:all
2021-11-19[ci] yarn formatGravatar FredKSchott 1-5/+3