mq-bridge 0.3.0 → 0.3.1
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 +81 -1
- package/index.d.ts +59 -6
- package/index.js +68 -8
- package/native.d.ts +119 -6
- package/native.js +53 -52
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ npm run example
|
|
|
24
24
|
```ts
|
|
25
25
|
import { Message, Route } from "mq-bridge";
|
|
26
26
|
|
|
27
|
-
const route = Route.
|
|
27
|
+
const route = Route.fromStr(config, "orders");
|
|
28
28
|
|
|
29
29
|
route.withHandler(async (message) => {
|
|
30
30
|
const data = message.json();
|
|
@@ -39,3 +39,83 @@ route.start();
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
Middleware is configured through the normal mq-bridge route config.
|
|
42
|
+
|
|
43
|
+
## Loading config
|
|
44
|
+
|
|
45
|
+
The constructors mirror the Python bindings — the same capabilities are exposed
|
|
46
|
+
in both, with Node using camelCase names where Python uses snake_case:
|
|
47
|
+
|
|
48
|
+
- `Route.fromFile(path, name?)` loads from a YAML/JSON file
|
|
49
|
+
- `Route.fromStr(text, name?)` loads from an in-memory YAML/JSON string
|
|
50
|
+
- `Route.fromConfig(obj, name?)` loads from a JS object
|
|
51
|
+
- `Publisher.fromFile` / `Publisher.fromStr` / `Publisher.fromConfig` build a publisher endpoint
|
|
52
|
+
|
|
53
|
+
The `name` is optional: pass it to pick one entry out of a `routes:`/`publishers:`
|
|
54
|
+
document, or omit it to treat the whole config as a single bare route/endpoint body.
|
|
55
|
+
`fromYaml` / `fromYamlStr` remain as deprecated aliases for `fromFile` / `fromStr`.
|
|
56
|
+
|
|
57
|
+
## Pull-based consumer
|
|
58
|
+
|
|
59
|
+
`Route` is push-based. To pull messages on your own schedule, use `Consumer`,
|
|
60
|
+
which wraps any input endpoint:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { Consumer } from "mq-bridge";
|
|
64
|
+
|
|
65
|
+
const consumer = Consumer.fromConfig({ nats: { subject: "orders", url: "nats://localhost:4222" } });
|
|
66
|
+
|
|
67
|
+
while (!consumer.exhausted) {
|
|
68
|
+
const batch = await consumer.poll(500, 1000); // [] on timeout
|
|
69
|
+
if (batch.length === 0) continue;
|
|
70
|
+
for (const message of batch) handle(message.json());
|
|
71
|
+
await consumer.commit(); // ack only after handling
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`poll(max?, timeoutMs?)` returns up to `max` messages (default 256) without
|
|
76
|
+
acking, waiting up to `timeoutMs` milliseconds (omit it to block until a message
|
|
77
|
+
arrives); `commit()` acks every batch returned since the last commit. Committing
|
|
78
|
+
only after the downstream write succeeds gives at-least-once delivery. `exhausted`
|
|
79
|
+
turns `true` once a bounded source (e.g. a file) is drained; streaming brokers
|
|
80
|
+
never set it. `Consumer.fromFile` / `fromStr` accept a named entry under a
|
|
81
|
+
`consumers:` section or a single bare endpoint body.
|
|
82
|
+
|
|
83
|
+
`consumer.status()` resolves to a snapshot (`healthy`, `target`, `pending`,
|
|
84
|
+
`capacity`, `error`, `details`). `pending` is the broker backlog/lag where the
|
|
85
|
+
transport reports it (Kafka offset lag, AMQP queue depth, NATS JetStream
|
|
86
|
+
`numPending`), so `pending === 0` is a precise "caught up" check; it's absent
|
|
87
|
+
where the broker exposes no backlog (core NATS, MQTT). `consumer.close()`
|
|
88
|
+
releases the connection — idempotent, and `poll()`/`status()` reject afterwards.
|
|
89
|
+
Node is garbage-collected, so close explicitly rather than waiting for GC.
|
|
90
|
+
|
|
91
|
+
> **You must call `commit()` — it is not optional.** It is the only thing that
|
|
92
|
+
> tells the broker a batch is done. If you keep polling without committing, the
|
|
93
|
+
> offset never advances (every message is **re-delivered** on the next run), most
|
|
94
|
+
> brokers **stall** once their unacknowledged/prefetch window fills, and the
|
|
95
|
+
> uncommitted batches are held in memory so the process **grows unbounded**.
|
|
96
|
+
> Commit after each batch you have durably handled; to retry a failed batch,
|
|
97
|
+
> simply don't commit it.
|
|
98
|
+
|
|
99
|
+
## Analysis
|
|
100
|
+
|
|
101
|
+
HTTP comparison benchmark, driven by a native load generator (`wrk`) so the
|
|
102
|
+
client is never the bottleneck. It boots each server in its own process — the
|
|
103
|
+
mq-bridge Node route plus raw Node `http`, uWebSockets.js, Fastify, and Express
|
|
104
|
+
(all peers run only when installed) — and drives each with `wrk`:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cd node/mq-bridge-node
|
|
108
|
+
npm run build # release addon (the bench is meaningless on a debug build)
|
|
109
|
+
npm i -D fastify express # optional Node HTTP peers
|
|
110
|
+
npm i -D uNetworking/uWebSockets.js#v20.51.0 # the http-arena Node leader (native, from GitHub)
|
|
111
|
+
npm run bench:http -- --connections 1,8,32 --duration 8
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Requires `wrk` on `PATH` (`brew install wrk`). The `mqb` target needs the addon
|
|
115
|
+
built with the `http` feature (`npm run build` or `npm run build:ci`). Each
|
|
116
|
+
server echoes a tiny JSON body with `value` incremented; mq-bridge routes on the
|
|
117
|
+
`kind` header while the framework peers post plain JSON.
|
|
118
|
+
|
|
119
|
+
`uws` (uWebSockets.js) is the framework that tops public Node benchmarks like
|
|
120
|
+
http-arena and TechEmpower — it bypasses Node's `http` stack with a C++ socket
|
|
121
|
+
layer, so it is the most demanding yardstick here.
|
package/index.d.ts
CHANGED
|
@@ -22,19 +22,72 @@ export class Message {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export class Publisher {
|
|
25
|
-
static
|
|
26
|
-
static
|
|
27
|
-
static fromConfig(config: JsonValue, name
|
|
25
|
+
static fromFile(path: string, name?: string | null): Publisher;
|
|
26
|
+
static fromStr(text: string, name?: string | null): Publisher;
|
|
27
|
+
static fromConfig(config: JsonValue, name?: string | null): Publisher;
|
|
28
|
+
/** @deprecated Use {@link Publisher.fromFile} instead. */
|
|
29
|
+
static fromYaml(path: string, name?: string | null): Publisher;
|
|
30
|
+
/** @deprecated Use {@link Publisher.fromStr} instead. */
|
|
31
|
+
static fromYamlStr(text: string, name?: string | null): Publisher;
|
|
28
32
|
send(message: Message): Promise<void>;
|
|
29
33
|
request(message: Message): Promise<Message>;
|
|
30
34
|
sendJson(data: JsonValue, metadata?: Metadata | null, id?: string | null): Promise<void>;
|
|
31
35
|
requestJson(data: JsonValue, metadata?: Metadata | null, id?: string | null): Promise<Message>;
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
export interface ConsumerStatus {
|
|
39
|
+
healthy: boolean;
|
|
40
|
+
target: string;
|
|
41
|
+
/** Broker backlog/lag where the transport reports it; absent otherwise. */
|
|
42
|
+
pending?: number;
|
|
43
|
+
capacity?: number;
|
|
44
|
+
error?: string;
|
|
45
|
+
details: JsonValue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class Consumer {
|
|
49
|
+
static fromFile(path: string, name?: string | null): Consumer;
|
|
50
|
+
static fromStr(text: string, name?: string | null): Consumer;
|
|
51
|
+
static fromConfig(config: JsonValue, name?: string | null): Consumer;
|
|
52
|
+
/**
|
|
53
|
+
* Receive up to `max` messages (default 256) without acking. Resolves to an
|
|
54
|
+
* empty array if `timeoutMs` milliseconds elapse with nothing received, or the
|
|
55
|
+
* source is exhausted. Omit `timeoutMs` to block until a message arrives. The
|
|
56
|
+
* returned messages are acked by the next `commit()` call — which you must
|
|
57
|
+
* call (see {@link Consumer.commit}).
|
|
58
|
+
*/
|
|
59
|
+
poll(max?: number | null, timeoutMs?: number | null): Promise<Message[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Acknowledge every batch returned by `poll()` since the last `commit()`,
|
|
62
|
+
* advancing the consumer offset.
|
|
63
|
+
*
|
|
64
|
+
* Calling this is required, not optional. Without it the offset never advances
|
|
65
|
+
* (messages are re-delivered on the next run), most brokers stall once their
|
|
66
|
+
* unacknowledged/prefetch window fills, and uncommitted batches are held in
|
|
67
|
+
* memory so the process grows unbounded. To retry a failed batch, simply
|
|
68
|
+
* don't commit it — it will be redelivered.
|
|
69
|
+
*/
|
|
70
|
+
commit(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Status snapshot for the underlying endpoint. `pending === 0` is a precise
|
|
73
|
+
* "caught up" signal on transports that report backlog (Kafka, AMQP, NATS
|
|
74
|
+
* JetStream); `pending` is absent where the broker exposes none.
|
|
75
|
+
*/
|
|
76
|
+
status(): Promise<ConsumerStatus>;
|
|
77
|
+
/** Release the broker connection. Idempotent; `poll()`/`status()` reject after. */
|
|
78
|
+
close(): Promise<void>;
|
|
79
|
+
/** `true` once the source has signalled end-of-stream (e.g. a drained file). */
|
|
80
|
+
get exhausted(): boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
34
83
|
export class Route {
|
|
35
|
-
static
|
|
36
|
-
static
|
|
37
|
-
static fromConfig(config: JsonValue, name
|
|
84
|
+
static fromFile(path: string, name?: string | null): Route;
|
|
85
|
+
static fromStr(text: string, name?: string | null): Route;
|
|
86
|
+
static fromConfig(config: JsonValue, name?: string | null): Route;
|
|
87
|
+
/** @deprecated Use {@link Route.fromFile} instead. */
|
|
88
|
+
static fromYaml(path: string, name?: string | null): Route;
|
|
89
|
+
/** @deprecated Use {@link Route.fromStr} instead. */
|
|
90
|
+
static fromYamlStr(text: string, name?: string | null): Route;
|
|
38
91
|
withHandler(handler: MessageHandler): void;
|
|
39
92
|
addHandler(kind: string, handler: JsonHandler): void;
|
|
40
93
|
start(): void;
|
package/index.js
CHANGED
|
@@ -57,18 +57,28 @@ class Publisher {
|
|
|
57
57
|
this._native = nativePublisher;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
static
|
|
61
|
-
return new Publisher(native.Publisher.
|
|
60
|
+
static fromFile(path, name) {
|
|
61
|
+
return new Publisher(native.Publisher.fromFile(path, name));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
static
|
|
65
|
-
return new Publisher(native.Publisher.
|
|
64
|
+
static fromStr(text, name) {
|
|
65
|
+
return new Publisher(native.Publisher.fromStr(text, name));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
static fromConfig(config, name) {
|
|
69
69
|
return new Publisher(native.Publisher.fromConfig(config, name));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** @deprecated Use {@link Publisher.fromFile} instead. */
|
|
73
|
+
static fromYaml(path, name) {
|
|
74
|
+
return new Publisher(native.Publisher.fromFile(path, name));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @deprecated Use {@link Publisher.fromStr} instead. */
|
|
78
|
+
static fromYamlStr(text, name) {
|
|
79
|
+
return new Publisher(native.Publisher.fromStr(text, name));
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
send(message) {
|
|
73
83
|
return this._native.send(Message._toNative(message));
|
|
74
84
|
}
|
|
@@ -86,23 +96,72 @@ class Publisher {
|
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
|
|
99
|
+
class Consumer {
|
|
100
|
+
constructor(nativeConsumer) {
|
|
101
|
+
this._native = nativeConsumer;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static fromFile(path, name) {
|
|
105
|
+
return new Consumer(native.Consumer.fromFile(path, name));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static fromStr(text, name) {
|
|
109
|
+
return new Consumer(native.Consumer.fromStr(text, name));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static fromConfig(config, name) {
|
|
113
|
+
return new Consumer(native.Consumer.fromConfig(config, name));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async poll(max, timeoutMs) {
|
|
117
|
+
const messages = await this._native.poll(max, timeoutMs);
|
|
118
|
+
return messages.map((message) => Message._fromNative(message));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
commit() {
|
|
122
|
+
return this._native.commit();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
status() {
|
|
126
|
+
return this._native.status();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
close() {
|
|
130
|
+
return this._native.close();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get exhausted() {
|
|
134
|
+
return this._native.exhausted;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
89
138
|
class Route {
|
|
90
139
|
constructor(nativeRoute) {
|
|
91
140
|
this._native = nativeRoute;
|
|
92
141
|
}
|
|
93
142
|
|
|
94
|
-
static
|
|
95
|
-
return new Route(native.Route.
|
|
143
|
+
static fromFile(path, name) {
|
|
144
|
+
return new Route(native.Route.fromFile(path, name));
|
|
96
145
|
}
|
|
97
146
|
|
|
98
|
-
static
|
|
99
|
-
return new Route(native.Route.
|
|
147
|
+
static fromStr(text, name) {
|
|
148
|
+
return new Route(native.Route.fromStr(text, name));
|
|
100
149
|
}
|
|
101
150
|
|
|
102
151
|
static fromConfig(config, name) {
|
|
103
152
|
return new Route(native.Route.fromConfig(config, name));
|
|
104
153
|
}
|
|
105
154
|
|
|
155
|
+
/** @deprecated Use {@link Route.fromFile} instead. */
|
|
156
|
+
static fromYaml(path, name) {
|
|
157
|
+
return new Route(native.Route.fromFile(path, name));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** @deprecated Use {@link Route.fromStr} instead. */
|
|
161
|
+
static fromYamlStr(text, name) {
|
|
162
|
+
return new Route(native.Route.fromStr(text, name));
|
|
163
|
+
}
|
|
164
|
+
|
|
106
165
|
withHandler(handler) {
|
|
107
166
|
this._native.withHandler(async (error, message) => {
|
|
108
167
|
if (error) {
|
|
@@ -148,6 +207,7 @@ function configSchema() {
|
|
|
148
207
|
module.exports = {
|
|
149
208
|
Message,
|
|
150
209
|
Publisher,
|
|
210
|
+
Consumer,
|
|
151
211
|
Route,
|
|
152
212
|
configSchema,
|
|
153
213
|
version: native.VERSION,
|
package/native.d.ts
CHANGED
|
@@ -1,9 +1,102 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* A pull-based consumer over any mq-bridge input endpoint.
|
|
5
|
+
*
|
|
6
|
+
* `poll()` receives a batch of messages but does **not** acknowledge them;
|
|
7
|
+
* call `commit()` once they have been durably handled to ack every batch
|
|
8
|
+
* returned since the previous commit (advancing offsets / removing them from
|
|
9
|
+
* the source). This manual-commit model gives at-least-once delivery across a
|
|
10
|
+
* failed downstream load. The endpoint config decides durability (consumer vs
|
|
11
|
+
* subscriber mode), exactly as it does for a route input.
|
|
12
|
+
*
|
|
13
|
+
* Relationship to the Rust core: this is a boundary-friendly projection of the
|
|
14
|
+
* core `MessageConsumer::receive_batch`, which is the low-level primitive. Two
|
|
15
|
+
* differences are deliberate, both because a Rust commit closure cannot be
|
|
16
|
+
* handed across the FFI boundary for JS to call later:
|
|
17
|
+
* - `receive_batch` returns the messages *and* their commit closure together;
|
|
18
|
+
* `poll()` returns only the messages and keeps the closure on the Rust side,
|
|
19
|
+
* so committing becomes the separate `commit()` call.
|
|
20
|
+
* - that closure accepts a per-message disposition vector (ack/nack/reject);
|
|
21
|
+
* `poll()` + `commit()` only ack the whole batch.
|
|
22
|
+
* `poll()` additionally layers a `timeoutMs` over `receive_batch` (which has no
|
|
23
|
+
* timeout of its own). Native Rust code should use `receive_batch` directly — it
|
|
24
|
+
* is strictly more expressive and needs no deferred-commit state.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Consumer {
|
|
27
|
+
/**
|
|
28
|
+
* Build a consumer from a YAML or JSON config file. Accepts a `consumers:`
|
|
29
|
+
* document entry (with `name`) or a single bare endpoint body.
|
|
30
|
+
*/
|
|
31
|
+
static fromFile(path: string, name?: string | undefined | null): Consumer
|
|
32
|
+
/** Build a consumer from an in-memory YAML or JSON string. */
|
|
33
|
+
static fromStr(text: string, name?: string | undefined | null): Consumer
|
|
34
|
+
/**
|
|
35
|
+
* Build a consumer from an in-memory mapping (e.g. a JS object). Omit `name`
|
|
36
|
+
* to treat the mapping as a single bare endpoint body.
|
|
37
|
+
*/
|
|
38
|
+
static fromConfig(config: JsonValue, name?: string | undefined | null): Consumer
|
|
39
|
+
/**
|
|
40
|
+
* Receive up to `max` messages without acking. Resolves to an empty array
|
|
41
|
+
* if `timeoutMs` milliseconds elapse with nothing received, or the source is
|
|
42
|
+
* exhausted (see `exhausted`). Omit `timeoutMs` to block until a message
|
|
43
|
+
* arrives. Acked by the next `commit()`.
|
|
44
|
+
*/
|
|
45
|
+
poll(max?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<Array<NativeMessage>>
|
|
46
|
+
/**
|
|
47
|
+
* Acknowledge every batch returned by `poll()` since the last `commit()`,
|
|
48
|
+
* advancing the consumer offset.
|
|
49
|
+
*
|
|
50
|
+
* Calling this is required, not optional. Without it the offset never
|
|
51
|
+
* advances (messages are re-delivered on the next run), most brokers stall
|
|
52
|
+
* once their unacknowledged/prefetch window fills, and uncommitted batches
|
|
53
|
+
* are held in memory so the process grows unbounded. To retry a failed
|
|
54
|
+
* batch, simply don't commit it — it will be redelivered.
|
|
55
|
+
*/
|
|
56
|
+
commit(): Promise<void>
|
|
57
|
+
/**
|
|
58
|
+
* `true` once the source has signalled end-of-stream (e.g. a fully drained
|
|
59
|
+
* file). Streaming brokers never set this.
|
|
60
|
+
*/
|
|
61
|
+
get exhausted(): boolean
|
|
62
|
+
/**
|
|
63
|
+
* Resolve to a status snapshot for the underlying endpoint: `healthy`,
|
|
64
|
+
* `target`, optional `pending` (broker backlog/lag where the transport
|
|
65
|
+
* reports it — Kafka offset lag, AMQP queue depth, NATS JetStream
|
|
66
|
+
* `numPending`), optional `capacity`/`error`, and `details`. `pending === 0`
|
|
67
|
+
* is a precise "caught up" signal on those transports; it is absent where
|
|
68
|
+
* the broker exposes no backlog (core NATS, MQTT). Point-in-time snapshot.
|
|
69
|
+
*/
|
|
70
|
+
status(): Promise<JsonValue>
|
|
71
|
+
/**
|
|
72
|
+
* Release the underlying consumer connection. Idempotent. After this,
|
|
73
|
+
* `poll()` and `status()` reject. GC'd JS has no deterministic drop, so
|
|
74
|
+
* closing explicitly is how the broker connection is freed promptly.
|
|
75
|
+
*/
|
|
76
|
+
close(): Promise<void>
|
|
77
|
+
}
|
|
78
|
+
|
|
3
79
|
export declare class Publisher {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Build a publisher endpoint from a YAML or JSON config file. Omit `name`
|
|
82
|
+
* (or pass `""`) when the file is a single bare endpoint body.
|
|
83
|
+
*/
|
|
84
|
+
static fromFile(path: string, name?: string | undefined | null): Publisher
|
|
85
|
+
/** Deprecated alias for `from_file`. */
|
|
86
|
+
static fromYaml(path: string, name?: string | undefined | null): Publisher
|
|
87
|
+
/**
|
|
88
|
+
* Build a publisher endpoint from an in-memory YAML or JSON string. Omit
|
|
89
|
+
* `name` (or pass `""`) when the string is a single bare endpoint body.
|
|
90
|
+
*/
|
|
91
|
+
static fromStr(text: string, name?: string | undefined | null): Publisher
|
|
92
|
+
/** Deprecated alias for `from_str`. */
|
|
93
|
+
static fromYamlStr(text: string, name?: string | undefined | null): Publisher
|
|
94
|
+
/**
|
|
95
|
+
* Build a publisher endpoint from an in-memory mapping (e.g. a JS object).
|
|
96
|
+
* Omit `name` (or pass `""`) to treat the mapping as a single bare endpoint
|
|
97
|
+
* body.
|
|
98
|
+
*/
|
|
99
|
+
static fromConfig(config: JsonValue, name?: string | undefined | null): Publisher
|
|
7
100
|
send(message: NativeMessage): Promise<void>
|
|
8
101
|
request(message: NativeMessage): Promise<NativeMessage>
|
|
9
102
|
sendJson(data: JsonValue, metadata?: Record<string, string> | undefined | null, id?: string | undefined | null): Promise<void>
|
|
@@ -11,9 +104,29 @@ export declare class Publisher {
|
|
|
11
104
|
}
|
|
12
105
|
|
|
13
106
|
export declare class Route {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Build a route from a YAML or JSON config file. Accepts a `routes:`
|
|
109
|
+
* document, a bare `{name: route}` map, or a single route body. Omit
|
|
110
|
+
* `name` (or pass `""`) when the file is a single bare route body.
|
|
111
|
+
*/
|
|
112
|
+
static fromFile(path: string, name?: string | undefined | null): Route
|
|
113
|
+
/** Deprecated alias for `from_file`. */
|
|
114
|
+
static fromYaml(path: string, name?: string | undefined | null): Route
|
|
115
|
+
/**
|
|
116
|
+
* Build a route from an in-memory YAML or JSON string. Accepts the same
|
|
117
|
+
* shapes as `from_file`. Omit `name` (or pass `""`) when the string is a
|
|
118
|
+
* single bare route body.
|
|
119
|
+
*/
|
|
120
|
+
static fromStr(text: string, name?: string | undefined | null): Route
|
|
121
|
+
/** Deprecated alias for `from_str`. */
|
|
122
|
+
static fromYamlStr(text: string, name?: string | undefined | null): Route
|
|
123
|
+
/**
|
|
124
|
+
* Build a route from an in-memory mapping (e.g. a JS object). Accepts a
|
|
125
|
+
* `routes:` document, a bare `{name: route}` map, or a single route body.
|
|
126
|
+
* Omit `name` (or pass `""`) to treat the mapping as a single bare route
|
|
127
|
+
* body, in which case a name is generated automatically.
|
|
128
|
+
*/
|
|
129
|
+
static fromConfig(config: JsonValue, name?: string | undefined | null): Route
|
|
17
130
|
withHandler(callback: ((err: Error | null, arg: NativeMessage) => Promise<NativeMessage | undefined | null>)): void
|
|
18
131
|
addHandler(kind: string, callback: ((err: Error | null, arg: JsonValue) => Promise<NativeMessage | undefined | null>)): void
|
|
19
132
|
start(): void
|
package/native.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('mq-bridge-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('mq-bridge-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.3.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
80
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('mq-bridge-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('mq-bridge-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.3.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
96
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('mq-bridge-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('mq-bridge-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.3.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
117
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('mq-bridge-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('mq-bridge-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.3.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
133
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('mq-bridge-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('mq-bridge-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.3.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
150
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('mq-bridge-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('mq-bridge-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.3.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
166
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('mq-bridge-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('mq-bridge-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.3.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
185
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('mq-bridge-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('mq-bridge-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.3.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
201
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('mq-bridge-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('mq-bridge-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.3.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
217
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('mq-bridge-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('mq-bridge-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.3.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
237
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('mq-bridge-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('mq-bridge-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.3.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
253
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('mq-bridge-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('mq-bridge-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.3.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
274
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('mq-bridge-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('mq-bridge-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.3.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
290
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('mq-bridge-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('mq-bridge-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.3.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
308
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('mq-bridge-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('mq-bridge-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.3.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
324
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('mq-bridge-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('mq-bridge-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.3.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
342
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('mq-bridge-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('mq-bridge-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.3.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
358
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('mq-bridge-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('mq-bridge-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.3.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
376
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('mq-bridge-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('mq-bridge-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.3.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
392
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('mq-bridge-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('mq-bridge-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.3.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
410
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('mq-bridge-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('mq-bridge-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.3.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
426
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('mq-bridge-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('mq-bridge-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.3.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
443
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('mq-bridge-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('mq-bridge-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.3.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
459
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('mq-bridge-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('mq-bridge-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.3.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
479
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('mq-bridge-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('mq-bridge-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.3.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
495
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('mq-bridge-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('mq-bridge-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.3.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.3.
|
|
511
|
+
if (bindingPackageVersion !== '0.3.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -587,6 +587,7 @@ if (!nativeBinding) {
|
|
|
587
587
|
}
|
|
588
588
|
|
|
589
589
|
module.exports = nativeBinding
|
|
590
|
+
module.exports.Consumer = nativeBinding.Consumer
|
|
590
591
|
module.exports.Publisher = nativeBinding.Publisher
|
|
591
592
|
module.exports.Route = nativeBinding.Route
|
|
592
593
|
module.exports.configSchema = nativeBinding.configSchema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mq-bridge",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Node.js bindings for mq-bridge",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,17 +32,18 @@
|
|
|
32
32
|
"build:ci": "napi build --platform --no-default-features --features \"http middleware schema\" --js native.js --dts native.d.ts",
|
|
33
33
|
"build:debug": "napi build --platform --js native.js --dts native.d.ts",
|
|
34
34
|
"example": "node examples/http-handler.js",
|
|
35
|
+
"bench:http": "node analysis/bench_http_native.js",
|
|
35
36
|
"test": "node --test test/*.test.js",
|
|
36
37
|
"sync-version": "node scripts/sync-version.mjs",
|
|
37
38
|
"create-npm-dirs": "napi create-npm-dirs",
|
|
38
39
|
"artifacts": "napi artifacts"
|
|
39
40
|
},
|
|
40
41
|
"optionalDependencies": {
|
|
41
|
-
"mq-bridge-darwin-x64": "0.3.
|
|
42
|
-
"mq-bridge-darwin-arm64": "0.3.
|
|
43
|
-
"mq-bridge-linux-x64-gnu": "0.3.
|
|
44
|
-
"mq-bridge-linux-arm64-gnu": "0.3.
|
|
45
|
-
"mq-bridge-win32-x64-msvc": "0.3.
|
|
42
|
+
"mq-bridge-darwin-x64": "0.3.1",
|
|
43
|
+
"mq-bridge-darwin-arm64": "0.3.1",
|
|
44
|
+
"mq-bridge-linux-x64-gnu": "0.3.1",
|
|
45
|
+
"mq-bridge-linux-arm64-gnu": "0.3.1",
|
|
46
|
+
"mq-bridge-win32-x64-msvc": "0.3.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@napi-rs/cli": "^3.0.0"
|