@evolu/common 6.0.1-preview.9 → 7.1.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.
- package/README.md +27 -29
- package/dist/src/Array.d.ts +317 -12
- package/dist/src/Array.d.ts.map +1 -1
- package/dist/src/Array.js +219 -9
- package/dist/src/Assert.d.ts +0 -13
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +0 -15
- package/dist/src/Brand.d.ts +75 -0
- package/dist/src/Brand.d.ts.map +1 -0
- package/dist/src/Brand.js +1 -0
- package/dist/src/Buffer.d.ts +1 -1
- package/dist/src/Buffer.d.ts.map +1 -1
- package/dist/src/Buffer.js +8 -7
- package/dist/src/Cache.d.ts +39 -0
- package/dist/src/Cache.d.ts.map +1 -0
- package/dist/src/Cache.js +47 -0
- package/dist/src/Callbacks.d.ts +45 -12
- package/dist/src/Callbacks.d.ts.map +1 -1
- package/dist/src/Callbacks.js +14 -7
- package/dist/src/Console.d.ts +32 -7
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +73 -10
- package/dist/src/Crypto.d.ts +56 -42
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +45 -54
- package/dist/src/Evolu/Db.d.ts +162 -74
- package/dist/src/Evolu/Db.d.ts.map +1 -1
- package/dist/src/Evolu/Db.js +284 -702
- package/dist/src/Evolu/Diff.d.ts +3 -3
- package/dist/src/Evolu/Diff.d.ts.map +1 -1
- package/dist/src/Evolu/Diff.js +7 -5
- package/dist/src/Evolu/Evolu.d.ts +213 -133
- package/dist/src/Evolu/Evolu.d.ts.map +1 -1
- package/dist/src/Evolu/Evolu.js +189 -180
- package/dist/src/Evolu/Internal.d.ts +2 -4
- package/dist/src/Evolu/Internal.d.ts.map +1 -1
- package/dist/src/Evolu/Internal.js +2 -4
- package/dist/src/Evolu/LocalAuth.d.ts +150 -0
- package/dist/src/Evolu/LocalAuth.d.ts.map +1 -0
- package/dist/src/Evolu/LocalAuth.js +174 -0
- package/dist/src/Evolu/Owner.d.ts +273 -120
- package/dist/src/Evolu/Owner.d.ts.map +1 -1
- package/dist/src/Evolu/Owner.js +130 -104
- package/dist/src/Evolu/Platform.d.ts +9 -7
- package/dist/src/Evolu/Platform.d.ts.map +1 -1
- package/dist/src/Evolu/Protocol.d.ts +268 -240
- package/dist/src/Evolu/Protocol.d.ts.map +1 -1
- package/dist/src/Evolu/Protocol.js +595 -447
- package/dist/src/Evolu/Public.d.ts +7 -9
- package/dist/src/Evolu/Public.d.ts.map +1 -1
- package/dist/src/Evolu/Public.js +3 -4
- package/dist/src/Evolu/PublicKysely.d.ts.map +1 -1
- package/dist/src/Evolu/PublicKysely.js +3 -4
- package/dist/src/Evolu/Query.d.ts +2 -1
- package/dist/src/Evolu/Query.d.ts.map +1 -1
- package/dist/src/Evolu/Query.js +1 -1
- package/dist/src/Evolu/Relay.d.ts +91 -8
- package/dist/src/Evolu/Relay.d.ts.map +1 -1
- package/dist/src/Evolu/Relay.js +214 -88
- package/dist/src/Evolu/Schema.d.ts +125 -47
- package/dist/src/Evolu/Schema.d.ts.map +1 -1
- package/dist/src/Evolu/Schema.js +175 -31
- package/dist/src/Evolu/Storage.d.ts +249 -27
- package/dist/src/Evolu/Storage.d.ts.map +1 -1
- package/dist/src/Evolu/Storage.js +198 -92
- package/dist/src/Evolu/Sync.d.ts +68 -13
- package/dist/src/Evolu/Sync.d.ts.map +1 -1
- package/dist/src/Evolu/Sync.js +469 -20
- package/dist/src/Evolu/Timestamp.d.ts +83 -30
- package/dist/src/Evolu/Timestamp.d.ts.map +1 -1
- package/dist/src/Evolu/Timestamp.js +79 -34
- package/dist/src/Identicon.d.ts +35 -0
- package/dist/src/Identicon.d.ts.map +1 -0
- package/dist/src/Identicon.js +143 -0
- package/dist/src/Instances.d.ts +34 -0
- package/dist/src/Instances.d.ts.map +1 -0
- package/dist/src/Instances.js +44 -0
- package/dist/src/Number.d.ts +4 -3
- package/dist/src/Number.d.ts.map +1 -1
- package/dist/src/Number.js +5 -4
- package/dist/src/Object.d.ts +10 -4
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +9 -3
- package/dist/src/Order.d.ts +0 -5
- package/dist/src/Order.d.ts.map +1 -1
- package/dist/src/Order.js +0 -5
- package/dist/src/Platform.d.ts +15 -0
- package/dist/src/Platform.d.ts.map +1 -0
- package/dist/src/Platform.js +17 -0
- package/dist/src/Random.d.ts +3 -7
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Random.js +0 -5
- package/dist/src/Ref.d.ts.map +1 -1
- package/dist/src/Relation.d.ts +79 -0
- package/dist/src/Relation.d.ts.map +1 -0
- package/dist/src/Relation.js +127 -0
- package/dist/src/Resources.d.ts +118 -0
- package/dist/src/Resources.d.ts.map +1 -0
- package/dist/src/Resources.js +197 -0
- package/dist/src/Result.d.ts +189 -59
- package/dist/src/Result.d.ts.map +1 -1
- package/dist/src/Result.js +30 -241
- package/dist/src/Skiplist.js +2 -1
- package/dist/src/Sqlite.d.ts +89 -5
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +136 -9
- package/dist/src/Store.d.ts +0 -5
- package/dist/src/Store.d.ts.map +1 -1
- package/dist/src/Store.js +0 -5
- package/dist/src/Task.d.ts +580 -0
- package/dist/src/Task.d.ts.map +1 -0
- package/dist/src/Task.js +464 -0
- package/dist/src/Time.d.ts +66 -6
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +96 -7
- package/dist/src/Type.d.ts +677 -344
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +718 -467
- package/dist/src/Types.d.ts +38 -75
- package/dist/src/Types.d.ts.map +1 -1
- package/dist/src/WebSocket.d.ts +5 -7
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +12 -23
- package/dist/src/Worker.d.ts +39 -16
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +22 -9
- package/dist/src/index.d.ts +8 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -3
- package/package.json +14 -13
- package/src/Array.ts +396 -19
- package/src/Assert.ts +0 -35
- package/src/Brand.ts +75 -0
- package/src/Buffer.ts +7 -7
- package/src/Cache.ts +79 -0
- package/src/Callbacks.ts +62 -22
- package/src/Console.ts +92 -12
- package/src/Crypto.ts +99 -91
- package/src/Evolu/Db.ts +519 -1026
- package/src/Evolu/Diff.ts +7 -5
- package/src/Evolu/Evolu.ts +476 -360
- package/src/Evolu/Internal.ts +2 -4
- package/src/Evolu/LocalAuth.ts +463 -0
- package/src/Evolu/Owner.ts +355 -228
- package/src/Evolu/Platform.ts +9 -9
- package/src/Evolu/Protocol.ts +846 -742
- package/src/Evolu/Public.ts +8 -15
- package/src/Evolu/PublicKysely.ts +4 -5
- package/src/Evolu/Query.ts +3 -2
- package/src/Evolu/Relay.ts +406 -103
- package/src/Evolu/Schema.ts +323 -91
- package/src/Evolu/Storage.ts +559 -137
- package/src/Evolu/Sync.ts +819 -36
- package/src/Evolu/Timestamp.ts +90 -58
- package/src/Identicon.ts +197 -0
- package/src/Instances.ts +90 -0
- package/src/Number.ts +6 -10
- package/src/Object.ts +13 -5
- package/src/Order.ts +0 -6
- package/src/Platform.ts +20 -0
- package/src/Random.ts +3 -8
- package/src/Ref.ts +0 -5
- package/src/Relation.ts +234 -0
- package/src/Resources.ts +367 -0
- package/src/Result.ts +196 -61
- package/src/Skiplist.ts +1 -1
- package/src/Sqlite.ts +152 -17
- package/src/Store.ts +0 -5
- package/src/Task.ts +894 -0
- package/src/Time.ts +179 -10
- package/src/Type.ts +1136 -731
- package/src/Types.ts +43 -77
- package/src/WebSocket.ts +27 -31
- package/src/Worker.ts +72 -29
- package/src/index.ts +8 -3
- package/dist/src/Evolu/Config.d.ts +0 -69
- package/dist/src/Evolu/Config.d.ts.map +0 -1
- package/dist/src/Evolu/Config.js +0 -9
- package/dist/src/Evolu/Kysely.d.ts +0 -6
- package/dist/src/Evolu/Kysely.d.ts.map +0 -1
- package/dist/src/Evolu/Kysely.js +0 -21
- package/dist/src/ManyToManyMap.d.ts +0 -26
- package/dist/src/ManyToManyMap.d.ts.map +0 -1
- package/dist/src/ManyToManyMap.js +0 -92
- package/dist/src/NanoId.d.ts +0 -27
- package/dist/src/NanoId.d.ts.map +0 -1
- package/dist/src/NanoId.js +0 -6
- package/dist/src/Promise.d.ts +0 -180
- package/dist/src/Promise.d.ts.map +0 -1
- package/dist/src/Promise.js +0 -176
- package/src/Evolu/Config.ts +0 -83
- package/src/Evolu/Kysely.ts +0 -38
- package/src/ManyToManyMap.ts +0 -140
- package/src/NanoId.ts +0 -39
- package/src/Promise.ts +0 -295
package/dist/src/Types.d.ts
CHANGED
|
@@ -19,6 +19,22 @@ import * as Kysely from "kysely";
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export type Predicate<T> = (value: T) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Checks a condition on a value at a given index and returns a boolean.
|
|
24
|
+
*
|
|
25
|
+
* Useful for callbacks that need both the element and its position.
|
|
26
|
+
*
|
|
27
|
+
* ### Example
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const isEvenIndex: PredicateWithIndex<string> = (value, index) =>
|
|
31
|
+
* index % 2 === 0;
|
|
32
|
+
*
|
|
33
|
+
* const items = ["a", "b", "c", "d"];
|
|
34
|
+
* const evenIndexItems = items.filter(isEvenIndex); // ["a", "c"]
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export type PredicateWithIndex<T> = (value: T, index: number) => boolean;
|
|
22
38
|
/**
|
|
23
39
|
* A type guard function that refines type `A` to a narrower type `B`.
|
|
24
40
|
*
|
|
@@ -38,6 +54,27 @@ export type Predicate<T> = (value: T) => boolean;
|
|
|
38
54
|
* ```
|
|
39
55
|
*/
|
|
40
56
|
export type Refinement<in A, out B extends A> = (a: A) => a is B;
|
|
57
|
+
/**
|
|
58
|
+
* A type guard function that refines type `A` to a narrower type `B` at a given
|
|
59
|
+
* index.
|
|
60
|
+
*
|
|
61
|
+
* Useful for callbacks that need both the element and its position while
|
|
62
|
+
* maintaining type narrowing.
|
|
63
|
+
*
|
|
64
|
+
* ### Example
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* type Item = { type: "number" | "string"; value: unknown };
|
|
68
|
+
*
|
|
69
|
+
* const isNumberItem: RefinementWithIndex<Item, Item & { type: "number" }> =
|
|
70
|
+
* (item, index): item is Item & { type: "number" } =>
|
|
71
|
+
* index > 0 && item.type === "number";
|
|
72
|
+
*
|
|
73
|
+
* const items: ReadonlyArray<Item> = [...];
|
|
74
|
+
* const [numbers, others] = partitionArray(items, isNumberItem);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export type RefinementWithIndex<in A, out B extends A> = (a: A, index: number) => a is B;
|
|
41
78
|
/**
|
|
42
79
|
* Makes properties optional if they accept `null` as a value.
|
|
43
80
|
*
|
|
@@ -71,80 +108,7 @@ export type NullablePartial<T, NK extends keyof T = {
|
|
|
71
108
|
*/
|
|
72
109
|
export type IntentionalNever = never;
|
|
73
110
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* Branded types enhance type safety by differentiating otherwise identical base
|
|
77
|
-
* types, such as `number` or `string`, to enforce stricter type checks.
|
|
78
|
-
*
|
|
79
|
-
* Supports multiple brands, allowing types to act like flags.
|
|
80
|
-
*
|
|
81
|
-
* ### Example 1: Single Brand
|
|
82
|
-
*
|
|
83
|
-
* ```ts
|
|
84
|
-
* // A branded type definition
|
|
85
|
-
* type UserId = number & Brand<"UserId">;
|
|
86
|
-
*
|
|
87
|
-
* // A function that creates `UserId` values.
|
|
88
|
-
* // Casting with `as UserId` is unsafe, so `createUserId` must be unit-tested.
|
|
89
|
-
* const createUserId = (): UserId => {
|
|
90
|
-
* return 123 as UserId; // Unsafe casting
|
|
91
|
-
* };
|
|
92
|
-
*
|
|
93
|
-
* const userId = createUserId();
|
|
94
|
-
*
|
|
95
|
-
* // A function that accepts only `UserId`.
|
|
96
|
-
* const getUser = (id: UserId) => {
|
|
97
|
-
* // Implementation
|
|
98
|
-
* };
|
|
99
|
-
*
|
|
100
|
-
* getUser(userId); // ✅ Valid
|
|
101
|
-
* getUser(123); // ❌ TypeScript error
|
|
102
|
-
* getUser("123"); // ❌ TypeScript error
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* ### Example 2: Multiple Brands
|
|
106
|
-
*
|
|
107
|
-
* ```ts
|
|
108
|
-
* // Define branded types
|
|
109
|
-
* type Min1 = string & Brand<"Min1">;
|
|
110
|
-
* type Max100 = string & Brand<"Max100">;
|
|
111
|
-
* type Min1Max100 = string & Brand<"Min1" | "Max100">;
|
|
112
|
-
*
|
|
113
|
-
* // Functions requiring specific brands
|
|
114
|
-
* const requiresMin1 = (value: Min1): void => {};
|
|
115
|
-
* const requiresMax100 = (value: Max100): void => {};
|
|
116
|
-
*
|
|
117
|
-
* // Values with single brands
|
|
118
|
-
* const min1Value: Min1 = "hello" as Min1;
|
|
119
|
-
* const max100Value: Max100 = "world" as Max100;
|
|
120
|
-
*
|
|
121
|
-
* // Value with multiple brands
|
|
122
|
-
* const min1Max100Value: Min1Max100 = "typescript" as Min1Max100;
|
|
123
|
-
*
|
|
124
|
-
* // Valid cases
|
|
125
|
-
* requiresMin1(min1Value); // ✅ Valid
|
|
126
|
-
* requiresMax100(max100Value); // ✅ Valid
|
|
127
|
-
* requiresMin1(min1Max100Value); // ✅ Valid: Min1Max100 satisfies Min1
|
|
128
|
-
* requiresMax100(min1Max100Value); // ✅ Valid: Min1Max100 satisfies Max100
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
export interface Brand<B extends string> {
|
|
132
|
-
readonly [__brand]: Readonly<Record<B, true>>;
|
|
133
|
-
}
|
|
134
|
-
declare const __brand: unique symbol;
|
|
135
|
-
/**
|
|
136
|
-
* Determines whether a type `T` is a branded type.
|
|
137
|
-
*
|
|
138
|
-
* Works with any base type intersected with a `Brand`.
|
|
139
|
-
*
|
|
140
|
-
* ### Examples
|
|
141
|
-
*
|
|
142
|
-
* - `IsBranded<string>` -> false
|
|
143
|
-
* - `IsBranded<string & Brand<"X">>` -> true
|
|
144
|
-
*/
|
|
145
|
-
export type IsBranded<T> = T extends Brand<string> ? true : false;
|
|
146
|
-
/**
|
|
147
|
-
* String | number | bigint | boolean | undefined | null
|
|
111
|
+
* String, number, bigint, boolean, undefined, null
|
|
148
112
|
*
|
|
149
113
|
* https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types
|
|
150
114
|
*/
|
|
@@ -184,5 +148,4 @@ export type Simplify<T> = Kysely.Simplify<T>;
|
|
|
184
148
|
* unchanged.
|
|
185
149
|
*/
|
|
186
150
|
export type PartialProp<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
187
|
-
export {};
|
|
188
151
|
//# sourceMappingURL=Types.d.ts.map
|
package/dist/src/Types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/Types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,EACD,EAAE,SAAS,MAAM,CAAC,GAAG;KAClB,CAAC,IAAI,MAAM,CAAC,GAAG,IAAI,SA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
|
|
6
|
-
import { RetryError, RetryOptions } from "./Promise.js";
|
|
7
1
|
import { Result } from "./Result.js";
|
|
2
|
+
import { RetryError, RetryOptions } from "./Task.js";
|
|
8
3
|
/** WebSocket with auto-reconnect and offline support. */
|
|
9
4
|
export interface WebSocket extends Disposable {
|
|
10
5
|
/**
|
|
@@ -13,9 +8,12 @@ export interface WebSocket extends Disposable {
|
|
|
13
8
|
*/
|
|
14
9
|
send: (data: string | ArrayBufferLike | Blob | ArrayBufferView) => Result<void, WebSocketSendError>;
|
|
15
10
|
readonly getReadyState: () => WebSocketReadyState;
|
|
11
|
+
/** Returns true if the WebSocket is open and ready to send data. */
|
|
12
|
+
readonly isOpen: () => boolean;
|
|
16
13
|
}
|
|
17
14
|
/**
|
|
18
|
-
* An error that occurs when trying to send data but WebSocket is
|
|
15
|
+
* An error that occurs when trying to send data but WebSocket is not available
|
|
16
|
+
* or is in the CONNECTING state.
|
|
19
17
|
*
|
|
20
18
|
* https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
|
|
21
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../../src/WebSocket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../../src/WebSocket.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAS,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG5D,yDAAyD;AACzD,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C;;;OAGG;IACH,IAAI,EAAE,CACJ,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,eAAe,KACpD,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAEtC,QAAQ,CAAC,aAAa,EAAE,MAAM,mBAAmB,CAAC;IAElD,oEAAoE;IACpE,QAAQ,CAAC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AAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,6BAA6B,CAAC;AAElC,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,eAAe,EAAE,eAwH7B,CAAC"}
|
package/dist/src/WebSocket.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Websocket with auto-reconnect and offline support
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { assertNoErrorInCatch } from "./Assert.js";
|
|
7
|
-
import { retry } from "./Promise.js";
|
|
8
1
|
import { err, ok } from "./Result.js";
|
|
2
|
+
import { retry } from "./Task.js";
|
|
3
|
+
import { maxPositiveInt } from "./Type.js";
|
|
9
4
|
/**
|
|
10
5
|
* Create a new {@link WebSocket}.
|
|
11
6
|
*
|
|
@@ -37,13 +32,11 @@ import { err, ok } from "./Result.js";
|
|
|
37
32
|
*
|
|
38
33
|
* TODO:
|
|
39
34
|
*/
|
|
40
|
-
export const createWebSocket = (url,
|
|
41
|
-
const { protocols, binaryType, onOpen, onClose, onMessage, onError, retryOptions, WebSocketConstructor = globalThis.WebSocket, } = options;
|
|
35
|
+
export const createWebSocket = (url, { protocols, binaryType, onOpen, onClose, onMessage, onError, retryOptions, WebSocketConstructor = globalThis.WebSocket, } = {}) => {
|
|
42
36
|
let isDisposed = false;
|
|
43
37
|
const reconnectController = new AbortController();
|
|
44
38
|
const defaultRetryOptions = {
|
|
45
|
-
|
|
46
|
-
maxRetries: Infinity,
|
|
39
|
+
retries: maxPositiveInt, // Practically infinite retries
|
|
47
40
|
};
|
|
48
41
|
let socket = null;
|
|
49
42
|
const disposeSocket = () => {
|
|
@@ -66,7 +59,10 @@ export const createWebSocket = (url, options = {}) => {
|
|
|
66
59
|
* - Is rejected when a connection is closed.
|
|
67
60
|
* - Is resolved when WebSocket is disposed().
|
|
68
61
|
*/
|
|
69
|
-
retry(
|
|
62
|
+
void retry({
|
|
63
|
+
...defaultRetryOptions,
|
|
64
|
+
...retryOptions,
|
|
65
|
+
}, () => new Promise((resolve) => {
|
|
70
66
|
disposePromise = () => {
|
|
71
67
|
resolve(ok());
|
|
72
68
|
};
|
|
@@ -98,19 +94,12 @@ export const createWebSocket = (url, options = {}) => {
|
|
|
98
94
|
socket.onmessage = (event) => {
|
|
99
95
|
onMessage?.(event.data);
|
|
100
96
|
};
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
...retryOptions,
|
|
104
|
-
})
|
|
105
|
-
.then((result) => {
|
|
106
|
-
if (result.ok || result.error.type === "RetryAbortError")
|
|
97
|
+
}))(reconnectController).then((result) => {
|
|
98
|
+
if (result.ok || result.error.type === "AbortError")
|
|
107
99
|
return;
|
|
108
100
|
onError?.(result.error);
|
|
109
|
-
})
|
|
110
|
-
.catch((error) => {
|
|
111
|
-
assertNoErrorInCatch("WebSocket retry", error);
|
|
112
101
|
});
|
|
113
|
-
|
|
102
|
+
return {
|
|
114
103
|
send: (data) => {
|
|
115
104
|
// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
|
|
116
105
|
if (!socket || socket.readyState === socket.CONNECTING) {
|
|
@@ -120,6 +109,7 @@ export const createWebSocket = (url, options = {}) => {
|
|
|
120
109
|
return ok();
|
|
121
110
|
},
|
|
122
111
|
getReadyState: () => socket ? nativeToStringState[socket.readyState] : "connecting",
|
|
112
|
+
isOpen: () => (socket ? socket.readyState === socket.OPEN : false),
|
|
123
113
|
[Symbol.dispose]() {
|
|
124
114
|
if (isDisposed)
|
|
125
115
|
return;
|
|
@@ -129,7 +119,6 @@ export const createWebSocket = (url, options = {}) => {
|
|
|
129
119
|
disposePromise?.();
|
|
130
120
|
},
|
|
131
121
|
};
|
|
132
|
-
return webSocket;
|
|
133
122
|
};
|
|
134
123
|
const nativeToStringState = {
|
|
135
124
|
[WebSocket.CONNECTING]: "connecting",
|
package/dist/src/Worker.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-platform worker abstraction
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import { TransferableError } from "./Error.js";
|
|
7
2
|
/** Cross-platform worker abstraction. */
|
|
8
3
|
export interface Worker<Input, Output> {
|
|
@@ -14,6 +9,21 @@ export interface Worker<Input, Output> {
|
|
|
14
9
|
export interface WorkerPostMessageDep<Output> {
|
|
15
10
|
readonly postMessage: (message: Output) => void;
|
|
16
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Error reporting wrapper that catches synchronous errors in handlers and
|
|
14
|
+
* converts them to transferable error messages sent to the main thread.
|
|
15
|
+
*/
|
|
16
|
+
export type WithErrorReporting = <A extends Array<any>>(handler: (...args: A) => void) => (...args: A) => void;
|
|
17
|
+
type HasInit<Input> = Extract<Input, {
|
|
18
|
+
type: "init";
|
|
19
|
+
}> extends never ? ["Input must contain a variant with { type: 'init' }"] : unknown;
|
|
20
|
+
type HasWorkerErrorOutput<T> = Extract<T, {
|
|
21
|
+
type: "onError";
|
|
22
|
+
}> extends infer E ? [E] extends [never] ? [
|
|
23
|
+
"Output must contain { type: 'onError'; error: TransferableError | ... }"
|
|
24
|
+
] : E extends {
|
|
25
|
+
error: infer Err;
|
|
26
|
+
} ? TransferableError extends Err ? unknown : ["Output.onError.error must include TransferableError"] : ["Output.onError must have an error property"] : never;
|
|
17
27
|
/**
|
|
18
28
|
* Creates a {@link Worker} that supports initialization with dependencies and
|
|
19
29
|
* safe error handling.
|
|
@@ -25,20 +35,33 @@ export declare const createInitializedWorker: <Input extends {
|
|
|
25
35
|
} & HasWorkerErrorOutput<Output>, Deps>({ init, onMessage, }: {
|
|
26
36
|
readonly init: (initMessage: Extract<Input, {
|
|
27
37
|
type: "init";
|
|
28
|
-
}>, postMessage: (msg: Output) => void,
|
|
38
|
+
}>, postMessage: (msg: Output) => void, withErrorReporting: WithErrorReporting) => Promise<Deps | null>;
|
|
29
39
|
readonly onMessage: (deps: Deps) => (message: Exclude<Input, {
|
|
30
40
|
type: "init";
|
|
31
41
|
}>) => void;
|
|
32
42
|
}) => Worker<Input, Output>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
/** Type helper to extract message types from a union type */
|
|
44
|
+
export type MessageHandlers<Input extends {
|
|
45
|
+
readonly type: string;
|
|
46
|
+
}, Deps> = {
|
|
47
|
+
readonly [K in Input["type"]]: (deps: Deps) => (message: Extract<Input, {
|
|
48
|
+
type: K;
|
|
49
|
+
}>) => void;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Creates a {@link Worker} with type-safe message handlers for each message
|
|
53
|
+
* type. This provides better type safety and organization compared to a single
|
|
54
|
+
* onMessage handler.
|
|
55
|
+
*/
|
|
56
|
+
export declare const createInitializedWorkerWithHandlers: <Input extends {
|
|
57
|
+
readonly type: string;
|
|
58
|
+
} & HasInit<Input>, Output extends {
|
|
59
|
+
readonly type: string;
|
|
60
|
+
} & HasWorkerErrorOutput<Output>, Deps>({ init, handlers, }: {
|
|
61
|
+
readonly init: (initMessage: Extract<Input, {
|
|
62
|
+
type: "init";
|
|
63
|
+
}>, postMessage: (msg: Output) => void, withErrorReporting: WithErrorReporting) => Promise<Deps | null>;
|
|
64
|
+
readonly handlers: Omit<MessageHandlers<Input, Deps>, "init">;
|
|
65
|
+
}) => Worker<Input, Output>;
|
|
43
66
|
export {};
|
|
44
67
|
//# sourceMappingURL=Worker.d.ts.map
|
package/dist/src/Worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAExE,yCAAyC;AACzC,MAAM,WAAW,MAAM,CAAC,KAAK,EAAE,MAAM;IACnC,qCAAqC;IACrC,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,KAAK,IAAI,CAAC;IAE/C,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,oBAAoB,CAAC,MAAM;IAC1C,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EACpD,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,KAC1B,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;AAE1B,KAAK,OAAO,CAAC,KAAK,IAChB,OAAO,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,SAAS,KAAK,GAC1C,CAAC,oDAAoD,CAAC,GACtD,OAAO,CAAC;AAEd,KAAK,oBAAoB,CAAC,CAAC,IACzB,OAAO,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;C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O,EAAE,OAAO,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KAAK,IAAI;CACpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAC9C,KAAK,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,KAAK,CAAC,EACxD,MAAM,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,oBAAoB,CAAC,MAAM,CAAC,EACvE,IAAI,EACJ,qBAGC;IACD,QAAQ,CAAC,IAAI,EAAE,CACb,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAC7C,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAClC,kBAAkB,EAAE,kBAAkB,KACnC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;CAC/D,KAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAWpB,CAAC"}
|
package/dist/src/Worker.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-platform worker abstraction
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
1
|
import { assert } from "./Assert.js";
|
|
7
2
|
import { createTransferableError } from "./Error.js";
|
|
8
3
|
/**
|
|
@@ -24,7 +19,11 @@ export const createInitializedWorker = ({ init, onMessage, }) => {
|
|
|
24
19
|
error: createTransferableError(error),
|
|
25
20
|
});
|
|
26
21
|
};
|
|
27
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Wraps function to catch errors and send them to the main thread instead of
|
|
24
|
+
* crashing the worker.
|
|
25
|
+
*/
|
|
26
|
+
const withErrorReporting = (handler) => (...args) => {
|
|
28
27
|
try {
|
|
29
28
|
handler(...args);
|
|
30
29
|
}
|
|
@@ -39,20 +38,20 @@ export const createInitializedWorker = ({ init, onMessage, }) => {
|
|
|
39
38
|
pendingMessages.push(message);
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
|
-
|
|
41
|
+
withErrorReporting(onMessage(deps))(message);
|
|
43
42
|
}
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
if (initializing)
|
|
47
46
|
return;
|
|
48
47
|
initializing = true;
|
|
49
|
-
init(message, postMessage,
|
|
48
|
+
init(message, postMessage, withErrorReporting)
|
|
50
49
|
.then((_deps) => {
|
|
51
50
|
if (_deps == null)
|
|
52
51
|
return;
|
|
53
52
|
deps = _deps;
|
|
54
53
|
for (const message of pendingMessages) {
|
|
55
|
-
|
|
54
|
+
withErrorReporting(onMessage(deps))(message);
|
|
56
55
|
}
|
|
57
56
|
pendingMessages.length = 0;
|
|
58
57
|
})
|
|
@@ -64,3 +63,17 @@ export const createInitializedWorker = ({ init, onMessage, }) => {
|
|
|
64
63
|
};
|
|
65
64
|
return worker;
|
|
66
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Creates a {@link Worker} with type-safe message handlers for each message
|
|
68
|
+
* type. This provides better type safety and organization compared to a single
|
|
69
|
+
* onMessage handler.
|
|
70
|
+
*/
|
|
71
|
+
export const createInitializedWorkerWithHandlers = ({ init, handlers, }) => createInitializedWorker({
|
|
72
|
+
init,
|
|
73
|
+
onMessage: (deps) => (message) => {
|
|
74
|
+
const messageType = message.type;
|
|
75
|
+
const handler = handlers[messageType];
|
|
76
|
+
// TypeScript knows handler exists because handlers covers all non-init message types
|
|
77
|
+
handler(deps)(message);
|
|
78
|
+
},
|
|
79
|
+
});
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./Array.js";
|
|
2
2
|
export * from "./Assert.js";
|
|
3
3
|
export * from "./BigInt.js";
|
|
4
|
+
export * from "./Brand.js";
|
|
4
5
|
export * from "./Buffer.js";
|
|
6
|
+
export * from "./Cache.js";
|
|
5
7
|
export * from "./Callbacks.js";
|
|
6
8
|
export * from "./Console.js";
|
|
7
9
|
export * from "./Crypto.js";
|
|
@@ -9,18 +11,21 @@ export * from "./Eq.js";
|
|
|
9
11
|
export * from "./Error.js";
|
|
10
12
|
export * from "./Evolu/Public.js";
|
|
11
13
|
export * from "./Function.js";
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
+
export * from "./Identicon.js";
|
|
15
|
+
export * from "./Instances.js";
|
|
14
16
|
export * from "./Number.js";
|
|
15
17
|
export * from "./Object.js";
|
|
16
18
|
export * from "./Order.js";
|
|
17
|
-
export * from "./
|
|
19
|
+
export * from "./Platform.js";
|
|
18
20
|
export * from "./Random.js";
|
|
19
21
|
export * from "./Ref.js";
|
|
22
|
+
export * from "./Relation.js";
|
|
23
|
+
export * from "./Resources.js";
|
|
20
24
|
export * from "./Result.js";
|
|
21
25
|
export * from "./Sqlite.js";
|
|
22
26
|
export * from "./Store.js";
|
|
23
27
|
export * from "./String.js";
|
|
28
|
+
export * from "./Task.js";
|
|
24
29
|
export * from "./Time.js";
|
|
25
30
|
export * from "./Type.js";
|
|
26
31
|
export * from "./Types.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./Array.js";
|
|
2
2
|
export * from "./Assert.js";
|
|
3
3
|
export * from "./BigInt.js";
|
|
4
|
+
export * from "./Brand.js";
|
|
4
5
|
export * from "./Buffer.js";
|
|
6
|
+
export * from "./Cache.js";
|
|
5
7
|
export * from "./Callbacks.js";
|
|
6
8
|
export * from "./Console.js";
|
|
7
9
|
export * from "./Crypto.js";
|
|
@@ -9,18 +11,21 @@ export * from "./Eq.js";
|
|
|
9
11
|
export * from "./Error.js";
|
|
10
12
|
export * from "./Evolu/Public.js";
|
|
11
13
|
export * from "./Function.js";
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
+
export * from "./Identicon.js";
|
|
15
|
+
export * from "./Instances.js";
|
|
14
16
|
export * from "./Number.js";
|
|
15
17
|
export * from "./Object.js";
|
|
16
18
|
export * from "./Order.js";
|
|
17
|
-
export * from "./
|
|
19
|
+
export * from "./Platform.js";
|
|
18
20
|
export * from "./Random.js";
|
|
19
21
|
export * from "./Ref.js";
|
|
22
|
+
export * from "./Relation.js";
|
|
23
|
+
export * from "./Resources.js";
|
|
20
24
|
export * from "./Result.js";
|
|
21
25
|
export * from "./Sqlite.js";
|
|
22
26
|
export * from "./Store.js";
|
|
23
27
|
export * from "./String.js";
|
|
28
|
+
export * from "./Task.js";
|
|
24
29
|
export * from "./Time.js";
|
|
25
30
|
export * from "./Type.js";
|
|
26
31
|
export * from "./Types.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/common",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "TypeScript library and local-first
|
|
3
|
+
"version": "7.1.0",
|
|
4
|
+
"description": "TypeScript library and local-first platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
7
7
|
"local-first",
|
|
@@ -42,22 +42,22 @@
|
|
|
42
42
|
"README.md"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@noble/ciphers": "^
|
|
46
|
-
"@noble/hashes": "^
|
|
47
|
-
"@scure/bip39": "^
|
|
48
|
-
"kysely": "^0.28.
|
|
49
|
-
"msgpackr": "^1.11.
|
|
50
|
-
"
|
|
51
|
-
"random": "^5.4.0"
|
|
45
|
+
"@noble/ciphers": "^2.0.0",
|
|
46
|
+
"@noble/hashes": "^2.0.0",
|
|
47
|
+
"@scure/bip39": "^2.0.0",
|
|
48
|
+
"kysely": "^0.28.4",
|
|
49
|
+
"msgpackr": "^1.11.5",
|
|
50
|
+
"random": "^5.4.1"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
53
|
"@bokuweb/zstd-wasm": "0.0.27",
|
|
55
54
|
"@types/better-sqlite3": "^7.6.13",
|
|
56
55
|
"@types/ws": "^8.18.1",
|
|
57
56
|
"better-sqlite3": "^12.1.1",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
57
|
+
"fast-check": "^4.2.0",
|
|
58
|
+
"shx": "^0.4.0",
|
|
59
|
+
"typescript": "^5.9.2",
|
|
60
|
+
"vitest": "^4.0.4",
|
|
61
61
|
"ws": "^8.18.2",
|
|
62
62
|
"@evolu/tsconfig": "0.0.2"
|
|
63
63
|
},
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"scripts": {
|
|
72
72
|
"dev": "tsc --watch",
|
|
73
73
|
"build": "shx rm -rf dist ./README.md && tsc && shx cp ../../README.md ./",
|
|
74
|
-
"test": "vitest --disableConsoleIntercept",
|
|
74
|
+
"test": "vitest run --disableConsoleIntercept",
|
|
75
|
+
"test:watch": "vitest --disableConsoleIntercept",
|
|
75
76
|
"clean": "shx rm -rf .turbo node_modules dist",
|
|
76
77
|
"format": "prettier --write \"src/*.{ts,tsx,md}\"",
|
|
77
78
|
"bench": "vitest bench"
|