silgi 0.41.52 → 0.41.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.mjs +1 -0
- package/dist/cli/build.mjs +19 -2
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +1 -0
- package/dist/cli/install.mjs +1 -0
- package/dist/cli/run.mjs +1 -0
- package/dist/cli/watch.mjs +1 -0
- package/dist/types/index.d.mts +5 -440
- package/package.json +3 -1
package/dist/build.mjs
CHANGED
package/dist/cli/build.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import { defu } from 'defu';
|
|
|
19
19
|
import { resolveModuleURL } from 'exsolve';
|
|
20
20
|
import { withTrailingSlash, isRelative } from 'ufo';
|
|
21
21
|
import { readdir, readFile } from 'node:fs/promises';
|
|
22
|
+
import micromatch from 'micromatch';
|
|
22
23
|
import { parseAsync } from 'oxc-parser';
|
|
23
24
|
import { glob } from 'tinyglobby';
|
|
24
25
|
import ignore from 'ignore';
|
|
@@ -648,9 +649,20 @@ function transformImportPath(path, packageName, relativeTo) {
|
|
|
648
649
|
return importPath;
|
|
649
650
|
}
|
|
650
651
|
function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName) {
|
|
652
|
+
function getIgnoredPatterns() {
|
|
653
|
+
const ignored = silgiInstance.options.watchOptions?.ignored;
|
|
654
|
+
if (!ignored)
|
|
655
|
+
return [];
|
|
656
|
+
if (Array.isArray(ignored))
|
|
657
|
+
return ignored.filter((v) => typeof v === "string");
|
|
658
|
+
if (typeof ignored === "string")
|
|
659
|
+
return [ignored];
|
|
660
|
+
return [];
|
|
661
|
+
}
|
|
651
662
|
silgiInstance.hook("before:scan.ts", (options) => {
|
|
663
|
+
const ignoredPatterns = getIgnoredPatterns();
|
|
652
664
|
for (const { exportName, path, uniqueId, category } of runtimeExports) {
|
|
653
|
-
if (
|
|
665
|
+
if (isWatchedPath(path, ignoredPatterns)) {
|
|
654
666
|
silgiInstance.options.devServer.watch.push(path);
|
|
655
667
|
}
|
|
656
668
|
switch (category) {
|
|
@@ -677,8 +689,9 @@ function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, pa
|
|
|
677
689
|
}
|
|
678
690
|
});
|
|
679
691
|
silgiInstance.hook("before:schema.ts", (options) => {
|
|
692
|
+
const ignoredPatterns = getIgnoredPatterns();
|
|
680
693
|
for (const { exportName, path, uniqueId, category } of typeExports) {
|
|
681
|
-
if (
|
|
694
|
+
if (isWatchedPath(path, ignoredPatterns)) {
|
|
682
695
|
silgiInstance.options.devServer.watch.push(path);
|
|
683
696
|
}
|
|
684
697
|
if (category === "shared" || category === "context") {
|
|
@@ -828,6 +841,9 @@ async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()
|
|
|
828
841
|
consola.error("Error scanning export files:", error);
|
|
829
842
|
}
|
|
830
843
|
}
|
|
844
|
+
function isWatchedPath(path, ignoredPatterns) {
|
|
845
|
+
return !micromatch.isMatch(path, ignoredPatterns);
|
|
846
|
+
}
|
|
831
847
|
|
|
832
848
|
const MissingModuleMatcher = /Cannot find module\s+['"]?([^'")\s]+)['"]?/i;
|
|
833
849
|
async function _resolveSilgiModule(silgiModule, silgi) {
|
|
@@ -1579,6 +1595,7 @@ async function generateApp(app, options = {}) {
|
|
|
1579
1595
|
if (template.watch === false) {
|
|
1580
1596
|
if (Array.isArray(app.options.watchOptions.ignored)) {
|
|
1581
1597
|
app.options.watchOptions.ignored.push(`${template.dst || template.src}`);
|
|
1598
|
+
app.options.devServer.watch.push(`!${template.dst || template.src}`);
|
|
1582
1599
|
}
|
|
1583
1600
|
}
|
|
1584
1601
|
if (options.filter && !options.filter(template)) {
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
package/dist/cli/install.mjs
CHANGED
package/dist/cli/run.mjs
CHANGED
package/dist/cli/watch.mjs
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -23,6 +23,7 @@ import { RouterContext } from 'rou3';
|
|
|
23
23
|
import { TransactionOptions, BuiltinDriverName, StorageValue, Storage } from 'unstorage';
|
|
24
24
|
import { ServerRequest } from 'srvx';
|
|
25
25
|
import { Defu } from 'defu';
|
|
26
|
+
import * as crossws from 'crossws';
|
|
26
27
|
import { silgiFetch } from 'silgi';
|
|
27
28
|
import { useRuntimeConfig } from 'silgi/runtime';
|
|
28
29
|
import { Unimport } from 'unimport';
|
|
@@ -137,442 +138,6 @@ interface SilgiEvent extends Record<string, unknown> {
|
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
140
|
|
|
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
|
-
|
|
576
141
|
/**
|
|
577
142
|
* Route configuration interface.
|
|
578
143
|
*/
|
|
@@ -669,9 +234,9 @@ interface ExtendShared {
|
|
|
669
234
|
interface ServicesObject {
|
|
670
235
|
}
|
|
671
236
|
interface WebSocketOptions {
|
|
672
|
-
resolve?: ResolveHooks;
|
|
673
|
-
hooks?: Partial<Hooks>;
|
|
674
|
-
adapterHooks?: Partial<Hooks>;
|
|
237
|
+
resolve?: crossws.ResolveHooks;
|
|
238
|
+
hooks?: Partial<crossws.Hooks>;
|
|
239
|
+
adapterHooks?: Partial<crossws.Hooks>;
|
|
675
240
|
}
|
|
676
241
|
type SlashCount<S extends string, Count extends any[] = []> = S extends `${infer _Prefix}/${infer Rest}` ? SlashCount<Rest, [any, ...Count]> : Count['length'];
|
|
677
242
|
type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3 ? S : never;
|
|
@@ -713,7 +278,7 @@ interface ServiceSetup<Method extends HTTPMethod = HTTPMethod, Path extends stri
|
|
|
713
278
|
path: Path;
|
|
714
279
|
method?: Method;
|
|
715
280
|
handler?: ServiceHandler<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
716
|
-
websocket?: Partial<Hooks>;
|
|
281
|
+
websocket?: Partial<crossws.Hooks>;
|
|
717
282
|
rules?: MergeRouteRules;
|
|
718
283
|
modules?: Partial<SetupModuleOption>;
|
|
719
284
|
storage?: StorageConfig<ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.41.
|
|
4
|
+
"version": "0.41.55",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"klona": "^2.0.6",
|
|
121
121
|
"knitwork": "^1.2.0",
|
|
122
122
|
"magicast": "^0.3.5",
|
|
123
|
+
"micromatch": "^4.0.8",
|
|
123
124
|
"mlly": "^1.7.4",
|
|
124
125
|
"ofetch": "^1.4.1",
|
|
125
126
|
"ohash": "^2.0.11",
|
|
@@ -148,6 +149,7 @@
|
|
|
148
149
|
"@nuxt/kit": "^3.17.2",
|
|
149
150
|
"@nuxt/schema": "^3.17.2",
|
|
150
151
|
"@silgi/ecosystem": "^0.6.8",
|
|
152
|
+
"@types/micromatch": "^4.0.9",
|
|
151
153
|
"@types/node": "^22.15.16",
|
|
152
154
|
"@types/semver": "^7.7.0",
|
|
153
155
|
"@vitest/coverage-v8": "3.0.5",
|