chore(deps): Replace async-mutex with superlock (#2529)

This commit is contained in:
Aaron
2026-07-29 09:12:36 -05:00
committed by GitHub
parent 8570ce29b0
commit acc4cdec07
6 changed files with 14 additions and 13 deletions
Generated
+4 -4
View File
@@ -233,8 +233,8 @@
"version": "1.2.8",
"dependencies": {
"@wxt-dev/browser": "workspace:^",
"async-mutex": "^0.5.0",
"dequal": "^2.0.3",
"superlock": "^1.3.2",
},
"devDependencies": {
"@aklinker1/buildc": "catalog:",
@@ -300,7 +300,6 @@
"@webext-core/match-patterns": "^2.0.0",
"@wxt-dev/browser": "workspace:^",
"@wxt-dev/storage": "workspace:^1.0.0",
"async-mutex": "^0.5.0",
"c12": "^3.3.4",
"cac": "^6.7.14 || ^7.0.0",
"chokidar": "^5.0.0",
@@ -325,6 +324,7 @@
"picomatch": "^4.0.3",
"publish-browser-extension": "^5.1.0 || ^6.0.0",
"scule": "^1.3.0",
"superlock": "^1.3.2",
"tiny-open": "^1.3.0",
"tinyglobby": "^0.2.16",
"unimport": "^3.13.1 || ^4.0.0 || ^5.0.0 || ^6.0.0",
@@ -1320,8 +1320,6 @@
"async": ["async@3.2.6", "", {}, "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA=="],
"async-mutex": ["async-mutex@0.5.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA=="],
"atomic-sleep": ["atomic-sleep@1.0.0", "", {}, "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ=="],
"atomically": ["atomically@2.1.1", "", { "dependencies": { "stubborn-fs": "^2.0.0", "when-exit": "^2.1.4" } }, "sha512-P4w9o2dqARji6P7MHprklbfiArZAWvo07yW7qs3pdljb3BWr12FIB7W+p0zJiuiVsUpRO0iZn1kFFcpPegg0tQ=="],
@@ -2298,6 +2296,8 @@
"superjson": ["superjson@2.2.6", "", { "dependencies": { "copy-anything": "^4" } }, "sha512-H+ue8Zo4vJmV2nRjpx86P35lzwDT3nItnIsocgumgr0hHMQ+ZGq5vrERg9kJBo5AWGmxZDhzDo+WVIJqkB0cGA=="],
"superlock": ["superlock@1.3.2", "", {}, "sha512-bLQRyrv/rT9ACCjPWyJJaE2+EMciIjnbiGWf2PHT1UoQYkoMfRJgTqLJedy16g8Q8xK5lZFRAl1devVxp4opjA=="],
"supports-color": ["supports-color@7.2.0", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="],
"svelte": ["svelte@5.50.2", "", { "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", "@sveltejs/acorn-typescript": "^1.0.5", "@types/estree": "^1.0.5", "acorn": "^8.12.1", "aria-query": "^5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", "devalue": "^5.6.2", "esm-env": "^1.2.1", "esrap": "^2.2.2", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", "zimmerframe": "^1.1.2" } }, "sha512-WCxzm3BBf+Ase6RwiDPR4G36cM4Kb0NuhmLK6x44I+D6reaxizDDg8kBkk4jT/19+Rgmc44eZkOvMO6daoSFIw=="],
+1
View File
@@ -106,6 +106,7 @@ words:
- solidjs
- styl
- subdependency
- superlock
- tabstrip
- teleporting
- topcli
+2 -2
View File
@@ -33,8 +33,8 @@
},
"dependencies": {
"@wxt-dev/browser": "workspace:^",
"async-mutex": "^0.5.0",
"dequal": "^2.0.3"
"dequal": "^2.0.3",
"superlock": "^1.3.2"
},
"devDependencies": {
"@aklinker1/buildc": "catalog:",
+3 -3
View File
@@ -7,7 +7,7 @@
* @module @wxt-dev/storage
*/
import { browser, type Browser } from '@wxt-dev/browser';
import { Mutex } from 'async-mutex';
import { withLock } from 'superlock';
import { dequal } from 'dequal/lite';
export const storage = createStorage();
@@ -487,12 +487,12 @@ function createStorage(): WxtStorage {
);
});
const initMutex = new Mutex();
const initLock = withLock();
const getFallback = () => opts?.fallback ?? opts?.defaultValue ?? null;
const getOrInitValue = () =>
initMutex.runExclusive(async () => {
initLock(async () => {
const value = await driver.getItem<any>(driverKey);
// Don't init value if it already exists or the init function isn't provided
if (value != null || opts?.init == null) return value;
+1 -1
View File
@@ -23,7 +23,6 @@
"@webext-core/match-patterns": "^2.0.0",
"@wxt-dev/browser": "workspace:^",
"@wxt-dev/storage": "workspace:^1.0.0",
"async-mutex": "^0.5.0",
"c12": "^3.3.4",
"cac": "^6.7.14 || ^7.0.0",
"chokidar": "^5.0.0",
@@ -48,6 +47,7 @@
"picomatch": "^4.0.3",
"publish-browser-extension": "^5.1.0 || ^6.0.0",
"scule": "^1.3.0",
"superlock": "^1.3.2",
"tiny-open": "^1.3.0",
"tinyglobby": "^0.2.16",
"unimport": "^3.13.1 || ^4.0.0 || ^5.0.0 || ^6.0.0"
@@ -1,4 +1,4 @@
import { Mutex } from 'async-mutex';
import { withLock } from 'superlock';
import { relative } from 'node:path';
import {
BuildOutput,
@@ -30,12 +30,12 @@ import { normalizePath } from './paths';
* when a file changes.
*/
export function createFileReloader(server: WxtDevServer) {
const fileChangedMutex = new Mutex();
const fileChangedLock = withLock();
const changeQueue: Array<[string, string]> = [];
let processLoop: Promise<void> | undefined;
const processQueue = async () => {
const reloading = fileChangedMutex.runExclusive(async () => {
const reloading = fileChangedLock(async () => {
const fileChanges = changeQueue
.splice(0, changeQueue.length)
.map(([_, file]) => file);