@q9labsai/chalk-client 5.3.1 → 5.4.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/{chunk-2CEMOTZF.js → chunk-TA2BJXI7.js} +59 -9
- package/dist/{chunk-O5JB5XVX.js → chunk-UVWRTXNO.js} +285 -47
- package/dist/{chunk-FD7ZSDTM.js → chunk-XF567GPH.js} +127 -8
- package/dist/connection/dependencies.d.ts +5 -0
- package/dist/connection/production.d.ts +1 -1
- package/dist/effect.js +3 -3
- package/dist/generated/sync.d.ts +38 -0
- package/dist/index.js +3 -3
- package/dist/media/client.d.ts +1 -0
- package/dist/media/index.js +1 -1
- package/dist/media/plane.d.ts +1 -0
- package/dist/sync/index.js +1 -1
- package/dist/sync/link-watch.d.ts +67 -0
- package/dist/sync/v1-client.d.ts +5 -0
- package/dist/sync/v1-types.d.ts +12 -1
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides whether a Sync drop is proven short. Contact is proven only by a ping and the pong that answers it: the pong proves
|
|
3
|
+
* contact at the moment the ping was SENT, and only when the round trip took 0 to `ROUND_TRIP_MS` on both the wall clock and the
|
|
4
|
+
* monotonic clock, with no page freeze, resume or discard in between. A pong that was buffered through a suspend shows a long round
|
|
5
|
+
* trip, a clock step back shows a negative one, and neither proves anything. No other frame proves contact, because a frame says
|
|
6
|
+
* when the page processed it, not when Sync sent it.
|
|
7
|
+
*
|
|
8
|
+
* A pong answers the oldest ping in flight, and no ping is ever evicted. A ping or pong that is lost therefore only makes later
|
|
9
|
+
* pongs pair with an older ping, which records an earlier contact and a longer round trip: it fails closed, and proof stops once the
|
|
10
|
+
* pairing skew passes `ROUND_TRIP_MS`. The one assumption is that Sync sends exactly one pong per ping; a duplicate pong is the only
|
|
11
|
+
* way to pair with a newer ping, and a ping sequence number would remove it. A late pong proves nothing and changes nothing else.
|
|
12
|
+
* When the oldest ping has gone unanswered for over `UNANSWERED_LIMIT_MS`, the old heartbeat timeout, `pinged()` returns false and
|
|
13
|
+
* the client replaces the socket; `restart()` empties the queue on the next one.
|
|
14
|
+
*
|
|
15
|
+
* A drop is long when any of these holds, and nothing else makes it long (a hidden tab, throttled timers and a slow network do not):
|
|
16
|
+
* - no contact was ever proven;
|
|
17
|
+
* - either clock went backwards since the last proven contact;
|
|
18
|
+
* - either clock advanced `LONG_DROP_MS` or more since the last proven contact;
|
|
19
|
+
* - the page was frozen, resumed or discarded since then.
|
|
20
|
+
*
|
|
21
|
+
* Known gap: a tab hidden for over 5 minutes with no live WebRTC connection runs its timers once a minute, so it sends one ping a
|
|
22
|
+
* minute and its last proof can be nearly 60 s old when the link drops. A short drop then reads long and the source turns off.
|
|
23
|
+
* That errs toward off, and Chrome exempts a page that holds a live WebRTC connection.
|
|
24
|
+
*
|
|
25
|
+
* On a quiet call the last ping can be up to 20 s older than the loss, so down time can read up to 20 s too long and the
|
|
26
|
+
* effective cutoff is 40 to 60 s. That errs toward turning the source off.
|
|
27
|
+
*/
|
|
28
|
+
export declare const LONG_DROP_MS = 60000;
|
|
29
|
+
export type LinkReading = {
|
|
30
|
+
readonly wall: number;
|
|
31
|
+
readonly mono: number;
|
|
32
|
+
readonly suspends: number;
|
|
33
|
+
};
|
|
34
|
+
export type LinkJudge = {
|
|
35
|
+
/** The last proof of contact, or null before the first answered ping. */
|
|
36
|
+
readonly proof: () => LinkReading | null;
|
|
37
|
+
/** True unless the time since `proof` is proven short; a missing proof is long. */
|
|
38
|
+
readonly longSince: (proof: LinkReading | null) => boolean;
|
|
39
|
+
};
|
|
40
|
+
export type LinkClock = {
|
|
41
|
+
readonly wall: () => number;
|
|
42
|
+
readonly mono: () => number;
|
|
43
|
+
};
|
|
44
|
+
/** The browser document, or any target that fires the Page Lifecycle `freeze` and `resume` events. */
|
|
45
|
+
export type PageLifecycle = {
|
|
46
|
+
readonly addEventListener: (type: "freeze" | "resume", listener: () => void) => void;
|
|
47
|
+
readonly removeEventListener: (type: "freeze" | "resume", listener: () => void) => void;
|
|
48
|
+
readonly wasDiscarded?: boolean;
|
|
49
|
+
};
|
|
50
|
+
export declare class LinkWatch implements LinkJudge {
|
|
51
|
+
#private;
|
|
52
|
+
constructor(clock: LinkClock, page: PageLifecycle | null);
|
|
53
|
+
/** Listens for page suspension. Idempotent, and paired with `close`. */
|
|
54
|
+
open(): void;
|
|
55
|
+
close(): void;
|
|
56
|
+
/** Call when a connection goes live: the previous socket's pings will not be answered. */
|
|
57
|
+
restart(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Call as a ping goes out, in the same order as the pings. False means the oldest ping has gone unanswered for over
|
|
60
|
+
* `UNANSWERED_LIMIT_MS`: the socket is dead and this ping must not be sent on it.
|
|
61
|
+
*/
|
|
62
|
+
pinged(): boolean;
|
|
63
|
+
/** Call as a pong is received. It answers the oldest ping in flight, and proves contact only if the round trip was short. */
|
|
64
|
+
ponged(): void;
|
|
65
|
+
proof(): LinkReading | null;
|
|
66
|
+
longSince(proof: LinkReading | null): boolean;
|
|
67
|
+
}
|
package/dist/sync/v1-client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LinkJudge } from "./link-watch";
|
|
1
2
|
import type { ChalkChatReactionInput, ChalkChatReactions, ChalkChatMessage, ChalkChatPageResult, ChalkChatReadReceipt, ChalkReaction, ChalkReactionEvent, ChalkSendChatMessageInput, ChalkSyncV1CollaborationCapability } from "../collaboration/types";
|
|
2
3
|
import type { V1AdmissionTarget, V1AssignableRole, V1CommandResult, V1DirectedRequest, V1DirectedRequestResult, V1MediaPause, V1CollaborationEvent, V1CollaborationClient, V1CollaborationExtensionState, V1EpisodeSnapshot, V1SelfMediaTargetResult, V1SyncClientOptions } from "./v1-types";
|
|
3
4
|
type CommandOptions = {
|
|
@@ -9,12 +10,16 @@ type RequestOptions = {
|
|
|
9
10
|
export { V1SyncError } from "./v1-error";
|
|
10
11
|
export declare class V1SyncClient implements V1CollaborationClient {
|
|
11
12
|
#private;
|
|
13
|
+
/** Tells a recovery whether the drop was proven short. */
|
|
14
|
+
readonly link: LinkJudge;
|
|
12
15
|
constructor(options: V1SyncClientOptions);
|
|
13
16
|
restartTransport(): void;
|
|
14
17
|
start(): Promise<void>;
|
|
15
18
|
stop(): void;
|
|
16
19
|
/** Announces completed startup; transport recovery resends until acknowledged. */
|
|
17
20
|
confirmEntered(): Promise<void>;
|
|
21
|
+
/** True when the connected Sync advertised `media_off_reason` in its welcome, so media items may carry `off_reason`. */
|
|
22
|
+
offReasonNegotiated(): boolean;
|
|
18
23
|
getSnapshot(): V1EpisodeSnapshot;
|
|
19
24
|
subscribe(listener: (snapshot: V1EpisodeSnapshot) => void): () => void;
|
|
20
25
|
onMediaPause(listener: (pause: V1MediaPause) => void): () => void;
|
package/dist/sync/v1-types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ConnectionReportTransportEvent } from "../transport-diagnostics";
|
|
2
|
+
import type { PageLifecycle } from "./link-watch";
|
|
2
3
|
import type { SetAdmissionPolicyCommandFrame, SyncV1ServerFrame } from "../generated/sync";
|
|
3
4
|
import type { ClientMediaPlane, MediaPlaneOutcome, MediaPlaneResult, MediaPlaneTarget, MediaPublication, MediaSource } from "../media/plane";
|
|
4
5
|
import type { ChalkChatReactionInput, ChalkChatReactions, ChalkChatMessage, ChalkChatPageResult, ChalkChatReadReceipt, ChalkReaction, ChalkReactionEvent, ChalkSendChatMessageInput, ChalkSyncV1CollaborationCapability } from "../collaboration/types";
|
|
@@ -50,7 +51,13 @@ export type V1ControlState = {
|
|
|
50
51
|
readonly participants: readonly V1Participant[];
|
|
51
52
|
readonly admissionRequests: readonly V1AdmissionRequest[];
|
|
52
53
|
};
|
|
53
|
-
|
|
54
|
+
/** Why Sync shows a media item as off. A missing reason is no evidence, never "off". */
|
|
55
|
+
export type V1MediaOffReason = "host" | "self" | "dead";
|
|
56
|
+
export type V1MediaPublication = MediaPublication & {
|
|
57
|
+
readonly offReason?: V1MediaOffReason;
|
|
58
|
+
/** The control revision of the host stop; only with `offReason: "host"`. */
|
|
59
|
+
readonly offRevision?: number;
|
|
60
|
+
};
|
|
54
61
|
export type V1Presence = {
|
|
55
62
|
readonly admissionRevision?: number;
|
|
56
63
|
/** Stable person identity, independent of the per-device participant ID. */
|
|
@@ -206,6 +213,10 @@ export type V1SyncClientOptions = {
|
|
|
206
213
|
readonly ids?: SyncIdGenerator;
|
|
207
214
|
readonly requestIds?: SyncIdGenerator;
|
|
208
215
|
readonly clock?: SyncClock;
|
|
216
|
+
/** Monotonic milliseconds, `performance.now()` by default. */
|
|
217
|
+
readonly monotonic?: () => number;
|
|
218
|
+
/** The page whose `freeze` and `resume` events show a suspend; the browser document by default, null for none. */
|
|
219
|
+
readonly page?: PageLifecycle | null;
|
|
209
220
|
readonly lifecycle?: SyncLifecycle;
|
|
210
221
|
readonly reconnectDelayMs?: number;
|
|
211
222
|
/** Per-attempt WebSocket opening allowance, clamped to 10–60 seconds; defaults to 10 seconds. */
|