@stryke/capnp 0.6.2 → 0.7.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/README.md +226 -1
- package/bin/capnpc.cjs +174 -276
- package/bin/capnpc.d.cts +6 -0
- package/bin/capnpc.d.ts +6 -0
- package/bin/capnpc.js +172 -273
- package/dist/chunk-CCU32X36.js +15 -0
- package/dist/{chunk-QVMMUK6E.js → chunk-PYRZUPFR.js} +3321 -204
- package/dist/chunk-R2JXWA7Q.cjs +15 -0
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-USNT2KNT.cjs +6 -0
- package/dist/chunk-X74MKAHT.cjs +7922 -0
- package/dist/index.cjs +122 -6
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +125 -9
- package/dist/rpc.cjs +4 -103
- package/dist/rpc.js +4 -103
- package/dist/types.cjs +7 -1
- package/dist/types.d.cts +14 -8
- package/dist/types.d.ts +14 -8
- package/dist/types.js +7 -1
- package/package.json +19 -11
- package/dist/capnp.cjs +0 -8
- package/dist/capnp.d.cts +0 -2
- package/dist/capnp.d.ts +0 -2
- package/dist/capnp.js +0 -8
- package/dist/chunk-34UFVQ2X.cjs +0 -4980
- package/dist/chunk-7QZRCXNX.js +0 -3310
- package/dist/chunk-AHJJINE5.cjs +0 -1
- package/dist/chunk-FGRQLKDC.js +0 -4980
- package/dist/chunk-IJMQEVSJ.cjs +0 -3310
- package/dist/chunk-ORA4UQMU.cjs +0 -1
- package/dist/chunk-OULCUN6I.js +0 -0
- package/dist/chunk-TZHOQHWF.js +0 -0
- package/dist/chunk-XNXRTQEO.cjs +0 -4805
- package/dist/compile.cjs +0 -7
- package/dist/compile.d.cts +0 -14
- package/dist/compile.d.ts +0 -14
- package/dist/compile.js +0 -7
package/bin/capnpc.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -38,6 +37,30 @@ module.exports = __toCommonJS(capnpc_exports);
|
|
|
38
37
|
var import_console = require("@storm-software/config-tools/logger/console");
|
|
39
38
|
var import_utilities = require("@storm-software/config-tools/utilities");
|
|
40
39
|
|
|
40
|
+
// ../path/src/exists.ts
|
|
41
|
+
var import_node_fs = require("fs");
|
|
42
|
+
var import_promises = require("fs/promises");
|
|
43
|
+
var existsSync = /* @__PURE__ */ __name((filePath) => {
|
|
44
|
+
return (0, import_node_fs.existsSync)(filePath);
|
|
45
|
+
}, "existsSync");
|
|
46
|
+
var exists = /* @__PURE__ */ __name(async (filePath) => {
|
|
47
|
+
return (0, import_promises.access)(filePath, import_promises.constants.F_OK).then(() => true).catch(() => false);
|
|
48
|
+
}, "exists");
|
|
49
|
+
|
|
50
|
+
// ../fs/src/helpers.ts
|
|
51
|
+
var import_nanotar = require("nanotar");
|
|
52
|
+
var import_node_fs2 = require("fs");
|
|
53
|
+
var import_promises2 = require("fs/promises");
|
|
54
|
+
async function createDirectory(path) {
|
|
55
|
+
if (await exists(path)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
return (0, import_promises2.mkdir)(path, {
|
|
59
|
+
recursive: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
__name(createDirectory, "createDirectory");
|
|
63
|
+
|
|
41
64
|
// ../fs/src/list-files.ts
|
|
42
65
|
var import_defu = __toESM(require("defu"), 1);
|
|
43
66
|
var import_glob = require("glob");
|
|
@@ -626,14 +649,14 @@ var isError = /* @__PURE__ */ __name((obj) => {
|
|
|
626
649
|
}, "isError");
|
|
627
650
|
|
|
628
651
|
// ../fs/src/read-file.ts
|
|
629
|
-
var
|
|
630
|
-
var
|
|
631
|
-
var
|
|
652
|
+
var import_node_fs3 = require("fs");
|
|
653
|
+
var import_promises3 = require("fs/promises");
|
|
654
|
+
var readFile2 = /* @__PURE__ */ __name(async (filePath) => {
|
|
632
655
|
try {
|
|
633
656
|
if (!filePath) {
|
|
634
657
|
throw new Error("No file path provided to read data");
|
|
635
658
|
}
|
|
636
|
-
return await (0,
|
|
659
|
+
return await (0, import_promises3.readFile)(filePath, {
|
|
637
660
|
encoding: "utf8"
|
|
638
661
|
});
|
|
639
662
|
} catch {
|
|
@@ -641,7 +664,7 @@ var readFile = /* @__PURE__ */ __name(async (filePath) => {
|
|
|
641
664
|
}
|
|
642
665
|
}, "readFile");
|
|
643
666
|
async function readJsonFile(path, options) {
|
|
644
|
-
const content = await
|
|
667
|
+
const content = await readFile2(path);
|
|
645
668
|
if (options) {
|
|
646
669
|
options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
|
|
647
670
|
}
|
|
@@ -657,21 +680,11 @@ async function readJsonFile(path, options) {
|
|
|
657
680
|
}
|
|
658
681
|
__name(readJsonFile, "readJsonFile");
|
|
659
682
|
|
|
660
|
-
// ../path/src/exists.ts
|
|
661
|
-
var import_node_fs2 = require("fs");
|
|
662
|
-
var import_promises2 = require("fs/promises");
|
|
663
|
-
var existsSync2 = /* @__PURE__ */ __name((filePath) => {
|
|
664
|
-
return (0, import_node_fs2.existsSync)(filePath);
|
|
665
|
-
}, "existsSync");
|
|
666
|
-
var exists = /* @__PURE__ */ __name(async (filePath) => {
|
|
667
|
-
return (0, import_promises2.access)(filePath, import_promises2.constants.F_OK).then(() => true).catch(() => false);
|
|
668
|
-
}, "exists");
|
|
669
|
-
|
|
670
683
|
// ../path/src/file-path-fns.ts
|
|
671
684
|
var import_node_path = require("path");
|
|
672
685
|
|
|
673
686
|
// ../path/src/is-file.ts
|
|
674
|
-
var
|
|
687
|
+
var import_node_fs4 = require("fs");
|
|
675
688
|
|
|
676
689
|
// ../path/src/join-paths.ts
|
|
677
690
|
var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
|
|
@@ -802,9 +815,6 @@ __name(normalizeString, "normalizeString");
|
|
|
802
815
|
|
|
803
816
|
// ../path/src/regex.ts
|
|
804
817
|
var DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
|
|
805
|
-
var DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
|
|
806
|
-
var UNC_REGEX = /^[/\\]{2}/;
|
|
807
|
-
var ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
|
|
808
818
|
|
|
809
819
|
// ../path/src/slash.ts
|
|
810
820
|
function slash(path) {
|
|
@@ -815,12 +825,6 @@ function slash(path) {
|
|
|
815
825
|
}
|
|
816
826
|
__name(slash, "slash");
|
|
817
827
|
|
|
818
|
-
// ../path/src/is-file.ts
|
|
819
|
-
function isAbsolutePath(path) {
|
|
820
|
-
return ABSOLUTE_PATH_REGEX.test(slash(path));
|
|
821
|
-
}
|
|
822
|
-
__name(isAbsolutePath, "isAbsolutePath");
|
|
823
|
-
|
|
824
828
|
// ../path/src/correct-path.ts
|
|
825
829
|
function normalizeWindowsPath2(input = "") {
|
|
826
830
|
if (!input) {
|
|
@@ -829,97 +833,6 @@ function normalizeWindowsPath2(input = "") {
|
|
|
829
833
|
return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
830
834
|
}
|
|
831
835
|
__name(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
832
|
-
function correctPath(path) {
|
|
833
|
-
if (!path || path.length === 0) {
|
|
834
|
-
return ".";
|
|
835
|
-
}
|
|
836
|
-
path = normalizeWindowsPath2(path);
|
|
837
|
-
const isUNCPath = path.match(UNC_REGEX);
|
|
838
|
-
const isPathAbsolute = isAbsolutePath(path);
|
|
839
|
-
const trailingSeparator = path.endsWith("/");
|
|
840
|
-
path = normalizeString2(path, !isPathAbsolute);
|
|
841
|
-
if (path.length === 0) {
|
|
842
|
-
if (isPathAbsolute) {
|
|
843
|
-
return "/";
|
|
844
|
-
}
|
|
845
|
-
return trailingSeparator ? "./" : ".";
|
|
846
|
-
}
|
|
847
|
-
if (trailingSeparator) {
|
|
848
|
-
path += "/";
|
|
849
|
-
}
|
|
850
|
-
if (DRIVE_LETTER_REGEX.test(path)) {
|
|
851
|
-
path += "/";
|
|
852
|
-
}
|
|
853
|
-
if (isUNCPath) {
|
|
854
|
-
if (!isPathAbsolute) {
|
|
855
|
-
return `//./${path}`;
|
|
856
|
-
}
|
|
857
|
-
return `//${path}`;
|
|
858
|
-
}
|
|
859
|
-
return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
|
|
860
|
-
}
|
|
861
|
-
__name(correctPath, "correctPath");
|
|
862
|
-
function normalizeString2(path, allowAboveRoot) {
|
|
863
|
-
let res = "";
|
|
864
|
-
let lastSegmentLength = 0;
|
|
865
|
-
let lastSlash = -1;
|
|
866
|
-
let dots = 0;
|
|
867
|
-
let char = null;
|
|
868
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
869
|
-
if (index < path.length) {
|
|
870
|
-
char = path[index];
|
|
871
|
-
} else if (char === "/") {
|
|
872
|
-
break;
|
|
873
|
-
} else {
|
|
874
|
-
char = "/";
|
|
875
|
-
}
|
|
876
|
-
if (char === "/") {
|
|
877
|
-
if (lastSlash === index - 1 || dots === 1) {
|
|
878
|
-
} else if (dots === 2) {
|
|
879
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
880
|
-
if (res.length > 2) {
|
|
881
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
882
|
-
if (lastSlashIndex === -1) {
|
|
883
|
-
res = "";
|
|
884
|
-
lastSegmentLength = 0;
|
|
885
|
-
} else {
|
|
886
|
-
res = res.slice(0, lastSlashIndex);
|
|
887
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
888
|
-
}
|
|
889
|
-
lastSlash = index;
|
|
890
|
-
dots = 0;
|
|
891
|
-
continue;
|
|
892
|
-
} else if (res.length > 0) {
|
|
893
|
-
res = "";
|
|
894
|
-
lastSegmentLength = 0;
|
|
895
|
-
lastSlash = index;
|
|
896
|
-
dots = 0;
|
|
897
|
-
continue;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
if (allowAboveRoot) {
|
|
901
|
-
res += res.length > 0 ? "/.." : "..";
|
|
902
|
-
lastSegmentLength = 2;
|
|
903
|
-
}
|
|
904
|
-
} else {
|
|
905
|
-
if (res.length > 0) {
|
|
906
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
907
|
-
} else {
|
|
908
|
-
res = path.slice(lastSlash + 1, index);
|
|
909
|
-
}
|
|
910
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
911
|
-
}
|
|
912
|
-
lastSlash = index;
|
|
913
|
-
dots = 0;
|
|
914
|
-
} else if (char === "." && dots !== -1) {
|
|
915
|
-
++dots;
|
|
916
|
-
} else {
|
|
917
|
-
dots = -1;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return res;
|
|
921
|
-
}
|
|
922
|
-
__name(normalizeString2, "normalizeString");
|
|
923
836
|
|
|
924
837
|
// ../path/src/get-workspace-root.ts
|
|
925
838
|
var import_config_tools = require("@storm-software/config-tools");
|
|
@@ -945,49 +858,20 @@ function findFilePath(filePath) {
|
|
|
945
858
|
return result === "/" ? result : result.replace(/\/$/, "");
|
|
946
859
|
}
|
|
947
860
|
__name(findFilePath, "findFilePath");
|
|
861
|
+
function relativePath(from, to, withEndSlash = false) {
|
|
862
|
+
return (0, import_node_path.relative)(withEndSlash !== true ? from.replace(/\/$/, "") : from, withEndSlash !== true ? to.replace(/\/$/, "") : to);
|
|
863
|
+
}
|
|
864
|
+
__name(relativePath, "relativePath");
|
|
948
865
|
|
|
949
866
|
// bin/capnpc.ts
|
|
950
867
|
var import_commander = require("commander");
|
|
951
|
-
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
952
|
-
|
|
953
|
-
// ../fs/src/helpers.ts
|
|
954
|
-
var import_nanotar = require("nanotar");
|
|
955
|
-
var import_node_fs4 = require("fs");
|
|
956
|
-
var import_promises3 = require("fs/promises");
|
|
957
|
-
async function createDirectory(path) {
|
|
958
|
-
if (await exists(path)) {
|
|
959
|
-
return;
|
|
960
|
-
}
|
|
961
|
-
return (0, import_promises3.mkdir)(path, {
|
|
962
|
-
recursive: true
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
__name(createDirectory, "createDirectory");
|
|
966
|
-
|
|
967
|
-
// ../fs/src/write-file.ts
|
|
968
|
-
var import_j_toml2 = require("@ltd/j-toml");
|
|
969
|
-
var import_defu2 = __toESM(require("defu"), 1);
|
|
970
|
-
var import_node_fs5 = require("fs");
|
|
971
868
|
var import_promises4 = require("fs/promises");
|
|
972
|
-
var
|
|
973
|
-
if (!filePath) {
|
|
974
|
-
throw new Error("No file path provided to read data");
|
|
975
|
-
}
|
|
976
|
-
const directory = findFilePath(correctPath(filePath));
|
|
977
|
-
if (!existsSync2(directory)) {
|
|
978
|
-
if (options.createDirectory !== false) {
|
|
979
|
-
await createDirectory(directory);
|
|
980
|
-
} else {
|
|
981
|
-
throw new Error(`Directory ${directory} does not exist`);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
return (0, import_promises4.writeFile)(filePath, content || "", options);
|
|
985
|
-
}, "writeFile");
|
|
869
|
+
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
986
870
|
|
|
987
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
871
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
|
|
988
872
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
989
873
|
|
|
990
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
874
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.0-_cOx6D.mjs
|
|
991
875
|
var ListElementSize = /* @__PURE__ */ ((ListElementSize2) => {
|
|
992
876
|
ListElementSize2[ListElementSize2["VOID"] = 0] = "VOID";
|
|
993
877
|
ListElementSize2[ListElementSize2["BIT"] = 1] = "BIT";
|
|
@@ -2980,7 +2864,7 @@ function checkDataBounds(byteOffset, byteLength, s) {
|
|
|
2980
2864
|
}
|
|
2981
2865
|
__name(checkDataBounds, "checkDataBounds");
|
|
2982
2866
|
|
|
2983
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
2867
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.BvfUH5E6.mjs
|
|
2984
2868
|
function CompositeList(CompositeClass) {
|
|
2985
2869
|
return class extends List {
|
|
2986
2870
|
static _capnp = {
|
|
@@ -3051,7 +2935,7 @@ var getUint8Mask = _makePrimitiveMaskFn(
|
|
|
3051
2935
|
DataView.prototype.setUint8
|
|
3052
2936
|
);
|
|
3053
2937
|
|
|
3054
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
2938
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/capnp/schema.mjs
|
|
3055
2939
|
var _capnpFileId = BigInt("0xa93fc509624c72d9");
|
|
3056
2940
|
var Node_Parameter = class extends Struct {
|
|
3057
2941
|
static {
|
|
@@ -5711,7 +5595,7 @@ CodeGeneratorRequest._Nodes = CompositeList(Node);
|
|
|
5711
5595
|
CodeGeneratorRequest._SourceInfo = CompositeList(Node_SourceInfo);
|
|
5712
5596
|
CodeGeneratorRequest._RequestedFiles = CompositeList(CodeGeneratorRequest_RequestedFile);
|
|
5713
5597
|
|
|
5714
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
5598
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.GpvEvMIK.mjs
|
|
5715
5599
|
var ArenaKind = /* @__PURE__ */ ((ArenaKind2) => {
|
|
5716
5600
|
ArenaKind2[ArenaKind2["SINGLE_SEGMENT"] = 0] = "SINGLE_SEGMENT";
|
|
5717
5601
|
ArenaKind2[ArenaKind2["MULTI_SEGMENT"] = 1] = "MULTI_SEGMENT";
|
|
@@ -6708,7 +6592,7 @@ function copy(m) {
|
|
|
6708
6592
|
}
|
|
6709
6593
|
__name(copy, "copy");
|
|
6710
6594
|
|
|
6711
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
6595
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
|
|
6712
6596
|
var GEN_EXPLICIT_DEFAULT_NON_PRIMITIVE = "CAPNP-ES000 Don't know how to generate a %s field with an explicit default value.";
|
|
6713
6597
|
var GEN_FIELD_NON_INLINE_STRUCT_LIST = "CAPNP-ES001 Don't know how to generate non-inline struct lists.";
|
|
6714
6598
|
var GEN_NODE_LOOKUP_FAIL = "CAPNP-ES002 Failed to look up node id %s.";
|
|
@@ -6820,10 +6704,11 @@ var Primitives = {
|
|
|
6820
6704
|
setter: "setVoid"
|
|
6821
6705
|
}
|
|
6822
6706
|
};
|
|
6823
|
-
var SOURCE_COMMENT =
|
|
6707
|
+
var SOURCE_COMMENT = `
|
|
6708
|
+
/* eslint-disable */
|
|
6824
6709
|
// biome-ignore lint: disable
|
|
6825
6710
|
|
|
6826
|
-
// Generated by
|
|
6711
|
+
// Generated by storm-capnpc
|
|
6827
6712
|
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
6828
6713
|
|
|
6829
6714
|
`;
|
|
@@ -7857,7 +7742,7 @@ function generateCapnpImport(ctx) {
|
|
|
7857
7742
|
(n) => n.name === "importPath"
|
|
7858
7743
|
);
|
|
7859
7744
|
const importAnnotation = tsImportPathAnnotation && fileNode.annotations.find((a) => a.id === tsImportPathAnnotation.id);
|
|
7860
|
-
const importPath = importAnnotation === void 0 ? "capnp
|
|
7745
|
+
const importPath = importAnnotation === void 0 ? "@stryke/capnp" : importAnnotation.value.text;
|
|
7861
7746
|
ctx.codeParts.push(`import * as $ from '${importPath}';`);
|
|
7862
7747
|
}
|
|
7863
7748
|
__name(generateCapnpImport, "generateCapnpImport");
|
|
@@ -7866,7 +7751,7 @@ function generateNestedImports(ctx) {
|
|
|
7866
7751
|
const { name } = imp;
|
|
7867
7752
|
let importPath;
|
|
7868
7753
|
if (name.startsWith("/capnp/")) {
|
|
7869
|
-
importPath =
|
|
7754
|
+
importPath = `@stryke/capnp/schemas/${name.slice(7).replace(/\.capnp$/, "")}`;
|
|
7870
7755
|
} else {
|
|
7871
7756
|
importPath = name.replace(/\.capnp$/, ".js");
|
|
7872
7757
|
if (importPath[0] !== ".") {
|
|
@@ -7902,12 +7787,35 @@ async function compileAll(codeGenRequest, opts) {
|
|
|
7902
7787
|
const req = new Message(codeGenRequest, false).getRoot(
|
|
7903
7788
|
CodeGeneratorRequest
|
|
7904
7789
|
);
|
|
7790
|
+
console.log(
|
|
7791
|
+
`
|
|
7792
|
+
Running capnpc for ${req.requestedFiles.length} capnp schema files
|
|
7793
|
+
`
|
|
7794
|
+
);
|
|
7905
7795
|
const ctx = new CodeGeneratorContext();
|
|
7906
7796
|
ctx.files = req.requestedFiles.map((file) => loadRequestedFile(req, file));
|
|
7797
|
+
if (ctx.files.length === 0) {
|
|
7798
|
+
throw new Error(GEN_NO_FILES);
|
|
7799
|
+
}
|
|
7800
|
+
console.log(
|
|
7801
|
+
`
|
|
7802
|
+
Compiling ${ctx.files.length} files: ${ctx.files.map((f) => f.tsPath).join(", ")}
|
|
7803
|
+
`
|
|
7804
|
+
);
|
|
7907
7805
|
const files = new Map(
|
|
7908
7806
|
ctx.files.map((file) => [file.tsPath, compileFile(file)])
|
|
7909
7807
|
);
|
|
7910
|
-
|
|
7808
|
+
if (files.size === 0) {
|
|
7809
|
+
throw new Error(GEN_NO_FILES);
|
|
7810
|
+
}
|
|
7811
|
+
if (opts?.dts === true || opts?.js === true) {
|
|
7812
|
+
console.log(
|
|
7813
|
+
`
|
|
7814
|
+
TypeScript Compiling ${files.size} files: ${[...files.keys()].join(", ")}
|
|
7815
|
+
`
|
|
7816
|
+
);
|
|
7817
|
+
tsCompile(files, opts?.dts === true, opts?.js === true, opts?.tsconfig);
|
|
7818
|
+
}
|
|
7911
7819
|
if (!opts?.ts) {
|
|
7912
7820
|
for (const [fileName] of files) {
|
|
7913
7821
|
if (fileName.endsWith(".ts") && !fileName.endsWith(".d.ts")) {
|
|
@@ -7951,6 +7859,7 @@ function tsCompile(files, dts, js, tsconfig) {
|
|
|
7951
7859
|
const compileOptions = {
|
|
7952
7860
|
moduleResolution: import_typescript.default.ModuleResolutionKind.Bundler,
|
|
7953
7861
|
target: import_typescript.default.ScriptTarget.ESNext,
|
|
7862
|
+
strict: true,
|
|
7954
7863
|
...tsconfig,
|
|
7955
7864
|
noEmitOnError: false,
|
|
7956
7865
|
noFallthroughCasesInSwitch: true,
|
|
@@ -7961,7 +7870,6 @@ function tsCompile(files, dts, js, tsconfig) {
|
|
|
7961
7870
|
removeComments: false,
|
|
7962
7871
|
skipLibCheck: true,
|
|
7963
7872
|
sourceMap: false,
|
|
7964
|
-
strict: true,
|
|
7965
7873
|
emitDeclarationOnly: dts && !js,
|
|
7966
7874
|
declaration: dts
|
|
7967
7875
|
};
|
|
@@ -8006,92 +7914,58 @@ function tsCompile(files, dts, js, tsconfig) {
|
|
|
8006
7914
|
}
|
|
8007
7915
|
__name(tsCompile, "tsCompile");
|
|
8008
7916
|
|
|
8009
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
7917
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/compiler/index.mjs
|
|
8010
7918
|
var import_typescript2 = require("typescript");
|
|
8011
7919
|
|
|
8012
7920
|
// src/compile.ts
|
|
8013
7921
|
var import_node_buffer2 = require("buffer");
|
|
8014
7922
|
var import_node_child_process = require("child_process");
|
|
8015
|
-
var import_node_fs6 = require("fs");
|
|
8016
7923
|
async function capnpc(options) {
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
chunks.push(chunk);
|
|
8024
|
-
});
|
|
8025
|
-
await new Promise((resolve) => {
|
|
8026
|
-
process.stdin.on("end", resolve);
|
|
8027
|
-
});
|
|
8028
|
-
const reqBuffer = import_node_buffer2.Buffer.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
|
|
8029
|
-
let i = 0;
|
|
8030
|
-
for (const chunk of chunks) {
|
|
8031
|
-
chunk.copy(reqBuffer, i);
|
|
8032
|
-
i += chunk.byteLength;
|
|
8033
|
-
}
|
|
8034
|
-
dataBuf = reqBuffer;
|
|
8035
|
-
}
|
|
8036
|
-
if (dataBuf.byteLength === 0) {
|
|
8037
|
-
const opts = [];
|
|
8038
|
-
if (output) {
|
|
8039
|
-
opts.push(`-o-:${output}`);
|
|
8040
|
-
} else {
|
|
8041
|
-
opts.push("-o-");
|
|
8042
|
-
}
|
|
8043
|
-
dataBuf = await new Promise((resolve) => {
|
|
8044
|
-
(0, import_node_child_process.exec)(`capnpc ${opts.join(" ")} ${schema.join(" ")}`, {
|
|
8045
|
-
encoding: "buffer"
|
|
8046
|
-
}, (error, stdout, stderr) => {
|
|
8047
|
-
if (stderr.length > 0) {
|
|
8048
|
-
process.stderr.write(stderr);
|
|
8049
|
-
}
|
|
8050
|
-
if (error) {
|
|
8051
|
-
throw error;
|
|
8052
|
-
}
|
|
8053
|
-
resolve(stdout);
|
|
8054
|
-
});
|
|
8055
|
-
});
|
|
8056
|
-
}
|
|
8057
|
-
const result = await compileAll(dataBuf, {
|
|
8058
|
-
ts: options.ts ?? true,
|
|
8059
|
-
js: options.js ?? false,
|
|
8060
|
-
dts: options.dts ?? true,
|
|
8061
|
-
tsconfig: tsconfig?.options
|
|
7924
|
+
const { output, tsconfig, schemas = [], tty } = options;
|
|
7925
|
+
let dataBuf = import_node_buffer2.Buffer.alloc(0);
|
|
7926
|
+
if (tty) {
|
|
7927
|
+
const chunks = [];
|
|
7928
|
+
process.stdin.on("data", (chunk) => {
|
|
7929
|
+
chunks.push(chunk);
|
|
8062
7930
|
});
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
if (output) {
|
|
8072
|
-
filePath = joinPaths(output, fileName);
|
|
8073
|
-
}
|
|
8074
|
-
if (!(0, import_node_fs6.existsSync)(findFilePath(filePath))) {
|
|
8075
|
-
await createDirectory(findFilePath(filePath));
|
|
8076
|
-
}
|
|
8077
|
-
await writeFile(
|
|
8078
|
-
filePath,
|
|
8079
|
-
// https://github.com/microsoft/TypeScript/issues/54632
|
|
8080
|
-
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
8081
|
-
);
|
|
7931
|
+
await new Promise((resolve) => {
|
|
7932
|
+
process.stdin.on("end", resolve);
|
|
7933
|
+
});
|
|
7934
|
+
const reqBuffer = import_node_buffer2.Buffer.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
|
|
7935
|
+
let i = 0;
|
|
7936
|
+
for (const chunk of chunks) {
|
|
7937
|
+
chunk.copy(reqBuffer, i);
|
|
7938
|
+
i += chunk.byteLength;
|
|
8082
7939
|
}
|
|
8083
|
-
|
|
8084
|
-
}
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
}
|
|
7940
|
+
dataBuf = reqBuffer;
|
|
7941
|
+
}
|
|
7942
|
+
if (dataBuf.byteLength === 0) {
|
|
7943
|
+
const opts = [];
|
|
7944
|
+
if (output) {
|
|
7945
|
+
opts.push(`-o-:${output}`);
|
|
8090
7946
|
} else {
|
|
8091
|
-
|
|
8092
|
-
}
|
|
8093
|
-
|
|
7947
|
+
opts.push("-o-");
|
|
7948
|
+
}
|
|
7949
|
+
dataBuf = await new Promise((resolve) => {
|
|
7950
|
+
(0, import_node_child_process.exec)(`capnpc ${opts.join(" ")} ${schemas.join(" ")}`, {
|
|
7951
|
+
encoding: "buffer"
|
|
7952
|
+
}, (error, stdout, stderr) => {
|
|
7953
|
+
if (stderr.length > 0) {
|
|
7954
|
+
process.stderr.write(stderr);
|
|
7955
|
+
}
|
|
7956
|
+
if (error) {
|
|
7957
|
+
throw error;
|
|
7958
|
+
}
|
|
7959
|
+
resolve(stdout);
|
|
7960
|
+
});
|
|
7961
|
+
});
|
|
8094
7962
|
}
|
|
7963
|
+
return compileAll(dataBuf, {
|
|
7964
|
+
ts: options.ts ?? true,
|
|
7965
|
+
js: false,
|
|
7966
|
+
dts: false,
|
|
7967
|
+
tsconfig: tsconfig?.options
|
|
7968
|
+
});
|
|
8095
7969
|
}
|
|
8096
7970
|
__name(capnpc, "capnpc");
|
|
8097
7971
|
|
|
@@ -8108,9 +7982,13 @@ function createProgram() {
|
|
|
8108
7982
|
}
|
|
8109
7983
|
const program = new import_commander.Command("storm-capnpc");
|
|
8110
7984
|
program.version("1.0.0", "-v --version", "display CLI version");
|
|
7985
|
+
const projectRootOption = new import_commander.Option("-p --project-root <path>", "The path to the project root directory");
|
|
8111
7986
|
const tsOption = new import_commander.Option("--ts", "An indicator to generate TypeScript files").default(true);
|
|
7987
|
+
const noTsOption = new import_commander.Option("--no-ts", "An indicator to disable generation of TypeScript files");
|
|
8112
7988
|
const jsOption = new import_commander.Option("--js", "An indicator to generate JavaScript files").default(false);
|
|
8113
|
-
const dtsOption = new import_commander.Option("--dts", "An indicator to generate TypeScript declaration files")
|
|
7989
|
+
const dtsOption = new import_commander.Option("--dts", "An indicator to generate TypeScript declaration files");
|
|
7990
|
+
const noDtsOption = new import_commander.Option("--no-dts", "An indicator to disable generation of TypeScript declaration files");
|
|
7991
|
+
const ttyOption = new import_commander.Option("--tty", "An indicator to enable TTY mode for the compiler");
|
|
8114
7992
|
const importPathOption = new import_commander.Option("-I --import-path <dir...>", "Add <dir> to the list of directories searched for non-relative imports").default([]).argParser((val) => {
|
|
8115
7993
|
if (val.startsWith("-I") || val.startsWith("--import-path")) {
|
|
8116
7994
|
return val.split(",").map((dir) => dir.trim());
|
|
@@ -8121,52 +7999,47 @@ function createProgram() {
|
|
|
8121
7999
|
});
|
|
8122
8000
|
const generateId = new import_commander.Option("-i --generate-id", "Generate a new 64-bit unique ID for use in a Cap'n Proto schema").default(true);
|
|
8123
8001
|
const standardImportOption = new import_commander.Option("--standard-import", "Add default import paths; use only those specified by -I").default(true);
|
|
8124
|
-
const schemaOption = new import_commander.Option("-s --schema <path
|
|
8125
|
-
joinPaths(process.cwd(), "**/*.capnp")
|
|
8126
|
-
]).argParser((val) => {
|
|
8127
|
-
let result = [];
|
|
8128
|
-
if (val.startsWith("--schema") || val.startsWith("-s")) {
|
|
8129
|
-
result = val.split(",").map((dir) => dir.trim());
|
|
8130
|
-
}
|
|
8131
|
-
result = [
|
|
8132
|
-
val.trim()
|
|
8133
|
-
];
|
|
8134
|
-
return result.map((dir) => dir.endsWith(".capnp") ? dir : joinPaths(dir, "**/*.capnp"));
|
|
8135
|
-
});
|
|
8002
|
+
const schemaOption = new import_commander.Option("-s --schema <path>", "The directory (or a glob to the directory) containing the Cap'n Proto schema files to compile (default: current working directory)").default(joinPaths("{projectRoot}", "**/*.capnp"));
|
|
8136
8003
|
const outputOption = new import_commander.Option("-o --output <path>", "The directory to output the generated files to");
|
|
8137
|
-
const tsconfigOption = new import_commander.Option("
|
|
8004
|
+
const tsconfigOption = new import_commander.Option("--tsconfig <path>", "The path to the TypeScript configuration file to use for compilation").default(joinPaths("{projectRoot}", "tsconfig.json"));
|
|
8005
|
+
const workspaceRootOption = new import_commander.Option("-w --workspace-root <path>", "The path to the workspace root directory").default(root);
|
|
8138
8006
|
program.command("compile", {
|
|
8139
8007
|
isDefault: true
|
|
8140
|
-
}).description("Run the Storm Cap'n Proto compiler").addOption(schemaOption).addOption(outputOption).addOption(importPathOption).addOption(tsconfigOption).addOption(generateId).addOption(standardImportOption).addOption(tsOption).addOption(jsOption).addOption(dtsOption).action(compileAction).showSuggestionAfterError(true).showHelpAfterError(true);
|
|
8008
|
+
}).description("Run the Storm Cap'n Proto compiler").addOption(projectRootOption).addOption(schemaOption).addOption(outputOption).addOption(importPathOption).addOption(tsconfigOption).addOption(generateId).addOption(standardImportOption).addOption(tsOption).addOption(noTsOption).addOption(jsOption).addOption(dtsOption).addOption(noDtsOption).addOption(workspaceRootOption).addOption(ttyOption).action(compileAction).showSuggestionAfterError(true).showHelpAfterError(true);
|
|
8141
8009
|
return program;
|
|
8142
8010
|
}
|
|
8143
8011
|
__name(createProgram, "createProgram");
|
|
8144
8012
|
async function compileAction(options) {
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
(0, import_console.writeFatal)(
|
|
8013
|
+
const tsconfigPath = options.tsconfig.replace("{projectRoot}", options.projectRoot);
|
|
8014
|
+
const schema = options.schema ? options.schema.replace("{projectRoot}", options.projectRoot) : options.projectRoot;
|
|
8015
|
+
if (!existsSync(tsconfigPath)) {
|
|
8016
|
+
const errorMessage = options.tsconfig ? `\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.";
|
|
8017
|
+
(0, import_console.writeFatal)(errorMessage, {
|
|
8150
8018
|
logLevel: "all"
|
|
8151
8019
|
});
|
|
8152
|
-
|
|
8020
|
+
throw new Error(errorMessage);
|
|
8153
8021
|
}
|
|
8154
|
-
const resolvedTsconfig = await readJsonFile(
|
|
8155
|
-
const tsconfig = import_typescript3.default.parseJsonConfigFileContent(resolvedTsconfig, import_typescript3.default.sys, findFilePath(
|
|
8156
|
-
tsconfig.options.configFilePath =
|
|
8022
|
+
const resolvedTsconfig = await readJsonFile(tsconfigPath);
|
|
8023
|
+
const tsconfig = import_typescript3.default.parseJsonConfigFileContent(resolvedTsconfig, import_typescript3.default.sys, findFilePath(tsconfigPath));
|
|
8024
|
+
tsconfig.options.configFilePath = tsconfigPath;
|
|
8157
8025
|
tsconfig.options.noImplicitOverride = false;
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
schema.
|
|
8026
|
+
tsconfig.options.noUnusedLocals = false;
|
|
8027
|
+
tsconfig.options.noUnusedParameters = false;
|
|
8028
|
+
tsconfig.options.outDir = joinPaths(options.projectRoot, relativePath(findFilePath(tsconfigPath), joinPaths(options.workspaceRoot, schema.endsWith(".capnp") ? findFilePath(schema) : schema)));
|
|
8029
|
+
(0, import_console.writeInfo)(`\u{1F4E6} Storm Cap'n Proto Compiler will output ${options.ts ? "TypeScript code" : ""}${options.js ? options.ts ? ", JavaScript code" : "JavaScript code" : ""}${options.dts ? options.ts || options.js ? ", TypeScript declarations" : "TypeScript declarations" : ""} files from schemas at ${schema} to ${tsconfig.options.outDir}...`, {
|
|
8030
|
+
logLevel: "all"
|
|
8031
|
+
});
|
|
8032
|
+
const schemas = [];
|
|
8033
|
+
if (!schema || !schema.includes("*") && !existsSync(schema)) {
|
|
8034
|
+
const errorMessage = `\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`;
|
|
8035
|
+
(0, import_console.writeFatal)(errorMessage, {
|
|
8036
|
+
logLevel: "all"
|
|
8037
|
+
});
|
|
8038
|
+
throw new Error(errorMessage);
|
|
8167
8039
|
}
|
|
8168
|
-
|
|
8169
|
-
|
|
8040
|
+
schemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
8041
|
+
if (schemas.length === 0) {
|
|
8042
|
+
(0, import_console.writeFatal)(`\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
8170
8043
|
logLevel: "all"
|
|
8171
8044
|
});
|
|
8172
8045
|
return;
|
|
@@ -8174,14 +8047,39 @@ async function compileAction(options) {
|
|
|
8174
8047
|
const result = await capnpc({
|
|
8175
8048
|
...options,
|
|
8176
8049
|
tsconfig,
|
|
8177
|
-
|
|
8050
|
+
schemas,
|
|
8051
|
+
ts: options.ts ?? (options.noTs !== void 0 ? !options.noTs : true),
|
|
8052
|
+
dts: options.dts ?? (options.noDts !== void 0 ? !options.noDts : true)
|
|
8178
8053
|
});
|
|
8179
8054
|
if (result.files.size === 0) {
|
|
8180
|
-
(0, import_console.
|
|
8055
|
+
(0, import_console.writeWarning)("\u26A0\uFE0F No files were generated. Please check your schema files.", {
|
|
8181
8056
|
logLevel: "all"
|
|
8182
8057
|
});
|
|
8183
8058
|
return;
|
|
8184
8059
|
}
|
|
8060
|
+
(0, import_console.writeInfo)(`Writing ${result.files.size} generated files to disk...`, {
|
|
8061
|
+
logLevel: "all"
|
|
8062
|
+
});
|
|
8063
|
+
for (const [fileName, content] of result.files) {
|
|
8064
|
+
let filePath = fileName;
|
|
8065
|
+
if (!existsSync(findFilePath(filePath))) {
|
|
8066
|
+
const fullPath = `/${filePath}`;
|
|
8067
|
+
if (existsSync(findFilePath(fullPath))) {
|
|
8068
|
+
filePath = fullPath;
|
|
8069
|
+
}
|
|
8070
|
+
}
|
|
8071
|
+
if (options.output) {
|
|
8072
|
+
filePath = joinPaths(options.output, fileName);
|
|
8073
|
+
}
|
|
8074
|
+
if (!existsSync(findFilePath(filePath))) {
|
|
8075
|
+
await createDirectory(findFilePath(filePath));
|
|
8076
|
+
}
|
|
8077
|
+
await (0, import_promises4.writeFile)(
|
|
8078
|
+
filePath,
|
|
8079
|
+
// https://github.com/microsoft/TypeScript/issues/54632
|
|
8080
|
+
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
8081
|
+
);
|
|
8082
|
+
}
|
|
8185
8083
|
(0, import_console.writeSuccess)("\u26A1 Storm Cap'n Proto Compiler completed successfully.", {
|
|
8186
8084
|
logLevel: "all"
|
|
8187
8085
|
});
|
package/bin/capnpc.d.cts
ADDED