selfstore 1.7.2 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -362,6 +362,24 @@ always branch on `err.code`, never parse error messages; treat
362
362
  design); an empty password means "not encrypted"; collection names starting
363
363
  with `__` are reserved.
364
364
 
365
+ ## Stability
366
+
367
+ The number on the package is not what you are trusting - the file is.
368
+
369
+ **A backup written by any version of selfstore stays readable by every later
370
+ version.** The test suite enforces it, and it holds across majors, not just
371
+ minors. The format is [specified](./SPEC.md) and readable without this library
372
+ at all, including from Python, so leaving is documented rather than promised.
373
+
374
+ For the package itself: semver, with a major reserved for a change that stops
375
+ an app compiling or alters what it already does - a new default counts. Releases
376
+ are deliberate and batched, not one per merge. The rules, and what the version
377
+ history reads like, are in [RELEASING.md](./RELEASING.md).
378
+
379
+ Published versions are never unpublished. A superseded one stays installable;
380
+ the tool for a release that should not be used is `npm deprecate`, and the tool
381
+ for a broken one is the next release.
382
+
365
383
  ## Install
366
384
 
367
385
  ```sh
package/dist/advanced.js CHANGED
@@ -1,4 +1,4 @@
1
- export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache } from './chunk-MZMMOEFW.js';
1
+ export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache } from './chunk-ZV2S3I76.js';
2
2
  export { datedName, pickFromDisk, saveToDisk } from './chunk-53WWPEML.js';
3
3
  import './chunk-SKWHKM25.js';
4
4
  import { FILE_ID_KEY, renameBackup, deleteBackup, createBackup, listBackups, findOrCreateOwnFile, adopt, preview, fromSession, connect, openExisting, isOpenSupported, isSupported, fromSession2, connect2, fromSession4, connect4, peer, fromSession3, connect3 } from './chunk-PK5BFQLI.js';
@@ -177,11 +177,31 @@ function createLocalStore(opts) {
177
177
  const replicaList = [];
178
178
  let chain = Promise.resolve();
179
179
  function serialize(fn) {
180
- const exec = locks ? () => locks.request(lockName, fn) : fn;
180
+ const exec = locks ? () => underLock(fn) : fn;
181
181
  const run = chain.then(exec, exec);
182
182
  chain = run.catch(() => void 0);
183
183
  return run;
184
184
  }
185
+ async function underLock(fn) {
186
+ const giveUp = new AbortController();
187
+ const timer2 = setTimeout(() => giveUp.abort(), LOCK_WAIT_MS);
188
+ let ran = false;
189
+ try {
190
+ return await locks.request(lockName, { signal: giveUp.signal }, () => {
191
+ ran = true;
192
+ clearTimeout(timer2);
193
+ return fn();
194
+ });
195
+ } catch (e) {
196
+ clearTimeout(timer2);
197
+ if (ran || !giveUp.signal.aborted) throw e;
198
+ lastError = transient("Another tab is holding the store; continuing without it.");
199
+ logger.warn(`[selfstore] cross-tab lock "${lockName}" unavailable, proceeding without it`);
200
+ notify();
201
+ return fn();
202
+ }
203
+ }
204
+ const LOCK_WAIT_MS = 1e4;
185
205
  const IDLE_LOCK_MS = 30 * 60 * 1e3;
186
206
  const durableKind = () => !isReservedStoreMode(targetKind);
187
207
  const subs = /* @__PURE__ */ new Set();
@@ -2030,5 +2050,5 @@ function gisDriveAuth(opts) {
2030
2050
  }
2031
2051
 
2032
2052
  export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache };
2033
- //# sourceMappingURL=chunk-MZMMOEFW.js.map
2034
- //# sourceMappingURL=chunk-MZMMOEFW.js.map
2053
+ //# sourceMappingURL=chunk-ZV2S3I76.js.map
2054
+ //# sourceMappingURL=chunk-ZV2S3I76.js.map