@stryke/capnp 0.12.32 → 0.12.41
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 +18 -9
- package/bin/capnpc.cjs +9 -8304
- package/bin/capnpc.d.cts +4 -2
- package/bin/capnpc.d.cts.map +1 -0
- package/bin/capnpc.d.mts +8 -0
- package/bin/capnpc.d.mts.map +1 -0
- package/bin/capnpc.mjs +11 -0
- package/bin/capnpc.mjs.map +1 -0
- package/dist/compile-DN7i0G3X.d.mts +40 -0
- package/dist/compile-DN7i0G3X.d.mts.map +1 -0
- package/dist/compile-DOMgXQRn.cjs +1 -0
- package/dist/compile-DccxA7WZ.d.cts +40 -0
- package/dist/compile-DccxA7WZ.d.cts.map +1 -0
- package/dist/compile-cQ918Wl_.mjs +2 -0
- package/dist/compile-cQ918Wl_.mjs.map +1 -0
- package/dist/compile.cjs +1 -11
- package/dist/compile.d.cts +3 -39
- package/dist/compile.d.mts +3 -0
- package/dist/compile.mjs +1 -0
- package/dist/dist-BzGdCkHS.cjs +1 -0
- package/dist/dist-CvDcvswe.mjs +2 -0
- package/dist/dist-CvDcvswe.mjs.map +1 -0
- package/dist/helpers-BIiGufva.cjs +6 -0
- package/dist/helpers-BYBeqv2d.mjs +7 -0
- package/dist/helpers-BYBeqv2d.mjs.map +1 -0
- package/dist/helpers.cjs +1 -7
- package/dist/helpers.d.cts +5 -4
- package/dist/helpers.d.cts.map +1 -0
- package/dist/{helpers.d.ts → helpers.d.mts} +5 -4
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +1 -0
- package/dist/index.cjs +1 -134
- package/dist/index.d.cts +4 -6
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +1 -0
- package/dist/rpc.cjs +1 -139
- package/dist/rpc.d.cts +62 -59
- package/dist/rpc.d.cts.map +1 -0
- package/dist/rpc.d.mts +74 -0
- package/dist/rpc.d.mts.map +1 -0
- package/dist/rpc.mjs +2 -0
- package/dist/rpc.mjs.map +1 -0
- package/dist/types-B2gKzfwi.cjs +1 -0
- package/dist/types-D52qMMoK.d.cts +55 -0
- package/dist/types-D52qMMoK.d.cts.map +1 -0
- package/dist/types-DBd3Wi0H.d.mts +55 -0
- package/dist/types-DBd3Wi0H.d.mts.map +1 -0
- package/dist/types-y_yfxLs5.mjs +2 -0
- package/dist/types-y_yfxLs5.mjs.map +1 -0
- package/dist/types.cjs +1 -7
- package/dist/types.d.cts +2 -53
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +42 -69
- package/schemas/cpp.cjs +1 -7
- package/schemas/cpp.d.cts +3 -1
- package/schemas/cpp.d.cts.map +1 -0
- package/schemas/cpp.d.mts +5 -0
- package/schemas/cpp.d.mts.map +1 -0
- package/schemas/cpp.mjs +2 -0
- package/schemas/cpp.mjs.map +1 -0
- package/schemas/index-CDymg4xL.d.mts +96 -0
- package/schemas/index-CDymg4xL.d.mts.map +1 -0
- package/schemas/index-b7dam4EA.d.cts +96 -0
- package/schemas/index-b7dam4EA.d.cts.map +1 -0
- package/schemas/persistent.cjs +1 -171
- package/schemas/persistent.d.cts +55 -55
- package/schemas/persistent.d.cts.map +1 -0
- package/schemas/{persistent.d.ts → persistent.d.mts} +55 -55
- package/schemas/persistent.d.mts.map +1 -0
- package/schemas/persistent.mjs +2 -0
- package/schemas/persistent.mjs.map +1 -0
- package/schemas/rpc-twoparty.cjs +1 -209
- package/schemas/rpc-twoparty.d.cts +76 -74
- package/schemas/rpc-twoparty.d.cts.map +1 -0
- package/schemas/{rpc-twoparty.d.ts → rpc-twoparty.d.mts} +76 -74
- package/schemas/rpc-twoparty.d.mts.map +1 -0
- package/schemas/rpc-twoparty.mjs +2 -0
- package/schemas/rpc-twoparty.mjs.map +1 -0
- package/schemas/rpc.cjs +1 -2563
- package/schemas/rpc.d.cts +749 -747
- package/schemas/rpc.d.cts.map +1 -0
- package/schemas/{rpc.d.ts → rpc.d.mts} +749 -747
- package/schemas/rpc.d.mts.map +1 -0
- package/schemas/rpc.mjs +2 -0
- package/schemas/rpc.mjs.map +1 -0
- package/schemas/schema.cjs +1 -2718
- package/schemas/schema.d.cts +984 -982
- package/schemas/schema.d.cts.map +1 -0
- package/schemas/schema.d.mts +1456 -0
- package/schemas/schema.d.mts.map +1 -0
- package/schemas/schema.mjs +2 -0
- package/schemas/schema.mjs.map +1 -0
- package/schemas/src-CtkguuVd.mjs +7 -0
- package/schemas/src-CtkguuVd.mjs.map +1 -0
- package/schemas/src-DqnIPdOg.cjs +6 -0
- package/schemas/ts.cjs +1 -7
- package/schemas/ts.d.cts +3 -1
- package/schemas/ts.d.cts.map +1 -0
- package/schemas/ts.d.mts +5 -0
- package/schemas/ts.d.mts.map +1 -0
- package/schemas/ts.mjs +2 -0
- package/schemas/ts.mjs.map +1 -0
- package/bin/capnpc.d.ts +0 -6
- package/bin/capnpc.js +0 -8273
- package/dist/chunk-CCU32X36.js +0 -15
- package/dist/chunk-GI42NGKQ.js +0 -3305
- package/dist/chunk-H32XGT26.js +0 -4107
- package/dist/chunk-JREA5Q77.js +0 -1082
- package/dist/chunk-KMCJ5MIQ.cjs +0 -3305
- package/dist/chunk-KO6NZLWH.cjs +0 -1082
- package/dist/chunk-LFP6TIPQ.cjs +0 -4760
- package/dist/chunk-NN62B5Z3.cjs +0 -4107
- package/dist/chunk-R2JXWA7Q.cjs +0 -15
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-USNT2KNT.cjs +0 -6
- package/dist/chunk-ZIENMW4V.js +0 -4760
- package/dist/compile.d.ts +0 -39
- package/dist/compile.js +0 -11
- package/dist/helpers.js +0 -7
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -134
- package/dist/rpc.d.ts +0 -71
- package/dist/rpc.js +0 -139
- package/dist/types.d.ts +0 -53
- package/dist/types.js +0 -7
- package/schemas/chunk-RNSYVJGA.cjs +0 -4700
- package/schemas/chunk-SHUYVCID.js +0 -6
- package/schemas/chunk-SW2MRW3B.js +0 -4700
- package/schemas/chunk-USNT2KNT.cjs +0 -6
- package/schemas/cpp.d.ts +0 -3
- package/schemas/cpp.js +0 -7
- package/schemas/persistent.js +0 -171
- package/schemas/rpc-twoparty.js +0 -209
- package/schemas/rpc.js +0 -2563
- package/schemas/schema.d.ts +0 -1454
- package/schemas/schema.js +0 -2718
- package/schemas/ts.d.ts +0 -3
- package/schemas/ts.js +0 -7
package/dist/rpc.cjs
CHANGED
|
@@ -1,139 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkLFP6TIPQcjs = require('./chunk-LFP6TIPQ.cjs');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkKMCJ5MIQcjs = require('./chunk-KMCJ5MIQ.cjs');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
|
|
12
|
-
|
|
13
|
-
// src/rpc.ts
|
|
14
|
-
var _worker_threads = require('worker_threads');
|
|
15
|
-
var CapnpRPCMessageChannelTransport = (_class = class extends _chunkLFP6TIPQcjs.DeferredTransport {
|
|
16
|
-
static {
|
|
17
|
-
_chunkUSNT2KNTcjs.__name.call(void 0, this, "CapnpRPCMessageChannelTransport");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
constructor(port) {
|
|
21
|
-
super();_class.prototype.__init.call(this);;
|
|
22
|
-
this.port = port;
|
|
23
|
-
this.port.on("message", this.resolve);
|
|
24
|
-
this.port.on("messageerror", this.reject);
|
|
25
|
-
this.port.on("close", this.close);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Closes the transport and removes all event listeners.
|
|
29
|
-
*/
|
|
30
|
-
__init() {this.close = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, () => {
|
|
31
|
-
this.port.off("message", this.resolve);
|
|
32
|
-
this.port.off("messageerror", this.reject);
|
|
33
|
-
this.port.off("close", this.close);
|
|
34
|
-
this.port.close();
|
|
35
|
-
super.close();
|
|
36
|
-
}, "close")}
|
|
37
|
-
/**
|
|
38
|
-
* Sends a Cap'n Proto RPC message over the MessagePort.
|
|
39
|
-
*
|
|
40
|
-
* @param msg - The RPC message to send.
|
|
41
|
-
*/
|
|
42
|
-
sendMessage(msg) {
|
|
43
|
-
const m = new (0, _chunkKMCJ5MIQcjs.Message)();
|
|
44
|
-
m.setRoot(msg);
|
|
45
|
-
const buf = m.toArrayBuffer();
|
|
46
|
-
this.port.postMessage(buf, [
|
|
47
|
-
buf
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
}, _class);
|
|
51
|
-
var CapnpRPC = (_class2 = class {constructor() { _class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this); }
|
|
52
|
-
static {
|
|
53
|
-
_chunkUSNT2KNTcjs.__name.call(void 0, this, "CapnpRPC");
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* A queue for deferred connections that are waiting to be accepted.
|
|
57
|
-
*
|
|
58
|
-
* @remarks
|
|
59
|
-
* This is used to manage incoming connections when the accept method is called.
|
|
60
|
-
*/
|
|
61
|
-
__init2() {this.acceptQueue = new Array()}
|
|
62
|
-
/**
|
|
63
|
-
* A map of connections by their ID.
|
|
64
|
-
*
|
|
65
|
-
* @remarks
|
|
66
|
-
* This is used to manage multiple connections and allows for easy retrieval by ID.
|
|
67
|
-
*/
|
|
68
|
-
__init3() {this.connections = {}}
|
|
69
|
-
/**
|
|
70
|
-
* A queue for connections that are waiting to be accepted.
|
|
71
|
-
*
|
|
72
|
-
* @remarks
|
|
73
|
-
* This is used to manage incoming connections when the accept method is called.
|
|
74
|
-
*/
|
|
75
|
-
__init4() {this.connectQueue = new Array()}
|
|
76
|
-
/**
|
|
77
|
-
* Creates a new {@link Conn} instance.
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
81
|
-
*/
|
|
82
|
-
connect(id = 0) {
|
|
83
|
-
if (this.connections[id] !== void 0) {
|
|
84
|
-
return this.connections[id];
|
|
85
|
-
}
|
|
86
|
-
const ch = new (0, _worker_threads.MessageChannel)();
|
|
87
|
-
const conn = new (0, _chunkLFP6TIPQcjs.Conn)(new CapnpRPCMessageChannelTransport(ch.port1));
|
|
88
|
-
const accept = this.acceptQueue.pop();
|
|
89
|
-
this.connections[id] = conn;
|
|
90
|
-
if (accept === void 0) {
|
|
91
|
-
this.connectQueue.push(ch.port2);
|
|
92
|
-
} else {
|
|
93
|
-
accept.resolve(new (0, _chunkLFP6TIPQcjs.Conn)(new CapnpRPCMessageChannelTransport(ch.port2)));
|
|
94
|
-
}
|
|
95
|
-
return conn;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Accepts a connection from the connect queue.
|
|
99
|
-
*
|
|
100
|
-
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
101
|
-
* @throws If no connections are available in the connect queue.
|
|
102
|
-
*/
|
|
103
|
-
async accept() {
|
|
104
|
-
const port2 = this.connectQueue.pop();
|
|
105
|
-
if (port2 !== void 0) {
|
|
106
|
-
return Promise.resolve(new (0, _chunkLFP6TIPQcjs.Conn)(new CapnpRPCMessageChannelTransport(port2)));
|
|
107
|
-
}
|
|
108
|
-
const deferred = new (0, _chunkLFP6TIPQcjs.Deferred)();
|
|
109
|
-
this.acceptQueue.push(deferred);
|
|
110
|
-
return deferred.promise;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Closes all connections and clears the queues.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* This method will reject all pending accept promises and close all
|
|
117
|
-
* connections in the connect queue.
|
|
118
|
-
*/
|
|
119
|
-
close() {
|
|
120
|
-
let i = this.acceptQueue.length;
|
|
121
|
-
while (--i >= 0) {
|
|
122
|
-
_optionalChain([this, 'access', _ => _.acceptQueue, 'access', _2 => _2[i], 'optionalAccess', _3 => _3.reject, 'call', _4 => _4()]);
|
|
123
|
-
}
|
|
124
|
-
i = this.connectQueue.length;
|
|
125
|
-
while (--i >= 0) {
|
|
126
|
-
this.connectQueue[i].close();
|
|
127
|
-
}
|
|
128
|
-
for (const id in this.connections) {
|
|
129
|
-
_optionalChain([this, 'access', _5 => _5.connections, 'access', _6 => _6[id], 'optionalAccess', _7 => _7.shutdown, 'call', _8 => _8()]);
|
|
130
|
-
}
|
|
131
|
-
this.acceptQueue.length = 0;
|
|
132
|
-
this.connectQueue.length = 0;
|
|
133
|
-
this.connections = {};
|
|
134
|
-
}
|
|
135
|
-
}, _class2);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
exports.CapnpRPC = CapnpRPC; exports.CapnpRPCMessageChannelTransport = CapnpRPCMessageChannelTransport;
|
|
1
|
+
const e=require(`./helpers-BIiGufva.cjs`),t=require(`./dist-BzGdCkHS.cjs`);let n=require(`node:worker_threads`),r=require(`./shared/capnp-es.GpvEvMIK.mjs`),i=require(`./shared/capnp-es.UAt3nLGq.mjs`);var a=class extends t.a{port;constructor(e){super(),this.port=e,this.port.on(`message`,this.resolve),this.port.on(`messageerror`,this.reject),this.port.on(`close`,this.close)}close=()=>{this.port.off(`message`,this.resolve),this.port.off(`messageerror`,this.reject),this.port.off(`close`,this.close),this.port.close(),super.close()};sendMessage(e){let t=new r.M;t.setRoot(e);let n=t.toArrayBuffer();this.port.postMessage(n,[n])}},o=class{acceptQueue=[];connections={};connectQueue=[];connect(e=0){if(this.connections[e]!==void 0)return this.connections[e];let r=new n.MessageChannel,i=new t.r(new a(r.port1)),o=this.acceptQueue.pop();return this.connections[e]=i,o===void 0?this.connectQueue.push(r.port2):o.resolve(new t.r(new a(r.port2))),i}async accept(){let e=this.connectQueue.pop();if(e!==void 0)return Promise.resolve(new t.r(new a(e)));let n=new i.D;return this.acceptQueue.push(n),n.promise}close(){let e=this.acceptQueue.length;for(;--e>=0;)this.acceptQueue[e]?.reject();for(e=this.connectQueue.length;--e>=0;)this.connectQueue[e].close();for(let e in this.connections)this.connections[e]?.shutdown();this.acceptQueue.length=0,this.connectQueue.length=0,this.connections={}}};exports.CapnpRPC=o,exports.CapnpRPCMessageChannelTransport=a;
|
package/dist/rpc.d.cts
CHANGED
|
@@ -1,71 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Message } from
|
|
3
|
-
import { MessagePort } from
|
|
1
|
+
import { Conn, Deferred, DeferredTransport } from "capnp-es";
|
|
2
|
+
import { Message } from "capnp-es/capnp/rpc";
|
|
3
|
+
import { MessagePort } from "node:worker_threads";
|
|
4
|
+
|
|
5
|
+
//#region src/rpc.d.ts
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* A transport class for Cap'n Proto RPC that uses {@link MessageChannel} for communication.
|
|
7
9
|
*/
|
|
8
10
|
declare class CapnpRPCMessageChannelTransport extends DeferredTransport {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
port: MessagePort;
|
|
12
|
+
constructor(port: MessagePort);
|
|
13
|
+
/**
|
|
14
|
+
* Closes the transport and removes all event listeners.
|
|
15
|
+
*/
|
|
16
|
+
close: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Sends a Cap'n Proto RPC message over the MessagePort.
|
|
19
|
+
*
|
|
20
|
+
* @param msg - The RPC message to send.
|
|
21
|
+
*/
|
|
22
|
+
sendMessage(msg: Message): void;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* A class that manages Cap'n Proto RPC connections.
|
|
24
26
|
*/
|
|
25
27
|
declare class CapnpRPC {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
28
|
+
/**
|
|
29
|
+
* A queue for deferred connections that are waiting to be accepted.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* This is used to manage incoming connections when the accept method is called.
|
|
33
|
+
*/
|
|
34
|
+
protected acceptQueue: Deferred<Conn>[];
|
|
35
|
+
/**
|
|
36
|
+
* A map of connections by their ID.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* This is used to manage multiple connections and allows for easy retrieval by ID.
|
|
40
|
+
*/
|
|
41
|
+
protected connections: Record<number, Conn>;
|
|
42
|
+
/**
|
|
43
|
+
* A queue for connections that are waiting to be accepted.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* This is used to manage incoming connections when the accept method is called.
|
|
47
|
+
*/
|
|
48
|
+
protected connectQueue: MessagePort[];
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new {@link Conn} instance.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
54
|
+
*/
|
|
55
|
+
connect(id?: number): Conn;
|
|
56
|
+
/**
|
|
57
|
+
* Accepts a connection from the connect queue.
|
|
58
|
+
*
|
|
59
|
+
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
60
|
+
* @throws If no connections are available in the connect queue.
|
|
61
|
+
*/
|
|
62
|
+
accept(): Promise<Conn>;
|
|
63
|
+
/**
|
|
64
|
+
* Closes all connections and clears the queues.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* This method will reject all pending accept promises and close all
|
|
68
|
+
* connections in the connect queue.
|
|
69
|
+
*/
|
|
70
|
+
close(): void;
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
//#endregion
|
|
71
73
|
export { CapnpRPC, CapnpRPCMessageChannelTransport };
|
|
74
|
+
//# sourceMappingURL=rpc.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.cts","names":[],"sources":["../../src/rpc.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA0BA;AACe,cADF,+BAAA,SAAwC,iBAAA,CACtC;EAEY,IAAA,EAFZ,WAEY;EA2BD,WAAA,CAAA,IAAA,EA3BC,WA2BD;EA9B2B;;AA0CrD;EAOuB,KAAA,EAAA,GAAA,GAAA,IAAA;EAAA;;;;;EAiDU,WAAA,CAAA,GAAA,EApEP,OAoEO,CAAA,EAAA,IAAA;;;;;cAxDpB,QAAA;;;;;;;yBAOU,SAAA;;;;;;;yBAQE,eAAe;;;;;;;0BAQhB;;;;;;;wBAQE;;;;;;;YAyBD,QAAQ"}
|
package/dist/rpc.d.mts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { MessagePort } from "node:worker_threads";
|
|
2
|
+
import { Conn, Deferred, DeferredTransport } from "capnp-es";
|
|
3
|
+
import { Message } from "capnp-es/capnp/rpc";
|
|
4
|
+
|
|
5
|
+
//#region src/rpc.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A transport class for Cap'n Proto RPC that uses {@link MessageChannel} for communication.
|
|
9
|
+
*/
|
|
10
|
+
declare class CapnpRPCMessageChannelTransport extends DeferredTransport {
|
|
11
|
+
port: MessagePort;
|
|
12
|
+
constructor(port: MessagePort);
|
|
13
|
+
/**
|
|
14
|
+
* Closes the transport and removes all event listeners.
|
|
15
|
+
*/
|
|
16
|
+
close: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Sends a Cap'n Proto RPC message over the MessagePort.
|
|
19
|
+
*
|
|
20
|
+
* @param msg - The RPC message to send.
|
|
21
|
+
*/
|
|
22
|
+
sendMessage(msg: Message): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A class that manages Cap'n Proto RPC connections.
|
|
26
|
+
*/
|
|
27
|
+
declare class CapnpRPC {
|
|
28
|
+
/**
|
|
29
|
+
* A queue for deferred connections that are waiting to be accepted.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* This is used to manage incoming connections when the accept method is called.
|
|
33
|
+
*/
|
|
34
|
+
protected acceptQueue: Deferred<Conn>[];
|
|
35
|
+
/**
|
|
36
|
+
* A map of connections by their ID.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* This is used to manage multiple connections and allows for easy retrieval by ID.
|
|
40
|
+
*/
|
|
41
|
+
protected connections: Record<number, Conn>;
|
|
42
|
+
/**
|
|
43
|
+
* A queue for connections that are waiting to be accepted.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* This is used to manage incoming connections when the accept method is called.
|
|
47
|
+
*/
|
|
48
|
+
protected connectQueue: MessagePort[];
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new {@link Conn} instance.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
54
|
+
*/
|
|
55
|
+
connect(id?: number): Conn;
|
|
56
|
+
/**
|
|
57
|
+
* Accepts a connection from the connect queue.
|
|
58
|
+
*
|
|
59
|
+
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
60
|
+
* @throws If no connections are available in the connect queue.
|
|
61
|
+
*/
|
|
62
|
+
accept(): Promise<Conn>;
|
|
63
|
+
/**
|
|
64
|
+
* Closes all connections and clears the queues.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* This method will reject all pending accept promises and close all
|
|
68
|
+
* connections in the connect queue.
|
|
69
|
+
*/
|
|
70
|
+
close(): void;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { CapnpRPC, CapnpRPCMessageChannelTransport };
|
|
74
|
+
//# sourceMappingURL=rpc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.mts","names":[],"sources":["../../src/rpc.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA0BA;AACe,cADF,+BAAA,SAAwC,iBAAA,CACtC;EAEY,IAAA,EAFZ,WAEY;EA2BD,WAAA,CAAA,IAAA,EA3BC,WA2BD;EA9B2B;;AA0CrD;EAOuB,KAAA,EAAA,GAAA,GAAA,IAAA;EAAA;;;;;EAiDU,WAAA,CAAA,GAAA,EApEP,OAoEO,CAAA,EAAA,IAAA;;;;;cAxDpB,QAAA;;;;;;;yBAOU,SAAA;;;;;;;yBAQE,eAAe;;;;;;;0BAQhB;;;;;;;wBAQE;;;;;;;YAyBD,QAAQ"}
|
package/dist/rpc.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as e,c as t,i as n,s as r}from"./dist-CvDcvswe.mjs";import{MessageChannel as i}from"node:worker_threads";var a=class extends t{port;constructor(e){super(),this.port=e,this.port.on(`message`,this.resolve),this.port.on(`messageerror`,this.reject),this.port.on(`close`,this.close)}close=()=>{this.port.off(`message`,this.resolve),this.port.off(`messageerror`,this.reject),this.port.off(`close`,this.close),this.port.close(),super.close()};sendMessage(t){let n=new e;n.setRoot(t);let r=n.toArrayBuffer();this.port.postMessage(r,[r])}},o=class{acceptQueue=[];connections={};connectQueue=[];connect(e=0){if(this.connections[e]!==void 0)return this.connections[e];let t=new i,r=new n(new a(t.port1)),o=this.acceptQueue.pop();return this.connections[e]=r,o===void 0?this.connectQueue.push(t.port2):o.resolve(new n(new a(t.port2))),r}async accept(){let e=this.connectQueue.pop();if(e!==void 0)return Promise.resolve(new n(new a(e)));let t=new r;return this.acceptQueue.push(t),t.promise}close(){let e=this.acceptQueue.length;for(;--e>=0;)this.acceptQueue[e]?.reject();for(e=this.connectQueue.length;--e>=0;)this.connectQueue[e].close();for(let e in this.connections)this.connections[e]?.shutdown();this.acceptQueue.length=0,this.connectQueue.length=0,this.connections={}}};export{o as CapnpRPC,a as CapnpRPCMessageChannelTransport};
|
|
2
|
+
//# sourceMappingURL=rpc.mjs.map
|
package/dist/rpc.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.mjs","names":[],"sources":["../../src/rpc.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Conn, Deferred, DeferredTransport, Message } from \"capnp-es\";\nimport type { Message as RPCMessage } from \"capnp-es/capnp/rpc\";\nimport type { MessagePort } from \"node:worker_threads\";\nimport { MessageChannel } from \"node:worker_threads\";\n\n/**\n * A transport class for Cap'n Proto RPC that uses {@link MessageChannel} for communication.\n */\nexport class CapnpRPCMessageChannelTransport extends DeferredTransport {\n public port: MessagePort;\n\n public constructor(port: MessagePort) {\n super();\n\n this.port = port;\n\n this.port.on(\"message\", this.resolve);\n this.port.on(\"messageerror\", this.reject);\n this.port.on(\"close\", this.close);\n }\n\n /**\n * Closes the transport and removes all event listeners.\n */\n public override close = (): void => {\n this.port.off(\"message\", this.resolve);\n this.port.off(\"messageerror\", this.reject);\n this.port.off(\"close\", this.close);\n this.port.close();\n\n super.close();\n };\n\n /**\n * Sends a Cap'n Proto RPC message over the MessagePort.\n *\n * @param msg - The RPC message to send.\n */\n public sendMessage(msg: RPCMessage): void {\n const m = new Message();\n m.setRoot(msg);\n\n const buf = m.toArrayBuffer();\n this.port.postMessage(buf, [buf]);\n }\n}\n\n/**\n * A class that manages Cap'n Proto RPC connections.\n */\nexport class CapnpRPC {\n /**\n * A queue for deferred connections that are waiting to be accepted.\n *\n * @remarks\n * This is used to manage incoming connections when the accept method is called.\n */\n protected acceptQueue = new Array<Deferred<Conn>>();\n\n /**\n * A map of connections by their ID.\n *\n * @remarks\n * This is used to manage multiple connections and allows for easy retrieval by ID.\n */\n protected connections: Record<number, Conn> = {};\n\n /**\n * A queue for connections that are waiting to be accepted.\n *\n * @remarks\n * This is used to manage incoming connections when the accept method is called.\n */\n protected connectQueue = new Array<MessagePort>();\n\n /**\n * Creates a new {@link Conn} instance.\n *\n * @remarks\n * This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.\n */\n public connect(id = 0): Conn {\n if (this.connections[id] !== undefined) {\n return this.connections[id];\n }\n\n const ch = new MessageChannel();\n const conn = new Conn(new CapnpRPCMessageChannelTransport(ch.port1));\n const accept = this.acceptQueue.pop();\n this.connections[id] = conn;\n\n if (accept === undefined) {\n this.connectQueue.push(ch.port2);\n } else {\n accept.resolve(new Conn(new CapnpRPCMessageChannelTransport(ch.port2)));\n }\n\n return conn;\n }\n\n /**\n * Accepts a connection from the connect queue.\n *\n * @returns A promise that resolves to a Conn instance when a connection is accepted.\n * @throws If no connections are available in the connect queue.\n */\n public async accept(): Promise<Conn> {\n const port2 = this.connectQueue.pop();\n if (port2 !== undefined) {\n return Promise.resolve(\n new Conn(new CapnpRPCMessageChannelTransport(port2))\n );\n }\n\n const deferred = new Deferred<Conn>();\n this.acceptQueue.push(deferred);\n return deferred.promise;\n }\n\n /**\n * Closes all connections and clears the queues.\n *\n * @remarks\n * This method will reject all pending accept promises and close all\n * connections in the connect queue.\n */\n public close(): void {\n let i = this.acceptQueue.length;\n while (--i >= 0) {\n this.acceptQueue[i]?.reject();\n }\n\n i = this.connectQueue.length;\n while (--i >= 0) {\n this.connectQueue[i]!.close();\n }\n\n for (const id in this.connections) {\n this.connections[id]?.shutdown();\n }\n\n this.acceptQueue.length = 0;\n this.connectQueue.length = 0;\n this.connections = {};\n }\n}\n"],"mappings":"kHA0BA,IAAa,EAAb,cAAqD,CAAkB,CACrE,KAEA,YAAmB,EAAmB,CACpC,OAAO,CAEP,KAAK,KAAO,EAEZ,KAAK,KAAK,GAAG,UAAW,KAAK,QAAQ,CACrC,KAAK,KAAK,GAAG,eAAgB,KAAK,OAAO,CACzC,KAAK,KAAK,GAAG,QAAS,KAAK,MAAM,CAMnC,UAAoC,CAClC,KAAK,KAAK,IAAI,UAAW,KAAK,QAAQ,CACtC,KAAK,KAAK,IAAI,eAAgB,KAAK,OAAO,CAC1C,KAAK,KAAK,IAAI,QAAS,KAAK,MAAM,CAClC,KAAK,KAAK,OAAO,CAEjB,MAAM,OAAO,EAQf,YAAmB,EAAuB,CACxC,IAAM,EAAI,IAAI,EACd,EAAE,QAAQ,EAAI,CAEd,IAAM,EAAM,EAAE,eAAe,CAC7B,KAAK,KAAK,YAAY,EAAK,CAAC,EAAI,CAAC,GAOxB,EAAb,KAAsB,CAOpB,YAAwB,EAA2B,CAQnD,YAA8C,EAAE,CAQhD,aAAyB,EAAwB,CAQjD,QAAe,EAAK,EAAS,CAC3B,GAAI,KAAK,YAAY,KAAQ,IAAA,GAC3B,OAAO,KAAK,YAAY,GAG1B,IAAM,EAAK,IAAI,EACT,EAAO,IAAI,EAAK,IAAI,EAAgC,EAAG,MAAM,CAAC,CAC9D,EAAS,KAAK,YAAY,KAAK,CASrC,MARA,MAAK,YAAY,GAAM,EAEnB,IAAW,IAAA,GACb,KAAK,aAAa,KAAK,EAAG,MAAM,CAEhC,EAAO,QAAQ,IAAI,EAAK,IAAI,EAAgC,EAAG,MAAM,CAAC,CAAC,CAGlE,EAST,MAAa,QAAwB,CACnC,IAAM,EAAQ,KAAK,aAAa,KAAK,CACrC,GAAI,IAAU,IAAA,GACZ,OAAO,QAAQ,QACb,IAAI,EAAK,IAAI,EAAgC,EAAM,CAAC,CACrD,CAGH,IAAM,EAAW,IAAI,EAErB,OADA,KAAK,YAAY,KAAK,EAAS,CACxB,EAAS,QAUlB,OAAqB,CACnB,IAAI,EAAI,KAAK,YAAY,OACzB,KAAO,EAAE,GAAK,GACZ,KAAK,YAAY,IAAI,QAAQ,CAI/B,IADA,EAAI,KAAK,aAAa,OACf,EAAE,GAAK,GACZ,KAAK,aAAa,GAAI,OAAO,CAG/B,IAAK,IAAM,KAAM,KAAK,YACpB,KAAK,YAAY,IAAK,UAAU,CAGlC,KAAK,YAAY,OAAS,EAC1B,KAAK,aAAa,OAAS,EAC3B,KAAK,YAAc,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{files=[]};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CodeGeneratorRequest_RequestedFile_Import, Field, Node } from "capnp-es/capnp/schema";
|
|
2
|
+
import { ParsedCommandLine } from "typescript";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
interface CodeGeneratorFileContext {
|
|
6
|
+
readonly nodes: Node[];
|
|
7
|
+
readonly imports: CodeGeneratorRequest_RequestedFile_Import[];
|
|
8
|
+
concreteLists: Array<[string, Field]>;
|
|
9
|
+
generatedNodeIds: Set<string>;
|
|
10
|
+
generatedResultsPromiseIds: Set<bigint>;
|
|
11
|
+
tsPath: string;
|
|
12
|
+
codeParts?: string[];
|
|
13
|
+
constructor: any;
|
|
14
|
+
toString: () => string;
|
|
15
|
+
}
|
|
16
|
+
declare class CodeGeneratorContext {
|
|
17
|
+
files: CodeGeneratorFileContext[];
|
|
18
|
+
}
|
|
19
|
+
interface CapnpcCLIOptions {
|
|
20
|
+
noTs?: boolean;
|
|
21
|
+
js?: boolean;
|
|
22
|
+
dts?: boolean;
|
|
23
|
+
noDts?: boolean;
|
|
24
|
+
schema?: string;
|
|
25
|
+
output?: string;
|
|
26
|
+
importPath?: string;
|
|
27
|
+
tsconfig?: string;
|
|
28
|
+
skipGenerateId?: boolean;
|
|
29
|
+
noStandardImport?: boolean;
|
|
30
|
+
projectRoot?: string;
|
|
31
|
+
workspaceRoot?: string;
|
|
32
|
+
tty?: boolean;
|
|
33
|
+
}
|
|
34
|
+
type CapnpcOptions = Omit<CapnpcCLIOptions, "tsconfig" | "schema"> & {
|
|
35
|
+
schemas: string | string[];
|
|
36
|
+
} & ({
|
|
37
|
+
tsconfig: ParsedCommandLine;
|
|
38
|
+
tsconfigPath?: string;
|
|
39
|
+
} | {
|
|
40
|
+
tsconfig?: ParsedCommandLine;
|
|
41
|
+
tsconfigPath: string;
|
|
42
|
+
});
|
|
43
|
+
type CapnpcResolvedOptions = Omit<CapnpcOptions, "noTs" | "noDts" | "schemas" | "tsconfigPath" | "output" | "importPath" | "projectRoot" | "workspaceRoot"> & Required<Pick<CapnpcOptions, "output" | "projectRoot" | "workspaceRoot">> & {
|
|
44
|
+
ts: boolean;
|
|
45
|
+
importPath: string[];
|
|
46
|
+
schemas: string[];
|
|
47
|
+
tsconfig: ParsedCommandLine;
|
|
48
|
+
};
|
|
49
|
+
interface CapnpcResult {
|
|
50
|
+
ctx: CodeGeneratorContext;
|
|
51
|
+
files: Map<string, string>;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { CodeGeneratorContext as a, CapnpcResult as i, CapnpcOptions as n, CodeGeneratorFileContext as o, CapnpcResolvedOptions as r, CapnpcCLIOptions as t };
|
|
55
|
+
//# sourceMappingURL=types-D52qMMoK.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-D52qMMoK.d.cts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;;UA4BiB,wBAAA;kBAEC;EAFD,SAAA,OAAA,EAGG,yCAHqB,EAAA;EAEvB,aAAA,EAID,KAJC,CAAA,CAAA,MAAA,EAIc,KAJd,CAAA,CAAA;EACE,gBAAA,EAIA,GAJA,CAAA,MAAA,CAAA;EAGY,0BAAA,EAEF,GAFE,CAAA,MAAA,CAAA;EAAf,MAAA,EAAA,MAAA;EACG,SAAA,CAAA,EAAA,MAAA,EAAA;EACU,WAAA,EAAA,GAAA;EAAG,QAAA,EAAA,GAAA,GAAA,MAAA;AASjC;AAIiB,cAJJ,oBAAA,CAIoB;EAgBrB,KAAA,EAnBH,wBAmBgB,EAAA;;AAAG,UAhBX,gBAAA,CAgBW;EAIV,IAAA,CAAA,EAAA,OAAA;EAIC,EAAA,CAAA,EAAA,OAAA;EAAiB,GAAA,CAAA,EAAA,OAAA;EAKxB,KAAA,CAAA,EAAA,OAAA;EACV,MAAA,CAAA,EAAA,MAAA;EADkC,MAAA,CAAA,EAAA,MAAA;EAWpB,UAAA,CAAA,EAAA,MAAA;EAAL,QAAA,CAAA,EAAA,MAAA;EAAT,cAAA,CAAA,EAAA,OAAA;EAIY,gBAAA,CAAA,EAAA,OAAA;EAAiB,WAAA,CAAA,EAAA,MAAA;EAGd,aAAA,CAAA,EAAY,MAAA;;;KA/BjB,aAAA,GAAgB,KAAK;;;YAIf;;;aAIC;;;KAKP,qBAAA,GAAwB,KAClC,4HAUA,SAAS,KAAK;;;;YAIF;;UAGG,YAAA;OACV;SACE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ParsedCommandLine } from "typescript";
|
|
2
|
+
import { CodeGeneratorRequest_RequestedFile_Import, Field, Node } from "capnp-es/capnp/schema";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
interface CodeGeneratorFileContext {
|
|
6
|
+
readonly nodes: Node[];
|
|
7
|
+
readonly imports: CodeGeneratorRequest_RequestedFile_Import[];
|
|
8
|
+
concreteLists: Array<[string, Field]>;
|
|
9
|
+
generatedNodeIds: Set<string>;
|
|
10
|
+
generatedResultsPromiseIds: Set<bigint>;
|
|
11
|
+
tsPath: string;
|
|
12
|
+
codeParts?: string[];
|
|
13
|
+
constructor: any;
|
|
14
|
+
toString: () => string;
|
|
15
|
+
}
|
|
16
|
+
declare class CodeGeneratorContext {
|
|
17
|
+
files: CodeGeneratorFileContext[];
|
|
18
|
+
}
|
|
19
|
+
interface CapnpcCLIOptions {
|
|
20
|
+
noTs?: boolean;
|
|
21
|
+
js?: boolean;
|
|
22
|
+
dts?: boolean;
|
|
23
|
+
noDts?: boolean;
|
|
24
|
+
schema?: string;
|
|
25
|
+
output?: string;
|
|
26
|
+
importPath?: string;
|
|
27
|
+
tsconfig?: string;
|
|
28
|
+
skipGenerateId?: boolean;
|
|
29
|
+
noStandardImport?: boolean;
|
|
30
|
+
projectRoot?: string;
|
|
31
|
+
workspaceRoot?: string;
|
|
32
|
+
tty?: boolean;
|
|
33
|
+
}
|
|
34
|
+
type CapnpcOptions = Omit<CapnpcCLIOptions, "tsconfig" | "schema"> & {
|
|
35
|
+
schemas: string | string[];
|
|
36
|
+
} & ({
|
|
37
|
+
tsconfig: ParsedCommandLine;
|
|
38
|
+
tsconfigPath?: string;
|
|
39
|
+
} | {
|
|
40
|
+
tsconfig?: ParsedCommandLine;
|
|
41
|
+
tsconfigPath: string;
|
|
42
|
+
});
|
|
43
|
+
type CapnpcResolvedOptions = Omit<CapnpcOptions, "noTs" | "noDts" | "schemas" | "tsconfigPath" | "output" | "importPath" | "projectRoot" | "workspaceRoot"> & Required<Pick<CapnpcOptions, "output" | "projectRoot" | "workspaceRoot">> & {
|
|
44
|
+
ts: boolean;
|
|
45
|
+
importPath: string[];
|
|
46
|
+
schemas: string[];
|
|
47
|
+
tsconfig: ParsedCommandLine;
|
|
48
|
+
};
|
|
49
|
+
interface CapnpcResult {
|
|
50
|
+
ctx: CodeGeneratorContext;
|
|
51
|
+
files: Map<string, string>;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { CodeGeneratorContext as a, CapnpcResult as i, CapnpcOptions as n, CodeGeneratorFileContext as o, CapnpcResolvedOptions as r, CapnpcCLIOptions as t };
|
|
55
|
+
//# sourceMappingURL=types-DBd3Wi0H.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DBd3Wi0H.d.mts","names":[],"sources":["../../src/types.ts"],"sourcesContent":[],"mappings":";;;;UA4BiB,wBAAA;kBAEC;EAFD,SAAA,OAAA,EAGG,yCAHqB,EAAA;EAEvB,aAAA,EAID,KAJC,CAAA,CAAA,MAAA,EAIc,KAJd,CAAA,CAAA;EACE,gBAAA,EAIA,GAJA,CAAA,MAAA,CAAA;EAGY,0BAAA,EAEF,GAFE,CAAA,MAAA,CAAA;EAAf,MAAA,EAAA,MAAA;EACG,SAAA,CAAA,EAAA,MAAA,EAAA;EACU,WAAA,EAAA,GAAA;EAAG,QAAA,EAAA,GAAA,GAAA,MAAA;AASjC;AAIiB,cAJJ,oBAAA,CAIoB;EAgBrB,KAAA,EAnBH,wBAmBgB,EAAA;;AAAG,UAhBX,gBAAA,CAgBW;EAIV,IAAA,CAAA,EAAA,OAAA;EAIC,EAAA,CAAA,EAAA,OAAA;EAAiB,GAAA,CAAA,EAAA,OAAA;EAKxB,KAAA,CAAA,EAAA,OAAA;EACV,MAAA,CAAA,EAAA,MAAA;EADkC,MAAA,CAAA,EAAA,MAAA;EAWpB,UAAA,CAAA,EAAA,MAAA;EAAL,QAAA,CAAA,EAAA,MAAA;EAAT,cAAA,CAAA,EAAA,OAAA;EAIY,gBAAA,CAAA,EAAA,OAAA;EAAiB,WAAA,CAAA,EAAA,MAAA;EAGd,aAAA,CAAA,EAAY,MAAA;;;KA/BjB,aAAA,GAAgB,KAAK;;;YAIf;;;aAIC;;;KAKP,qBAAA,GAAwB,KAClC,4HAUA,SAAS,KAAK;;;;YAIF;;UAGG,YAAA;OACV;SACE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-y_yfxLs5.mjs","names":[],"sources":["../../src/types.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable camelcase */\n\nimport type {\n CodeGeneratorRequest_RequestedFile_Import,\n Field,\n Node\n} from \"capnp-es/capnp/schema\";\n// eslint-disable-next-line ts/consistent-type-imports\nimport { ParsedCommandLine } from \"typescript\";\n\nexport interface CodeGeneratorFileContext {\n // inputs\n readonly nodes: Node[];\n readonly imports: CodeGeneratorRequest_RequestedFile_Import[];\n\n // outputs\n concreteLists: Array<[string, Field]>;\n generatedNodeIds: Set<string>;\n generatedResultsPromiseIds: Set<bigint>;\n tsPath: string;\n codeParts?: string[];\n\n constructor: any;\n\n toString: () => string;\n}\n\nexport class CodeGeneratorContext {\n files: CodeGeneratorFileContext[] = [];\n}\n\nexport interface CapnpcCLIOptions {\n noTs?: boolean;\n js?: boolean;\n dts?: boolean;\n noDts?: boolean;\n schema?: string;\n output?: string;\n importPath?: string;\n tsconfig?: string;\n skipGenerateId?: boolean;\n noStandardImport?: boolean;\n projectRoot?: string;\n workspaceRoot?: string;\n tty?: boolean;\n}\n\nexport type CapnpcOptions = Omit<CapnpcCLIOptions, \"tsconfig\" | \"schema\"> & {\n schemas: string | string[];\n} & (\n | {\n tsconfig: ParsedCommandLine;\n tsconfigPath?: string;\n }\n | {\n tsconfig?: ParsedCommandLine;\n tsconfigPath: string;\n }\n );\n\nexport type CapnpcResolvedOptions = Omit<\n CapnpcOptions,\n | \"noTs\"\n | \"noDts\"\n | \"schemas\"\n | \"tsconfigPath\"\n | \"output\"\n | \"importPath\"\n | \"projectRoot\"\n | \"workspaceRoot\"\n> &\n Required<Pick<CapnpcOptions, \"output\" | \"projectRoot\" | \"workspaceRoot\">> & {\n ts: boolean;\n importPath: string[];\n schemas: string[];\n tsconfig: ParsedCommandLine;\n };\n\nexport interface CapnpcResult {\n ctx: CodeGeneratorContext;\n files: Map<string, string>;\n}\n"],"mappings":"AA6CA,IAAa,EAAb,KAAkC,CAChC,MAAoC,EAAE"}
|
package/dist/types.cjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _chunkR2JXWA7Qcjs = require('./chunk-R2JXWA7Q.cjs');
|
|
4
|
-
require('./chunk-USNT2KNT.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.CodeGeneratorContext = _chunkR2JXWA7Qcjs.CodeGeneratorContext;
|
|
1
|
+
const e=require(`./types-B2gKzfwi.cjs`);exports.CodeGeneratorContext=e.t;
|
package/dist/types.d.cts
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface CodeGeneratorFileContext {
|
|
5
|
-
readonly nodes: Node[];
|
|
6
|
-
readonly imports: CodeGeneratorRequest_RequestedFile_Import[];
|
|
7
|
-
concreteLists: Array<[string, Field]>;
|
|
8
|
-
generatedNodeIds: Set<string>;
|
|
9
|
-
generatedResultsPromiseIds: Set<bigint>;
|
|
10
|
-
tsPath: string;
|
|
11
|
-
codeParts?: string[];
|
|
12
|
-
constructor: any;
|
|
13
|
-
toString: () => string;
|
|
14
|
-
}
|
|
15
|
-
declare class CodeGeneratorContext {
|
|
16
|
-
files: CodeGeneratorFileContext[];
|
|
17
|
-
}
|
|
18
|
-
interface CapnpcCLIOptions {
|
|
19
|
-
noTs?: boolean;
|
|
20
|
-
js?: boolean;
|
|
21
|
-
dts?: boolean;
|
|
22
|
-
noDts?: boolean;
|
|
23
|
-
schema?: string;
|
|
24
|
-
output?: string;
|
|
25
|
-
importPath?: string;
|
|
26
|
-
tsconfig?: string;
|
|
27
|
-
skipGenerateId?: boolean;
|
|
28
|
-
noStandardImport?: boolean;
|
|
29
|
-
projectRoot?: string;
|
|
30
|
-
workspaceRoot?: string;
|
|
31
|
-
tty?: boolean;
|
|
32
|
-
}
|
|
33
|
-
type CapnpcOptions = Omit<CapnpcCLIOptions, "tsconfig" | "schema"> & {
|
|
34
|
-
schemas: string | string[];
|
|
35
|
-
} & ({
|
|
36
|
-
tsconfig: ParsedCommandLine;
|
|
37
|
-
tsconfigPath?: string;
|
|
38
|
-
} | {
|
|
39
|
-
tsconfig?: ParsedCommandLine;
|
|
40
|
-
tsconfigPath: string;
|
|
41
|
-
});
|
|
42
|
-
type CapnpcResolvedOptions = Omit<CapnpcOptions, "noTs" | "noDts" | "schemas" | "tsconfigPath" | "output" | "importPath" | "projectRoot" | "workspaceRoot"> & Required<Pick<CapnpcOptions, "output" | "projectRoot" | "workspaceRoot">> & {
|
|
43
|
-
ts: boolean;
|
|
44
|
-
importPath: string[];
|
|
45
|
-
schemas: string[];
|
|
46
|
-
tsconfig: ParsedCommandLine;
|
|
47
|
-
};
|
|
48
|
-
interface CapnpcResult {
|
|
49
|
-
ctx: CodeGeneratorContext;
|
|
50
|
-
files: Map<string, string>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { type CapnpcCLIOptions, type CapnpcOptions, type CapnpcResolvedOptions, type CapnpcResult, CodeGeneratorContext, type CodeGeneratorFileContext };
|
|
1
|
+
import { a as CodeGeneratorContext, i as CapnpcResult, n as CapnpcOptions, o as CodeGeneratorFileContext, r as CapnpcResolvedOptions, t as CapnpcCLIOptions } from "./types-D52qMMoK.cjs";
|
|
2
|
+
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResolvedOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as CodeGeneratorContext, i as CapnpcResult, n as CapnpcOptions, o as CodeGeneratorFileContext, r as CapnpcResolvedOptions, t as CapnpcCLIOptions } from "./types-DBd3Wi0H.mjs";
|
|
2
|
+
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResolvedOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./types-y_yfxLs5.mjs";export{e as CodeGeneratorContext};
|