@morojs/engine 1.1.18 → 1.1.19

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
@@ -14,8 +14,9 @@ export interface EngineCapabilities {
14
14
  limits: boolean;
15
15
  /** In-process TLS termination via ServeOptions.ssl. */
16
16
  tls: boolean;
17
- /** ALPN-negotiated HTTP/2 alongside HTTP/1.1 — reserved for a future
18
- * release; not yet configurable (no ServeOptions field). */
17
+ /** HTTP/2 via ServeOptions.http2 (engine >= 1.1.19): negotiated by ALPN on
18
+ * a TLS listener, by prior knowledge on a cleartext one, with HTTP/1.1
19
+ * served beside it on the same port. */
19
20
  http2: boolean;
20
21
  /** WebSocket permessage-deflate (RFC 7692) via ServeOptions.wsDeflate. */
21
22
  wsDeflate: boolean;
@@ -63,6 +64,10 @@ export interface EngineCapabilities {
63
64
  * exist: the engine can perform valid WebSocket upgrades itself, firing
64
65
  * onWsOpen without the request ever reaching onRequest. */
65
66
  wsAutoUpgrade: boolean;
67
+ /** getBodyType() and getBodyText() exist. */
68
+ bodyText: boolean;
69
+ /** getBodyLent() exists. */
70
+ bodyLent: boolean;
66
71
  }
67
72
 
68
73
  export interface FastApiInfo {
@@ -256,6 +261,28 @@ export interface ServeOptions {
256
261
  ciphersuites?: string; // TLS 1.3 suites (colon-separated)
257
262
  ecdhCurve?: string; // key-share groups, e.g. 'X25519:P-256'; 'auto' = default
258
263
  };
264
+ /** HTTP/2 (RFC 9113). Off by default. `true`, or an object of settings to
265
+ * advertise. With `ssl` the listener offers "h2" ahead of "http/1.1" in
266
+ * ALPN; without it a client speaks HTTP/2 by opening with the connection
267
+ * preface (prior knowledge, e.g. `curl --http2-prior-knowledge`). Every
268
+ * other client is served HTTP/1.1 on the same port. A request arriving on
269
+ * an HTTP/2 stream is delivered exactly as an HTTP/1 request is - the same
270
+ * callbacks, the same accessors, the same response calls. Not served over
271
+ * HTTP/2: WebSocket upgrades (RFC 8441), server push, CONNECT. */
272
+ http2?:
273
+ | boolean
274
+ | {
275
+ /** Streams a client may have open at once. Default 256. */
276
+ maxConcurrentStreams?: number;
277
+ /** Per-stream receive window, in bytes. Default 1 MiB. */
278
+ initialWindowSize?: number;
279
+ /** Largest frame payload accepted. Default (and minimum) 16,384. */
280
+ maxFrameSize?: number;
281
+ /** Largest decoded request header list. Default: maxHeadSize. */
282
+ maxHeaderListSize?: number;
283
+ /** HPACK dynamic table size offered to the client. Default 4,096. */
284
+ headerTableSize?: number;
285
+ };
259
286
  /** WebSocket permessage-deflate (RFC 7692). Off by default.
260
287
  * boolean to enable with defaults, or an options object. */
261
288
  wsDeflate?:
@@ -326,6 +353,25 @@ export function getHeader(reqId: number, lowercaseName: string): string | undefi
326
353
  * without a copy and stay valid for as long as JS holds the buffer; a second
327
354
  * call during the same request returns the same storage, not a snapshot. */
328
355
  export function getBody(reqId: number): ArrayBuffer | null;
356
+ /** The request's Content-Type: '' when it has a body but no such header,
357
+ * null when it has no body (or the request is gone). */
358
+ export function getBodyType(reqId: number): string | null;
359
+ /** The body as a string when every byte of it is ASCII, null otherwise (read
360
+ * it with getBody then). The string is the exact bytes received - decoded
361
+ * as UTF-8 or as Latin-1 it is the same text - and lives on the JS heap
362
+ * like any other string, where getBody's ArrayBuffer counts as external
363
+ * memory until a collection frees it. Null once getBody has taken the
364
+ * bytes. */
365
+ export function getBodyText(reqId: number): string | null;
366
+ /** The body as an ArrayBuffer that is detached when the response is complete
367
+ * or the request is aborted (byteLength 0, every view empty). The bytes are
368
+ * moved into it, not copied, and released at that moment instead of at some
369
+ * later collection - which is what keeps a server reading bodies at a high
370
+ * rate out of back-to-back full collections. For a handler that relays,
371
+ * hashes or echoes a body and keeps none of it. Code that keeps the body
372
+ * past the response reads it with getBody (a copy, during a loan) or
373
+ * transfers the lent buffer. Null when there is no body. */
374
+ export function getBodyLent(reqId: number): ArrayBuffer | null;
329
375
  export function getRemoteAddress(reqId: number): string;
330
376
  export function isAborted(reqId: number): boolean;
331
377
 
@@ -463,6 +509,9 @@ declare const engine: {
463
509
  getHeaders: typeof getHeaders;
464
510
  getHeader: typeof getHeader;
465
511
  getBody: typeof getBody;
512
+ getBodyType: typeof getBodyType;
513
+ getBodyText: typeof getBodyText;
514
+ getBodyLent: typeof getBodyLent;
466
515
  getRemoteAddress: typeof getRemoteAddress;
467
516
  isAborted: typeof isAborted;
468
517
  respond: typeof respond;
package/index.js CHANGED
@@ -161,6 +161,9 @@ const NATIVE_API = new Set([
161
161
  'getHeaders',
162
162
  'getHeader',
163
163
  'getBody',
164
+ 'getBodyType',
165
+ 'getBodyText',
166
+ 'getBodyLent',
164
167
  'getRemoteAddress',
165
168
  'isAborted',
166
169
  'respond',
package/index.mjs CHANGED
@@ -38,6 +38,9 @@ export let getQuery = (...a) => (getQuery = engine.getQuery)(...a);
38
38
  export let getHeaders = (...a) => (getHeaders = engine.getHeaders)(...a);
39
39
  export let getHeader = (...a) => (getHeader = engine.getHeader)(...a);
40
40
  export let getBody = (...a) => (getBody = engine.getBody)(...a);
41
+ export let getBodyType = (...a) => (getBodyType = engine.getBodyType)(...a);
42
+ export let getBodyText = (...a) => (getBodyText = engine.getBodyText)(...a);
43
+ export let getBodyLent = (...a) => (getBodyLent = engine.getBodyLent)(...a);
41
44
  export let getRemoteAddress = (...a) => (getRemoteAddress = engine.getRemoteAddress)(...a);
42
45
  export let isAborted = (...a) => (isAborted = engine.isAborted)(...a);
43
46
  export let respond = (...a) => (respond = engine.respond)(...a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morojs/engine",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
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.18",
42
- "@morojs/engine-darwin-x64": "1.1.18",
43
- "@morojs/engine-linux-x64-gnu": "1.1.18",
44
- "@morojs/engine-linux-arm64-gnu": "1.1.18",
45
- "@morojs/engine-linux-x64-musl": "1.1.18",
46
- "@morojs/engine-linux-arm64-musl": "1.1.18",
47
- "@morojs/engine-win32-x64": "1.1.18"
41
+ "@morojs/engine-darwin-arm64": "1.1.19",
42
+ "@morojs/engine-darwin-x64": "1.1.19",
43
+ "@morojs/engine-linux-x64-gnu": "1.1.19",
44
+ "@morojs/engine-linux-arm64-gnu": "1.1.19",
45
+ "@morojs/engine-linux-x64-musl": "1.1.19",
46
+ "@morojs/engine-linux-arm64-musl": "1.1.19",
47
+ "@morojs/engine-win32-x64": "1.1.19"
48
48
  },
49
49
  "keywords": [
50
50
  "morojs",