@evolu/common 8.12.0 → 8.14.0

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.
Files changed (59) hide show
  1. package/dist/src/Callbacks.d.ts +12 -1
  2. package/dist/src/Callbacks.d.ts.map +1 -1
  3. package/dist/src/Callbacks.js +3 -0
  4. package/dist/src/Error.d.ts +10 -4
  5. package/dist/src/Error.d.ts.map +1 -1
  6. package/dist/src/Error.js +10 -4
  7. package/dist/src/Object.d.ts +65 -0
  8. package/dist/src/Object.d.ts.map +1 -1
  9. package/dist/src/Object.js +142 -0
  10. package/dist/src/Resource.d.ts +0 -5
  11. package/dist/src/Resource.d.ts.map +1 -1
  12. package/dist/src/Resource.js +6 -13
  13. package/dist/src/Sqlite.d.ts.map +1 -1
  14. package/dist/src/Sqlite.js +7 -0
  15. package/dist/src/Task.d.ts +10 -8
  16. package/dist/src/Task.d.ts.map +1 -1
  17. package/dist/src/Task.js +41 -5
  18. package/dist/src/Worker.d.ts +3 -3
  19. package/dist/src/local-first/Db.d.ts +8 -3
  20. package/dist/src/local-first/Db.d.ts.map +1 -1
  21. package/dist/src/local-first/Db.js +56 -19
  22. package/dist/src/local-first/Evolu.d.ts +147 -39
  23. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  24. package/dist/src/local-first/Evolu.js +53 -9
  25. package/dist/src/local-first/Owner.d.ts +9 -0
  26. package/dist/src/local-first/Owner.d.ts.map +1 -1
  27. package/dist/src/local-first/Owner.js +9 -0
  28. package/dist/src/local-first/Protocol.d.ts +6 -4
  29. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  30. package/dist/src/local-first/Protocol.js +1 -6
  31. package/dist/src/local-first/Schema.d.ts +7 -1
  32. package/dist/src/local-first/Schema.d.ts.map +1 -1
  33. package/dist/src/local-first/Shared.d.ts +550 -153
  34. package/dist/src/local-first/Shared.d.ts.map +1 -1
  35. package/dist/src/local-first/Shared.js +724 -273
  36. package/dist/src/local-first/Storage.d.ts +16 -12
  37. package/dist/src/local-first/Storage.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/Callbacks.test.ts +20 -0
  40. package/src/Callbacks.ts +17 -1
  41. package/src/Error.ts +10 -4
  42. package/src/Object.test.ts +296 -0
  43. package/src/Object.ts +163 -0
  44. package/src/Resource.test.ts +20 -16
  45. package/src/Resource.ts +6 -20
  46. package/src/Sqlite.ts +7 -0
  47. package/src/Task.test.ts +233 -62
  48. package/src/Task.ts +47 -13
  49. package/src/Worker.ts +3 -3
  50. package/src/local-first/Db.ts +88 -18
  51. package/src/local-first/Evolu.test.ts +381 -11
  52. package/src/local-first/Evolu.ts +219 -51
  53. package/src/local-first/Owner.ts +9 -0
  54. package/src/local-first/Protocol.test.ts +42 -60
  55. package/src/local-first/Protocol.ts +7 -9
  56. package/src/local-first/Schema.ts +8 -2
  57. package/src/local-first/Shared.test.ts +2714 -644
  58. package/src/local-first/Shared.ts +1245 -401
  59. package/src/local-first/Storage.ts +18 -19
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import { type NonEmptyReadonlyArray } from "../Array.ts";
7
7
  import type { ConsoleDep } from "../Console.ts";
8
- import type { DecryptWithXChaCha20Poly1305Error } from "../Crypto.ts";
9
8
  import type { UnknownError } from "../Error.ts";
10
9
  import { type LockManagerDep } from "../LockManager.ts";
11
10
  import type { FlushSyncDep, ReloadAppDep } from "../Platform.ts";
@@ -15,11 +14,9 @@ import { Name, PositiveInt, type TypeError, UrlSafeString } from "../Type.ts";
15
14
  import type { CreateBroadcastChannelDep, CreateMessageChannelDep } from "../Worker.ts";
16
15
  import type { CreateDbWorkerDep, UnsupportedDbVersionError } from "./Db.ts";
17
16
  import type { AppOwner, Owner, OwnerId, OwnerTransport, ReadonlyOwner } from "./Owner.ts";
18
- import { type ProtocolError } from "./Protocol.ts";
19
17
  import type { Queries, QueriesToQueryRowsPromises, Query, QueryRows, Row } from "./Query.ts";
20
18
  import type { EvoluSchema, IndexesConfig, Mutation, MutationValues, ValidateSchema } from "./Schema.ts";
21
19
  import type { OtherBuildRunningError, SharedWorkerDep, SyncState } from "./Shared.ts";
22
- import { type StorageQuotaError } from "./Storage.ts";
23
20
  /**
24
21
  * Configuration for {@link createEvolu}.
25
22
  *
@@ -266,6 +263,36 @@ export interface Evolu<S extends EvoluSchema = EvoluSchema> extends AsyncDisposa
266
263
  readonly name: Name;
267
264
  /** {@link AppOwner}. */
268
265
  readonly appOwner: AppOwner;
266
+ /**
267
+ * Whether this device keeps the database, resolved once the shared worker
268
+ * serves it, or `Unknown` if this instance is disposed first.
269
+ *
270
+ * Apps tell the user when it is `NotPersisted`, because then data that has
271
+ * not synced is lost when the database closes. Apps must not tell the user
272
+ * that data is saved on the device when it is `Unknown`.
273
+ *
274
+ * ### Example
275
+ *
276
+ * ```ts
277
+ * import { assertEqual } from "@evolu/common";
278
+ * import type { DevicePersistence } from "@evolu/common/local-first";
279
+ *
280
+ * // The notice for `await evolu.devicePersistence`, or null for none.
281
+ * const persistenceNotice = (
282
+ * devicePersistence: DevicePersistence,
283
+ * ): string | null =>
284
+ * devicePersistence === "NotPersisted"
285
+ * ? "Your data isn't kept on this device. Changes that haven't synced are lost when you close this tab."
286
+ * : null;
287
+ *
288
+ * assertEqual(persistenceNotice("Unknown"), null);
289
+ * assertEqual(
290
+ * persistenceNotice("NotPersisted"),
291
+ * "Your data isn't kept on this device. Changes that haven't synced are lost when you close this tab.",
292
+ * );
293
+ * ```
294
+ */
295
+ readonly devicePersistence: Promise<DevicePersistence>;
269
296
  /**
270
297
  * Inserts a row and returns the generated {@link Id}.
271
298
  *
@@ -276,8 +303,10 @@ export interface Evolu<S extends EvoluSchema = EvoluSchema> extends AsyncDisposa
276
303
  *
277
304
  * Pass `onComplete` when follow-up work must wait until the mutation is
278
305
  * stored and subscribed queries reflect it. It never runs when the database
279
- * is unavailable; see {@link Evolu.loadQuery}. A stored change is not always
280
- * visible; see {@link MutationOptions.onComplete}.
306
+ * is unavailable; see {@link Evolu.loadQuery}. It also never runs when the
307
+ * mutation could not be stored, which {@link EvoluErrorDep.evoluError}
308
+ * reports. A stored change is not always visible; see
309
+ * {@link MutationOptions.onComplete}.
281
310
  *
282
311
  * ### Example
283
312
  *
@@ -578,6 +607,9 @@ export interface Evolu<S extends EvoluSchema = EvoluSchema> extends AsyncDisposa
578
607
  /**
579
608
  * Exports the SQLite database file.
580
609
  *
610
+ * The exported file is not encrypted, even when the local database is. Any
611
+ * SQLite tool can read all local data from it, so treat it as plaintext.
612
+ *
581
613
  * Exports are sequential: concurrent calls share one pending export instead
582
614
  * of starting parallel exports.
583
615
  *
@@ -680,9 +712,12 @@ export interface Evolu<S extends EvoluSchema = EvoluSchema> extends AsyncDisposa
680
712
  *
681
713
  * Reconciles locally stored changes, including writes previously rejected
682
714
  * with {@link ProtocolQuotaError}, through the owner's active transports. Call
683
- * this after the relay provider confirms additional quota is available.
684
- * Existing connections and {@link Evolu.useOwner} registrations are retained,
685
- * including registrations shared by multiple instances or tabs.
715
+ * this after the relay provider confirms additional quota is available. It
716
+ * also checks again the changes this database skipped from the owner's
717
+ * relays, and sends such a relay the changes received from other relays,
718
+ * which otherwise wait for its next sync, such as after a reconnect. Existing
719
+ * connections and {@link Evolu.useOwner} registrations are retained, including
720
+ * registrations shared by multiple instances or tabs.
686
721
  *
687
722
  * The owner must have an active writable registration in this database.
688
723
  * Unregistered or read-only owners are ignored. Requests are skipped while
@@ -690,8 +725,9 @@ export interface Evolu<S extends EvoluSchema = EvoluSchema> extends AsyncDisposa
690
725
  * reopen. Disposal drops locally buffered requests. Calling a disposed
691
726
  * instance throws, like other Evolu operations.
692
727
  *
693
- * Returns immediately, without waiting for synchronization to complete.
694
- * Errors are reported through {@link EvoluErrorDep.evoluError}.
728
+ * Returns immediately, without waiting for synchronization to complete. The
729
+ * owner's routes in sync state show a failure, such as a quota rejection, as
730
+ * `failure`, and a skipped change as `skippedError`.
695
731
  *
696
732
  * ### Example
697
733
  *
@@ -718,9 +754,32 @@ export interface Evolu<S extends EvoluSchema = EvoluSchema> extends AsyncDisposa
718
754
  */
719
755
  export type UnuseOwner = () => void;
720
756
  /**
721
- * Represents errors that can occur in {@link Evolu}.
757
+ * Whether this device keeps an {@link Evolu} database, stating only what Evolu
758
+ * knows for sure.
722
759
  *
723
- * Apps show them from {@link EvoluErrorDep.evoluError}.
760
+ * - `Persisted`: the platform stores it in the app's own file, as React Native
761
+ * does.
762
+ * - `NotPersisted`: it is kept in memory, because {@link EvoluConfig.memoryOnly}
763
+ * asks for that or the platform offers no persistent storage, as a browser
764
+ * does in Safari's Private Browsing or a Firefox private window. Data that
765
+ * has not synced is lost when the database closes.
766
+ * - `Unknown`: it is stored, but the platform may delete it. A browser can keep
767
+ * storage only for a private session, as Chrome's incognito does without
768
+ * telling the app, delete it after a while or when disk space runs low, and
769
+ * let the user clear it.
770
+ *
771
+ * See [Will my data stay on the
772
+ * device?](https://www.evolu.dev/docs/faq#will-my-data-stay-on-the-device).
773
+ *
774
+ * @group Core
775
+ */
776
+ export type DevicePersistence = "Persisted" | "NotPersisted" | "Unknown";
777
+ /**
778
+ * Represents app-level errors that can occur in {@link Evolu}.
779
+ *
780
+ * Apps show them from {@link EvoluErrorDep.evoluError}. Problems a relay causes
781
+ * while syncing an owner are not EvoluErrors; see below. An unexpected failure
782
+ * while syncing is an {@link UnknownError}.
724
783
  *
725
784
  * An error that leaves the app unusable deserves a modal dialog, which moves
726
785
  * focus into itself and restores it when closed. Any other error is a status
@@ -734,25 +793,45 @@ export type UnuseOwner = () => void;
734
793
  * - {@link OtherBuildRunningError} blocks the app while it lasts: another version
735
794
  * of the app holds the local data. Ask the user to close the app's other
736
795
  * tabs. It clears when the wait ends.
737
- * - {@link ProtocolError} does not block the app: sync with a relay failed for an
738
- * owner, because the relay rejected or failed a request, or sent data that
739
- * could not be decoded or verified; sync state shows the affected routes. A
740
- * {@link ProtocolQuotaError} needs more relay quota, then
741
- * {@link Evolu.requestSync}; a {@link ProtocolVersionError} needs an app or
742
- * relay update.
743
- * - {@link StorageQuotaError} does not block the app: a storage or billing quota
744
- * was exceeded, so a batch of an owner's changes was not stored. The built-in
745
- * client storage does not report it yet; a relay's quota arrives as
746
- * {@link ProtocolQuotaError}.
747
- * - {@link DecryptWithXChaCha20Poly1305Error} does not block the app: changes
748
- * received for an owner could not be decrypted, so none of their batch was
749
- * stored.
750
796
  * - {@link UnknownError} does not block the app: Evolu logged an unexpected
751
- * failure. Show a generic message.
797
+ * failure, such as a mutation that could not be stored. Show a generic
798
+ * message.
799
+ *
800
+ * A problem syncing an owner through a relay belongs to that relay and often
801
+ * repeats in every round, so sync state shows it on the relay's route, as its
802
+ * {@link PendingSyncRoute.failure} with its details, and apps show it as the
803
+ * owner's `Error` {@link OwnerSyncStatus}. When the relay rejected or failed a
804
+ * request, or sent a frame that could not be decoded, the route shows a
805
+ * {@link ProtocolError}. A {@link ProtocolQuotaError} needs more relay quota,
806
+ * then {@link Evolu.requestSync}, and a {@link ProtocolVersionError} needs an app
807
+ * or relay update.
808
+ *
809
+ * A received change that was not created with the owner's encryption key, was
810
+ * altered afterwards, or cannot be decoded by this app version is skipped,
811
+ * while everything else still syncs. The relay offers it again in every round,
812
+ * so the route shows it as its `skippedError`: the
813
+ * {@link DecryptWithXChaCha20Poly1305Error},
814
+ * {@link ProtocolTimestampMismatchError}, or {@link ProtocolInvalidDataError} of
815
+ * the first change skipped in a reply, with its details. The owner's status is
816
+ * `Error` with it too, unless a relay has a failure. Once this database stores
817
+ * a valid change with that timestamp, for example from another relay, the relay
818
+ * no longer offers its copy, and the route completes with its next sync, such
819
+ * as after a reconnect or {@link Evolu.requestSync}, during which no changes
820
+ * arrive from other relays. If you don't trust that relay, stop using it for
821
+ * the owner. For owners that use the default transports, such as
822
+ * {@link Evolu.appOwner} when {@link EvoluConfig.transports} is not empty,
823
+ * replace the relay there; an empty list stops syncing the app owner and makes
824
+ * {@link Evolu.useOwner} require explicit transports. For an owner you passed
825
+ * explicit transports to {@link Evolu.useOwner}, call its {@link UnuseOwner} and
826
+ * use it again without that relay. Do this wherever the owner is used, such as
827
+ * in every tab, because the owner syncs through every transport any of its uses
828
+ * claims. If every route of the owner shows
829
+ * {@link DecryptWithXChaCha20Poly1305Error} and your code creates or shares the
830
+ * owner, check the owner's keys.
752
831
  *
753
832
  * @group Core
754
833
  */
