@abraca/dabra 2.93.0 → 2.96.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/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,35 @@ declare class OfflineStore {
|
|
|
169
169
|
private dbPromise;
|
|
170
170
|
private _destroyed;
|
|
171
171
|
private getDb;
|
|
172
|
+
/** Updates buffered for the next batched write. */
|
|
173
|
+
private writeBuffer;
|
|
174
|
+
/** Callers of `persistUpdate` awaiting the batch that carries their update. */
|
|
175
|
+
private writeWaiters;
|
|
176
|
+
private flushTimer;
|
|
177
|
+
/**
|
|
178
|
+
* Queue a local update for persistence.
|
|
179
|
+
*
|
|
180
|
+
* The returned promise settles when the update has actually been committed,
|
|
181
|
+
* not when it was queued — so `await persistUpdate(u)` still means "on disk",
|
|
182
|
+
* exactly as it did when every call opened its own transaction.
|
|
183
|
+
*/
|
|
172
184
|
persistUpdate(update: Uint8Array): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Commit every buffered update as ONE transaction.
|
|
187
|
+
*
|
|
188
|
+
* Safe to call at any time, including with an empty buffer — every read path
|
|
189
|
+
* calls it first so a caller can never observe a store that is missing writes
|
|
190
|
+
* still sitting in memory.
|
|
191
|
+
*/
|
|
192
|
+
flushWrites(): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Issue the buffered writes synchronously, without awaiting them.
|
|
195
|
+
*
|
|
196
|
+
* For teardown paths that cannot await: `pagehide` (the page may not survive
|
|
197
|
+
* a microtask) and `destroy()`. IndexedDB will not close a connection until
|
|
198
|
+
* its running transactions finish, so writes issued here still land.
|
|
199
|
+
*/
|
|
200
|
+
flushWritesSync(): void;
|
|
173
201
|
getPendingUpdates(): Promise<Uint8Array[]>;
|
|
174
202
|
clearPendingUpdates(): Promise<void>;
|
|
175
203
|
/**
|
|
@@ -397,6 +425,28 @@ interface AbracadabraClientConfig {
|
|
|
397
425
|
* concurrent invocations.
|
|
398
426
|
*/
|
|
399
427
|
onAuthFailed?: (ctx: AuthFailureContext) => void;
|
|
428
|
+
/**
|
|
429
|
+
* How long before a token's `exp` the session is re-minted, in ms.
|
|
430
|
+
*
|
|
431
|
+
* Only meaningful once a session renewer is installed — which
|
|
432
|
+
* {@link AbracadabraClient.loginWithKey} does for you. Capped at a third of
|
|
433
|
+
* the token's own lifetime, so a server issuing short-lived tokens is not
|
|
434
|
+
* re-authenticated on every check.
|
|
435
|
+
*
|
|
436
|
+
* Default 20 minutes: comfortably inside the server's 4-hour crypto-auth
|
|
437
|
+
* TTL and wider than any polling interval a consumer is likely to run.
|
|
438
|
+
*/
|
|
439
|
+
tokenRenewMarginMs?: number;
|
|
440
|
+
/**
|
|
441
|
+
* Fallback interval, in ms, for a token whose `exp` cannot be read.
|
|
442
|
+
* Default 60s.
|
|
443
|
+
*
|
|
444
|
+
* Renewal is normally scheduled from the token's own expiry, so this is not
|
|
445
|
+
* a poll. `0` disables the timer entirely — the session is then renewed
|
|
446
|
+
* only on demand (before a socket handshake, or an explicit
|
|
447
|
+
* {@link AbracadabraClient.ensureFreshToken}).
|
|
448
|
+
*/
|
|
449
|
+
tokenRenewCheckMs?: number;
|
|
400
450
|
}
|
|
401
451
|
declare class AbracadabraClient {
|
|
402
452
|
private _token;
|
|
@@ -418,12 +468,78 @@ declare class AbracadabraClient {
|
|
|
418
468
|
/** In-flight mints, keyed like `streamTokens` — collapses the burst a page
|
|
419
469
|
* of media blocks produces into one request per upload. */
|
|
420
470
|
private readonly streamTokenInflight;
|
|
471
|
+
private _renew;
|
|
472
|
+
private _renewing;
|
|
473
|
+
private _renewTimer;
|
|
474
|
+
private readonly _tokenListeners;
|
|
475
|
+
private readonly renewMarginMs;
|
|
476
|
+
private readonly renewCheckMs;
|
|
421
477
|
constructor(config: AbracadabraClientConfig);
|
|
422
478
|
get token(): string | null;
|
|
423
479
|
set token(value: string | null);
|
|
424
480
|
get isAuthenticated(): boolean;
|
|
425
481
|
/** Check if the current JWT token is present and not expired. */
|
|
426
482
|
isTokenValid(): boolean;
|
|
483
|
+
/** When the current token stops validating, in ms. `0` when unknown. */
|
|
484
|
+
get tokenExpiresAt(): number;
|
|
485
|
+
/**
|
|
486
|
+
* Install the way this client re-authenticates itself, or `null` to stop.
|
|
487
|
+
*
|
|
488
|
+
* {@link loginWithKey} installs one for you, so a key-authenticated client
|
|
489
|
+
* — every Node runner, and every browser session on a crypto identity —
|
|
490
|
+
* renews without its consumer doing anything. Install one by hand for a
|
|
491
|
+
* password session or any other flow that can mint a fresh token.
|
|
492
|
+
*
|
|
493
|
+
* The function must return the new JWT; adopting it (and notifying open
|
|
494
|
+
* sockets) is this client's job.
|
|
495
|
+
*/
|
|
496
|
+
setSessionRenewer(renew: (() => Promise<string>) | null): void;
|
|
497
|
+
/** Whether this client knows how to re-authenticate itself. */
|
|
498
|
+
get canRenewSession(): boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Called whenever the session token changes — a login, a renewal, a device
|
|
501
|
+
* refresh, a key revocation. Providers use this to re-arm sockets that are
|
|
502
|
+
* already open. Returns an unsubscribe function.
|
|
503
|
+
*/
|
|
504
|
+
onTokenChanged(listener: (token: string) => void): () => void;
|
|
505
|
+
/**
|
|
506
|
+
* Make sure the token has life left in it, re-minting if it does not.
|
|
507
|
+
*
|
|
508
|
+
* Cheap when the token is fresh — one subtraction — so callers need not
|
|
509
|
+
* reason about when the last renewal was, and concurrent callers share one
|
|
510
|
+
* handshake. Returns whether the session is believed good; `false` is not
|
|
511
|
+
* fatal, and the caller's own failure is still the authority.
|
|
512
|
+
*/
|
|
513
|
+
ensureFreshToken(marginMs?: number): Promise<boolean>;
|
|
514
|
+
/**
|
|
515
|
+
* How long before `exp` this session is re-minted.
|
|
516
|
+
*
|
|
517
|
+
* Capped at a third of the token's own lifetime, so a server configured
|
|
518
|
+
* with short-lived tokens is not re-authenticated on every check — without
|
|
519
|
+
* the cap a 45-second token against a 20-minute margin would mint a new
|
|
520
|
+
* session every time anything asked.
|
|
521
|
+
*/
|
|
522
|
+
private renewMargin;
|
|
523
|
+
/**
|
|
524
|
+
* Arm a single timer for the moment this token needs replacing.
|
|
525
|
+
*
|
|
526
|
+
* Scheduled from the token's OWN expiry rather than on a fixed interval,
|
|
527
|
+
* and that is not tidiness. A poll can outrun the margin: measured against
|
|
528
|
+
* a server issuing 45-second tokens, a 60-second poll first fired fifteen
|
|
529
|
+
* seconds AFTER the token had already lapsed — long enough for the
|
|
530
|
+
* awareness heartbeat to hit an expired session and have the socket dropped
|
|
531
|
+
* under it. A deadline cannot be outrun by the thing it is a deadline for.
|
|
532
|
+
*
|
|
533
|
+
* Re-armed on every token change, so a renewal schedules the next one.
|
|
534
|
+
*/
|
|
535
|
+
private scheduleSessionRenewal;
|
|
536
|
+
private stopSessionRenewal;
|
|
537
|
+
/**
|
|
538
|
+
* Stop renewing and drop every listener. Call when a client is discarded —
|
|
539
|
+
* a long-lived consumer that builds one client per connection would
|
|
540
|
+
* otherwise leave a timer per discarded client.
|
|
541
|
+
*/
|
|
542
|
+
destroy(): void;
|
|
427
543
|
/** Derives ws:// or wss:// URL from the http(s) base URL. */
|
|
428
544
|
get wsUrl(): string;
|
|
429
545
|
/** Register a new user with password. */
|
|
@@ -1541,6 +1657,8 @@ declare class AbracadabraProvider extends AbracadabraBaseProvider {
|
|
|
1541
1657
|
private static readonly DEFAULT_MAX_CHILDREN;
|
|
1542
1658
|
private readonly maxChildren;
|
|
1543
1659
|
private abracadabraConfig;
|
|
1660
|
+
/** Detach from the client's token broadcasts. See the constructor. */
|
|
1661
|
+
private unsubscribeToken;
|
|
1544
1662
|
private readonly boundHandleYSubdocsChange;
|
|
1545
1663
|
/**
|
|
1546
1664
|
* Resolves once the document has been pre-populated from the local
|
|
@@ -1661,6 +1779,16 @@ declare class AbracadabraProvider extends AbracadabraBaseProvider {
|
|
|
1661
1779
|
private evictLRU;
|
|
1662
1780
|
/** Return all currently-loaded child providers. */
|
|
1663
1781
|
get children(): Map<string, AbracadabraProvider>;
|
|
1782
|
+
/**
|
|
1783
|
+
* Land buffered offline writes before the page goes away.
|
|
1784
|
+
*
|
|
1785
|
+
* `OfflineStore` coalesces local updates into one transaction per ~150 ms
|
|
1786
|
+
* window (see WRITE_COALESCE_MS). That window is the only moment an edit
|
|
1787
|
+
* exists in memory but not on disk, and a closing tab is exactly when it
|
|
1788
|
+
* would be lost — so pagehide flushes it synchronously. `super.pageHide()`
|
|
1789
|
+
* still clears our awareness state for peers.
|
|
1790
|
+
*/
|
|
1791
|
+
pageHide(): void;
|
|
1664
1792
|
/**
|
|
1665
1793
|
* Override to persist every local update to IndexedDB before sending it
|
|
1666
1794
|
* over the wire, ensuring no work is lost during connection outages.
|
|
@@ -2606,6 +2734,7 @@ declare class AbracadabraWS extends EventEmitter {
|
|
|
2606
2734
|
} | null;
|
|
2607
2735
|
private onlineListener;
|
|
2608
2736
|
private offlineListener;
|
|
2737
|
+
unsubscribeLifecycle: (() => void) | null;
|
|
2609
2738
|
constructor(configuration: AbracadabraWSConfiguration);
|
|
2610
2739
|
/**
|
|
2611
2740
|
* Whether the device currently believes it has network connectivity.
|
|
@@ -2653,6 +2782,33 @@ declare class AbracadabraWS extends EventEmitter {
|
|
|
2653
2782
|
*/
|
|
2654
2783
|
reconnect(): Promise<unknown>;
|
|
2655
2784
|
send(message: any): void;
|
|
2785
|
+
/** The last token this socket was re-armed with — see {@link refreshAuth}. */
|
|
2786
|
+
private lastRefreshToken;
|
|
2787
|
+
/**
|
|
2788
|
+
* Re-arm this CONNECTION with a freshly minted JWT, in place.
|
|
2789
|
+
*
|
|
2790
|
+
* The server tracks a connection's expiry as one shared value
|
|
2791
|
+
* (`SyncSession`'s `jwt_exp`, an `Arc<AtomicI64>` every session on the socket
|
|
2792
|
+
* points at) and rejects every non-stateless frame once it passes — dropping
|
|
2793
|
+
* the whole socket for an ordinary session. `auth:refresh {"token":…}` moves
|
|
2794
|
+
* that value, and it rides `MSG_STATELESS` precisely because stateless is the
|
|
2795
|
+
* one frame kind an expired session may still send.
|
|
2796
|
+
*
|
|
2797
|
+
* So ONE frame, through any authenticated document, re-arms everything
|
|
2798
|
+
* multiplexed here. Sending it per attached provider would be N identical
|
|
2799
|
+
* frames on a shared socket carrying sixty documents; `lastRefreshToken` is
|
|
2800
|
+
* what keeps it at one.
|
|
2801
|
+
*
|
|
2802
|
+
* Verified against a live server with a 45-second token TTL, on an ORDINARY
|
|
2803
|
+
* (non-elevated) account, refreshing before the lapse so the socket is never
|
|
2804
|
+
* dropped and never re-handshaken: without the frame the socket is closed
|
|
2805
|
+
* past the original expiry, with it `close` never fires at all.
|
|
2806
|
+
*
|
|
2807
|
+
* Returns whether a frame actually went out. `false` means there was nobody
|
|
2808
|
+
* to send it through — harmless, because the next handshake carries the new
|
|
2809
|
+
* token anyway (see the provider's token closure).
|
|
2810
|
+
*/
|
|
2811
|
+
refreshAuth(token: string): boolean;
|
|
2656
2812
|
onClose({
|
|
2657
2813
|
event
|
|
2658
2814
|
}: onCloseParameters): void;
|
|
@@ -2979,6 +3135,30 @@ interface CompleteAbracadabraBaseProviderConfiguration {
|
|
|
2979
3135
|
* socket connection, or ensure that the Provider receives messages before running into `AbracadabraWS.messageReconnectTimeout`.
|
|
2980
3136
|
*/
|
|
2981
3137
|
awareness: Awareness | null;
|
|
3138
|
+
/**
|
|
3139
|
+
* Defer building the Awareness instance until something actually reads
|
|
3140
|
+
* `provider.awareness`.
|
|
3141
|
+
*
|
|
3142
|
+
* Every Awareness costs a 3 s `setInterval` for as long as it lives, plus a
|
|
3143
|
+
* wire frame every 15 s to renew its clock — forever, whether or not a human
|
|
3144
|
+
* is looking at the document. That is the right price for a document someone
|
|
3145
|
+
* has open, and pure waste for the dozens a background indexer or a search
|
|
3146
|
+
* sweep opens and closes. Measured: 10 loaded children = 11 instances = 66
|
|
3147
|
+
* heartbeat callbacks per 20 s idle.
|
|
3148
|
+
*
|
|
3149
|
+
* When this is set, the instance is built on first access instead of in the
|
|
3150
|
+
* constructor, and building it also publishes local state and queries peers,
|
|
3151
|
+
* so a document that later gains an editor gets symmetric presence exactly as
|
|
3152
|
+
* if it had been eager all along. Consumers see no difference: the public
|
|
3153
|
+
* `awareness` accessor always returns a usable instance.
|
|
3154
|
+
*
|
|
3155
|
+
* `AbracadabraProvider.loadChild` sets this. Top-level providers stay eager,
|
|
3156
|
+
* so every socket keeps at least one heartbeat and the liveness assumption in
|
|
3157
|
+
* `AbracadabraWS.checkConnection` is untouched.
|
|
3158
|
+
*
|
|
3159
|
+
* Ignored when an explicit `awareness` (including `null`) is supplied.
|
|
3160
|
+
*/
|
|
3161
|
+
lazyAwareness?: boolean;
|
|
2982
3162
|
/**
|
|
2983
3163
|
* A token that's sent to the backend for authentication purposes.
|
|
2984
3164
|
*/
|
|
@@ -3106,7 +3286,42 @@ declare class AbracadabraBaseProvider extends EventEmitter {
|
|
|
3106
3286
|
setConfiguration(configuration?: Partial<AbracadabraBaseProviderConfiguration>): void;
|
|
3107
3287
|
get document(): Y.Doc;
|
|
3108
3288
|
get isAttached(): boolean;
|
|
3289
|
+
/** True while an Awareness instance is owed but has not been built yet. */
|
|
3290
|
+
private _awarenessDeferred;
|
|
3291
|
+
/** True when the caller passed `awareness: null` and meant it. */
|
|
3292
|
+
private _awarenessExplicitlyNull;
|
|
3293
|
+
/**
|
|
3294
|
+
* The presence instance for this document, built on demand.
|
|
3295
|
+
*
|
|
3296
|
+
* Reading this materializes a deferred instance (see `lazyAwareness`), which
|
|
3297
|
+
* is why every consumer — TipTap's CollaborationCaret, presence UI, app code
|
|
3298
|
+
* — keeps working unchanged: touching `.awareness` is itself the signal that
|
|
3299
|
+
* this document needs presence.
|
|
3300
|
+
*
|
|
3301
|
+
* Provider INTERNALS must use `peekAwareness()` instead, or the lazy path
|
|
3302
|
+
* materializes everything it was meant to avoid.
|
|
3303
|
+
*/
|
|
3109
3304
|
get awareness(): Awareness | null;
|
|
3305
|
+
/**
|
|
3306
|
+
* The Awareness instance if one exists, without ever creating one.
|
|
3307
|
+
*
|
|
3308
|
+
* @internal Used by provider internals and `MessageReceiver`. A deferred
|
|
3309
|
+
* document has no local presence, so there is nothing for an inbound
|
|
3310
|
+
* awareness frame to be applied to and nothing to answer a peer's query with
|
|
3311
|
+
* — and materializing on a peer's frame would hand every idle background
|
|
3312
|
+
* document a heartbeat as soon as anyone else joined the space.
|
|
3313
|
+
*/
|
|
3314
|
+
peekAwareness(): Awareness | null;
|
|
3315
|
+
/**
|
|
3316
|
+
* Build the deferred Awareness instance and bring it fully up to date:
|
|
3317
|
+
* seeded, wired, published, and caught up with the peers already present.
|
|
3318
|
+
*/
|
|
3319
|
+
private _materializeAwareness;
|
|
3320
|
+
/**
|
|
3321
|
+
* Seed and wire an Awareness instance. Shared by the eager constructor path
|
|
3322
|
+
* and the lazy materialization path so the two cannot drift.
|
|
3323
|
+
*/
|
|
3324
|
+
private _initAwareness;
|
|
3110
3325
|
get hasUnsyncedChanges(): boolean;
|
|
3111
3326
|
private resetUnsyncedChanges;
|
|
3112
3327
|
incrementUnsyncedChanges(): void;
|
|
@@ -6269,4 +6484,207 @@ declare function collectMediaFileBlocks(root: Y.XmlFragment | Y.XmlElement): Med
|
|
|
6269
6484
|
*/
|
|
6270
6485
|
declare function reconcileDocCover(treeMap: Y.Map<unknown>, docId: string, fragment: Y.XmlFragment | Y.XmlElement): void;
|
|
6271
6486
|
//#endregion
|
|
6272
|
-
|
|
6487
|
+
//#region packages/provider/src/PerfCounters.d.ts
|
|
6488
|
+
/**
|
|
6489
|
+
* PerfCounters — opt-in resource accounting for the provider.
|
|
6490
|
+
*
|
|
6491
|
+
* WHY THIS EXISTS
|
|
6492
|
+
*
|
|
6493
|
+
* The provider's expensive behaviour is idle behaviour: timers that fire and
|
|
6494
|
+
* frames that go out when nobody is doing anything. That cost is invisible to
|
|
6495
|
+
* ordinary profiling of a busy app and invisible to the test suite, so it grew
|
|
6496
|
+
* unnoticed. This module makes it countable, so a budget can be asserted
|
|
6497
|
+
* instead of argued about.
|
|
6498
|
+
*
|
|
6499
|
+
* DESIGN CONSTRAINTS
|
|
6500
|
+
*
|
|
6501
|
+
* 1. **Inert until installed.** Importing this module patches nothing and
|
|
6502
|
+
* costs nothing. Only `installPerfCounters()` wraps anything, and
|
|
6503
|
+
* `uninstall()` restores the exact original references. Nothing in the
|
|
6504
|
+
* production path ever calls in here.
|
|
6505
|
+
*
|
|
6506
|
+
* 2. **Attribute by stack, don't instrument by hand.** Timers are the unit of
|
|
6507
|
+
* battery cost, and the ones that matter are created inside dependencies
|
|
6508
|
+
* (`y-protocols`' Awareness starts a 3 s interval per instance). Recording
|
|
6509
|
+
* a creation stack for every timer means we count the real cost wherever it
|
|
6510
|
+
* comes from — including timers added later by code that never heard of
|
|
6511
|
+
* this module — instead of sprinkling counter calls through the provider
|
|
6512
|
+
* and hoping they stay in sync with reality.
|
|
6513
|
+
*
|
|
6514
|
+
* 3. **No global socket patching.** In Node the provider runs on the `ws`
|
|
6515
|
+
* package, not `globalThis.WebSocket`, so a global patch would silently
|
|
6516
|
+
* measure nothing. `instrumentSocket()` takes an explicit AbracadabraWS
|
|
6517
|
+
* instead — the same approach `_perf_client.mts` already uses.
|
|
6518
|
+
*
|
|
6519
|
+
* Not covered here on purpose: `Y.encodeStateAsUpdate` cost. It cannot be
|
|
6520
|
+
* patched through an ES import binding, and the perf harness measures it
|
|
6521
|
+
* directly by calling it, which is more accurate anyway.
|
|
6522
|
+
*/
|
|
6523
|
+
/** One group of timers sharing an origin and a delay. */
|
|
6524
|
+
interface TimerGroup {
|
|
6525
|
+
/** Best-effort source attribution, e.g. "y-protocols/awareness.js". */
|
|
6526
|
+
origin: string;
|
|
6527
|
+
/** The delay the timer was created with, in ms. */
|
|
6528
|
+
delayMs: number;
|
|
6529
|
+
/** Timers of this shape created since the last reset. */
|
|
6530
|
+
created: number;
|
|
6531
|
+
/** Timers of this shape still live right now. */
|
|
6532
|
+
live: number;
|
|
6533
|
+
/** Callback invocations of this shape since the last reset. */
|
|
6534
|
+
fired: number;
|
|
6535
|
+
}
|
|
6536
|
+
interface PerfSnapshot {
|
|
6537
|
+
/** Wall-clock ms since the last `reset()` (or install). */
|
|
6538
|
+
elapsedMs: number;
|
|
6539
|
+
timers: {
|
|
6540
|
+
intervalsCreated: number;
|
|
6541
|
+
intervalsLive: number;
|
|
6542
|
+
timeoutsCreated: number;
|
|
6543
|
+
timeoutsLive: number; /** Every callback invocation from a wrapped timer. */
|
|
6544
|
+
fired: number; /** Fired per second over the elapsed window — the battery number. */
|
|
6545
|
+
firedPerSecond: number; /** Grouped by origin + delay, largest `live` first. */
|
|
6546
|
+
groups: TimerGroup[];
|
|
6547
|
+
};
|
|
6548
|
+
animationFrames: {
|
|
6549
|
+
requested: number;
|
|
6550
|
+
fired: number;
|
|
6551
|
+
};
|
|
6552
|
+
awareness: {
|
|
6553
|
+
/**
|
|
6554
|
+
* Live `y-protocols` Awareness instances, derived from their
|
|
6555
|
+
* characteristic heartbeat interval (outdatedTimeout / 10 = 3000 ms
|
|
6556
|
+
* created inside awareness.js). This is the count the whole idle-cost
|
|
6557
|
+
* ledger hinges on.
|
|
6558
|
+
*/
|
|
6559
|
+
liveInstances: number; /** Heartbeat callback invocations since the last reset. */
|
|
6560
|
+
heartbeatFires: number;
|
|
6561
|
+
};
|
|
6562
|
+
indexedDb: {
|
|
6563
|
+
transactions: number; /** Transactions by object-store name. */
|
|
6564
|
+
byStore: Record<string, number>;
|
|
6565
|
+
databasesOpened: number;
|
|
6566
|
+
};
|
|
6567
|
+
sockets: {
|
|
6568
|
+
framesSent: number;
|
|
6569
|
+
bytesSent: number;
|
|
6570
|
+
framesReceived: number;
|
|
6571
|
+
bytesReceived: number; /** Frames sent grouped by the wire message type byte, when readable. */
|
|
6572
|
+
sentByType: Record<string, number>;
|
|
6573
|
+
};
|
|
6574
|
+
}
|
|
6575
|
+
/** An AbracadabraWS-shaped object. Kept structural to avoid an import cycle. */
|
|
6576
|
+
interface SocketLike {
|
|
6577
|
+
send(message: unknown): void;
|
|
6578
|
+
on(event: string, handler: (...args: any[]) => void): unknown;
|
|
6579
|
+
off(event: string, handler: (...args: any[]) => void): unknown;
|
|
6580
|
+
}
|
|
6581
|
+
/**
|
|
6582
|
+
* Begin counting. Idempotent — a second call is a no-op rather than a
|
|
6583
|
+
* double-wrap, which would double every number and be very hard to notice.
|
|
6584
|
+
*/
|
|
6585
|
+
declare function installPerfCounters(): void;
|
|
6586
|
+
/** Restore every patched global. Safe to call when not installed. */
|
|
6587
|
+
declare function uninstall(): void;
|
|
6588
|
+
/** Zero every counter. Live-timer bookkeeping is preserved — it is a census. */
|
|
6589
|
+
declare function reset(): void;
|
|
6590
|
+
/**
|
|
6591
|
+
* Count frames on one AbracadabraWS. Returns a restore function; the restore is
|
|
6592
|
+
* also run by `uninstall()`.
|
|
6593
|
+
*
|
|
6594
|
+
* Wrapping the instance (rather than a global) is deliberate: in Node the
|
|
6595
|
+
* provider runs on the `ws` package, so patching `globalThis.WebSocket` would
|
|
6596
|
+
* silently measure nothing at all.
|
|
6597
|
+
*/
|
|
6598
|
+
declare function instrumentSocket(socket: SocketLike): () => void;
|
|
6599
|
+
declare function snapshot(): PerfSnapshot;
|
|
6600
|
+
/** Field-by-field difference of two snapshots, for before/after comparisons. */
|
|
6601
|
+
declare function diff(before: PerfSnapshot, after: PerfSnapshot): {
|
|
6602
|
+
elapsedMs: number;
|
|
6603
|
+
timersFired: number;
|
|
6604
|
+
intervalsCreated: number;
|
|
6605
|
+
intervalsLive: number;
|
|
6606
|
+
awarenessLive: number;
|
|
6607
|
+
heartbeatFires: number;
|
|
6608
|
+
framesSent: number;
|
|
6609
|
+
bytesSent: number;
|
|
6610
|
+
idbTransactions: number;
|
|
6611
|
+
};
|
|
6612
|
+
/** Whether counting is currently active. */
|
|
6613
|
+
declare function isInstalled(): boolean;
|
|
6614
|
+
//#endregion
|
|
6615
|
+
//#region packages/provider/src/LifecycleGate.d.ts
|
|
6616
|
+
/**
|
|
6617
|
+
* LifecycleGate — one place that knows whether the app is actually being looked at.
|
|
6618
|
+
*
|
|
6619
|
+
* Nothing in the provider used to ask. A grep for `visibilitychange` across the
|
|
6620
|
+
* package returned exactly one hit, in `TokenManager`, and it used the signal to
|
|
6621
|
+
* do MORE work on resume — nothing anywhere used it to do less. So a backgrounded
|
|
6622
|
+
* PWA kept its socket liveness checker running, kept re-running a full-tree
|
|
6623
|
+
* background sync every five minutes, and kept broadcasting presence, at exactly
|
|
6624
|
+
* the same rate as a phone held open in front of a person.
|
|
6625
|
+
*
|
|
6626
|
+
* Two design points that matter:
|
|
6627
|
+
*
|
|
6628
|
+
* 1. **The visibility source is injectable.** Hidden-state behaviour is the part
|
|
6629
|
+
* of this that most needs testing and is the hardest to reach from a test
|
|
6630
|
+
* runner, so `setSource()` lets a test drive it deterministically instead of
|
|
6631
|
+
* the tests having to fake a DOM.
|
|
6632
|
+
*
|
|
6633
|
+
* 2. **Hiding is debounced, revealing is not.** Alt-tabbing to look something up
|
|
6634
|
+
* is not "the user has gone away", and treating it as such would make presence
|
|
6635
|
+
* avatars flicker across everyone else's screen every time someone checked
|
|
6636
|
+
* their mail. Coming back is always immediate — a user who returns must never
|
|
6637
|
+
* wait on a timer to see live data.
|
|
6638
|
+
*
|
|
6639
|
+
* In Node, and anywhere else without a `document`, this is inert and reports
|
|
6640
|
+
* visible forever.
|
|
6641
|
+
*/
|
|
6642
|
+
type VisibilityState = "visible" | "hidden";
|
|
6643
|
+
/** Something that can report visibility and notify on change. */
|
|
6644
|
+
interface VisibilitySource {
|
|
6645
|
+
/** Current state at the moment of the call. */
|
|
6646
|
+
get(): VisibilityState;
|
|
6647
|
+
/** Subscribe to changes. Returns an unsubscribe function. */
|
|
6648
|
+
subscribe(onChange: () => void): () => void;
|
|
6649
|
+
}
|
|
6650
|
+
/** How long the app must stay hidden before we act on it. */
|
|
6651
|
+
declare const HIDE_GRACE_MS = 10000;
|
|
6652
|
+
declare class LifecycleGate {
|
|
6653
|
+
private readonly graceMs;
|
|
6654
|
+
private source;
|
|
6655
|
+
private unsubscribe;
|
|
6656
|
+
private hideTimer;
|
|
6657
|
+
private _backgrounded;
|
|
6658
|
+
private listeners;
|
|
6659
|
+
constructor(source?: VisibilitySource, graceMs?: number);
|
|
6660
|
+
/**
|
|
6661
|
+
* True when the app has been hidden for longer than the grace period.
|
|
6662
|
+
*
|
|
6663
|
+
* Deliberately NOT the same as `document.hidden`: a tab that was hidden two
|
|
6664
|
+
* seconds ago is still, for our purposes, in use.
|
|
6665
|
+
*/
|
|
6666
|
+
get backgrounded(): boolean;
|
|
6667
|
+
/** Subscribe to background/foreground transitions. Returns an unsubscribe fn. */
|
|
6668
|
+
onChange(listener: (backgrounded: boolean) => void): () => void;
|
|
6669
|
+
/** Swap the visibility source. Used by tests to drive state deterministically. */
|
|
6670
|
+
setSource(source: VisibilitySource): void;
|
|
6671
|
+
private onVisibilityChange;
|
|
6672
|
+
private setBackgrounded;
|
|
6673
|
+
destroy(): void;
|
|
6674
|
+
}
|
|
6675
|
+
declare function getLifecycleGate(): LifecycleGate;
|
|
6676
|
+
/**
|
|
6677
|
+
* Replace the shared gate. Tests use this to install a controllable source;
|
|
6678
|
+
* passing `null` restores the default browser-backed gate on next access.
|
|
6679
|
+
*/
|
|
6680
|
+
declare function setLifecycleGate(gate: LifecycleGate | null): void;
|
|
6681
|
+
/** A visibility source a test (or an embedder) can drive by hand. */
|
|
6682
|
+
declare class ManualVisibilitySource implements VisibilitySource {
|
|
6683
|
+
private state;
|
|
6684
|
+
private listeners;
|
|
6685
|
+
get(): VisibilityState;
|
|
6686
|
+
subscribe(onChange: () => void): () => void;
|
|
6687
|
+
set(state: VisibilityState): void;
|
|
6688
|
+
}
|
|
6689
|
+
//#endregion
|
|
6690
|
+
export { AbracadabraBaseProvider, AbracadabraBaseProviderConfiguration, AbracadabraClient, AbracadabraClientConfig, AbracadabraOutgoingMessageArguments, AbracadabraProvider, AbracadabraProviderConfiguration, AbracadabraWS, AbracadabraWSConfiguration, AbracadabraWebRTC, type AbracadabraWebRTCConfiguration, AbracadabraWebSocketConn, AdminConfigField, AdminConfigOriginKind, AuditLogEntry, AuditQueryOpts, AuditVerifyResult, AuthFailureContext, AuthFailureReason, AuthMessageType, AuthorizedScope, AwarenessError, BackgroundSyncManager, type BackgroundSyncManagerOptions, BackgroundSyncPersistence, BroadcastChannelSync, CHANNEL_NAMES, ChannelKeyResolver, type ChatChannel, ChatClient, type ChatClientTransport, type MarkReadInput as ChatMarkReadInput, type ChatMessage, type ChatReadCursor, type ChatReadReceipt, type ChatTypingEvent, type ChildrenPage, CloseEvent, CompleteAbracadabraBaseProviderConfiguration, CompleteAbracadabraWSConfiguration, CompleteHocuspocusProviderConfiguration, CompleteHocuspocusProviderWebsocketConfiguration, type ConnectPolicyResult, ConnectionTimeout, Constructable, ConstructableOutgoingMessage, ContentManager, type CreateNotificationInput, CryptoIdentity, CryptoIdentityKeystore, DEFAULT_FILE_CHUNK_SIZE, DEFAULT_ICE_SERVERS, DataChannelRouter, type DeleteMessageInput, DevicePairingChannel, type DevicePairingConfig, DeviceRegistrationService, type DeviceServerStatus, type DeviceSessionRecord, type DeviceSessionStorage, type DeviceTier, DocBacklink, type DocEncryptionInfo, DocKeyManager, DocSearchHit, type DocSyncState, type DocSyncStatus, type DocumentBlock, DocumentCache, type DocumentCacheOptions, type DocumentContent, DocumentManager, type DocumentManagerConfig, DocumentMeta, type DocumentMetaInfo, type DocumentMetaWire, E2EAbracadabraProvider, E2EEChannel, type E2EEIdentity, E2EOfflineStore, type EditMessageInput, EffectivePermissionEntry, EffectivePermissionsResponse, EffectiveRole, EncryptedChatClient, EncryptedYMap, EncryptedYText, EnvSnapshotExtension, EnvSnapshotItem, EnvSnapshotResponse, type FetchInboxInput, type FetchNotificationsInput, FileBlobStore, FileTransferChannel, FileTransferHandle, type FileTransferMeta, type FileTransferStatus, type FoldedMessage, Forbidden, GEO_TYPE_META_SCHEMAS, type GetChatHistoryInput, HIDE_GRACE_MS, HealthStatus, HocusPocusWebSocket, HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration, HocuspocusWebSocket, type IdentityDeviceEntry, type IdentityDocConfiguration, IdentityDocProvider, type IdentityProfile, type IdentityServerEntry, type IdentitySpaceEntry, type InboxEntry, type MarkReadInput$1 as InboxMarkReadInput, InviteRow, KEY_EXCHANGE_CHANNEL, type KeyAuthClient, Kind, LifecycleGate, type LoadKeyFileOptions, LocalStorageDeviceSessionStorage, type LoginOrRegisterOptions, ManualSignaling, type ManualSignalingBlob, ManualVisibilitySource, type MediaFileBlock, type MessageRecord, MessageTooBig, MessageType, MetaFieldType, MetaManager, MetaValidationError, type NodeKeypair, type NotificationReadUpdate, type NotificationRecord, NotificationsClient, OfflineStore, OutgoingMessageArguments, OutgoingMessageInterface, PAGE_TYPES, PageMeta, PageTypeInfo, PageTypeMetaField, type PairingRequest, type PairingResult, PeerConnection, type PeerInfo, type PeerState, PendingSubdoc, type PerfSnapshot, PermissionEntry, type PolicyAuthClient, PublicKeyInfo, QUERY_PREFIX, QueryClient, QueryError, type QueryFrame, type QueryKind, type QuerySpec, type QuerySubscriptionHandle, type QuerySubscriptionHandlers, type QueryTransport, RPC_PREFIX, ReadyzStatus, ResetConnection, type RpcCallHandle, type RpcCallOptions, RpcClient, RpcError, type RpcErrorCode, type RpcErrorPayload, type RpcFrame, type RpcHandler, type RpcHandlerContext, type RpcKind, type RpcTarget, type RpcTransport, SERVER_ROOT_ID, type SchemaDocTypeName, type SchemaMetaOf, type SchemaRegistryLike, type SchemaValidatorLike, SearchIndex, SearchResult, type SendChatMessageInput, type SendMessageInput, type SendMessageResult, ServerInfo, type ServerProfile, type ServerRegistry, ServerResetOutcome, type SignalingIncoming, type SignalingOutgoing, SignalingSocket, SnapshotCreateResult, SnapshotData, SnapshotFileEntry, SnapshotForkResult, SnapshotMeta, SnapshotRestoreResult, StatesArray, StreamTokenInfo, SubdocMessage, SubdocRegisteredEvent, TYPE_ALIASES, ThumbnailOptions, type TimerGroup, TokenManager, type TokenManagerOptions, TreeEntry, TreeManager, TreeNode, TreeSearchResult, TypedDocTypeMismatchError, type TypedDocsClient, type TypedTreeEntry, Unauthorized, UploadInfo, UploadMeta, UploadQueueEntry, UploadQueueStatus, UserMetaField, UserProfile, type VisibilitySource, type VisibilityState, WebSocketStatus, WriteRejectionKind, WsReadyStates, YjsDataChannel, addServer, attachUpdatedAtObserver, awarenessStatesToArray, wordlist as bip39Wordlist, buildBlockquoteElement, buildBlocksFromMarkdown, buildBulletListElement, buildCodeBlockElement, buildHeadingElement, buildHorizontalRuleElement, buildOrderedListElement, buildParagraphElement, buildTaskListElement, collectMediaFileBlocks, decryptChatContent, decryptField, defaultKeyFileFor, deriveDmDocId, deriveIdentityDocId, deriveSeedWrappingKey, deterministicKeypair, dropCachesIfServerReplaced, encryptChatContent, encryptField, filenameToLabel, foldRecords, forgetServerIdentity, generateMnemonic, getLifecycleGate, installPerfCounters, isEncryptedContent, isPlaceholderLabel, isServerScopedStore, loadOrCreateKeyFile, loadServerRegistry, loginOrRegisterWithKey, loginOrRegisterWithPolicy, makeChallengeSigner, makeEncryptedYMap, makeEncryptedYText, makeEntryMap, migrateLegacyDefault, mnemonicToEd25519Seed, mnemonicToKeyPair, normalizeRootId, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onCompactedParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onReconnectedParameters, onServerErrorParameters, onStatelessParameters, onStatusParameters, onSubdocLoadedParameters, onSubdocRegisteredParameters, onSyncedParameters, onUnsyncedChangesParameters, onWriteRejectedParameters, openSyncedProvider, parseFrontmatter, patchEntry, isInstalled as perfCountersInstalled, diff as perfDiff, instrumentSocket as perfInstrumentSocket, snapshot as perfSnapshot, pickEntrySpace, populateYDocFromMarkdown, readAuthMessage, readBlocksFromFragment, readEntries, reconcileDocCover, recordFromYAny, removeServer, reset as resetPerfCounters, resolvePageType, resolveServer, saveServerRegistry, serverRegistryPath, setDefault, setLifecycleGate, signChallengeWithSeed, toPlain, uninstall as uninstallPerfCounters, unwrapSeed, validateMnemonic, waitForSync, withTimeout, wrapSeed, writeAuthenticated, writeAuthentication, writePermissionDenied, writeTokenSyncRequest, yjsToMarkdown };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/dabra",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.96.0",
|
|
4
4
|
"description": "abracadabra provider",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"abracadabra",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"yjs": "^13.6.8"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@abraca/schema": "2.
|
|
38
|
+
"@abraca/schema": "2.96.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"test": "node --no-warnings --conditions=source --experimental-transform-types --test 'tests/*.test.ts'"
|