@evolu/common 6.0.1-preview.8 → 7.0.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 (184) hide show
  1. package/README.md +2 -2
  2. package/dist/src/Array.d.ts +256 -12
  3. package/dist/src/Array.d.ts.map +1 -1
  4. package/dist/src/Array.js +215 -9
  5. package/dist/src/Assert.d.ts +0 -13
  6. package/dist/src/Assert.d.ts.map +1 -1
  7. package/dist/src/Assert.js +0 -15
  8. package/dist/src/Brand.d.ts +75 -0
  9. package/dist/src/Brand.d.ts.map +1 -0
  10. package/dist/src/Brand.js +1 -0
  11. package/dist/src/Buffer.d.ts +1 -1
  12. package/dist/src/Buffer.d.ts.map +1 -1
  13. package/dist/src/Buffer.js +8 -7
  14. package/dist/src/Cache.d.ts +44 -0
  15. package/dist/src/Cache.d.ts.map +1 -0
  16. package/dist/src/Cache.js +52 -0
  17. package/dist/src/Callbacks.d.ts +45 -12
  18. package/dist/src/Callbacks.d.ts.map +1 -1
  19. package/dist/src/Callbacks.js +14 -7
  20. package/dist/src/Console.d.ts +31 -6
  21. package/dist/src/Console.d.ts.map +1 -1
  22. package/dist/src/Console.js +72 -9
  23. package/dist/src/Crypto.d.ts +56 -42
  24. package/dist/src/Crypto.d.ts.map +1 -1
  25. package/dist/src/Crypto.js +40 -53
  26. package/dist/src/Evolu/Db.d.ts +162 -74
  27. package/dist/src/Evolu/Db.d.ts.map +1 -1
  28. package/dist/src/Evolu/Db.js +284 -702
  29. package/dist/src/Evolu/Diff.d.ts +3 -3
  30. package/dist/src/Evolu/Diff.d.ts.map +1 -1
  31. package/dist/src/Evolu/Diff.js +7 -5
  32. package/dist/src/Evolu/Evolu.d.ts +214 -134
  33. package/dist/src/Evolu/Evolu.d.ts.map +1 -1
  34. package/dist/src/Evolu/Evolu.js +189 -180
  35. package/dist/src/Evolu/Internal.d.ts +0 -2
  36. package/dist/src/Evolu/Internal.d.ts.map +1 -1
  37. package/dist/src/Evolu/Internal.js +0 -2
  38. package/dist/src/Evolu/LocalAuth.d.ts +150 -0
  39. package/dist/src/Evolu/LocalAuth.d.ts.map +1 -0
  40. package/dist/src/Evolu/LocalAuth.js +174 -0
  41. package/dist/src/Evolu/Owner.d.ts +273 -120
  42. package/dist/src/Evolu/Owner.d.ts.map +1 -1
  43. package/dist/src/Evolu/Owner.js +130 -104
  44. package/dist/src/Evolu/Platform.d.ts +9 -7
  45. package/dist/src/Evolu/Platform.d.ts.map +1 -1
  46. package/dist/src/Evolu/Protocol.d.ts +268 -240
  47. package/dist/src/Evolu/Protocol.d.ts.map +1 -1
  48. package/dist/src/Evolu/Protocol.js +600 -454
  49. package/dist/src/Evolu/Public.d.ts +6 -8
  50. package/dist/src/Evolu/Public.d.ts.map +1 -1
  51. package/dist/src/Evolu/Public.js +2 -3
  52. package/dist/src/Evolu/PublicKysely.d.ts.map +1 -1
  53. package/dist/src/Evolu/PublicKysely.js +3 -4
  54. package/dist/src/Evolu/Query.d.ts +2 -1
  55. package/dist/src/Evolu/Query.d.ts.map +1 -1
  56. package/dist/src/Evolu/Query.js +1 -1
  57. package/dist/src/Evolu/Relay.d.ts +91 -8
  58. package/dist/src/Evolu/Relay.d.ts.map +1 -1
  59. package/dist/src/Evolu/Relay.js +214 -88
  60. package/dist/src/Evolu/Schema.d.ts +125 -47
  61. package/dist/src/Evolu/Schema.d.ts.map +1 -1
  62. package/dist/src/Evolu/Schema.js +175 -31
  63. package/dist/src/Evolu/Storage.d.ts +249 -27
  64. package/dist/src/Evolu/Storage.d.ts.map +1 -1
  65. package/dist/src/Evolu/Storage.js +198 -92
  66. package/dist/src/Evolu/Sync.d.ts +68 -13
  67. package/dist/src/Evolu/Sync.d.ts.map +1 -1
  68. package/dist/src/Evolu/Sync.js +469 -20
  69. package/dist/src/Evolu/Timestamp.d.ts +83 -30
  70. package/dist/src/Evolu/Timestamp.d.ts.map +1 -1
  71. package/dist/src/Evolu/Timestamp.js +79 -34
  72. package/dist/src/Identicon.d.ts +35 -0
  73. package/dist/src/Identicon.d.ts.map +1 -0
  74. package/dist/src/Identicon.js +143 -0
  75. package/dist/src/Instances.d.ts +34 -0
  76. package/dist/src/Instances.d.ts.map +1 -0
  77. package/dist/src/Instances.js +44 -0
  78. package/dist/src/Number.d.ts +4 -3
  79. package/dist/src/Number.d.ts.map +1 -1
  80. package/dist/src/Number.js +5 -4
  81. package/dist/src/Object.d.ts +10 -4
  82. package/dist/src/Object.d.ts.map +1 -1
  83. package/dist/src/Object.js +9 -3
  84. package/dist/src/Platform.d.ts +20 -0
  85. package/dist/src/Platform.d.ts.map +1 -0
  86. package/dist/src/Platform.js +22 -0
  87. package/dist/src/Random.d.ts +3 -2
  88. package/dist/src/Random.d.ts.map +1 -1
  89. package/dist/src/Relation.d.ts +79 -0
  90. package/dist/src/Relation.d.ts.map +1 -0
  91. package/dist/src/Relation.js +127 -0
  92. package/dist/src/Resources.d.ts +118 -0
  93. package/dist/src/Resources.d.ts.map +1 -0
  94. package/dist/src/Resources.js +197 -0
  95. package/dist/src/Result.d.ts +184 -52
  96. package/dist/src/Result.d.ts.map +1 -1
  97. package/dist/src/Result.js +30 -241
  98. package/dist/src/Skiplist.js +2 -1
  99. package/dist/src/Sqlite.d.ts +89 -5
  100. package/dist/src/Sqlite.d.ts.map +1 -1
  101. package/dist/src/Sqlite.js +136 -9
  102. package/dist/src/Task.d.ts +586 -0
  103. package/dist/src/Task.d.ts.map +1 -0
  104. package/dist/src/Task.js +469 -0
  105. package/dist/src/Time.d.ts +66 -1
  106. package/dist/src/Time.d.ts.map +1 -1
  107. package/dist/src/Time.js +99 -5
  108. package/dist/src/Type.d.ts +676 -343
  109. package/dist/src/Type.d.ts.map +1 -1
  110. package/dist/src/Type.js +718 -467
  111. package/dist/src/Types.d.ts +1 -75
  112. package/dist/src/Types.d.ts.map +1 -1
  113. package/dist/src/WebSocket.d.ts +5 -2
  114. package/dist/src/WebSocket.d.ts.map +1 -1
  115. package/dist/src/WebSocket.js +12 -18
  116. package/dist/src/Worker.d.ts +39 -11
  117. package/dist/src/Worker.d.ts.map +1 -1
  118. package/dist/src/Worker.js +22 -4
  119. package/dist/src/index.d.ts +8 -3
  120. package/dist/src/index.d.ts.map +1 -1
  121. package/dist/src/index.js +8 -3
  122. package/package.json +15 -14
  123. package/src/Array.ts +301 -19
  124. package/src/Assert.ts +0 -21
  125. package/src/Brand.ts +75 -0
  126. package/src/Buffer.ts +7 -7
  127. package/src/Cache.ts +85 -0
  128. package/src/Callbacks.ts +62 -22
  129. package/src/Console.ts +91 -11
  130. package/src/Crypto.ts +94 -90
  131. package/src/Evolu/Db.ts +519 -1026
  132. package/src/Evolu/Diff.ts +7 -5
  133. package/src/Evolu/Evolu.ts +477 -361
  134. package/src/Evolu/Internal.ts +0 -2
  135. package/src/Evolu/LocalAuth.ts +463 -0
  136. package/src/Evolu/Owner.ts +355 -228
  137. package/src/Evolu/Platform.ts +9 -9
  138. package/src/Evolu/Protocol.ts +842 -742
  139. package/src/Evolu/Public.ts +7 -14
  140. package/src/Evolu/PublicKysely.ts +4 -5
  141. package/src/Evolu/Query.ts +3 -2
  142. package/src/Evolu/Relay.ts +406 -103
  143. package/src/Evolu/Schema.ts +323 -91
  144. package/src/Evolu/Storage.ts +559 -137
  145. package/src/Evolu/Sync.ts +819 -36
  146. package/src/Evolu/Timestamp.ts +90 -58
  147. package/src/Identicon.ts +197 -0
  148. package/src/Instances.ts +90 -0
  149. package/src/Number.ts +6 -10
  150. package/src/Object.ts +13 -5
  151. package/src/Platform.ts +26 -0
  152. package/src/Random.ts +3 -2
  153. package/src/Relation.ts +234 -0
  154. package/src/Resources.ts +367 -0
  155. package/src/Result.ts +191 -54
  156. package/src/Skiplist.ts +1 -1
  157. package/src/Sqlite.ts +152 -17
  158. package/src/Task.ts +901 -0
  159. package/src/Time.ts +180 -5
  160. package/src/Type.ts +1135 -730
  161. package/src/Types.ts +1 -77
  162. package/src/WebSocket.ts +27 -25
  163. package/src/Worker.ts +72 -23
  164. package/src/index.ts +8 -3
  165. package/dist/src/Evolu/Config.d.ts +0 -69
  166. package/dist/src/Evolu/Config.d.ts.map +0 -1
  167. package/dist/src/Evolu/Config.js +0 -9
  168. package/dist/src/Evolu/Kysely.d.ts +0 -6
  169. package/dist/src/Evolu/Kysely.d.ts.map +0 -1
  170. package/dist/src/Evolu/Kysely.js +0 -21
  171. package/dist/src/ManyToManyMap.d.ts +0 -26
  172. package/dist/src/ManyToManyMap.d.ts.map +0 -1
  173. package/dist/src/ManyToManyMap.js +0 -92
  174. package/dist/src/NanoId.d.ts +0 -27
  175. package/dist/src/NanoId.d.ts.map +0 -1
  176. package/dist/src/NanoId.js +0 -6
  177. package/dist/src/Promise.d.ts +0 -180
  178. package/dist/src/Promise.d.ts.map +0 -1
  179. package/dist/src/Promise.js +0 -176
  180. package/src/Evolu/Config.ts +0 -83
  181. package/src/Evolu/Kysely.ts +0 -38
  182. package/src/ManyToManyMap.ts +0 -140
  183. package/src/NanoId.ts +0 -39
  184. package/src/Promise.ts +0 -295
@@ -1,131 +1,157 @@
1
+ import * as bip39 from "@scure/bip39";
2
+ import { wordlist } from "@scure/bip39/wordlists/english.js";
3
+ import { createSlip21, EncryptionKey, Entropy16, Entropy32, } from "../Crypto.js";
4
+ import { getOrNull } from "../Result.js";
5
+ import { brand, Id, IdBytes, idBytesToId, idToIdBytes, NonNegativeInt, } from "../Type.js";
1
6
  /**
2
- * TODO:
3
- *
4
- * @module
5
- */
6
- import { assert } from "../Assert.js";
7
- import { createEncryptionKey, createSlip21, createSlip21Id, mnemonicToMnemonicSeed, } from "../Crypto.js";
8
- import { brand, DateIso, Id, length, Uint8Array, } from "../Type.js";
9
- import { createInitialTimestamp, timestampToTimestampString, } from "./Timestamp.js";
10
- /**
11
- * The unique identifier of {@link Owner} derived from the {@link Mnemonic}.
12
- *
13
- * This branded {@link Id} type, generated by {@link createSlip21Id}, is a
14
- * 21-character {@link Base64Url} string (126 bits of entropy), providing a
15
- * compact, shareable, and secure identifier for UI use, tied to the owner's
16
- * mnemonic and derivation path.
7
+ * OwnerId is a branded {@link Id} that uniquely identifies an {@link Owner}.
8
+ * Branded from {@link Id} to leverage existing helpers like {@link idToIdBytes}.
17
9
  */
