stitchkit 0.110.0 → 0.110.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.
- package/CHANGELOG.md +11 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
- package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
- package/dist/browser/socket-io-client.d.ts +6 -0
- package/dist/browser/socket-io-client.d.ts.map +1 -0
- package/dist/browser/socket-io-contract.d.ts +183 -0
- package/dist/browser/socket-io-contract.d.ts.map +1 -0
- package/dist/browser/socket-io-default-peer.d.ts +3 -0
- package/dist/browser/socket-io-default-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-explicit-peer.d.ts +12 -0
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +2 -11
- package/dist/browser/socket-io-peer.d.ts.map +1 -1
- package/dist/browser/socket-io.d.ts +5 -224
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
- package/dist/entrypoints/agent-runtime/harness.js +2 -2
- package/dist/entrypoints/agent-runtime/realtime.js +3 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
- package/dist/entrypoints/agent-runtime.js +5 -5
- package/dist/entrypoints/application/directory-inbox.js +6 -6
- package/dist/entrypoints/application.js +1 -1
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/cli.js +8 -8
- package/dist/entrypoints/contract.js +1 -1
- package/dist/entrypoints/files.js +1 -1
- package/dist/entrypoints/http.d.ts +1 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +6 -2
- package/dist/entrypoints/index.js +20 -411
- package/dist/entrypoints/node.js +3 -3
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +1 -1
- package/dist/entrypoints/realtime.d.ts +6 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -0
- package/dist/entrypoints/realtime.js +25 -0
- package/dist/entrypoints/remote.js +1 -1
- package/dist/entrypoints/server.js +11 -11
- package/dist/entrypoints/telegram/screens.js +9 -9
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/testing.js +2 -2
- package/dist/entrypoints/tools/connections.js +3 -3
- package/dist/entrypoints/tools/invoker.js +3 -3
- package/dist/entrypoints/tools/mcp.js +4 -4
- package/dist/entrypoints/tools.js +22 -22
- package/dist/{index-61m15a18.js → index-0d8m0kee.js} +1 -1
- package/dist/{index-dmfr2cg5.js → index-2tazbwhv.js} +6 -6
- package/dist/index-86sxnvpr.js +336 -0
- package/dist/{index-2pevnh0x.js → index-8rstkvcf.js} +3 -3
- package/dist/{index-064zxbwj.js → index-924500c3.js} +1 -1
- package/dist/{index-mnhtbqrb.js → index-dd1z5kxb.js} +2 -2
- package/dist/{index-7a1xhhdx.js → index-e1sjcjfy.js} +31 -11
- package/dist/{index-p6mvqcbq.js → index-ghwntn9n.js} +1 -1
- package/dist/index-hqsbtvta.js +92 -0
- package/dist/{index-73cz22ds.js → index-mha6b4vk.js} +6 -6
- package/dist/{index-fnra8n1j.js → index-s2eybn7b.js} +9 -9
- package/dist/{index-njs9gvrh.js → index-s6d8zsha.js} +6 -6
- package/dist/{index-jyw90rps.js → index-tjdsyrys.js} +1 -1
- package/dist/process/group-presence.d.ts +3 -0
- package/dist/process/group-presence.d.ts.map +1 -0
- package/dist/process/group-settlement.d.ts.map +1 -1
- package/dist/process/group.d.ts.map +1 -1
- package/llms/realtime.txt +31 -0
- package/llms/stitchkit.txt +1 -0
- package/llms-full.txt +22 -0
- package/llms.txt +2 -1
- package/package.json +5 -1
- package/dist/{index-9j2atjte.js → index-2f9r0jgr.js} +3 -3
- package/dist/{index-y70v24cw.js → index-8asb62xn.js} +0 -0
- package/dist/{index-k7qdkh3n.js → index-h1spd9kv.js} +3 -3
- package/dist/{index-zgwkwr1g.js → index-jk44mbqb.js} +0 -0
- package/dist/{index-qd8x73e8.js → index-k8fbzggr.js} +0 -0
- package/dist/{index-85qve8mq.js → index-pzw0fpek.js} +0 -0
- package/dist/{index-y3nemndz.js → index-r6v4mc67.js} +3 -3
- package/dist/{index-ktjmgq9p.js → index-s0xbnpfh.js} +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,17 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.110.1] - 2026-10-14
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `stitchkit/realtime` provides the shared typed Socket.IO client and retained-topic helpers through an explicit-peer graph that Hermes can compile. Pass `peers: { client: () => import('socket.io-client') }`; root Node/Web clients keep optional lazy peer resolution. HTTP uploads are also available from `stitchkit/http`, so native/shared modules can use public leaves throughout their graph (I7, I8).
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Process-group cleanup accepts a fresh kernel absence after SIGKILL instead of relying only on a potentially stale process-table snapshot. Permission refusals and unknown/exiting states still require proof; the same cleanup deadline applies and failures retain their last observed states.
|
|
27
|
+
- A synchronously throwing injected Socket.IO peer loader now reaches `onConnectError`, clears connection intent and allows the next `connect()` to retry, just like an asynchronously rejected loader.
|
|
28
|
+
|
|
18
29
|
## [0.110.0] - 2026-10-14
|
|
19
30
|
|
|
20
31
|
### ⚠️ Breaking changes
|
|
@@ -133,11 +133,6 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
133
133
|
parts: ({
|
|
134
134
|
type: "text";
|
|
135
135
|
text: string;
|
|
136
|
-
} | {
|
|
137
|
-
type: "file";
|
|
138
|
-
mediaType: string;
|
|
139
|
-
reference: string;
|
|
140
|
-
filename?: string | undefined;
|
|
141
136
|
} | {
|
|
142
137
|
type: "reasoning";
|
|
143
138
|
text: string;
|
|
@@ -146,6 +141,11 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
146
141
|
provider: string;
|
|
147
142
|
data: Record<string, import("zod").JSONType>;
|
|
148
143
|
} | undefined;
|
|
144
|
+
} | {
|
|
145
|
+
type: "file";
|
|
146
|
+
mediaType: string;
|
|
147
|
+
reference: string;
|
|
148
|
+
filename?: string | undefined;
|
|
149
149
|
} | {
|
|
150
150
|
type: "source";
|
|
151
151
|
sourceId: string;
|
|
@@ -313,11 +313,6 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
313
313
|
parts: ({
|
|
314
314
|
type: "text";
|
|
315
315
|
text: string;
|
|
316
|
-
} | {
|
|
317
|
-
type: "file";
|
|
318
|
-
mediaType: string;
|
|
319
|
-
reference: string;
|
|
320
|
-
filename?: string | undefined;
|
|
321
316
|
} | {
|
|
322
317
|
type: "reasoning";
|
|
323
318
|
text: string;
|
|
@@ -326,6 +321,11 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
326
321
|
provider: string;
|
|
327
322
|
data: Record<string, import("zod").JSONType>;
|
|
328
323
|
} | undefined;
|
|
324
|
+
} | {
|
|
325
|
+
type: "file";
|
|
326
|
+
mediaType: string;
|
|
327
|
+
reference: string;
|
|
328
|
+
filename?: string | undefined;
|
|
329
329
|
} | {
|
|
330
330
|
type: "source";
|
|
331
331
|
sourceId: string;
|
|
@@ -8,6 +8,11 @@ export declare function userMessage(conversationId: string, id: string): {
|
|
|
8
8
|
parts: ({
|
|
9
9
|
type: "text";
|
|
10
10
|
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "file";
|
|
13
|
+
mediaType: string;
|
|
14
|
+
reference: string;
|
|
15
|
+
filename?: string | undefined;
|
|
11
16
|
} | {
|
|
12
17
|
type: "reasoning";
|
|
13
18
|
text: string;
|
|
@@ -16,11 +21,6 @@ export declare function userMessage(conversationId: string, id: string): {
|
|
|
16
21
|
provider: string;
|
|
17
22
|
data: Record<string, import("zod").JSONType>;
|
|
18
23
|
} | undefined;
|
|
19
|
-
} | {
|
|
20
|
-
type: "file";
|
|
21
|
-
mediaType: string;
|
|
22
|
-
reference: string;
|
|
23
|
-
filename?: string | undefined;
|
|
24
24
|
} | {
|
|
25
25
|
type: "source";
|
|
26
26
|
sourceId: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RealtimeContract, RealtimeEventRegistry } from '../realtime/contract.js';
|
|
2
|
+
import type { RealtimeClient, RealtimeClientOptions, SocketEventMap, SocketIOClient, SocketIOClientConfig } from './socket-io-contract.js';
|
|
3
|
+
import { type IoFn } from './socket-io-peer.js';
|
|
4
|
+
export declare function createRealtimeClientWithPeer<const TServerToClient extends RealtimeEventRegistry, const TClientToServer extends RealtimeEventRegistry>(contract: RealtimeContract<TServerToClient, TClientToServer>, { onRejected, logger, onRequestPhase, ...config }: RealtimeClientOptions<TServerToClient>, defaultIo: () => Promise<IoFn>): RealtimeClient<TServerToClient, TClientToServer>;
|
|
5
|
+
export declare function createSocketIOClientWithPeer<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap>(config: SocketIOClientConfig<TServerEvents>, defaultIo: () => Promise<IoFn>): SocketIOClient<TServerEvents, TClientEvents>;
|
|
6
|
+
//# sourceMappingURL=socket-io-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-io-client.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAcpF,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAoB,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAK/D,wBAAgB,4BAA4B,CAC1C,KAAK,CAAC,eAAe,SAAS,qBAAqB,EACnD,KAAK,CAAC,eAAe,SAAS,qBAAqB,EAEnD,QAAQ,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,EAC5D,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,EAAE,qBAAqB,CAAC,eAAe,CAAC,EACzF,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC7B,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAelD;AAED,wBAAgB,4BAA4B,CAC1C,aAAa,SAAS,cAAc,EACpC,aAAa,SAAS,cAAc,EAEpC,MAAM,EAAE,oBAAoB,CAAC,aAAa,CAAC,EAC3C,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC7B,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,CAE9C"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { RealtimeEventRegistry } from '../realtime/contract.js';
|
|
2
|
+
import type { RealtimeRequestOptions, RealtimeRequestPhaseHook } from '../realtime/request.js';
|
|
3
|
+
import type { BindRealtimeClientOptions, BoundRealtimeClient } from './realtime-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* A literal optional Socket.IO peer loader owned by the consuming bundle.
|
|
6
|
+
* Root clients may omit it and use lazy runtime resolution; `stitchkit/realtime`
|
|
7
|
+
* requires it so its graph is compilable by Hermes without a computed import.
|
|
8
|
+
*/
|
|
9
|
+
export interface SocketIOClientPeerLoaders {
|
|
10
|
+
/**
|
|
11
|
+
* `() => import('socket.io-client')`.
|
|
12
|
+
*
|
|
13
|
+
* Typed as `unknown` and shape-checked where it is used — the same reason
|
|
14
|
+
* `SocketIOPeerLoaders.bunEngine` is. The root `stitchkit` entry is the
|
|
15
|
+
* browser-safe one, and its declarations must not name `socket.io-client`:
|
|
16
|
+
* a consumer who imports `createClient` and never opens a socket would then
|
|
17
|
+
* need the package installed just to TYPECHECK, which the consumer-lane peer
|
|
18
|
+
* budget refuses by name. The loader is still written the obvious way; only
|
|
19
|
+
* the type of what it returns is checked at the boundary rather than here,
|
|
20
|
+
* and a loader that returns the wrong module is refused by name at runtime.
|
|
21
|
+
*/
|
|
22
|
+
client?: () => Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Socket.IO event map — `{ event: (...args) => void }`. Aliases Socket.IO's
|
|
26
|
+
* own event-map constraint, which intentionally maps to `any`: that is what
|
|
27
|
+
* lets a plain `interface ServerToClientEvents { … }` (no index signature) be
|
|
28
|
+
* passed as a type argument. The constraint lives here instead of importing
|
|
29
|
+
* Socket.IO's equivalent: the root HTTP client declarations must remain usable
|
|
30
|
+
* when no optional Socket.IO peer is installed. Per-event typing is fully
|
|
31
|
+
* preserved on the public `on` / `emit` signatures.
|
|
32
|
+
*/
|
|
33
|
+
export interface SocketEventMap {
|
|
34
|
+
[event: string]: any;
|
|
35
|
+
}
|
|
36
|
+
export interface SocketIOClientConfig<TServerEvents extends SocketEventMap = SocketEventMap> {
|
|
37
|
+
/** Server origin, e.g. `https://api.example.com`. */
|
|
38
|
+
url: string;
|
|
39
|
+
/** Socket.IO endpoint path. Default `/socket.io/`. */
|
|
40
|
+
path?: string;
|
|
41
|
+
/** Send cookies on the handshake (cookie-based auth). Default `true`. */
|
|
42
|
+
withCredentials?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Handshake auth payload — token-based auth, the alternative to cookie auth
|
|
45
|
+
* (`withCredentials`). Reaches the server as `socket.handshake.auth`. A
|
|
46
|
+
* **function** is re-read on every (re)connect, so a rotated token is picked
|
|
47
|
+
* up automatically — no need to recreate the client (and lose durable
|
|
48
|
+
* subscriptions). The function may be async.
|
|
49
|
+
*/
|
|
50
|
+
auth?: Record<string, unknown> | (() => Record<string, unknown> | Promise<Record<string, unknown>>);
|
|
51
|
+
/** Extra query params on the handshake URL — reaches `socket.handshake.query`. */
|
|
52
|
+
query?: Record<string, string | number | boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Extra handshake headers. In a browser these apply to the **polling**
|
|
55
|
+
* transport only — a WebSocket upgrade cannot set request headers, so for
|
|
56
|
+
* browser WebSocket auth use `auth` instead. Useful from non-browser clients
|
|
57
|
+
* (Node/Bun server-to-server) where headers are honoured on every transport.
|
|
58
|
+
*/
|
|
59
|
+
extraHeaders?: Record<string, string>;
|
|
60
|
+
/** Transports, in preference order. Default `['websocket', 'polling']`. */
|
|
61
|
+
transports?: Array<'websocket' | 'polling'>;
|
|
62
|
+
/** Reconnection attempts. Default `Infinity`. */
|
|
63
|
+
reconnectionAttempts?: number;
|
|
64
|
+
/** Initial reconnection delay (ms). Default `1000`. */
|
|
65
|
+
reconnectionDelay?: number;
|
|
66
|
+
/** Max reconnection delay (ms). Default `5000`. */
|
|
67
|
+
reconnectionDelayMax?: number;
|
|
68
|
+
/** Connection timeout (ms). Default `20000`. */
|
|
69
|
+
timeout?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Survive a **server-initiated** disconnect. When the server drops the socket
|
|
72
|
+
* (`socket.disconnect()` server-side, reason `io server disconnect`) Socket.IO
|
|
73
|
+
* does **not** auto-reconnect — by design the client is meant to stay down.
|
|
74
|
+
* That silently kills a long-lived client after a backend restart or an
|
|
75
|
+
* auth-gate drop: the WebSocket is gone for good and nothing recovers it.
|
|
76
|
+
*
|
|
77
|
+
* With this set, the client recycles itself instead — after the given delay it
|
|
78
|
+
* reconnects on the same socket, which re-reads the `auth` function (so a
|
|
79
|
+
* rotated token is picked up automatically, exactly like an ordinary
|
|
80
|
+
* reconnect). Other disconnect reasons (`transport close`, `ping timeout`, …)
|
|
81
|
+
* are untouched — Socket.IO's own reconnection already handles those.
|
|
82
|
+
*
|
|
83
|
+
* Set `false` to keep Socket.IO's default (stay disconnected). Default `1000` ms.
|
|
84
|
+
*/
|
|
85
|
+
reconnectOnServerDisconnect?: number | false;
|
|
86
|
+
/**
|
|
87
|
+
* Server → client events to **retain** ("sticky events"). The client keeps the
|
|
88
|
+
* last payload of each listed event and replays it to any handler subscribed
|
|
89
|
+
* afterwards (and on the next subscribe after a re-render), so a late
|
|
90
|
+
* subscriber catches up to the current state at once instead of waiting for the
|
|
91
|
+
* next emission. The retained value survives a `disconnect()` / `connect()`
|
|
92
|
+
* cycle. Only the first emitted argument of an event is retained.
|
|
93
|
+
*/
|
|
94
|
+
retain?: Array<keyof TServerEvents & string>;
|
|
95
|
+
/**
|
|
96
|
+
* Observe handshake/connection failures (`connect_error`). `terminal: true`
|
|
97
|
+
* means socket.io will NOT retry on its own — that is how a server-side
|
|
98
|
+
* handshake gate rejection (`io.use` middleware / the stitchkit `handshake`
|
|
99
|
+
* option, `data.code === 'handshake_rejected'`) arrives, unlike a
|
|
100
|
+
* transport-level failure which keeps retrying. On a terminal error the
|
|
101
|
+
* client resets its connection intent, so a later `connect()` starts a fresh
|
|
102
|
+
* attempt and re-reads a function-form `auth` — the recovery path after
|
|
103
|
+
* rotating a rejected token. For transport-level failures (server down) the
|
|
104
|
+
* hook fires once **per retry attempt** — debounce before wiring it to
|
|
105
|
+
* user-facing alerts.
|
|
106
|
+
*/
|
|
107
|
+
onConnectError?: (error: {
|
|
108
|
+
message: string;
|
|
109
|
+
data?: unknown;
|
|
110
|
+
terminal: boolean;
|
|
111
|
+
}) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Observe every emit dropped because the socket was disconnected (the
|
|
114
|
+
* central alternative to guarding each call with `connected`). Receives the
|
|
115
|
+
* **wire** arguments — for a validated `RealtimeClient` that is the
|
|
116
|
+
* Zod-parsed values plus the wrapped ack callback, not the caller's original
|
|
117
|
+
* arguments. The drop itself is also reported by `emit` returning `false`.
|
|
118
|
+
*/
|
|
119
|
+
onDroppedEmit?: (dropped: {
|
|
120
|
+
event: string;
|
|
121
|
+
args: unknown[];
|
|
122
|
+
}) => void;
|
|
123
|
+
/**
|
|
124
|
+
* How to load the optional `socket.io-client` peer. Omit it and the peer is
|
|
125
|
+
* resolved lazily, exactly as before — this exists for a consumer who ships
|
|
126
|
+
* one self-contained artifact and needs the specifier to be a literal their
|
|
127
|
+
* own bundler can follow. → `SocketIOClientPeerLoaders`
|
|
128
|
+
*/
|
|
129
|
+
peers?: SocketIOClientPeerLoaders;
|
|
130
|
+
}
|
|
131
|
+
export interface SocketIOClient<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap> {
|
|
132
|
+
/** Create the socket (if absent) and connect. Idempotent. */
|
|
133
|
+
connect(): void;
|
|
134
|
+
/** Disconnect and drop the socket instance. */
|
|
135
|
+
disconnect(): void;
|
|
136
|
+
/** True while the underlying socket is connected. */
|
|
137
|
+
readonly connected: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Subscribe to a server → client event. Returns an unsubscribe. The handler
|
|
140
|
+
* is durable — it is re-attached onto every socket the client builds, so it
|
|
141
|
+
* survives a `disconnect()` / `connect()` cycle.
|
|
142
|
+
*/
|
|
143
|
+
on<E extends keyof TServerEvents & string>(event: E, handler: TServerEvents[E]): () => void;
|
|
144
|
+
/**
|
|
145
|
+
* Emit a client → server event. Returns `true` when the event was handed to
|
|
146
|
+
* the transport (not a delivery guarantee) and `false` when it was dropped
|
|
147
|
+
* because the socket is disconnected — including the window while the lazy
|
|
148
|
+
* peer is still loading right after `connect()`. A drop also fires the
|
|
149
|
+
* `onDroppedEmit` hook. The default stays a drop (no buffering): after a
|
|
150
|
+
* reconnect the durable subscriptions replay state deterministically instead
|
|
151
|
+
* of an unordered backlog of stale emits.
|
|
152
|
+
*/
|
|
153
|
+
emit<E extends keyof TClientEvents & string>(event: E, ...args: Parameters<TClientEvents[E]>): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Low-level native Socket.IO acknowledgement request. Contract-aware callers
|
|
156
|
+
* should use `createRealtimeClient().request()`, which validates both sides.
|
|
157
|
+
*/
|
|
158
|
+
emitWithAck(event: string, args: unknown[], options: RealtimeRequestOptions): Promise<unknown>;
|
|
159
|
+
/**
|
|
160
|
+
* Subscribe to connection up/down changes. Returns an unsubscribe. On a
|
|
161
|
+
* disconnect the listener also receives the Socket.IO **reason** (e.g.
|
|
162
|
+
* `io server disconnect`, `transport close`, `ping timeout`) as a second
|
|
163
|
+
* argument — `undefined` on connect. The extra argument is additive: a
|
|
164
|
+
* `(connected: boolean) => void` listener keeps working unchanged.
|
|
165
|
+
*/
|
|
166
|
+
onConnectionChange(listener: (connected: boolean, reason?: string) => void): () => void;
|
|
167
|
+
}
|
|
168
|
+
/** Minimal Stitchkit client transport required by a validated realtime binding. */
|
|
169
|
+
export interface RealtimeClient<TServerToClient extends RealtimeEventRegistry, TClientToServer extends RealtimeEventRegistry> extends BoundRealtimeClient<TServerToClient, TClientToServer> {
|
|
170
|
+
connect(): void;
|
|
171
|
+
disconnect(): void;
|
|
172
|
+
}
|
|
173
|
+
export interface RealtimeClientOptions<TServerToClient extends RealtimeEventRegistry> extends BindRealtimeClientOptions, SocketIOClientConfig<{
|
|
174
|
+
[TEvent in keyof TServerToClient]: (...args: unknown[]) => void;
|
|
175
|
+
}> {
|
|
176
|
+
/**
|
|
177
|
+
* Observe bounded metadata-only phases of acknowledged requests. Engine.IO
|
|
178
|
+
* phases are local encoder/decoder boundaries, not remote send time or RTT.
|
|
179
|
+
* Observer failures are isolated from request lifecycle.
|
|
180
|
+
*/
|
|
181
|
+
onRequestPhase?: RealtimeRequestPhaseHook;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=socket-io-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-io-contract.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io-contract.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-io-default-peer.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io-default-peer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAa7C,wBAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RealtimeContract, RealtimeEventRegistry } from '../realtime/contract.js';
|
|
2
|
+
import type { RealtimeClient, RealtimeClientOptions, SocketEventMap, SocketIOClient, SocketIOClientConfig, SocketIOClientPeerLoaders } from './socket-io-contract.js';
|
|
3
|
+
export type { RealtimeClient, RealtimeClientOptions, SocketEventMap, SocketIOClient, SocketIOClientConfig, SocketIOClientPeerLoaders, } from './socket-io-contract.js';
|
|
4
|
+
/** Create a validated realtime client with durable subscriptions and typed requests. */
|
|
5
|
+
export declare function createRealtimeClient<const TServerToClient extends RealtimeEventRegistry, const TClientToServer extends RealtimeEventRegistry>(contract: RealtimeContract<TServerToClient, TClientToServer>, config: RealtimeClientOptions<TServerToClient> & {
|
|
6
|
+
peers: Required<SocketIOClientPeerLoaders>;
|
|
7
|
+
}): RealtimeClient<TServerToClient, TClientToServer>;
|
|
8
|
+
/** Create the shared Socket.IO transport with durable subscriptions and explicit connection intent. */
|
|
9
|
+
export declare function createSocketIOClient<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap>(config: SocketIOClientConfig<TServerEvents> & {
|
|
10
|
+
peers: Required<SocketIOClientPeerLoaders>;
|
|
11
|
+
}): SocketIOClient<TServerEvents, TClientEvents>;
|
|
12
|
+
//# sourceMappingURL=socket-io-explicit-peer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-io-explicit-peer.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io-explicit-peer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAKpF,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAS9B,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,KAAK,CAAC,eAAe,SAAS,qBAAqB,EACnD,KAAK,CAAC,eAAe,SAAS,qBAAqB,EAEnD,QAAQ,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,EAC5D,MAAM,EAAE,qBAAqB,CAAC,eAAe,CAAC,GAAG;IAC/C,KAAK,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC;CAC5C,GACA,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAElD;AAED,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,aAAa,SAAS,cAAc,EACpC,aAAa,SAAS,cAAc,EAEpC,MAAM,EAAE,oBAAoB,CAAC,aAAa,CAAC,GAAG;IAAE,KAAK,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAA;CAAE,GAC3F,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,CAE9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SocketIOClientPeerLoaders } from './socket-io.js';
|
|
1
|
+
import type { SocketIOClientPeerLoaders } from './socket-io-contract.js';
|
|
2
2
|
export type IoFn = typeof import('socket.io-client')['io'];
|
|
3
3
|
/**
|
|
4
4
|
* One client's way of getting to `io`, memoised.
|
|
@@ -7,14 +7,5 @@ export type IoFn = typeof import('socket.io-client')['io'];
|
|
|
7
7
|
* process may legitimately be built by different bundles, and one of them
|
|
8
8
|
* winning a shared slot would decide which module the other uses.
|
|
9
9
|
*/
|
|
10
|
-
export declare function createIoResolver(injected: SocketIOClientPeerLoaders['client']): () => Promise<IoFn>;
|
|
11
|
-
/**
|
|
12
|
-
* Adapt our friendly `auth` form to what `io()` expects. socket.io's function
|
|
13
|
-
* form is callback-based (`(cb) => cb(payload)`) and called on every (re)connect;
|
|
14
|
-
* we accept a plain sync/async producer and bridge it to that callback. If the
|
|
15
|
-
* producer fails, send an empty auth object rather than leaving the handshake
|
|
16
|
-
* waiting forever; a normal server-side auth gate will reject it. Object /
|
|
17
|
-
* `undefined` pass straight through. No casts: socket.io types `auth` as
|
|
18
|
-
* `{ [k]: any } | ((cb: (data: object) => void) => void)`.
|
|
19
|
-
*/
|
|
10
|
+
export declare function createIoResolver(injected: SocketIOClientPeerLoaders['client'], defaultIo: () => Promise<IoFn>): () => Promise<IoFn>;
|
|
20
11
|
//# sourceMappingURL=socket-io-peer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-io-peer.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io-peer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"socket-io-peer.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io-peer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,MAAM,IAAI,GAAG,cAAc,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC;AAc3D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,yBAAyB,CAAC,QAAQ,CAAC,EAC7C,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC7B,MAAM,OAAO,CAAC,IAAI,CAAC,CA2CrB"}
|
|
@@ -1,227 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed Socket.IO client — the family WebSocket client.
|
|
3
|
-
*
|
|
4
|
-
* The whole family runs on Socket.IO (`polling` fallback, heartbeat, acks,
|
|
5
|
-
* mature reconnection) — not a hand-rolled WebSocket. Every project copied the
|
|
6
|
-
* same ~150-line client: `io()` config, connection-state machine, a typed
|
|
7
|
-
* `on/emit`, a connection-change subscription. `createSocketIOClient` is that
|
|
8
|
-
* shared kernel.
|
|
9
|
-
*
|
|
10
|
-
* Subscriptions are durable: `on()` registers a handler once and the client
|
|
11
|
-
* re-attaches it onto every socket it builds — so a handler survives an
|
|
12
|
-
* explicit `disconnect()` / `connect()` cycle, and (because re-attach happens
|
|
13
|
-
* before `socket.connect()`) no handshake-time event is ever missed. A thin
|
|
14
|
-
* per-project layer can therefore subscribe once at construction.
|
|
15
|
-
*
|
|
16
|
-
* Auth identity (`userId`, `clientId`) is project-specific — it arrives in an
|
|
17
|
-
* app `authenticated` event — so it stays in that per-project layer on top.
|
|
18
|
-
* This client owns only the transport: connection lifecycle + typed events.
|
|
19
|
-
*
|
|
20
|
-
* The returned client satisfies `CacheBridgeSocket` (`on()` returns an
|
|
21
|
-
* unsubscribe), so it plugs straight into `createCacheBridge`.
|
|
22
|
-
*/
|
|
23
1
|
import type { RealtimeContract, RealtimeEventRegistry } from '../realtime/contract.js';
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* The mirror of `SocketIOPeerLoaders` on the server, and for the same reason.
|
|
30
|
-
* The specifier above is a variable, so no bundler can follow it — by
|
|
31
|
-
* construction, not by accident. A consumer who ships one self-contained file
|
|
32
|
-
* to a machine with no `node_modules` therefore had no way to get
|
|
33
|
-
* `socket.io-client` into the artifact, and learned about it at the first
|
|
34
|
-
* `connect()` rather than at build time. The only workaround was patching
|
|
35
|
-
* stitchkit's built `dist`, which breaks whenever its internal layout moves —
|
|
36
|
-
* exactly the dead end the server half was added to close.
|
|
37
|
-
*
|
|
38
|
-
* Passing a loader puts the literal in the CONSUMER's source, where their own
|
|
39
|
-
* bundler sees it statically and includes the package:
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* createSocketIOClient({
|
|
43
|
-
* url,
|
|
44
|
-
* peers: { client: () => import('socket.io-client') },
|
|
45
|
-
* })
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* A function rather than an already-resolved module, so laziness is unchanged:
|
|
49
|
-
* a project that never opens a socket still never loads it.
|
|
50
|
-
*/
|
|
51
|
-
export interface SocketIOClientPeerLoaders {
|
|
52
|
-
/**
|
|
53
|
-
* `() => import('socket.io-client')`.
|
|
54
|
-
*
|
|
55
|
-
* Typed as `unknown` and shape-checked where it is used — the same reason
|
|
56
|
-
* `SocketIOPeerLoaders.bunEngine` is. The root `stitchkit` entry is the
|
|
57
|
-
* browser-safe one, and its declarations must not name `socket.io-client`:
|
|
58
|
-
* a consumer who imports `createClient` and never opens a socket would then
|
|
59
|
-
* need the package installed just to TYPECHECK, which the consumer-lane peer
|
|
60
|
-
* budget refuses by name. The loader is still written the obvious way; only
|
|
61
|
-
* the type of what it returns is checked at the boundary rather than here,
|
|
62
|
-
* and a loader that returns the wrong module is refused by name at runtime.
|
|
63
|
-
*/
|
|
64
|
-
client?: () => Promise<unknown>;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Socket.IO event map — `{ event: (...args) => void }`. Aliases Socket.IO's
|
|
68
|
-
* own event-map constraint, which intentionally maps to `any`: that is what
|
|
69
|
-
* lets a plain `interface ServerToClientEvents { … }` (no index signature) be
|
|
70
|
-
* passed as a type argument. The constraint lives here instead of importing
|
|
71
|
-
* Socket.IO's equivalent: the root HTTP client declarations must remain usable
|
|
72
|
-
* when no optional Socket.IO peer is installed. Per-event typing is fully
|
|
73
|
-
* preserved on the public `on` / `emit` signatures.
|
|
74
|
-
*/
|
|
75
|
-
export interface SocketEventMap {
|
|
76
|
-
[event: string]: any;
|
|
77
|
-
}
|
|
78
|
-
export interface SocketIOClientConfig<TServerEvents extends SocketEventMap = SocketEventMap> {
|
|
79
|
-
/** Server origin, e.g. `https://api.example.com`. */
|
|
80
|
-
url: string;
|
|
81
|
-
/** Socket.IO endpoint path. Default `/socket.io/`. */
|
|
82
|
-
path?: string;
|
|
83
|
-
/** Send cookies on the handshake (cookie-based auth). Default `true`. */
|
|
84
|
-
withCredentials?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Handshake auth payload — token-based auth, the alternative to cookie auth
|
|
87
|
-
* (`withCredentials`). Reaches the server as `socket.handshake.auth`. A
|
|
88
|
-
* **function** is re-read on every (re)connect, so a rotated token is picked
|
|
89
|
-
* up automatically — no need to recreate the client (and lose durable
|
|
90
|
-
* subscriptions). The function may be async.
|
|
91
|
-
*/
|
|
92
|
-
auth?: Record<string, unknown> | (() => Record<string, unknown> | Promise<Record<string, unknown>>);
|
|
93
|
-
/** Extra query params on the handshake URL — reaches `socket.handshake.query`. */
|
|
94
|
-
query?: Record<string, string | number | boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Extra handshake headers. In a browser these apply to the **polling**
|
|
97
|
-
* transport only — a WebSocket upgrade cannot set request headers, so for
|
|
98
|
-
* browser WebSocket auth use `auth` instead. Useful from non-browser clients
|
|
99
|
-
* (Node/Bun server-to-server) where headers are honoured on every transport.
|
|
100
|
-
*/
|
|
101
|
-
extraHeaders?: Record<string, string>;
|
|
102
|
-
/** Transports, in preference order. Default `['websocket', 'polling']`. */
|
|
103
|
-
transports?: Array<'websocket' | 'polling'>;
|
|
104
|
-
/** Reconnection attempts. Default `Infinity`. */
|
|
105
|
-
reconnectionAttempts?: number;
|
|
106
|
-
/** Initial reconnection delay (ms). Default `1000`. */
|
|
107
|
-
reconnectionDelay?: number;
|
|
108
|
-
/** Max reconnection delay (ms). Default `5000`. */
|
|
109
|
-
reconnectionDelayMax?: number;
|
|
110
|
-
/** Connection timeout (ms). Default `20000`. */
|
|
111
|
-
timeout?: number;
|
|
112
|
-
/**
|
|
113
|
-
* Survive a **server-initiated** disconnect. When the server drops the socket
|
|
114
|
-
* (`socket.disconnect()` server-side, reason `io server disconnect`) Socket.IO
|
|
115
|
-
* does **not** auto-reconnect — by design the client is meant to stay down.
|
|
116
|
-
* That silently kills a long-lived client after a backend restart or an
|
|
117
|
-
* auth-gate drop: the WebSocket is gone for good and nothing recovers it.
|
|
118
|
-
*
|
|
119
|
-
* With this set, the client recycles itself instead — after the given delay it
|
|
120
|
-
* reconnects on the same socket, which re-reads the `auth` function (so a
|
|
121
|
-
* rotated token is picked up automatically, exactly like an ordinary
|
|
122
|
-
* reconnect). Other disconnect reasons (`transport close`, `ping timeout`, …)
|
|
123
|
-
* are untouched — Socket.IO's own reconnection already handles those.
|
|
124
|
-
*
|
|
125
|
-
* Set `false` to keep Socket.IO's default (stay disconnected). Default `1000` ms.
|
|
126
|
-
*/
|
|
127
|
-
reconnectOnServerDisconnect?: number | false;
|
|
128
|
-
/**
|
|
129
|
-
* Server → client events to **retain** ("sticky events"). The client keeps the
|
|
130
|
-
* last payload of each listed event and replays it to any handler subscribed
|
|
131
|
-
* afterwards (and on the next subscribe after a re-render), so a late
|
|
132
|
-
* subscriber catches up to the current state at once instead of waiting for the
|
|
133
|
-
* next emission. The retained value survives a `disconnect()` / `connect()`
|
|
134
|
-
* cycle. Only the first emitted argument of an event is retained.
|
|
135
|
-
*/
|
|
136
|
-
retain?: Array<keyof TServerEvents & string>;
|
|
137
|
-
/**
|
|
138
|
-
* Observe handshake/connection failures (`connect_error`). `terminal: true`
|
|
139
|
-
* means socket.io will NOT retry on its own — that is how a server-side
|
|
140
|
-
* handshake gate rejection (`io.use` middleware / the stitchkit `handshake`
|
|
141
|
-
* option, `data.code === 'handshake_rejected'`) arrives, unlike a
|
|
142
|
-
* transport-level failure which keeps retrying. On a terminal error the
|
|
143
|
-
* client resets its connection intent, so a later `connect()` starts a fresh
|
|
144
|
-
* attempt and re-reads a function-form `auth` — the recovery path after
|
|
145
|
-
* rotating a rejected token. For transport-level failures (server down) the
|
|
146
|
-
* hook fires once **per retry attempt** — debounce before wiring it to
|
|
147
|
-
* user-facing alerts.
|
|
148
|
-
*/
|
|
149
|
-
onConnectError?: (error: {
|
|
150
|
-
message: string;
|
|
151
|
-
data?: unknown;
|
|
152
|
-
terminal: boolean;
|
|
153
|
-
}) => void;
|
|
154
|
-
/**
|
|
155
|
-
* Observe every emit dropped because the socket was disconnected (the
|
|
156
|
-
* central alternative to guarding each call with `connected`). Receives the
|
|
157
|
-
* **wire** arguments — for a validated `RealtimeClient` that is the
|
|
158
|
-
* Zod-parsed values plus the wrapped ack callback, not the caller's original
|
|
159
|
-
* arguments. The drop itself is also reported by `emit` returning `false`.
|
|
160
|
-
*/
|
|
161
|
-
onDroppedEmit?: (dropped: {
|
|
162
|
-
event: string;
|
|
163
|
-
args: unknown[];
|
|
164
|
-
}) => void;
|
|
165
|
-
/**
|
|
166
|
-
* How to load the optional `socket.io-client` peer. Omit it and the peer is
|
|
167
|
-
* resolved lazily, exactly as before — this exists for a consumer who ships
|
|
168
|
-
* one self-contained artifact and needs the specifier to be a literal their
|
|
169
|
-
* own bundler can follow. → `SocketIOClientPeerLoaders`
|
|
170
|
-
*/
|
|
171
|
-
peers?: SocketIOClientPeerLoaders;
|
|
172
|
-
}
|
|
173
|
-
export interface SocketIOClient<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap> {
|
|
174
|
-
/** Create the socket (if absent) and connect. Idempotent. */
|
|
175
|
-
connect(): void;
|
|
176
|
-
/** Disconnect and drop the socket instance. */
|
|
177
|
-
disconnect(): void;
|
|
178
|
-
/** True while the underlying socket is connected. */
|
|
179
|
-
readonly connected: boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Subscribe to a server → client event. Returns an unsubscribe. The handler
|
|
182
|
-
* is durable — it is re-attached onto every socket the client builds, so it
|
|
183
|
-
* survives a `disconnect()` / `connect()` cycle.
|
|
184
|
-
*/
|
|
185
|
-
on<E extends keyof TServerEvents & string>(event: E, handler: TServerEvents[E]): () => void;
|
|
186
|
-
/**
|
|
187
|
-
* Emit a client → server event. Returns `true` when the event was handed to
|
|
188
|
-
* the transport (not a delivery guarantee) and `false` when it was dropped
|
|
189
|
-
* because the socket is disconnected — including the window while the lazy
|
|
190
|
-
* peer is still loading right after `connect()`. A drop also fires the
|
|
191
|
-
* `onDroppedEmit` hook. The default stays a drop (no buffering): after a
|
|
192
|
-
* reconnect the durable subscriptions replay state deterministically instead
|
|
193
|
-
* of an unordered backlog of stale emits.
|
|
194
|
-
*/
|
|
195
|
-
emit<E extends keyof TClientEvents & string>(event: E, ...args: Parameters<TClientEvents[E]>): boolean;
|
|
196
|
-
/**
|
|
197
|
-
* Low-level native Socket.IO acknowledgement request. Contract-aware callers
|
|
198
|
-
* should use `createRealtimeClient().request()`, which validates both sides.
|
|
199
|
-
*/
|
|
200
|
-
emitWithAck(event: string, args: unknown[], options: RealtimeRequestOptions): Promise<unknown>;
|
|
201
|
-
/**
|
|
202
|
-
* Subscribe to connection up/down changes. Returns an unsubscribe. On a
|
|
203
|
-
* disconnect the listener also receives the Socket.IO **reason** (e.g.
|
|
204
|
-
* `io server disconnect`, `transport close`, `ping timeout`) as a second
|
|
205
|
-
* argument — `undefined` on connect. The extra argument is additive: a
|
|
206
|
-
* `(connected: boolean) => void` listener keeps working unchanged.
|
|
207
|
-
*/
|
|
208
|
-
onConnectionChange(listener: (connected: boolean, reason?: string) => void): () => void;
|
|
209
|
-
}
|
|
210
|
-
/** Minimal Stitchkit client transport required by a validated realtime binding. */
|
|
211
|
-
export interface RealtimeClient<TServerToClient extends RealtimeEventRegistry, TClientToServer extends RealtimeEventRegistry> extends BoundRealtimeClient<TServerToClient, TClientToServer> {
|
|
212
|
-
connect(): void;
|
|
213
|
-
disconnect(): void;
|
|
214
|
-
}
|
|
215
|
-
export interface RealtimeClientOptions<TServerToClient extends RealtimeEventRegistry> extends BindRealtimeClientOptions, SocketIOClientConfig<{
|
|
216
|
-
[TEvent in keyof TServerToClient]: (...args: unknown[]) => void;
|
|
217
|
-
}> {
|
|
218
|
-
/**
|
|
219
|
-
* Observe bounded metadata-only phases of acknowledged requests. Engine.IO
|
|
220
|
-
* phases are local encoder/decoder boundaries, not remote send time or RTT.
|
|
221
|
-
* Observer failures are isolated from request lifecycle.
|
|
222
|
-
*/
|
|
223
|
-
onRequestPhase?: RealtimeRequestPhaseHook;
|
|
224
|
-
}
|
|
225
|
-
export declare function createRealtimeClient<const TServerToClient extends RealtimeEventRegistry, const TClientToServer extends RealtimeEventRegistry>(contract: RealtimeContract<TServerToClient, TClientToServer>, { onRejected, logger, onRequestPhase, ...config }: RealtimeClientOptions<TServerToClient>): RealtimeClient<TServerToClient, TClientToServer>;
|
|
2
|
+
import type { RealtimeClient, RealtimeClientOptions, SocketEventMap, SocketIOClient, SocketIOClientConfig } from './socket-io-contract.js';
|
|
3
|
+
export type { RealtimeClient, RealtimeClientOptions, SocketEventMap, SocketIOClient, SocketIOClientConfig, SocketIOClientPeerLoaders, } from './socket-io-contract.js';
|
|
4
|
+
/** Create a validated realtime client with durable subscriptions and typed requests. */
|
|
5
|
+
export declare function createRealtimeClient<const TServerToClient extends RealtimeEventRegistry, const TClientToServer extends RealtimeEventRegistry>(contract: RealtimeContract<TServerToClient, TClientToServer>, config: RealtimeClientOptions<TServerToClient>): RealtimeClient<TServerToClient, TClientToServer>;
|
|
6
|
+
/** Create the shared Socket.IO transport with durable subscriptions and explicit connection intent. */
|
|
226
7
|
export declare function createSocketIOClient<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap>(config: SocketIOClientConfig<TServerEvents>): SocketIOClient<TServerEvents, TClientEvents>;
|
|
227
8
|
//# sourceMappingURL=socket-io.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-io.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"socket-io.d.ts","sourceRoot":"","sources":["../../src/browser/socket-io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAKpF,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAI9B,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,KAAK,CAAC,eAAe,SAAS,qBAAqB,EACnD,KAAK,CAAC,eAAe,SAAS,qBAAqB,EAEnD,QAAQ,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,EAC5D,MAAM,EAAE,qBAAqB,CAAC,eAAe,CAAC,GAC7C,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAElD;AAED,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,aAAa,SAAS,cAAc,EACpC,aAAa,SAAS,cAAc,EACpC,MAAM,EAAE,oBAAoB,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,CAE3F"}
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
AgentCodingToolAuthorizationSchema2,
|
|
7
7
|
AgentCodingToolPathAuthorizationSchema2,
|
|
8
8
|
createAgentCodingTools2
|
|
9
|
-
} from "../../index-
|
|
9
|
+
} from "../../index-tjdsyrys.js";
|
|
10
10
|
import"../../index-2kbysk9s.js";
|
|
11
11
|
import"../../index-84bf5spd.js";
|
|
12
12
|
import"../../index-8ks9b85e.js";
|
|
13
|
-
import"../../index-
|
|
13
|
+
import"../../index-e1sjcjfy.js";
|
|
14
14
|
import"../../index-zrtrjkbf.js";
|
|
15
15
|
import"../../index-636mggad.js";
|
|
16
16
|
export {
|
|
@@ -5,7 +5,7 @@ import"../../index-8kzct1d6.js";
|
|
|
5
5
|
import {
|
|
6
6
|
composeAgentPrompt2,
|
|
7
7
|
createAgentRuntime2
|
|
8
|
-
} from "../../index-
|
|
8
|
+
} from "../../index-924500c3.js";
|
|
9
9
|
import"../../index-qaet40b2.js";
|
|
10
10
|
import"../../index-mnkk1ffz.js";
|
|
11
11
|
import"../../index-fynr93w4.js";
|
|
@@ -13,7 +13,7 @@ import"../../index-t5sjh517.js";
|
|
|
13
13
|
import"../../index-cykxpxz5.js";
|
|
14
14
|
import"../../index-ct75c3at.js";
|
|
15
15
|
import"../../index-q6crhe1n.js";
|
|
16
|
-
import"../../index-
|
|
16
|
+
import"../../index-mha6b4vk.js";
|
|
17
17
|
import"../../index-c17xcx4k.js";
|
|
18
18
|
import"../../index-0gs4ymfj.js";
|
|
19
19
|
import"../../index-5w6t91ze.js";
|