@stryke/capnp 0.10.0 → 0.10.1
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 +62 -30
- package/bin/capnpc.js +62 -30
- package/dist/compile.cjs +4 -2
- package/dist/compile.d.cts +3 -3
- package/dist/compile.d.ts +3 -3
- package/dist/compile.js +4 -2
- package/dist/helpers.cjs +41 -23
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.js +40 -22
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.cts +13 -4
- package/dist/types.d.ts +13 -4
- package/dts/index.d.cts +14 -5
- package/dts/index.d.ts +14 -5
- package/package.json +4 -4
- package/schemas/persistent.cjs +20 -20
- package/schemas/persistent.js +1 -1
- package/schemas/rpc-twoparty.cjs +32 -32
- package/schemas/rpc-twoparty.js +1 -1
- package/schemas/rpc.cjs +495 -495
- package/schemas/rpc.js +1 -1
- package/schemas/schema.cjs +675 -675
- package/schemas/schema.js +1 -1
- /package/schemas/{chunk-ZGPCLBI4.cjs → chunk-BM2HWFSD.cjs} +0 -0
- /package/schemas/{chunk-3CJYH45H.js → chunk-TAKPBFYZ.js} +0 -0
package/bin/capnpc.cjs
CHANGED
|
@@ -7297,6 +7297,15 @@ var import_node_child_process = require("child_process");
|
|
|
7297
7297
|
// src/helpers.ts
|
|
7298
7298
|
var import_console = require("@storm-software/config-tools/logger/console");
|
|
7299
7299
|
|
|
7300
|
+
// ../convert/src/to-array.ts
|
|
7301
|
+
function toArray(array) {
|
|
7302
|
+
array = array ?? [];
|
|
7303
|
+
return Array.isArray(array) ? array : [
|
|
7304
|
+
array
|
|
7305
|
+
];
|
|
7306
|
+
}
|
|
7307
|
+
__name(toArray, "toArray");
|
|
7308
|
+
|
|
7300
7309
|
// ../type-checks/src/get-object-tag.ts
|
|
7301
7310
|
var getObjectTag = /* @__PURE__ */ __name((value) => {
|
|
7302
7311
|
if (value == null) {
|
|
@@ -7918,41 +7927,58 @@ __name(listFiles, "listFiles");
|
|
|
7918
7927
|
// src/helpers.ts
|
|
7919
7928
|
var import_typescript3 = require("typescript");
|
|
7920
7929
|
async function resolveOptions(options) {
|
|
7921
|
-
const tsconfigPath = options.
|
|
7922
|
-
const
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7930
|
+
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
7931
|
+
const schemas = toArray(options.schemas ? Array.isArray(options.schemas) ? options.schemas.map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)) : options.schemas : joinPaths(options.projectRoot, "schemas/**/*.capnp"));
|
|
7932
|
+
let resolvedTsconfig;
|
|
7933
|
+
if (options.tsconfig) {
|
|
7934
|
+
resolvedTsconfig = options.tsconfig;
|
|
7935
|
+
} else {
|
|
7936
|
+
if (!tsconfigPath || !existsSync(tsconfigPath)) {
|
|
7937
|
+
const errorMessage = tsconfigPath ? `\u2716 The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "\u2716 The specified TypeScript configuration file does not exist. Please provide a valid path.";
|
|
7938
|
+
(0, import_console.writeFatal)(errorMessage, {
|
|
7939
|
+
logLevel: "all"
|
|
7940
|
+
});
|
|
7941
|
+
throw new Error(errorMessage);
|
|
7942
|
+
}
|
|
7943
|
+
const tsconfigFile = await readJsonFile(tsconfigPath);
|
|
7944
|
+
resolvedTsconfig = (0, import_typescript3.parseJsonConfigFileContent)(tsconfigFile, import_typescript3.sys, findFilePath(tsconfigPath));
|
|
7945
|
+
if (!resolvedTsconfig) {
|
|
7946
|
+
const errorMessage = `\u2716 The specified TypeScript configuration file "${tsconfigPath}" is invalid. Please provide a valid configuration.`;
|
|
7947
|
+
(0, import_console.writeFatal)(errorMessage, {
|
|
7948
|
+
logLevel: "all"
|
|
7949
|
+
});
|
|
7950
|
+
throw new Error(errorMessage);
|
|
7951
|
+
}
|
|
7952
|
+
resolvedTsconfig.options.configFilePath = tsconfigPath;
|
|
7953
|
+
resolvedTsconfig.options.noImplicitOverride = false;
|
|
7954
|
+
resolvedTsconfig.options.noUnusedLocals = false;
|
|
7955
|
+
resolvedTsconfig.options.noUnusedParameters = false;
|
|
7956
|
+
}
|
|
7957
|
+
const resolvedSchemas = [];
|
|
7958
|
+
for (const schema of schemas) {
|
|
7959
|
+
if (!schema || !schema.includes("*") && !existsSync(schema)) {
|
|
7960
|
+
if (schemas.length <= 1) {
|
|
7961
|
+
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
7962
|
+
}
|
|
7963
|
+
} else {
|
|
7964
|
+
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
7943
7968
|
(0, import_console.writeWarning)(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
7944
7969
|
logLevel: "all"
|
|
7945
7970
|
});
|
|
7946
7971
|
return null;
|
|
7947
7972
|
}
|
|
7973
|
+
resolvedTsconfig.options.outDir = joinPaths(options.projectRoot, relativePath(tsconfigPath ? findFilePath(tsconfigPath) : options.projectRoot, joinPaths(options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? findFilePath(resolvedSchemas[0]) : resolvedSchemas[0])));
|
|
7948
7974
|
return {
|
|
7949
7975
|
workspaceRoot: options.workspaceRoot,
|
|
7950
7976
|
projectRoot: options.projectRoot,
|
|
7951
|
-
schemas,
|
|
7977
|
+
schemas: resolvedSchemas,
|
|
7952
7978
|
js: options.js ?? false,
|
|
7953
7979
|
ts: options.ts ?? (options.noTs !== void 0 ? !options.noTs : true),
|
|
7954
7980
|
dts: options.dts ?? (options.noDts !== void 0 ? !options.noDts : true),
|
|
7955
|
-
tsconfig:
|
|
7981
|
+
tsconfig: resolvedTsconfig
|
|
7956
7982
|
};
|
|
7957
7983
|
}
|
|
7958
7984
|
__name(resolveOptions, "resolveOptions");
|
|
@@ -8002,7 +8028,7 @@ async function capnpc(options) {
|
|
|
8002
8028
|
ts: options.ts ?? true,
|
|
8003
8029
|
js: false,
|
|
8004
8030
|
dts: false,
|
|
8005
|
-
tsconfig
|
|
8031
|
+
tsconfig: tsconfig.options
|
|
8006
8032
|
});
|
|
8007
8033
|
}
|
|
8008
8034
|
__name(capnpc, "capnpc");
|
|
@@ -8048,24 +8074,30 @@ function createProgram() {
|
|
|
8048
8074
|
}
|
|
8049
8075
|
__name(createProgram, "createProgram");
|
|
8050
8076
|
async function compileAction(options) {
|
|
8051
|
-
const resolvedOptions = await resolveOptions(
|
|
8077
|
+
const resolvedOptions = await resolveOptions({
|
|
8078
|
+
...options,
|
|
8079
|
+
projectRoot: options.projectRoot,
|
|
8080
|
+
tsconfig: void 0,
|
|
8081
|
+
tsconfigPath: options.tsconfig || joinPaths(options.projectRoot, "tsconfig.json"),
|
|
8082
|
+
schemas: options.schema
|
|
8083
|
+
});
|
|
8052
8084
|
if (!resolvedOptions) {
|
|
8053
8085
|
(0, import_console3.writeWarning)("\u2716 Unable to resolve Cap'n Proto compiler options - the program will terminate", {
|
|
8054
8086
|
logLevel: "all"
|
|
8055
8087
|
});
|
|
8056
8088
|
return;
|
|
8057
8089
|
}
|
|
8058
|
-
(0, import_console3.writeInfo)(`\u{1F4E6}
|
|
8090
|
+
(0, import_console3.writeInfo)(`\u{1F4E6} Storm Cap'n Proto Compiler will output ${resolvedOptions.ts ? "TypeScript code" : ""}${resolvedOptions.js ? resolvedOptions.ts ? ", JavaScript code" : "JavaScript code" : ""}${resolvedOptions.dts ? resolvedOptions.ts || resolvedOptions.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${options.schema ? options.schema.replace("{projectRoot}", resolvedOptions.projectRoot).replace("{workspaceRoot}", resolvedOptions.workspaceRoot) : resolvedOptions.projectRoot} to ${resolvedOptions.tsconfig.options.outDir}...`, {
|
|
8059
8091
|
logLevel: "all"
|
|
8060
8092
|
});
|
|
8061
8093
|
const result = await capnpc(resolvedOptions);
|
|
8062
8094
|
if (result.files.size === 0) {
|
|
8063
|
-
(0, import_console3.writeWarning)("\u26A0\uFE0F
|
|
8095
|
+
(0, import_console3.writeWarning)("\u26A0\uFE0F No files were generated. Please check your schema files.", {
|
|
8064
8096
|
logLevel: "all"
|
|
8065
8097
|
});
|
|
8066
8098
|
return;
|
|
8067
8099
|
}
|
|
8068
|
-
(0, import_console3.writeInfo)(
|
|
8100
|
+
(0, import_console3.writeInfo)(`\u{1F4CB} Writing ${result.files.size} generated files to disk...`, {
|
|
8069
8101
|
logLevel: "all"
|
|
8070
8102
|
});
|
|
8071
8103
|
for (const [fileName, content] of result.files) {
|
|
@@ -8088,7 +8120,7 @@ async function compileAction(options) {
|
|
|
8088
8120
|
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
8089
8121
|
);
|
|
8090
8122
|
}
|
|
8091
|
-
(0, import_console3.writeSuccess)("\u26A1
|
|
8123
|
+
(0, import_console3.writeSuccess)("\u26A1 Storm Cap'n Proto Compiler completed successfully.", {
|
|
8092
8124
|
logLevel: "all"
|
|
8093
8125
|
});
|
|
8094
8126
|
}
|
package/bin/capnpc.js
CHANGED
|
@@ -7266,6 +7266,15 @@ import { exec } from "node:child_process";
|
|
|
7266
7266
|
// src/helpers.ts
|
|
7267
7267
|
import { writeFatal, writeWarning } from "@storm-software/config-tools/logger/console";
|
|
7268
7268
|
|
|
7269
|
+
// ../convert/src/to-array.ts
|
|
7270
|
+
function toArray(array) {
|
|
7271
|
+
array = array ?? [];
|
|
7272
|
+
return Array.isArray(array) ? array : [
|
|
7273
|
+
array
|
|
7274
|
+
];
|
|
7275
|
+
}
|
|
7276
|
+
__name(toArray, "toArray");
|
|
7277
|
+
|
|
7269
7278
|
// ../type-checks/src/get-object-tag.ts
|
|
7270
7279
|
var getObjectTag = /* @__PURE__ */ __name((value) => {
|
|
7271
7280
|
if (value == null) {
|
|
@@ -7887,41 +7896,58 @@ __name(listFiles, "listFiles");
|
|
|
7887
7896
|
// src/helpers.ts
|
|
7888
7897
|
import { parseJsonConfigFileContent, sys } from "typescript";
|
|
7889
7898
|
async function resolveOptions(options) {
|
|
7890
|
-
const tsconfigPath = options.
|
|
7891
|
-
const
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7899
|
+
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
7900
|
+
const schemas = toArray(options.schemas ? Array.isArray(options.schemas) ? options.schemas.map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)) : options.schemas : joinPaths(options.projectRoot, "schemas/**/*.capnp"));
|
|
7901
|
+
let resolvedTsconfig;
|
|
7902
|
+
if (options.tsconfig) {
|
|
7903
|
+
resolvedTsconfig = options.tsconfig;
|
|
7904
|
+
} else {
|
|
7905
|
+
if (!tsconfigPath || !existsSync(tsconfigPath)) {
|
|
7906
|
+
const errorMessage = tsconfigPath ? `\u2716 The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "\u2716 The specified TypeScript configuration file does not exist. Please provide a valid path.";
|
|
7907
|
+
writeFatal(errorMessage, {
|
|
7908
|
+
logLevel: "all"
|
|
7909
|
+
});
|
|
7910
|
+
throw new Error(errorMessage);
|
|
7911
|
+
}
|
|
7912
|
+
const tsconfigFile = await readJsonFile(tsconfigPath);
|
|
7913
|
+
resolvedTsconfig = parseJsonConfigFileContent(tsconfigFile, sys, findFilePath(tsconfigPath));
|
|
7914
|
+
if (!resolvedTsconfig) {
|
|
7915
|
+
const errorMessage = `\u2716 The specified TypeScript configuration file "${tsconfigPath}" is invalid. Please provide a valid configuration.`;
|
|
7916
|
+
writeFatal(errorMessage, {
|
|
7917
|
+
logLevel: "all"
|
|
7918
|
+
});
|
|
7919
|
+
throw new Error(errorMessage);
|
|
7920
|
+
}
|
|
7921
|
+
resolvedTsconfig.options.configFilePath = tsconfigPath;
|
|
7922
|
+
resolvedTsconfig.options.noImplicitOverride = false;
|
|
7923
|
+
resolvedTsconfig.options.noUnusedLocals = false;
|
|
7924
|
+
resolvedTsconfig.options.noUnusedParameters = false;
|
|
7925
|
+
}
|
|
7926
|
+
const resolvedSchemas = [];
|
|
7927
|
+
for (const schema of schemas) {
|
|
7928
|
+
if (!schema || !schema.includes("*") && !existsSync(schema)) {
|
|
7929
|
+
if (schemas.length <= 1) {
|
|
7930
|
+
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
7931
|
+
}
|
|
7932
|
+
} else {
|
|
7933
|
+
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
7934
|
+
}
|
|
7935
|
+
}
|
|
7936
|
+
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
7912
7937
|
writeWarning(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
7913
7938
|
logLevel: "all"
|
|
7914
7939
|
});
|
|
7915
7940
|
return null;
|
|
7916
7941
|
}
|
|
7942
|
+
resolvedTsconfig.options.outDir = joinPaths(options.projectRoot, relativePath(tsconfigPath ? findFilePath(tsconfigPath) : options.projectRoot, joinPaths(options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? findFilePath(resolvedSchemas[0]) : resolvedSchemas[0])));
|
|
7917
7943
|
return {
|
|
7918
7944
|
workspaceRoot: options.workspaceRoot,
|
|
7919
7945
|
projectRoot: options.projectRoot,
|
|
7920
|
-
schemas,
|
|
7946
|
+
schemas: resolvedSchemas,
|
|
7921
7947
|
js: options.js ?? false,
|
|
7922
7948
|
ts: options.ts ?? (options.noTs !== void 0 ? !options.noTs : true),
|
|
7923
7949
|
dts: options.dts ?? (options.noDts !== void 0 ? !options.noDts : true),
|
|
7924
|
-
tsconfig:
|
|
7950
|
+
tsconfig: resolvedTsconfig
|
|
7925
7951
|
};
|
|
7926
7952
|
}
|
|
7927
7953
|
__name(resolveOptions, "resolveOptions");
|
|
@@ -7971,7 +7997,7 @@ async function capnpc(options) {
|
|
|
7971
7997
|
ts: options.ts ?? true,
|
|
7972
7998
|
js: false,
|
|
7973
7999
|
dts: false,
|
|
7974
|
-
tsconfig
|
|
8000
|
+
tsconfig: tsconfig.options
|
|
7975
8001
|
});
|
|
7976
8002
|
}
|
|
7977
8003
|
__name(capnpc, "capnpc");
|
|
@@ -8017,24 +8043,30 @@ function createProgram() {
|
|
|
8017
8043
|
}
|
|
8018
8044
|
__name(createProgram, "createProgram");
|
|
8019
8045
|
async function compileAction(options) {
|
|
8020
|
-
const resolvedOptions = await resolveOptions(
|
|
8046
|
+
const resolvedOptions = await resolveOptions({
|
|
8047
|
+
...options,
|
|
8048
|
+
projectRoot: options.projectRoot,
|
|
8049
|
+
tsconfig: void 0,
|
|
8050
|
+
tsconfigPath: options.tsconfig || joinPaths(options.projectRoot, "tsconfig.json"),
|
|
8051
|
+
schemas: options.schema
|
|
8052
|
+
});
|
|
8021
8053
|
if (!resolvedOptions) {
|
|
8022
8054
|
writeWarning3("\u2716 Unable to resolve Cap'n Proto compiler options - the program will terminate", {
|
|
8023
8055
|
logLevel: "all"
|
|
8024
8056
|
});
|
|
8025
8057
|
return;
|
|
8026
8058
|
}
|
|
8027
|
-
writeInfo(`\u{1F4E6}
|
|
8059
|
+
writeInfo(`\u{1F4E6} Storm Cap'n Proto Compiler will output ${resolvedOptions.ts ? "TypeScript code" : ""}${resolvedOptions.js ? resolvedOptions.ts ? ", JavaScript code" : "JavaScript code" : ""}${resolvedOptions.dts ? resolvedOptions.ts || resolvedOptions.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${options.schema ? options.schema.replace("{projectRoot}", resolvedOptions.projectRoot).replace("{workspaceRoot}", resolvedOptions.workspaceRoot) : resolvedOptions.projectRoot} to ${resolvedOptions.tsconfig.options.outDir}...`, {
|
|
8028
8060
|
logLevel: "all"
|
|
8029
8061
|
});
|
|
8030
8062
|
const result = await capnpc(resolvedOptions);
|
|
8031
8063
|
if (result.files.size === 0) {
|
|
8032
|
-
writeWarning3("\u26A0\uFE0F
|
|
8064
|
+
writeWarning3("\u26A0\uFE0F No files were generated. Please check your schema files.", {
|
|
8033
8065
|
logLevel: "all"
|
|
8034
8066
|
});
|
|
8035
8067
|
return;
|
|
8036
8068
|
}
|
|
8037
|
-
writeInfo(
|
|
8069
|
+
writeInfo(`\u{1F4CB} Writing ${result.files.size} generated files to disk...`, {
|
|
8038
8070
|
logLevel: "all"
|
|
8039
8071
|
});
|
|
8040
8072
|
for (const [fileName, content] of result.files) {
|
|
@@ -8057,7 +8089,7 @@ async function compileAction(options) {
|
|
|
8057
8089
|
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
8058
8090
|
);
|
|
8059
8091
|
}
|
|
8060
|
-
writeSuccess("\u26A1
|
|
8092
|
+
writeSuccess("\u26A1 Storm Cap'n Proto Compiler completed successfully.", {
|
|
8061
8093
|
logLevel: "all"
|
|
8062
8094
|
});
|
|
8063
8095
|
}
|
package/dist/compile.cjs
CHANGED
|
@@ -51,7 +51,7 @@ async function capnpc(options) {
|
|
|
51
51
|
ts: _nullishCoalesce(options.ts, () => ( true)),
|
|
52
52
|
js: false,
|
|
53
53
|
dts: false,
|
|
54
|
-
tsconfig
|
|
54
|
+
tsconfig: tsconfig.options
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
_chunkUSNT2KNTcjs.__name.call(void 0, capnpc, "capnpc");
|
|
@@ -63,7 +63,9 @@ async function compile(dataBuf, options) {
|
|
|
63
63
|
});
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
return _compiler.compileAll.call(void 0, dataBuf, _defu2.default.call(void 0,
|
|
66
|
+
return _compiler.compileAll.call(void 0, dataBuf, _defu2.default.call(void 0, {
|
|
67
|
+
tsconfig: resolvedOptions.tsconfig.options
|
|
68
|
+
}, resolvedOptions, {
|
|
67
69
|
ts: true,
|
|
68
70
|
js: false,
|
|
69
71
|
dts: false
|
package/dist/compile.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as capnp_es_capnp_schema from 'capnp-es/capnp/schema';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
|
-
import {
|
|
3
|
+
import { CapnpcResolvedOptions, CapnpcResult, CapnpcOptions } from './types.cjs';
|
|
4
4
|
import 'typescript';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -9,7 +9,7 @@ import 'typescript';
|
|
|
9
9
|
* @param options - The options for the compilation process.
|
|
10
10
|
* @returns A promise that resolves to the compilation result.
|
|
11
11
|
*/
|
|
12
|
-
declare function capnpc(options:
|
|
12
|
+
declare function capnpc(options: CapnpcResolvedOptions): Promise<CapnpcResult>;
|
|
13
13
|
/**
|
|
14
14
|
* Compiles Cap'n Proto schemas into TypeScript files.
|
|
15
15
|
*
|
|
@@ -17,7 +17,7 @@ declare function capnpc(options: CapnpcOptions): Promise<CapnpcResult>;
|
|
|
17
17
|
* @param options - The options for the compilation process.
|
|
18
18
|
* @returns A promise that resolves to the compilation result.
|
|
19
19
|
*/
|
|
20
|
-
declare function compile(dataBuf: Buffer, options:
|
|
20
|
+
declare function compile(dataBuf: Buffer, options: CapnpcOptions): Promise<{
|
|
21
21
|
ctx: {
|
|
22
22
|
files: {
|
|
23
23
|
readonly req: capnp_es_capnp_schema.CodeGeneratorRequest;
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as capnp_es_capnp_schema from 'capnp-es/capnp/schema';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
|
-
import {
|
|
3
|
+
import { CapnpcResolvedOptions, CapnpcResult, CapnpcOptions } from './types.js';
|
|
4
4
|
import 'typescript';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -9,7 +9,7 @@ import 'typescript';
|
|
|
9
9
|
* @param options - The options for the compilation process.
|
|
10
10
|
* @returns A promise that resolves to the compilation result.
|
|
11
11
|
*/
|
|
12
|
-
declare function capnpc(options:
|
|
12
|
+
declare function capnpc(options: CapnpcResolvedOptions): Promise<CapnpcResult>;
|
|
13
13
|
/**
|
|
14
14
|
* Compiles Cap'n Proto schemas into TypeScript files.
|
|
15
15
|
*
|
|
@@ -17,7 +17,7 @@ declare function capnpc(options: CapnpcOptions): Promise<CapnpcResult>;
|
|
|
17
17
|
* @param options - The options for the compilation process.
|
|
18
18
|
* @returns A promise that resolves to the compilation result.
|
|
19
19
|
*/
|
|
20
|
-
declare function compile(dataBuf: Buffer, options:
|
|
20
|
+
declare function compile(dataBuf: Buffer, options: CapnpcOptions): Promise<{
|
|
21
21
|
ctx: {
|
|
22
22
|
files: {
|
|
23
23
|
readonly req: capnp_es_capnp_schema.CodeGeneratorRequest;
|
package/dist/compile.js
CHANGED
|
@@ -51,7 +51,7 @@ async function capnpc(options) {
|
|
|
51
51
|
ts: options.ts ?? true,
|
|
52
52
|
js: false,
|
|
53
53
|
dts: false,
|
|
54
|
-
tsconfig
|
|
54
|
+
tsconfig: tsconfig.options
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
__name(capnpc, "capnpc");
|
|
@@ -63,7 +63,9 @@ async function compile(dataBuf, options) {
|
|
|
63
63
|
});
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
return compileAll(dataBuf, defu(
|
|
66
|
+
return compileAll(dataBuf, defu({
|
|
67
|
+
tsconfig: resolvedOptions.tsconfig.options
|
|
68
|
+
}, resolvedOptions, {
|
|
67
69
|
ts: true,
|
|
68
70
|
js: false,
|
|
69
71
|
dts: false
|
package/dist/helpers.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
|
|
4
4
|
var _console = require('@storm-software/config-tools/logger/console');
|
|
5
|
+
var _toarray = require('@stryke/convert/to-array');
|
|
5
6
|
var _json = require('@stryke/fs/json');
|
|
6
7
|
var _listfiles = require('@stryke/fs/list-files');
|
|
7
8
|
var _exists = require('@stryke/path/exists');
|
|
@@ -9,41 +10,58 @@ var _filepathfns = require('@stryke/path/file-path-fns');
|
|
|
9
10
|
var _joinpaths = require('@stryke/path/join-paths');
|
|
10
11
|
var _typescript = require('typescript');
|
|
11
12
|
async function resolveOptions(options) {
|
|
12
|
-
const tsconfigPath =
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
14
|
+
const schemas = _toarray.toArray.call(void 0, options.schemas ? Array.isArray(options.schemas) ? options.schemas.map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)) : options.schemas : _joinpaths.joinPaths.call(void 0, options.projectRoot, "schemas/**/*.capnp"));
|
|
15
|
+
let resolvedTsconfig;
|
|
16
|
+
if (options.tsconfig) {
|
|
17
|
+
resolvedTsconfig = options.tsconfig;
|
|
18
|
+
} else {
|
|
19
|
+
if (!tsconfigPath || !_exists.existsSync.call(void 0, tsconfigPath)) {
|
|
20
|
+
const errorMessage = tsconfigPath ? `\u2716 The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "\u2716 The specified TypeScript configuration file does not exist. Please provide a valid path.";
|
|
21
|
+
_console.writeFatal.call(void 0, errorMessage, {
|
|
22
|
+
logLevel: "all"
|
|
23
|
+
});
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
26
|
+
const tsconfigFile = await _json.readJsonFile.call(void 0, tsconfigPath);
|
|
27
|
+
resolvedTsconfig = _typescript.parseJsonConfigFileContent.call(void 0, tsconfigFile, _typescript.sys, _filepathfns.findFilePath.call(void 0, tsconfigPath));
|
|
28
|
+
if (!resolvedTsconfig) {
|
|
29
|
+
const errorMessage = `\u2716 The specified TypeScript configuration file "${tsconfigPath}" is invalid. Please provide a valid configuration.`;
|
|
30
|
+
_console.writeFatal.call(void 0, errorMessage, {
|
|
31
|
+
logLevel: "all"
|
|
32
|
+
});
|
|
33
|
+
throw new Error(errorMessage);
|
|
34
|
+
}
|
|
35
|
+
resolvedTsconfig.options.configFilePath = tsconfigPath;
|
|
36
|
+
resolvedTsconfig.options.noImplicitOverride = false;
|
|
37
|
+
resolvedTsconfig.options.noUnusedLocals = false;
|
|
38
|
+
resolvedTsconfig.options.noUnusedParameters = false;
|
|
20
39
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
40
|
+
const resolvedSchemas = [];
|
|
41
|
+
for (const schema of schemas) {
|
|
42
|
+
if (!schema || !schema.includes("*") && !_exists.existsSync.call(void 0, schema)) {
|
|
43
|
+
if (schemas.length <= 1) {
|
|
44
|
+
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
resolvedSchemas.push(...await _listfiles.listFiles.call(void 0, schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : _joinpaths.joinPaths.call(void 0, schema, "**/*.capnp")));
|
|
48
|
+
}
|
|
31
49
|
}
|
|
32
|
-
|
|
33
|
-
if (schemas.length === 0) {
|
|
50
|
+
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
34
51
|
_console.writeWarning.call(void 0, `\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
35
52
|
logLevel: "all"
|
|
36
53
|
});
|
|
37
54
|
return null;
|
|
38
55
|
}
|
|
56
|
+
resolvedTsconfig.options.outDir = _joinpaths.joinPaths.call(void 0, options.projectRoot, _filepathfns.relativePath.call(void 0, tsconfigPath ? _filepathfns.findFilePath.call(void 0, tsconfigPath) : options.projectRoot, _joinpaths.joinPaths.call(void 0, options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? _filepathfns.findFilePath.call(void 0, resolvedSchemas[0]) : resolvedSchemas[0])));
|
|
39
57
|
return {
|
|
40
58
|
workspaceRoot: options.workspaceRoot,
|
|
41
59
|
projectRoot: options.projectRoot,
|
|
42
|
-
schemas,
|
|
60
|
+
schemas: resolvedSchemas,
|
|
43
61
|
js: _nullishCoalesce(options.js, () => ( false)),
|
|
44
62
|
ts: _nullishCoalesce(options.ts, () => ( (options.noTs !== void 0 ? !options.noTs : true))),
|
|
45
63
|
dts: _nullishCoalesce(options.dts, () => ( (options.noDts !== void 0 ? !options.noDts : true))),
|
|
46
|
-
tsconfig:
|
|
64
|
+
tsconfig: resolvedTsconfig
|
|
47
65
|
};
|
|
48
66
|
}
|
|
49
67
|
_chunkUSNT2KNTcjs.__name.call(void 0, resolveOptions, "resolveOptions");
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CapnpcOptions, CapnpcResolvedOptions } from './types.cjs';
|
|
2
2
|
import 'capnp-es/capnp/schema';
|
|
3
3
|
import 'typescript';
|
|
4
4
|
|
|
@@ -8,6 +8,6 @@ import 'typescript';
|
|
|
8
8
|
* @param options - The options to resolve
|
|
9
9
|
* @returns The resolved options
|
|
10
10
|
*/
|
|
11
|
-
declare function resolveOptions(options:
|
|
11
|
+
declare function resolveOptions(options: CapnpcOptions): Promise<CapnpcResolvedOptions | null>;
|
|
12
12
|
|
|
13
13
|
export { resolveOptions };
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CapnpcOptions, CapnpcResolvedOptions } from './types.js';
|
|
2
2
|
import 'capnp-es/capnp/schema';
|
|
3
3
|
import 'typescript';
|
|
4
4
|
|
|
@@ -8,6 +8,6 @@ import 'typescript';
|
|
|
8
8
|
* @param options - The options to resolve
|
|
9
9
|
* @returns The resolved options
|
|
10
10
|
*/
|
|
11
|
-
declare function resolveOptions(options:
|
|
11
|
+
declare function resolveOptions(options: CapnpcOptions): Promise<CapnpcResolvedOptions | null>;
|
|
12
12
|
|
|
13
13
|
export { resolveOptions };
|
package/dist/helpers.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
__name
|
|
3
3
|
} from "./chunk-SHUYVCID.js";
|
|
4
4
|
import { writeFatal, writeWarning } from "@storm-software/config-tools/logger/console";
|
|
5
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
5
6
|
import { readJsonFile } from "@stryke/fs/json";
|
|
6
7
|
import { listFiles } from "@stryke/fs/list-files";
|
|
7
8
|
import { existsSync } from "@stryke/path/exists";
|
|
@@ -9,41 +10,58 @@ import { findFilePath, relativePath } from "@stryke/path/file-path-fns";
|
|
|
9
10
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
10
11
|
import { parseJsonConfigFileContent, sys } from "typescript";
|
|
11
12
|
async function resolveOptions(options) {
|
|
12
|
-
const tsconfigPath = options.
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
14
|
+
const schemas = toArray(options.schemas ? Array.isArray(options.schemas) ? options.schemas.map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)) : options.schemas : joinPaths(options.projectRoot, "schemas/**/*.capnp"));
|
|
15
|
+
let resolvedTsconfig;
|
|
16
|
+
if (options.tsconfig) {
|
|
17
|
+
resolvedTsconfig = options.tsconfig;
|
|
18
|
+
} else {
|
|
19
|
+
if (!tsconfigPath || !existsSync(tsconfigPath)) {
|
|
20
|
+
const errorMessage = tsconfigPath ? `\u2716 The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "\u2716 The specified TypeScript configuration file does not exist. Please provide a valid path.";
|
|
21
|
+
writeFatal(errorMessage, {
|
|
22
|
+
logLevel: "all"
|
|
23
|
+
});
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
26
|
+
const tsconfigFile = await readJsonFile(tsconfigPath);
|
|
27
|
+
resolvedTsconfig = parseJsonConfigFileContent(tsconfigFile, sys, findFilePath(tsconfigPath));
|
|
28
|
+
if (!resolvedTsconfig) {
|
|
29
|
+
const errorMessage = `\u2716 The specified TypeScript configuration file "${tsconfigPath}" is invalid. Please provide a valid configuration.`;
|
|
30
|
+
writeFatal(errorMessage, {
|
|
31
|
+
logLevel: "all"
|
|
32
|
+
});
|
|
33
|
+
throw new Error(errorMessage);
|
|
34
|
+
}
|
|
35
|
+
resolvedTsconfig.options.configFilePath = tsconfigPath;
|
|
36
|
+
resolvedTsconfig.options.noImplicitOverride = false;
|
|
37
|
+
resolvedTsconfig.options.noUnusedLocals = false;
|
|
38
|
+
resolvedTsconfig.options.noUnusedParameters = false;
|
|
20
39
|
}
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
40
|
+
const resolvedSchemas = [];
|
|
41
|
+
for (const schema of schemas) {
|
|
42
|
+
if (!schema || !schema.includes("*") && !existsSync(schema)) {
|
|
43
|
+
if (schemas.length <= 1) {
|
|
44
|
+
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
48
|
+
}
|
|
31
49
|
}
|
|
32
|
-
|
|
33
|
-
if (schemas.length === 0) {
|
|
50
|
+
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
34
51
|
writeWarning(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
35
52
|
logLevel: "all"
|
|
36
53
|
});
|
|
37
54
|
return null;
|
|
38
55
|
}
|
|
56
|
+
resolvedTsconfig.options.outDir = joinPaths(options.projectRoot, relativePath(tsconfigPath ? findFilePath(tsconfigPath) : options.projectRoot, joinPaths(options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? findFilePath(resolvedSchemas[0]) : resolvedSchemas[0])));
|
|
39
57
|
return {
|
|
40
58
|
workspaceRoot: options.workspaceRoot,
|
|
41
59
|
projectRoot: options.projectRoot,
|
|
42
|
-
schemas,
|
|
60
|
+
schemas: resolvedSchemas,
|
|
43
61
|
js: options.js ?? false,
|
|
44
62
|
ts: options.ts ?? (options.noTs !== void 0 ? !options.noTs : true),
|
|
45
63
|
dts: options.dts ?? (options.noDts !== void 0 ? !options.noDts : true),
|
|
46
|
-
tsconfig:
|
|
64
|
+
tsconfig: resolvedTsconfig
|
|
47
65
|
};
|
|
48
66
|
}
|
|
49
67
|
__name(resolveOptions, "resolveOptions");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { capnpc, compile } from './compile.cjs';
|
|
2
2
|
export { CapnpRPC, MessageChannelTransport } from './rpc.cjs';
|
|
3
|
-
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext } from './types.cjs';
|
|
3
|
+
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResolvedOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext } from './types.cjs';
|
|
4
4
|
export * from 'capnp-es';
|
|
5
5
|
import 'capnp-es/capnp/schema';
|
|
6
6
|
import 'node:buffer';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { capnpc, compile } from './compile.js';
|
|
2
2
|
export { CapnpRPC, MessageChannelTransport } from './rpc.js';
|
|
3
|
-
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext } from './types.js';
|
|
3
|
+
export { CapnpcCLIOptions, CapnpcOptions, CapnpcResolvedOptions, CapnpcResult, CodeGeneratorContext, CodeGeneratorFileContext } from './types.js';
|
|
4
4
|
export * from 'capnp-es';
|
|
5
5
|
import 'capnp-es/capnp/schema';
|
|
6
6
|
import 'node:buffer';
|