selfstore 1.8.29 → 1.8.30

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.
@@ -1,12 +1,12 @@
1
- import { B as BackupTarget } from './store-CKGrIFQU.js';
2
- export { A as AuthExpiredError, f as BuiltinTargetKind, E as EncodeOptions, H as Header, K as KdfParams, L as LocalStore, g as LocalStoreOptions, e as LocalStoreState, M as MirrorState, h as Mode, i as PasswordCheck, b as PasswordPolicy, j as PasswordRequirement, P as PeerSource, k as PeerState, R as RESERVED_COLLECTION_PREFIX, l as RESERVED_STORE_MODES, m as RecipientStanza, n as ReplicaState, o as SelfstoreError, p as SelfstoreErrorCode, q as Severity, a as Snapshot, c as SnapshotFile, r as StatusAction, d as StatusDescriptor, s as StatusInput, t as StorageState, S as StoreError, u as StoreGroupConfig, v as SyncJournalEntry, w as SyncSource, T as TargetKind, x as checkPasswordPolicy, y as createLocalStore, z as deriveStatus, C as errorLabelKey, D as isAuthExpired, F as isReservedStoreMode, G as isSelfstoreError } from './store-CKGrIFQU.js';
1
+ import { B as BackupTarget } from './store-CZOqxDj5.js';
2
+ export { A as AuthExpiredError, f as BuiltinTargetKind, E as EncodeOptions, H as Header, K as KdfParams, L as LocalStore, g as LocalStoreOptions, e as LocalStoreState, M as MirrorState, h as Mode, i as PasswordCheck, b as PasswordPolicy, j as PasswordRequirement, P as PeerSource, k as PeerState, R as RESERVED_COLLECTION_PREFIX, l as RESERVED_STORE_MODES, m as RecipientStanza, n as ReplicaState, o as SelfstoreError, p as SelfstoreErrorCode, q as Severity, a as Snapshot, c as SnapshotFile, r as StatusAction, d as StatusDescriptor, s as StatusInput, t as StorageState, S as StoreError, u as StoreGroupConfig, v as SyncJournalEntry, w as SyncSource, T as TargetKind, x as checkPasswordPolicy, y as createLocalStore, z as deriveStatus, C as errorLabelKey, D as isAuthExpired, F as isReservedStoreMode, G as isSelfstoreError } from './store-CZOqxDj5.js';
3
3
  import { K as KV } from './cache-ilsK3Tki.js';
4
4
  export { C as CachedFile, L as LocalCache, e as LockableCache, i as indexedDbCache, f as isLockableCache, m as memoryCache } from './cache-ilsK3Tki.js';
5
- export { G as GisDriveAuthOptions, a as GisTokenPersistence, d as datedName, e as exportSnapshot, g as gisDriveAuth, i as importSnapshot, b as inspect, c as isEncrypted, p as pickFromDisk, f as preloadGoogleIdentity, s as saveToDisk } from './local-ClXq1N2M.js';
6
- import { c as connect$2, f as fromSession$2, a as connect$3, b as fromSession$3, p as peer } from './s3-dG1SCnV1.js';
7
- export { S as S3Config, d as S3ConnectOptions, W as WebdavConfig, e as WebdavConnectOptions, g as WebdavPeerOptions } from './s3-dG1SCnV1.js';
8
- import { c as connect$1, f as fromSession$1, p as preview, b as adopt, d as findOrCreateOwnFile, l as listBackups, e as createBackup, g as deleteBackup, r as renameBackup, h as account, i as createCompanion, s as share, u as unshare, o as owner, j as secondary } from './drive--mndByvF.js';
9
- export { k as DriveAccount, a as DriveAuth, m as DriveBackupInfo, D as DriveOptions } from './drive--mndByvF.js';
5
+ export { G as GisDriveAuthOptions, a as GisTokenPersistence, d as datedName, e as exportSnapshot, g as gisDriveAuth, i as importSnapshot, b as inspect, c as isEncrypted, p as pickFromDisk, f as preloadGoogleIdentity, s as saveToDisk } from './local-CGYx16zM.js';
6
+ import { c as connect$2, f as fromSession$2, a as connect$3, b as fromSession$3, p as peer } from './s3-iiFYjype.js';
7
+ export { S as S3Config, d as S3ConnectOptions, W as WebdavConfig, e as WebdavConnectOptions, g as WebdavPeerOptions } from './s3-iiFYjype.js';
8
+ import { c as connect$1, f as fromSession$1, p as preview, b as adopt, d as findOrCreateOwnFile, l as listBackups, e as createBackup, g as deleteBackup, r as renameBackup, h as account, i as createCompanion, s as share, u as unshare, o as owner, j as secondary } from './drive-DvnzpjLM.js';
9
+ export { k as DriveAccount, a as DriveAuth, m as DriveBackupInfo, D as DriveOptions } from './drive-DvnzpjLM.js';
10
10
  import './sync.js';
