@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.
- package/README.md +4 -61
- package/dist/src/Array.d.ts +343 -102
- package/dist/src/Array.d.ts.map +1 -1
- package/dist/src/Array.js +181 -85
- package/dist/src/Assert.d.ts +57 -11
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +47 -11
- package/dist/src/BigInt.d.ts +6 -1
- package/dist/src/BigInt.d.ts.map +1 -1
- package/dist/src/BigInt.js +5 -0
- package/dist/src/Brand.d.ts +40 -12
- package/dist/src/Brand.d.ts.map +1 -1
- package/dist/src/Brand.js +5 -0
- package/dist/src/Buffer.d.ts +6 -1
- package/dist/src/Buffer.d.ts.map +1 -1
- package/dist/src/Buffer.js +7 -2
- package/dist/src/Cache.d.ts +10 -2
- package/dist/src/Cache.d.ts.map +1 -1
- package/dist/src/Cache.js +6 -0
- package/dist/src/Callbacks.d.ts +10 -7
- package/dist/src/Callbacks.d.ts.map +1 -1
- package/dist/src/Callbacks.js +23 -13
- package/dist/src/Console.d.ts +361 -69
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +217 -117
- package/dist/src/Crypto.d.ts +70 -21
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +72 -27
- package/dist/src/Eq.d.ts +22 -2
- package/dist/src/Eq.d.ts.map +1 -1
- package/dist/src/Eq.js +21 -1
- package/dist/src/Error.d.ts +23 -12
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +27 -11
- package/dist/src/Function.d.ts +128 -56
- package/dist/src/Function.d.ts.map +1 -1
- package/dist/src/Function.js +118 -14
- package/dist/src/Identicon.d.ts +5 -0
- package/dist/src/Identicon.d.ts.map +1 -1
- package/dist/src/Identicon.js +6 -1
- package/dist/src/Lookup.d.ts +160 -0
- package/dist/src/Lookup.d.ts.map +1 -0
- package/dist/src/Lookup.js +192 -0
- package/dist/src/Microtask.d.ts +21 -0
- package/dist/src/Microtask.d.ts.map +1 -0
- package/dist/src/Microtask.js +37 -0
- package/dist/src/Number.d.ts +18 -4
- package/dist/src/Number.d.ts.map +1 -1
- package/dist/src/Number.js +23 -1
- package/dist/src/Object.d.ts +110 -5
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +108 -5
- package/dist/src/Option.d.ts +58 -0
- package/dist/src/Option.d.ts.map +1 -0
- package/dist/src/Option.js +43 -0
- package/dist/src/Order.d.ts +5 -0
- package/dist/src/Order.d.ts.map +1 -1
- package/dist/src/Order.js +8 -3
- package/dist/src/Platform.d.ts +36 -2
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +10 -6
- package/dist/src/Polyfills.d.ts +27 -0
- package/dist/src/Polyfills.d.ts.map +1 -0
- package/dist/src/Polyfills.js +299 -0
- package/dist/src/Random.d.ts +18 -7
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Random.js +9 -7
- package/dist/src/Redacted.d.ts +7 -4
- package/dist/src/Redacted.d.ts.map +1 -1
- package/dist/src/Redacted.js +5 -0
- package/dist/src/Ref.d.ts +31 -16
- package/dist/src/Ref.d.ts.map +1 -1
- package/dist/src/Ref.js +35 -7
- package/dist/src/RefCount.d.ts +62 -0
- package/dist/src/RefCount.d.ts.map +1 -0
- package/dist/src/RefCount.js +83 -0
- package/dist/src/Relation.d.ts +84 -29
- package/dist/src/Relation.d.ts.map +1 -1
- package/dist/src/Relation.js +83 -105
- package/dist/src/Resource.d.ts +263 -0
- package/dist/src/Resource.d.ts.map +1 -0
- package/dist/src/Resource.js +389 -0
- package/dist/src/Result.d.ts +390 -374
- package/dist/src/Result.d.ts.map +1 -1
- package/dist/src/Result.js +142 -70
- package/dist/src/Schedule.d.ts +953 -0
- package/dist/src/Schedule.d.ts.map +1 -0
- package/dist/src/Schedule.js +1199 -0
- package/dist/src/Set.d.ts +181 -0
- package/dist/src/Set.d.ts.map +1 -0
- package/dist/src/Set.js +137 -0
- package/dist/src/Skiplist.d.ts +6 -1
- package/dist/src/Skiplist.d.ts.map +1 -1
- package/dist/src/Skiplist.js +5 -0
- package/dist/src/Sqlite.d.ts +160 -60
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +290 -190
- package/dist/src/Store.d.ts +36 -28
- package/dist/src/Store.d.ts.map +1 -1
- package/dist/src/Store.js +55 -15
- package/dist/src/String.d.ts +5 -0
- package/dist/src/String.d.ts.map +1 -1
- package/dist/src/String.js +5 -0
- package/dist/src/Task.d.ts +2263 -423
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +1488 -348
- package/dist/src/Test.d.ts +122 -0
- package/dist/src/Test.d.ts.map +1 -0
- package/dist/src/Test.js +66 -0
- package/dist/src/Time.d.ts +201 -48
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +190 -86
- package/dist/src/Tracer.d.ts +48 -0
- package/dist/src/Tracer.d.ts.map +1 -0
- package/dist/src/Tracer.js +6 -0
- package/dist/src/Type.d.ts +582 -209
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +362 -240
- package/dist/src/Types.d.ts +160 -6
- package/dist/src/Types.d.ts.map +1 -1
- package/dist/src/Types.js +22 -2
- package/dist/src/WebSocket.d.ts +113 -58
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +210 -118
- package/dist/src/Worker.d.ts +245 -60
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +220 -64
- package/dist/src/index.d.ts +25 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -3
- package/dist/src/local-first/Db.d.ts +24 -213
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +622 -293
- package/dist/src/local-first/Error.d.ts +12 -0
- package/dist/src/local-first/Error.d.ts.map +1 -0
- package/dist/src/local-first/Error.js +6 -0
- package/dist/src/local-first/Evolu.d.ts +330 -285
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +472 -402
- package/dist/src/local-first/LocalAuth.d.ts +10 -10
- package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
- package/dist/src/local-first/LocalAuth.js +6 -1
- package/dist/src/local-first/Owner.d.ts +70 -27
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +27 -14
- package/dist/src/local-first/Protocol.d.ts +58 -50
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +253 -155
- package/dist/src/local-first/Query.d.ts +133 -43
- package/dist/src/local-first/Query.d.ts.map +1 -1
- package/dist/src/local-first/Query.js +139 -90
- package/dist/src/local-first/Relay.d.ts +18 -38
- package/dist/src/local-first/Relay.d.ts.map +1 -1
- package/dist/src/local-first/Relay.js +59 -171
- package/dist/src/local-first/Schema.d.ts +139 -144
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Schema.js +78 -163
- package/dist/src/local-first/Shared.d.ts +125 -0
- package/dist/src/local-first/Shared.d.ts.map +1 -0
- package/dist/src/local-first/Shared.js +569 -0
- package/dist/src/local-first/Storage.d.ts +50 -53
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/dist/src/local-first/Storage.js +121 -173
- package/dist/src/local-first/Timestamp.d.ts +28 -35
- package/dist/src/local-first/Timestamp.d.ts.map +1 -1
- package/dist/src/local-first/Timestamp.js +24 -25
- package/dist/src/local-first/index.d.ts +2 -15
- package/dist/src/local-first/index.d.ts.map +1 -1
- package/dist/src/local-first/index.js +2 -15
- package/package.json +36 -26
- package/src/Array.ts +467 -106
- package/src/Assert.ts +87 -12
- package/src/BigInt.ts +7 -1
- package/src/Brand.ts +41 -12
- package/src/Buffer.ts +10 -4
- package/src/Cache.ts +11 -2
- package/src/Callbacks.ts +33 -23
- package/src/Console.ts +567 -178
- package/src/Crypto.ts +111 -62
- package/src/Eq.ts +30 -3
- package/src/Error.ts +50 -34
- package/src/Function.ts +140 -68
- package/src/Identicon.ts +7 -1
- package/src/Lookup.ts +415 -0
- package/src/Microtask.ts +58 -0
- package/src/Number.ts +40 -7
- package/src/Object.ts +155 -16
- package/src/Option.ts +74 -0
- package/src/Order.ts +11 -3
- package/src/Platform.ts +43 -7
- package/src/Polyfills.ts +465 -0
- package/src/Random.ts +25 -11
- package/src/Redacted.ts +8 -4
- package/src/Ref.ts +72 -21
- package/src/RefCount.ts +170 -0
- package/src/Relation.ts +188 -136
- package/src/Resource.ts +864 -0
- package/src/Result.ts +548 -381
- package/src/Schedule.ts +1471 -0
- package/src/Set.ts +247 -0
- package/src/Skiplist.ts +7 -1
- package/src/Sqlite.ts +409 -304
- package/src/Store.ts +94 -48
- package/src/String.ts +6 -0
- package/src/Task.ts +3685 -740
- package/src/Test.ts +162 -0
- package/src/Time.ts +348 -145
- package/src/Tracer.ts +54 -0
- package/src/Type.ts +1064 -630
- package/src/Types.ts +202 -7
- package/src/WebSocket.ts +311 -178
- package/src/Worker.ts +527 -147
- package/src/index.ts +74 -3
- package/src/local-first/Db.ts +871 -597
- package/src/local-first/Error.ts +17 -0
- package/src/local-first/Evolu.ts +884 -823
- package/src/local-first/LocalAuth.ts +10 -10
- package/src/local-first/Owner.ts +94 -42
- package/src/local-first/Protocol.ts +440 -303
- package/src/local-first/Query.ts +243 -194
- package/src/local-first/Relay.ts +91 -252
- package/src/local-first/Schema.ts +284 -394
- package/src/local-first/Shared.ts +932 -0
- package/src/local-first/Storage.ts +209 -282
- package/src/local-first/Timestamp.ts +38 -45
- package/src/local-first/index.ts +2 -16
- package/LICENSE +0 -21
- package/dist/src/Instances.d.ts +0 -34
- package/dist/src/Instances.d.ts.map +0 -1
- package/dist/src/Instances.js +0 -44
- package/dist/src/Resources.d.ts +0 -118
- package/dist/src/Resources.d.ts.map +0 -1
- package/dist/src/Resources.js +0 -197
- package/dist/src/local-first/Platform.d.ts +0 -25
- package/dist/src/local-first/Platform.d.ts.map +0 -1
- package/dist/src/local-first/Platform.js +0 -1
- package/dist/src/local-first/Public.d.ts +0 -22
- package/dist/src/local-first/Public.d.ts.map +0 -1
- package/dist/src/local-first/Public.js +0 -15
- package/dist/src/local-first/PublicKysely.d.ts +0 -148
- package/dist/src/local-first/PublicKysely.d.ts.map +0 -1
- package/dist/src/local-first/PublicKysely.js +0 -184
- package/dist/src/local-first/Sync.d.ts +0 -112
- package/dist/src/local-first/Sync.d.ts.map +0 -1
- package/dist/src/local-first/Sync.js +0 -529
- package/src/Instances.ts +0 -90
- package/src/Resources.ts +0 -367
- package/src/local-first/Platform.ts +0 -27
- package/src/local-first/Public.ts +0 -42
- package/src/local-first/PublicKysely.ts +0 -239
- package/src/local-first/Sync.ts +0 -960
package/dist/src/Brand.js
CHANGED
package/dist/src/Buffer.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary data handling and byte array utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { NonNegativeInt } from "./Type.js";
|
|
2
7
|
export { bytesToHex, bytesToUtf8, concatBytes, hexToBytes, utf8ToBytes, } from "@noble/ciphers/utils.js";
|
|
3
8
|
/**
|
|
@@ -13,7 +18,7 @@ export declare class BufferError extends Error {
|
|
|
13
18
|
* its capacity) to minimize memory reallocations and uses `subarray` for
|
|
14
19
|
* efficient, copy-free data access in methods like `unwrap` and `shift`.
|
|
15
20
|
*
|
|
16
|
-
*
|
|
21
|
+
* ## Recommended Usage
|
|
17
22
|
*
|
|
18
23
|
* Create as few Buffers as possible—typically one main Buffer for the final
|
|
19
24
|
* output. Temporary Buffers are allowed when necessary (e.g., for
|
package/dist/src/Buffer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Buffer.d.ts","sourceRoot":"","sources":["../../src/Buffer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Buffer.d.ts","sourceRoot":"","sources":["../../src/Buffer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAsB,MAAM,WAAW,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAM5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,WAAW,MAAM;IACrB,kDAAkD;IAClD,WAAW,EAAE,MAAM,cAAc,CAAC;IAElC,gEAAgE;IAChE,SAAS,EAAE,MAAM,cAAc,CAAC;IAEhC;;;OAGG;IACH,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAEtD;;;OAGG;IACH,KAAK,EAAE,MAAM,cAAc,CAAC;IAE5B;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,UAAU,CAAC;IAE1C;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAE3C;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB;;;;OAIG;IACH,MAAM,EAAE,MAAM,UAAU,CAAC;CAC1B;AAED,8DAA8D;AAC9D,eAAO,MAAM,YAAY,GACvB,YAAY,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,KACzC,MA4DF,CAAC"}
|
package/dist/src/Buffer.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Binary data handling and byte array utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { NonNegativeInt, zeroNonNegativeInt } from "./Type.js";
|
|
2
7
|
export { bytesToHex, bytesToUtf8, concatBytes, hexToBytes, utf8ToBytes, } from "@noble/ciphers/utils.js";
|
|
3
8
|
/**
|
|
4
9
|
* Custom error for {@link Buffer}-related failures like premature end of data.
|
|
@@ -56,7 +61,7 @@ export const createBuffer = (arrayLike) => {
|
|
|
56
61
|
length = newLength;
|
|
57
62
|
},
|
|
58
63
|
reset: () => {
|
|
59
|
-
length =
|
|
64
|
+
length = zeroNonNegativeInt;
|
|
60
65
|
},
|
|
61
66
|
unwrap: () => value.subarray(0, length),
|
|
62
67
|
};
|
package/dist/src/Cache.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache implementations including LRU eviction.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { PositiveInt } from "./Type.js";
|
|
2
7
|
/**
|
|
3
8
|
* Generic cache interface providing basic key-value storage operations.
|
|
4
9
|
*
|
|
5
10
|
* Keys are compared by reference (standard Map semantics).
|
|
6
11
|
*
|
|
7
|
-
* Note: Cache does not extend Map because
|
|
8
|
-
*
|
|
12
|
+
* Note: Cache has a Map-like API but does not extend Map because it behaves
|
|
13
|
+
* differently. Eviction policies (like LRU) can remove entries implicitly, and
|
|
14
|
+
* code that accepts a Map can assume values remain until deleted explicitly. An
|
|
15
|
+
* evicting cache is not a safe substitute for Map (Liskov Substitution
|
|
16
|
+
* Principle).
|
|
9
17
|
*/
|
|
10
18
|
export interface Cache<K, V> {
|
|
11
19
|
/** Checks if a key exists in the cache. */
|
package/dist/src/Cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;IACzB,2CAA2C;IAC3C,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;IAEzB,kEAAkE;IAClE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAE/B,4CAA4C;IAC5C,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;IAE9B,oCAAoC;IACpC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;IAEzB,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,UAAU,WAAW,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAmCtE,CAAC"}
|
package/dist/src/Cache.js
CHANGED
package/dist/src/Callbacks.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Request-response correlation for callbacks across boundaries.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { RandomBytesDep } from "./Crypto.js";
|
|
3
7
|
import { Id } from "./Type.js";
|
|
8
|
+
import type { Callback } from "./Types.js";
|
|
4
9
|
/**
|
|
5
10
|
* Request-response correlation for callbacks across boundaries.
|
|
6
11
|
*
|
|
@@ -40,14 +45,12 @@ import { Id } from "./Type.js";
|
|
|
40
45
|
* @template T - The type of argument passed to callbacks (defaults to undefined
|
|
41
46
|
* for no-argument callbacks)
|
|
42
47
|
*/
|
|
43
|
-
export interface Callbacks<T = undefined> {
|
|
48
|
+
export interface Callbacks<T = undefined> extends Disposable {
|
|
44
49
|
/** Registers a callback function and returns a unique ID. */
|
|
45
|
-
readonly register: (callback:
|
|
50
|
+
readonly register: (callback: Callback<T>) => Id;
|
|
46
51
|
/** Executes and removes a callback associated with the given ID. */
|
|
47
|
-
readonly execute: T extends undefined ? (id:
|
|
52
|
+
readonly execute: T extends undefined ? (id: Id) => undefined : (id: Id, arg: T) => undefined;
|
|
48
53
|
}
|
|
49
|
-
/** Unique identifier for a callback in {@link Callbacks}. */
|
|
50
|
-
export type CallbackId = Id & Brand<"Callback">;
|
|
51
54
|
/** Creates a {@link Callbacks} registry for managing callbacks. */
|
|
52
55
|
export declare const createCallbacks: <T = undefined>(deps: RandomBytesDep) => Callbacks<T>;
|
|
53
56
|
//# sourceMappingURL=Callbacks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Callbacks.d.ts","sourceRoot":"","sources":["../../src/Callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Callbacks.d.ts","sourceRoot":"","sources":["../../src/Callbacks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAY,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,SAAS,CAAE,SAAQ,UAAU;IAC1D,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAEjD,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,CAAC,SAAS,SAAS,GACjC,CAAC,EAAE,EAAE,EAAE,KAAK,SAAS,GACrB,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,SAAS,CAAC;CACnC;AAED,mEAAmE;AACnE,eAAO,MAAM,eAAe,GAAI,CAAC,GAAG,SAAS,EAC3C,MAAM,cAAc,KACnB,SAAS,CAAC,CAAC,CA6Bb,CAAC"}
|
package/dist/src/Callbacks.js
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Request-response correlation for callbacks across boundaries.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { createId, Id } from "./Type.js";
|
|
2
7
|
/** Creates a {@link Callbacks} registry for managing callbacks. */
|
|
3
8
|
export const createCallbacks = (deps) => {
|
|
4
9
|
const callbackMap = new Map();
|
|
10
|
+
const execute = ((id, ...args) => {
|
|
11
|
+
const callback = callbackMap.get(id);
|
|
12
|
+
if (!callback)
|
|
13
|
+
return undefined;
|
|
14
|
+
callbackMap.delete(id);
|
|
15
|
+
if (args.length === 0) {
|
|
16
|
+
// Called without argument (undefined case)
|
|
17
|
+
callback();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
callback(args[0]);
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
});
|
|
5
24
|
return {
|
|
6
25
|
register: (callback) => {
|
|
7
26
|
const id = createId(deps);
|
|
8
27
|
callbackMap.set(id, callback);
|
|
9
28
|
return id;
|
|
10
29
|
},
|
|
11
|
-
execute
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return;
|
|
15
|
-
callbackMap.delete(id);
|
|
16
|
-
if (args.length === 0) {
|
|
17
|
-
// Called without argument (undefined case)
|
|
18
|
-
callback();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
callback(args[0]);
|
|
22
|
-
}
|
|
30
|
+
execute,
|
|
31
|
+
[Symbol.dispose]: () => {
|
|
32
|
+
callbackMap.clear();
|
|
23
33
|
},
|
|
24
34
|
};
|
|
25
35
|
};
|
package/dist/src/Console.d.ts
CHANGED
|
@@ -1,95 +1,387 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* 22.x+, and React Native 0.75+. Includes methods guaranteed to be available in
|
|
4
|
-
* these environments and expected to remain compatible in future versions.
|
|
5
|
-
* Output formatting may vary (e.g., interactive UI in browsers vs. text in
|
|
6
|
-
* Node.js/React Native), but functionality is consistent across platforms.
|
|
2
|
+
* Platform-agnostic console with structured logging.
|
|
7
3
|
*
|
|
8
|
-
*
|
|
9
|
-
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadonlyStore } from "./Store.js";
|
|
7
|
+
import { type Millis, type TimeDep } from "./Time.js";
|
|
8
|
+
/**
|
|
9
|
+
* Platform-agnostic console with structured logging.
|
|
10
|
+
*
|
|
11
|
+
* Captures structured log entries and routes them to configurable outputs.
|
|
12
|
+
* Provides methods guaranteed to be available across browsers, Node.js, and
|
|
13
|
+
* React Native.
|
|
14
|
+
*
|
|
15
|
+
* Key features:
|
|
16
|
+
*
|
|
17
|
+
* - Structured entries — logs are captured as {@link ConsoleEntry} objects with
|
|
18
|
+
* method, path, and args
|
|
19
|
+
* - Pluggable outputs — route logs to console, files, arrays, or custom
|
|
20
|
+
* destinations via {@link ConsoleOutput}
|
|
21
|
+
* - Child consoles — use {@link Console.child} to create derived consoles
|
|
22
|
+
* - Level filtering — see {@link ConsoleLevel} for severity ordering
|
|
23
|
+
* - Entry formatting — use {@link createConsoleFormatter} for timestamps and path
|
|
24
|
+
* prefixes
|
|
25
|
+
*
|
|
26
|
+
* Built-in outputs:
|
|
27
|
+
*
|
|
28
|
+
* - {@link createNativeConsoleOutput} — writes to `globalThis.console` (default)
|
|
29
|
+
* - {@link createConsoleArrayOutput} — captures entries to an array (testing)
|
|
30
|
+
* - {@link createConsoleStoreOutput} — stores latest entry in a
|
|
31
|
+
* {@link ReadonlyStore} for subscribing
|
|
32
|
+
* - {@link createMultiOutput} — fans out to multiple outputs
|
|
10
33
|
*
|
|
11
34
|
* ### Example
|
|
12
35
|
*
|
|
13
36
|
* ```ts
|
|
14
|
-
*
|
|
15
|
-
*
|
|
37
|
+
* // Basic usage - defaults to "log"
|
|
38
|
+
* const console = createConsole();
|
|
16
39
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
40
|
+
* // With formatting (timestamps and path prefixes)
|
|
41
|
+
* const console = createConsole({
|
|
42
|
+
* level: "info",
|
|
43
|
+
* formatter: createConsoleFormatter()({ timestampFormat: "relative" }),
|
|
44
|
+
* });
|
|
19
45
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* node app.js | grep -v "\[debug\]" # Hide debug logs
|
|
24
|
-
* ```
|
|
46
|
+
* // Children inherit level at creation, then are independent
|
|
47
|
+
* const console = run.deps.console.child("relay");
|
|
48
|
+
* console.setLevel("silent");
|
|
25
49
|
*
|
|
26
|
-
*
|
|
50
|
+
* // Tip: Wrap logged values in objects for labeled output in DevTools
|
|
51
|
+
* console.info("Creating instance", { config }); // Good — expandable "config:" label
|
|
52
|
+
* console.info("Creating instance", config); // Avoid — anonymous object, no label
|
|
27
53
|
*
|
|
28
|
-
*
|
|
29
|
-
* {
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
54
|
+
* // Batch update via children
|
|
55
|
+
* const setLevelRecursive = (c: Console, level: ConsoleLevel): void => {
|
|
56
|
+
* c.setLevel(level);
|
|
57
|
+
* for (const child of c.children) setLevelRecursive(child, level);
|
|
58
|
+
* };
|
|
35
59
|
* ```
|
|
60
|
+
*
|
|
61
|
+
* Console intentionally does not use {@link Task}. Logging must be as fast as
|
|
62
|
+
* possible and always work, even during error handling or shutdown.
|
|
63
|
+
*
|
|
64
|
+
* For testing, use {@link testCreateConsole} which creates a {@link TestConsole}
|
|
65
|
+
* with array output and snapshot helpers.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link createConsole}
|
|
36
68
|
*/
|
|
37
69
|
export interface Console {
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
/** Name of this console. Empty for root. */
|
|
71
|
+
readonly name: string;
|
|
72
|
+
/** Child consoles created via {@link Console.child}. */
|
|
73
|
+
readonly children: ReadonlySet<Console>;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the effective log level.
|
|
76
|
+
*
|
|
77
|
+
* If this console has its own level set via {@link Console.setLevel}, returns
|
|
78
|
+
* that. Otherwise returns the inherited level from creation time.
|
|
79
|
+
*/
|
|
80
|
+
readonly getLevel: () => ConsoleLevel;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the log level for this console.
|
|
83
|
+
*
|
|
84
|
+
* Pass a level to override the inherited level, or `null` to revert to the
|
|
85
|
+
* inherited level.
|
|
86
|
+
*/
|
|
87
|
+
readonly setLevel: (level: ConsoleLevel | null) => void;
|
|
88
|
+
/** Returns true if this console has its own level set (not inherited). */
|
|
89
|
+
readonly hasOwnLevel: () => boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a child console with the given name added to the path.
|
|
92
|
+
*
|
|
93
|
+
* Child inherits the parent's configured level (not any runtime override).
|
|
94
|
+
* Use {@link Console.children} to access all children for batch operations.
|
|
95
|
+
*/
|
|
96
|
+
readonly child: (name: string) => Console;
|
|
97
|
+
/** Outputs a stack trace. */
|
|
98
|
+
readonly trace: (...args: ReadonlyArray<unknown>) => void;
|
|
99
|
+
/** Development diagnostics. */
|
|
100
|
+
readonly debug: (...args: ReadonlyArray<unknown>) => void;
|
|
101
|
+
/** General-purpose messages. */
|
|
102
|
+
readonly log: (...args: ReadonlyArray<unknown>) => void;
|
|
103
|
+
/** Operational milestones (startup, shutdown). */
|
|
104
|
+
readonly info: (...args: ReadonlyArray<unknown>) => void;
|
|
105
|
+
/** Recoverable issues that may need attention. */
|
|
106
|
+
readonly warn: (...args: ReadonlyArray<unknown>) => void;
|
|
107
|
+
/** Failures requiring immediate attention. */
|
|
108
|
+
readonly error: (...args: ReadonlyArray<unknown>) => void;
|
|
109
|
+
/** Displays an object with expandable properties. Level: debug. */
|
|
110
|
+
readonly dir: (item: unknown) => void;
|
|
111
|
+
/** Displays tabular data. Level: debug. */
|
|
112
|
+
readonly table: (data: unknown) => void;
|
|
113
|
+
/** Starts a timer with the given label. Level: debug. */
|
|
114
|
+
readonly time: (label: string) => void;
|
|
115
|
+
/** Logs elapsed time for a timer. Level: debug. */
|
|
116
|
+
readonly timeLog: (label: string, ...args: ReadonlyArray<unknown>) => void;
|
|
117
|
+
/** Ends a timer and logs elapsed time. Level: debug. */
|
|
118
|
+
readonly timeEnd: (label: string) => void;
|
|
119
|
+
/** Increments and logs a counter. Level: debug. */
|
|
120
|
+
readonly count: (label?: string) => void;
|
|
121
|
+
/** Resets a counter. Level: debug. */
|
|
122
|
+
readonly countReset: (label?: string) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Writes a pre-built {@link ConsoleEntry} directly to the output, bypassing
|
|
125
|
+
* level filtering. Used to replay entries from another context (e.g., a
|
|
126
|
+
* SharedWorker) where filtering was already applied.
|
|
127
|
+
*/
|
|
128
|
+
readonly write: (entry: ConsoleEntry) => void;
|
|
68
129
|
}
|
|
69
|
-
/** Dependency interface for injecting a Console instance. */
|
|
70
130
|
export interface ConsoleDep {
|
|
71
131
|
readonly console: Console;
|
|
72
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Log level controlling which messages are output.
|
|
135
|
+
*
|
|
136
|
+
* Setting a level enables all logs at that level and above (ordered by
|
|
137
|
+
* severity):
|
|
138
|
+
*
|
|
139
|
+
* - `"trace"` — Stack traces and detailed execution flow
|
|
140
|
+
* - `"debug"` — Development diagnostics, timers, counters
|
|
141
|
+
* - `"log"` — General-purpose messages
|
|
142
|
+
* - `"info"` — Operational milestones (startup, shutdown)
|
|
143
|
+
* - `"warn"` — Recoverable issues that may need attention
|
|
144
|
+
* - `"error"` — Failures requiring immediate attention
|
|
145
|
+
* - `"silent"` — Disables all logging
|
|
146
|
+
*/
|
|
147
|
+
export type ConsoleLevel = "trace" | "debug" | "log" | "info" | "warn" | "error" | "silent";
|
|
148
|
+
/**
|
|
149
|
+
* Structured log entry captured by {@link Console}.
|
|
150
|
+
*
|
|
151
|
+
* Contains all information needed for outputs to route the log: method for
|
|
152
|
+
* routing, path for context, and the original arguments.
|
|
153
|
+
*/
|
|
154
|
+
export interface ConsoleEntry {
|
|
155
|
+
/** The console method that was called. */
|
|
156
|
+
readonly method: ConsoleMethod;
|
|
157
|
+
/** Hierarchical path from {@link Console.child} calls (e.g., ["relay", "db"]). */
|
|
158
|
+
readonly path: ReadonlyArray<string>;
|
|
159
|
+
/** Original arguments passed to the console method. */
|
|
160
|
+
readonly args: ReadonlyArray<unknown>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Console method being called.
|
|
164
|
+
*
|
|
165
|
+
* Used in {@link ConsoleEntry} to identify which console method was invoked.
|
|
166
|
+
* Outputs can route or format differently based on the method.
|
|
167
|
+
*/
|
|
168
|
+
export type ConsoleMethod = "trace" | "debug" | "log" | "info" | "warn" | "error" | "dir" | "table" | "time" | "timeLog" | "timeEnd" | "count" | "countReset";
|
|
169
|
+
/**
|
|
170
|
+
* Output destination for {@link Console}.
|
|
171
|
+
*
|
|
172
|
+
* Implement this interface to create custom log destinations (file, network,
|
|
173
|
+
* array for testing, etc.).
|
|
174
|
+
*
|
|
175
|
+
* Use {@link createNativeConsoleOutput} for native console output.
|
|
176
|
+
*/
|
|
177
|
+
export interface ConsoleOutput {
|
|
178
|
+
/** Write a log entry to this output. */
|
|
179
|
+
readonly write: (entry: ConsoleEntry, formatter?: ConsoleFormatter) => void;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Transforms a {@link ConsoleEntry} before output.
|
|
183
|
+
*
|
|
184
|
+
* Used by {@link ConsoleConfig.formatter} and {@link ConsoleOutput.write}. Create
|
|
185
|
+
* one with {@link createConsoleFormatter}.
|
|
186
|
+
*/
|
|
187
|
+
export type ConsoleFormatter = (entry: ConsoleEntry) => ReadonlyArray<unknown>;
|
|
188
|
+
/** Configuration for {@link createConsole}. */
|
|
73
189
|
export interface ConsoleConfig {
|
|
190
|
+
/** Name of this console. Defaults to empty string. */
|
|
191
|
+
readonly name?: string;
|
|
192
|
+
/** Initial log level. Defaults to `"log"`. */
|
|
193
|
+
readonly level?: ConsoleLevel;
|
|
74
194
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* methods except `error`, which always outputs to ensure critical issues are
|
|
78
|
-
* not missed.
|
|
195
|
+
* Output destination for log entries. Defaults to
|
|
196
|
+
* {@link createNativeConsoleOutput}.
|
|
79
197
|
*/
|
|
80
|
-
readonly
|
|
198
|
+
readonly output?: ConsoleOutput;
|
|
199
|
+
/** Path prefix for this console. Defaults to `[]`. */
|
|
200
|
+
readonly path?: ReadonlyArray<string>;
|
|
201
|
+
/**
|
|
202
|
+
* Transforms entry args before writing (e.g., adds timestamps, path
|
|
203
|
+
* prefixes).
|
|
204
|
+
*
|
|
205
|
+
* Receives the entry and returns modified args. Use
|
|
206
|
+
* {@link createConsoleFormatter} for common formatting options.
|
|
207
|
+
*/
|
|
208
|
+
readonly formatter?: ConsoleFormatter;
|
|
81
209
|
}
|
|
82
|
-
/**
|
|
83
|
-
export
|
|
84
|
-
export interface ConsoleWithTimeConfig extends ConsoleConfig {
|
|
210
|
+
/** Configuration for {@link createConsoleFormatter}. */
|
|
211
|
+
export interface ConsoleFormatterConfig {
|
|
85
212
|
/**
|
|
86
|
-
*
|
|
213
|
+
* Timestamp format to prepend to log messages.
|
|
87
214
|
*
|
|
88
|
-
* -
|
|
89
|
-
* -
|
|
215
|
+
* - `"relative"` — elapsed since start: `+0.000s`, `+1.500s`, `+1m30.000s`
|
|
216
|
+
* - `"absolute"` — local clock time: `14:32:15.234`
|
|
217
|
+
* - `"iso"` — ISO 8601 UTC: `2026-01-28T14:30:00.123Z`
|
|
218
|
+
* - `"none"` — no timestamp (default)
|
|
90
219
|
*/
|
|
91
|
-
readonly
|
|
220
|
+
readonly timestampFormat?: ConsoleEntryTimestampFormat;
|
|
221
|
+
/**
|
|
222
|
+
* Start time for relative timestamps. Defaults to first entry timestamp.
|
|
223
|
+
*
|
|
224
|
+
* Pass a {@link Millis} value to use a custom start time, useful when multiple
|
|
225
|
+
* consoles should share the same relative timeline.
|
|
226
|
+
*/
|
|
227
|
+
readonly startTime?: Millis;
|
|
228
|
+
}
|
|
229
|
+
/** Timestamp format for {@link ConsoleFormatterConfig}. */
|
|
230
|
+
export type ConsoleEntryTimestampFormat = "relative" | "absolute" | "iso" | "none";
|
|
231
|
+
/**
|
|
232
|
+
* A {@link ConsoleOutput} that stores the latest entry in a
|
|
233
|
+
* {@link ReadonlyStore}.
|
|
234
|
+
*
|
|
235
|
+
* Subscribe to {@link ConsoleStoreOutput.entry} to observe all log entries.
|
|
236
|
+
*
|
|
237
|
+
* ### Example
|
|
238
|
+
*
|
|
239
|
+
* ```ts
|
|
240
|
+
* const storeOutput = createConsoleStoreOutput();
|
|
241
|
+
* const console = createConsole({ output: storeOutput });
|
|
242
|
+
*
|
|
243
|
+
* storeOutput.entry.subscribe(() => {
|
|
244
|
+
* const entry = storeOutput.entry.get();
|
|
245
|
+
* if (entry) forwardToClient(entry);
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export interface ConsoleStoreOutput extends ConsoleOutput {
|
|
250
|
+
/** Latest entry written to this output. */
|
|
251
|
+
readonly entry: ReadonlyStore<ConsoleEntry | null>;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Dependency providing the latest {@link ConsoleEntry} from a
|
|
255
|
+
* {@link ConsoleStoreOutput}.
|
|
256
|
+
*/
|
|
257
|
+
export interface ConsoleStoreOutputEntryDep {
|
|
258
|
+
readonly consoleStoreOutputEntry: ReadonlyStore<ConsoleEntry | null>;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* A test console that captures all output for assertions.
|
|
262
|
+
*
|
|
263
|
+
* Use as a drop-in replacement for {@link Console} in tests.
|
|
264
|
+
*/
|
|
265
|
+
export interface TestConsole extends Console {
|
|
266
|
+
/** Gets all captured entries and clears the internal buffer. */
|
|
267
|
+
readonly getEntriesSnapshot: () => ReadonlyArray<ConsoleEntry>;
|
|
268
|
+
/** Clears all captured entries. */
|
|
269
|
+
readonly clearEntries: () => void;
|
|
92
270
|
}
|
|
93
|
-
|
|
94
|
-
|
|
271
|
+
export interface TestConsoleDep {
|
|
272
|
+
readonly console: TestConsole;
|
|
273
|
+
}
|
|
274
|
+
/** Creates a {@link Console}. */
|
|
275
|
+
export declare const createConsole: ({ name, level, output, path, formatter, }?: ConsoleConfig) => Console;
|
|
276
|
+
/**
|
|
277
|
+
* Creates a {@link ConsoleOutput} that writes to `globalThis.console`.
|
|
278
|
+
*
|
|
279
|
+
* Pure transport - just calls the native console method with the entry args.
|
|
280
|
+
* Use {@link createConsoleFormatter} with {@link ConsoleConfig.formatter} for
|
|
281
|
+
* timestamps and path prefixes.
|
|
282
|
+
*
|
|
283
|
+
* ### Example
|
|
284
|
+
*
|
|
285
|
+
* ```ts
|
|
286
|
+
* const output = createNativeConsoleOutput();
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export declare const createNativeConsoleOutput: () => ConsoleOutput;
|
|
290
|
+
/**
|
|
291
|
+
* Creates a {@link ConsoleFormatter} for {@link ConsoleConfig.formatter}.
|
|
292
|
+
*
|
|
293
|
+
* Prepends timestamps and path prefixes to entry args.
|
|
294
|
+
*
|
|
295
|
+
* ### Example
|
|
296
|
+
*
|
|
297
|
+
* ```ts
|
|
298
|
+
* const root = createConsole({
|
|
299
|
+
* formatter: createConsoleFormatter()({
|
|
300
|
+
* timestampFormat: "relative",
|
|
301
|
+
* }),
|
|
302
|
+
* });
|
|
303
|
+
*
|
|
304
|
+
* // Relative — elapsed since start
|
|
305
|
+
* const relay = root.child("relay");
|
|
306
|
+
* relay.log("connected"); // +0.000s [relay] connected
|
|
307
|
+
* relay.log("synced"); // +1.500s [relay] synced
|
|
308
|
+
*
|
|
309
|
+
* // Nested children
|
|
310
|
+
* const db = relay.child("db");
|
|
311
|
+
* db.log("opened"); // +1.500s [relay] [db] opened
|
|
312
|
+
*
|
|
313
|
+
* // Absolute — local clock time (HH:MM:SS.mmm)
|
|
314
|
+
* // relay.log("connected"); // 15:30:15.123 [relay] connected
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export declare const createConsoleFormatter: ({ time }?: Partial<TimeDep>) => (config?: ConsoleFormatterConfig) => ConsoleFormatter;
|
|
318
|
+
/** Creates a {@link ConsoleStoreOutput}. */
|
|
319
|
+
export declare const createConsoleStoreOutput: () => ConsoleStoreOutput;
|
|
320
|
+
/**
|
|
321
|
+
* Creates a {@link ConsoleOutput} that captures entries to an array.
|
|
322
|
+
*
|
|
323
|
+
* Useful for testing. Pass your own array to inspect captured entries.
|
|
324
|
+
*
|
|
325
|
+
* ### Example
|
|
326
|
+
*
|
|
327
|
+
* ```ts
|
|
328
|
+
* const entries: Array<ConsoleEntry> = [];
|
|
329
|
+
* const output = createConsoleArrayOutput(entries);
|
|
330
|
+
*
|
|
331
|
+
* // After logging...
|
|
332
|
+
* expect(entries).toMatchInlineSnapshot();
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
export declare const createConsoleArrayOutput: (entries: Array<ConsoleEntry>) => ConsoleOutput;
|
|
336
|
+
/**
|
|
337
|
+
* Creates a {@link ConsoleOutput} that fans out to multiple outputs.
|
|
338
|
+
*
|
|
339
|
+
* Each entry is written to all outputs in order. Useful for combining a native
|
|
340
|
+
* console output with a store output for forwarding.
|
|
341
|
+
*
|
|
342
|
+
* ### Example
|
|
343
|
+
*
|
|
344
|
+
* ```ts
|
|
345
|
+
* const storeOutput = createConsoleStoreOutput();
|
|
346
|
+
* const console = createConsole({
|
|
347
|
+
* output: createMultiOutput([createNativeConsoleOutput(), storeOutput]),
|
|
348
|
+
* });
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
export declare const createMultiOutput: (outputs: ReadonlyArray<ConsoleOutput>) => ConsoleOutput;
|
|
352
|
+
/**
|
|
353
|
+
* Creates a {@link TestConsole} that captures all output for testing.
|
|
354
|
+
*
|
|
355
|
+
* Unlike {@link createConsole}, this doesn't require dependencies and uses a
|
|
356
|
+
* simple incrementing counter for timestamps (starting at 0).
|
|
357
|
+
*
|
|
358
|
+
* ### Example
|
|
359
|
+
*
|
|
360
|
+
* ```ts
|
|
361
|
+
* test("logging", () => {
|
|
362
|
+
* const console = testCreateConsole();
|
|
363
|
+
* console.info("Hello");
|
|
364
|
+
*
|
|
365
|
+
* expect(console.getEntriesSnapshot()).toMatchInlineSnapshot(`
|
|
366
|
+
* [
|
|
367
|
+
* {
|
|
368
|
+
* "method": "info",
|
|
369
|
+
* "path": [],
|
|
370
|
+
* "args": ["Hello"]
|
|
371
|
+
* }
|
|
372
|
+
* ]
|
|
373
|
+
* `);
|
|
374
|
+
* });
|
|
375
|
+
*
|
|
376
|
+
* test("level filtering", () => {
|
|
377
|
+
* const console = testCreateConsole({ level: "warn" });
|
|
378
|
+
* console.debug("ignored");
|
|
379
|
+
* console.warn("logged");
|
|
380
|
+
* expect(console.getEntriesSnapshot()).toHaveLength(1);
|
|
381
|
+
* });
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
export declare const testCreateConsole: ({ level, }?: {
|
|
385
|
+
level?: ConsoleLevel;
|
|
386
|
+
}) => TestConsole;
|
|
95
387
|
//# sourceMappingURL=Console.d.ts.map
|