@morojs/engine 1.1.13 → 1.1.15

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/index.d.ts CHANGED
@@ -59,6 +59,10 @@ export interface EngineCapabilities {
59
59
  /** Batched pipelined dispatch: the onRequestBatch callback, getBatchBuffers()
60
60
  * and getPath(). Off under MORO_ENGINE_BATCH=0. */
61
61
  batchDispatch: boolean;
62
+ /** setWsAutoUpgrade(), wsGetHeaders(), wsGetQuery() and wsGetRemoteAddress()
63
+ * exist: the engine can perform valid WebSocket upgrades itself, firing
64
+ * onWsOpen without the request ever reaching onRequest. */
65
+ wsAutoUpgrade: boolean;
62
66
  }
63
67
 
64
68
  export interface FastApiInfo {
@@ -420,6 +424,20 @@ export function upgradeToWebSocket(reqId: number): number;
420
424
  export function wsSend(wsId: number, data: string | ArrayBuffer | Uint8Array | Buffer, isBinary: boolean): boolean;
421
425
  /** Send a Close frame and close the connection. */
422
426
  export function wsClose(wsId: number, code?: number, reason?: string): void;
427
+ /** With `on`, every valid WebSocket handshake is answered by the engine itself:
428
+ * the 101 goes out, onWsOpen fires (and any frames pipelined with the
429
+ * handshake reach onWsMessage), and onRequest is never called for it. An
430
+ * invalid handshake is surfaced to onRequest as any other request. Applies
431
+ * to this server only; register it again after close() + serve(). */
432
+ export function setWsAutoUpgrade(serverId: number, on: boolean): void;
433
+ /** The handshake request's headers, flat [name, value, ...] with names
434
+ * lowercased (the shape getHeaders() gives), kept for the socket's lifetime;
435
+ * undefined once the socket is gone. */
436
+ export function wsGetHeaders(wsId: number): string[] | undefined;
437
+ /** The handshake request's raw query string ('' when it had none). */
438
+ export function wsGetQuery(wsId: number): string | undefined;
439
+ /** The peer's address, as getRemoteAddress() gives it for a request. */
440
+ export function wsGetRemoteAddress(wsId: number): string | undefined;
423
441
 
424
442
  /** Non-throwing load diagnostics. Never throws. */
425
443
  export function probe(): EngineProbeResult;
@@ -461,6 +479,10 @@ declare const engine: {
461
479
  upgradeToWebSocket: typeof upgradeToWebSocket;
462
480
  wsSend: typeof wsSend;
463
481
  wsClose: typeof wsClose;
482
+ setWsAutoUpgrade: typeof setWsAutoUpgrade;
483
+ wsGetHeaders: typeof wsGetHeaders;
484
+ wsGetQuery: typeof wsGetQuery;
485
+ wsGetRemoteAddress: typeof wsGetRemoteAddress;
464
486
  probe: typeof probe;
465
487
  version: string;
466
488
  };
package/index.js CHANGED
@@ -180,6 +180,10 @@ const NATIVE_API = new Set([
180
180
  'upgradeToWebSocket',
181
181
  'wsSend',
182
182
  'wsClose',
183
+ 'setWsAutoUpgrade',
184
+ 'wsGetHeaders',
185
+ 'wsGetQuery',
186
+ 'wsGetRemoteAddress',
183
187
  ]);
184
188
 
185
189
  module.exports = new Proxy(
package/index.mjs CHANGED
@@ -57,3 +57,7 @@ export let endWith = (...a) => (endWith = engine.endWith)(...a);
57
57
  export let upgradeToWebSocket = (...a) => (upgradeToWebSocket = engine.upgradeToWebSocket)(...a);
58
58
  export let wsSend = (...a) => (wsSend = engine.wsSend)(...a);
59
59
  export let wsClose = (...a) => (wsClose = engine.wsClose)(...a);
60
+ export let setWsAutoUpgrade = (...a) => (setWsAutoUpgrade = engine.setWsAutoUpgrade)(...a);
61
+ export let wsGetHeaders = (...a) => (wsGetHeaders = engine.wsGetHeaders)(...a);
62
+ export let wsGetQuery = (...a) => (wsGetQuery = engine.wsGetQuery)(...a);
63
+ export let wsGetRemoteAddress = (...a) => (wsGetRemoteAddress = engine.wsGetRemoteAddress)(...a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morojs/engine",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "MoroJS native HTTP engine - Moro-authored C++ core with per-platform prebuilt binaries and automatic Node.js fallback in MoroJS",
5
5
  "license": "MIT",
6
6
  "author": "CM Ventures Inc.",
@@ -38,13 +38,13 @@
38
38
  "provenance": true
39
39
  },
40
40
  "optionalDependencies": {
41
- "@morojs/engine-darwin-arm64": "1.1.13",
42
- "@morojs/engine-darwin-x64": "1.1.13",
43
- "@morojs/engine-linux-x64-gnu": "1.1.13",
44
- "@morojs/engine-linux-arm64-gnu": "1.1.13",
45
- "@morojs/engine-linux-x64-musl": "1.1.13",
46
- "@morojs/engine-linux-arm64-musl": "1.1.13",
47
- "@morojs/engine-win32-x64": "1.1.13"
41
+ "@morojs/engine-darwin-arm64": "1.1.15",
42
+ "@morojs/engine-darwin-x64": "1.1.15",
43
+ "@morojs/engine-linux-x64-gnu": "1.1.15",
44
+ "@morojs/engine-linux-arm64-gnu": "1.1.15",
45
+ "@morojs/engine-linux-x64-musl": "1.1.15",
46
+ "@morojs/engine-linux-arm64-musl": "1.1.15",
47
+ "@morojs/engine-win32-x64": "1.1.15"
48
48
  },
49
49
  "keywords": [
50
50
  "morojs",