silgi 0.41.38 → 0.41.40

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.41.38";
4
+ const version = "0.41.40";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -1,4 +1,4 @@
1
- import { SilgiRuntimeConfig, SilgiConfig, Silgi, SilgiEvent, SilgiRuntimeContext, SilgiSchema, RouteEntry, CustomRequestInit, SilgiCLI, SilgiStorageBase, MergeAll, Routers, HTTPMethod, MiddlewareSetup, Resolvers, SilgiURL, BaseMethodSchema, ServiceSetupsForMethods, ServiceDefinitionByMethodAndPath, ServiceSetup, SilgiRuntimeShareds, StorageConfig } from 'silgi/types';
1
+ import { SilgiRuntimeConfig, SilgiConfig, Silgi, SilgiEvent, SilgiRuntimeContext, SilgiSchema, RouteEntry, CustomRequestInit, WebSocketOptions, SilgiCLI, SilgiStorageBase, MergeAll, Routers, HTTPMethod, MiddlewareSetup, Resolvers, SilgiURL, BaseMethodSchema, ServiceSetupsForMethods, ServiceDefinitionByMethodAndPath, ServiceSetup, SilgiRuntimeShareds, StorageConfig } from 'silgi/types';
2
2
  import { ServerRequest } from 'srvx';
3
3
  import { UseContext } from 'unctx';
4
4
  import { Storage, StorageValue } from 'unstorage';
@@ -136,6 +136,7 @@ declare function silgiFetch(_request: Request | URL, options?: RequestInit & {
136
136
  }, context?: SilgiRuntimeContext): Promise<Response | Promise<Response>>;
137
137
  declare function middleware(event: SilgiEvent): Promise<any>;
138
138
  declare function handler(event: SilgiEvent): Promise<any>;
139
+ declare function getWebsocket(silgi?: Silgi): WebSocketOptions;
139
140
 
140
141
  declare const silgiCLICtx: UseContext<SilgiCLI>;
141
142
  declare function useSilgiCLI(): SilgiCLI;
@@ -159,6 +160,93 @@ declare function useSilgi(): Silgi;
159
160
  */
160
161
  declare function tryUseSilgi(): Silgi | null;
161
162
 
163
+ /**
164
+ * A helper class for [server sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)
165
+ */
166
+ declare class EventStream {
167
+ private readonly _event;
168
+ private readonly _transformStream;
169
+ private readonly _writer;
170
+ private readonly _encoder;
171
+ private _writerIsClosed;
172
+ private _paused;
173
+ private _unsentData;
174
+ private _disposed;
175
+ private _handled;
176
+ constructor(event: SilgiEvent, opts?: EventStreamOptions);
177
+ /**
178
+ * Publish new event(s) for the client
179
+ */
180
+ push(message: string): Promise<void>;
181
+ push(message: string[]): Promise<void>;
182
+ push(message: EventStreamMessage): Promise<void>;
183
+ push(message: EventStreamMessage[]): Promise<void>;
184
+ private _sendEvent;
185
+ private _sendEvents;
186
+ pause(): void;
187
+ get isPaused(): boolean;
188
+ resume(): Promise<void>;
189
+ flush(): Promise<void>;
190
+ /**
191
+ * Close the stream and the connection if the stream is being sent to the client
192
+ */
193
+ close(): Promise<void>;
194
+ /**
195
+ * Triggers callback when the writable stream is closed.
196
+ * It is also triggered after calling the `close()` method.
197
+ */
198
+ onClosed(cb: () => any): void;
199
+ send(): Promise<BodyInit>;
200
+ }
201
+
202
+ interface EventStreamOptions {
203
+ /**
204
+ * Automatically close the writable stream when the request is closed
205
+ *
206
+ * Default is `true`
207
+ */
208
+ autoclose?: boolean;
209
+ }
210
+ /**
211
+ * See https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#fields
212
+ */
213
+ interface EventStreamMessage {
214
+ id?: string;
215
+ event?: string;
216
+ retry?: number;
217
+ data: string;
218
+ }
219
+ /**
220
+ * Initialize an EventStream instance for creating [server sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
221
+ *
222
+ * @experimental This function is experimental and might be unstable in some environments.
223
+ *
224
+ * @example
225
+ *
226
+ * ```ts
227
+ * import { createEventStream, sendEventStream } from "h3";
228
+ *
229
+ * app.get("/sse", (event) => {
230
+ * const eventStream = createEventStream(event);
231
+ *
232
+ * // Send a message every second
233
+ * const interval = setInterval(async () => {
234
+ * await eventStream.push("Hello world");
235
+ * }, 1000);
236
+ *
237
+ * // cleanup the interval and close the stream when the connection is terminated
238
+ * eventStream.onClosed(async () => {
239
+ * console.log("closing SSE...");
240
+ * clearInterval(interval);
241
+ * await eventStream.close();
242
+ * });
243
+ *
244
+ * return eventStream.send();
245
+ * });
246
+ * ```
247
+ */
248
+ declare function createEventStream(event: SilgiEvent, opts?: EventStreamOptions): EventStream;
249
+
162
250
  declare function getEvent<T extends SilgiEvent>(event?: SilgiEvent): T;
