@interncom/diplomatic 0.2.7 → 0.3.1

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.
@@ -22,3 +22,31 @@ export declare class CoalesceTail<T> {
22
22
  flush(): Promise<void>;
23
23
  private drain;
24
24
  }
25
+ /** Default quiet period before a scheduled sync after local writes. */
26
+ export declare const defaultSyncDebounceMs = 100;
27
+ /**
28
+ * Debounce async work: each `schedule()` resets a timer; when the quiet period
29
+ * elapses, `work` runs via {@link CoalesceTail} so stampeding fires do not
30
+ * overlap (trailing pass if more demand arrives mid-run).
31
+ *
32
+ * - `delayMs <= 0`: run on the next microtask path immediately (no timer).
33
+ * - `flush()`: cancel the timer, start work if a run was pending, await drain.
34
+ * - `cancel()`: drop the pending timer without running (in-flight continues).
35
+ */
36
+ export declare class Debounced<T = void> {
37
+ private timer;
38
+ private readonly delayMs;
39
+ private readonly work;
40
+ private readonly tail;
41
+ constructor(delayMs: number, work: () => Promise<T>);
42
+ /** Request a run after the debounce quiet period (resets the timer). */
43
+ schedule(): void;
44
+ /**
45
+ * Run any pending debounced work now and wait until the drain finishes.
46
+ * No-op if nothing is pending or in flight.
47
+ */
48
+ flush(): Promise<void>;
49
+ /** Drop a pending timer without starting work. In-flight work is untouched. */
50
+ cancel(): void;
51
+ private fire;
52
+ }
@@ -17,10 +17,16 @@ import { nullStateManager, StateManager } from "./state";
17
17
  import { IDBStore, openIDBStore } from "./stores/idb/store";
18
18
  import { MemoryStore } from "./stores/memory/store";
19
19
  import { SingletonStateManager } from "./shared/singleton";
20
- import type { Applier, IDiplomaticClientState, IStore, IStoredMessage, IStoredMessageData } from "./types";
20
+ import type { Applier, IClient, IDiplomaticClientState, IHostRow, IStore, IStoredMessage, IStoredMessageData, IStoredMessageWrite } from "./types";
21
+ import { isPendingApply, normalizeStoredMessageData } from "./types";
22
+ import type { SyncProgressEvent } from "./progress";
23
+ import { defaultPeekProgressEvery, idleProgress, shouldEmitItemProgress } from "./progress";
24
+ import { openDiplomaticClient, type OpenDiplomaticClientMainOptions, type OpenDiplomaticClientOptions, type OpenDiplomaticClientWorkerOptions, type OpenedDiplomaticClient } from "./openClient";
25
+ import { WorkerClient } from "./worker/client";
26
+ import type { WorkerClientOptions } from "./worker/client";
21
27
  export declare function genWebClient(stateMgr: IStateManager, url: URL): Promise<{
22
28
  client: SyncClient<URL>;
23
29
  setSeed: (seedHex: string) => Promise<void>;
24
30
  }>;
25
- export { btoh, Clock, crypto, Decoder, eidCodec, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, hostHTTPTransport, htob, HTTPTransport, IDBStore, IEntDB, IEntity, IStore, MasterSeed, MemoryStore, nullEntDB, nullStateManager, openEntIDB, openIDBStore, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, };
26
- export type { Applier, HostHandle, ICrypto, IDiplomaticClientState, IHostConnectionInfo, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, ITransport, };
31
+ export { btoh, Clock, crypto, Decoder, defaultPeekProgressEvery, eidCodec, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, hostHTTPTransport, htob, HTTPTransport, IDBStore, idleProgress, IEntDB, IEntity, isPendingApply, IStore, MasterSeed, MemoryStore, normalizeStoredMessageData, nullEntDB, nullStateManager, openDiplomaticClient, openEntIDB, openIDBStore, shouldEmitItemProgress, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, WorkerClient, };
32
+ export type { Applier, HostHandle, IClient, ICrypto, IDiplomaticClientState, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITransport, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, SyncProgressEvent, WorkerClientOptions, };