11
11
 
12
12
  /**
package/dist/advanced.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { peer, fromSession as fromSession$3, connect as connect$3 } from './chunk-GHSHIDF3.js';
2
2
  import { fromSession as fromSession$2, connect as connect$2 } from './chunk-IDW3WQKF.js';
3
- export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache, preloadGoogleIdentity } from './chunk-OCWNUAXV.js';
3
+ export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache, preloadGoogleIdentity } from './chunk-TB3CKC6Z.js';
4
4
  import './chunk-GSZSZGSD.js';
5
5
  export { datedName, pickFromDisk, saveToDisk } from './chunk-Q3NO477P.js';
6
6
  import './chunk-FJGWTBAL.js';
package/dist/backups.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { B as BackupsHost } from './manager-yCM0M0FL.js';
2
- export { a as BackupFileInfo, b as BackupOwner, c as BackupRow, d as BackupsErrorCode, e as BackupsKeys, f as BackupsManager, g as BackupsNaming, h as BackupsSnapshot, K as KnownBackups, i as createBackupsManager } from './manager-yCM0M0FL.js';
3
- import { D as DriveOptions } from './drive--mndByvF.js';
1
+ import { B as BackupsHost } from './manager-B-gb3lIn.js';
2
+ export { a as BackupFileInfo, b as BackupOwner, c as BackupRow, d as BackupsErrorCode, e as BackupsKeys, f as BackupsManager, g as BackupsNaming, h as BackupsSnapshot, K as KnownBackups, i as createBackupsManager } from './manager-B-gb3lIn.js';
3
+ import { D as DriveOptions } from './drive-DvnzpjLM.js';
4
4
  import './cache-ilsK3Tki.js';
5
- import './store-CKGrIFQU.js';
5
+ import './store-CZOqxDj5.js';
6
6
  import './sync.js';
7
7
  import './machine-ALMkT3mk.js';
8
8
 
@@ -46,6 +46,14 @@ function deriveStatus(input) {
46
46
  labelKey: "status.pendingDownload"
47
47
  };
48
48
  }
49
+ if (isDurableKind(input.targetKind) && input.unsent) {
50
+ return {
51
+ state: "cache-only",
52
+ severity: "warn",
53
+ actionable: false,
54
+ labelKey: "status.unsent"
55
+ };
56
+ }
49
57
  if (input.targetKind === "device") {
50
58
  if (input.copy?.at) {
51
59
  return {
@@ -192,6 +200,7 @@ function createLocalStore(opts) {
192
200
  const warnedNoId = /* @__PURE__ */ new Set();
193
201
  let seenEpoch;
194
202
  let pendingEdit = false;
203
+ let unsent = false;
195
204
  let editSeq = 0;
196
205
  let queuedKind = null;
197
206
  let prefetched = null;
@@ -651,11 +660,15 @@ function createLocalStore(opts) {
651
660
  kvSetSafe(KEY.syncJournal, redactForStorage(journal), "journal");
652
661
  return entry;
653
662
  }
663
+ function deferPush() {
664
+ lastError = transient("Save deferred: destination momentarily unreachable.");
665
+ unsent = true;
666
+ }
654
667
  async function pushDurable(source = "push") {
655
668
  if (!durable || locked() || needsAttention) return false;
656
669
  try {
657
670
  if (!await durable.isReady()) {
658
- lastError = transient("Save deferred: destination momentarily unreachable.");
671
+ deferPush();
659
672
  return false;
660
673
  }
661
674
  const seen = await statBeforeOverwrite();
@@ -663,7 +676,7 @@ function createLocalStore(opts) {
663
676
  const pulled = await pullRemoteIntoLocal(source, seen);
664
677
  if (locked() || needsAttention) return false;
665
678
  if (pulled === "unreachable") {
666
- lastError = transient("Save deferred: destination momentarily unreachable.");
679
+ deferPush();
667
680
  return false;
668
681
  }
669
682
  }
@@ -671,6 +684,7 @@ function createLocalStore(opts) {
671
684
  const digest = await contentDigest(snap);
672
685
  if (digest === lastSavedContentHash) {
673
686
  lastError = null;
687
+ unsent = false;
674
688
  return true;
675
689
  }
676
690
  const written = await durable.save(await buildBlob(snap));
@@ -678,6 +692,7 @@ function createLocalStore(opts) {
678
692
  lastSavedContentHash = digest;
679
693
  kvSetSafe(KEY.savedHash, digest, "savedHash");
680
694
  lastError = null;
695
+ unsent = false;
681
696
  return true;
682
697
  } catch (e) {
683
698
  if (isAuthExpired(e)) {
@@ -685,7 +700,7 @@ function createLocalStore(opts) {
685
700
  } else if (isSelfstoreError(e) && e.code === "TARGET_GONE") {
686
701
  raiseGate("TARGET_GONE", e.message);
687
702
  } else {
688
- lastError = transient("Save deferred: destination momentarily unreachable.");
703
+ deferPush();
689
704
  }
690
705
  logger.error("[selfstore] push to durable failed", e);
691
706
  return false;
@@ -1067,7 +1082,8 @@ function createLocalStore(opts) {
1067
1082
  needsAttention,
1068
1083
  locked: locked(),
1069
1084
  pendingDownload,
1070
- copy: { at: lastCopyAt, stale: copyIsStale }
1085
+ copy: { at: lastCopyAt, stale: copyIsStale },
1086
+ unsent
1071
1087
  }),
1072
1088
  lastError,
1073
1089
  journal,
@@ -1194,7 +1210,11 @@ function createLocalStore(opts) {
1194
1210
  editSeq++;
1195
1211
  clearTimeout(timer);
1196
1212
  timer = setTimeout(
1197
- () => save().catch((e) => logger.error("[selfstore] scheduled save failed", e)),
1213
+ () => save().catch((e) => {
1214
+ unsent = true;
1215
+ notify();
1216
+ logger.error("[selfstore] scheduled save failed", e);
1217
+ }),
1198
1218
  debounceMs
1199
1219
  );
1200
1220
  armIdleLock();
@@ -1208,7 +1228,7 @@ function createLocalStore(opts) {
1208
1228
  syncIfStale(source) {
1209
1229
  return serialize(async () => {
1210
1230
  if (locked() || needsAttention || mode !== "persistent") return;
1211
- if (!durable?.stat && peerList.length === 0) return;
1231
+ if (!durable?.stat && peerList.length === 0 && !unsent) return;
1212
1232
  const nowMs = Date.now();
1213
1233
  if (nowMs - lastStaleCheck < STALE_CHECK_MS) return;
1214
1234
  lastStaleCheck = nowMs;
@@ -1218,7 +1238,13 @@ function createLocalStore(opts) {
1218
1238
  moved = seen !== null && seen !== remoteVersion;
1219
1239
  }
1220
1240
  if (!moved) moved = await anyPeerMoved();
1221
- if (!moved) return;
1241
+ if (!moved) {
1242
+ if (unsent && durable) {
1243
+ await pushDurable(source);
1244
+ notify();
1245
+ }
1246
+ return;
1247
+ }
1222
1248
  try {
1223
1249
  await doPull(source);
1224
1250
  } catch (e) {
@@ -2177,5 +2203,5 @@ function gisDriveAuth(opts) {
2177
2203
  }
2178
2204
 
2179
2205
  export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache, preloadGoogleIdentity };
2180
- //# sourceMappingURL=chunk-OCWNUAXV.js.map
2181
- //# sourceMappingURL=chunk-OCWNUAXV.js.map
2206
+ //# sourceMappingURL=chunk-TB3CKC6Z.js.map
2207
+ //# sourceMappingURL=chunk-TB3CKC6Z.js.map