@stryke/capnp 0.2.6 → 0.3.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/dist/bin/capnpc.cjs +11269 -0
- package/dist/bin/capnpc.d.cts +6 -0
- package/dist/bin/capnpc.d.ts +6 -0
- package/dist/bin/capnpc.js +11266 -0
- package/dist/chunk-E5KOPL7Q.cjs +6 -0
- package/dist/chunk-EK5N4FAF.js +55 -0
- package/dist/chunk-IWTVA3JL.cjs +104 -0
- package/dist/chunk-QKE2ND5U.js +104 -0
- package/dist/chunk-TE2KW23K.cjs +55 -0
- package/dist/chunk-UQ2KKHLM.js +6 -0
- package/dist/src/compile.cjs +7 -0
- package/dist/src/compile.d.cts +7 -0
- package/dist/src/compile.d.ts +7 -0
- package/dist/src/compile.js +7 -0
- package/dist/src/index.cjs +13 -0
- package/dist/src/index.d.cts +4 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +13 -0
- package/dist/src/types.cjs +2 -0
- package/dist/src/types.d.cts +37 -0
- package/dist/src/types.d.ts +37 -0
- package/dist/src/types.js +2 -0
- package/package.json +47 -49
- package/dist/compile.cjs +0 -67
- package/dist/compile.d.ts +0 -2
- package/dist/compile.mjs +0 -1
- package/dist/index.cjs +0 -27
- package/dist/index.d.ts +0 -10
- package/dist/index.mjs +0 -1
- package/dist/types.cjs +0 -1
- package/dist/types.d.ts +0 -30
- package/dist/types.mjs +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
34
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
35
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
36
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.23__@swc+core@1.11.9_@swc+_19c55e6731afe9a981cc7f7992b35303/node_modules/tsup/assets/esm_shims.js
|
|
42
|
+
var init_esm_shims = __esm({
|
|
43
|
+
"../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.23__@swc+core@1.11.9_@swc+_19c55e6731afe9a981cc7f7992b35303/node_modules/tsup/assets/esm_shims.js"() {
|
|
44
|
+
"use strict";
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
__name,
|
|
50
|
+
__require,
|
|
51
|
+
__commonJS,
|
|
52
|
+
__export,
|
|
53
|
+
__toESM,
|
|
54
|
+
init_esm_shims
|
|
55
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkTE2KW23Kcjs = require('./chunk-TE2KW23K.cjs');
|
|
5
|
+
|
|
6
|
+
// src/compile.ts
|
|
7
|
+
_chunkTE2KW23Kcjs.init_cjs_shims.call(void 0, );
|
|
8
|
+
var _helpers = require('@stryke/fs/helpers');
|
|
9
|
+
var _writefile = require('@stryke/fs/write-file');
|
|
10
|
+
var _filepathfns = require('@stryke/path/file-path-fns');
|
|
11
|
+
var _joinpaths = require('@stryke/path/join-paths');
|
|
12
|
+
var _compiler = require('capnp-es/compiler');
|
|
13
|
+
var _buffer = require('buffer');
|
|
14
|
+
var _child_process = require('child_process');
|
|
15
|
+
var _fs = require('fs');
|
|
16
|
+
async function readStdin() {
|
|
17
|
+
if (process.stdin.isTTY) {
|
|
18
|
+
return _buffer.Buffer.alloc(0);
|
|
19
|
+
}
|
|
20
|
+
const chunks = [];
|
|
21
|
+
process.stdin.on("data", (chunk) => {
|
|
22
|
+
chunks.push(chunk);
|
|
23
|
+
});
|
|
24
|
+
await new Promise((resolve) => {
|
|
25
|
+
process.stdin.on("end", resolve);
|
|
26
|
+
});
|
|
27
|
+
const reqBuffer = _buffer.Buffer.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
|
|
28
|
+
let i = 0;
|
|
29
|
+
for (const chunk of chunks) {
|
|
30
|
+
chunk.copy(reqBuffer, i);
|
|
31
|
+
i += chunk.byteLength;
|
|
32
|
+
}
|
|
33
|
+
return reqBuffer;
|
|
34
|
+
}
|
|
35
|
+
_chunkTE2KW23Kcjs.__name.call(void 0, readStdin, "readStdin");
|
|
36
|
+
async function capnpc(options) {
|
|
37
|
+
try {
|
|
38
|
+
const { outputPath, tsconfig, sourcePath = [] } = options;
|
|
39
|
+
let dataBuf = await readStdin();
|
|
40
|
+
if (dataBuf.byteLength === 0) {
|
|
41
|
+
const opts = [];
|
|
42
|
+
if (outputPath) {
|
|
43
|
+
opts.push(`-o-:${outputPath}`);
|
|
44
|
+
} else {
|
|
45
|
+
opts.push("-o-");
|
|
46
|
+
}
|
|
47
|
+
dataBuf = await new Promise((resolve) => {
|
|
48
|
+
_child_process.exec.call(void 0, `capnpc ${opts.join(" ")} ${sourcePath.join(" ")}`, {
|
|
49
|
+
encoding: "buffer"
|
|
50
|
+
}, (error, stdout, stderr) => {
|
|
51
|
+
if (stderr.length > 0) {
|
|
52
|
+
process.stderr.write(stderr);
|
|
53
|
+
}
|
|
54
|
+
if (error) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
resolve(stdout);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const result = await _compiler.compileAll.call(void 0, dataBuf, {
|
|
62
|
+
ts: _nullishCoalesce(options.ts, () => ( true)),
|
|
63
|
+
js: _nullishCoalesce(options.js, () => ( false)),
|
|
64
|
+
dts: _nullishCoalesce(options.dts, () => ( true)),
|
|
65
|
+
tsconfig: _optionalChain([tsconfig, 'optionalAccess', _ => _.options])
|
|
66
|
+
});
|
|
67
|
+
for (const [fileName, content] of result.files) {
|
|
68
|
+
let filePath = fileName;
|
|
69
|
+
if (!_fs.existsSync.call(void 0, _filepathfns.findFilePath.call(void 0, filePath))) {
|
|
70
|
+
const fullPath = `/${filePath}`;
|
|
71
|
+
if (_fs.existsSync.call(void 0, _filepathfns.findFilePath.call(void 0, fullPath))) {
|
|
72
|
+
filePath = fullPath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (outputPath) {
|
|
76
|
+
filePath = _joinpaths.joinPaths.call(void 0, outputPath, fileName);
|
|
77
|
+
}
|
|
78
|
+
if (!_fs.existsSync.call(void 0, _filepathfns.findFilePath.call(void 0, filePath))) {
|
|
79
|
+
await _helpers.createDirectory.call(void 0, _filepathfns.findFilePath.call(void 0, filePath));
|
|
80
|
+
}
|
|
81
|
+
await _writefile.writeFile.call(void 0,
|
|
82
|
+
filePath,
|
|
83
|
+
// https://github.com/microsoft/TypeScript/issues/54632
|
|
84
|
+
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error instanceof Error) {
|
|
90
|
+
console.error(`Error: ${error.message}`);
|
|
91
|
+
if (error.stack) {
|
|
92
|
+
console.error(error.stack);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
console.error("An unknown error occurred:", error);
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_chunkTE2KW23Kcjs.__name.call(void 0, capnpc, "capnpc");
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
exports.capnpc = capnpc;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name,
|
|
3
|
+
init_esm_shims
|
|
4
|
+
} from "./chunk-EK5N4FAF.js";
|
|
5
|
+
|
|
6
|
+
// src/compile.ts
|
|
7
|
+
init_esm_shims();
|
|
8
|
+
import { createDirectory } from "@stryke/fs/helpers";
|
|
9
|
+
import { writeFile } from "@stryke/fs/write-file";
|
|
10
|
+
import { findFilePath } from "@stryke/path/file-path-fns";
|
|
11
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
12
|
+
import { compileAll } from "capnp-es/compiler";
|
|
13
|
+
import { Buffer } from "node:buffer";
|
|
14
|
+
import { exec } from "node:child_process";
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
async function readStdin() {
|
|
17
|
+
if (process.stdin.isTTY) {
|
|
18
|
+
return Buffer.alloc(0);
|
|
19
|
+
}
|
|
20
|
+
const chunks = [];
|
|
21
|
+
process.stdin.on("data", (chunk) => {
|
|
22
|
+
chunks.push(chunk);
|
|
23
|
+
});
|
|
24
|
+
await new Promise((resolve) => {
|
|
25
|
+
process.stdin.on("end", resolve);
|
|
26
|
+
});
|
|
27
|
+
const reqBuffer = Buffer.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
|
|
28
|
+
let i = 0;
|
|
29
|
+
for (const chunk of chunks) {
|
|
30
|
+
chunk.copy(reqBuffer, i);
|
|
31
|
+
i += chunk.byteLength;
|
|
32
|
+
}
|
|
33
|
+
return reqBuffer;
|
|
34
|
+
}
|
|
35
|
+
__name(readStdin, "readStdin");
|
|
36
|
+
async function capnpc(options) {
|
|
37
|
+
try {
|
|
38
|
+
const { outputPath, tsconfig, sourcePath = [] } = options;
|
|
39
|
+
let dataBuf = await readStdin();
|
|
40
|
+
if (dataBuf.byteLength === 0) {
|
|
41
|
+
const opts = [];
|
|
42
|
+
if (outputPath) {
|
|
43
|
+
opts.push(`-o-:${outputPath}`);
|
|
44
|
+
} else {
|
|
45
|
+
opts.push("-o-");
|
|
46
|
+
}
|
|
47
|
+
dataBuf = await new Promise((resolve) => {
|
|
48
|
+
exec(`capnpc ${opts.join(" ")} ${sourcePath.join(" ")}`, {
|
|
49
|
+
encoding: "buffer"
|
|
50
|
+
}, (error, stdout, stderr) => {
|
|
51
|
+
if (stderr.length > 0) {
|
|
52
|
+
process.stderr.write(stderr);
|
|
53
|
+
}
|
|
54
|
+
if (error) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
resolve(stdout);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const result = await compileAll(dataBuf, {
|
|
62
|
+
ts: options.ts ?? true,
|
|
63
|
+
js: options.js ?? false,
|
|
64
|
+
dts: options.dts ?? true,
|
|
65
|
+
tsconfig: tsconfig?.options
|
|
66
|
+
});
|
|
67
|
+
for (const [fileName, content] of result.files) {
|
|
68
|
+
let filePath = fileName;
|
|
69
|
+
if (!existsSync(findFilePath(filePath))) {
|
|
70
|
+
const fullPath = `/${filePath}`;
|
|
71
|
+
if (existsSync(findFilePath(fullPath))) {
|
|
72
|
+
filePath = fullPath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (outputPath) {
|
|
76
|
+
filePath = joinPaths(outputPath, fileName);
|
|
77
|
+
}
|
|
78
|
+
if (!existsSync(findFilePath(filePath))) {
|
|
79
|
+
await createDirectory(findFilePath(filePath));
|
|
80
|
+
}
|
|
81
|
+
await writeFile(
|
|
82
|
+
filePath,
|
|
83
|
+
// https://github.com/microsoft/TypeScript/issues/54632
|
|
84
|
+
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error instanceof Error) {
|
|
90
|
+
console.error(`Error: ${error.message}`);
|
|
91
|
+
if (error.stack) {
|
|
92
|
+
console.error(error.stack);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
console.error("An unknown error occurred:", error);
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
__name(capnpc, "capnpc");
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
capnpc
|
|
104
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
20
|
+
var __export = (target, all) => {
|
|
21
|
+
for (var name in all)
|
|
22
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
34
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
35
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
36
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
// ../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.23__@swc+core@1.11.9_@swc+_19c55e6731afe9a981cc7f7992b35303/node_modules/tsup/assets/cjs_shims.js
|
|
42
|
+
var init_cjs_shims = __esm({
|
|
43
|
+
"../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.8_@types+node@22.15.23__@swc+core@1.11.9_@swc+_19c55e6731afe9a981cc7f7992b35303/node_modules/tsup/assets/cjs_shims.js"() {
|
|
44
|
+
"use strict";
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
exports.__name = __name; exports.__require = __require; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM; exports.init_cjs_shims = init_cjs_shims;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkIWTVA3JLcjs = require('../chunk-IWTVA3JL.cjs');
|
|
4
|
+
require('../chunk-E5KOPL7Q.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkTE2KW23Kcjs = require('../chunk-TE2KW23K.cjs');
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
_chunkTE2KW23Kcjs.init_cjs_shims.call(void 0, );
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.capnpc = _chunkIWTVA3JLcjs.capnpc;
|
|
@@ -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 };
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/capnp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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": {
|
|
@@ -8,37 +8,11 @@
|
|
|
8
8
|
"url": "https://github.com/storm-software/stryke",
|
|
9
9
|
"directory": "packages/capnp"
|
|
10
10
|
},
|
|
11
|
-
"private": false,
|
|
12
|
-
"keywords": [
|
|
13
|
-
"capnp",
|
|
14
|
-
"capnproto",
|
|
15
|
-
"serialization",
|
|
16
|
-
"protocol",
|
|
17
|
-
"compiler",
|
|
18
|
-
"storm-software",
|
|
19
|
-
"stryke"
|
|
20
|
-
],
|
|
21
|
-
"peerDependencies": { "typescript": ">=4.0.0" },
|
|
22
|
-
"peerDependenciesMeta": { "typescript": { "optional": false } },
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@stryke/fs": "^0.20.5",
|
|
25
|
-
"@stryke/path": "^0.7.5",
|
|
26
|
-
"capnp-es": "^0.0.9"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": { "@types/node": "^22.14.0" },
|
|
29
|
-
"publishConfig": { "access": "public" },
|
|
30
|
-
"sideEffects": false,
|
|
31
|
-
"files": ["dist/**/*"],
|
|
32
11
|
"homepage": "https://stormsoftware.com",
|
|
33
12
|
"bugs": {
|
|
34
13
|
"url": "https://stormsoftware.com/support",
|
|
35
14
|
"email": "support@stormsoftware.com"
|
|
36
15
|
},
|
|
37
|
-
"license": "Apache-2.0",
|
|
38
|
-
"funding": {
|
|
39
|
-
"type": "github",
|
|
40
|
-
"url": "https://github.com/sponsors/storm-software"
|
|
41
|
-
},
|
|
42
16
|
"author": {
|
|
43
17
|
"name": "Storm Software",
|
|
44
18
|
"email": "contact@stormsoftware.com",
|
|
@@ -58,48 +32,72 @@
|
|
|
58
32
|
"url": "https://stormsoftware.com"
|
|
59
33
|
}
|
|
60
34
|
],
|
|
35
|
+
"funding": {
|
|
36
|
+
"type": "github",
|
|
37
|
+
"url": "https://github.com/sponsors/storm-software"
|
|
38
|
+
},
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"private": false,
|
|
41
|
+
"bin": { "storm-capnpc": "dist/capnpc.js" },
|
|
42
|
+
"main": "./dist/index.cjs",
|
|
43
|
+
"module": "./dist/index.js",
|
|
61
44
|
"exports": {
|
|
62
|
-
"
|
|
63
|
-
"import": { "types": "./dist/
|
|
45
|
+
".": {
|
|
46
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
64
47
|
"require": {
|
|
65
|
-
"types": "./dist/
|
|
66
|
-
"default": "./dist/
|
|
48
|
+
"types": "./dist/index.d.cts",
|
|
49
|
+
"default": "./dist/index.cjs"
|
|
67
50
|
},
|
|
68
|
-
"default": { "types": "./dist/
|
|
51
|
+
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }
|
|
69
52
|
},
|
|
70
53
|
"./index": {
|
|
71
|
-
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.
|
|
54
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
72
55
|
"require": {
|
|
73
|
-
"types": "./dist/index.d.
|
|
56
|
+
"types": "./dist/index.d.cts",
|
|
74
57
|
"default": "./dist/index.cjs"
|
|
75
58
|
},
|
|
76
|
-
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.
|
|
59
|
+
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }
|
|
77
60
|
},
|
|
78
61
|
"./compile": {
|
|
79
62
|
"import": {
|
|
80
63
|
"types": "./dist/compile.d.ts",
|
|
81
|
-
"default": "./dist/compile.
|
|
64
|
+
"default": "./dist/compile.js"
|
|
82
65
|
},
|
|
83
66
|
"require": {
|
|
84
|
-
"types": "./dist/compile.d.
|
|
67
|
+
"types": "./dist/compile.d.cts",
|
|
85
68
|
"default": "./dist/compile.cjs"
|
|
86
69
|
},
|
|
87
70
|
"default": {
|
|
88
71
|
"types": "./dist/compile.d.ts",
|
|
89
|
-
"default": "./dist/compile.
|
|
72
|
+
"default": "./dist/compile.js"
|
|
90
73
|
}
|
|
91
74
|
},
|
|
92
|
-
".": {
|
|
93
|
-
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
|
|
94
|
-
"require": {
|
|
95
|
-
"types": "./dist/index.d.ts",
|
|
96
|
-
"default": "./dist/index.cjs"
|
|
97
|
-
},
|
|
98
|
-
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
|
|
99
|
-
},
|
|
100
75
|
"./package.json": "./package.json"
|
|
101
76
|
},
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
77
|
+
"types": "./dist/index.d.ts",
|
|
78
|
+
"files": ["dist/**/*"],
|
|
79
|
+
"keywords": [
|
|
80
|
+
"capnp",
|
|
81
|
+
"capnproto",
|
|
82
|
+
"serialization",
|
|
83
|
+
"protocol",
|
|
84
|
+
"compiler",
|
|
85
|
+
"storm-software",
|
|
86
|
+
"stryke"
|
|
87
|
+
],
|
|
88
|
+
"peerDependencies": { "typescript": ">=4.0.0" },
|
|
89
|
+
"peerDependenciesMeta": { "typescript": { "optional": false } },
|
|
90
|
+
"dependencies": {
|
|
91
|
+
"@stryke/fs": "^0.20.6",
|
|
92
|
+
"@stryke/path": "^0.7.5",
|
|
93
|
+
"capnp-es": "^0.0.11"
|
|
94
|
+
},
|
|
95
|
+
"devDependencies": {
|
|
96
|
+
"@storm-software/config": "latest",
|
|
97
|
+
"@storm-software/config-tools": "latest",
|
|
98
|
+
"@types/node": "^22.14.0",
|
|
99
|
+
"chalk": "^5.4.1",
|
|
100
|
+
"commander": "^14.0.0"
|
|
101
|
+
},
|
|
102
|
+
"publishConfig": { "access": "public" }
|
|
105
103
|
}
|