mcbe-ipc 3.0.4 → 3.1.4

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
@@ -2,19 +2,25 @@
2
2
 
3
3
  An IPC[^1] system for MCBE Script API projects
4
4
 
5
- [^1]: Inter-Pack Communication
5
+ ## 🔗 Dependencies
6
+
7
+ | Package | Version |
8
+ |----------------------|---------|
9
+ | `@minecraft/server` | 1.18.0 |
10
+
11
+ ## 🚀 Installation
6
12
 
7
- ## Dependencies
13
+ ### 📦 NPM
14
+ ```bash
15
+ npm install mcbe-ipc
16
+ ```
8
17
 
9
- | Name | Version |
10
- |---|---|
11
- | `@minecraft/server` | Any |
18
+ ### 🛠 Manual
19
+ 1. Download the applicable file(s) for your language from the latest [release](https://github.com/OmniacDev/MCBE-IPC/releases/latest):
20
+ - For **JavaScript**: `ipc.js` and `ipc.d.ts`
21
+ - For **TypeScript**: `ipc.ts`
22
+ 2. Add the downloaded file(s) to your project directory.
12
23
 
13
- ## Installation
14
- **JavaScript**
15
- 1. Download `ipc.js` and `ipc.d.ts` from the latest [release](https://github.com/OmniacDev/MCBE-IPC/releases/latest)
16
- 2. Copy the files into your project
17
24
 
18
- **TypeScript**
19
- 1. Download `ipc.ts` from the latest [release](https://github.com/OmniacDev/MCBE-IPC/releases/latest)
20
- 2. Copy file into your project
25
+
26
+ [^1]: Inter-Pack Communication
package/dist/ipc.d.ts CHANGED
@@ -24,10 +24,11 @@
24
24
  */
25
25
  export declare namespace PROTO {
26
26
  interface Serializable<T> {
27
- serialize(value: T, stream: ByteQueue): Generator<void, void, void>;
28
- deserialize(stream: ByteQueue): Generator<void, T, void>;
27
+ serialize(value: T, stream: Buffer): Generator<void, void, void>;
28
+ deserialize(stream: Buffer): Generator<void, T, void>;
29
29
  }
30
- class ByteQueue {
30
+ type Infer<S> = S extends PROTO.Serializable<infer T> ? T : never;
31
+ class Buffer {
31
32
  private _buffer;
32
33
  private _data_view;
33
34
  private _length;
@@ -36,15 +37,17 @@ export declare namespace PROTO {
36
37
  get front(): number;
37
38
  get data_view(): DataView;
38
39
  constructor(size?: number);
39
- write(...values: number[]): void;
40
- read(amount?: number): number[];
40
+ write_byte(byte: number): void;
41
+ write_bytes(bytes: Uint8Array): void;
42
+ read_byte(): number;
43
+ read_bytes(amount: number): Uint8Array;
41
44
  ensure_capacity(size: number): void;
42
- static from_uint8array(array: Uint8Array): ByteQueue;
45
+ static from_uint8array(array: Uint8Array): Buffer;
43
46
  to_uint8array(): Uint8Array;
44
47
  }
45
48
  namespace MIPS {
46
- function serialize(byte_queue: PROTO.ByteQueue): Generator<void, string, void>;
47
- function deserialize(str: string): Generator<void, PROTO.ByteQueue, void>;
49
+ function serialize(stream: PROTO.Buffer): Generator<void, string, void>;
50
+ function deserialize(str: string): Generator<void, PROTO.Buffer, void>;
48
51
  }
49
52
  const Void: PROTO.Serializable<void>;
50
53
  const Null: PROTO.Serializable<null>;
@@ -83,21 +86,22 @@ export declare namespace PROTO {
83
86
  const Header: PROTO.Serializable<Header>;
84
87
  }
85
88
  export declare namespace NET {
86
- function serialize(byte_queue: PROTO.ByteQueue, max_size?: number): Generator<void, string[], void>;
87
- function deserialize(strings: string[]): Generator<void, PROTO.ByteQueue, void>;
88
- function emit<S extends PROTO.Serializable<T>, T>(endpoint: string, serializer: S & PROTO.Serializable<T>, value: T): Generator<void, void, void>;
89
- function listen<T, S extends PROTO.Serializable<T>>(endpoint: string, serializer: S & PROTO.Serializable<T>, callback: (value: T) => Generator<void, void, void>): () => void;
89
+ let FRAG_MAX: number;
90
+ function serialize(buffer: PROTO.Buffer, max_size?: number): Generator<void, string[], void>;
91
+ function deserialize(strings: string[]): Generator<void, PROTO.Buffer, void>;
92
+ function emit<S extends PROTO.Serializable<any>>(endpoint: string, serializer: S, value: PROTO.Infer<S>): Generator<void, void, void>;
93
+ function listen<S extends PROTO.Serializable<any>>(endpoint: string, serializer: S, callback: (value: PROTO.Infer<S>) => Generator<void, void, void>): () => void;
90
94
  }
91
95
  export declare namespace IPC {
92
96
  /** Sends a message with `args` to `channel` */
93
- function send<S extends PROTO.Serializable<T>, T>(channel: string, serializer: S & PROTO.Serializable<T>, value: T): void;
97
+ function send<S extends PROTO.Serializable<any>>(channel: string, serializer: S, value: PROTO.Infer<S>): void;
94
98
  /** Sends an `invoke` message through IPC, and expects a result asynchronously. */
95
- function invoke<TS extends PROTO.Serializable<T>, T, RS extends PROTO.Serializable<R>, R>(channel: string, serializer: TS & PROTO.Serializable<T>, value: T, deserializer: RS & PROTO.Serializable<R>): Promise<R>;
99
+ function invoke<S extends PROTO.Serializable<any>, D extends PROTO.Serializable<any>>(channel: string, serializer: S, value: PROTO.Infer<S>, deserializer: S): Promise<PROTO.Infer<D>>;
96
100
  /** Listens to `channel`. When a new message arrives, `listener` will be called with `listener(args)`. */
97
- function on<S extends PROTO.Serializable<T>, T>(channel: string, deserializer: S & PROTO.Serializable<T>, listener: (value: T) => void): () => void;
101
+ function on<D extends PROTO.Serializable<any>>(channel: string, deserializer: D, listener: (value: PROTO.Infer<D>) => void): () => void;
98
102
  /** Listens to `channel` once. When a new message arrives, `listener` will be called with `listener(args)`, and then removed. */
99
- function once<S extends PROTO.Serializable<T>, T>(channel: string, deserializer: S & PROTO.Serializable<T>, listener: (value: T) => void): () => void;
103
+ function once<D extends PROTO.Serializable<any>>(channel: string, deserializer: D, listener: (value: PROTO.Infer<D>) => void): () => void;
100
104
  /** Adds a handler for an `invoke` IPC. This handler will be called whenever `invoke(channel, ...args)` is called */
101
- function handle<TS extends PROTO.Serializable<T>, T, RS extends PROTO.Serializable<R>, R>(channel: string, deserializer: TS & PROTO.Serializable<T>, serializer: RS & PROTO.Serializable<R>, listener: (value: T) => R): () => void;
105
+ function handle<D extends PROTO.Serializable<any>, S extends PROTO.Serializable<any>>(channel: string, deserializer: D, serializer: S, listener: (value: PROTO.Infer<D>) => PROTO.Infer<S>): () => void;
102
106
  }
103
107
  export default IPC;
package/dist/ipc.js CHANGED
@@ -22,10 +22,10 @@
22
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  * SOFTWARE.
24
24
  */
25
- import { ScriptEventSource, system, world } from '@minecraft/server';
25
+ import { ScriptEventSource, system } from '@minecraft/server';
26
26
  export var PROTO;
27
27
  (function (PROTO) {
28
- class ByteQueue {
28
+ class Buffer {
29
29
  get end() {
30
30
  return this._length + this._offset;
31
31
  }
@@ -41,20 +41,31 @@ export var PROTO;
41
41
  this._length = 0;
42
42
  this._offset = 0;
43
43
  }
44
- write(...values) {
45
- this.ensure_capacity(values.length);
46
- this._buffer.set(values, this.end);
47
- this._length += values.length;
44
+ write_byte(byte) {
45
+ this.ensure_capacity(1);
46
+ this._buffer[this.end] = byte;
47
+ this._length++;
48
48
  }
49
- read(amount = 1) {
49
+ write_bytes(bytes) {
50
+ this.ensure_capacity(bytes.length);
51
+ this._buffer.set(bytes, this.end);
52
+ this._length += bytes.length;
53
+ }
54
+ read_byte() {
55
+ const byte = this._buffer[this._offset];
56
+ this._length--;
57
+ this._offset++;
58
+ return byte;
59
+ }
60
+ read_bytes(amount) {
50
61
  if (this._length > 0) {
51
62
  const max_amount = amount > this._length ? this._length : amount;
52
- const values = this._buffer.subarray(this._offset, this._offset + max_amount);
63
+ const values = this._buffer.slice(this._offset, this._offset + max_amount);
53
64
  this._length -= max_amount;
54
65
  this._offset += max_amount;
55
- return globalThis.Array.from(values);
66
+ return values;
56
67
  }
57
- return [];
68
+ return new Uint8Array();
58
69
  }
59
70
  ensure_capacity(size) {
60
71
  if (this.end + size > this._buffer.length) {
@@ -66,22 +77,22 @@ export var PROTO;
66
77
  }
67
78
  }
68
79
  static from_uint8array(array) {
69
- const byte_queue = new ByteQueue();
70
- byte_queue._buffer = array;
71
- byte_queue._length = array.length;
72
- byte_queue._offset = 0;
73
- byte_queue._data_view = new DataView(array.buffer);
74
- return byte_queue;
80
+ const buffer = new Buffer();
81
+ buffer._buffer = array;
82
+ buffer._length = array.length;
83
+ buffer._offset = 0;
84
+ buffer._data_view = new DataView(array.buffer);
85
+ return buffer;
75
86
  }
76
87
  to_uint8array() {
77
88
  return this._buffer.subarray(this._offset, this.end);
78
89
  }
79
90
  }
80
- PROTO.ByteQueue = ByteQueue;
91
+ PROTO.Buffer = Buffer;
81
92
  let MIPS;
82
93
  (function (MIPS) {
83
- function* serialize(byte_queue) {
84
- const uint8array = byte_queue.to_uint8array();
94
+ function* serialize(stream) {
95
+ const uint8array = stream.to_uint8array();
85
96
  let str = '(0x';
86
97
  for (let i = 0; i < uint8array.length; i++) {
87
98
  const hex = uint8array[i].toString(16).padStart(2, '0').toUpperCase();
@@ -94,16 +105,16 @@ export var PROTO;
94
105
  MIPS.serialize = serialize;
95
106
  function* deserialize(str) {
96
107
  if (str.startsWith('(0x') && str.endsWith(')')) {
97
- const result = [];
108
+ const buffer = new Buffer();
98
109
  const hex_str = str.slice(3, str.length - 1);
99
110
  for (let i = 0; i < hex_str.length; i++) {
100
111
  const hex = hex_str[i] + hex_str[++i];
101
- result.push(parseInt(hex, 16));
112
+ buffer.write_byte(parseInt(hex, 16));
102
113
  yield;
103
114
  }
104
- return ByteQueue.from_uint8array(new Uint8Array(result));
115
+ return buffer;
105
116
  }
106
- return new ByteQueue();
117
+ return new Buffer();
107
118
  }
108
119
  MIPS.deserialize = deserialize;
109
120
  })(MIPS = PROTO.MIPS || (PROTO.MIPS = {}));
@@ -126,90 +137,90 @@ export var PROTO;
126
137
  PROTO.Int8 = {
127
138
  *serialize(value, stream) {
128
139
  const length = 1;
129
- stream.write(...globalThis.Array(length).fill(0));
140
+ stream.write_bytes(new Uint8Array(length));
130
141
  stream.data_view.setInt8(stream.end - length, value);
131
142
  },
132
143
  *deserialize(stream) {
133
144
  const value = stream.data_view.getInt8(stream.front);
134
- stream.read(1);
145
+ stream.read_bytes(1);
135
146
  return value;
136
147
  }
137
148
  };
138
149
  PROTO.Int16 = {
139
150
  *serialize(value, stream) {
140
151
  const length = 2;
141
- stream.write(...globalThis.Array(length).fill(0));
152
+ stream.write_bytes(new Uint8Array(length));
142
153
  stream.data_view.setInt16(stream.end - length, value);
143
154
  },
144
155
  *deserialize(stream) {
145
156
  const value = stream.data_view.getInt16(stream.front);
146
- stream.read(2);
157
+ stream.read_bytes(2);
147
158
  return value;
148
159
  }
149
160
  };
150
161
  PROTO.Int32 = {
151
162
  *serialize(value, stream) {
152
163
  const length = 4;
153
- stream.write(...globalThis.Array(length).fill(0));
164
+ stream.write_bytes(new Uint8Array(length));
154
165
  stream.data_view.setInt32(stream.end - length, value);
155
166
  },
156
167
  *deserialize(stream) {
157
168
  const value = stream.data_view.getInt32(stream.front);
158
- stream.read(4);
169
+ stream.read_bytes(4);
159
170
  return value;
160
171
  }
161
172
  };
162
173
  PROTO.UInt8 = {
163
174
  *serialize(value, stream) {
164
175
  const length = 1;
165
- stream.write(...globalThis.Array(length).fill(0));
176
+ stream.write_bytes(new Uint8Array(length));
166
177
  stream.data_view.setUint8(stream.end - length, value);
167
178
  },
168
179
  *deserialize(stream) {
169
180
  const value = stream.data_view.getUint8(stream.front);
170
- stream.read(1);
181
+ stream.read_bytes(1);
171
182
  return value;
172
183
  }
173
184
  };
174
185
  PROTO.UInt16 = {
175
186
  *serialize(value, stream) {
176
187
  const length = 2;
177
- stream.write(...globalThis.Array(length).fill(0));
188
+ stream.write_bytes(new Uint8Array(length));
178
189
  stream.data_view.setUint16(stream.end - length, value);
179
190
  },
180
191
  *deserialize(stream) {
181
192
  const value = stream.data_view.getUint16(stream.front);
182
- stream.read(2);
193
+ stream.read_bytes(2);
183
194
  return value;
184
195
  }
185
196
  };
186
197
  PROTO.UInt32 = {
187
198
  *serialize(value, stream) {
188
199
  const length = 4;
189
- stream.write(...globalThis.Array(length).fill(0));
200
+ stream.write_bytes(new Uint8Array(length));
190
201
  stream.data_view.setUint32(stream.end - length, value);
191
202
  },
192
203
  *deserialize(stream) {
193
204
  const value = stream.data_view.getUint32(stream.front);
194
- stream.read(4);
205
+ stream.read_bytes(4);
195
206
  return value;
196
207
  }
197
208
  };
198
209
  PROTO.UVarInt32 = {
199
210
  *serialize(value, stream) {
200
211
  while (value >= 0x80) {
201
- stream.write((value & 0x7f) | 0x80);
212
+ stream.write_byte((value & 0x7f) | 0x80);
202
213
  value >>= 7;
203
214
  yield;
204
215
  }
205
- stream.write(value);
216
+ stream.write_byte(value);
206
217
  },
207
218
  *deserialize(stream) {
208
219
  let value = 0;
209
220
  let size = 0;
210
221
  let byte;
211
222
  do {
212
- byte = stream.read()[0];
223
+ byte = stream.read_byte();
213
224
  value |= (byte & 0x7f) << (size * 7);
214
225
  size += 1;
215
226
  yield;
@@ -220,24 +231,24 @@ export var PROTO;
220
231
  PROTO.Float32 = {
221
232
  *serialize(value, stream) {
222
233
  const length = 4;
223
- stream.write(...globalThis.Array(length).fill(0));
234
+ stream.write_bytes(new Uint8Array(length));
224
235
  stream.data_view.setFloat32(stream.end - length, value);
225
236
  },
226
237
  *deserialize(stream) {
227
238
  const value = stream.data_view.getFloat32(stream.front);
228
- stream.read(4);
239
+ stream.read_bytes(4);
229
240
  return value;
230
241
  }
231
242
  };
232
243
  PROTO.Float64 = {
233
244
  *serialize(value, stream) {
234
245
  const length = 8;
235
- stream.write(...globalThis.Array(length).fill(0));
246
+ stream.write_bytes(new Uint8Array(length));
236
247
  stream.data_view.setFloat64(stream.end - length, value);
237
248
  },
238
249
  *deserialize(stream) {
239
250
  const value = stream.data_view.getFloat64(stream.front);
240
- stream.read(8);
251
+ stream.read_bytes(8);
241
252
  return value;
242
253
  }
243
254
  };
@@ -261,21 +272,21 @@ export var PROTO;
261
272
  };
262
273
  PROTO.Boolean = {
263
274
  *serialize(value, stream) {
264
- stream.write(value ? 1 : 0);
275
+ stream.write_byte(value ? 1 : 0);
265
276
  },
266
277
  *deserialize(stream) {
267
- const value = stream.read()[0];
278
+ const value = stream.read_byte();
268
279
  return value === 1;
269
280
  }
270
281
  };
271
282
  PROTO.UInt8Array = {
272
283
  *serialize(value, stream) {
273
284
  yield* PROTO.UVarInt32.serialize(value.length, stream);
274
- stream.write(...value);
285
+ stream.write_bytes(value);
275
286
  },
276
287
  *deserialize(stream) {
277
288
  const length = yield* PROTO.UVarInt32.deserialize(stream);
278
- return new Uint8Array(stream.read(length));
289
+ return stream.read_bytes(length);
279
290
  }
280
291
  };
281
292
  PROTO.Date = {
@@ -409,11 +420,11 @@ export var PROTO;
409
420
  })(PROTO || (PROTO = {}));
410
421
  export var NET;
411
422
  (function (NET) {
412
- const FRAG_MAX = 2048;
423
+ NET.FRAG_MAX = 2048;
413
424
  const ENCODING = 'mcbe-ipc:v3';
414
425
  const ENDPOINTS = new Map();
415
- function* serialize(byte_queue, max_size = Infinity) {
416
- const uint8array = byte_queue.to_uint8array();
426
+ function* serialize(buffer, max_size = Infinity) {
427
+ const uint8array = buffer.to_uint8array();
417
428
  const result = [];
418
429
  let acc_str = '';
419
430
  let acc_size = 0;
@@ -441,7 +452,7 @@ export var NET;
441
452
  }
442
453
  NET.serialize = serialize;
443
454
  function* deserialize(strings) {
444
- const result = [];
455
+ const buffer = new PROTO.Buffer();
445
456
  for (let i = 0; i < strings.length; i++) {
446
457
  const str = strings[i];
447
458
  for (let j = 0; j < str.length; j++) {
@@ -449,18 +460,18 @@ export var NET;
449
460
  if (char_code <= 0xff) {
450
461
  const hex = str[j] + str[++j];
451
462
  const hex_code = parseInt(hex, 16);
452
- result.push(hex_code & 0xff);
453
- result.push(hex_code >> 8);
463
+ buffer.write_byte(hex_code & 0xff);
464
+ buffer.write_byte(hex_code >> 8);
454
465
  }
455
466
  else {
456
- result.push(char_code & 0xff);
457
- result.push(char_code >> 8);
467
+ buffer.write_byte(char_code & 0xff);
468
+ buffer.write_byte(char_code >> 8);
458
469
  }
459
470
  yield;
460
471
  }
461
472
  yield;
462
473
  }
463
- return PROTO.ByteQueue.from_uint8array(new Uint8Array(result));
474
+ return buffer;
464
475
  }
465
476
  NET.deserialize = deserialize;
466
477
  system.afterEvents.scriptEventReceive.subscribe(event => {
@@ -503,23 +514,19 @@ export var NET;
503
514
  }
504
515
  function* emit(endpoint, serializer, value) {
505
516
  const guid = generate_id();
506
- const endpoint_stream = new PROTO.ByteQueue();
517
+ const endpoint_stream = new PROTO.Buffer();
507
518
  yield* PROTO.Endpoint.serialize(endpoint, endpoint_stream);
508
519
  const serialized_endpoint = yield* PROTO.MIPS.serialize(endpoint_stream);
509
- const RUN = function* (header, serialized_packet) {
510
- const header_stream = new PROTO.ByteQueue();
511
- yield* PROTO.Header.serialize(header, header_stream);
512
- const serialized_header = yield* PROTO.MIPS.serialize(header_stream);
513
- world
514
- .getDimension('overworld')
515
- .runCommand(`scriptevent ${serialized_endpoint}:${serialized_header} ${serialized_packet}`);
516
- };
517
- const packet_stream = new PROTO.ByteQueue();
520
+ const packet_stream = new PROTO.Buffer();
518
521
  yield* serializer.serialize(value, packet_stream);
519
- const serialized_packets = yield* serialize(packet_stream, FRAG_MAX);
522
+ const serialized_packets = yield* serialize(packet_stream, NET.FRAG_MAX);
520
523
  for (let i = 0; i < serialized_packets.length; i++) {
521
524
  const serialized_packet = serialized_packets[i];
522
- yield* RUN({ guid, encoding: ENCODING, index: i, final: i === serialized_packets.length - 1 }, serialized_packet);
525
+ const header = { guid, encoding: ENCODING, index: i, final: i === serialized_packets.length - 1 };
526
+ const header_stream = new PROTO.Buffer();
527
+ yield* PROTO.Header.serialize(header, header_stream);
528
+ const serialized_header = yield* PROTO.MIPS.serialize(header_stream);
529
+ system.sendScriptEvent(`${serialized_endpoint}:${serialized_header}`, serialized_packet);
523
530
  }
524
531
  }
525
532
  NET.emit = emit;
package/package.json CHANGED
@@ -3,15 +3,15 @@
3
3
  "author": "OmniacDev",
4
4
  "description": "IPC system for MCBE Script API projects",
5
5
  "license": "MIT",
6
- "version": "3.0.4",
6
+ "version": "3.1.4",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/OmniacDev/mcbe-ipc.git"
9
+ "url": "git+https://github.com/OmniacDev/MCBE-IPC.git"
10
10
  },
11
11
  "bugs": {
12
- "url": "https://github.com/OmniacDev/mcbe-ipc/issues"
12
+ "url": "https://github.com/OmniacDev/MCBE-IPC/issues"
13
13
  },
14
- "homepage": "https://github.com/OmniacDev/mcbe-ipc",
14
+ "homepage": "https://github.com/OmniacDev/MCBE-IPC",
15
15
  "type": "module",
16
16
  "main": "dist/ipc.js",
17
17
  "types": "dist/ipc.d.ts",
@@ -28,6 +28,6 @@
28
28
  "typescript": "^5.5.4"
29
29
  },
30
30
  "dependencies": {
31
- "@minecraft/server": "^1.13.0"
31
+ "@minecraft/server": "^1.18.0"
32
32
  }
33
33
  }
@@ -1,61 +0,0 @@
1
- /**
2
- * @license
3
- * MIT License
4
- *
5
- * Copyright (c) 2025 OmniacDev
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
- import { PROTO } from './ipc';
26
- export declare namespace DirectIPC {
27
- class Connection {
28
- private readonly _from;
29
- private readonly _to;
30
- private readonly _enc;
31
- private readonly _terminators;
32
- private MAYBE_ENCRYPT;
33
- private MAYBE_DECRYPT;
34
- get from(): string;
35
- get to(): string;
36
- constructor(from: string, to: string, encryption: string | false);
37
- terminate(notify?: boolean): void;
38
- send<S extends PROTO.Serializable<T>, T>(channel: string, serializer: S & PROTO.Serializable<T>, value: T): void;
39
- invoke<TS extends PROTO.Serializable<T>, T, RS extends PROTO.Serializable<R>, R>(channel: string, serializer: TS & PROTO.Serializable<T>, value: T, deserializer: RS & PROTO.Serializable<R>): Promise<R>;
40
- on<S extends PROTO.Serializable<T>, T>(channel: string, deserializer: S & PROTO.Serializable<T>, listener: (value: T) => void): () => void;
41
- once<S extends PROTO.Serializable<T>, T>(channel: string, deserializer: S & PROTO.Serializable<T>, listener: (value: T) => void): () => void;
42
- handle<TS extends PROTO.Serializable<T>, T, RS extends PROTO.Serializable<R>, R>(channel: string, deserializer: TS & PROTO.Serializable<T>, serializer: RS & PROTO.Serializable<R>, listener: (value: T) => R): () => void;
43
- }
44
- class ConnectionManager {
45
- private readonly _id;
46
- private readonly _enc_map;
47
- private readonly _con_map;
48
- private readonly _enc_force;
49
- private MAYBE_ENCRYPT;
50
- private MAYBE_DECRYPT;
51
- get id(): string;
52
- constructor(id: string, force_encryption?: boolean);
53
- connect(to: string, encrypted?: boolean, timeout?: number, mod?: number, prime?: number): Promise<Connection>;
54
- send<S extends PROTO.Serializable<T>, T>(channel: string, serializer: S & PROTO.Serializable<T>, value: T): void;
55
- invoke<TS extends PROTO.Serializable<T>, T, RS extends PROTO.Serializable<R>, R>(channel: string, serializer: TS & PROTO.Serializable<T>, value: T, deserializer: RS & PROTO.Serializable<R>): Promise<R>[];
56
- on<S extends PROTO.Serializable<T>, T>(channel: string, deserializer: S & PROTO.Serializable<T>, listener: (value: T) => void): () => void;
57
- once<S extends PROTO.Serializable<T>, T>(channel: string, deserializer: S & PROTO.Serializable<T>, listener: (value: T) => void): () => void;
58
- handle<TS extends PROTO.Serializable<T>, T, RS extends PROTO.Serializable<R>, R>(channel: string, deserializer: TS & PROTO.Serializable<T>, serializer: RS & PROTO.Serializable<R>, listener: (value: T) => R): () => void;
59
- }
60
- }
61
- export default DirectIPC;