163
251
  declare function getEventContext<T extends SilgiRuntimeContext>(event?: SilgiEvent): T;
164
252
 
@@ -247,4 +335,4 @@ declare function useSilgiStorage<T extends StorageValue = StorageValue>(base?: S
247
335
 
248
336
  declare const autoImportTypes: string[];
249
337
 
250
- export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
338
+ export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, getWebsocket, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
@@ -313,14 +313,15 @@ async function createSilgi(config) {
313
313
  tag: "silgi"
314
314
  })).withTag("silgi"),
315
315
  captureError: config.captureError ?? (() => {
316
- })
316
+ }),
317
+ websocket: config.websocket ?? void 0
317
318
  };
318
319
  sharedRuntimeConfig(silgi.options.runtimeConfig);
319
320
  if (!silgi.router) {
320
321
  silgi.router = createRouter();
321
322
  }
322
323
  for (const [_route, object] of Object.entries(silgi.services)) {
323
- const { method } = getServicePath(_route);
324
+ const { method, type } = getServicePath(_route);
324
325
  if (!object)
325
326
  continue;
326
327
  const path = String(object.path);
@@ -328,7 +329,7 @@ async function createSilgi(config) {
328
329
  if (routeParts.length > 0) {
329
330
  const prefix = `/${routeParts[0]}`;
330
331
  if (!silgi.routerPrefixs.includes(prefix)) {
331
- silgi.routerPrefixs.push(prefix);
332
+ silgi.routerPrefixs.push(`${type}:${prefix}`);
332
333
  }
333
334
  }
334
335
  let routeWithParams = path;
@@ -1065,6 +1066,20 @@ async function handler(event) {
1065
1066
  (_previous) => _previous === void 0 ? kNotFound : _previous
1066
1067
  ) : kNotFound;
1067
1068
  }
1069
+ function getWebsocket(silgi = useSilgi()) {
1070
+ return {
1071
+ ...silgi.options.websocket,
1072
+ resolve: async (request) => {
1073
+ console.log("WebSocket resolve");
1074
+ getPathname(request.url || "/");
1075
+ request.method || "GET";
1076
+ const event = new SilgiHttpEvent(request, {});
1077
+ const silgiContext = useSilgi();
1078
+ const handler2 = silgiContext.router && findRoute(silgiContext.router, event.req.method, event.url.pathname);
1079
+ return handler2?.data.service?.websocket?.hooks || {};
1080
+ }
1081
+ };
1082
+ }
1068
1083
 
1069
1084
  function storageMount(silgi) {
1070
1085
  const _silgi = silgi || useSilgi();
@@ -1078,6 +1093,178 @@ function storageMount(silgi) {
1078
1093
  };
1079
1094
  }
1080
1095
 
1096
+ class EventStream {
1097
+ _event;
1098
+ _transformStream = new TransformStream();
1099
+ _writer;
1100
+ _encoder = new TextEncoder();
1101
+ _writerIsClosed = false;
1102
+ _paused = false;
1103
+ _unsentData;
1104
+ _disposed = false;
1105
+ _handled = false;
1106
+ constructor(event, opts = {}) {
1107
+ this._event = event;
1108
+ this._writer = this._transformStream.writable.getWriter();
1109
+ this._writer.closed.then(() => {
1110
+ this._writerIsClosed = true;
1111
+ });
1112
+ if (opts.autoclose !== false) {
1113
+ this._event?.runtime?.node?.res?.once("close", () => this.close());
1114
+ }
1115
+ }
1116
+ async push(message) {
1117
+ if (typeof message === "string") {
1118
+ await this._sendEvent({ data: message });
1119
+ return;
1120
+ }
1121
+ if (Array.isArray(message)) {
1122
+ if (message.length === 0) {
1123
+ return;
1124
+ }
1125
+ if (typeof message[0] === "string") {
1126
+ const msgs = [];
1127
+ for (const item of message) {
1128
+ msgs.push({ data: item });
1129
+ }
1130
+ await this._sendEvents(msgs);
1131
+ return;
1132
+ }
1133
+ await this._sendEvents(message);
1134
+ return;
1135
+ }
1136
+ await this._sendEvent(message);
1137
+ }
1138
+ async _sendEvent(message) {
1139
+ if (this._writerIsClosed) {
1140
+ return;
1141
+ }
1142
+ if (this._paused && !this._unsentData) {
1143
+ this._unsentData = formatEventStreamMessage(message);
1144
+ return;
1145
+ }
1146
+ if (this._paused) {
1147
+ this._unsentData += formatEventStreamMessage(message);
1148
+ return;
1149
+ }
1150
+ await this._writer.write(this._encoder.encode(formatEventStreamMessage(message))).catch();
1151
+ }
1152
+ async _sendEvents(messages) {
1153
+ if (this._writerIsClosed) {
1154
+ return;
1155
+ }
1156
+ const payload = formatEventStreamMessages(messages);
1157
+ if (this._paused && !this._unsentData) {
1158
+ this._unsentData = payload;
1159
+ return;
1160
+ }
1161
+ if (this._paused) {
1162
+ this._unsentData += payload;
1163
+ return;
1164
+ }
1165
+ await this._writer.write(this._encoder.encode(payload)).catch();
1166
+ }
1167
+ pause() {
1168
+ this._paused = true;
1169
+ }
1170
+ get isPaused() {
1171
+ return this._paused;
1172
+ }
1173
+ async resume() {
1174
+ this._paused = false;
1175
+ await this.flush();
1176
+ }
1177
+ async flush() {
1178
+ if (this._writerIsClosed) {
1179
+ return;
1180
+ }
1181
+ if (this._unsentData?.length) {
1182
+ await this._writer.write(this._encoder.encode(this._unsentData));
1183
+ this._unsentData = void 0;
1184
+ }
1185
+ }
1186
+ /**
1187
+ * Close the stream and the connection if the stream is being sent to the client
1188
+ */
1189
+ async close() {
1190
+ if (this._disposed) {
1191
+ return;
1192
+ }
1193
+ if (!this._writerIsClosed) {
1194
+ try {
1195
+ await this._writer.close();
1196
+ } catch {
1197
+ }
1198
+ }
1199
+ this._disposed = true;
1200
+ }
1201
+ /**
1202
+ * Triggers callback when the writable stream is closed.
1203
+ * It is also triggered after calling the `close()` method.
1204
+ */
1205
+ onClosed(cb) {
1206
+ this._writer.closed.then(cb);
1207
+ }
1208
+ async send() {
1209
+ setEventStreamHeaders(this._event);
1210
+ this._event.res.status = 200;
1211
+ this._handled = true;
1212
+ return this._transformStream.readable;
1213
+ }
1214
+ }
1215
+ function formatEventStreamMessage(message) {
1216
+ let result = "";
1217
+ if (message.id) {
1218
+ result += `id: ${message.id}
1219
+ `;
1220
+ }
1221
+ if (message.event) {
1222
+ result += `event: ${message.event}
1223
+ `;
1224
+ }
1225
+ if (typeof message.retry === "number" && Number.isInteger(message.retry)) {
1226
+ result += `retry: ${message.retry}
1227
+ `;
1228
+ }
1229
+ result += `data: ${message.data}
1230
+
1231
+ `;
1232
+ return result;
1233
+ }
1234
+ function formatEventStreamMessages(messages) {
1235
+ let result = "";
1236
+ for (const msg of messages) {
1237
+ result += formatEventStreamMessage(msg);
1238
+ }
1239
+ return result;
1240
+ }
1241
+ function setEventStreamHeaders(event) {
1242
+ event.res.headers.set("content-type", "text/event-stream");
1243
+ event.res.headers.set(
1244
+ "cache-control",
1245
+ "private, no-cache, no-store, no-transform, must-revalidate, max-age=0"
1246
+ );
1247
+ event.res.headers.set("x-accel-buffering", "no");
1248
+ if (!isHttp2Request(event)) {
1249
+ event.res.headers.set("connection", "keep-alive");
1250
+ }
1251
+ }
1252
+ function isHttp2Request(event) {
1253
+ const rawHeaders = event.req.headers;
1254
+ if (typeof rawHeaders.get === "function") {
1255
+ try {
1256
+ return rawHeaders.has(":path") || rawHeaders.has(":method");
1257
+ } catch {
1258
+ return false;
1259
+ }
1260
+ }
1261
+ return ":path" in rawHeaders || ":method" in rawHeaders;
1262
+ }
1263
+
1264
+ function createEventStream(event, opts) {
1265
+ return new EventStream(event, opts);
1266
+ }
1267
+
1081
1268
  function getEvent(event) {
1082
1269
  if (event?.event) {
1083
1270
  return getEvent(event.event);
@@ -1138,8 +1325,9 @@ function defineServiceSetup(setup) {
1138
1325
  }
1139
1326
  function createService(params) {
1140
1327
  const method = params.method || "ALL";
1328
+ const type = params.websocket ? "websocket" : "http";
1141
1329
  return {
1142
- [`${method}:${params.path}`]: params
1330
+ [`${type}:${method}:${params.path}`]: params
1143
1331
  };
1144
1332
  }
1145
1333
 
@@ -1154,4 +1342,4 @@ const autoImportTypes = [
1154
1342
  "ExtractQueryParamsFromURI"
1155
1343
  ];
1156
1344
 
1157
- export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
1345
+ export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, getWebsocket, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
1
+ export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, getWebsocket, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
2
2
  import 'silgi/types';
3
3
  import 'srvx';
4
4
  import 'unctx';
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
1
+ export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, getWebsocket, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
2
2
  export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from './_chunks/silgiApp.mjs';
3
3
  import 'node:async_hooks';
4
4
  import 'unctx';
@@ -313,6 +313,7 @@ declare function isRuntimePresents(names: PresetName[]): boolean;
313
313
  declare function removeExtension(filePath: string, force?: boolean): string;
314
314
  declare function getServicePath(_route: string): {
315
315
  method: string;
316
+ type: string;
316
317
  route: string;
317
318
  };
318
319
 
@@ -77,17 +77,26 @@ function removeExtension(filePath, force = false) {
77
77
  }
78
78
  function getServicePath(_route) {
79
79
  let method = "";
80
+ let type = "";
80
81
  let route = _route;
81
- if (route.includes(":")) {
82
- const [methodPart, ...routeParts] = route.split(":");
83
- method = methodPart.toUpperCase();
82
+ const parts = route.split(":");
83
+ if (parts.length === 3) {
84
+ type = parts[0].toLowerCase();
85
+ method = parts[1].toUpperCase();
84
86
  if (method === "GLOBAL" || method === "ALL") {
85
87
  method = "";
86
88
  }
87
- route = routeParts.join(":");
89
+ route = parts[2];
90
+ } else if (parts.length === 2) {
91
+ method = parts[0].toUpperCase();
92
+ if (method === "GLOBAL" || method === "ALL") {
93
+ method = "";
94
+ }
95
+ route = parts[1];
88
96
  }
89
97
  return {
90
98
  method,
99
+ type,
91
100
  route
92
101
  };
93
102
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  defineEventHandler,
3
- toWebRequest
3
+ toWebRequest,
4
+ defineWebSocketHandler
4
5
  } from "h3";
5
6
  import {
6
7
  silgiFetch,
@@ -13,11 +14,22 @@ export async function addNitroApp(silgiContext = useSilgi()) {
13
14
  }
14
15
  const prefixs = silgiContext.routerPrefixs;
15
16
  for (const prefix of prefixs) {
16
- nitro.router.use(`${prefix}/**`, defineEventHandler(async (event) => {
17
- const evet = toWebRequest(event);
18
- const resolvedRoute = await silgiFetch(evet);
19
- return resolvedRoute;
20
- }));
17
+ let type = "http";
18
+ let path = "";
19
+ const parts = prefix.split(":");
20
+ type = parts[0].toUpperCase();
21
+ path = parts[1];
22
+ if (type === "HTTP") {
23
+ nitro.router.use(`${path}/**`, defineEventHandler(async (event) => {
24
+ const evet = toWebRequest(event);
25
+ const resolvedRoute = await silgiFetch(evet);
26
+ return resolvedRoute;
27
+ }));
28
+ }
29
+ }
30
+ const webhookServices = Object.entries(silgiContext.services).filter(([key]) => key.startsWith("websocket:")).map(([, value]) => value);
31
+ for (const webhook of webhookServices) {
32
+ nitro.router.use(webhook.path, defineWebSocketHandler(webhook.websocket || {}));
21
33
  }
22
34
  }
23
35
  export default addNitroApp;
@@ -116,6 +116,11 @@ interface SilgiEvent extends Record<string, unknown> {
116
116
  * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
117
117
  */
118
118
  readonly req: ServerRequest;
119
+ /**
120
+ * Access to runtime specific additional context.
121
+ *
122
+ */
123
+ runtime: ServerRequest["runtime"];
119
124
  /**
120
125
  * Access to the parsed request URL.
121
126
  *
@@ -132,6 +137,442 @@ interface SilgiEvent extends Record<string, unknown> {
132
137
  };
133
138
  }
134
139
 
140
+ /**
141
+ * A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute.
142
+ *
143
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
144
+ */
145
+ interface CloseEvent extends Event {
146
+ /**
147
+ * Returns the WebSocket connection close code provided by the server.
148
+ *
149
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
150
+ */
151
+ readonly code: number;
152
+ /**
153
+ * Returns the WebSocket connection close reason provided by the server.
154
+ *
155
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
156
+ */
157
+ readonly reason: string;
158
+ /**
159
+ * Returns true if the connection closed cleanly; false otherwise.
160
+ *
161
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
162
+ */
163
+ readonly wasClean: boolean;
164
+ }
165
+ /**
166
+ * An event which takes place in the DOM.
167
+ *
168
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
169
+ */
170
+ interface Event {
171
+ /**
172
+ * Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
173
+ *
174
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
175
+ */
176
+ readonly bubbles: boolean;
177
+ /**
178
+ * @deprecated
179
+ *
180
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
181
+ */
182
+ cancelBubble: boolean;
183
+ /**
184
+ * Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
185
+ *
186
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
187
+ */
188
+ readonly cancelable: boolean;
189
+ /**
190
+ * Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
191
+ *
192
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
193
+ */
194
+ readonly composed: boolean;
195
+ /**
196
+ * Returns the object whose event listener's callback is currently being invoked.
197
+ *
198
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
199
+ */
200
+ readonly currentTarget: EventTarget | null;
201
+ /**
202
+ * Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
203
+ *
204
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
205
+ */
206
+ readonly defaultPrevented: boolean;
207
+ /**
208
+ * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
209
+ *
210
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
211
+ */
212
+ readonly eventPhase: number;
213
+ /**
214
+ * Returns true if event was dispatched by the user agent, and false otherwise.
215
+ *
216
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
217
+ */
218
+ readonly isTrusted: boolean;
219
+ /**
220
+ * @deprecated
221
+ *
222
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
223
+ */
224
+ returnValue: boolean;
225
+ /**
226
+ * @deprecated
227
+ *
228
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
229
+ */
230
+ readonly srcElement: EventTarget | null;
231
+ /**
232
+ * Returns the object to which event is dispatched (its target).
233
+ *
234
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
235
+ */
236
+ readonly target: EventTarget | null;
237
+ /**
238
+ * Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
239
+ *
240
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
241
+ */
242
+ readonly timeStamp: DOMHighResTimeStamp;
243
+ /**
244
+ * Returns the type of event, e.g. "click", "hashchange", or "submit".
245
+ *
246
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
247
+ */
248
+ readonly type: string;
249
+ /**
250
+ * Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget.
251
+ *
252
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
253
+ */
254
+ composedPath(): EventTarget[];
255
+ /**
256
+ * @deprecated
257
+ *
258
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/initEvent)
259
+ */
260
+ initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
261
+ /**
262
+ * If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
263
+ *
264
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
265
+ */
266
+ preventDefault(): void;
267
+ /**
268
+ * Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
269
+ *
270
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
271
+ */
272
+ stopImmediatePropagation(): void;
273
+ /**
274
+ * When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
275
+ *
276
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
277
+ */
278
+ stopPropagation(): void;
279
+ readonly NONE: 0;
280
+ readonly CAPTURING_PHASE: 1;
281
+ readonly AT_TARGET: 2;
282
+ readonly BUBBLING_PHASE: 3;
283
+ }
284
+ /**
285
+ * EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
286
+ *
287
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
288
+ */
289
+ interface EventTarget {
290
+ /**
291
+ * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
292
+ *
293
+ * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
294
+ *
295
+ * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
296
+ *
297
+ * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
298
+ *
299
+ * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
300
+ *
301
+ * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
302
+ *
303
+ * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
304
+ *
305
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
306
+ */
307
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
308
+ /**
309
+ * Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
310
+ *
311
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
312
+ */
313
+ dispatchEvent(event: Event): boolean;
314
+ /**
315
+ * Removes the event listener in target's event listener list with the same type, callback, and options.
316
+ *
317
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
318
+ */
319
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
320
+ }
321
+ /**
322
+ * A message received by a target object.
323
+ *
324
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
325
+ */
326
+ interface MessageEvent$1<T = any> extends Event {
327
+ /**
328
+ * Returns the data of the message.
329
+ *
330
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
331
+ */
332
+ readonly data: T;
333
+ /**
334
+ * Returns the last event ID string, for server-sent events.
335
+ *
336
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
337
+ */
338
+ readonly lastEventId: string;
339
+ /**
340
+ * Returns the origin of the message, for server-sent events and cross-document messaging.
341
+ *
342
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
343
+ */
344
+ readonly origin: string;
345
+ /**
346
+ * Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging.
347
+ *
348
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
349
+ */
350
+ readonly ports: ReadonlyArray<MessagePort>;
351
+ /**
352
+ * Returns the WindowProxy of the source window, for cross-document messaging, and the MessagePort being attached, in the connect event fired at SharedWorkerGlobalScope objects.
353
+ *
354
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
355
+ */
356
+ readonly source: MessageEventSource | null;
357
+ /** @deprecated */
358
+ initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: MessagePort[]): void;
359
+ }
360
+ /**
361
+ * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
362
+ *
363
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
364
+ */
365
+ interface WebSocket extends EventTarget {
366
+ /**
367
+ * Returns a string that indicates how binary data from the WebSocket object is exposed to scripts:
368
+ *
369
+ * Can be set, to change how binary data is returned. The default is "blob".
370
+ *
371
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
372
+ */
373
+ binaryType: BinaryType | (string & {});
374
+ /**
375
+ * Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network.
376
+ *
377
+ * If the WebSocket connection is closed, this attribute's value will only increase with each call to the send() method. (The number does not reset to zero once the connection closes.)
378
+ *
379
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/bufferedAmount)
380
+ */
381
+ readonly bufferedAmount: number;
382
+ /**
383
+ * Returns the extensions selected by the server, if any.
384
+ *
385
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
386
+ */
387
+ readonly extensions: string;
388
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close_event) */
389
+ onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
390
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/error_event) */
391
+ onerror: ((this: WebSocket, ev: Event) => any) | null;
392
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/message_event) */
393
+ onmessage: ((this: WebSocket, ev: MessageEvent$1) => any) | null;
394
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/open_event) */
395
+ onopen: ((this: WebSocket, ev: Event) => any) | null;
396
+ /**
397
+ * Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
398
+ *
399
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
400
+ */
401
+ readonly protocol: string;
402
+ /**
403
+ * Returns the state of the WebSocket object's connection. It can have the values described below.
404
+ *
405
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
406
+ */
407
+ readonly readyState: number;
408
+ /**
409
+ * Returns the URL that was used to establish the WebSocket connection.
410
+ *
411
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
412
+ */
413
+ readonly url: string;
414
+ /**
415
+ * Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
416
+ *
417
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
418
+ */
419
+ close(code?: number, reason?: string): void;
420
+ /**
421
+ * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
422
+ *
423
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
424
+ */
425
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
426
+ readonly CONNECTING: 0;
427
+ readonly OPEN: 1;
428
+ readonly CLOSING: 2;
429
+ readonly CLOSED: 3;
430
+ addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
431
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
432
+ removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
433
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
434
+ }
435
+
436
+ declare const kNodeInspect: unique symbol;
437
+
438
+ interface AdapterInternal {
439
+ ws: unknown;
440
+ request: UpgradeRequest;
441
+ peers?: Set<Peer>;
442
+ context?: Peer["context"];
443
+ }
444
+ declare abstract class Peer<Internal extends AdapterInternal = AdapterInternal> {
445
+ #private;
446
+ protected _internal: Internal;
447
+ protected _topics: Set<string>;
448
+ protected _id?: string;
449
+ constructor(internal: Internal);
450
+ get context(): Record<string, unknown>;
451
+ /**
452
+ * Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the peer.
453
+ */
454
+ get id(): string;
455
+ /** IP address of the peer */
456
+ get remoteAddress(): string | undefined;
457
+ /** upgrade request */
458
+ get request(): UpgradeRequest;
459
+ /**
460
+ * Get the [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) instance.
461
+ *
462
+ * **Note:** crossws adds polyfill for the following properties if native values are not available:
463
+ * - `protocol`: Extracted from the `sec-websocket-protocol` header.
464
+ * - `extensions`: Extracted from the `sec-websocket-extensions` header.
465
+ * - `url`: Extracted from the request URL (http -> ws).
466
+ * */
467
+ get websocket(): Partial<WebSocket>;
468
+ /** All connected peers to the server */
469
+ get peers(): Set<Peer>;
470
+ /** All topics, this peer has been subscribed to. */
471
+ get topics(): Set<string>;
472
+ abstract close(code?: number, reason?: string): void;
473
+ /** Abruptly close the connection */
474
+ terminate(): void;
475
+ /** Subscribe to a topic */
476
+ subscribe(topic: string): void;
477
+ /** Unsubscribe from a topic */
478
+ unsubscribe(topic: string): void;
479
+ /** Send a message to the peer. */
480
+ abstract send(data: unknown, options?: {
481
+ compress?: boolean;
482
+ }): number | void | undefined;
483
+ /** Send message to subscribes of topic */
484
+ abstract publish(topic: string, data: unknown, options?: {
485
+ compress?: boolean;
486
+ }): void;
487
+ toString(): string;
488
+ [Symbol.toPrimitive](): string;
489
+ [Symbol.toStringTag](): "WebSocket";
490
+ [kNodeInspect](): Record<string, unknown>;
491
+ }
492
+
493
+ declare class WSError extends Error {
494
+ constructor(...args: any[]);
495
+ }
496
+
497
+ declare class Message implements Partial<MessageEvent> {
498
+ #private;
499
+ /** Access to the original [message event](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/message_event) if available. */
500
+ readonly event?: MessageEvent;
501
+ /** Access to the Peer that emitted the message. */
502
+ readonly peer?: Peer;
503
+ /** Raw message data (can be of any type). */
504
+ readonly rawData: unknown;
505
+ constructor(rawData: unknown, peer: Peer, event?: MessageEvent);
506
+ /**
507
+ * Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the message.
508
+ */
509
+ get id(): string;
510
+ /**
511
+ * Get data as [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) value.
512
+ *
513
+ * If raw data is in any other format or string, it will be automatically converted and encoded.
514
+ */
515
+ uint8Array(): Uint8Array;
516
+ /**
517
+ * Get data as [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) value.
518
+ *
519
+ * If raw data is in any other format or string, it will be automatically converted and encoded.
520
+ */
521
+ arrayBuffer(): ArrayBuffer | SharedArrayBuffer;
522
+ /**
523
+ * Get data as [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) value.
524
+ *
525
+ * If raw data is in any other format or string, it will be automatically converted and encoded. */
526
+ blob(): Blob;
527
+ /**
528
+ * Get stringified text version of the message.
529
+ *
530
+ * If raw data is in any other format, it will be automatically converted and decoded.
531
+ */
532
+ text(): string;
533
+ /**
534
+ * Get parsed version of the message text with [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
535
+ */
536
+ json<T = unknown>(): T;
537
+ /**
538
+ * Message data (value varies based on `peer.websocket.binaryType`).
539
+ */
540
+ get data(): unknown;
541
+ toString(): string;
542
+ [Symbol.toPrimitive](): string;
543
+ [kNodeInspect](): {
544
+ data: unknown;
545
+ };
546
+ }
547
+ type ResolveHooks = (info: RequestInit | Peer) => Partial<Hooks> | Promise<Partial<Hooks>>;
548
+ type MaybePromise<T> = T | Promise<T>;
549
+ type UpgradeRequest = Request | {
550
+ url: string;
551
+ headers: Headers;
552
+ };
553
+ interface Hooks {
554
+ /** Upgrading */
555
+ /**
556
+ *
557
+ * @param request
558
+ * @throws {Response}
559
+ */
560
+ upgrade: (request: UpgradeRequest & {
561
+ context: Peer["context"];
562
+ }) => MaybePromise<Response | ResponseInit | void>;
563
+ /** A message is received */
564
+ message: (peer: Peer, message: Message) => MaybePromise<void>;
565
+ /** A socket is opened */
566
+ open: (peer: Peer) => MaybePromise<void>;
567
+ /** A socket is closed */
568
+ close: (peer: Peer, details: {
569
+ code?: number;
570
+ reason?: string;
571
+ }) => MaybePromise<void>;
572
+ /** An error occurs */
573
+ error: (peer: Peer, error: WSError) => MaybePromise<void>;
574
+ }
575
+
135
576
  /**
136
577
  * Route configuration interface.
137
578
  */
