@abraca/dabra 2.95.0 → 2.97.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
@@ -1,125 +1,13 @@
1
1
  import { Event, MessageEvent } from "ws";
2
+ import * as y_protocols_awareness0 from "y-protocols/awareness";
3
+ import { Awareness } from "y-protocols/awareness";
2
4
  import * as Y from "yjs";
5
+ import * as lib0_encoding0 from "lib0/encoding";
6
+ import { Encoder } from "lib0/encoding";
7
+ import * as decoding from "lib0/decoding";
8
+ import { Decoder } from "lib0/decoding";
9
+ import { wordlist } from "@scure/bip39/wordlists/english.js";
3
10
 
4
- //#region node_modules/lib0/observable.d.ts
5
- /**
6
- * Handles named events.
7
- *
8
- * @deprecated
9
- * @template N
10
- */
11
- declare class Observable<N> {
12
- /**
13
- * Some desc.
14
- * @type {Map<N, any>}
15
- */
16
- _observers: Map<N, any>;
17
- /**
18
- * @param {N} name
19
- * @param {function} f
20
- */
21
- on(name: N, f: Function): void;
22
- /**
23
- * @param {N} name
24
- * @param {function} f
25
- */
26
- once(name: N, f: Function): void;
27
- /**
28
- * @param {N} name
29
- * @param {function} f
30
- */
31
- off(name: N, f: Function): void;
32
- /**
33
- * Emit a named event. All registered event listeners that listen to the
34
- * specified name will receive the event.
35
- *
36
- * @todo This should catch exceptions
37
- *
38
- * @param {N} name The event name.
39
- * @param {Array<any>} args The arguments that are applied to the event listener.
40
- */
41
- emit(name: N, args: Array<any>): void;
42
- destroy(): void;
43
- }
44
- //#endregion
45
- //#region node_modules/y-protocols/awareness.d.ts
46
- /**
47
- * @typedef {Object} MetaClientState
48
- * @property {number} MetaClientState.clock
49
- * @property {number} MetaClientState.lastUpdated unix timestamp
50
- */
51
- /**
52
- * The Awareness class implements a simple shared state protocol that can be used for non-persistent data like awareness information
53
- * (cursor, username, status, ..). Each client can update its own local state and listen to state changes of
54
- * remote clients. Every client may set a state of a remote peer to `null` to mark the client as offline.
55
- *
56
- * Each client is identified by a unique client id (something we borrow from `doc.clientID`). A client can override
57
- * its own state by propagating a message with an increasing timestamp (`clock`). If such a message is received, it is
58
- * applied if the known state of that client is older than the new state (`clock < newClock`). If a client thinks that
59
- * a remote client is offline, it may propagate a message with
60
- * `{ clock: currentClientClock, state: null, client: remoteClient }`. If such a
61
- * message is received, and the known clock of that client equals the received clock, it will override the state with `null`.
62
- *
63
- * Before a client disconnects, it should propagate a `null` state with an updated clock.
64
- *
65
- * Awareness states must be updated every 30 seconds. Otherwise the Awareness instance will delete the client state.
66
- *
67
- * @extends {Observable<string>}
68
- */
69
- declare class Awareness extends Observable<string> {
70
- /**
71
- * @param {Y.Doc} doc
72
- */
73
- constructor(doc: Y.Doc);
74
- doc: Y.Doc;
75
- /**
76
- * @type {number}
77
- */
78
- clientID: number;
79
- /**
80
- * Maps from client id to client state
81
- * @type {Map<number, Object<string, any>>}
82
- */
83
- states: Map<number, {
84
- [x: string]: any;
85
- }>;
86
- /**
87
- * @type {Map<number, MetaClientState>}
88
- */
89
- meta: Map<number, MetaClientState>;
90
- _checkInterval: any;
91
- /**
92
- * @return {Object<string,any>|null}
93
- */
94
- getLocalState(): {
95
- [x: string]: any;
96
- } | null;
97
- /**
98
- * @param {Object<string,any>|null} state
99
- */
100
- setLocalState(state: {
101
- [x: string]: any;
102
- } | null): void;
103
- /**
104
- * @param {string} field
105
- * @param {any} value
106
- */
107
- setLocalStateField(field: string, value: any): void;
108
- /**
109
- * @return {Map<number,Object<string,any>>}
110
- */
111
- getStates(): Map<number, {
112
- [x: string]: any;
113
- }>;
114
- }
115
- type MetaClientState = {
116
- clock: number;
117
- /**
118
- * unix timestamp
119
- */
120
- lastUpdated: number;
121
- };
122
- //#endregion
123
11
  //#region packages/provider/src/EventEmitter.d.ts
