cry-ebus2 4.0.13 → 4.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"echoWorker.d.mts","sourceRoot":"","sources":["../src/echoWorker.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGrC,qBAAa,UAAW,SAAQ,MAAM;IAClC,OAAO,SAAS;IAEV,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAKxC"}
1
+ {"version":3,"file":"echoWorker.d.mts","sourceRoot":"","sources":["../src/echoWorker.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,qBAAa,UAAW,SAAQ,MAAM;IAClC,OAAO,SAAS;IAEV,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAGxC"}
@@ -1,4 +1,4 @@
1
- import { sleep } from "./sleep.mjs";
1
+ // AI modified: 2026-05-13 (removed parseInt+sleep delay-and-echo is a separate concern handled by DelayWorker; pure echo here)
2
2
  import { Worker } from "./worker.mjs";
3
3
  export class EchoWorker extends Worker {
4
4
  constructor() {
@@ -6,9 +6,6 @@ export class EchoWorker extends Worker {
6
6
  this.service = "echo";
7
7
  }
8
8
  async process(msg) {
9
- let num = Number.parseInt(msg);
10
- if (!isNaN(num))
11
- await sleep(num);
12
9
  return msg;
13
10
  }
14
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"echoWorker.mjs","sourceRoot":"","sources":["../src/echoWorker.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGrC,MAAM,OAAO,UAAW,SAAQ,MAAM;IAAtC;;QACI,YAAO,GAAG,MAAM,CAAA;IAOpB,CAAC;IALG,KAAK,CAAC,OAAO,CAAC,GAAQ;QAClB,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;QACjC,OAAO,GAAG,CAAA;IACd,CAAC;CACJ"}
1
+ {"version":3,"file":"echoWorker.mjs","sourceRoot":"","sources":["../src/echoWorker.mts"],"names":[],"mappings":"AAAA,iIAAiI;AACjI,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,MAAM,OAAO,UAAW,SAAQ,MAAM;IAAtC;;QACI,YAAO,GAAG,MAAM,CAAA;IAKpB,CAAC;IAHG,KAAK,CAAC,OAAO,CAAC,GAAQ;QAClB,OAAO,GAAG,CAAA;IACd,CAAC;CACJ"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Types-only export for browser / type-only consumers.
3
+ * No runtime code, no dependencies — safe for `import type` in any environment.
4
+ *
5
+ * Usage:
6
+ * import type { EbusConfiguration, EbusRequestOptions, ... } from "cry-ebus2/typesOnly"
7
+ */
8
+ export interface EbusConfiguration {
9
+ address: string;
10
+ pubAddress: string;
11
+ sendHighWaterMark: number;
12
+ sendTimeout: number;
13
+ port: number;
14
+ pubPort: number;
15
+ server: string;
16
+ receiveTimeout: number;
17
+ heartbeatInterval: number;
18
+ heartbeatTimeout: number;
19
+ brokerHeartbeatTimeout: number;
20
+ clientChecksBrokerWithHeartbeat: boolean;
21
+ brokerChecksWorkersWithHeartbeat: boolean;
22
+ requestQueueSizeLimit: number;
23
+ }
24
+ export interface EbusRequestOptions {
25
+ receiveTimeout: number;
26
+ zip: boolean;
27
+ raw: boolean;
28
+ prepacked: boolean;
29
+ returningError?: boolean;
30
+ /** Milliseconds to hold the request on the broker before dispatching to a worker. Expiry is extended by this amount. */
31
+ delayMs?: number;
32
+ }
33
+ export interface EbusClientEvents {
34
+ "ebus/start": () => void;
35
+ "ebus/stop": () => void;
36
+ }
37
+ export type EbusRejectReason = "timeout" | "reject" | "error";
38
+ export interface EbusRejectError extends Error {
39
+ rejectMessage?: string;
40
+ reason: EbusRejectReason;
41
+ more: any;
42
+ }
43
+ export interface EbusUnpackedResult<T = any> {
44
+ opts: Partial<EbusRequestOptions>;
45
+ data: T;
46
+ unpack: (data: any, opts: Partial<EbusRequestOptions>) => any;
47
+ type: "reply" | "error" | "reject" | "timeout" | "unknown";
48
+ }
49
+ /** Wire protocol header byte. C01 = client, W01 = worker. */
50
+ export type Header = "C01" | "W01";
51
+ /** Wire protocol message type byte. */
52
+ export type Message = "\x00" | "\x01" | "\x02" | "\x03" | "\x04" | "\x05" | "\x06" | "\x07" | "\x08" | "\x10" | "\x11" | "\x12" | "\x13" | "\x14" | "\x15" | "\x16";
53
+ export interface DelayRequest {
54
+ delay: number;
55
+ block: boolean;
56
+ }
57
+ export interface ErrorRequest {
58
+ more: any;
59
+ delay: number;
60
+ message: string;
61
+ }
62
+ export interface RejectRequest {
63
+ more: any;
64
+ delay: number;
65
+ message: string;
66
+ }
67
+ //# sourceMappingURL=typesOnly.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typesOnly.d.mts","sourceRoot":"","sources":["../src/typesOnly.mts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,+BAA+B,EAAE,OAAO,CAAC;IACzC,gCAAgC,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M,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Types-only export for browser / type-only consumers.
3
+ * No runtime code, no dependencies — safe for `import type` in any environment.
4
+ *
5
+ * Usage:
6
+ * import type { EbusConfiguration, EbusRequestOptions, ... } from "cry-ebus2/typesOnly"
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=typesOnly.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typesOnly.mjs","sourceRoot":"","sources":["../src/typesOnly.mts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "cry-ebus2",
3
- "version": "4.0.13",
3
+ "version": "4.0.15",
4
4
  "description": "",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.mts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.mts",
10
+ "default": "./dist/index.mjs"
11
+ },
12
+ "./typesOnly": {
13
+ "types": "./dist/typesOnly.d.mts",
14
+ "default": "./dist/typesOnly.mjs"
15
+ }
16
+ },
7
17
  "type": "module",
8
18
  "scripts": {
9
19
  "build": "tsc",
@@ -1,13 +1,10 @@
1
- import { sleep } from "./sleep.mjs"
1
+ // AI modified: 2026-05-13 (removed parseInt+sleep delay-and-echo is a separate concern handled by DelayWorker; pure echo here)
2
2
  import { Worker } from "./worker.mjs"
3
3
 
4
-
5
4
  export class EchoWorker extends Worker {
6
5
  service = "echo"
7
6
 
8
7
  async process(msg: any): Promise<any> {
9
- let num = Number.parseInt(msg)
10
- if (!isNaN(num)) await sleep(num)
11
8
  return msg
12
9
  }
13
10
  }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Types-only export for browser / type-only consumers.
3
+ * No runtime code, no dependencies — safe for `import type` in any environment.
4
+ *
5
+ * Usage:
6
+ * import type { EbusConfiguration, EbusRequestOptions, ... } from "cry-ebus2/typesOnly"
7
+ */
8
+
9
+ // ── Configuration ──────────────────────────────────────────────────────────────
10
+
11
+ export interface EbusConfiguration {
12
+ address: string;
13
+ pubAddress: string;
14
+ sendHighWaterMark: number;
15
+ sendTimeout: number;
16
+ port: number;
17
+ pubPort: number;
18
+ server: string;
19
+ receiveTimeout: number;
20
+ heartbeatInterval: number;
21
+ heartbeatTimeout: number;
22
+ brokerHeartbeatTimeout: number;
23
+ clientChecksBrokerWithHeartbeat: boolean;
24
+ brokerChecksWorkersWithHeartbeat: boolean;
25
+ requestQueueSizeLimit: number;
26
+ }
27
+
28
+ // ── Request options ───────────────────────────────────────────────────────────
29
+
30
+ export interface EbusRequestOptions {
31
+ receiveTimeout: number;
32
+ zip: boolean;
33
+ raw: boolean;
34
+ prepacked: boolean;
35
+ returningError?: boolean;
36
+ /** Milliseconds to hold the request on the broker before dispatching to a worker. Expiry is extended by this amount. */
37
+ delayMs?: number;
38
+ }
39
+
40
+ // ── Events ────────────────────────────────────────────────────────────────────
41
+
42
+ export interface EbusClientEvents {
43
+ "ebus/start": () => void;
44
+ "ebus/stop": () => void;
45
+ }
46
+
47
+ // ── Reject types ──────────────────────────────────────────────────────────────
48
+
49
+ export type EbusRejectReason = "timeout" | "reject" | "error";
50
+
51
+ export interface EbusRejectError extends Error {
52
+ rejectMessage?: string;
53
+ reason: EbusRejectReason;
54
+ more: any;
55
+ }
56
+
57
+ // ── Unpacked result ───────────────────────────────────────────────────────────
58
+
59
+ export interface EbusUnpackedResult<T = any> {
60
+ opts: Partial<EbusRequestOptions>;
61
+ data: T;
62
+ unpack: (data: any, opts: Partial<EbusRequestOptions>) => any;
63
+ type: "reply" | "error" | "reject" | "timeout" | "unknown";
64
+ }
65
+
66
+ // ── Wire protocol enums ───────────────────────────────────────────────────────
67
+
68
+ /** Wire protocol header byte. C01 = client, W01 = worker. */
69
+ export type Header = "C01" | "W01";
70
+
71
+ /** Wire protocol message type byte. */
72
+ export type Message =
73
+ | "\x00" // None
74
+ | "\x01" // Ready
75
+ | "\x02" // Request
76
+ | "\x03" // Reply
77
+ | "\x04" // Error
78
+ | "\x05" // Reject
79
+ | "\x06" // Timeout
80
+ | "\x07" // Heartbeat
81
+ | "\x08" // Disconnect
82
+ | "\x10" // Services
83
+ | "\x11" // Workers
84
+ | "\x12" // Subscribe
85
+ | "\x13" // Publish
86
+ | "\x14" // Shutdown
87
+ | "\x15" // ShutdownAndRestart
88
+ | "\x16"; // RestartAllWorkers
89
+
90
+ // ── Worker request interfaces ─────────────────────────────────────────────────
91
+
92
+ export interface DelayRequest {
93
+ delay: number;
94
+ block: boolean;
95
+ }
96
+
97
+ export interface ErrorRequest {
98
+ more: any;
99
+ delay: number;
100
+ message: string;
101
+ }
102
+
103
+ export interface RejectRequest {
104
+ more: any;
105
+ delay: number;
106
+ message: string;
107
+ }