755
- export type EvoluError = DecryptWithXChaCha20Poly1305Error | OtherBuildRunningError | ProtocolError | StorageQuotaError | UnknownError | UnsupportedDbVersionError;
834
+ export type EvoluError = OtherBuildRunningError | UnknownError | UnsupportedDbVersionError;
756
835
  /**
757
836
  * The largest {@link Mutation}, in bytes.
758
837
  *
@@ -793,6 +872,13 @@ export interface EvoluErrorDep {
793
872
  * instead; see {@link UnsupportedDbVersionError}. Show that blocking message
794
873
  * outside any query-loading boundary, so pending queries do not hide it.
795
874
  *
875
+ * An {@link UnknownError} leaves Evolu in an unknown state, so the app can
876
+ * only ask the user to close the tab. A failed shared worker closes itself,
877
+ * so the app opened again starts a new one. Some errors reach every tab, such
878
+ * as an unexpected failure of the shared worker. An app that forwards this
879
+ * store to an error tracker from each tab then reports such an error once per
880
+ * tab.
881
+ *
796
882
  * ### Example
797
883
  *
798
884
  * ```ts
@@ -806,14 +892,13 @@ export interface EvoluErrorDep {
806
892
  * // The message for the current error, or null for none.
807
893
  * const errorMessage = (error: EvoluError | null): string | null => {
808
894
  * if (!error) return null;
809
- * // oxlint-disable-next-line typescript/switch-exhaustiveness-check -- The default handles every other EvoluError.
810
895
  * switch (error.type) {
811
896
  * case "UnsupportedDbVersionError":
812
897
  * return "Your data requires a newer version of this app. Please update it.";
813
898
  * case "OtherBuildRunningError":
814
899
  * return "This app is open in another tab with a different version. Close that tab to continue.";
815
- * default:
816
- * return "Something went wrong. Please try again.";
900
+ * case "UnknownError":
901
+ * return "Something went wrong. Please close this tab and open the app again.";
817
902
  * }
818
903
  * };
819
904
  *
@@ -848,8 +933,15 @@ export interface SyncStateDep {
848
933
  /**
849
934
  * {@link ReadonlyStore} of the latest {@link SyncState} shared by all
850
935
  * {@link Evolu} instances, or null before the shared worker sends its first
851
- * snapshot. Derive what to show from it, such as one indicator per relay, or
852
- * use {@link syncStateToOwnerSyncStates} for one state per owner.
936
+ * snapshot. It lists every database the shared worker serves, including other
937
+ * tabs', so an app finds its own by {@link Evolu.name}. Apps show users an
938
+ * owner's {@link OwnerSyncStatus}, from {@link syncStateToOwnerSyncStatus} or a
939
+ * framework binding's `useOwnerSyncStatus`; views of each relay use
940
+ * {@link syncStateToRelaySyncStates}.
941
+ *
942
+ * Each snapshot keeps the previous snapshot's object for every part that did
943
+ * not change, and a snapshot equal to the previous one leaves the store
944
+ * unchanged, so parts and derived statuses can be compared with `===`.
853
945
  *
854
946
  * ### Example
855
947
  *
@@ -858,6 +950,7 @@ export interface SyncStateDep {
858
950
  * assertEqual,
859
951
  * createId,
860
952
  * createStore,
953
+ * Millis,
861
954
  * testCreateDeps,
862
955
  * } from "@evolu/common";
863
956
  * import type {
@@ -867,7 +960,7 @@ export interface SyncStateDep {
867
960
  *
868
961
  * const openRelayLabels = (deps: SyncStateDep): ReadonlyArray<string> =>
869
962
  * (deps.syncState.get()?.transports ?? [])
870
- * .filter(({ readyState }) => readyState === "open")
963
+ * .filter(({ connection }) => connection.type === "Open")
871
964
  * .map(({ label }) => label);
872
965
  *
873
966
  * using syncState = createStore<SyncState | null>(null);
@@ -877,12 +970,14 @@ export interface SyncStateDep {
877
970
  * syncState.set({
878
971
  * transports: [
879
972
  * {
973
+ * type: "WebSocket",
880
974
  * id: createId<"SyncTransport">(deps),
881
975
  * label: "wss://relay.example",
882
- * readyState: "open",
883
- * openedAt: null,
884
- * closedAt: null,
885
- * error: null,
976
+ * connection: {
977
+ * type: "Open",
978
+ * openedAt: Millis.orThrow(1000),
979
+ * error: null,
980
+ * },
886
981
  * },
887
982
  * ],
888
983
  * tenants: [],
@@ -892,6 +987,19 @@ export interface SyncStateDep {
892
987
  */
893
988
  readonly syncState: ReadonlyStore<SyncState | null>;
894
989
  }
990
+ /**
991
+ * Asks the platform to keep stored databases until the user deletes them.
992
+ *
993
+ * Only unsynced local changes exist nowhere else, so each {@link Evolu} instance
994
+ * calls it after its first local mutation, when its
995
+ * {@link Evolu.devicePersistence} is `Unknown`. A platform provides it when its
996
+ * storage can be deleted without the user, as a browser's can.
997
+ *
998
+ * @group Construction
999
+ */
1000
+ export interface RequestPersistentStorageDep {
1001
+ readonly requestPersistentStorage: () => void;
1002
+ }
895
1003
  /**
896
1004
  * Shared platform dependencies for creating {@link Evolu} instances.
897
1005
  *
@@ -905,11 +1013,11 @@ export type EvoluDeps = EvoluPlatformDeps & ConsoleDep & EvoluErrorDep & SyncSta
905
1013
  * Platform-specific dependencies required to create {@link EvoluDeps}.
906
1014
  *
907
1015
  * Provides worker and channel adapters plus optional platform integrations for
908
- * logging and synchronous UI flush.
1016
+ * logging, synchronous UI flush, and persistent storage requests.
909
1017
  *
910
1018
  * @group Construction
911
1019
  */