@@ -227,6 +668,11 @@ interface ExtendShared {
227
668
 
228
669
  interface ServicesObject {
229
670
  }
671
+ interface WebSocketOptions {
672
+ resolve?: ResolveHooks;
673
+ hooks?: Partial<Hooks>;
674
+ adapterHooks?: Partial<Hooks>;
675
+ }
230
676
  type SlashCount<S extends string, Count extends any[] = []> = S extends `${infer _Prefix}/${infer Rest}` ? SlashCount<Rest, [any, ...Count]> : Count['length'];
231
677
  type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3 ? S : never;
232
678
  /**
@@ -259,13 +705,7 @@ type ServiceHandlerInput<Input extends StandardSchemaV1 = StandardSchemaV1, Path
259
705
  } : {
260
706
  args: InferInput<Input>;
261
707
  };
262
- /**
263
- * Handler fonksiyon tipi
264
- *
265
- * Resolved = false -> handler(input, shared, event, source) // all required
266
- * Resolved = true -> handler(input, shared?, event?, source?) // only input required
267
- */
268
- type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output> : (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output>;
708
+ type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output> | AsyncGenerator<InferOutput<Output>> | Generator<InferOutput<Output>> | Iterator<InferOutput<Output>> | AsyncIterator<InferOutput<Output>> | ReadableStream<InferOutput<Output>> : (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output> | AsyncGenerator<InferOutput<Output>> | Generator<InferOutput<Output>> | Iterator<InferOutput<Output>> | AsyncIterator<InferOutput<Output>> | ReadableStream<InferOutput<Output>>;
269
709
  /**
270
710
  * Servis setup tipi
271
711
  */
@@ -273,6 +713,7 @@ interface ServiceSetup<Method extends HTTPMethod = HTTPMethod, Path extends stri
273
713
  path: Path;
274
714
  method?: Method;
275
715
  handler?: ServiceHandler<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
716
+ websocket?: Partial<Hooks>;
276
717
  rules?: MergeRouteRules;
277
718
  modules?: Partial<SetupModuleOption>;
278
719
  storage?: StorageConfig<ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>>;
@@ -613,6 +1054,7 @@ interface SilgiOptions {
613
1054
  captureError: CaptureError;
614
1055
  adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
615
1056
  meta: MetaData;
1057
+ websocket?: WebSocketOptions;
616
1058
  [key: string]: any;
617
1059
  }
618
1060
 
@@ -710,8 +1152,6 @@ interface SilgiRoute {
710
1152
  method?: HTTPMethod;
711
1153
  service?: ResolvedServiceDefinition[keyof ResolvedServiceDefinition];
712
1154
  middleware?: MiddlewareSetup;
713
- queryParams?: Record<string, string>;
714
- pathParams?: Record<string, string>;
715
1155
  }
716
1156
  interface Silgi {
717
1157
  router: RouterContext<SilgiRoute>;
@@ -739,6 +1179,7 @@ interface Silgi {
739
1179
  envOptions: EnvOptions;
740
1180
  options: SilgiOptions & SilgiRuntimeOptions;
741
1181
  captureError: CaptureError;
1182
+ websocket?: WebSocketOptions;
742
1183
  }
743
1184
  interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRuntimeOptions> {
744
1185
  options: DeepPartial<SilgiOptions>;
@@ -1234,4 +1675,4 @@ interface LoadConfigOptions {
1234
1675
  consola?: ConsolaInstance;
1235
1676
  }
1236
1677
 
1237
- export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, EventProtocol, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, LoadConfigOptions, Max4Slashes, MergeAll, MergeRouteRules, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareHandler, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, Resolvers, RouteEntry, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceDefinitionByMethodAndPath, ServiceHandler, ServiceHandlerInput, ServiceSetup, ServiceSetupsForMethods, ServicesObject, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeDefaultConfig, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WithPathParams };
1678
+ export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, EventProtocol, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, LoadConfigOptions, Max4Slashes, MergeAll, MergeRouteRules, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareHandler, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, Resolvers, RouteEntry, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceDefinitionByMethodAndPath, ServiceHandler, ServiceHandlerInput, ServiceSetup, ServiceSetupsForMethods, ServicesObject, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeDefaultConfig, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WebSocketOptions, WithPathParams };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.41.38",
4
+ "version": "0.41.40",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {