stitchkit 0.48.1 → 0.49.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/README.md +1 -2
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/{index-ts21eyz4.js → index-fjfzsq6y.js} +243 -8
- package/dist/index.js +29 -0
- package/dist/node.d.ts +3 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +102 -12
- package/dist/server/bun.d.ts +7 -8
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +119 -6
- package/dist/server/node.d.ts +12 -13
- package/dist/server/node.d.ts.map +1 -1
- package/dist/server/shutdown.d.ts +76 -0
- package/dist/server/shutdown.d.ts.map +1 -0
- package/dist/server/socket-io-config.d.ts +5 -1
- package/dist/server/socket-io-config.d.ts.map +1 -1
- package/dist/server/socket-io-node.d.ts +4 -1
- package/dist/server/socket-io-node.d.ts.map +1 -1
- package/dist/server/socket-io.d.ts +12 -4
- package/dist/server/socket-io.d.ts.map +1 -1
- package/llms-full.txt +163 -27
- package/package.json +2 -1
package/dist/server/index.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ShutdownOptionsSchema,
|
|
3
|
+
ShutdownResultSchema,
|
|
4
|
+
ShutdownStateSchema,
|
|
5
|
+
ShutdownStatusSchema,
|
|
2
6
|
bindRealtimeServer,
|
|
3
7
|
composeWebSocketHandlers,
|
|
4
8
|
createHandler,
|
|
5
9
|
createImplement,
|
|
6
10
|
createImplementRegistry,
|
|
11
|
+
createServerLifecycle,
|
|
7
12
|
createSocketIOServer,
|
|
8
13
|
defineMultipartStream,
|
|
9
14
|
implement,
|
|
@@ -11,7 +16,7 @@ import {
|
|
|
11
16
|
parseMultipart,
|
|
12
17
|
socketIoLane,
|
|
13
18
|
webSocketLane
|
|
14
|
-
} from "../index-
|
|
19
|
+
} from "../index-fjfzsq6y.js";
|
|
15
20
|
import {
|
|
16
21
|
createAuthHook,
|
|
17
22
|
createBearerResolver,
|
|
@@ -67,16 +72,110 @@ import {
|
|
|
67
72
|
} from "../index-h05ygjqx.js";
|
|
68
73
|
// src/server/bun.ts
|
|
69
74
|
function createServer(config) {
|
|
70
|
-
const {
|
|
75
|
+
const {
|
|
76
|
+
websocket: configuredWebSocket,
|
|
77
|
+
socket,
|
|
78
|
+
development,
|
|
79
|
+
bun: bunExtra,
|
|
80
|
+
port = 3000,
|
|
81
|
+
hostname
|
|
82
|
+
} = config;
|
|
83
|
+
const socketRoutePrefix = socket?.route.path.replace(/\*socketPath$/, "");
|
|
84
|
+
const websocket = configuredWebSocket ?? socket?.websocket;
|
|
85
|
+
const openSockets = new Set;
|
|
86
|
+
let hadWebSockets = false;
|
|
87
|
+
const trackedWebSocket = websocket ? {
|
|
88
|
+
...websocket,
|
|
89
|
+
open(ws) {
|
|
90
|
+
hadWebSockets = true;
|
|
91
|
+
openSockets.add(ws);
|
|
92
|
+
websocket.open?.(ws);
|
|
93
|
+
},
|
|
94
|
+
close(ws, code, reason) {
|
|
95
|
+
openSockets.delete(ws);
|
|
96
|
+
websocket.close?.(ws, code, reason);
|
|
97
|
+
}
|
|
98
|
+
} : undefined;
|
|
99
|
+
let runtime;
|
|
100
|
+
const requireRuntime = () => {
|
|
101
|
+
if (!runtime)
|
|
102
|
+
throw new Error("[stitchkit] Bun server lifecycle started before Bun.serve");
|
|
103
|
+
return runtime;
|
|
104
|
+
};
|
|
105
|
+
const adapter = {
|
|
106
|
+
beginShutdown: () => socket?.beginShutdown(),
|
|
107
|
+
pendingRequests: () => runtime?.pendingRequests ?? 0,
|
|
108
|
+
pendingWebSockets: () => openSockets.size,
|
|
109
|
+
async closeRealtime() {
|
|
110
|
+
const logicalClose = socket?.close();
|
|
111
|
+
for (const ws of openSockets)
|
|
112
|
+
ws.close(1001, "Server shutting down");
|
|
113
|
+
await Promise.all([
|
|
114
|
+
logicalClose,
|
|
115
|
+
new Promise((resolve) => {
|
|
116
|
+
if (openSockets.size === 0) {
|
|
117
|
+
resolve();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const timer = setInterval(() => {
|
|
121
|
+
if (openSockets.size === 0) {
|
|
122
|
+
clearInterval(timer);
|
|
123
|
+
resolve();
|
|
124
|
+
}
|
|
125
|
+
}, 5);
|
|
126
|
+
})
|
|
127
|
+
]);
|
|
128
|
+
},
|
|
129
|
+
async stopGracefully() {
|
|
130
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
131
|
+
const server2 = requireRuntime();
|
|
132
|
+
if (server2.pendingRequests === 0 && openSockets.size === 0) {
|
|
133
|
+
const stopping = server2.stop(true);
|
|
134
|
+
if (!hadWebSockets)
|
|
135
|
+
await stopping;
|
|
136
|
+
else
|
|
137
|
+
stopping.catch(() => {
|
|
138
|
+
return;
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
await server2.stop(false);
|
|
143
|
+
},
|
|
144
|
+
async forceStop() {
|
|
145
|
+
for (const ws of openSockets)
|
|
146
|
+
ws.terminate();
|
|
147
|
+
openSockets.clear();
|
|
148
|
+
const stopping = requireRuntime().stop(true);
|
|
149
|
+
if (!hadWebSockets)
|
|
150
|
+
await stopping;
|
|
151
|
+
else
|
|
152
|
+
stopping.catch(() => {
|
|
153
|
+
return;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const lifecycle = createServerLifecycle(() => adapter);
|
|
71
158
|
const handler = createHandler(config);
|
|
72
|
-
const
|
|
73
|
-
|
|
159
|
+
const consumerFetch = config.wrapFetch ? config.wrapFetch(handler) : handler;
|
|
160
|
+
const admittedFetch = lifecycle.wrapFetch(consumerFetch);
|
|
161
|
+
const fetch = async (request, server2) => {
|
|
162
|
+
if (socket && socketRoutePrefix) {
|
|
163
|
+
const pathname = new URL(request.url).pathname;
|
|
164
|
+
if (pathname.startsWith(socketRoutePrefix)) {
|
|
165
|
+
return await socket.route.handler(request, {
|
|
166
|
+
params: { socketPath: pathname.slice(socketRoutePrefix.length) },
|
|
167
|
+
server: server2
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return admittedFetch(request, server2);
|
|
172
|
+
};
|
|
173
|
+
runtime = trackedWebSocket ? Bun.serve({
|
|
74
174
|
...bunExtra,
|
|
75
|
-
...routes && { routes },
|
|
76
175
|
...development && { development },
|
|
77
176
|
port,
|
|
78
177
|
hostname,
|
|
79
|
-
websocket,
|
|
178
|
+
websocket: trackedWebSocket,
|
|
80
179
|
fetch
|
|
81
180
|
}) : Bun.serve({
|
|
82
181
|
...bunExtra,
|
|
@@ -85,6 +184,16 @@ function createServer(config) {
|
|
|
85
184
|
hostname,
|
|
86
185
|
fetch
|
|
87
186
|
});
|
|
187
|
+
const server = runtime;
|
|
188
|
+
return {
|
|
189
|
+
url: server.url.toString().replace(/\/$/, ""),
|
|
190
|
+
port: server.port ?? port,
|
|
191
|
+
runtime: server,
|
|
192
|
+
get status() {
|
|
193
|
+
return lifecycle.status;
|
|
194
|
+
},
|
|
195
|
+
shutdown: lifecycle.shutdown
|
|
196
|
+
};
|
|
88
197
|
}
|
|
89
198
|
// src/server/swept-map.ts
|
|
90
199
|
function createSweptMap(options) {
|
|
@@ -849,6 +958,10 @@ export {
|
|
|
849
958
|
bindRealtimeServer,
|
|
850
959
|
badRequest,
|
|
851
960
|
appError,
|
|
961
|
+
ShutdownStatusSchema,
|
|
962
|
+
ShutdownStateSchema,
|
|
963
|
+
ShutdownResultSchema,
|
|
964
|
+
ShutdownOptionsSchema,
|
|
852
965
|
STITCH_ERROR_STATUS,
|
|
853
966
|
DEFAULT_CORS_EXPOSE_HEADERS,
|
|
854
967
|
DEFAULT_CORS_ALLOW_HEADERS,
|
package/dist/server/node.d.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import type { Server as HttpServer } from 'node:http';
|
|
2
|
+
import { serve } from 'srvx/node';
|
|
3
|
+
import { type ManagedServerHandle } from './shutdown';
|
|
2
4
|
import type { FetchComposition, HandlerConfig } from './types';
|
|
5
|
+
export interface NodeSocketLifecycle {
|
|
6
|
+
attach(server: HttpServer): void;
|
|
7
|
+
beginShutdown(): void;
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
connections(): number;
|
|
10
|
+
}
|
|
3
11
|
export interface NodeServerConfig extends HandlerConfig, FetchComposition {
|
|
4
12
|
port?: number;
|
|
5
13
|
hostname?: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
* `node:http.Server` (srvx `server.node.server`) once it is listening, so
|
|
9
|
-
* Socket.IO owns the HTTP `upgrade` event on the same port.
|
|
10
|
-
*/
|
|
11
|
-
socket?: {
|
|
12
|
-
attach(server: HttpServer): void;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface NodeServerHandle {
|
|
16
|
-
url: string;
|
|
17
|
-
port: number;
|
|
18
|
-
close(closeActive?: boolean): Promise<void>;
|
|
14
|
+
/** A full Socket.IO lifecycle from `createSocketIOServer`. */
|
|
15
|
+
socket?: NodeSocketLifecycle;
|
|
19
16
|
}
|
|
17
|
+
export type NodeRuntimeServer = ReturnType<typeof serve>;
|
|
18
|
+
export type NodeServerHandle = ManagedServerHandle<NodeRuntimeServer>;
|
|
20
19
|
export declare function serveNode(config: NodeServerConfig): Promise<NodeServerHandle>;
|
|
21
20
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/server/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/server/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAkB,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,aAAa,IAAI,IAAI,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,WAAW,IAAI,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,aAAa,EAAE,gBAAgB;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACzD,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;AAEtE,wBAAsB,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoHnF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { FetchHandler } from './types';
|
|
3
|
+
export declare const ShutdownStateSchema: z.ZodEnum<{
|
|
4
|
+
clean: "clean";
|
|
5
|
+
"closing-realtime": "closing-realtime";
|
|
6
|
+
"draining-http": "draining-http";
|
|
7
|
+
forced: "forced";
|
|
8
|
+
running: "running";
|
|
9
|
+
"stopping-runtime": "stopping-runtime";
|
|
10
|
+
}>;
|
|
11
|
+
export type ShutdownState = z.infer<typeof ShutdownStateSchema>;
|
|
12
|
+
export declare const ShutdownOptionsSchema: z.ZodObject<{
|
|
13
|
+
gracePeriodMs: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
retryAfterSeconds: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type ShutdownOptions = z.input<typeof ShutdownOptionsSchema>;
|
|
18
|
+
export declare const ShutdownStatusSchema: z.ZodObject<{
|
|
19
|
+
state: z.ZodEnum<{
|
|
20
|
+
clean: "clean";
|
|
21
|
+
"closing-realtime": "closing-realtime";
|
|
22
|
+
"draining-http": "draining-http";
|
|
23
|
+
forced: "forced";
|
|
24
|
+
running: "running";
|
|
25
|
+
"stopping-runtime": "stopping-runtime";
|
|
26
|
+
}>;
|
|
27
|
+
acceptedRequests: z.ZodNumber;
|
|
28
|
+
completedRequests: z.ZodNumber;
|
|
29
|
+
pendingRequests: z.ZodNumber;
|
|
30
|
+
pendingWebSockets: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type ShutdownStatus = z.infer<typeof ShutdownStatusSchema>;
|
|
33
|
+
export declare const ShutdownResultSchema: z.ZodObject<{
|
|
34
|
+
outcome: z.ZodEnum<{
|
|
35
|
+
clean: "clean";
|
|
36
|
+
forced: "forced";
|
|
37
|
+
}>;
|
|
38
|
+
reason: z.ZodOptional<z.ZodEnum<{
|
|
39
|
+
deadline: "deadline";
|
|
40
|
+
signal: "signal";
|
|
41
|
+
}>>;
|
|
42
|
+
acceptedRequests: z.ZodNumber;
|
|
43
|
+
completedRequests: z.ZodNumber;
|
|
44
|
+
pendingRequests: z.ZodNumber;
|
|
45
|
+
pendingWebSockets: z.ZodNumber;
|
|
46
|
+
pendingRequestsAtForce: z.ZodNumber;
|
|
47
|
+
pendingWebSocketsAtForce: z.ZodNumber;
|
|
48
|
+
abortedRequests: z.ZodNumber;
|
|
49
|
+
forcedWebSockets: z.ZodNumber;
|
|
50
|
+
durationMs: z.ZodNumber;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type ShutdownResult = z.infer<typeof ShutdownResultSchema>;
|
|
53
|
+
/** Shared lifecycle shape; only the explicit runtime escape hatch varies. */
|
|
54
|
+
export interface ManagedServerHandle<TRuntime> {
|
|
55
|
+
readonly url: string;
|
|
56
|
+
readonly port: number;
|
|
57
|
+
readonly runtime: TRuntime;
|
|
58
|
+
readonly status: ShutdownStatus;
|
|
59
|
+
shutdown(options?: ShutdownOptions): Promise<ShutdownResult>;
|
|
60
|
+
}
|
|
61
|
+
export interface ShutdownAdapter {
|
|
62
|
+
beginShutdown(retryAfterSeconds: number): void;
|
|
63
|
+
pendingRequests(): number;
|
|
64
|
+
pendingWebSockets(): number;
|
|
65
|
+
closeRealtime(): Promise<void>;
|
|
66
|
+
stopGracefully(): Promise<void>;
|
|
67
|
+
forceStop(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
interface ServerLifecycle {
|
|
70
|
+
wrapFetch<TServer>(handler: FetchHandler<TServer>): FetchHandler<TServer>;
|
|
71
|
+
readonly status: ShutdownStatus;
|
|
72
|
+
shutdown(options?: ShutdownOptions): Promise<ShutdownResult>;
|
|
73
|
+
}
|
|
74
|
+
export declare function createServerLifecycle(getAdapter: () => ShutdownAdapter): ServerLifecycle;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=shutdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/server/shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,mBAAmB;;;;;;;EAO9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,qBAAqB;;;;iBAahC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qB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8HxF"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Runtime-neutral Socket.IO configuration shared by Bun and Node adapters. */
|
|
2
2
|
import type { ServerOptions } from 'socket.io';
|
|
3
|
+
/** Runtime-neutral Engine.IO handshake policy, evaluated before shutdown admission. */
|
|
4
|
+
export type SocketIORequestPolicy = (request: Request) => boolean | Promise<boolean>;
|
|
3
5
|
export interface SocketIOServerConfig {
|
|
4
6
|
/** CORS — the browser origin(s) allowed to open a socket. */
|
|
5
7
|
cors: {
|
|
@@ -14,7 +16,9 @@ export interface SocketIOServerConfig {
|
|
|
14
16
|
pingTimeout?: number;
|
|
15
17
|
/** Heartbeat: ms between pings. */
|
|
16
18
|
pingInterval?: number;
|
|
19
|
+
/** Runtime-neutral policy for accepting a new Engine.IO handshake. */
|
|
20
|
+
allowRequest?: SocketIORequestPolicy;
|
|
17
21
|
/** Typed Socket.IO options not owned by this wrapper. */
|
|
18
|
-
serverOptions?: Partial<ServerOptions>;
|
|
22
|
+
serverOptions?: Omit<Partial<ServerOptions>, 'allowRequest'>;
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=socket-io-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-io-config.d.ts","sourceRoot":"","sources":["../../src/server/socket-io-config.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3D,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,UAAU,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IAC5C,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"socket-io-config.d.ts","sourceRoot":"","sources":["../../src/server/socket-io-config.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,uFAAuF;AACvF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAErF,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3D,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,UAAU,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IAC5C,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,yDAAyD;IACzD,aAAa,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC,CAAC;CAC9D"}
|
|
@@ -3,11 +3,14 @@ import type { Server as HttpServer } from 'node:http';
|
|
|
3
3
|
import type { Server as SocketIOServer } from 'socket.io';
|
|
4
4
|
import type { SocketEventMap } from '../browser/socket-io';
|
|
5
5
|
import type { SocketIOServerConfig } from './socket-io-config';
|
|
6
|
-
export type { SocketIOServerConfig } from './socket-io-config';
|
|
6
|
+
export type { SocketIORequestPolicy, SocketIOServerConfig } from './socket-io-config';
|
|
7
7
|
/** The runtime-neutral part of a Socket.IO handle used by `serveNode`. */
|
|
8
8
|
export interface NodeSocketIOServerHandle<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap> {
|
|
9
9
|
io: SocketIOServer<TClientEvents, TServerEvents>;
|
|
10
10
|
attach(server: HttpServer): void;
|
|
11
|
+
beginShutdown(): void;
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
connections(): number;
|
|
11
14
|
}
|
|
12
15
|
/** Create a Socket.IO handle typed only for the Node capabilities it exposes. */
|
|
13
16
|
export declare function createNodeSocketIOServer<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap>(config: SocketIOServerConfig): Promise<NodeSocketIOServerHandle<TServerEvents, TClientEvents>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-io-node.d.ts","sourceRoot":"","sources":["../../src/server/socket-io-node.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"socket-io-node.d.ts","sourceRoot":"","sources":["../../src/server/socket-io-node.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,0EAA0E;AAC1E,MAAM,WAAW,wBAAwB,CACvC,aAAa,SAAS,cAAc,EACpC,aAAa,SAAS,cAAc;IAEpC,EAAE,EAAE,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACjD,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,aAAa,IAAI,IAAI,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,WAAW,IAAI,MAAM,CAAC;CACvB;AAED,iFAAiF;AACjF,wBAAsB,wBAAwB,CAC5C,aAAa,SAAS,cAAc,EACpC,aAAa,SAAS,cAAc,EAEpC,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,wBAAwB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAEjE"}
|
|
@@ -23,10 +23,8 @@ import type { BunServer } from './bun';
|
|
|
23
23
|
import type { SocketIOServerConfig } from './socket-io-config';
|
|
24
24
|
import type { RawRoute } from './types';
|
|
25
25
|
import { type ComposedLane } from './websocket';
|
|
26
|
-
export type { SocketIOServerConfig } from './socket-io-config';
|
|
27
|
-
export interface
|
|
28
|
-
/** The typed Socket.IO server — attach `io.on('connection', ...)` handlers. */
|
|
29
|
-
io: SocketIOServer<TClientEvents, TServerEvents>;
|
|
26
|
+
export type { SocketIORequestPolicy, SocketIOServerConfig } from './socket-io-config';
|
|
27
|
+
export interface SocketIOServerLifecycle {
|
|
30
28
|
/**
|
|
31
29
|
* WebSocket handler for `Bun.serve({ websocket })`. Real on Bun; on Node it is
|
|
32
30
|
* an inert no-op — sockets there are driven by the `node:http.Server`
|
|
@@ -47,6 +45,16 @@ export interface SocketIOServerHandle<TServerEvents extends SocketEventMap, TCli
|
|
|
47
45
|
* `serveNode({ socket })` calls this for you.
|
|
48
46
|
*/
|
|
49
47
|
attach(server: HttpServer): void;
|
|
48
|
+
/** Stop admitting new Engine.IO handshakes. Called by the managed server. */
|
|
49
|
+
beginShutdown(): void;
|
|
50
|
+
/** Idempotently close namespaces, adapters and the bound transport engine. */
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
/** Current Engine.IO client count, when the engine has been bound. */
|
|
53
|
+
connections(): number;
|
|
54
|
+
}
|
|
55
|
+
export interface SocketIOServerHandle<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap> extends SocketIOServerLifecycle {
|
|
56
|
+
/** The typed Socket.IO server — attach `io.on('connection', ...)` handlers. */
|
|
57
|
+
io: SocketIOServer<TClientEvents, TServerEvents>;
|
|
50
58
|
}
|
|
51
59
|
export declare function createSocketIOServer<TServerEvents extends SocketEventMap, TClientEvents extends SocketEventMap>(config: SocketIOServerConfig): Promise<SocketIOServerHandle<TServerEvents, TClientEvents>>;
|
|
52
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-io.d.ts","sourceRoot":"","sources":["../../src/server/socket-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EACV,MAAM,IAAI,SAAS,EAEpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"socket-io.d.ts","sourceRoot":"","sources":["../../src/server/socket-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EACV,MAAM,IAAI,SAAS,EAEpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,MAAM,IAAI,cAAc,EAEzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EA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