912
- export type EvoluPlatformDeps = CreateDbWorkerDep & CreateBroadcastChannelDep & CreateMessageChannelDep & LockManagerDep & ReloadAppDep & SharedWorkerDep & Partial<ConsoleDep> & Partial<FlushSyncDep>;
1020
+ export type EvoluPlatformDeps = CreateDbWorkerDep & CreateBroadcastChannelDep & CreateMessageChannelDep & LockManagerDep & ReloadAppDep & SharedWorkerDep & Partial<ConsoleDep> & Partial<FlushSyncDep> & Partial<RequestPersistentStorageDep>;
913
1021
  /**
914
1022
  * Creates shared dependencies used by all {@link createEvolu} instances on a
915
1023
  * platform.
@@ -1 +1 @@
1
- {"version":3,"file":"Evolu.d.ts","sourceRoot":"","sources":["../../../src/local-first/Evolu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,YA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AAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,wBAAwB,EAAE,MAAM,IAAI,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,iBAAiB,GACvC,UAAU,GACV,aAAa,GACb,YAAY,GACZ,UAAU,CAAC;AAEb;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAC/C,yBAAyB,GACzB,uBAAuB,GACvB,cAAc,GACd,YAAY,GACZ,eAAe,GACf,OAAO,CAAC,UAAU,CAAC,GACnB,OAAO,CAAC,YAAY,CAAC,GACrB,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,SAAU,iBAAiB,KAAG,SA4HzD,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACrB,CAAC,SAAS,WAAW,UACZ,cAAc,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,UACvD,WAAW,KAClB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAmhBzC,CAAC"}
@@ -64,7 +64,7 @@ import { createUnknownError } from "../Error.js";
64
64
  import { disposable, exhaustiveCheck, todo } from "../Function.js";
65
65
  import { acquireLeaderLock, acquireLeaderLockCallback, } from "../LockManager.js";
66
66
  import { createMicrotaskBatch } from "../Microtask.js";
67
- import { createMutableRecord, objectToEntries, } from "../Object.js";
67
+ import { createMutableRecord, isPlainObject, objectToEntries, shareStructure, } from "../Object.js";
68
68
  import { createRefCountByKey } from "../RefCount.js";
69
69
  import { err, ok } from "../Result.js";
70
70
  import { isNonEmptySet } from "../Set.js";
@@ -183,11 +183,16 @@ export const createEvoluDeps = (deps) => {
183
183
  setEvoluError(createUnknownError(message.entry.args));
184
184
  }
185
185
  break;
186
- case "Error":
187
- setEvoluError(message.error);
186
+ case "Error": {
187
+ // Every build shares this channel, so another build's worker can post
188
+ // an error type this build does not post, such as an older build's
189
+ // sync error. That build's own tabs show it, so this tab only logs it.
190
+ if (message.error.type === "UnknownError")
191
+ setEvoluError(message.error);
188
192
  // Keep typed errors visible in logs as operational failures.
189
193
  console.error(message.error);
190
194
  break;
195
+ }
191
196
  default:
192
197
  exhaustiveCheck(message);
193
198
  }
@@ -198,15 +203,14 @@ export const createEvoluDeps = (deps) => {
198
203
  deps.createDbWorker().postMessage(message, [message.port]);
199
204
  break;
200
205
  case "Error":
201
- // Sent to this tab only: its database refused startup, or its worker
202
- // still waits for another build.
206
+ // Sent to this tab only: its database refused startup, a mutation it
207
+ // made could not be stored, or its worker still waits for another
208
+ // build.
203
209
  setEvoluError(message.error);
204
210
  console.error(message.error);
205
211
  break;
206
212
  case "Waiting":
207
- case "StorageUnavailable":
208
- // Platform adapters act on these; see Builds and Storage in the Shared
209
- // module.
213
+ // Platform adapters act on it; see Builds in the Shared module.
210
214
  break;
211
215
  case "Connected": {
212
216
  assert(!syncStateBroadcastChannel, "The shared worker connects once.");
@@ -218,7 +222,13 @@ export const createEvoluDeps = (deps) => {
218
222
  // arrive in order, so the last one is current.
219
223
  syncStateBroadcastChannel = createBroadcastChannel(message.syncStateChannelName);
220
224
  syncStateBroadcastChannel.onMessage = (state) => {
221
- syncState.set(state);
225
+ // Every snapshot arrives as a new structured clone, so its unchanged
226
+ // parts get the previous snapshot's objects back, and an unchanged
227
+ // snapshot leaves the store as it is.
228
+ const previous = syncState.get();
229
+ syncState.set(previous
230
+ ? shareStructure(previous, state, syncStateItemToKey)
231
+ : state);
222
232
  };
223
233
  // Asking only after listening misses no snapshot.
224
234
  sharedWorker.port.postMessage({ type: "RequestSyncState" });
@@ -254,6 +264,12 @@ export const createEvoluDeps = (deps) => {
254
264
  __disposeResources(env_1);
255
265
  }
256
266
  };
267
+ // Transports, tenants, owners, and routes come and go, so each is compared
268
+ // with its previous self by its ID: a transport's id, a tenant's name, an
269
+ // owner's ownerId, or a route's transportId. A wrong key only loses sharing.
270
+ const syncStateItemToKey = (item) => isPlainObject(item)
271
+ ? (item.id ?? item.name ?? item.ownerId ?? item.transportId)
272
+ : undefined;
257
273
  /**
258
274
  * Creates an {@link Evolu} instance from {@link EvoluSchema} and
259
275
  * {@link EvoluConfig}.
@@ -326,6 +342,12 @@ export const createEvolu = (schema, config) => async (run) => {
326
342
  exportDatabasePending?.reject({ type: "EvoluDisposedError" });
327
343
  exportDatabasePending = null;
328
344
  });
345
+ const devicePersistence = Promise.withResolvers();
346
+ // A disposed instance never hears from its tenant, so awaiters settle.
347
+ disposer.defer(() => {
348
+ devicePersistence.resolve("Unknown");
349
+ });
350
+ let isPersistentStorageRequested = false;
329
351
  let postMessage;
330
352
  // Scope worker/channel wiring and keep only postMessage outside.
331
353
  {
@@ -387,6 +409,16 @@ export const createEvolu = (schema, config) => async (run) => {
387
409
  exportDatabasePending = null;
388
410
  break;
389
411
  }
412
+ case "OnMutateFailed": {
413
+ // The tab reports the failure, and these callbacks never run.
414
+ for (const onCompleteId of message.onCompleteIds) {
415
+ onMutateCompleteCallbacks.unregister(onCompleteId);
416
+ }
417
+ break;
418
+ }
419
+ case "OnDevicePersistence":
420
+ devicePersistence.resolve(message.devicePersistence);
421
+ break;
390
422
  default:
391
423
  exhaustiveCheck(message);
392
424
  }
@@ -472,6 +504,17 @@ export const createEvolu = (schema, config) => async (run) => {
472
504
  const size = measureMutation(dbChange.table, dbChange.values);
473
505
  assert(size <= maxMutationSize, `The mutation of table '${dbChange.table}' is ${size} bytes, over maxMutationSize (${maxMutationSize}). Bound the Types of its columns or check it with evolu.getMutationSize.`);
474
506
  }
507
+ // Only unsynced local changes exist nowhere else, so the first one is
508
+ // when asking the platform to keep them starts to matter. Asking on
509
+ // load would show Firefox's permission prompt to every visitor.
510
+ if (!isPersistentStorageRequested) {
511
+ isPersistentStorageRequested = true;
512
+ void devicePersistence.promise.then((persistence) => {
513
+ if (persistence === "Unknown" && !disposed) {
514
+ run.deps.requestPersistentStorage?.();
515
+ }
516
+ });
517
+ }
475
518
  mutateBatch.push({
476
519
  change: { ...dbChange, ownerId: options?.ownerId ?? appOwner.id },
477
520
  onComplete: options?.onComplete,
@@ -530,6 +573,7 @@ export const createEvolu = (schema, config) => async (run) => {
530
573
  return ok(disposable({
531
574
  name,
532
575
  appOwner,
576
+ devicePersistence: devicePersistence.promise,
533
577
  insert: createMutation("insert"),
534
578
  update: createMutation("update"),
535
579
  upsert: createMutation("upsert"),
@@ -28,6 +28,15 @@
28
28
  * - {@link OwnerEncryptionKey}: the symmetric key that protects the data.
29
29
  * - {@link OwnerWriteKey}: the rotatable token that authorizes writes.
30
30
  *
31
+ * Only holders of the encryption key can create an owner's changes. Each change
32
+ * is encrypted and authenticated together with its timestamp, so a relay, or
33
+ * anyone who can write to a relay for the owner, can store bytes for the owner
34
+ * but cannot forge or move a change. A client stores only the changes it can
35
+ * decrypt, verify, and decode, and syncs only what it stored. It skips any
36
+ * other change, which sync state shows on the route of the relay that holds it,
37
+ * and the relay offers it again on each sync until the client stores a valid
38
+ * change with that timestamp.
39
+ *
31
40
  * @module
32
41
  */