124
12
  declare class EventEmitter {
125
13
  callbacks: {
@@ -169,7 +57,35 @@ declare class OfflineStore {
169
57
  private dbPromise;
170
58
  private _destroyed;
171
59
  private getDb;
60
+ /** Updates buffered for the next batched write. */
61
+ private writeBuffer;
62
+ /** Callers of `persistUpdate` awaiting the batch that carries their update. */
63
+ private writeWaiters;
64
+ private flushTimer;
65
+ /**
66
+ * Queue a local update for persistence.
67
+ *
68
+ * The returned promise settles when the update has actually been committed,
69
+ * not when it was queued — so `await persistUpdate(u)` still means "on disk",
70
+ * exactly as it did when every call opened its own transaction.
71
+ */
172
72
  persistUpdate(update: Uint8Array): Promise<void>;
73
+ /**
74
+ * Commit every buffered update as ONE transaction.
75
+ *
76
+ * Safe to call at any time, including with an empty buffer — every read path
77
+ * calls it first so a caller can never observe a store that is missing writes
78
+ * still sitting in memory.
79
+ */
80
+ flushWrites(): Promise<void>;
81
+ /**
82
+ * Issue the buffered writes synchronously, without awaiting them.
83
+ *
84
+ * For teardown paths that cannot await: `pagehide` (the page may not survive
85
+ * a microtask) and `destroy()`. IndexedDB will not close a connection until
86
+ * its running transactions finish, so writes issued here still land.
87
+ */
88
+ flushWritesSync(): void;
173
89
  getPendingUpdates(): Promise<Uint8Array[]>;
174
90
  clearPendingUpdates(): Promise<void>;
175
91
  /**
@@ -1751,6 +1667,16 @@ declare class AbracadabraProvider extends AbracadabraBaseProvider {
1751
1667
  private evictLRU;
1752
1668
  /** Return all currently-loaded child providers. */
1753
1669
  get children(): Map<string, AbracadabraProvider>;
1670
+ /**
1671
+ * Land buffered offline writes before the page goes away.
1672
+ *
1673
+ * `OfflineStore` coalesces local updates into one transaction per ~150 ms
1674
+ * window (see WRITE_COALESCE_MS). That window is the only moment an edit
1675
+ * exists in memory but not on disk, and a closing tab is exactly when it
1676
+ * would be lost — so pagehide flushes it synchronously. `super.pageHide()`
1677
+ * still clears our awareness state for peers.
1678
+ */
1679
+ pageHide(): void;
1754
1680
  /**
1755
1681
  * Override to persist every local update to IndexedDB before sending it
1756
1682
  * over the wire, ensuring no work is lost during connection outages.
@@ -1788,19 +1714,6 @@ declare class AbracadabraProvider extends AbracadabraBaseProvider {
1788
1714
  destroy(): void;
1789
1715
  }
1790
1716
  //#endregion
1791
- //#region node_modules/lib0/encoding.d.ts
1792
- /**
1793
- * A BinaryEncoder handles the encoding to an Uint8Array.
1794
- */
1795
- declare class Encoder {
1796
- cpos: number;
1797
- cbuf: Uint8Array<ArrayBuffer>;
1798
- /**
1799
- * @type {Array<Uint8Array>}
1800
- */
1801
- bufs: Array<Uint8Array>;
1802
- }
1803
- //#endregion
1804
1717
  //#region packages/provider/src/CloseEvents.d.ts
1805
1718
  interface CloseEvent {
1806
1719
  code: number;
@@ -1832,30 +1745,6 @@ declare const Forbidden: CloseEvent;
1832
1745
  */
1833
1746
  declare const ConnectionTimeout: CloseEvent;
1834
1747
  //#endregion
1835
- //#region node_modules/lib0/decoding.d.ts
1836
- /**
1837
- * A Decoder handles the decoding of an Uint8Array.
1838
- * @template {ArrayBufferLike} [Buf=ArrayBufferLike]
1839
- */
1840
- declare class Decoder<Buf extends ArrayBufferLike = ArrayBufferLike> {
1841
- /**
1842
- * @param {Uint8Array<Buf>} uint8Array Binary data to decode
1843
- */
1844
- constructor(uint8Array: Uint8Array<Buf>);
1845
- /**
1846
- * Decoding target.
1847
- *
1848
- * @type {Uint8Array<Buf>}
1849
- */
1850
- arr: Uint8Array<Buf>;
1851
- /**
1852
- * Current decoding position.
1853
- *
1854
- * @type {number}
1855
- */
1856
- pos: number;
1857
- }
1858
- //#endregion
1859
1748
  //#region packages/provider/src/IncomingMessage.d.ts
1860
1749
  declare class IncomingMessage {
1861
1750
  data: any;
@@ -1885,42 +1774,42 @@ declare class OutgoingMessage implements OutgoingMessageInterface {
1885
1774
  declare class AuthenticationMessage extends OutgoingMessage {
1886
1775
  type: MessageType;
1887
1776
  description: string;
1888
- get(args: Partial<OutgoingMessageArguments>): Encoder;
1777
+ get(args: Partial<OutgoingMessageArguments>): lib0_encoding0.Encoder;
1889
1778
  }
1890
1779
  //#endregion
1891
1780
  //#region packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts
1892
1781
  declare class AwarenessMessage extends OutgoingMessage {
1893
1782
  type: MessageType;
1894
1783
  description: string;
1895
- get(args: Partial<OutgoingMessageArguments>): Encoder;
1784
+ get(args: Partial<OutgoingMessageArguments>): lib0_encoding0.Encoder;
1896
1785
  }
1897
1786
  //#endregion
1898
1787
  //#region packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts
1899
1788
  declare class QueryAwarenessMessage extends OutgoingMessage {
1900
1789
  type: MessageType;
1901
1790
  description: string;
1902
- get(args: Partial<OutgoingMessageArguments>): Encoder;
1791
+ get(args: Partial<OutgoingMessageArguments>): lib0_encoding0.Encoder;
1903
1792
  }
1904
1793
  //#endregion
1905
1794
  //#region packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts
1906
1795
  declare class SyncStepOneMessage extends OutgoingMessage {
1907
1796
  type: MessageType;
1908
1797
  description: string;
1909
- get(args: Partial<OutgoingMessageArguments>): Encoder;
1798
+ get(args: Partial<OutgoingMessageArguments>): lib0_encoding0.Encoder;
1910
1799
  }
1911
1800
  //#endregion
1912
1801
  //#region packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts
1913
1802
  declare class SyncStepTwoMessage extends OutgoingMessage {
1914
1803
  type: MessageType;
1915
1804
  description: string;
1916
- get(args: Partial<OutgoingMessageArguments>): Encoder;
1805
+ get(args: Partial<OutgoingMessageArguments>): lib0_encoding0.Encoder;
1917
1806
  }
1918
1807
  //#endregion
1919
1808
  //#region packages/provider/src/OutgoingMessages/UpdateMessage.d.ts
1920
1809
  declare class UpdateMessage extends OutgoingMessage {
1921
1810
  type: MessageType;
1922
1811
  description: string;
1923
- get(args: Partial<OutgoingMessageArguments>): Encoder;
1812
+ get(args: Partial<OutgoingMessageArguments>): lib0_encoding0.Encoder;
1924
1813
  }
1925
1814
  //#endregion
1926
1815
  //#region packages/provider/src/types.d.ts
@@ -2696,6 +2585,7 @@ declare class AbracadabraWS extends EventEmitter {
2696
2585
  } | null;
2697
2586
  private onlineListener;
2698
2587
  private offlineListener;
2588
+ unsubscribeLifecycle: (() => void) | null;
2699
2589
  constructor(configuration: AbracadabraWSConfiguration);
2700
2590
  /**
2701
2591
  * Whether the device currently believes it has network connectivity.
@@ -3096,6 +2986,30 @@ interface CompleteAbracadabraBaseProviderConfiguration {
3096
2986
  * socket connection, or ensure that the Provider receives messages before running into `AbracadabraWS.messageReconnectTimeout`.
3097
2987
  */
3098
2988
  awareness: Awareness | null;
2989
+ /**
2990
+ * Defer building the Awareness instance until something actually reads
2991
+ * `provider.awareness`.
2992
+ *
2993
+ * Every Awareness costs a 3 s `setInterval` for as long as it lives, plus a
2994
+ * wire frame every 15 s to renew its clock — forever, whether or not a human
2995
+ * is looking at the document. That is the right price for a document someone
2996
+ * has open, and pure waste for the dozens a background indexer or a search
2997
+ * sweep opens and closes. Measured: 10 loaded children = 11 instances = 66
2998
+ * heartbeat callbacks per 20 s idle.
2999
+ *
3000
+ * When this is set, the instance is built on first access instead of in the
3001
+ * constructor, and building it also publishes local state and queries peers,
3002
+ * so a document that later gains an editor gets symmetric presence exactly as
3003
+ * if it had been eager all along. Consumers see no difference: the public
3004
+ * `awareness` accessor always returns a usable instance.
3005
+ *
3006
+ * `AbracadabraProvider.loadChild` sets this. Top-level providers stay eager,
3007
+ * so every socket keeps at least one heartbeat and the liveness assumption in
3008
+ * `AbracadabraWS.checkConnection` is untouched.
3009
+ *
3010
+ * Ignored when an explicit `awareness` (including `null`) is supplied.
3011
+ */
3012
+ lazyAwareness?: boolean;
3099
3013
  /**
3100
3014
  * A token that's sent to the backend for authentication purposes.
3101
3015
  */
@@ -3205,6 +3119,10 @@ declare class AbracadabraBaseProvider extends EventEmitter {
3205
3119
  */
3206
3120
  subscribeQuery(spec: QuerySpec, handlers?: QuerySubscriptionHandlers): QuerySubscriptionHandle;
3207
3121
  constructor(configuration: AbracadabraBaseProviderConfiguration);
3122
+ /** A periodic re-sync tick that was skipped because the app was hidden. */
3123
+ missedForceSync: boolean;
3124
+ /** Detaches the force-sync lifecycle subscription, when one was installed. */
3125
+ unsubscribeForceSyncLifecycle: (() => void) | null;
3208
3126
  boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
3209
3127
  boundAwarenessUpdateHandler: ({
3210
3128
  added,
@@ -3223,7 +3141,42 @@ declare class AbracadabraBaseProvider extends EventEmitter {
3223
3141
  setConfiguration(configuration?: Partial<AbracadabraBaseProviderConfiguration>): void;
3224
3142
  get document(): Y.Doc;
3225
3143
  get isAttached(): boolean;
3144
+ /** True while an Awareness instance is owed but has not been built yet. */
3145
+ private _awarenessDeferred;
3146
+ /** True when the caller passed `awareness: null` and meant it. */
3147
+ private _awarenessExplicitlyNull;
3148
+ /**
3149
+ * The presence instance for this document, built on demand.
3150
+ *
3151
+ * Reading this materializes a deferred instance (see `lazyAwareness`), which
3152
+ * is why every consumer — TipTap's CollaborationCaret, presence UI, app code
3153
+ * — keeps working unchanged: touching `.awareness` is itself the signal that
3154
+ * this document needs presence.
3155
+ *
3156
+ * Provider INTERNALS must use `peekAwareness()` instead, or the lazy path
3157
+ * materializes everything it was meant to avoid.
3158
+ */
3226
3159
  get awareness(): Awareness | null;
3160
+ /**
3161
+ * The Awareness instance if one exists, without ever creating one.
3162
+ *
3163
+ * @internal Used by provider internals and `MessageReceiver`. A deferred
3164
+ * document has no local presence, so there is nothing for an inbound
3165
+ * awareness frame to be applied to and nothing to answer a peer's query with
3166
+ * — and materializing on a peer's frame would hand every idle background
3167
+ * document a heartbeat as soon as anyone else joined the space.
3168
+ */
3169
+ peekAwareness(): Awareness | null;
3170
+ /**
3171
+ * Build the deferred Awareness instance and bring it fully up to date:
3172
+ * seeded, wired, published, and caught up with the peers already present.
3173
+ */
3174
+ private _materializeAwareness;
3175
+ /**
3176
+ * Seed and wire an Awareness instance. Shared by the eager constructor path
3177
+ * and the lazy materialization path so the two cannot drift.
3178
+ */
3179
+ private _initAwareness;
3227
3180
  get hasUnsyncedChanges(): boolean;
3228
3181
  private resetUnsyncedChanges;
3229
3182
  incrementUnsyncedChanges(): void;
@@ -3445,11 +3398,11 @@ declare enum AuthMessageType {
3445
3398
  PermissionDenied = 1,
3446
3399
  Authenticated = 2
3447
3400
  }
3448
- declare const writeAuthentication: (encoder: Encoder, auth: string) => void;
3449
- declare const writePermissionDenied: (encoder: Encoder, reason: string) => void;
3450
- declare const writeAuthenticated: (encoder: Encoder, scope: AuthorizedScope) => void;
3451
- declare const writeTokenSyncRequest: (encoder: Encoder) => void;
3452
- declare const readAuthMessage: (decoder: Decoder, sendToken: () => void, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;
3401
+ declare const writeAuthentication: (encoder: lib0_encoding0.Encoder, auth: string) => void;
3402
+ declare const writePermissionDenied: (encoder: lib0_encoding0.Encoder, reason: string) => void;
3403
+ declare const writeAuthenticated: (encoder: lib0_encoding0.Encoder, scope: AuthorizedScope) => void;
3404
+ declare const writeTokenSyncRequest: (encoder: lib0_encoding0.Encoder) => void;
3405
+ declare const readAuthMessage: (decoder: decoding.Decoder, sendToken: () => void, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;
3453
3406
  //#endregion
3454
3407
  //#region packages/provider/src/awarenessStatesToArray.d.ts
3455
3408
  declare const awarenessStatesToArray: (states: Map<number, Record<string, any>>) => {
@@ -3470,7 +3423,7 @@ declare const awarenessStatesToArray: (states: Map<number, Record<string, any>>)
3470
3423
  declare class SubdocMessage extends OutgoingMessage {
3471
3424
  type: MessageType;
3472
3425
  description: string;
3473
- get(args: Partial<AbracadabraOutgoingMessageArguments>): Encoder;
3426
+ get(args: Partial<AbracadabraOutgoingMessageArguments>): lib0_encoding0.Encoder;
3474
3427
  }
3475
3428
  //#endregion
3476
3429
  //#region packages/provider/src/NodeIdentity.d.ts
@@ -4466,7 +4419,7 @@ interface AbracadabraWebRTCConfiguration {
4466
4419
  /** Optional Y.Doc to sync over data channels (hybrid mode). */
4467
4420
  document?: InstanceType<typeof Y.Doc> | null;
4468
4421
  /** Optional Awareness instance for presence sync over data channels. */
4469
- awareness?: InstanceType<typeof Awareness> | null;
4422
+ awareness?: InstanceType<typeof y_protocols_awareness0.Awareness> | null;
4470
4423
  /** ICE server configuration. Defaults to Google STUN. */
4471
4424
  iceServers?: RTCIceServer[];
4472
4425
  /** Display name for this peer. */
@@ -5448,10 +5401,6 @@ declare class NotificationsClient extends EventEmitter {
5448
5401
  private handleServerError;
5449
5402
  }
5450
5403
  //#endregion
5451
- //#region node_modules/@scure/bip39/wordlists/english.d.ts
5452
- /** English BIP39 wordlist. */
5453
- declare const wordlist: string[];
5454
- //#endregion
5455
5404
  //#region packages/provider/src/MnemonicKeyDerivation.d.ts
5456
5405
  /**
5457
5406
  * Generate a new BIP-39 mnemonic phrase.
@@ -6386,4 +6335,207 @@ declare function collectMediaFileBlocks(root: Y.XmlFragment | Y.XmlElement): Med
6386
6335
  */
6387
6336
  declare function reconcileDocCover(treeMap: Y.Map<unknown>, docId: string, fragment: Y.XmlFragment | Y.XmlElement): void;
6388
6337
  //#endregion
6389
- 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, 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, type LoadKeyFileOptions, LocalStorageDeviceSessionStorage, type LoginOrRegisterOptions, ManualSignaling, type ManualSignalingBlob, 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, 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, TokenManager, type TokenManagerOptions, TreeEntry, TreeManager, TreeNode, TreeSearchResult, TypedDocTypeMismatchError, type TypedDocsClient, type TypedTreeEntry, Unauthorized, UploadInfo, UploadMeta, UploadQueueEntry, UploadQueueStatus, UserMetaField, UserProfile, 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, 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, pickEntrySpace, populateYDocFromMarkdown, readAuthMessage, readBlocksFromFragment, readEntries, reconcileDocCover, recordFromYAny, removeServer, resolvePageType, resolveServer, saveServerRegistry, serverRegistryPath, setDefault, signChallengeWithSeed, toPlain, unwrapSeed, validateMnemonic, waitForSync, withTimeout, wrapSeed, writeAuthenticated, writeAuthentication, writePermissionDenied, writeTokenSyncRequest, yjsToMarkdown };
6338
+ //#region packages/provider/src/PerfCounters.d.ts
6339
+ /**
6340
+ * PerfCounters — opt-in resource accounting for the provider.
6341
+ *
6342
+ * WHY THIS EXISTS
6343
+ *
6344
+ * The provider's expensive behaviour is idle behaviour: timers that fire and
6345
+ * frames that go out when nobody is doing anything. That cost is invisible to
6346
+ * ordinary profiling of a busy app and invisible to the test suite, so it grew
6347
+ * unnoticed. This module makes it countable, so a budget can be asserted
6348
+ * instead of argued about.
6349
+ *
6350
+ * DESIGN CONSTRAINTS
6351
+ *
6352
+ * 1. **Inert until installed.** Importing this module patches nothing and
6353
+ * costs nothing. Only `installPerfCounters()` wraps anything, and
6354
+ * `uninstall()` restores the exact original references. Nothing in the
6355
+ * production path ever calls in here.
6356
+ *
6357
+ * 2. **Attribute by stack, don't instrument by hand.** Timers are the unit of
6358
+ * battery cost, and the ones that matter are created inside dependencies
6359
+ * (`y-protocols`' Awareness starts a 3 s interval per instance). Recording
6360
+ * a creation stack for every timer means we count the real cost wherever it
6361
+ * comes from — including timers added later by code that never heard of
6362
+ * this module — instead of sprinkling counter calls through the provider
6363
+ * and hoping they stay in sync with reality.
6364
+ *
6365
+ * 3. **No global socket patching.** In Node the provider runs on the `ws`
6366
+ * package, not `globalThis.WebSocket`, so a global patch would silently
6367
+ * measure nothing. `instrumentSocket()` takes an explicit AbracadabraWS
6368
+ * instead — the same approach `_perf_client.mts` already uses.
6369
+ *
6370
+ * Not covered here on purpose: `Y.encodeStateAsUpdate` cost. It cannot be
6371
+ * patched through an ES import binding, and the perf harness measures it
6372
+ * directly by calling it, which is more accurate anyway.
6373
+ */
6374
+ /** One group of timers sharing an origin and a delay. */
6375
+ interface TimerGroup {
6376
+ /** Best-effort source attribution, e.g. "y-protocols/awareness.js". */
6377
+ origin: string;
6378
+ /** The delay the timer was created with, in ms. */
6379
+ delayMs: number;
6380
+ /** Timers of this shape created since the last reset. */
6381
+ created: number;
6382
+ /** Timers of this shape still live right now. */
6383
+ live: number;
6384
+ /** Callback invocations of this shape since the last reset. */
6385
+ fired: number;
6386
+ }
6387
+ interface PerfSnapshot {
6388
+ /** Wall-clock ms since the last `reset()` (or install). */
6389
+ elapsedMs: number;
6390
+ timers: {
6391
+ intervalsCreated: number;
6392
+ intervalsLive: number;
6393
+ timeoutsCreated: number;
6394
+ timeoutsLive: number; /** Every callback invocation from a wrapped timer. */
6395
+ fired: number; /** Fired per second over the elapsed window — the battery number. */
6396
+ firedPerSecond: number; /** Grouped by origin + delay, largest `live` first. */
6397
+ groups: TimerGroup[];
6398
+ };
6399
+ animationFrames: {
6400
+ requested: number;
6401
+ fired: number;
6402
+ };
6403
+ awareness: {
6404
+ /**
6405
+ * Live `y-protocols` Awareness instances, derived from their
6406
+ * characteristic heartbeat interval (outdatedTimeout / 10 = 3000 ms
6407
+ * created inside awareness.js). This is the count the whole idle-cost
6408
+ * ledger hinges on.
6409
+ */
6410
+ liveInstances: number; /** Heartbeat callback invocations since the last reset. */
6411
+ heartbeatFires: number;
6412
+ };
6413
+ indexedDb: {
6414
+ transactions: number; /** Transactions by object-store name. */
6415
+ byStore: Record<string, number>;
6416
+ databasesOpened: number;
6417
+ };
6418
+ sockets: {
6419
+ framesSent: number;
6420
+ bytesSent: number;
6421
+ framesReceived: number;
6422
+ bytesReceived: number; /** Frames sent grouped by the wire message type byte, when readable. */
6423
+ sentByType: Record<string, number>;
6424
+ };
6425
+ }
6426
+ /** An AbracadabraWS-shaped object. Kept structural to avoid an import cycle. */
6427
+ interface SocketLike {
6428
+ send(message: unknown): void;
6429
+ on(event: string, handler: (...args: any[]) => void): unknown;
6430
+ off(event: string, handler: (...args: any[]) => void): unknown;
6431
+ }
6432
+ /**
6433
+ * Begin counting. Idempotent — a second call is a no-op rather than a
6434
+ * double-wrap, which would double every number and be very hard to notice.
6435
+ */
6436
+ declare function installPerfCounters(): void;
6437
+ /** Restore every patched global. Safe to call when not installed. */
6438
+ declare function uninstall(): void;
6439
+ /** Zero every counter. Live-timer bookkeeping is preserved — it is a census. */
6440
+ declare function reset(): void;
6441
+ /**
6442
+ * Count frames on one AbracadabraWS. Returns a restore function; the restore is
6443
+ * also run by `uninstall()`.
6444
+ *
6445
+ * Wrapping the instance (rather than a global) is deliberate: in Node the
6446
+ * provider runs on the `ws` package, so patching `globalThis.WebSocket` would
6447
+ * silently measure nothing at all.
6448
+ */
6449
+ declare function instrumentSocket(socket: SocketLike): () => void;
6450
+ declare function snapshot(): PerfSnapshot;
6451
+ /** Field-by-field difference of two snapshots, for before/after comparisons. */
6452
+ declare function diff(before: PerfSnapshot, after: PerfSnapshot): {
6453
+ elapsedMs: number;
6454
+ timersFired: number;
6455
+ intervalsCreated: number;
6456
+ intervalsLive: number;
6457
+ awarenessLive: number;
6458
+ heartbeatFires: number;
6459
+ framesSent: number;
6460
+ bytesSent: number;
6461
+ idbTransactions: number;
6462
+ };
6463
+ /** Whether counting is currently active. */
6464
+ declare function isInstalled(): boolean;
6465
+ //#endregion
6466
+ //#region packages/provider/src/LifecycleGate.d.ts
6467
+ /**
6468
+ * LifecycleGate — one place that knows whether the app is actually being looked at.
6469
+ *
6470
+ * Nothing in the provider used to ask. A grep for `visibilitychange` across the
6471
+ * package returned exactly one hit, in `TokenManager`, and it used the signal to
6472
+ * do MORE work on resume — nothing anywhere used it to do less. So a backgrounded
6473
+ * PWA kept its socket liveness checker running, kept re-running a full-tree
6474
+ * background sync every five minutes, and kept broadcasting presence, at exactly
6475
+ * the same rate as a phone held open in front of a person.
6476
+ *
6477
+ * Two design points that matter:
6478
+ *
6479
+ * 1. **The visibility source is injectable.** Hidden-state behaviour is the part
6480
+ * of this that most needs testing and is the hardest to reach from a test
6481
+ * runner, so `setSource()` lets a test drive it deterministically instead of
6482
+ * the tests having to fake a DOM.
6483
+ *
6484
+ * 2. **Hiding is debounced, revealing is not.** Alt-tabbing to look something up
6485
+ * is not "the user has gone away", and treating it as such would make presence
6486
+ * avatars flicker across everyone else's screen every time someone checked
6487
+ * their mail. Coming back is always immediate — a user who returns must never
6488
+ * wait on a timer to see live data.
6489
+ *
6490
+ * In Node, and anywhere else without a `document`, this is inert and reports
6491
+ * visible forever.
6492
+ */
6493
+ type VisibilityState = "visible" | "hidden";
6494
+ /** Something that can report visibility and notify on change. */
6495
+ interface VisibilitySource {
6496
+ /** Current state at the moment of the call. */
6497
+ get(): VisibilityState;
6498
+ /** Subscribe to changes. Returns an unsubscribe function. */
6499
+ subscribe(onChange: () => void): () => void;
6500
+ }
6501
+ /** How long the app must stay hidden before we act on it. */
6502
+ declare const HIDE_GRACE_MS = 10000;
6503
+ declare class LifecycleGate {
6504
+ private readonly graceMs;
6505
+ private source;
6506
+ private unsubscribe;
6507
+ private hideTimer;
6508
+ private _backgrounded;
6509
+ private listeners;
6510
+ constructor(source?: VisibilitySource, graceMs?: number);
6511
+ /**
6512
+ * True when the app has been hidden for longer than the grace period.
6513
+ *
6514
+ * Deliberately NOT the same as `document.hidden`: a tab that was hidden two
6515
+ * seconds ago is still, for our purposes, in use.
6516
+ */
6517
+ get backgrounded(): boolean;
6518
+ /** Subscribe to background/foreground transitions. Returns an unsubscribe fn. */
6519
+ onChange(listener: (backgrounded: boolean) => void): () => void;
6520
+ /** Swap the visibility source. Used by tests to drive state deterministically. */
6521
+ setSource(source: VisibilitySource): void;
6522
+ private onVisibilityChange;
6523
+ private setBackgrounded;
6524
+ destroy(): void;
6525
+ }
6526
+ declare function getLifecycleGate(): LifecycleGate;
6527
+ /**
6528
+ * Replace the shared gate. Tests use this to install a controllable source;
6529
+ * passing `null` restores the default browser-backed gate on next access.
6530
+ */
6531
+ declare function setLifecycleGate(gate: LifecycleGate | null): void;
6532
+ /** A visibility source a test (or an embedder) can drive by hand. */
6533
+ declare class ManualVisibilitySource implements VisibilitySource {
6534
+ private state;
6535
+ private listeners;
6536
+ get(): VisibilityState;
6537
+ subscribe(onChange: () => void): () => void;
6538
+ set(state: VisibilityState): void;
6539
+ }
6540
+ //#endregion
6541
+ 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.95.0",
3
+ "version": "2.97.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.95.0"
38
+ "@abraca/schema": "2.97.0"
39
39
  },
40
40
  "scripts": {
41
41
  "test": "node --no-warnings --conditions=source --experimental-transform-types --test 'tests/*.test.ts'"