@evolu/common 7.4.0 → 8.0.0-next.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 (251) hide show
  1. package/README.md +4 -61
  2. package/dist/src/Array.d.ts +343 -102
  3. package/dist/src/Array.d.ts.map +1 -1
  4. package/dist/src/Array.js +181 -85
  5. package/dist/src/Assert.d.ts +57 -11
  6. package/dist/src/Assert.d.ts.map +1 -1
  7. package/dist/src/Assert.js +47 -11
  8. package/dist/src/BigInt.d.ts +6 -1
  9. package/dist/src/BigInt.d.ts.map +1 -1
  10. package/dist/src/BigInt.js +5 -0
  11. package/dist/src/Brand.d.ts +40 -12
  12. package/dist/src/Brand.d.ts.map +1 -1
  13. package/dist/src/Brand.js +5 -0
  14. package/dist/src/Buffer.d.ts +6 -1
  15. package/dist/src/Buffer.d.ts.map +1 -1
  16. package/dist/src/Buffer.js +7 -2
  17. package/dist/src/Cache.d.ts +10 -2
  18. package/dist/src/Cache.d.ts.map +1 -1
  19. package/dist/src/Cache.js +6 -0
  20. package/dist/src/Callbacks.d.ts +10 -7
  21. package/dist/src/Callbacks.d.ts.map +1 -1
  22. package/dist/src/Callbacks.js +23 -13
  23. package/dist/src/Console.d.ts +361 -69
  24. package/dist/src/Console.d.ts.map +1 -1
  25. package/dist/src/Console.js +217 -117
  26. package/dist/src/Crypto.d.ts +70 -21
  27. package/dist/src/Crypto.d.ts.map +1 -1
  28. package/dist/src/Crypto.js +72 -27
  29. package/dist/src/Eq.d.ts +22 -2
  30. package/dist/src/Eq.d.ts.map +1 -1
  31. package/dist/src/Eq.js +21 -1
  32. package/dist/src/Error.d.ts +23 -12
  33. package/dist/src/Error.d.ts.map +1 -1
  34. package/dist/src/Error.js +27 -11
  35. package/dist/src/Function.d.ts +128 -56
  36. package/dist/src/Function.d.ts.map +1 -1
  37. package/dist/src/Function.js +118 -14
  38. package/dist/src/Identicon.d.ts +5 -0
  39. package/dist/src/Identicon.d.ts.map +1 -1
  40. package/dist/src/Identicon.js +6 -1
  41. package/dist/src/Lookup.d.ts +160 -0
  42. package/dist/src/Lookup.d.ts.map +1 -0
  43. package/dist/src/Lookup.js +192 -0
  44. package/dist/src/Microtask.d.ts +21 -0
  45. package/dist/src/Microtask.d.ts.map +1 -0
  46. package/dist/src/Microtask.js +37 -0
  47. package/dist/src/Number.d.ts +18 -4
  48. package/dist/src/Number.d.ts.map +1 -1
  49. package/dist/src/Number.js +23 -1
  50. package/dist/src/Object.d.ts +110 -5
  51. package/dist/src/Object.d.ts.map +1 -1
  52. package/dist/src/Object.js +108 -5
  53. package/dist/src/Option.d.ts +58 -0
  54. package/dist/src/Option.d.ts.map +1 -0
  55. package/dist/src/Option.js +43 -0
  56. package/dist/src/Order.d.ts +5 -0
  57. package/dist/src/Order.d.ts.map +1 -1
  58. package/dist/src/Order.js +8 -3
  59. package/dist/src/Platform.d.ts +36 -2
  60. package/dist/src/Platform.d.ts.map +1 -1
  61. package/dist/src/Platform.js +10 -6
  62. package/dist/src/Polyfills.d.ts +27 -0
  63. package/dist/src/Polyfills.d.ts.map +1 -0
  64. package/dist/src/Polyfills.js +299 -0
  65. package/dist/src/Random.d.ts +18 -7
  66. package/dist/src/Random.d.ts.map +1 -1
  67. package/dist/src/Random.js +9 -7
  68. package/dist/src/Redacted.d.ts +7 -4
  69. package/dist/src/Redacted.d.ts.map +1 -1
  70. package/dist/src/Redacted.js +5 -0
  71. package/dist/src/Ref.d.ts +31 -16
  72. package/dist/src/Ref.d.ts.map +1 -1
  73. package/dist/src/Ref.js +35 -7
  74. package/dist/src/RefCount.d.ts +62 -0
  75. package/dist/src/RefCount.d.ts.map +1 -0
  76. package/dist/src/RefCount.js +83 -0
  77. package/dist/src/Relation.d.ts +84 -29
  78. package/dist/src/Relation.d.ts.map +1 -1
  79. package/dist/src/Relation.js +83 -105
  80. package/dist/src/Resource.d.ts +263 -0
  81. package/dist/src/Resource.d.ts.map +1 -0
  82. package/dist/src/Resource.js +389 -0
  83. package/dist/src/Result.d.ts +390 -374
  84. package/dist/src/Result.d.ts.map +1 -1
  85. package/dist/src/Result.js +142 -70
  86. package/dist/src/Schedule.d.ts +953 -0
  87. package/dist/src/Schedule.d.ts.map +1 -0
  88. package/dist/src/Schedule.js +1199 -0
  89. package/dist/src/Set.d.ts +181 -0
  90. package/dist/src/Set.d.ts.map +1 -0
  91. package/dist/src/Set.js +137 -0
  92. package/dist/src/Skiplist.d.ts +6 -1
  93. package/dist/src/Skiplist.d.ts.map +1 -1
  94. package/dist/src/Skiplist.js +5 -0
  95. package/dist/src/Sqlite.d.ts +160 -60
  96. package/dist/src/Sqlite.d.ts.map +1 -1
  97. package/dist/src/Sqlite.js +290 -190
  98. package/dist/src/Store.d.ts +36 -28
  99. package/dist/src/Store.d.ts.map +1 -1
  100. package/dist/src/Store.js +55 -15
  101. package/dist/src/String.d.ts +5 -0
  102. package/dist/src/String.d.ts.map +1 -1
  103. package/dist/src/String.js +5 -0
  104. package/dist/src/Task.d.ts +2263 -423
  105. package/dist/src/Task.d.ts.map +1 -1
  106. package/dist/src/Task.js +1488 -348
  107. package/dist/src/Test.d.ts +122 -0
  108. package/dist/src/Test.d.ts.map +1 -0
  109. package/dist/src/Test.js +66 -0
  110. package/dist/src/Time.d.ts +201 -48
  111. package/dist/src/Time.d.ts.map +1 -1
  112. package/dist/src/Time.js +190 -86
  113. package/dist/src/Tracer.d.ts +48 -0
  114. package/dist/src/Tracer.d.ts.map +1 -0
  115. package/dist/src/Tracer.js +6 -0
  116. package/dist/src/Type.d.ts +582 -209
  117. package/dist/src/Type.d.ts.map +1 -1
  118. package/dist/src/Type.js +362 -240
  119. package/dist/src/Types.d.ts +160 -6
  120. package/dist/src/Types.d.ts.map +1 -1
  121. package/dist/src/Types.js +22 -2
  122. package/dist/src/WebSocket.d.ts +113 -58
  123. package/dist/src/WebSocket.d.ts.map +1 -1
  124. package/dist/src/WebSocket.js +210 -118
  125. package/dist/src/Worker.d.ts +245 -60
  126. package/dist/src/Worker.d.ts.map +1 -1
  127. package/dist/src/Worker.js +220 -64
  128. package/dist/src/index.d.ts +25 -3
  129. package/dist/src/index.d.ts.map +1 -1
  130. package/dist/src/index.js +19 -3
  131. package/dist/src/local-first/Db.d.ts +24 -213
  132. package/dist/src/local-first/Db.d.ts.map +1 -1
  133. package/dist/src/local-first/Db.js +622 -293
  134. package/dist/src/local-first/Error.d.ts +12 -0
  135. package/dist/src/local-first/Error.d.ts.map +1 -0
  136. package/dist/src/local-first/Error.js +6 -0
  137. package/dist/src/local-first/Evolu.d.ts +330 -285
  138. package/dist/src/local-first/Evolu.d.ts.map +1 -1
  139. package/dist/src/local-first/Evolu.js +472 -402
  140. package/dist/src/local-first/LocalAuth.d.ts +10 -10
  141. package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
  142. package/dist/src/local-first/LocalAuth.js +6 -1
  143. package/dist/src/local-first/Owner.d.ts +70 -27
  144. package/dist/src/local-first/Owner.d.ts.map +1 -1
  145. package/dist/src/local-first/Owner.js +27 -14
  146. package/dist/src/local-first/Protocol.d.ts +58 -50
  147. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  148. package/dist/src/local-first/Protocol.js +253 -155
  149. package/dist/src/local-first/Query.d.ts +133 -43
  150. package/dist/src/local-first/Query.d.ts.map +1 -1
  151. package/dist/src/local-first/Query.js +139 -90
  152. package/dist/src/local-first/Relay.d.ts +18 -38
  153. package/dist/src/local-first/Relay.d.ts.map +1 -1
  154. package/dist/src/local-first/Relay.js +59 -171
  155. package/dist/src/local-first/Schema.d.ts +139 -144
  156. package/dist/src/local-first/Schema.d.ts.map +1 -1
  157. package/dist/src/local-first/Schema.js +78 -163
  158. package/dist/src/local-first/Shared.d.ts +125 -0
  159. package/dist/src/local-first/Shared.d.ts.map +1 -0
  160. package/dist/src/local-first/Shared.js +569 -0
  161. package/dist/src/local-first/Storage.d.ts +50 -53
  162. package/dist/src/local-first/Storage.d.ts.map +1 -1
  163. package/dist/src/local-first/Storage.js +121 -173
  164. package/dist/src/local-first/Timestamp.d.ts +28 -35
  165. package/dist/src/local-first/Timestamp.d.ts.map +1 -1
  166. package/dist/src/local-first/Timestamp.js +24 -25
  167. package/dist/src/local-first/index.d.ts +2 -15
  168. package/dist/src/local-first/index.d.ts.map +1 -1
  169. package/dist/src/local-first/index.js +2 -15
  170. package/package.json +36 -26
  171. package/src/Array.ts +467 -106
  172. package/src/Assert.ts +87 -12
  173. package/src/BigInt.ts +7 -1
  174. package/src/Brand.ts +41 -12
  175. package/src/Buffer.ts +10 -4
  176. package/src/Cache.ts +11 -2
  177. package/src/Callbacks.ts +33 -23
  178. package/src/Console.ts +567 -178
  179. package/src/Crypto.ts +111 -62
  180. package/src/Eq.ts +30 -3
  181. package/src/Error.ts +50 -34
  182. package/src/Function.ts +140 -68
  183. package/src/Identicon.ts +7 -1
  184. package/src/Lookup.ts +415 -0
  185. package/src/Microtask.ts +58 -0
  186. package/src/Number.ts +40 -7
  187. package/src/Object.ts +155 -16
  188. package/src/Option.ts +74 -0
  189. package/src/Order.ts +11 -3
  190. package/src/Platform.ts +43 -7
  191. package/src/Polyfills.ts +465 -0
  192. package/src/Random.ts +25 -11
  193. package/src/Redacted.ts +8 -4
  194. package/src/Ref.ts +72 -21
  195. package/src/RefCount.ts +170 -0
  196. package/src/Relation.ts +188 -136
  197. package/src/Resource.ts +864 -0
  198. package/src/Result.ts +548 -381
  199. package/src/Schedule.ts +1471 -0
  200. package/src/Set.ts +247 -0
  201. package/src/Skiplist.ts +7 -1
  202. package/src/Sqlite.ts +409 -304
  203. package/src/Store.ts +94 -48
  204. package/src/String.ts +6 -0
  205. package/src/Task.ts +3685 -740
  206. package/src/Test.ts +162 -0
  207. package/src/Time.ts +348 -145
  208. package/src/Tracer.ts +54 -0
  209. package/src/Type.ts +1064 -630
  210. package/src/Types.ts +202 -7
  211. package/src/WebSocket.ts +311 -178
  212. package/src/Worker.ts +527 -147
  213. package/src/index.ts +74 -3
  214. package/src/local-first/Db.ts +871 -597
  215. package/src/local-first/Error.ts +17 -0
  216. package/src/local-first/Evolu.ts +884 -823
  217. package/src/local-first/LocalAuth.ts +10 -10
  218. package/src/local-first/Owner.ts +94 -42
  219. package/src/local-first/Protocol.ts +440 -303
  220. package/src/local-first/Query.ts +243 -194
  221. package/src/local-first/Relay.ts +91 -252
  222. package/src/local-first/Schema.ts +284 -394
  223. package/src/local-first/Shared.ts +932 -0
  224. package/src/local-first/Storage.ts +209 -282
  225. package/src/local-first/Timestamp.ts +38 -45
  226. package/src/local-first/index.ts +2 -16
  227. package/LICENSE +0 -21
  228. package/dist/src/Instances.d.ts +0 -34
  229. package/dist/src/Instances.d.ts.map +0 -1
  230. package/dist/src/Instances.js +0 -44
  231. package/dist/src/Resources.d.ts +0 -118
  232. package/dist/src/Resources.d.ts.map +0 -1
  233. package/dist/src/Resources.js +0 -197
  234. package/dist/src/local-first/Platform.d.ts +0 -25
  235. package/dist/src/local-first/Platform.d.ts.map +0 -1
  236. package/dist/src/local-first/Platform.js +0 -1
  237. package/dist/src/local-first/Public.d.ts +0 -22
  238. package/dist/src/local-first/Public.d.ts.map +0 -1
  239. package/dist/src/local-first/Public.js +0 -15
  240. package/dist/src/local-first/PublicKysely.d.ts +0 -148
  241. package/dist/src/local-first/PublicKysely.d.ts.map +0 -1
  242. package/dist/src/local-first/PublicKysely.js +0 -184
  243. package/dist/src/local-first/Sync.d.ts +0 -112
  244. package/dist/src/local-first/Sync.d.ts.map +0 -1
  245. package/dist/src/local-first/Sync.js +0 -529
  246. package/src/Instances.ts +0 -90
  247. package/src/Resources.ts +0 -367
  248. package/src/local-first/Platform.ts +0 -27
  249. package/src/local-first/Public.ts +0 -42
  250. package/src/local-first/PublicKysely.ts +0 -239
  251. package/src/local-first/Sync.ts +0 -960
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Polyfills.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * Installs polyfills required by `@evolu/common`.
8
+ *
9
+ * Installs resource-management polyfills (`Symbol.dispose`,
10
+ * `Symbol.asyncDispose`, `DisposableStack`, `AsyncDisposableStack`, and
11
+ * `SuppressedError`), which are not yet supported by Safari and React Native.
12
+ *
13
+ * Evolu currently does not require any additional polyfills. If that changes,
14
+ * this is where they will be installed.
15
+ *
16
+ * `@evolu/react-native` has its own `Polyfills` module and its
17
+ * `installPolyfills` calls this function first, then installs React Native
18
+ * specific polyfills.
19
+ *
20
+ * Call this explicitly from the app entry point.
21
+ *
22
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Resource_management
23
+ * @see https://github.com/es-shims/DisposableStack
24
+ * @see https://github.com/es-shims/DisposableStack/issues/9
25
+ */
26
+ export const installPolyfills = () => {
27
+ /**
28
+ * This module intentionally owns `DisposableStack` and `AsyncDisposableStack`
29
+ * polyfills instead of depending on `es-shims/DisposableStack` at runtime.
30
+ *
31
+ * Evolu originally used the upstream package, but WebKit hit a known async
32
+ * disposal completion bug (`completion["?"]` crash, see issue #9). The local
33
+ * implementation applies the fix and keeps behavior deterministic across
34
+ * runtimes used by Evolu.
35
+ *
36
+ * Conformance is validated by tests that combine upstream-style and test262
37
+ * parity cases with Evolu-specific regressions. Those tests run against
38
+ * native Node.js behavior and against this polyfill path in browser projects,
39
+ * including WebKit.
40
+ */
41
+ installDisposableStack();
42
+ };
43
+ /** Installs `DisposableStack`-related polyfills missing from the runtime. */
44
+ const installDisposableStack = () => {
45
+ installSuppressedError();
46
+ const symbolDispose = getOrInstallSymbol("dispose", "Symbol.dispose");
47
+ const symbolAsyncDispose = getOrInstallSymbol("asyncDispose", "Symbol.asyncDispose");
48
+ if (typeof globalThis.DisposableStack !== "function") {
49
+ defineGlobalValue(globalThis, "DisposableStack", createDisposableStackPolyfill(symbolDispose));
50
+ }
51
+ if (typeof globalThis.AsyncDisposableStack !== "function") {
52
+ defineGlobalValue(globalThis, "AsyncDisposableStack", createAsyncDisposableStackPolyfill(symbolDispose, symbolAsyncDispose));
53
+ }
54
+ };
55
+ const suppressedErrorMessage = "An error was suppressed during disposal.";
56
+ const disposedMessage = (className, method) => `Cannot call ${className}.prototype.${method} on an already-disposed DisposableStack`;
57
+ const defineGlobalValue = (target, key, value) => {
58
+ Object.defineProperty(target, key, {
59
+ configurable: true,
60
+ enumerable: false,
61
+ writable: true,
62
+ value,
63
+ });
64
+ };
65
+ const defineMethodAlias = (target, alias, methodName) => {
66
+ defineGlobalValue(target, alias, Object.getOwnPropertyDescriptor(target, methodName)?.value);
67
+ };
68
+ const throwIfDisposed = (disposed, message) => {
69
+ if (disposed) {
70
+ throw new ReferenceError(message);
71
+ }
72
+ };
73
+ const appendDisposeError = (currentError, previousError) => new globalThis.SuppressedError(currentError, previousError, suppressedErrorMessage);
74
+ const assertObjectOrFunction = (value) => {
75
+ if ((typeof value !== "object" || value === null) &&
76
+ typeof value !== "function") {
77
+ throw new TypeError("Disposable value must be an object or function.");
78
+ }
79
+ return value;
80
+ };
81
+ const getMethod = (value, key) => {
82
+ const method = value[key];
83
+ if (method === undefined)
84
+ return undefined;
85
+ if (typeof method !== "function") {
86
+ throw new TypeError("Disposable method must be a function.");
87
+ }
88
+ return method;
89
+ };
90
+ const getOrInstallSymbol = (key, description) => {
91
+ const SymbolCtor = globalThis.Symbol;
92
+ const installedValue = Object.getOwnPropertyDescriptor(SymbolCtor, key)
93
+ ?.value;
94
+ const installed = typeof installedValue === "symbol" ? installedValue : undefined;
95
+ if (installed != null)
96
+ return installed;
97
+ const symbol = Symbol(description);
98
+ Object.defineProperty(SymbolCtor, key, {
99
+ configurable: false,
100
+ enumerable: false,
101
+ writable: false,
102
+ value: symbol,
103
+ });
104
+ return symbol;
105
+ };
106
+ const installSuppressedError = () => {
107
+ if (typeof globalThis.SuppressedError === "function")
108
+ return;
109
+ class SuppressedErrorPolyfill extends Error {
110
+ error;
111
+ suppressed;
112
+ constructor(error, suppressed, message) {
113
+ super(message ?? suppressedErrorMessage);
114
+ this.name = "SuppressedError";
115
+ this.error = error;
116
+ this.suppressed = suppressed;
117
+ }
118
+ }
119
+ defineGlobalValue(globalThis, "SuppressedError", SuppressedErrorPolyfill);
120
+ };
121
+ const createDisposableStackPolyfill = (symbolDispose) => {
122
+ class DisposableStackPolyfill {
123
+ #disposed = false;
124
+ #resources = [];
125
+ get disposed() {
126
+ return this.#disposed;
127
+ }
128
+ use(value) {
129
+ throwIfDisposed(this.#disposed, disposedMessage("DisposableStack", "use"));
130
+ if (value == null)
131
+ return value;
132
+ const target = assertObjectOrFunction(value);
133
+ const method = getMethod(target, symbolDispose);
134
+ if (method == null) {
135
+ throw new TypeError("Resource does not implement Symbol.dispose.");
136
+ }
137
+ this.#resources.push({
138
+ dispose: () => {
139
+ method.call(target);
140
+ },
141
+ });
142
+ return value;
143
+ }
144
+ adopt(value, onDispose) {
145
+ throwIfDisposed(this.#disposed, disposedMessage("DisposableStack", "adopt"));
146
+ if (typeof onDispose !== "function") {
147
+ throw new TypeError("onDispose must be a function.");
148
+ }
149
+ this.#resources.push({
150
+ dispose: () => {
151
+ onDispose(value);
152
+ },
153
+ });
154
+ return value;
155
+ }
156
+ defer(onDispose) {
157
+ throwIfDisposed(this.#disposed, disposedMessage("DisposableStack", "defer"));
158
+ if (typeof onDispose !== "function") {
159
+ throw new TypeError("onDispose must be a function.");
160
+ }
161
+ this.#resources.push({
162
+ dispose: () => {
163
+ onDispose();
164
+ },
165
+ });
166
+ }
167
+ move() {
168
+ throwIfDisposed(this.#disposed, disposedMessage("DisposableStack", "move"));
169
+ const moved = new DisposableStackPolyfill();
170
+ moved.#resources = this.#resources;
171
+ this.#resources = [];
172
+ this.#disposed = true;
173
+ return moved;
174
+ }
175
+ dispose() {
176
+ if (this.#disposed)
177
+ return;
178
+ this.#disposed = true;
179
+ const resources = this.#resources;
180
+ this.#resources = [];
181
+ let completionError = undefined;
182
+ let hasCompletionError = false;
183
+ for (let i = resources.length - 1; i >= 0; i--) {
184
+ try {
185
+ resources[i].dispose();
186
+ }
187
+ catch (error) {
188
+ completionError = hasCompletionError
189
+ ? appendDisposeError(error, completionError)
190
+ : error;
191
+ hasCompletionError = true;
192
+ }
193
+ }
194
+ if (hasCompletionError) {
195
+ throw completionError;
196
+ }
197
+ }
198
+ }
199
+ defineMethodAlias(DisposableStackPolyfill.prototype, symbolDispose, "dispose");
200
+ Object.defineProperty(DisposableStackPolyfill.prototype, Symbol.toStringTag, {
201
+ configurable: true,
202
+ enumerable: false,
203
+ writable: false,
204
+ value: "DisposableStack",
205
+ });
206
+ return DisposableStackPolyfill;
207
+ };
208
+ const createAsyncDisposableStackPolyfill = (symbolDispose, symbolAsyncDispose) => {
209
+ class AsyncDisposableStackPolyfill {
210
+ #disposed = false;
211
+ #resources = [];
212
+ get disposed() {
213
+ return this.#disposed;
214
+ }
215
+ use(value) {
216
+ throwIfDisposed(this.#disposed, disposedMessage("AsyncDisposableStack", "use"));
217
+ if (value == null)
218
+ return value;
219
+ const target = assertObjectOrFunction(value);
220
+ const asyncMethod = getMethod(target, symbolAsyncDispose);
221
+ if (asyncMethod != null) {
222
+ this.#resources.push({
223
+ dispose: async () => {
224
+ await asyncMethod.call(target);
225
+ },
226
+ });
227
+ return value;
228
+ }
229
+ const syncMethod = getMethod(target, symbolDispose);
230
+ if (syncMethod != null) {
231
+ this.#resources.push({
232
+ dispose: () => Promise.resolve().then(() => {
233
+ syncMethod.call(target);
234
+ }),
235
+ });
236
+ return value;
237
+ }
238
+ throw new TypeError("Resource does not implement Symbol.asyncDispose or Symbol.dispose.");
239
+ }
240
+ adopt(value, onDisposeAsync) {
241
+ throwIfDisposed(this.#disposed, disposedMessage("AsyncDisposableStack", "adopt"));
242
+ if (typeof onDisposeAsync !== "function") {
243
+ throw new TypeError("onDisposeAsync must be a function.");
244
+ }
245
+ this.#resources.push({
246
+ dispose: () => Promise.resolve().then(() => onDisposeAsync(value)),
247
+ });
248
+ return value;
249
+ }
250
+ defer(onDisposeAsync) {
251
+ throwIfDisposed(this.#disposed, disposedMessage("AsyncDisposableStack", "defer"));
252
+ if (typeof onDisposeAsync !== "function") {
253
+ throw new TypeError("onDisposeAsync must be a function.");
254
+ }
255
+ this.#resources.push({
256
+ dispose: () => Promise.resolve().then(() => onDisposeAsync()),
257
+ });
258
+ }
259
+ move() {
260
+ throwIfDisposed(this.#disposed, disposedMessage("AsyncDisposableStack", "move"));
261
+ const moved = new AsyncDisposableStackPolyfill();
262
+ moved.#resources = this.#resources;
263
+ this.#resources = [];
264
+ this.#disposed = true;
265
+ return moved;
266
+ }
267
+ async disposeAsync() {
268
+ if (this.#disposed)
269
+ return;
270
+ this.#disposed = true;
271
+ const resources = this.#resources;
272
+ this.#resources = [];
273
+ let completionError = undefined;
274
+ let hasCompletionError = false;
275
+ for (let i = resources.length - 1; i >= 0; i--) {
276
+ try {
277
+ await resources[i].dispose();
278
+ }
279
+ catch (error) {
280
+ completionError = hasCompletionError
281
+ ? appendDisposeError(error, completionError)
282
+ : error;
283
+ hasCompletionError = true;
284
+ }
285
+ }
286
+ if (hasCompletionError) {
287
+ throw completionError;
288
+ }
289
+ }
290
+ }
291
+ defineMethodAlias(AsyncDisposableStackPolyfill.prototype, symbolAsyncDispose, "disposeAsync");
292
+ Object.defineProperty(AsyncDisposableStackPolyfill.prototype, Symbol.toStringTag, {
293
+ configurable: true,
294
+ enumerable: false,
295
+ writable: false,
296
+ value: "AsyncDisposableStack",
297
+ });
298
+ return AsyncDisposableStackPolyfill;
299
+ };
@@ -1,4 +1,16 @@
1
+ /**
2
+ * Seeded random number generation.
3
+ *
4
+ * @module
5
+ */
1
6
  import { Random as RandomLib } from "random";
7
+ import type { Brand } from "./Brand.js";
8
+ /**
9
+ * A random floating point number in [0, 1).
10
+ *
11
+ * Branded to distinguish random values from arbitrary numbers.
12
+ */
13
+ export type RandomNumber = number & Brand<"RandomNumber">;
2
14
  /**
3
15
  * A simple wrapper around Math.random().
4
16
  *
@@ -18,13 +30,15 @@ import { Random as RandomLib } from "random";
18
30
  */
19
31
  export interface Random {
20
32
  /** Returns a floating point number in [0, 1). Just like Math.random(). */
21
- next: () => number;
33
+ next: () => RandomNumber;
22
34
  }
23
35
  export interface RandomDep {
24
36
  random: Random;
25
37
  }
26
38
  /** Creates a {@link Random} using Math.random(). */
27
39
  export declare const createRandom: () => Random;
40
+ /** Creates a seeded {@link Random} for deterministic tests. Default seed "evolu". */
41
+ export declare const testCreateRandom: (seed?: string) => Random;
28
42
  /**
29
43
  * Creates {@link Random} using {@link RandomLibDep} with a seed which is useful
30
44
  * for tests.
@@ -36,13 +50,10 @@ export declare const createRandomWithSeed: (seed: string) => Random;
36
50
  * https://github.com/transitive-bullshit/random
37
51
  */
38
52
  export interface RandomLibDep {
39
- random: RandomLib;
53
+ readonly randomLib: RandomLib;
40
54
  }
41
55
  /** Creates a `RandomLib` using the NPM `random` package. */
42
56
  export declare const createRandomLib: () => RandomLib;
43
- /**
44
- * Creates {@link RandomLibDep} using the NPM `random` package with a seed which
45
- * is useful for tests.
46
- */
47
- export declare const createRandomLibWithSeed: (seed: string) => RandomLibDep;
57
+ /** Creates a seeded `RandomLib` for deterministic tests. Default seed "evolu". */
58
+ export declare const testCreateRandomLib: (seed?: string) => RandomLib;
48
59
  //# sourceMappingURL=Random.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Random.d.ts","sourceRoot":"","sources":["../../src/Random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,MAAM;IACrB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,eAAO,MAAM,YAAY,QAAO,MAE9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,MAKnD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,4DAA4D;AAC5D,eAAO,MAAM,eAAe,QAAO,SAA4B,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,YAErD,CAAC"}
1
+ {"version":3,"file":"Random.d.ts","sourceRoot":"","sources":["../../src/Random.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,MAAM;IACrB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,eAAO,MAAM,YAAY,QAAO,MAE9B,CAAC;AAEH,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,GAAI,aAAc,KAAG,MACtB,CAAC;AAE7B;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,MAKnD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED,4DAA4D;AAC5D,eAAO,MAAM,eAAe,QAAO,SAA4B,CAAC;AAEhE,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,GAAI,aAAc,KAAG,SAChC,CAAC"}
@@ -1,8 +1,15 @@
1
+ /**
2
+ * Seeded random number generation.
3
+ *
4
+ * @module
5
+ */
1
6
  import { Random as RandomLib } from "random";
2
7
  /** Creates a {@link Random} using Math.random(). */
3
8
  export const createRandom = () => ({
4
9
  next: () => Math.random(),
5
10
  });
11
+ /** Creates a seeded {@link Random} for deterministic tests. Default seed "evolu". */
12
+ export const testCreateRandom = (seed = "evolu") => createRandomWithSeed(seed);
6
13
  /**
7
14
  * Creates {@link Random} using {@link RandomLibDep} with a seed which is useful
8
15
  * for tests.
@@ -15,10 +22,5 @@ export const createRandomWithSeed = (seed) => {
15
22
  };
16
23
  /** Creates a `RandomLib` using the NPM `random` package. */
17
24
  export const createRandomLib = () => new RandomLib();
18
- /**
19
- * Creates {@link RandomLibDep} using the NPM `random` package with a seed which
20
- * is useful for tests.
21
- */
22
- export const createRandomLibWithSeed = (seed) => ({
23
- random: new RandomLib(seed),
24
- });
25
+ /** Creates a seeded `RandomLib` for deterministic tests. Default seed "evolu". */
26
+ export const testCreateRandomLib = (seed = "evolu") => new RandomLib(seed);
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Sensitive value protection against accidental exposure.
3
+ *
4
+ * @module
5
+ */
1
6
  import type { Brand } from "./Brand.js";
2
7
  import type { Eq } from "./Eq.js";
3
8
  /**
@@ -42,8 +47,8 @@ import type { Eq } from "./Eq.js";
42
47
  * // use value...
43
48
  * };
44
49
  *
45
- * fetchUser(redactedKey); //
46
- * // fetchUser(createRedacted("x" as DbPassword)); // type error
50
+ * fetchUser(redactedKey); // ok
51
+ * // fetchUser(createRedacted("x" as DbPassword)); // type error
47
52
  *
48
53
  * // Automatic cleanup with `using`
49
54
  * {
@@ -51,8 +56,6 @@ import type { Eq } from "./Eq.js";
51
56
  * // ... use secret ...
52
57
  * } // automatically wiped from memory
53
58
  * ```
54
- *
55
- * @experimental
56
59
  */
57
60
  export interface Redacted<A> extends Brand<"Redacted">, Disposable {
58
61
  /** The inner type. Useful for inference via `typeof redacted.Type`. */
@@ -1 +1 @@
1
- {"version":3,"file":"Redacted.d.ts","sourceRoot":"","sources":["../../src/Redacted.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAElC;;;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;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,UAAU,QAAQ,CAAC,CAAC,CAAC,KAAG,CAGzD,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,QAAQ,CAAC,OAAO,CAG7B,CAAC;AAEzC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAC1B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAEY,CAAC"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Sensitive value protection against accidental exposure.
3
+ *
4
+ * @module
5
+ */
1
6
  import { assert } from "./Assert.js";
2
7
  /** Creates a {@link Redacted} wrapper for a sensitive value. */
3
8
  export const createRedacted = (value) => {
package/dist/src/Ref.d.ts CHANGED
@@ -1,21 +1,26 @@
1
1
  /**
2
- * `Ref` provides a simple API to hold and update a value, similar to a "ref" in
3
- * functional programming or React. It exposes methods to get, set, and modify
4
- * the current state.
2
+ * Mutable reference to an immutable value.
5
3
  *
6
- * Use a Ref instead of a variable when you want to pass state around as an
7
- * object or update it in a controlled way. If you need subscriptions, see
8
- * {@link Store}.
4
+ * @module
5
+ */
6
+ /**
7
+ * Mutable reference to an immutable value.
8
+ *
9
+ * `Ref` holds the current value and exposes explicit `get`, `set`, `update`,
10
+ * and `modify` operations. The reference is mutable, but the value inside it
11
+ * must be immutable and replaced with a new value rather than mutated in place.
12
+ * Storing a mutable value in `Ref` does not make sense, because callers could
13
+ * mutate that value directly and pass it around without `Ref`.
9
14
  *
10
- * Updating in a controlled way means all changes go through specific methods
11
- * (`set` or `modify`), making state updates predictable and easy to track.
15
+ * Use it when mutable ownership of a value needs to be passed around as a
16
+ * value. For reactive state with subscriptions, see {@link Store}.
12
17
  *
13
18
  * ### Example
14
19
  *
15
20
  * ```ts
16
21
  * const count = createRef(0);
17
22
  * count.set(1);
18
- * count.modify((n) => n + 1);
23
+ * count.update((n) => n + 1);
19
24
  * console.log(count.get()); // 2
20
25
  * ```
21
26
  *
@@ -28,13 +33,23 @@
28
33
  * ```
29
34
  */
30
35
  export interface Ref<T> {
31
- /** Returns the current state. */
36
+ /** Returns the current value. */
32
37
  readonly get: () => T;
33
- /** Sets the state. */
34
- readonly set: (state: T) => void;
35
- /** Modifies the state using an updater function. */
36
- readonly modify: (updater: (current: T) => T) => void;
38
+ /** Sets the current value. */
39
+ readonly set: (value: T) => void;
40
+ /** Sets the current value and returns the previous value. */
41
+ readonly getAndSet: (value: T) => T;
42
+ /** Sets the current value and returns it. */
43
+ readonly setAndGet: (value: T) => T;
44
+ /** Updates the current value. */
45
+ readonly update: (updater: (current: T) => T) => void;
46
+ /** Updates the current value and returns the previous value. */
47
+ readonly getAndUpdate: (updater: (current: T) => T) => T;
48
+ /** Updates the current value and returns it. */
49
+ readonly updateAndGet: (updater: (current: T) => T) => T;
50
+ /** Modifies the current value and returns a computed result. */
51
+ readonly modify: <R>(updater: (current: T) => readonly [result: R, nextValue: T]) => R;
37
52
  }
38
- /** Creates a {@link Ref} with the given initial state. */
39
- export declare const createRef: <T>(initialState: T) => Ref<T>;
53
+ /** Creates a {@link Ref} with the given initial immutable value. */
54
+ export declare const createRef: <T>(initialValue: T) => Ref<T>;
40
55
  //# sourceMappingURL=Ref.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../../src/Ref.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEtB,sBAAsB;IACtB,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAEjC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EA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E;AACpE,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,cAAc,CAAC,KAAG,GAAG,CAAC,CAAC,CA0CnD,CAAC"}
package/dist/src/Ref.js CHANGED
@@ -1,13 +1,41 @@
1
- /** Creates a {@link Ref} with the given initial state. */
2
- export const createRef = (initialState) => {
3
- let currentState = initialState;
1
+ /**
2
+ * Mutable reference to an immutable value.
3
+ *
4
+ * @module
5
+ */
6
+ /** Creates a {@link Ref} with the given initial immutable value. */
7
+ export const createRef = (initialValue) => {
8
+ let currentValue = initialValue;
4
9
  return {
5
- get: () => currentState,
6
- set: (state) => {
7
- currentState = state;
10
+ get: () => currentValue,
11
+ set: (value) => {
12
+ currentValue = value;
13
+ },
14
+ getAndSet: (value) => {
15
+ const previousValue = currentValue;
16
+ currentValue = value;
17
+ return previousValue;
18
+ },
19
+ setAndGet: (value) => {
20
+ currentValue = value;
21
+ return currentValue;
22
+ },
23
+ update: (updater) => {
24
+ currentValue = updater(currentValue);
25
+ },
26
+ getAndUpdate: (updater) => {
27
+ const previousValue = currentValue;
28
+ currentValue = updater(currentValue);
29
+ return previousValue;
30
+ },
31
+ updateAndGet: (updater) => {
32
+ currentValue = updater(currentValue);
33
+ return currentValue;
8
34
  },
9
35
  modify: (updater) => {
10
- currentState = updater(currentState);
36
+ const [result, nextValue] = updater(currentValue);
37
+ currentValue = nextValue;
38
+ return result;
11
39
  },
12
40
  };
13
41
  };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Reference counting helpers.
3
+ *
4
+ * @module
5
+ */
6
+ import { type LookupOption } from "./Lookup.js";
7
+ import { NonNegativeInt, PositiveInt } from "./Type.js";
8
+ /**
9
+ * Reference count for one retained value.
10
+ *
11
+ * Decrementing below zero is a programmer error checked with {@link assert}.
12
+ */
13
+ export interface RefCount extends Disposable {
14
+ /** Increments the count and returns the new count. */
15
+ readonly increment: () => PositiveInt;
16
+ /**
17
+ * Decrements the count and returns the new count.
18
+ *
19
+ * Decrementing below zero is a programmer error checked with {@link assert}.
20
+ */
21
+ readonly decrement: () => NonNegativeInt;
22
+ /** Returns the current count. */
23
+ readonly getCount: () => NonNegativeInt;
24
+ /** Disposes and invalidates the helper. Further method calls throw. */
25
+ readonly [Symbol.dispose]: () => void;
26
+ }
27
+ /** Creates {@link RefCount}. */
28
+ export declare const createRefCount: () => RefCount;
29
+ /**
30
+ * Reference counts keyed by logical identity.
31
+ *
32
+ * By default, {@link createRefCountByKey} uses reference identity, the same as
33
+ * `Map` keys. Callers may instead provide a {@link Lookup lookup} so logical
34
+ * equality is based on a derived stable key. Decrementing a missing key is a
35
+ * programmer error checked with {@link assert}.
36
+ */
37
+ export interface RefCountByKey<TKey> extends Disposable {
38
+ /** Increments key count and returns the new count. */
39
+ readonly increment: (key: TKey) => PositiveInt;
40
+ /**
41
+ * Decrements key count and returns the new count.
42
+ *
43
+ * Decrementing a missing key is a programmer error checked with
44
+ * {@link assert}.
45
+ */
46
+ readonly decrement: (key: TKey) => NonNegativeInt;
47
+ /** Gets current count for key. Returns `0` when the key is not tracked. */
48
+ readonly getCount: (key: TKey) => NonNegativeInt;
49
+ /** Returns `true` when the key is tracked with count greater than zero. */
50
+ readonly has: (key: TKey) => boolean;
51
+ /** Returns all currently tracked keys. */
52
+ readonly keys: () => ReadonlySet<TKey>;
53
+ /** Disposes and invalidates the helper. Further method calls throw. */
54
+ readonly [Symbol.dispose]: () => void;
55
+ }
56
+ /** Options for {@link createRefCountByKey}. */
57
+ export interface CreateRefCountByKeyOptions<TKey, L = TKey> extends LookupOption<TKey, L> {
58
+ }
59
+ /** Creates {@link RefCountByKey}. */
60
+ export declare function createRefCountByKey<TKey = unknown>(): RefCountByKey<TKey>;
61
+ export declare function createRefCountByKey<TKey, L>(options: CreateRefCountByKeyOptions<TKey, L>): RefCountByKey<TKey>;
62
+ //# sourceMappingURL=RefCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RefCount.d.ts","sourceRoot":"","sources":["../../src/RefCount.ts"],"names":[],"mappings":"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