selfstore 1.8.16 → 1.8.18

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-CiLoRJmy.js';
2
- export { A as AuthExpiredError, a as BuiltinTargetKind, E as EncodeOptions, H as Header, K as KdfParams, L as LocalStore, b as LocalStoreOptions, c as LocalStoreState, M as MirrorState, d as Mode, e as PasswordCheck, f as PasswordPolicy, g as PasswordRequirement, P as PeerSource, h as PeerState, R as RESERVED_COLLECTION_PREFIX, i as RESERVED_STORE_MODES, j as RecipientStanza, k as ReplicaState, l as SelfstoreError, m as SelfstoreErrorCode, n as Severity, o as Snapshot, p as SnapshotFile, q as StatusAction, r 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-CiLoRJmy.js';
1
+ import { B as BackupTarget } from './store-Cs6QIzzG.js';
2
+ export { A as AuthExpiredError, a as BuiltinTargetKind, E as EncodeOptions, H as Header, K as KdfParams, L as LocalStore, b as LocalStoreOptions, c as LocalStoreState, M as MirrorState, d as Mode, e as PasswordCheck, f as PasswordPolicy, g as PasswordRequirement, P as PeerSource, h as PeerState, R as RESERVED_COLLECTION_PREFIX, i as RESERVED_STORE_MODES, j as RecipientStanza, k as ReplicaState, l as SelfstoreError, m as SelfstoreErrorCode, n as Severity, o as Snapshot, p as SnapshotFile, q as StatusAction, r 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-Cs6QIzzG.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, s as saveToDisk } from './local-CldSa9EY.js';
6
- import { c as connect$2, f as fromSession$2, a as connect$3, b as fromSession$3, p as peer } from './s3-DgyTwMRc.js';
7
- export { S as S3Config, d as S3ConnectOptions, W as WebdavConfig, e as WebdavConnectOptions, g as WebdavPeerOptions } from './s3-DgyTwMRc.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 } from './drive-B2fm71qD.js';
9
- export { i as DriveAccount, a as DriveAuth, j as DriveBackupInfo, D as DriveOptions } from './drive-B2fm71qD.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, s as saveToDisk } from './local-Dh6eGiK9.js';
6
+ import { c as connect$2, f as fromSession$2, a as connect$3, b as fromSession$3, p as peer } from './s3-0qqIyphl.js';
7
+ export { S as S3Config, d as S3ConnectOptions, W as WebdavConfig, e as WebdavConnectOptions, g as WebdavPeerOptions } from './s3-0qqIyphl.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 } from './drive-CY_Vsj7V.js';
9
+ export { i as DriveAccount, a as DriveAuth, j as DriveBackupInfo, D as DriveOptions } from './drive-CY_Vsj7V.js';
10
10
  import './sync.js';
11
11
 
12
12
  /**
package/dist/advanced.js CHANGED
@@ -1,4 +1,4 @@
1
- export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache } from './chunk-TXAMWBG5.js';
1
+ export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache } from './chunk-RBIQRTZR.js';
2
2
  import './chunk-SKWHKM25.js';
3
3
  export { datedName, pickFromDisk, saveToDisk } from './chunk-DCEXWSM6.js';
4
4
  import { openExisting, isOpenSupported, isSupported, fromSession as fromSession$1, connect as connect$1, fromSession3, connect3, peer, fromSession2, connect2 } from './chunk-TKWU52LK.js';
package/dist/backups.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { B as BackupsHost } from './manager-BqzTVaep.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-BqzTVaep.js';
3
- import { D as DriveOptions } from './drive-B2fm71qD.js';
1
+ import { B as BackupsHost } from './manager-DhoIbJyg.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-DhoIbJyg.js';
3
+ import { D as DriveOptions } from './drive-CY_Vsj7V.js';
4
4
  import './cache-ilsK3Tki.js';
5
- import './store-CiLoRJmy.js';
5
+ import './store-Cs6QIzzG.js';
6
6
  import './sync.js';
7
7
  import './machine-ALMkT3mk.js';
8
8
 
@@ -45,6 +45,15 @@ function deriveStatus(input) {
45
45
  };
46
46
  }
47
47
  if (input.targetKind === "device") {
48
+ if (input.copy?.at) {
49
+ return {
50
+ state: "cache-only",
51
+ severity: input.copy.stale ? "warn" : "ok",
52
+ actionable: true,
53
+ action: "choose-destination",
54
+ labelKey: input.copy.stale ? "status.copyStale" : "status.copy"
55
+ };
56
+ }
48
57
  return {
49
58
  state: "cache-only",
50
59
  severity: "warn",
@@ -68,6 +77,10 @@ var KEY = {
68
77
  version: "version",
69
78
  syncMeta: "syncMeta",
70
79
  lastSavedAt: "lastSavedAt",
80
+ // When a portable copy was last written, and whether anything has been
81
+ // entered since. See the state fields of the same name.
82
+ copyAt: "copyAt",
83
+ copyStale: "copyStale",
71
84
  enc: "enc",
72
85
  targetKind: "targetKind",
73
86
  remoteVersion: "remoteVersion",
@@ -149,6 +162,8 @@ function createLocalStore(opts) {
149
162
  let lastError = null;
150
163
  let pendingDownload = false;
151
164
  let lastSavedAt = null;
165
+ let lastCopyAt = null;
166
+ let copyIsStale = false;
152
167
  let ready = false;
153
168
  let saving = false;
154
169
  let lastSavedContentHash = null;
@@ -439,6 +454,8 @@ function createLocalStore(opts) {
439
454
  meta = await kv.get(KEY.syncMeta) ?? createMeta();
440
455
  baseMeta = await kv.get(KEY.baseMeta) ?? null;
441
456
  lastSavedAt = await kv.get(KEY.lastSavedAt) ?? null;
457
+ lastCopyAt = await kv.get(KEY.copyAt) ?? null;
458
+ copyIsStale = await kv.get(KEY.copyStale) ?? false;
442
459
  remoteVersion = await kv.get(KEY.remoteVersion) ?? null;
443
460
  lastSavedContentHash = await kv.get(KEY.savedHash) ?? null;
444
461
  if (durable) {
@@ -614,6 +631,10 @@ function createLocalStore(opts) {
614
631
  notify();
615
632
  try {
616
633
  await persistLocal();
634
+ if (lastCopyAt !== null && !copyIsStale) {
635
+ copyIsStale = true;
636
+ kvSetSafe(KEY.copyStale, true, "copyStale");
637
+ }
617
638
  if (editSeq === seq) pendingEdit = false;
618
639
  if (targetKind === "file-manual") {
619
640
  lastSavedContentHash = digest;
@@ -947,13 +968,16 @@ function createLocalStore(opts) {
947
968
  locked: locked(),
948
969
  saving,
949
970
  lastSavedAt,
971
+ lastCopyAt,
972
+ copyIsStale,
950
973
  status: deriveStatus({
951
974
  persistent: mode === "persistent",
952
975
  targetKind,
953
976
  saving,
954
977
  needsAttention,
955
978
  locked: locked(),
956
- pendingDownload
979
+ pendingDownload,
980
+ copy: { at: lastCopyAt, stale: copyIsStale }
957
981
  }),
958
982
  lastError,
959
983
  journal,
@@ -1005,6 +1029,8 @@ function createLocalStore(opts) {
1005
1029
  apply(migrated(snap, storedV));
1006
1030
  }
1007
1031
  lastSavedAt = await kv.get(KEY.lastSavedAt) ?? null;
1032
+ lastCopyAt = await kv.get(KEY.copyAt) ?? null;
1033
+ copyIsStale = await kv.get(KEY.copyStale) ?? false;
1008
1034
  lastSavedContentHash = await kv.get(KEY.savedHash) ?? null;
1009
1035
  meta = await kv.get(KEY.syncMeta) ?? createMeta();
1010
1036
  await kv.set(KEY.syncMeta, meta);
@@ -1372,6 +1398,10 @@ function createLocalStore(opts) {
1372
1398
  },
1373
1399
  markDownloaded() {
1374
1400
  pendingDownload = false;
1401
+ lastCopyAt = Date.now();
1402
+ copyIsStale = false;
1403
+ kvSetSafe(KEY.copyAt, lastCopyAt, "copyAt");
1404
+ kvSetSafe(KEY.copyStale, false, "copyStale");
1375
1405
  lastSavedAt = Date.now();
1376
1406
  void kv.set(KEY.lastSavedAt, lastSavedAt).catch(() => void 0);
1377
1407
  notify();
@@ -2110,5 +2140,5 @@ function gisDriveAuth(opts) {
2110
2140
  }
2111
2141
 
2112
2142
  export { RESERVED_STORE_MODES, createLocalStore, deriveStatus, gisDriveAuth, indexedDbCache, isLockableCache, isReservedStoreMode, memoryCache };
2113
- //# sourceMappingURL=chunk-TXAMWBG5.js.map
2114
- //# sourceMappingURL=chunk-TXAMWBG5.js.map
2143
+ //# sourceMappingURL=chunk-RBIQRTZR.js.map
2144
+ //# sourceMappingURL=chunk-RBIQRTZR.js.map