@stryke/capnp 0.10.1 → 0.10.2

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/rpc.cjs CHANGED
@@ -1,121 +1,10 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
4
- var _capnpes = require('capnp-es');
5
- var _nodeworker_threads = require('node:worker_threads');
6
- class MessageChannelTransport extends _capnpes.DeferredTransport {
7
- static {
8
- _chunkUSNT2KNTcjs.__name.call(void 0, this, "MessageChannelTransport");
9
- }
10
-
11
- constructor(port) {
12
- super(), this.port = port, this.close = () => {
13
- this.port.off("message", this.resolve);
14
- this.port.off("messageerror", this.reject);
15
- this.port.off("close", this.close);
16
- this.port.close();
17
- super.close();
18
- };
19
- this.port.on("message", this.resolve);
20
- this.port.on("messageerror", this.reject);
21
- this.port.on("close", this.close);
22
- }
23
-
24
- sendMessage(msg) {
25
- const m = new (0, _capnpes.Message)();
26
- m.setRoot(msg);
27
- const buf = m.toArrayBuffer();
28
- this.port.postMessage(buf, [
29
- buf
30
- ]);
31
- }
32
- }
33
- class CapnpRPC {constructor() { CapnpRPC.prototype.__init.call(this);CapnpRPC.prototype.__init2.call(this);CapnpRPC.prototype.__init3.call(this); }
34
- static {
35
- _chunkUSNT2KNTcjs.__name.call(void 0, this, "CapnpRPC");
36
- }
37
- /**
38
- * A queue for deferred connections that are waiting to be accepted.
39
- *
40
- * @remarks
41
- * This is used to manage incoming connections when the accept method is called.
42
- */
43
- __init() {this.acceptQueue = new Array()}
44
- /**
45
- * A map of connections by their ID.
46
- *
47
- * @remarks
48
- * This is used to manage multiple connections and allows for easy retrieval by ID.
49
- */
50
- __init2() {this.connections = {}}
51
- /**
52
- * A queue for connections that are waiting to be accepted.
53
- *
54
- * @remarks
55
- * This is used to manage incoming connections when the accept method is called.
56
- */
57
- __init3() {this.connectQueue = new Array()}
58
- /**
59
- * Creates a new {@link Conn} instance.
60
- *
61
- * @remarks
62
- * This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
63
- */
64
- connect(id = 0) {
65
- if (this.connections[id] !== void 0) {
66
- return this.connections[id];
67
- }
68
- const ch = new (0, _nodeworker_threads.MessageChannel)();
69
- const conn = new (0, _capnpes.Conn)(new MessageChannelTransport(ch.port1));
70
- const accept = this.acceptQueue.pop();
71
- this.connections[id] = conn;
72
- if (accept === void 0) {
73
- this.connectQueue.push(ch.port2);
74
- } else {
75
- accept.resolve(new (0, _capnpes.Conn)(new MessageChannelTransport(ch.port2)));
76
- }
77
- return conn;
78
- }
79
- /**
80
- * Accepts a connection from the connect queue.
81
- *
82
- * @returns A promise that resolves to a Conn instance when a connection is accepted.
83
- * @throws If no connections are available in the connect queue.
84
- */
85
- async accept() {
86
- const port2 = this.connectQueue.pop();
87
- if (port2 !== void 0) {
88
- return Promise.resolve(new (0, _capnpes.Conn)(new MessageChannelTransport(port2)));
89
- }
90
- const deferred = new (0, _capnpes.Deferred)();
91
- this.acceptQueue.push(deferred);
92
- return deferred.promise;
93
- }
94
- /**
95
- * Closes all connections and clears the queues.
96
- *
97
- * @remarks
98
- * This method will reject all pending accept promises and close all
99
- * connections in the connect queue.
100
- */
101
- close() {
102
- let i = this.acceptQueue.length;
103
- while (--i >= 0) {
104
- _optionalChain([this, 'access', _ => _.acceptQueue, 'access', _2 => _2[i], 'optionalAccess', _3 => _3.reject, 'call', _4 => _4()]);
105
- }
106
- i = this.connectQueue.length;
107
- while (--i >= 0) {
108
- this.connectQueue[i].close();
109
- }
110
- for (const id in this.connections) {
111
- _optionalChain([this, 'access', _5 => _5.connections, 'access', _6 => _6[id], 'optionalAccess', _7 => _7.shutdown, 'call', _8 => _8()]);
112
- }
113
- this.acceptQueue.length = 0;
114
- this.connectQueue.length = 0;
115
- this.connections = {};
116
- }
117
- }
118
3
 
4
+ var _chunkIBMXNAOTcjs = require('./chunk-IBMXNAOT.cjs');
5
+ require('./chunk-KXWOF6H4.cjs');
6
+ require('./chunk-USNT2KNT.cjs');
119
7
 
120
8
 
121
- exports.CapnpRPC = CapnpRPC; exports.MessageChannelTransport = MessageChannelTransport;
9
+
10
+ exports.CapnpRPC = _chunkIBMXNAOTcjs.CapnpRPC; exports.MessageChannelTransport = _chunkIBMXNAOTcjs.MessageChannelTransport;
package/dist/rpc.js CHANGED
@@ -1,120 +1,9 @@
1
1
  import {
2
- __name
3
- } from "./chunk-SHUYVCID.js";
4
- import { Conn, Deferred, DeferredTransport, Message } from "capnp-es";
5
- import { MessageChannel } from "node:worker_threads";
6
- class MessageChannelTransport extends DeferredTransport {
7
- static {
8
- __name(this, "MessageChannelTransport");
9
- }
10
- port;
11
- constructor(port) {
12
- super(), this.port = port, this.close = () => {
13
- this.port.off("message", this.resolve);
14
- this.port.off("messageerror", this.reject);
15
- this.port.off("close", this.close);
16
- this.port.close();
17
- super.close();
18
- };
19
- this.port.on("message", this.resolve);
20
- this.port.on("messageerror", this.reject);
21
- this.port.on("close", this.close);
22
- }
23
- close;
24
- sendMessage(msg) {
25
- const m = new Message();
26
- m.setRoot(msg);
27
- const buf = m.toArrayBuffer();
28
- this.port.postMessage(buf, [
29
- buf
30
- ]);
31
- }
32
- }
33
- class CapnpRPC {
34
- static {
35
- __name(this, "CapnpRPC");
36
- }
37
- /**
38
- * A queue for deferred connections that are waiting to be accepted.
39
- *
40
- * @remarks
41
- * This is used to manage incoming connections when the accept method is called.
42
- */
43
- acceptQueue = new Array();
44
- /**
45
- * A map of connections by their ID.
46
- *
47
- * @remarks
48
- * This is used to manage multiple connections and allows for easy retrieval by ID.
49
- */
50
- connections = {};
51
- /**
52
- * A queue for connections that are waiting to be accepted.
53
- *
54
- * @remarks
55
- * This is used to manage incoming connections when the accept method is called.
56
- */
57
- connectQueue = new Array();
58
- /**
59
- * Creates a new {@link Conn} instance.
60
- *
61
- * @remarks
62
- * This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
63
- */
64
- connect(id = 0) {
65
- if (this.connections[id] !== void 0) {
66
- return this.connections[id];
67
- }
68
- const ch = new MessageChannel();
69
- const conn = new Conn(new MessageChannelTransport(ch.port1));
70
- const accept = this.acceptQueue.pop();
71
- this.connections[id] = conn;
72
- if (accept === void 0) {
73
- this.connectQueue.push(ch.port2);
74
- } else {
75
- accept.resolve(new Conn(new MessageChannelTransport(ch.port2)));
76
- }
77
- return conn;
78
- }
79
- /**
80
- * Accepts a connection from the connect queue.
81
- *
82
- * @returns A promise that resolves to a Conn instance when a connection is accepted.
83
- * @throws If no connections are available in the connect queue.
84
- */
85
- async accept() {
86
- const port2 = this.connectQueue.pop();
87
- if (port2 !== void 0) {
88
- return Promise.resolve(new Conn(new MessageChannelTransport(port2)));
89
- }
90
- const deferred = new Deferred();
91
- this.acceptQueue.push(deferred);
92
- return deferred.promise;
93
- }
94
- /**
95
- * Closes all connections and clears the queues.
96
- *
97
- * @remarks
98
- * This method will reject all pending accept promises and close all
99
- * connections in the connect queue.
100
- */
101
- close() {
102
- let i = this.acceptQueue.length;
103
- while (--i >= 0) {
104
- this.acceptQueue[i]?.reject();
105
- }
106
- i = this.connectQueue.length;
107
- while (--i >= 0) {
108
- this.connectQueue[i].close();
109
- }
110
- for (const id in this.connections) {
111
- this.connections[id]?.shutdown();
112
- }
113
- this.acceptQueue.length = 0;
114
- this.connectQueue.length = 0;
115
- this.connections = {};
116
- }
117
- }
2
+ CapnpRPC,
3
+ MessageChannelTransport
4
+ } from "./chunk-N2KNXTXN.js";
5
+ import "./chunk-5VHN3KGS.js";
6
+ import "./chunk-SHUYVCID.js";
118
7
  export {
119
8
  CapnpRPC,
120
9
  MessageChannelTransport
package/dist/types.cjs CHANGED
@@ -1,12 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
4
- class CodeGeneratorContext {constructor() { CodeGeneratorContext.prototype.__init.call(this); }
5
- static {
6
- _chunkUSNT2KNTcjs.__name.call(void 0, this, "CodeGeneratorContext");
7
- }
8
- __init() {this.files = []}
9
- }
3
+ var _chunkR2JXWA7Qcjs = require('./chunk-R2JXWA7Q.cjs');
4
+ require('./chunk-USNT2KNT.cjs');
10
5
 
11
6
 
12
- exports.CodeGeneratorContext = CodeGeneratorContext;
7
+ exports.CodeGeneratorContext = _chunkR2JXWA7Qcjs.CodeGeneratorContext;
package/dist/types.js CHANGED
@@ -1,12 +1,7 @@
1
1
  import {
2
- __name
3
- } from "./chunk-SHUYVCID.js";
4
- class CodeGeneratorContext {
5
- static {
6
- __name(this, "CodeGeneratorContext");
7
- }
8
- files = [];
9
- }
2
+ CodeGeneratorContext
3
+ } from "./chunk-CCU32X36.js";
4
+ import "./chunk-SHUYVCID.js";
10
5
  export {
11
6
  CodeGeneratorContext
12
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/capnp",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "type": "module",
5
5
  "description": "A package to assist in running the Cap'n Proto compiler and creating Cap'n Proto serialization protocol schemas.",
6
6
  "repository": {
@@ -129,7 +129,7 @@
129
129
  "peerDependencies": { "typescript": ">=4.0.0" },
130
130
  "peerDependenciesMeta": { "typescript": { "optional": false } },
131
131
  "dependencies": {
132
- "@stryke/fs": "^0.23.2",
132
+ "@stryke/fs": "^0.23.3",
133
133
  "@stryke/path": "^0.12.3",
134
134
  "defu": "^6.1.4",
135
135
  "hex2dec": "^1.1.2",
@@ -148,5 +148,5 @@
148
148
  "tsx": "^4.20.1"
149
149
  },
150
150
  "publishConfig": { "access": "public" },
151
- "gitHead": "407bacee3e398d8a0a7025421a82d3700aaceda0"
151
+ "gitHead": "bd1c18c69a24e82c1b126b1e5de36008bbac52d9"
152
152
  }