18
10
  export const OwnerId = brand("OwnerId", Id);
19
- export const writeKeyLength = 16;
11
+ /** Bytes representation of {@link OwnerId}. */
12
+ export const OwnerIdBytes = brand("OwnerIdBytes", IdBytes);
13
+ export const ownerIdToOwnerIdBytes = (ownerId) => idToIdBytes(ownerId);
14
+ export const ownerIdBytesToOwnerId = (ownerIdBytes) => idBytesToId(ownerIdBytes);
15
+ export const ownerWriteKeyLength = NonNegativeInt.orThrow(16);
16
+ export const OwnerEncryptionKey = brand("OwnerEncryptionKey", EncryptionKey);
20
17
  /**
21
- * A secure token proving the initiator can write changes. Derived from a
22
- * mnemonic or randomly generated. It's rotatable.
18
+ * A secure token for write operations. It's derived from {@link OwnerSecret} by
19
+ * default and can be rotated via {@link createOwnerWriteKey}.
23
20
  */
24
- export const WriteKey = brand("WriteKey", length(writeKeyLength)(Uint8Array));
21
+ export const OwnerWriteKey = brand("OwnerWriteKey", Entropy16);
25
22
  /**
26
- * Creates an {@link AppOwner}, optionally from an existing mnemonic to restore
27
- * it on another device; otherwise, generates a new mnemonic.
23
+ * 32 bytes of cryptographic entropy used to derive {@link Owner} keys.
24
+ *
25
+ * Can be created using {@link createOwnerSecret} or converted from a
26
+ * {@link Mnemonic} using {@link mnemonicToOwnerSecret}.
28
27
  */
