@stryke/capnp 0.6.3 → 0.8.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 +208 -313
- package/bin/capnpc.d.cts +6 -0
- package/bin/capnpc.d.ts +6 -0
- package/bin/capnpc.js +206 -310
- package/dist/chunk-CCU32X36.js +15 -0
- package/dist/{chunk-COUAFT7O.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 +13 -8
- package/dist/types.d.ts +13 -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-5MK6PQWW.cjs +0 -3310
- package/dist/chunk-AHJJINE5.cjs +0 -1
- package/dist/chunk-CFDWCYSU.cjs +0 -4805
- package/dist/chunk-M5QB7J6H.cjs +0 -4980
- package/dist/chunk-N5AOPRAP.js +0 -3310
- package/dist/chunk-ORA4UQMU.cjs +0 -1
- package/dist/chunk-OULCUN6I.js +0 -0
- package/dist/chunk-QHIE4YNG.js +0 -4980
- package/dist/chunk-TZHOQHWF.js +0 -0
- 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.js
CHANGED
|
@@ -3,32 +3,32 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
4
|
|
|
5
5
|
// bin/capnpc.ts
|
|
6
|
-
import { writeFatal, writeInfo, writeSuccess } from "@storm-software/config-tools/logger/console";
|
|
6
|
+
import { writeFatal, writeInfo, writeSuccess, writeWarning } from "@storm-software/config-tools/logger/console";
|
|
7
7
|
import { exitWithError, exitWithSuccess, findWorkspaceRootSafe as findWorkspaceRootSafe2, handleProcess } from "@storm-software/config-tools/utilities";
|
|
8
8
|
|
|
9
|
-
// ../
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
// ../path/src/exists.ts
|
|
10
|
+
import { existsSync as existsSyncFs } from "node:fs";
|
|
11
|
+
import { access, constants } from "node:fs/promises";
|
|
12
|
+
var existsSync = /* @__PURE__ */ __name((filePath) => {
|
|
13
|
+
return existsSyncFs(filePath);
|
|
14
|
+
}, "existsSync");
|
|
15
|
+
var exists = /* @__PURE__ */ __name(async (filePath) => {
|
|
16
|
+
return access(filePath, constants.F_OK).then(() => true).catch(() => false);
|
|
17
|
+
}, "exists");
|
|
18
|
+
|
|
19
|
+
// ../fs/src/helpers.ts
|
|
20
|
+
import { parseTar, parseTarGzip } from "nanotar";
|
|
21
|
+
import { createWriteStream, mkdirSync, rmSync } from "node:fs";
|
|
22
|
+
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
23
|
+
async function createDirectory(path) {
|
|
24
|
+
if (await exists(path)) {
|
|
25
|
+
return;
|
|
25
26
|
}
|
|
26
|
-
return
|
|
27
|
+
return mkdir(path, {
|
|
28
|
+
recursive: true
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
|
-
__name(
|
|
29
|
-
|
|
30
|
-
// ../fs/src/read-file.ts
|
|
31
|
-
import { parse as parseToml } from "@ltd/j-toml";
|
|
31
|
+
__name(createDirectory, "createDirectory");
|
|
32
32
|
|
|
33
33
|
// ../type-checks/src/get-object-tag.ts
|
|
34
34
|
var getObjectTag = /* @__PURE__ */ __name((value) => {
|
|
@@ -594,9 +594,9 @@ var isError = /* @__PURE__ */ __name((obj) => {
|
|
|
594
594
|
}, "isError");
|
|
595
595
|
|
|
596
596
|
// ../fs/src/read-file.ts
|
|
597
|
-
import { existsSync, readFileSync as readFileSyncFs } from "node:fs";
|
|
597
|
+
import { existsSync as existsSync2, readFileSync as readFileSyncFs } from "node:fs";
|
|
598
598
|
import { readFile as readFileFs } from "node:fs/promises";
|
|
599
|
-
var
|
|
599
|
+
var readFile2 = /* @__PURE__ */ __name(async (filePath) => {
|
|
600
600
|
try {
|
|
601
601
|
if (!filePath) {
|
|
602
602
|
throw new Error("No file path provided to read data");
|
|
@@ -608,35 +608,6 @@ var readFile = /* @__PURE__ */ __name(async (filePath) => {
|
|
|
608
608
|
throw new Error("An error occurred writing data to file");
|
|
609
609
|
}
|
|
610
610
|
}, "readFile");
|
|
611
|
-
async function readJsonFile(path, options) {
|
|
612
|
-
const content = await readFile(path);
|
|
613
|
-
if (options) {
|
|
614
|
-
options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
|
|
615
|
-
}
|
|
616
|
-
try {
|
|
617
|
-
return StormJSON.parseJson(content, options);
|
|
618
|
-
} catch (error) {
|
|
619
|
-
if (isError(error)) {
|
|
620
|
-
error.message = error.message.replace("JSON", path);
|
|
621
|
-
throw error;
|
|
622
|
-
}
|
|
623
|
-
throw new Error(`Failed to parse JSON: ${path}`);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
__name(readJsonFile, "readJsonFile");
|
|
627
|
-
|
|
628
|
-
// ../path/src/exists.ts
|
|
629
|
-
import { existsSync as existsSyncFs } from "node:fs";
|
|
630
|
-
import { access, constants } from "node:fs/promises";
|
|
631
|
-
var existsSync2 = /* @__PURE__ */ __name((filePath) => {
|
|
632
|
-
return existsSyncFs(filePath);
|
|
633
|
-
}, "existsSync");
|
|
634
|
-
var exists = /* @__PURE__ */ __name(async (filePath) => {
|
|
635
|
-
return access(filePath, constants.F_OK).then(() => true).catch(() => false);
|
|
636
|
-
}, "exists");
|
|
637
|
-
|
|
638
|
-
// ../path/src/file-path-fns.ts
|
|
639
|
-
import { relative } from "node:path";
|
|
640
611
|
|
|
641
612
|
// ../path/src/is-file.ts
|
|
642
613
|
import { lstatSync, statSync } from "node:fs";
|
|
@@ -770,9 +741,6 @@ __name(normalizeString, "normalizeString");
|
|
|
770
741
|
|
|
771
742
|
// ../path/src/regex.ts
|
|
772
743
|
var DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
|
|
773
|
-
var DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
|
|
774
|
-
var UNC_REGEX = /^[/\\]{2}/;
|
|
775
|
-
var ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
|
|
776
744
|
|
|
777
745
|
// ../path/src/slash.ts
|
|
778
746
|
function slash(path) {
|
|
@@ -783,12 +751,6 @@ function slash(path) {
|
|
|
783
751
|
}
|
|
784
752
|
__name(slash, "slash");
|
|
785
753
|
|
|
786
|
-
// ../path/src/is-file.ts
|
|
787
|
-
function isAbsolutePath(path) {
|
|
788
|
-
return ABSOLUTE_PATH_REGEX.test(slash(path));
|
|
789
|
-
}
|
|
790
|
-
__name(isAbsolutePath, "isAbsolutePath");
|
|
791
|
-
|
|
792
754
|
// ../path/src/correct-path.ts
|
|
793
755
|
function normalizeWindowsPath2(input = "") {
|
|
794
756
|
if (!input) {
|
|
@@ -797,97 +759,9 @@ function normalizeWindowsPath2(input = "") {
|
|
|
797
759
|
return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
798
760
|
}
|
|
799
761
|
__name(normalizeWindowsPath2, "normalizeWindowsPath");
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
path = normalizeWindowsPath2(path);
|
|
805
|
-
const isUNCPath = path.match(UNC_REGEX);
|
|
806
|
-
const isPathAbsolute = isAbsolutePath(path);
|
|
807
|
-
const trailingSeparator = path.endsWith("/");
|
|
808
|
-
path = normalizeString2(path, !isPathAbsolute);
|
|
809
|
-
if (path.length === 0) {
|
|
810
|
-
if (isPathAbsolute) {
|
|
811
|
-
return "/";
|
|
812
|
-
}
|
|
813
|
-
return trailingSeparator ? "./" : ".";
|
|
814
|
-
}
|
|
815
|
-
if (trailingSeparator) {
|
|
816
|
-
path += "/";
|
|
817
|
-
}
|
|
818
|
-
if (DRIVE_LETTER_REGEX.test(path)) {
|
|
819
|
-
path += "/";
|
|
820
|
-
}
|
|
821
|
-
if (isUNCPath) {
|
|
822
|
-
if (!isPathAbsolute) {
|
|
823
|
-
return `//./${path}`;
|
|
824
|
-
}
|
|
825
|
-
return `//${path}`;
|
|
826
|
-
}
|
|
827
|
-
return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
|
|
828
|
-
}
|
|
829
|
-
__name(correctPath, "correctPath");
|
|
830
|
-
function normalizeString2(path, allowAboveRoot) {
|
|
831
|
-
let res = "";
|
|
832
|
-
let lastSegmentLength = 0;
|
|
833
|
-
let lastSlash = -1;
|
|
834
|
-
let dots = 0;
|
|
835
|
-
let char = null;
|
|
836
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
837
|
-
if (index < path.length) {
|
|
838
|
-
char = path[index];
|
|
839
|
-
} else if (char === "/") {
|
|
840
|
-
break;
|
|
841
|
-
} else {
|
|
842
|
-
char = "/";
|
|
843
|
-
}
|
|
844
|
-
if (char === "/") {
|
|
845
|
-
if (lastSlash === index - 1 || dots === 1) {
|
|
846
|
-
} else if (dots === 2) {
|
|
847
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
848
|
-
if (res.length > 2) {
|
|
849
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
850
|
-
if (lastSlashIndex === -1) {
|
|
851
|
-
res = "";
|
|
852
|
-
lastSegmentLength = 0;
|
|
853
|
-
} else {
|
|
854
|
-
res = res.slice(0, lastSlashIndex);
|
|
855
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
856
|
-
}
|
|
857
|
-
lastSlash = index;
|
|
858
|
-
dots = 0;
|
|
859
|
-
continue;
|
|
860
|
-
} else if (res.length > 0) {
|
|
861
|
-
res = "";
|
|
862
|
-
lastSegmentLength = 0;
|
|
863
|
-
lastSlash = index;
|
|
864
|
-
dots = 0;
|
|
865
|
-
continue;
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
if (allowAboveRoot) {
|
|
869
|
-
res += res.length > 0 ? "/.." : "..";
|
|
870
|
-
lastSegmentLength = 2;
|
|
871
|
-
}
|
|
872
|
-
} else {
|
|
873
|
-
if (res.length > 0) {
|
|
874
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
875
|
-
} else {
|
|
876
|
-
res = path.slice(lastSlash + 1, index);
|
|
877
|
-
}
|
|
878
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
879
|
-
}
|
|
880
|
-
lastSlash = index;
|
|
881
|
-
dots = 0;
|
|
882
|
-
} else if (char === "." && dots !== -1) {
|
|
883
|
-
++dots;
|
|
884
|
-
} else {
|
|
885
|
-
dots = -1;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
return res;
|
|
889
|
-
}
|
|
890
|
-
__name(normalizeString2, "normalizeString");
|
|
762
|
+
|
|
763
|
+
// ../path/src/file-path-fns.ts
|
|
764
|
+
import { relative } from "node:path";
|
|
891
765
|
|
|
892
766
|
// ../path/src/get-workspace-root.ts
|
|
893
767
|
import { findWorkspaceRootSafe } from "@storm-software/config-tools";
|
|
@@ -918,48 +792,58 @@ function relativePath(from, to, withEndSlash = false) {
|
|
|
918
792
|
}
|
|
919
793
|
__name(relativePath, "relativePath");
|
|
920
794
|
|
|
921
|
-
// bin/capnpc.ts
|
|
922
|
-
import { Command, Option } from "commander";
|
|
923
|
-
import ts2 from "typescript";
|
|
924
|
-
|
|
925
|
-
// ../fs/src/helpers.ts
|
|
926
|
-
import { parseTar, parseTarGzip } from "nanotar";
|
|
927
|
-
import { createWriteStream, mkdirSync, rmSync } from "node:fs";
|
|
928
|
-
import { mkdir, readFile as readFile2, rm } from "node:fs/promises";
|
|
929
|
-
async function createDirectory(path) {
|
|
930
|
-
if (await exists(path)) {
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
return mkdir(path, {
|
|
934
|
-
recursive: true
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
__name(createDirectory, "createDirectory");
|
|
938
|
-
|
|
939
795
|
// ../fs/src/write-file.ts
|
|
940
|
-
import { stringify as stringifyToml } from "@ltd/j-toml";
|
|
941
|
-
import defu2 from "defu";
|
|
942
796
|
import { writeFileSync as writeFileSyncFs } from "node:fs";
|
|
943
797
|
import { writeFile as writeFileFs } from "node:fs/promises";
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
798
|
+
|
|
799
|
+
// ../fs/src/json.ts
|
|
800
|
+
async function readJsonFile(path, options) {
|
|
801
|
+
const content = await readFile2(path);
|
|
802
|
+
if (options) {
|
|
803
|
+
options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
|
|
804
|
+
}
|
|
805
|
+
try {
|
|
806
|
+
return StormJSON.parseJson(content, options);
|
|
807
|
+
} catch (error) {
|
|
808
|
+
if (isError(error)) {
|
|
809
|
+
error.message = error.message.replace("JSON", path);
|
|
810
|
+
throw error;
|
|
954
811
|
}
|
|
812
|
+
throw new Error(`Failed to parse JSON: ${path}`);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
__name(readJsonFile, "readJsonFile");
|
|
816
|
+
|
|
817
|
+
// ../fs/src/list-files.ts
|
|
818
|
+
import defu from "defu";
|
|
819
|
+
import { glob } from "glob";
|
|
820
|
+
var DEFAULT_OPTIONS = {
|
|
821
|
+
dot: true
|
|
822
|
+
};
|
|
823
|
+
async function list(filesGlob, options) {
|
|
824
|
+
return glob(filesGlob, defu(options ?? {}, DEFAULT_OPTIONS));
|
|
825
|
+
}
|
|
826
|
+
__name(list, "list");
|
|
827
|
+
async function listFiles(filesGlob, options) {
|
|
828
|
+
const result = (await list(filesGlob, defu({
|
|
829
|
+
withFileTypes: true
|
|
830
|
+
}, options ?? {}))).filter((ret) => ret.isFile());
|
|
831
|
+
if (!options?.withFileTypes) {
|
|
832
|
+
return result.map((file) => file.fullpath());
|
|
955
833
|
}
|
|
956
|
-
return
|
|
957
|
-
}
|
|
834
|
+
return result;
|
|
835
|
+
}
|
|
836
|
+
__name(listFiles, "listFiles");
|
|
958
837
|
|
|
959
|
-
//
|
|
838
|
+
// bin/capnpc.ts
|
|
839
|
+
import { Command, Option } from "commander";
|
|
840
|
+
import { writeFile as writeFile2 } from "node:fs/promises";
|
|
841
|
+
import ts2 from "typescript";
|
|
842
|
+
|
|
843
|
+
// ../../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
|
|
960
844
|
import ts from "typescript";
|
|
961
845
|
|
|
962
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
846
|
+
// ../../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
|
|
963
847
|
var ListElementSize = /* @__PURE__ */ ((ListElementSize2) => {
|
|
964
848
|
ListElementSize2[ListElementSize2["VOID"] = 0] = "VOID";
|
|
965
849
|
ListElementSize2[ListElementSize2["BIT"] = 1] = "BIT";
|
|
@@ -2952,7 +2836,7 @@ function checkDataBounds(byteOffset, byteLength, s) {
|
|
|
2952
2836
|
}
|
|
2953
2837
|
__name(checkDataBounds, "checkDataBounds");
|
|
2954
2838
|
|
|
2955
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
2839
|
+
// ../../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
|
|
2956
2840
|
function CompositeList(CompositeClass) {
|
|
2957
2841
|
return class extends List {
|
|
2958
2842
|
static _capnp = {
|
|
@@ -3023,7 +2907,7 @@ var getUint8Mask = _makePrimitiveMaskFn(
|
|
|
3023
2907
|
DataView.prototype.setUint8
|
|
3024
2908
|
);
|
|
3025
2909
|
|
|
3026
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
2910
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/capnp/schema.mjs
|
|
3027
2911
|
var _capnpFileId = BigInt("0xa93fc509624c72d9");
|
|
3028
2912
|
var Node_Parameter = class extends Struct {
|
|
3029
2913
|
static {
|
|
@@ -5683,7 +5567,7 @@ CodeGeneratorRequest._Nodes = CompositeList(Node);
|
|
|
5683
5567
|
CodeGeneratorRequest._SourceInfo = CompositeList(Node_SourceInfo);
|
|
5684
5568
|
CodeGeneratorRequest._RequestedFiles = CompositeList(CodeGeneratorRequest_RequestedFile);
|
|
5685
5569
|
|
|
5686
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
5570
|
+
// ../../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
|
|
5687
5571
|
var ArenaKind = /* @__PURE__ */ ((ArenaKind2) => {
|
|
5688
5572
|
ArenaKind2[ArenaKind2["SINGLE_SEGMENT"] = 0] = "SINGLE_SEGMENT";
|
|
5689
5573
|
ArenaKind2[ArenaKind2["MULTI_SEGMENT"] = 1] = "MULTI_SEGMENT";
|
|
@@ -6680,7 +6564,7 @@ function copy(m) {
|
|
|
6680
6564
|
}
|
|
6681
6565
|
__name(copy, "copy");
|
|
6682
6566
|
|
|
6683
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
6567
|
+
// ../../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
|
|
6684
6568
|
var GEN_EXPLICIT_DEFAULT_NON_PRIMITIVE = "CAPNP-ES000 Don't know how to generate a %s field with an explicit default value.";
|
|
6685
6569
|
var GEN_FIELD_NON_INLINE_STRUCT_LIST = "CAPNP-ES001 Don't know how to generate non-inline struct lists.";
|
|
6686
6570
|
var GEN_NODE_LOOKUP_FAIL = "CAPNP-ES002 Failed to look up node id %s.";
|
|
@@ -6792,10 +6676,11 @@ var Primitives = {
|
|
|
6792
6676
|
setter: "setVoid"
|
|
6793
6677
|
}
|
|
6794
6678
|
};
|
|
6795
|
-
var SOURCE_COMMENT =
|
|
6679
|
+
var SOURCE_COMMENT = `
|
|
6680
|
+
/* eslint-disable */
|
|
6796
6681
|
// biome-ignore lint: disable
|
|
6797
6682
|
|
|
6798
|
-
// Generated by
|
|
6683
|
+
// Generated by storm-capnpc
|
|
6799
6684
|
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
6800
6685
|
|
|
6801
6686
|
`;
|
|
@@ -7829,7 +7714,7 @@ function generateCapnpImport(ctx) {
|
|
|
7829
7714
|
(n) => n.name === "importPath"
|
|
7830
7715
|
);
|
|
7831
7716
|
const importAnnotation = tsImportPathAnnotation && fileNode.annotations.find((a) => a.id === tsImportPathAnnotation.id);
|
|
7832
|
-
const importPath = importAnnotation === void 0 ? "
|
|
7717
|
+
const importPath = importAnnotation === void 0 ? "@stryke/capnp" : importAnnotation.value.text;
|
|
7833
7718
|
ctx.codeParts.push(`import * as $ from '${importPath}';`);
|
|
7834
7719
|
}
|
|
7835
7720
|
__name(generateCapnpImport, "generateCapnpImport");
|
|
@@ -7838,7 +7723,7 @@ function generateNestedImports(ctx) {
|
|
|
7838
7723
|
const { name } = imp;
|
|
7839
7724
|
let importPath;
|
|
7840
7725
|
if (name.startsWith("/capnp/")) {
|
|
7841
|
-
importPath =
|
|
7726
|
+
importPath = `@stryke/capnp/schemas/${name.slice(7).replace(/\.capnp$/, "")}`;
|
|
7842
7727
|
} else {
|
|
7843
7728
|
importPath = name.replace(/\.capnp$/, ".js");
|
|
7844
7729
|
if (importPath[0] !== ".") {
|
|
@@ -7874,12 +7759,35 @@ async function compileAll(codeGenRequest, opts) {
|
|
|
7874
7759
|
const req = new Message(codeGenRequest, false).getRoot(
|
|
7875
7760
|
CodeGeneratorRequest
|
|
7876
7761
|
);
|
|
7762
|
+
console.log(
|
|
7763
|
+
`
|
|
7764
|
+
Running capnpc for ${req.requestedFiles.length} capnp schema files
|
|
7765
|
+
`
|
|
7766
|
+
);
|
|
7877
7767
|
const ctx = new CodeGeneratorContext();
|
|
7878
7768
|
ctx.files = req.requestedFiles.map((file) => loadRequestedFile(req, file));
|
|
7769
|
+
if (ctx.files.length === 0) {
|
|
7770
|
+
throw new Error(GEN_NO_FILES);
|
|
7771
|
+
}
|
|
7772
|
+
console.log(
|
|
7773
|
+
`
|
|
7774
|
+
Compiling ${ctx.files.length} files: ${ctx.files.map((f) => f.tsPath).join(", ")}
|
|
7775
|
+
`
|
|
7776
|
+
);
|
|
7879
7777
|
const files = new Map(
|
|
7880
7778
|
ctx.files.map((file) => [file.tsPath, compileFile(file)])
|
|
7881
7779
|
);
|
|
7882
|
-
|
|
7780
|
+
if (files.size === 0) {
|
|
7781
|
+
throw new Error(GEN_NO_FILES);
|
|
7782
|
+
}
|
|
7783
|
+
if (opts?.dts === true || opts?.js === true) {
|
|
7784
|
+
console.log(
|
|
7785
|
+
`
|
|
7786
|
+
TypeScript Compiling ${files.size} files: ${[...files.keys()].join(", ")}
|
|
7787
|
+
`
|
|
7788
|
+
);
|
|
7789
|
+
tsCompile(files, opts?.dts === true, opts?.js === true, opts?.tsconfig);
|
|
7790
|
+
}
|
|
7883
7791
|
if (!opts?.ts) {
|
|
7884
7792
|
for (const [fileName] of files) {
|
|
7885
7793
|
if (fileName.endsWith(".ts") && !fileName.endsWith(".d.ts")) {
|
|
@@ -7978,92 +7886,58 @@ function tsCompile(files, dts, js, tsconfig) {
|
|
|
7978
7886
|
}
|
|
7979
7887
|
__name(tsCompile, "tsCompile");
|
|
7980
7888
|
|
|
7981
|
-
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=
|
|
7889
|
+
// ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=824b6bae5f47936633f815d4ffa9019910937dad06e41df5249655046cadee7a_typescript@5.8.3/node_modules/capnp-es/dist/compiler/index.mjs
|
|
7982
7890
|
import "typescript";
|
|
7983
7891
|
|
|
7984
7892
|
// src/compile.ts
|
|
7985
7893
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
7986
7894
|
import { exec } from "node:child_process";
|
|
7987
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
7988
7895
|
async function capnpc(options) {
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
chunks.push(chunk);
|
|
7996
|
-
});
|
|
7997
|
-
await new Promise((resolve) => {
|
|
7998
|
-
process.stdin.on("end", resolve);
|
|
7999
|
-
});
|
|
8000
|
-
const reqBuffer = Buffer3.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
|
|
8001
|
-
let i = 0;
|
|
8002
|
-
for (const chunk of chunks) {
|
|
8003
|
-
chunk.copy(reqBuffer, i);
|
|
8004
|
-
i += chunk.byteLength;
|
|
8005
|
-
}
|
|
8006
|
-
dataBuf = reqBuffer;
|
|
8007
|
-
}
|
|
8008
|
-
if (dataBuf.byteLength === 0) {
|
|
8009
|
-
const opts = [];
|
|
8010
|
-
if (output) {
|
|
8011
|
-
opts.push(`-o-:${output}`);
|
|
8012
|
-
} else {
|
|
8013
|
-
opts.push("-o-");
|
|
8014
|
-
}
|
|
8015
|
-
dataBuf = await new Promise((resolve) => {
|
|
8016
|
-
exec(`capnpc ${opts.join(" ")} ${schema.join(" ")}`, {
|
|
8017
|
-
encoding: "buffer"
|
|
8018
|
-
}, (error, stdout, stderr) => {
|
|
8019
|
-
if (stderr.length > 0) {
|
|
8020
|
-
process.stderr.write(stderr);
|
|
8021
|
-
}
|
|
8022
|
-
if (error) {
|
|
8023
|
-
throw error;
|
|
8024
|
-
}
|
|
8025
|
-
resolve(stdout);
|
|
8026
|
-
});
|
|
8027
|
-
});
|
|
8028
|
-
}
|
|
8029
|
-
const result = await compileAll(dataBuf, {
|
|
8030
|
-
ts: options.ts ?? true,
|
|
8031
|
-
js: options.js ?? false,
|
|
8032
|
-
dts: options.dts ?? true,
|
|
8033
|
-
tsconfig: tsconfig?.options
|
|
7896
|
+
const { output, tsconfig, schemas = [], tty } = options;
|
|
7897
|
+
let dataBuf = Buffer3.alloc(0);
|
|
7898
|
+
if (tty) {
|
|
7899
|
+
const chunks = [];
|
|
7900
|
+
process.stdin.on("data", (chunk) => {
|
|
7901
|
+
chunks.push(chunk);
|
|
8034
7902
|
});
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
if (output) {
|
|
8044
|
-
filePath = joinPaths(output, fileName);
|
|
8045
|
-
}
|
|
8046
|
-
if (!existsSync3(findFilePath(filePath))) {
|
|
8047
|
-
await createDirectory(findFilePath(filePath));
|
|
8048
|
-
}
|
|
8049
|
-
await writeFile(
|
|
8050
|
-
filePath,
|
|
8051
|
-
// https://github.com/microsoft/TypeScript/issues/54632
|
|
8052
|
-
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
8053
|
-
);
|
|
7903
|
+
await new Promise((resolve) => {
|
|
7904
|
+
process.stdin.on("end", resolve);
|
|
7905
|
+
});
|
|
7906
|
+
const reqBuffer = Buffer3.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
|
|
7907
|
+
let i = 0;
|
|
7908
|
+
for (const chunk of chunks) {
|
|
7909
|
+
chunk.copy(reqBuffer, i);
|
|
7910
|
+
i += chunk.byteLength;
|
|
8054
7911
|
}
|
|
8055
|
-
|
|
8056
|
-
}
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
}
|
|
7912
|
+
dataBuf = reqBuffer;
|
|
7913
|
+
}
|
|
7914
|
+
if (dataBuf.byteLength === 0) {
|
|
7915
|
+
const opts = [];
|
|
7916
|
+
if (output) {
|
|
7917
|
+
opts.push(`-o-:${output}`);
|
|
8062
7918
|
} else {
|
|
8063
|
-
|
|
8064
|
-
}
|
|
8065
|
-
|
|
7919
|
+
opts.push("-o-");
|
|
7920
|
+
}
|
|
7921
|
+
dataBuf = await new Promise((resolve) => {
|
|
7922
|
+
exec(`capnpc ${opts.join(" ")} ${schemas.join(" ")}`, {
|
|
7923
|
+
encoding: "buffer"
|
|
7924
|
+
}, (error, stdout, stderr) => {
|
|
7925
|
+
if (stderr.length > 0) {
|
|
7926
|
+
process.stderr.write(stderr);
|
|
7927
|
+
}
|
|
7928
|
+
if (error) {
|
|
7929
|
+
throw error;
|
|
7930
|
+
}
|
|
7931
|
+
resolve(stdout);
|
|
7932
|
+
});
|
|
7933
|
+
});
|
|
8066
7934
|
}
|
|
7935
|
+
return compileAll(dataBuf, {
|
|
7936
|
+
ts: options.ts ?? true,
|
|
7937
|
+
js: false,
|
|
7938
|
+
dts: false,
|
|
7939
|
+
tsconfig: tsconfig?.options
|
|
7940
|
+
});
|
|
8067
7941
|
}
|
|
8068
7942
|
__name(capnpc, "capnpc");
|
|
8069
7943
|
|
|
@@ -8080,9 +7954,13 @@ function createProgram() {
|
|
|
8080
7954
|
}
|
|
8081
7955
|
const program = new Command("storm-capnpc");
|
|
8082
7956
|
program.version("1.0.0", "-v --version", "display CLI version");
|
|
7957
|
+
const projectRootOption = new Option("-p --project-root <path>", "The path to the project root directory");
|
|
8083
7958
|
const tsOption = new Option("--ts", "An indicator to generate TypeScript files").default(true);
|
|
7959
|
+
const noTsOption = new Option("--no-ts", "An indicator to disable generation of TypeScript files");
|
|
8084
7960
|
const jsOption = new Option("--js", "An indicator to generate JavaScript files").default(false);
|
|
8085
|
-
const dtsOption = new Option("--dts", "An indicator to generate TypeScript declaration files")
|
|
7961
|
+
const dtsOption = new Option("--dts", "An indicator to generate TypeScript declaration files");
|
|
7962
|
+
const noDtsOption = new Option("--no-dts", "An indicator to disable generation of TypeScript declaration files");
|
|
7963
|
+
const ttyOption = new Option("--tty", "An indicator to enable TTY mode for the compiler");
|
|
8086
7964
|
const importPathOption = new Option("-I --import-path <dir...>", "Add <dir> to the list of directories searched for non-relative imports").default([]).argParser((val) => {
|
|
8087
7965
|
if (val.startsWith("-I") || val.startsWith("--import-path")) {
|
|
8088
7966
|
return val.split(",").map((dir) => dir.trim());
|
|
@@ -8093,54 +7971,47 @@ function createProgram() {
|
|
|
8093
7971
|
});
|
|
8094
7972
|
const generateId = new Option("-i --generate-id", "Generate a new 64-bit unique ID for use in a Cap'n Proto schema").default(true);
|
|
8095
7973
|
const standardImportOption = new Option("--standard-import", "Add default import paths; use only those specified by -I").default(true);
|
|
8096
|
-
const schemaOption = new Option("-s --schema <path
|
|
8097
|
-
joinPaths(process.cwd(), "**/*.capnp")
|
|
8098
|
-
]).argParser((val) => {
|
|
8099
|
-
let result = [];
|
|
8100
|
-
if (val.startsWith("--schema") || val.startsWith("-s")) {
|
|
8101
|
-
result = val.split(",").map((dir) => dir.trim());
|
|
8102
|
-
}
|
|
8103
|
-
result = [
|
|
8104
|
-
val.trim()
|
|
8105
|
-
];
|
|
8106
|
-
return result.map((dir) => dir.endsWith(".capnp") ? dir : joinPaths(dir, "**/*.capnp"));
|
|
8107
|
-
});
|
|
7974
|
+
const schemaOption = new 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"));
|
|
8108
7975
|
const outputOption = new Option("-o --output <path>", "The directory to output the generated files to");
|
|
8109
|
-
const tsconfigOption = new Option("
|
|
7976
|
+
const tsconfigOption = new Option("--tsconfig <path>", "The path to the TypeScript configuration file to use for compilation").default(joinPaths("{projectRoot}", "tsconfig.json"));
|
|
8110
7977
|
const workspaceRootOption = new Option("-w --workspace-root <path>", "The path to the workspace root directory").default(root);
|
|
8111
7978
|
program.command("compile", {
|
|
8112
7979
|
isDefault: true
|
|
8113
|
-
}).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).addOption(workspaceRootOption).action(compileAction).showSuggestionAfterError(true).showHelpAfterError(true);
|
|
7980
|
+
}).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);
|
|
8114
7981
|
return program;
|
|
8115
7982
|
}
|
|
8116
7983
|
__name(createProgram, "createProgram");
|
|
8117
7984
|
async function compileAction(options) {
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
writeFatal(
|
|
7985
|
+
const tsconfigPath = options.tsconfig.replace("{projectRoot}", options.projectRoot);
|
|
7986
|
+
const schema = options.schema ? options.schema.replace("{projectRoot}", options.projectRoot) : options.projectRoot;
|
|
7987
|
+
if (!existsSync(tsconfigPath)) {
|
|
7988
|
+
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.";
|
|
7989
|
+
writeFatal(errorMessage, {
|
|
8123
7990
|
logLevel: "all"
|
|
8124
7991
|
});
|
|
8125
|
-
|
|
7992
|
+
throw new Error(errorMessage);
|
|
8126
7993
|
}
|
|
8127
|
-
const resolvedTsconfig = await readJsonFile(
|
|
8128
|
-
const tsconfig = ts2.parseJsonConfigFileContent(resolvedTsconfig, ts2.sys, findFilePath(
|
|
8129
|
-
tsconfig.options.configFilePath =
|
|
7994
|
+
const resolvedTsconfig = await readJsonFile(tsconfigPath);
|
|
7995
|
+
const tsconfig = ts2.parseJsonConfigFileContent(resolvedTsconfig, ts2.sys, findFilePath(tsconfigPath));
|
|
7996
|
+
tsconfig.options.configFilePath = tsconfigPath;
|
|
8130
7997
|
tsconfig.options.noImplicitOverride = false;
|
|
8131
|
-
tsconfig.options.
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
}
|
|
8140
|
-
|
|
7998
|
+
tsconfig.options.noUnusedLocals = false;
|
|
7999
|
+
tsconfig.options.noUnusedParameters = false;
|
|
8000
|
+
tsconfig.options.outDir = joinPaths(options.projectRoot, relativePath(findFilePath(tsconfigPath), joinPaths(options.workspaceRoot, schema.endsWith(".capnp") ? findFilePath(schema) : schema)));
|
|
8001
|
+
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}...`, {
|
|
8002
|
+
logLevel: "all"
|
|
8003
|
+
});
|
|
8004
|
+
const schemas = [];
|
|
8005
|
+
if (!schema || !schema.includes("*") && !existsSync(schema)) {
|
|
8006
|
+
const errorMessage = `\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`;
|
|
8007
|
+
writeFatal(errorMessage, {
|
|
8008
|
+
logLevel: "all"
|
|
8009
|
+
});
|
|
8010
|
+
throw new Error(errorMessage);
|
|
8141
8011
|
}
|
|
8142
|
-
|
|
8143
|
-
|
|
8012
|
+
schemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
8013
|
+
if (schemas.length === 0) {
|
|
8014
|
+
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.`, {
|
|
8144
8015
|
logLevel: "all"
|
|
8145
8016
|
});
|
|
8146
8017
|
return;
|
|
@@ -8148,14 +8019,39 @@ async function compileAction(options) {
|
|
|
8148
8019
|
const result = await capnpc({
|
|
8149
8020
|
...options,
|
|
8150
8021
|
tsconfig,
|
|
8151
|
-
|
|
8022
|
+
schemas,
|
|
8023
|
+
ts: options.ts ?? (options.noTs !== void 0 ? !options.noTs : true),
|
|
8024
|
+
dts: options.dts ?? (options.noDts !== void 0 ? !options.noDts : true)
|
|
8152
8025
|
});
|
|
8153
8026
|
if (result.files.size === 0) {
|
|
8154
|
-
|
|
8027
|
+
writeWarning("\u26A0\uFE0F No files were generated. Please check your schema files.", {
|
|
8155
8028
|
logLevel: "all"
|
|
8156
8029
|
});
|
|
8157
8030
|
return;
|
|
8158
8031
|
}
|
|
8032
|
+
writeInfo(`Writing ${result.files.size} generated files to disk...`, {
|
|
8033
|
+
logLevel: "all"
|
|
8034
|
+
});
|
|
8035
|
+
for (const [fileName, content] of result.files) {
|
|
8036
|
+
let filePath = fileName;
|
|
8037
|
+
if (!existsSync(findFilePath(filePath))) {
|
|
8038
|
+
const fullPath = `/${filePath}`;
|
|
8039
|
+
if (existsSync(findFilePath(fullPath))) {
|
|
8040
|
+
filePath = fullPath;
|
|
8041
|
+
}
|
|
8042
|
+
}
|
|
8043
|
+
if (options.output) {
|
|
8044
|
+
filePath = joinPaths(options.output, fileName);
|
|
8045
|
+
}
|
|
8046
|
+
if (!existsSync(findFilePath(filePath))) {
|
|
8047
|
+
await createDirectory(findFilePath(filePath));
|
|
8048
|
+
}
|
|
8049
|
+
await writeFile2(
|
|
8050
|
+
filePath,
|
|
8051
|
+
// https://github.com/microsoft/TypeScript/issues/54632
|
|
8052
|
+
content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
|
|
8053
|
+
);
|
|
8054
|
+
}
|
|
8159
8055
|
writeSuccess("\u26A1 Storm Cap'n Proto Compiler completed successfully.", {
|
|
8160
8056
|
logLevel: "all"
|
|
8161
8057
|
});
|