@synapticon/motion-master-client 6.0.0-alpha.52 → 6.0.0-alpha.54

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/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from './hex.js';
8
8
  export * from './sdo.js';
9
9
  export * from './somanet.js';
10
10
  export * from './mmpd.js';
11
+ export * from './wire-time.js';
package/dist/index.js CHANGED
@@ -14,3 +14,4 @@ export * from './hex.js';
14
14
  export * from './sdo.js';
15
15
  export * from './somanet.js';
16
16
  export * from './mmpd.js';
17
+ export * from './wire-time.js';
@@ -0,0 +1,2 @@
1
+ export declare const WIRE_TIME_HEADER = "X-Wire-Us";
2
+ export declare function wireTimeMs(res: Response): number | null;
@@ -0,0 +1,18 @@
1
+ // Helper for the server-measured wire-time channel.
2
+ //
3
+ // Endpoints that perform a fieldbus transaction (SDO, FoE, ...) report the on-device wire cost —
4
+ // control-plane lock acquire + the mailbox/ESC round-trip — via the `X-Wire-Us` response header
5
+ // (microseconds), independent of the response body shape. A cross-origin client subtracts this
6
+ // from its own observed HTTP round-trip to separate the device cost from browser/transport
7
+ // overhead. The header is CORS-exposed by the server so it is readable cross-origin.
8
+ // Name of the wire-time response header (microseconds, integer).
9
+ export const WIRE_TIME_HEADER = 'X-Wire-Us';
10
+ // Reads the server-measured wire time from a response, in milliseconds, or null if the header is
11
+ // absent or unparseable. Accepts any `Response` (the generated client's `HttpResponse` extends it).
12
+ export function wireTimeMs(res) {
13
+ const raw = res.headers.get(WIRE_TIME_HEADER);
14
+ if (raw === null)
15
+ return null;
16
+ const us = Number(raw);
17
+ return Number.isFinite(us) ? us / 1000 : null;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapticon/motion-master-client",
3
- "version": "6.0.0-alpha.52",
3
+ "version": "6.0.0-alpha.54",
4
4
  "description": "Isomorphic TypeScript client for Motion Master: the generated HTTP API client, the WebSocket connection, and helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {