@stryke/capnp 0.2.6 → 0.4.0
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/bin/capnpc.cjs +1179 -0
- package/bin/capnpc.js +1146 -0
- package/dist/chunk-LY3GWW4E.js +977 -0
- package/dist/chunk-ORA4UQMU.cjs +1 -0
- package/dist/chunk-PV3OG5H3.cjs +977 -0
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-USNT2KNT.cjs +6 -0
- package/dist/compile.cjs +6 -66
- package/dist/compile.d.cts +7 -0
- package/dist/compile.d.ts +7 -2
- package/dist/compile.js +7 -0
- package/dist/index.cjs +7 -26
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -10
- package/dist/index.js +8 -0
- package/dist/rpc.cjs +103 -0
- package/dist/rpc.d.cts +42 -0
- package/dist/rpc.d.ts +42 -0
- package/dist/rpc.js +103 -0
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +37 -0
- package/dist/types.d.ts +25 -18
- package/dist/types.js +1 -0
- package/package.json +61 -46
- package/dist/compile.mjs +0 -1
- package/dist/index.mjs +0 -1
- /package/dist/{types.mjs → chunk-OULCUN6I.js} +0 -0
package/dist/compile.cjs
CHANGED
|
@@ -1,67 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _writeFile = require("@stryke/fs/write-file");
|
|
9
|
-
var _filePathFns = require("@stryke/path/file-path-fns");
|
|
10
|
-
var _joinPaths = require("@stryke/path/join-paths");
|
|
11
|
-
var _compiler = require("capnp-es/compiler");
|
|
12
|
-
var _nodeBuffer = require("node:buffer");
|
|
13
|
-
var _nodeChild_process = require("node:child_process");
|
|
14
|
-
var _nodeFs = require("node:fs");
|
|
15
|
-
async function k() {
|
|
16
|
-
if (process.stdin.isTTY) return _nodeBuffer.Buffer.alloc(0);
|
|
17
|
-
const i = [];
|
|
18
|
-
process.stdin.on("data", t => {
|
|
19
|
-
i.push(t);
|
|
20
|
-
}), await new Promise(t => {
|
|
21
|
-
process.stdin.on("end", t);
|
|
22
|
-
});
|
|
23
|
-
const e = _nodeBuffer.Buffer.alloc(i.reduce((t, n) => t + n.byteLength, 0));
|
|
24
|
-
let c = 0;
|
|
25
|
-
for (const t of i) t.copy(e, c), c += t.byteLength;
|
|
26
|
-
return e;
|
|
27
|
-
}
|
|
28
|
-
async function capnpc(i) {
|
|
29
|
-
try {
|
|
30
|
-
const {
|
|
31
|
-
ts: e = !0,
|
|
32
|
-
js: c = !1,
|
|
33
|
-
dts: t = !1,
|
|
34
|
-
outDir: n,
|
|
35
|
-
tsconfig: d
|
|
36
|
-
} = i;
|
|
37
|
-
let f = await k();
|
|
38
|
-
if (f.byteLength === 0) {
|
|
39
|
-
const o = [];
|
|
40
|
-
n ? o.push(`-o-:${n}`) : o.push("-o-"), f = await new Promise(a => {
|
|
41
|
-
(0, _nodeChild_process.exec)(`capnpc ${o.join(" ")} ${o.join(" ")}`, {
|
|
42
|
-
encoding: "buffer"
|
|
43
|
-
}, (r, s, u) => {
|
|
44
|
-
if (u.length > 0 && process.stderr.write(u), r) throw r;
|
|
45
|
-
a(s);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const l = await (0, _compiler.compileAll)(f, {
|
|
50
|
-
ts: e,
|
|
51
|
-
js: c,
|
|
52
|
-
dts: t,
|
|
53
|
-
tsconfig: d
|
|
54
|
-
});
|
|
55
|
-
for (const [o, a] of l.files) {
|
|
56
|
-
let r = o;
|
|
57
|
-
if (!(0, _nodeFs.existsSync)((0, _filePathFns.findFilePath)(r))) {
|
|
58
|
-
const s = `/${r}`;
|
|
59
|
-
(0, _nodeFs.existsSync)((0, _filePathFns.findFilePath)(s)) && (r = s);
|
|
60
|
-
}
|
|
61
|
-
n && (r = (0, _joinPaths.joinPaths)(n, o)), await (0, _helpers.createDirectory)((0, _filePathFns.findFilePath)(r)), await (0, _writeFile.writeFile)(r, a.replace(/^\s+/gm, s => " ".repeat(s.length / 2)));
|
|
62
|
-
}
|
|
63
|
-
return l;
|
|
64
|
-
} catch (e) {
|
|
65
|
-
throw e instanceof Error ? (console.error(`Error: ${e.message}`), e.stack && console.error(e.stack)) : console.error("An unknown error occurred:", e), e;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
3
|
+
var _chunkPV3OG5H3cjs = require('./chunk-PV3OG5H3.cjs');
|
|
4
|
+
require('./chunk-USNT2KNT.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.capnpc = _chunkPV3OG5H3cjs.capnpc;
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { CapnpcOptions, CapnpcResult } from './types.js';
|
|
2
|
+
import 'capnp-es/capnp/schema';
|
|
3
|
+
import 'typescript';
|
|
4
|
+
|
|
5
|
+
declare function capnpc(options: CapnpcOptions): Promise<CapnpcResult>;
|
|
6
|
+
|
|
7
|
+
export { capnpc };
|
package/dist/compile.js
ADDED
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (key in exports && exports[key] === _compile[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _compile[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _types = require("./types.cjs");
|
|
18
|
-
Object.keys(_types).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _types[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
3
|
+
var _chunkPV3OG5H3cjs = require('./chunk-PV3OG5H3.cjs');
|
|
4
|
+
require('./chunk-USNT2KNT.cjs');
|
|
5
|
+
require('./chunk-ORA4UQMU.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.capnpc = _chunkPV3OG5H3cjs.capnpc;
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* A package for running the Cap'n Proto compiler in a TypeScript application
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
export * from "./compile";
|
|
10
|
-
export * from "./types";
|
|
1
|
+
export { capnpc } from './compile.js';
|
|
2
|
+
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext } from './types.js';
|
|
3
|
+
import 'capnp-es/capnp/schema';
|
|
4
|
+
import 'typescript';
|
package/dist/index.js
ADDED
package/dist/rpc.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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; } var _class;
|
|
2
|
+
|
|
3
|
+
var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
|
|
4
|
+
|
|
5
|
+
// src/rpc.ts
|
|
6
|
+
var _capnpes = require('capnp-es');
|
|
7
|
+
var _worker_threads = require('worker_threads');
|
|
8
|
+
var CapnpRPC = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this); }
|
|
9
|
+
static {
|
|
10
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, this, "CapnpRPC");
|
|
11
|
+
}
|
|
12
|
+
__init() {this.acceptQueue = new Array()}
|
|
13
|
+
__init2() {this.connections = {}}
|
|
14
|
+
__init3() {this.connectQueue = new Array()}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new {@link Conn} instance.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
20
|
+
*/
|
|
21
|
+
connect(id = 0) {
|
|
22
|
+
if (this.connections[id] !== void 0) return this.connections[id];
|
|
23
|
+
const ch = new (0, _worker_threads.MessageChannel)();
|
|
24
|
+
const conn = new (0, _capnpes.Conn)(new MessageChannelTransport(ch.port1));
|
|
25
|
+
const accept = this.acceptQueue.pop();
|
|
26
|
+
this.connections[id] = conn;
|
|
27
|
+
if (accept === void 0) {
|
|
28
|
+
this.connectQueue.push(ch.port2);
|
|
29
|
+
} else {
|
|
30
|
+
accept.resolve(new (0, _capnpes.Conn)(new MessageChannelTransport(ch.port2)));
|
|
31
|
+
}
|
|
32
|
+
return conn;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Accepts a connection from the connect queue.
|
|
36
|
+
*
|
|
37
|
+
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
38
|
+
* @throws If no connections are available in the connect queue.
|
|
39
|
+
*/
|
|
40
|
+
async accept() {
|
|
41
|
+
const port2 = this.connectQueue.pop();
|
|
42
|
+
if (port2 !== void 0) {
|
|
43
|
+
return Promise.resolve(new (0, _capnpes.Conn)(new MessageChannelTransport(port2)));
|
|
44
|
+
}
|
|
45
|
+
const deferred = new (0, _capnpes.Deferred)();
|
|
46
|
+
this.acceptQueue.push(deferred);
|
|
47
|
+
return deferred.promise;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Closes all connections and clears the queues.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This method will reject all pending accept promises and close all
|
|
54
|
+
* connections in the connect queue.
|
|
55
|
+
*/
|
|
56
|
+
close() {
|
|
57
|
+
let i = this.acceptQueue.length;
|
|
58
|
+
while (--i >= 0) {
|
|
59
|
+
_optionalChain([this, 'access', _ => _.acceptQueue, 'access', _2 => _2[i], 'optionalAccess', _3 => _3.reject, 'call', _4 => _4()]);
|
|
60
|
+
}
|
|
61
|
+
i = this.connectQueue.length;
|
|
62
|
+
while (--i >= 0) {
|
|
63
|
+
_optionalChain([this, 'access', _5 => _5.connectQueue, 'access', _6 => _6[i], 'optionalAccess', _7 => _7.close, 'call', _8 => _8()]);
|
|
64
|
+
}
|
|
65
|
+
for (const id in this.connections) {
|
|
66
|
+
_optionalChain([this, 'access', _9 => _9.connections, 'access', _10 => _10[id], 'optionalAccess', _11 => _11.shutdown, 'call', _12 => _12()]);
|
|
67
|
+
}
|
|
68
|
+
this.acceptQueue.length = 0;
|
|
69
|
+
this.connectQueue.length = 0;
|
|
70
|
+
this.connections = {};
|
|
71
|
+
}
|
|
72
|
+
}, _class);
|
|
73
|
+
var MessageChannelTransport = class extends _capnpes.DeferredTransport {
|
|
74
|
+
static {
|
|
75
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, this, "MessageChannelTransport");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
constructor(port) {
|
|
79
|
+
super(), this.port = port, this.close = () => {
|
|
80
|
+
this.port.off("message", this.resolve);
|
|
81
|
+
this.port.off("messageerror", this.reject);
|
|
82
|
+
this.port.off("close", this.close);
|
|
83
|
+
this.port.close();
|
|
84
|
+
super.close();
|
|
85
|
+
};
|
|
86
|
+
this.port.on("message", this.resolve);
|
|
87
|
+
this.port.on("messageerror", this.reject);
|
|
88
|
+
this.port.on("close", this.close);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
sendMessage(msg) {
|
|
92
|
+
const m = new (0, _capnpes.Message)();
|
|
93
|
+
m.setRoot(msg);
|
|
94
|
+
const buf = m.toArrayBuffer();
|
|
95
|
+
this.port.postMessage(buf, [
|
|
96
|
+
buf
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
exports.CapnpRPC = CapnpRPC; exports.MessageChannelTransport = MessageChannelTransport;
|
package/dist/rpc.d.cts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Deferred, Conn, DeferredTransport } from 'capnp-es';
|
|
2
|
+
import { Message } from 'capnp-es/capnp/rpc';
|
|
3
|
+
import { MessagePort } from 'node:worker_threads';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A class that manages Cap'n Proto RPC connections.
|
|
7
|
+
*/
|
|
8
|
+
declare class CapnpRPC {
|
|
9
|
+
protected acceptQueue: Deferred<Conn>[];
|
|
10
|
+
protected connections: Record<number, Conn>;
|
|
11
|
+
protected connectQueue: MessagePort[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link Conn} instance.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
17
|
+
*/
|
|
18
|
+
connect(id?: number): Conn;
|
|
19
|
+
/**
|
|
20
|
+
* Accepts a connection from the connect queue.
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
23
|
+
* @throws If no connections are available in the connect queue.
|
|
24
|
+
*/
|
|
25
|
+
accept(): Promise<Conn>;
|
|
26
|
+
/**
|
|
27
|
+
* Closes all connections and clears the queues.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This method will reject all pending accept promises and close all
|
|
31
|
+
* connections in the connect queue.
|
|
32
|
+
*/
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
declare class MessageChannelTransport extends DeferredTransport {
|
|
36
|
+
port: MessagePort;
|
|
37
|
+
constructor(port: MessagePort);
|
|
38
|
+
close: () => void;
|
|
39
|
+
sendMessage(msg: Message): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { CapnpRPC, MessageChannelTransport };
|
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Deferred, Conn, DeferredTransport } from 'capnp-es';
|
|
2
|
+
import { Message } from 'capnp-es/capnp/rpc';
|
|
3
|
+
import { MessagePort } from 'node:worker_threads';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A class that manages Cap'n Proto RPC connections.
|
|
7
|
+
*/
|
|
8
|
+
declare class CapnpRPC {
|
|
9
|
+
protected acceptQueue: Deferred<Conn>[];
|
|
10
|
+
protected connections: Record<number, Conn>;
|
|
11
|
+
protected connectQueue: MessagePort[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link Conn} instance.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
17
|
+
*/
|
|
18
|
+
connect(id?: number): Conn;
|
|
19
|
+
/**
|
|
20
|
+
* Accepts a connection from the connect queue.
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
23
|
+
* @throws If no connections are available in the connect queue.
|
|
24
|
+
*/
|
|
25
|
+
accept(): Promise<Conn>;
|
|
26
|
+
/**
|
|
27
|
+
* Closes all connections and clears the queues.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* This method will reject all pending accept promises and close all
|
|
31
|
+
* connections in the connect queue.
|
|
32
|
+
*/
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
declare class MessageChannelTransport extends DeferredTransport {
|
|
36
|
+
port: MessagePort;
|
|
37
|
+
constructor(port: MessagePort);
|
|
38
|
+
close: () => void;
|
|
39
|
+
sendMessage(msg: Message): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { CapnpRPC, MessageChannelTransport };
|
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-SHUYVCID.js";
|
|
4
|
+
|
|
5
|
+
// src/rpc.ts
|
|
6
|
+
import { Conn, Deferred, DeferredTransport, Message } from "capnp-es";
|
|
7
|
+
import { MessageChannel } from "node:worker_threads";
|
|
8
|
+
var CapnpRPC = class {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "CapnpRPC");
|
|
11
|
+
}
|
|
12
|
+
acceptQueue = new Array();
|
|
13
|
+
connections = {};
|
|
14
|
+
connectQueue = new Array();
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new {@link Conn} instance.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
|
|
20
|
+
*/
|
|
21
|
+
connect(id = 0) {
|
|
22
|
+
if (this.connections[id] !== void 0) return this.connections[id];
|
|
23
|
+
const ch = new MessageChannel();
|
|
24
|
+
const conn = new Conn(new MessageChannelTransport(ch.port1));
|
|
25
|
+
const accept = this.acceptQueue.pop();
|
|
26
|
+
this.connections[id] = conn;
|
|
27
|
+
if (accept === void 0) {
|
|
28
|
+
this.connectQueue.push(ch.port2);
|
|
29
|
+
} else {
|
|
30
|
+
accept.resolve(new Conn(new MessageChannelTransport(ch.port2)));
|
|
31
|
+
}
|
|
32
|
+
return conn;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Accepts a connection from the connect queue.
|
|
36
|
+
*
|
|
37
|
+
* @returns A promise that resolves to a Conn instance when a connection is accepted.
|
|
38
|
+
* @throws If no connections are available in the connect queue.
|
|
39
|
+
*/
|
|
40
|
+
async accept() {
|
|
41
|
+
const port2 = this.connectQueue.pop();
|
|
42
|
+
if (port2 !== void 0) {
|
|
43
|
+
return Promise.resolve(new Conn(new MessageChannelTransport(port2)));
|
|
44
|
+
}
|
|
45
|
+
const deferred = new Deferred();
|
|
46
|
+
this.acceptQueue.push(deferred);
|
|
47
|
+
return deferred.promise;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Closes all connections and clears the queues.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This method will reject all pending accept promises and close all
|
|
54
|
+
* connections in the connect queue.
|
|
55
|
+
*/
|
|
56
|
+
close() {
|
|
57
|
+
let i = this.acceptQueue.length;
|
|
58
|
+
while (--i >= 0) {
|
|
59
|
+
this.acceptQueue[i]?.reject();
|
|
60
|
+
}
|
|
61
|
+
i = this.connectQueue.length;
|
|
62
|
+
while (--i >= 0) {
|
|
63
|
+
this.connectQueue[i]?.close();
|
|
64
|
+
}
|
|
65
|
+
for (const id in this.connections) {
|
|
66
|
+
this.connections[id]?.shutdown();
|
|
67
|
+
}
|
|
68
|
+
this.acceptQueue.length = 0;
|
|
69
|
+
this.connectQueue.length = 0;
|
|
70
|
+
this.connections = {};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var MessageChannelTransport = class extends DeferredTransport {
|
|
74
|
+
static {
|
|
75
|
+
__name(this, "MessageChannelTransport");
|
|
76
|
+
}
|
|
77
|
+
port;
|
|
78
|
+
constructor(port) {
|
|
79
|
+
super(), this.port = port, this.close = () => {
|
|
80
|
+
this.port.off("message", this.resolve);
|
|
81
|
+
this.port.off("messageerror", this.reject);
|
|
82
|
+
this.port.off("close", this.close);
|
|
83
|
+
this.port.close();
|
|
84
|
+
super.close();
|
|
85
|
+
};
|
|
86
|
+
this.port.on("message", this.resolve);
|
|
87
|
+
this.port.on("messageerror", this.reject);
|
|
88
|
+
this.port.on("close", this.close);
|
|
89
|
+
}
|
|
90
|
+
close;
|
|
91
|
+
sendMessage(msg) {
|
|
92
|
+
const m = new Message();
|
|
93
|
+
m.setRoot(msg);
|
|
94
|
+
const buf = m.toArrayBuffer();
|
|
95
|
+
this.port.postMessage(buf, [
|
|
96
|
+
buf
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
CapnpRPC,
|
|
102
|
+
MessageChannelTransport
|
|
103
|
+
};
|
package/dist/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";require('./chunk-ORA4UQMU.cjs');
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Node, CodeGeneratorRequest_RequestedFile_Import, Field, CodeGeneratorRequest, CodeGeneratorRequest_RequestedFile } from 'capnp-es/capnp/schema';
|
|
2
|
+
import ts from 'typescript';
|
|
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: (req: CodeGeneratorRequest, file: CodeGeneratorRequest_RequestedFile) => any;
|
|
13
|
+
toString: () => string;
|
|
14
|
+
}
|
|
15
|
+
interface CodeGeneratorContext {
|
|
16
|
+
files: CodeGeneratorFileContext[];
|
|
17
|
+
}
|
|
18
|
+
interface CapnpcCLIOptions {
|
|
19
|
+
ts: boolean;
|
|
20
|
+
js: boolean;
|
|
21
|
+
dts: boolean;
|
|
22
|
+
sourcePath: string[];
|
|
23
|
+
outputPath: string;
|
|
24
|
+
importPath: string[];
|
|
25
|
+
tsconfigPath: string;
|
|
26
|
+
generateId: boolean;
|
|
27
|
+
standardImport: boolean;
|
|
28
|
+
}
|
|
29
|
+
type CapnpcOptions = Omit<CapnpcCLIOptions, "tsconfigPath"> & {
|
|
30
|
+
tsconfig?: ts.ParsedCommandLine;
|
|
31
|
+
};
|
|
32
|
+
interface CapnpcResult {
|
|
33
|
+
ctx: CodeGeneratorContext;
|
|
34
|
+
files: Map<string, string>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { CapnpcCLIOptions, CapnpcOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { Node, CodeGeneratorRequest_RequestedFile_Import, Field, CodeGeneratorRequest, CodeGeneratorRequest_RequestedFile } from 'capnp-es/capnp/schema';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
|
|
4
|
+
interface CodeGeneratorFileContext {
|
|
5
|
+
readonly nodes: Node[];
|
|
6
|
+
readonly imports: CodeGeneratorRequest_RequestedFile_Import[];
|
|
4
7
|
concreteLists: Array<[string, Field]>;
|
|
5
|
-
|
|
6
|
-
generatedNodeIds: string[];
|
|
8
|
+
generatedNodeIds: Set<string>;
|
|
7
9
|
generatedResultsPromiseIds: Set<bigint>;
|
|
8
|
-
imports: CodeGeneratorRequest_RequestedFile_Import[];
|
|
9
|
-
nodes: Node[];
|
|
10
|
-
req: CodeGeneratorRequest;
|
|
11
|
-
statements: ts.Statement[];
|
|
12
10
|
tsPath: string;
|
|
11
|
+
codeParts?: string[];
|
|
13
12
|
constructor: (req: CodeGeneratorRequest, file: CodeGeneratorRequest_RequestedFile) => any;
|
|
14
13
|
toString: () => string;
|
|
15
14
|
}
|
|
16
|
-
|
|
15
|
+
interface CodeGeneratorContext {
|
|
17
16
|
files: CodeGeneratorFileContext[];
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
ts
|
|
21
|
-
js
|
|
22
|
-
dts
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
interface CapnpcCLIOptions {
|
|
19
|
+
ts: boolean;
|
|
20
|
+
js: boolean;
|
|
21
|
+
dts: boolean;
|
|
22
|
+
sourcePath: string[];
|
|
23
|
+
outputPath: string;
|
|
24
|
+
importPath: string[];
|
|
25
|
+
tsconfigPath: string;
|
|
26
|
+
generateId: boolean;
|
|
27
|
+
standardImport: boolean;
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
type CapnpcOptions = Omit<CapnpcCLIOptions, "tsconfigPath"> & {
|
|
30
|
+
tsconfig?: ts.ParsedCommandLine;
|
|
31
|
+
};
|
|
32
|
+
interface CapnpcResult {
|
|
28
33
|
ctx: CodeGeneratorContext;
|
|
29
34
|
files: Map<string, string>;
|
|
30
35
|
}
|
|
36
|
+
|
|
37
|
+
export type { CapnpcCLIOptions, CapnpcOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./chunk-OULCUN6I.js";
|