33
42
  import type { NonEmptyReadonlyArray } from "../Array.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"Owner.d.ts","sourceRoot":"","sources":["../../../src/local-first/Owner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUnD,OAAO,EAML,QAAQ,EACR,cAAc,EACd,KAAK,KAAK,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EA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QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,GAAG,qBAAqB,CAAC;CAC5E"}
@@ -28,6 +28,15 @@
28
28
  * - {@link OwnerEncryptionKey}: the symmetric key that protects the data.
29
29
  * - {@link OwnerWriteKey}: the rotatable token that authorizes writes.
30
30
  *
31
+ * Only holders of the encryption key can create an owner's changes. Each change
32
+ * is encrypted and authenticated together with its timestamp, so a relay, or
33
+ * anyone who can write to a relay for the owner, can store bytes for the owner
34
+ * but cannot forge or move a change. A client stores only the changes it can
35
+ * decrypt, verify, and decode, and syncs only what it stored. It skips any
36
+ * other change, which sync state shows on the route of the relay that holds it,
37
+ * and the relay offers it again on each sync until the client stores a valid
38
+ * change with that timestamp.
39
+ *
31
40
  * @module
32
41
  */
33
42
  import * as bip39 from "@scure/bip39";
@@ -304,8 +304,9 @@ export interface ProtocolInvalidDataError extends Typed<"ProtocolInvalidDataErro
304
304
  export interface ProtocolWriteKeyError extends OwnerError, Typed<"ProtocolWriteKeyError"> {
305
305
  }
306
306
  /**
307
- * Error indicating a serious relay-side write failure. Clients should log this
308
- * error and show a generic sync error to the user.
307
+ * Error indicating a serious relay-side write failure. Sync state shows it as
308
+ * the failure of that relay's route; apps show a generic sync error for the
309
+ * owner's `Error` status.
309
310
  */
310
311
  export interface ProtocolWriteError extends OwnerError, Typed<"ProtocolWriteError"> {
311
312
  }
@@ -326,8 +327,9 @@ export interface ProtocolWriteError extends OwnerError, Typed<"ProtocolWriteErro
326
327
  export interface ProtocolQuotaError extends OwnerError, Typed<"ProtocolQuotaError"> {
327
328
  }
328
329
  /**
329
- * Error indicating a serious relay-side synchronization failure. Clients should
330
- * log this error and show a generic sync error to the user.
330
+ * Error indicating a serious relay-side synchronization failure. Sync state
331
+ * shows it as the failure of that relay's route; apps show a generic sync error
332
+ * for the owner's `Error` status.
331
333
  */
332
334
  export interface ProtocolSyncError extends OwnerError, Typed<"ProtocolSyncError"> {
333
335
  }
@@ -1 +1 @@
1
- {"version":3,"file":"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AED,eAAO,MAAM,2BAA2B,iBAEtB,UAAU,YACf,kCAAkC;AAC3C,sBAAsB;UACb,cAAc,KACtB,IAAI,CACL,iCAAiC,EACjC,wBAAwB,EACxB,UAAU,CA4JX,CAAC;AAwdJ;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,SAC5B,cAAc,eACX,WAAW,OAAO,aAAa,KAAG,iBAmB3C,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,WAAW,WAAW,KAAG,IAyBrE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAC1B,oBAAoB,OACxB,aAAa,KACjB,MAAM,CACP,QAAQ,EACN,iCAAiC,GACjC,wBAAwB,GACxB,8BAA8B,CA8DjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,qBACpB,eAAe,gBACnB,OAAO,KACpB,OAOF,CAAC;AAGF,eAAO,MAAM,iBAAiB;aAI5B,MAAM;aACN,MAAM;aACN,IAAI;aACJ,KAAK;aAIL,cAAc;aAId,WAAW;aACX,SAAS;aACT,EAAE;aACF,IAAI;aAKJ,0BAA0B;aAE1B,uBAAuB;CAIf,CAAC;AAEX,eAAO,MAAM,iBAAiB,WAAY,MAAM,SAAS,WAAW,KAAG,IAsGtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,KAAG,WA6DlD,CAAC"}
@@ -764,14 +764,9 @@ version = protocolVersion) => async (run) => {
764
764
  try {
765
765
  const result = await run(storage.writeMessages(ownerIdBytes, messages));
766
766
  if (!result.ok) {
767
- const isQuotaError = result.error.type === "StorageQuotaError";
768
- if (!isQuotaError)
769
- run.deps.console.error(result.error);
770
767
  const message = createProtocolMessageBuffer(ownerId, {
771
768
  messageType: MessageType.Response,
772
- errorCode: isQuotaError
773
- ? ProtocolErrorCode.QuotaError
774
- : ProtocolErrorCode.WriteError,
769
+ errorCode: ProtocolErrorCode.QuotaError,
775
770
  }).unwrap();
776
771
  return ok({ type: "Response", message });
777
772
  }
@@ -405,7 +405,13 @@ export interface MutationOptions {
405
405
  * Called after the mutation's changes are stored and subscribed queries
406
406
  * reflect them. Useful for follow-up work (e.g., notifications, navigation)
407
407
  * after insert, update, or upsert. It never runs when the database is
408
- * unavailable.
408
+ * unavailable or the mutation could not be stored, which
409
+ * {@link EvoluErrorDep.evoluError} reports.
410
+ *
411
+ * An Evolu instance stores its mutations in batches, each in one transaction.
412
+ * A batch holds the mutations made before Evolu sends it in a microtask,
413
+ * usually one synchronous block, and {@link Evolu.requestSync} sends it early.
414
+ * When one mutation cannot be stored, none of its batch is.
409
415
  *
410
416
  * Stored does not always mean visible. A change quarantined for
411
417
  * {@link QuarantineReason.TimestampDrift} is stored in