29
- export const createAppOwner = (deps) => (mnemonic = deps.createMnemonic()) => {
30
- const owner = createOwner(deps)(mnemonic);
31
- return { type: "AppOwner", ...owner };
32
- };
28
+ export const OwnerSecret = brand("OwnerSecret", Entropy32);
29
+ /** Creates a {@link OwnerSecret}. */
30
+ export const createOwnerSecret = (deps) => deps.randomBytes.create(32);
31
+ /** Converts an {@link OwnerSecret} to a {@link Mnemonic}. */
32
+ export const ownerSecretToMnemonic = (secret) => bip39.entropyToMnemonic(secret, wordlist);
33
+ /** Converts a {@link Mnemonic} to an {@link OwnerSecret}. */
34
+ export const mnemonicToOwnerSecret = (mnemonic) => bip39.mnemonicToEntropy(mnemonic, wordlist);
35
+ /** Creates a randomly generated {@link OwnerWriteKey}. */
36
+ export const createOwnerWriteKey = (deps) => deps.randomBytes.create(16);
33
37
  /**
34
- * Creates a {@link ShardOwner} for sharding app data with a freshly generated
35
- * mnemonic. Unlike {@link createAppOwner}, it doesn’t accept an existing
36
- * mnemonic because ShardOwner mnemonics are always generated and restored
37
- * automatically via database sync.
38
+ * Creates an {@link Owner} from a {@link OwnerSecret} using SLIP-21 key
39
+ * derivation.
40
+ *
41
+ * This is an internal helper function, use:
42
+ *
43
+ * - {@link createAppOwner}
44
+ * - {@link createShardOwner}
45
+ * - {@link createSharedOwner}
46
+ * - {@link createSharedReadonlyOwner}
38
47
  */
