@morojs/engine 1.1.6 → 1.1.9

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 CHANGED
@@ -78,7 +78,11 @@ once per process by a feature check and a self-test, and anywhere it is
78
78
  unavailable (kernels before 6.1, gVisor, containers under Docker's default
79
79
  seccomp profile, which blocks `io_uring_setup`) the engine silently stays on
80
80
  libuv. Neither transport changes a byte on the wire. `probe().transport`
81
- reports which one is live and `probe().transportReason` why.
81
+ reports which one is live, `probe().transportReason` why, and
82
+ `probe().transportMode` which io_uring ring mode is running: `defer-taskrun`
83
+ (completions run as one batch inside the engine's own `io_uring_enter`, woken
84
+ through a registered eventfd) or `coop-taskrun` (the 1.1.6 mode, also
85
+ selectable with `MORO_ENGINE_URING_TASKRUN=coop`).
82
86
 
83
87
  ## License
84
88
 
package/index.d.ts CHANGED
@@ -25,11 +25,22 @@ export interface EngineCapabilities {
25
25
  /** Explicit TLS cipher/group policy is parsed:
26
26
  * ServeOptions.ssl.ciphers, ciphersuites, and ecdhCurve. */
27
27
  tlsPolicy: boolean;
28
+ /** updateSsl() is available: the certificate/key (and policy) of a TLS
29
+ * server can be replaced for new handshakes without a restart. */
30
+ tlsReload: boolean;
28
31
  /** setStaticRoute() / clearStaticRoutes() are available. */
29
32
  staticRoutes: boolean;
33
+ /** setParamRoute() / clearParamRoutes() are available: a route with one
34
+ * variable path segment, echoed as the body, answered inside the engine. */
35
+ paramRoutes: boolean;
30
36
  /** prepareResponse() / releaseTemplates() / respondPrepared() /
31
37
  * respondPreparedEmpty() / writeHeadPrepared() / endWith() are available. */
32
38
  responseTemplates: boolean;
39
+ /** Every callback into JS (onRequest, onRequestBatch, onAborted, onWritable,
40
+ * the WebSocket callbacks) runs inside a Node callback scope, so
41
+ * process.nextTick callbacks and microtasks queued during dispatch run
42
+ * when the callback returns, as they do after Node's own I/O callbacks. */
43
+ callbackScope: boolean;
33
44
  /** onAborted / onWritable are delivered on a later loop turn - never
34
45
  * re-entrantly from inside respond()/writeHead()/write()/end(). close()
35
46
  * still delivers pending onAborted calls before it returns. False only
@@ -90,6 +101,11 @@ export interface EngineProbeResult {
90
101
  transport?: 'uv' | 'uring';
91
102
  /** Why the transport is not io_uring ('ok' when it is). */
92
103
  transportReason?: string;
104
+ /** 'uv', or the io_uring ring mode in use: 'defer-taskrun' (completions run
105
+ * as one batch inside the engine's own io_uring_enter, woken through a
106
+ * registered eventfd) or 'coop-taskrun' (the 1.1.6 mode). The probe tries
107
+ * defer first; MORO_ENGINE_URING_TASKRUN=coop|defer pins one. */
108
+ transportMode?: 'uv' | 'defer-taskrun' | 'coop-taskrun';
93
109
  /** Per-thread fast/slow hit counters per hot entry point - present only when
94
110
  * MORO_ENGINE_FASTCALL_STATS=1 was set when the addon loaded (test/CI proof
95
111
  * that the fast path is taken). */
@@ -273,6 +289,14 @@ export function close(serverId: number): void;
273
289
  /** Stop accepting new connections while existing ones keep being served —
274
290
  * the drain phase of a graceful shutdown. Idempotent. */
275
291
  export function stopListening(serverId: number): void;
292
+ /** Replace the TLS certificate/key (and cipher policy) used for every
293
+ * handshake from now on, without restarting the listener (feature-detect via
294
+ * probe().capabilities.tlsReload). `ssl` is the full ServeOptions.ssl shape,
295
+ * not a diff; ticketKeys carry over when omitted so session resumption
296
+ * survives a rotation. Established connections keep the context they
297
+ * handshaked with. Throws (leaving the current context in place) on invalid
298
+ * material, and for a server that was not started with ssl. */
299
+ export function updateSsl(serverId: number, ssl: NonNullable<ServeOptions['ssl']>): void;
276
300
 
277
301
  // ---- per-request accessors (valid until the response ends / aborts) ----
278
302
  export function getMethod(reqId: number): string | undefined;
@@ -334,6 +358,29 @@ export function setStaticRoute(
334
358
  /** Drop every static route registered on this server. */
335
359
  export function clearStaticRoutes(serverId: number): void;
336
360
 
361
+ // ---- Parameter routes ----
362
+ /** Register a route with ONE variable path segment whose body IS that
363
+ * segment, answered entirely inside the engine like a static route:
364
+ * `/user/:id` is prefix "/user/" and suffix ""; `/files/:name.json` is
365
+ * prefix "/files/" and suffix ".json". The segment must be non-empty and
366
+ * contain no '/', so `/user/` and `/user/1/2` still reach onRequest. It is
367
+ * written as it is on the wire, undecoded (uWS's writeParameterValue does
368
+ * the same); a route that needs decoding stays a JS route. The header block
369
+ * is materialised once, so the reply is byte-identical to
370
+ * respond(status, headersFlat, segment). Only an exact method match
371
+ * short-circuits; re-registering (method, prefix, suffix) replaces it.
372
+ * Feature-detect via probe().capabilities.paramRoutes. */
373
+ export function setParamRoute(
374
+ serverId: number,
375
+ method: number,
376
+ prefix: string,
377
+ suffix: string,
378
+ status?: number,
379
+ headersFlat?: string[] | null
380
+ ): void;
381
+ /** Drop every parameter route registered on this server. */
382
+ export function clearParamRoutes(serverId: number): void;
383
+
337
384
  // ---- Prepared response templates ----
338
385
  /** Materialise status + headers ONCE (the same header builder respond() uses,
339
386
  * so the wire bytes are identical) and get back a template id to replay per
@@ -385,6 +432,7 @@ declare const engine: {
385
432
  listen: typeof listen;
386
433
  close: typeof close;
387
434
  stopListening: typeof stopListening;
435
+ updateSsl: typeof updateSsl;
388
436
  getMethod: typeof getMethod;
389
437
  getBatchBuffers: typeof getBatchBuffers;
390
438
  getPath: typeof getPath;
@@ -400,6 +448,8 @@ declare const engine: {
400
448
  end: typeof end;
401
449
  setStaticRoute: typeof setStaticRoute;
402
450
  clearStaticRoutes: typeof clearStaticRoutes;
451
+ setParamRoute: typeof setParamRoute;
452
+ clearParamRoutes: typeof clearParamRoutes;
403
453
  prepareResponse: typeof prepareResponse;
404
454
  releaseTemplates: typeof releaseTemplates;
405
455
  respondPrepared: typeof respondPrepared;
package/index.js CHANGED
@@ -153,6 +153,7 @@ const NATIVE_API = new Set([
153
153
  'listen',
154
154
  'close',
155
155
  'stopListening',
156
+ 'updateSsl',
156
157
  'getMethod',
157
158
  'getBatchBuffers',
158
159
  'getPath',
@@ -168,6 +169,8 @@ const NATIVE_API = new Set([
168
169
  'end',
169
170
  'setStaticRoute',
170
171
  'clearStaticRoutes',
172
+ 'setParamRoute',
173
+ 'clearParamRoutes',
171
174
  'prepareResponse',
172
175
  'releaseTemplates',
173
176
  'respondPrepared',
package/index.mjs CHANGED
@@ -30,6 +30,7 @@ export let serve = (...a) => (serve = engine.serve)(...a);
30
30
  export let listen = (...a) => (listen = engine.listen)(...a);
31
31
  export let close = (...a) => (close = engine.close)(...a);
32
32
  export let stopListening = (...a) => (stopListening = engine.stopListening)(...a);
33
+ export let updateSsl = (...a) => (updateSsl = engine.updateSsl)(...a);
33
34
  export let getMethod = (...a) => (getMethod = engine.getMethod)(...a);
34
35
  export let getBatchBuffers = (...a) => (getBatchBuffers = engine.getBatchBuffers)(...a);
35
36
  export let getPath = (...a) => (getPath = engine.getPath)(...a);
@@ -45,6 +46,8 @@ export let write = (...a) => (write = engine.write)(...a);
45
46
  export let end = (...a) => (end = engine.end)(...a);
46
47
  export let setStaticRoute = (...a) => (setStaticRoute = engine.setStaticRoute)(...a);
47
48
  export let clearStaticRoutes = (...a) => (clearStaticRoutes = engine.clearStaticRoutes)(...a);
49
+ export let setParamRoute = (...a) => (setParamRoute = engine.setParamRoute)(...a);
50
+ export let clearParamRoutes = (...a) => (clearParamRoutes = engine.clearParamRoutes)(...a);
48
51
  export let prepareResponse = (...a) => (prepareResponse = engine.prepareResponse)(...a);
49
52
  export let releaseTemplates = (...a) => (releaseTemplates = engine.releaseTemplates)(...a);
50
53
  export let respondPrepared = (...a) => (respondPrepared = engine.respondPrepared)(...a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morojs/engine",
3
- "version": "1.1.6",
3
+ "version": "1.1.9",
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.6",
42
- "@morojs/engine-darwin-x64": "1.1.6",
43
- "@morojs/engine-linux-x64-gnu": "1.1.6",
44
- "@morojs/engine-linux-arm64-gnu": "1.1.6",
45
- "@morojs/engine-linux-x64-musl": "1.1.6",
46
- "@morojs/engine-linux-arm64-musl": "1.1.6",
47
- "@morojs/engine-win32-x64": "1.1.6"
41
+ "@morojs/engine-darwin-arm64": "1.1.9",
42
+ "@morojs/engine-darwin-x64": "1.1.9",
43
+ "@morojs/engine-linux-x64-gnu": "1.1.9",
44
+ "@morojs/engine-linux-arm64-gnu": "1.1.9",
45
+ "@morojs/engine-linux-x64-musl": "1.1.9",
46
+ "@morojs/engine-linux-arm64-musl": "1.1.9",
47
+ "@morojs/engine-win32-x64": "1.1.9"
48
48
  },
49
49
  "keywords": [
50
50
  "morojs",