39
- export const createShardOwner = (deps) => {
40
- const owner = createOwner(deps)();
48
+ export const createOwner = (secret) => ({
49
+ id: ownerIdBytesToOwnerId(OwnerIdBytes.orThrow(createSlip21(secret, ["Evolu", "OwnerIdBytes"]).slice(0, 16))),
50
+ encryptionKey: OwnerEncryptionKey.orThrow(createSlip21(secret, ["Evolu", "OwnerEncryptionKey"])),
51
+ writeKey: OwnerWriteKey.orThrow(createSlip21(secret, ["Evolu", "OwnerWriteKey"]).slice(0, 16)),
52
+ });
53
+ /** Creates an {@link AppOwner} from an {@link OwnerSecret}. */
54
+ export const createAppOwner = (secret) => ({
55
+ type: "AppOwner",
56
+ mnemonic: ownerSecretToMnemonic(secret),
57
+ ...createOwner(secret),
58
+ });
59
+ /** Creates a {@link ShardOwner} from an {@link OwnerSecret}. */
60
+ export const createShardOwner = (secret, transports) => {
41
61
  return {
42
62
  type: "ShardOwner",
43
- mnemonic: owner.mnemonic,
44
- writeKey: owner.writeKey,
63
+ ...createOwner(secret),
64
+ ...(transports && { transports }),
45
65
  };
46
66
  };
47
67
  /**
48
- * Creates a fresh {@link SharedOwner} for sharing data with write access. Takes
49
- * no arguments as both `mnemonic` and rotatable `writeKey` are newly generated;
50
- * when shared, recipients use the provided `mnemonic` and `writeKey` directly
51
- * as a {@link SharedOwner} without needing to recreate it.
68
+ * Derives a {@link ShardOwner} from an {@link AppOwner} using the specified path.
69
+ *
70
+ * **Advantages of derived owners:**
71
+ *
72
+ * - **Deterministic**: Same path always produces the same ShardOwner across all
73
+ * devices
74
+ * - **Immediate availability**: Can be hardcoded and used before sync occurs
75
+ * - **Consistent setup**: All devices start with identical data structure
76
+ * - **Lifecycle management**: Can implement epoch patterns for clean data
77
+ * deletion and recreation
78
+ *
79
+ * **Common patterns:**
80
+ *
81
+ * - Use paths like `["shard", 1]` for versioned data lifecycle
82
+ * - Use paths like `["project", "MyApp", 1]` for named partitions with versions
83
+ * - Each device can derive the same owners and set up initial structure
52
84
  */
53
- export const createSharedOwner = (deps) => {
54
- const mnemonic = deps.createMnemonic();
55
- const writeKey = createWriteKey(deps)(); // Random, no seed
85
+ export const deriveShardOwner = (owner, path, transports) => {
86
+ const secret = createSlip21(owner.encryptionKey, path);
56
87
  return {
57
- type: "SharedOwner",
58
- mnemonic,
59
- writeKey,
88
+ type: "ShardOwner",
89
+ ...createOwner(secret),
90
+ ...(transports && { transports }),
60
91
  };
61
92
  };
62
93
  /**
63
- * Creates a {@link SharedReadonlyOwner} from a {@link SharedOwner} for read-only
64
- * data sharing. Extracts the `mnemonic` from the provided {@link SharedOwner},
65
- * omitting its `writeKey` to ensure read-only access.
94
+ * Creates a {@link SharedOwner} from an {@link OwnerSecret} for collaborative
95
+ * write access.
96
+ *
97
+ * Use {@link createSharedReadonlyOwner} to create a read-only version for
98
+ * sharing.
66
99
  */
67
- export const createSharedReadonlyOwner = (sharedOwner) => {
100
+ export const createSharedOwner = (secret, transports) => {
68
101
  return {
69
- type: "SharedReadonlyOwner",
70
- mnemonic: sharedOwner.mnemonic,
71
- };
72
- };
73
- /** Creates an {@link Owner} with optional `mnemonic` and `writeKey`. */
74
- export const createOwner = (deps) => (mnemonic = deps.createMnemonic(), writeKey) => {
75
- const seed = mnemonicToMnemonicSeed(mnemonic);
76
- const id = createSlip21Id(seed, ["Evolu", "Owner Id"]);
77
- const encryptionKey = createEncryptionKey(seed);
78
- const createdAt = DateIso.fromParent(new Date(deps.time.now()));
79
- assert(createdAt.ok, "Invalid DateIso: bad system clock");
80
- return {
81
- mnemonic,
82
- createdAt: createdAt.value,
83
- id,
84
- encryptionKey,
85
- writeKey: writeKey ?? createWriteKey(deps)(seed),
102
+ type: "SharedOwner",
103
+ ...createOwner(secret),
104
+ ...(transports && { transports }),
86
105
  };
87
106
  };
88
- export const createWriteKey = (deps) => (seed) => {
89
- const key = seed
90
- ? createSlip21(seed, ["Evolu", "Write Key"]).slice(0, 16)
91
- : deps.createRandomBytes(16);
92
- const writeKey = WriteKey.from(key);
93
- assert(writeKey.ok, "Ensure valid WriteKey");
94
- return writeKey.value;
95
- };
107
+ /** Creates a {@link SharedReadonlyOwner} from a {@link SharedOwner}. */
108
+ export const createSharedReadonlyOwner = (sharedOwner) => ({
109
+ type: "SharedReadonlyOwner",
110
+ id: sharedOwner.id,
111
+ encryptionKey: sharedOwner.encryptionKey,
112
+ ...(sharedOwner.transports && { transports: sharedOwner.transports }),
113
+ });
96
114
  /**
97
- * Creates an {@link OwnerRow} from any {@link Owner} variant for the
98
- * `evolu_owner` table, adding a `timestamp` ({@link TimestampString}) for CRDT
99
- * sync.
115
+ * Creates an {@link OwnerWebSocketTransport} for the given relay URL and
116
+ * {@link OwnerId}.
117
+ *
118
+ * The URL must be a WebSocket base URL without query parameters or fragments
119
+ * (e.g., `wss://relay.evolu.dev`, not `wss://relay.evolu.dev?foo=bar`). The
120
+ * function appends the `ownerId` as a query parameter.
121
+ *
122
+ * ### Example
123
+ *
124
+ * ```ts
125
+ * // Create transport "wss://relay.evolu.dev?ownerId=..."
126
+ * const transport = createOwnerWebSocketTransport({
127
+ * url: "wss://relay.evolu.dev",
128
+ * ownerId: owner.id,
129
+ * });
130
+ *
131
+ * // Use with createEvolu
132
+ * const evolu = createEvolu(deps)(Schema, {
133
+ * transports: [transport],
134
+ * });
135
+ * ```
100
136
  */
101
- export const createOwnerRow = (deps) => (owner) => {
102
- const timestamp = timestampToTimestampString(createInitialTimestamp(deps));
103
- switch (owner.type) {
104
- case "AppOwner": {
105
- const { type, ...rest } = owner;
106
- return { ...rest, timestamp };
107
- }
108
- case "ShardOwner":
109
- case "SharedOwner":
110
- return {
111
- ...createOwner(deps)(owner.mnemonic, owner.writeKey),
112
- timestamp,
113
- };
114
- case "SharedReadonlyOwner":
115
- return {
116
- ...createOwner(deps)(owner.mnemonic),
117
- writeKey: null,
118
- timestamp,
119
- };
120
- }
121
- };
137
+ export const createOwnerWebSocketTransport = (config) => ({
138
+ type: "WebSocket",
139
+ url: `${config.url}?ownerId=${config.ownerId}`,
140
+ });
122
141
  /**
123
- * Rotates the {@link WriteKey} for an {@link AppOwner}, {@link ShardOwner}, or
124
- * {@link SharedOwner}, returning a new instance with the updated key.
142
+ * Extracts {@link OwnerId} from an {@link OwnerWebSocketTransport} URL query
143
+ * string.
144
+ *
145
+ * Parses the query string `?ownerId=...` and validates that the extracted value
146
+ * is a valid {@link OwnerId}.
147
+ *
148
+ * ### Example
149
+ *
150
+ * ```ts
151
+ * parseOwnerIdFromOwnerWebSocketTransportUrl(
152
+ * "/sync?ownerId=_12345678abcdefgh",
153
+ * );
154
+ * // Returns: OwnerId or null
155
+ * ```
125
156
  */
126
- export const rotateWriteKey = (owner, newWriteKey) => {
127
- return {
128
- ...owner,
129
- writeKey: newWriteKey,
130
- };
131
- };
157
+ export const parseOwnerIdFromOwnerWebSocketTransportUrl = (url) => getOrNull(OwnerId.fromUnknown(url.split("=")[1]));
@@ -1,4 +1,3 @@
1
- import { Config } from "./Config.js";
2
1
  /**
3
2
  * FlushSync is for libraries like React to flush updates synchronously inside
4
3
  * the provided callback to ensure the DOM is updated immediately.
@@ -13,11 +12,14 @@ export type FlushSync = (callback: () => void) => void;
13
12
  export interface FlushSyncDep {
14
13
  readonly flushSync: FlushSync;
15
14
  }
16
- export interface AppState {
17
- readonly reset: () => void;
18
- }
19
- export type CreateAppState = (config: Config) => AppState;
20
- export interface CreateAppStateDep {
21
- readonly createAppState: CreateAppState;
15
+ /**
16
+ * Reload the app in a platform-specific way.
17
+ *
18
+ * - **Web**: Redirects to the specified URL
19
+ * - **React Native**: Restarts the app (URL parameter ignored)
20
+ */
21
+ export type ReloadApp = (url: string) => void;
22
+ export interface ReloadAppDep {
23
+ readonly reloadApp: ReloadApp;
22
24
  }
23
25
  //# sourceMappingURL=Platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,QAAQ,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;CACzC"}
1
+ {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../../src/Evolu/Platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAEvD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAE9C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B"}