@stryke/capnp 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/bin/capnpc.cjs +1179 -0
  2. package/bin/capnpc.js +1146 -0
  3. package/dist/chunk-LY3GWW4E.js +977 -0
  4. package/dist/chunk-ORA4UQMU.cjs +1 -0
  5. package/dist/chunk-OULCUN6I.js +0 -0
  6. package/dist/chunk-PV3OG5H3.cjs +977 -0
  7. package/dist/chunk-SHUYVCID.js +6 -0
  8. package/dist/chunk-USNT2KNT.cjs +6 -0
  9. package/dist/compile.cjs +7 -0
  10. package/dist/compile.js +7 -0
  11. package/dist/index.cjs +8 -0
  12. package/dist/index.js +8 -0
  13. package/dist/rpc.cjs +103 -0
  14. package/dist/rpc.d.cts +42 -0
  15. package/dist/rpc.d.ts +42 -0
  16. package/dist/rpc.js +103 -0
  17. package/dist/types.cjs +1 -0
  18. package/dist/types.js +1 -0
  19. package/package.json +19 -2
  20. package/dist/bin/capnpc.cjs +0 -11269
  21. package/dist/bin/capnpc.d.cts +0 -6
  22. package/dist/bin/capnpc.d.ts +0 -6
  23. package/dist/bin/capnpc.js +0 -11266
  24. package/dist/chunk-E5KOPL7Q.cjs +0 -6
  25. package/dist/chunk-EK5N4FAF.js +0 -55
  26. package/dist/chunk-IWTVA3JL.cjs +0 -104
  27. package/dist/chunk-QKE2ND5U.js +0 -104
  28. package/dist/chunk-TE2KW23K.cjs +0 -55
  29. package/dist/chunk-UQ2KKHLM.js +0 -6
  30. package/dist/src/compile.cjs +0 -7
  31. package/dist/src/compile.js +0 -7
  32. package/dist/src/index.cjs +0 -13
  33. package/dist/src/index.js +0 -13
  34. package/dist/src/types.cjs +0 -2
  35. package/dist/src/types.js +0 -2
  36. /package/dist/{src/compile.d.cts → compile.d.cts} +0 -0
  37. /package/dist/{src/compile.d.ts → compile.d.ts} +0 -0
  38. /package/dist/{src/index.d.cts → index.d.cts} +0 -0
  39. /package/dist/{src/index.d.ts → index.d.ts} +0 -0
  40. /package/dist/{src/types.d.cts → types.d.cts} +0 -0
  41. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
package/bin/capnpc.cjs ADDED
@@ -0,0 +1,1179 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // bin/capnpc.ts
33
+ var capnpc_exports = {};
34
+ __export(capnpc_exports, {
35
+ createProgram: () => createProgram
36
+ });
37
+ module.exports = __toCommonJS(capnpc_exports);
38
+ var import_console = require("@storm-software/config-tools/logger/console");
39
+ var import_utilities = require("@storm-software/config-tools/utilities");
40
+
41
+ // ../fs/src/list-files.ts
42
+ var import_defu = __toESM(require("defu"), 1);
43
+ var import_glob = require("glob");
44
+ var DEFAULT_OPTIONS = {
45
+ dot: true
46
+ };
47
+ async function list(filesGlob, options) {
48
+ return (0, import_glob.glob)(filesGlob, (0, import_defu.default)(options ?? {}, DEFAULT_OPTIONS));
49
+ }
50
+ __name(list, "list");
51
+ async function listFiles(filesGlob, options) {
52
+ const result = (await list(filesGlob, (0, import_defu.default)({
53
+ withFileTypes: true
54
+ }, options ?? {}))).filter((ret) => ret.isFile());
55
+ if (!options?.withFileTypes) {
56
+ return result.map((file) => file.fullpath());
57
+ }
58
+ return result;
59
+ }
60
+ __name(listFiles, "listFiles");
61
+
62
+ // ../fs/src/read-file.ts
63
+ var import_j_toml = require("@ltd/j-toml");
64
+
65
+ // ../type-checks/src/get-object-tag.ts
66
+ var getObjectTag = /* @__PURE__ */ __name((value) => {
67
+ if (value == null) {
68
+ return value === void 0 ? "[object Undefined]" : "[object Null]";
69
+ }
70
+ return Object.prototype.toString.call(value);
71
+ }, "getObjectTag");
72
+
73
+ // ../type-checks/src/is-plain-object.ts
74
+ var isObjectLike = /* @__PURE__ */ __name((obj) => {
75
+ return typeof obj === "object" && obj !== null;
76
+ }, "isObjectLike");
77
+ var isPlainObject = /* @__PURE__ */ __name((obj) => {
78
+ if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") {
79
+ return false;
80
+ }
81
+ if (Object.getPrototypeOf(obj) === null) {
82
+ return true;
83
+ }
84
+ let proto = obj;
85
+ while (Object.getPrototypeOf(proto) !== null) {
86
+ proto = Object.getPrototypeOf(proto);
87
+ }
88
+ return Object.getPrototypeOf(obj) === proto;
89
+ }, "isPlainObject");
90
+
91
+ // ../type-checks/src/is-object.ts
92
+ var isObject = /* @__PURE__ */ __name((value) => {
93
+ try {
94
+ return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
95
+ } catch {
96
+ return false;
97
+ }
98
+ }, "isObject");
99
+
100
+ // ../type-checks/src/is-string.ts
101
+ var isString = /* @__PURE__ */ __name((value) => {
102
+ try {
103
+ return typeof value === "string";
104
+ } catch {
105
+ return false;
106
+ }
107
+ }, "isString");
108
+
109
+ // ../json/src/storm-json.ts
110
+ var import_jsonc_parser2 = require("jsonc-parser");
111
+ var import_node_buffer = require("buffer");
112
+ var import_superjson = __toESM(require("superjson"), 1);
113
+
114
+ // ../types/src/base.ts
115
+ var EMPTY_STRING = "";
116
+ var $NestedValue = Symbol("NestedValue");
117
+
118
+ // ../json/src/utils/strip-comments.ts
119
+ var singleComment = Symbol("singleComment");
120
+ var multiComment = Symbol("multiComment");
121
+ function stripWithoutWhitespace() {
122
+ return "";
123
+ }
124
+ __name(stripWithoutWhitespace, "stripWithoutWhitespace");
125
+ function stripWithWhitespace(value, start, end) {
126
+ return value.slice(start, end).replace(/\S/g, " ");
127
+ }
128
+ __name(stripWithWhitespace, "stripWithWhitespace");
129
+ function isEscaped(value, quotePosition) {
130
+ let index = quotePosition - 1;
131
+ let backslashCount = 0;
132
+ while (value[index] === "\\") {
133
+ index -= 1;
134
+ backslashCount += 1;
135
+ }
136
+ return Boolean(backslashCount % 2);
137
+ }
138
+ __name(isEscaped, "isEscaped");
139
+ function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
140
+ if (typeof value !== "string") {
141
+ throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
142
+ }
143
+ const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
144
+ let isInsideString = false;
145
+ let isInsideComment = false;
146
+ let offset = 0;
147
+ let buffer = "";
148
+ let result = "";
149
+ let commaIndex = -1;
150
+ for (let index = 0; index < value.length; index++) {
151
+ const currentCharacter = value[index];
152
+ const nextCharacter = value[index + 1];
153
+ if (!isInsideComment && currentCharacter === '"') {
154
+ const escaped = isEscaped(value, index);
155
+ if (!escaped) {
156
+ isInsideString = !isInsideString;
157
+ }
158
+ }
159
+ if (isInsideString) {
160
+ continue;
161
+ }
162
+ if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "//") {
163
+ buffer += value.slice(offset, index);
164
+ offset = index;
165
+ isInsideComment = singleComment;
166
+ index++;
167
+ } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "\r\n") {
168
+ index++;
169
+ isInsideComment = false;
170
+ buffer += strip(value, offset, index);
171
+ offset = index;
172
+ } else if (isInsideComment === singleComment && currentCharacter === "\n") {
173
+ isInsideComment = false;
174
+ buffer += strip(value, offset, index);
175
+ offset = index;
176
+ } else if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "/*") {
177
+ buffer += value.slice(offset, index);
178
+ offset = index;
179
+ isInsideComment = multiComment;
180
+ index++;
181
+ } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "*/") {
182
+ index++;
183
+ isInsideComment = false;
184
+ buffer += strip(value, offset, index + 1);
185
+ offset = index + 1;
186
+ } else if (trailingCommas && !isInsideComment) {
187
+ if (commaIndex !== -1) {
188
+ if (currentCharacter === "}" || currentCharacter === "]") {
189
+ buffer += value.slice(offset, index);
190
+ result += strip(buffer, 0, 1) + buffer.slice(1);
191
+ buffer = "";
192
+ offset = index;
193
+ commaIndex = -1;
194
+ } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
195
+ buffer += value.slice(offset, index);
196
+ offset = index;
197
+ commaIndex = -1;
198
+ }
199
+ } else if (currentCharacter === ",") {
200
+ result += buffer + value.slice(offset, index);
201
+ buffer = "";
202
+ offset = index;
203
+ commaIndex = index;
204
+ }
205
+ }
206
+ }
207
+ return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
208
+ }
209
+ __name(stripComments, "stripComments");
210
+
211
+ // ../json/src/utils/parse.ts
212
+ var suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
213
+ var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
214
+ var JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
215
+ function jsonParseTransform(key, value) {
216
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
217
+ console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
218
+ return;
219
+ }
220
+ return value;
221
+ }
222
+ __name(jsonParseTransform, "jsonParseTransform");
223
+ function parse(value, options = {}) {
224
+ if (typeof value !== "string") {
225
+ return value;
226
+ }
227
+ let stripped = stripComments(value);
228
+ if (stripped[0] === '"' && stripped[stripped.length - 1] === '"' && !stripped.includes("\\")) {
229
+ return stripped.slice(1, -1);
230
+ }
231
+ stripped = stripped.trim();
232
+ if (stripped.length <= 9) {
233
+ switch (stripped.toLowerCase()) {
234
+ case "true": {
235
+ return true;
236
+ }
237
+ case "false": {
238
+ return false;
239
+ }
240
+ case "undefined": {
241
+ return void 0;
242
+ }
243
+ case "null": {
244
+ return null;
245
+ }
246
+ case "nan": {
247
+ return Number.NaN;
248
+ }
249
+ case "infinity": {
250
+ return Number.POSITIVE_INFINITY;
251
+ }
252
+ case "-infinity": {
253
+ return Number.NEGATIVE_INFINITY;
254
+ }
255
+ }
256
+ }
257
+ if (!JsonSigRx.test(stripped)) {
258
+ if (options.strict) {
259
+ throw new Error("Invalid JSON");
260
+ }
261
+ return stripped;
262
+ }
263
+ try {
264
+ if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
265
+ if (options.strict) {
266
+ throw new Error("Possible prototype pollution");
267
+ }
268
+ return JSON.parse(stripped, jsonParseTransform);
269
+ }
270
+ return JSON.parse(stripped);
271
+ } catch (error) {
272
+ if (options.strict) {
273
+ throw error;
274
+ }
275
+ return value;
276
+ }
277
+ }
278
+ __name(parse, "parse");
279
+
280
+ // ../json/src/utils/parse-error.ts
281
+ var import_jsonc_parser = require("jsonc-parser");
282
+ var import_lines_and_columns = require("lines-and-columns");
283
+
284
+ // ../json/src/utils/code-frames.ts
285
+ var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
286
+ function getMarkerLines(loc, source, opts = {}) {
287
+ const startLoc = {
288
+ column: 0,
289
+ line: -1,
290
+ ...loc.start
291
+ };
292
+ const endLoc = {
293
+ ...startLoc,
294
+ ...loc.end
295
+ };
296
+ const { linesAbove = 2, linesBelow = 3 } = opts || {};
297
+ const startLine = startLoc.line;
298
+ const startColumn = startLoc.column;
299
+ const endLine = endLoc.line;
300
+ const endColumn = endLoc.column;
301
+ let start = Math.max(startLine - (linesAbove + 1), 0);
302
+ let end = Math.min(source.length, endLine + linesBelow);
303
+ if (startLine === -1) {
304
+ start = 0;
305
+ }
306
+ if (endLine === -1) {
307
+ end = source.length;
308
+ }
309
+ const lineDiff = endLine - startLine;
310
+ const markerLines = {};
311
+ if (lineDiff) {
312
+ for (let i = 0; i <= lineDiff; i++) {
313
+ const lineNumber = i + startLine;
314
+ if (!startColumn) {
315
+ markerLines[lineNumber] = true;
316
+ } else if (i === 0) {
317
+ const sourceLength = source[lineNumber - 1]?.length ?? 0;
318
+ markerLines[lineNumber] = [
319
+ startColumn,
320
+ sourceLength - startColumn + 1
321
+ ];
322
+ } else if (i === lineDiff) {
323
+ markerLines[lineNumber] = [
324
+ 0,
325
+ endColumn
326
+ ];
327
+ } else {
328
+ const sourceLength = source[lineNumber - i]?.length ?? 0;
329
+ markerLines[lineNumber] = [
330
+ 0,
331
+ sourceLength
332
+ ];
333
+ }
334
+ }
335
+ } else if (startColumn === endColumn) {
336
+ markerLines[startLine] = startColumn ? [
337
+ startColumn,
338
+ 0
339
+ ] : true;
340
+ } else {
341
+ markerLines[startLine] = [
342
+ startColumn,
343
+ endColumn - startColumn
344
+ ];
345
+ }
346
+ return {
347
+ start,
348
+ end,
349
+ markerLines
350
+ };
351
+ }
352
+ __name(getMarkerLines, "getMarkerLines");
353
+ function codeFrameColumns(rawLines, loc, opts = {}) {
354
+ const lines = rawLines.split(NEWLINE);
355
+ const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
356
+ const numberMaxWidth = String(end).length;
357
+ const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;
358
+ const frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
359
+ const number = start + 1 + index;
360
+ const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
361
+ const gutter = ` ${paddedNumber} | `;
362
+ const hasMarker = Boolean(markerLines[number] ?? false);
363
+ if (hasMarker) {
364
+ let markerLine = "";
365
+ if (Array.isArray(hasMarker)) {
366
+ const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
367
+ const numberOfMarkers = hasMarker[1] || 1;
368
+ markerLine = [
369
+ "\n ",
370
+ gutter.replace(/\d/g, " "),
371
+ markerSpacing,
372
+ "^".repeat(numberOfMarkers)
373
+ ].join("");
374
+ }
375
+ return [
376
+ ">",
377
+ gutter,
378
+ line,
379
+ markerLine
380
+ ].join("");
381
+ }
382
+ return ` ${gutter}${line}`;
383
+ }).join("\n");
384
+ return frame;
385
+ }
386
+ __name(codeFrameColumns, "codeFrameColumns");
387
+
388
+ // ../json/src/utils/parse-error.ts
389
+ function formatParseError(input, parseError) {
390
+ const { error, offset, length } = parseError;
391
+ const result = new import_lines_and_columns.LinesAndColumns(input).locationForIndex(offset);
392
+ let line = result?.line ?? 0;
393
+ let column = result?.column ?? 0;
394
+ line++;
395
+ column++;
396
+ return `${(0, import_jsonc_parser.printParseErrorCode)(error)} in JSON at ${line}:${column}
397
+ ${codeFrameColumns(input, {
398
+ start: {
399
+ line,
400
+ column
401
+ },
402
+ end: {
403
+ line,
404
+ column: column + length
405
+ }
406
+ })}
407
+ `;
408
+ }
409
+ __name(formatParseError, "formatParseError");
410
+
411
+ // ../type-checks/src/is-number.ts
412
+ var isNumber = /* @__PURE__ */ __name((value) => {
413
+ try {
414
+ return value instanceof Number || typeof value === "number" || Number(value) === value;
415
+ } catch {
416
+ return false;
417
+ }
418
+ }, "isNumber");
419
+
420
+ // ../type-checks/src/is-undefined.ts
421
+ var isUndefined = /* @__PURE__ */ __name((value) => {
422
+ return value === void 0;
423
+ }, "isUndefined");
424
+
425
+ // ../json/src/utils/stringify.ts
426
+ var invalidKeyChars = [
427
+ "@",
428
+ "/",
429
+ "#",
430
+ "$",
431
+ " ",
432
+ ":",
433
+ ";",
434
+ ",",
435
+ ".",
436
+ "!",
437
+ "?",
438
+ "&",
439
+ "=",
440
+ "+",
441
+ "-",
442
+ "*",
443
+ "%",
444
+ "^",
445
+ "~",
446
+ "|",
447
+ "\\",
448
+ '"',
449
+ "'",
450
+ "`",
451
+ "{",
452
+ "}",
453
+ "[",
454
+ "]",
455
+ "(",
456
+ ")",
457
+ "<",
458
+ ">"
459
+ ];
460
+ var stringify = /* @__PURE__ */ __name((value, spacing = 2) => {
461
+ const space = isNumber(spacing) ? " ".repeat(spacing) : spacing;
462
+ switch (value) {
463
+ case null: {
464
+ return "null";
465
+ }
466
+ case void 0: {
467
+ return '"undefined"';
468
+ }
469
+ case true: {
470
+ return "true";
471
+ }
472
+ case false: {
473
+ return "false";
474
+ }
475
+ case Number.POSITIVE_INFINITY: {
476
+ return "infinity";
477
+ }
478
+ case Number.NEGATIVE_INFINITY: {
479
+ return "-infinity";
480
+ }
481
+ }
482
+ if (Array.isArray(value)) {
483
+ return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
484
+ }
485
+ if (value instanceof Uint8Array) {
486
+ return value.toString();
487
+ }
488
+ switch (typeof value) {
489
+ case "number": {
490
+ return `${value}`;
491
+ }
492
+ case "string": {
493
+ return JSON.stringify(value);
494
+ }
495
+ case "object": {
496
+ const keys = Object.keys(value).filter((key) => !isUndefined(value[key]));
497
+ return `{${space}${keys.map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
498
+ }
499
+ default:
500
+ return "null";
501
+ }
502
+ }, "stringify");
503
+
504
+ // ../json/src/storm-json.ts
505
+ var StormJSON = class _StormJSON extends import_superjson.default {
506
+ static {
507
+ __name(this, "StormJSON");
508
+ }
509
+ static #instance;
510
+ static get instance() {
511
+ if (!_StormJSON.#instance) {
512
+ _StormJSON.#instance = new _StormJSON();
513
+ }
514
+ return _StormJSON.#instance;
515
+ }
516
+ /**
517
+ * Deserialize the given value with superjson using the given metadata
518
+ */
519
+ static deserialize(payload) {
520
+ return _StormJSON.instance.deserialize(payload);
521
+ }
522
+ /**
523
+ * Serialize the given value with superjson
524
+ */
525
+ static serialize(object) {
526
+ return _StormJSON.instance.serialize(object);
527
+ }
528
+ /**
529
+ * Parse the given string value with superjson using the given metadata
530
+ *
531
+ * @param value - The string value to parse
532
+ * @returns The parsed data
533
+ */
534
+ static parse(value) {
535
+ return parse(value);
536
+ }
537
+ /**
538
+ * Serializes the given data to a JSON string.
539
+ * By default the JSON string is formatted with a 2 space indentation to be easy readable.
540
+ *
541
+ * @param value - Object which should be serialized to JSON
542
+ * @param _options - JSON serialize options
543
+ * @returns the formatted JSON representation of the object
544
+ */
545
+ static stringify(value, _options) {
546
+ const customTransformer = _StormJSON.instance.customTransformerRegistry.findApplicable(value);
547
+ let result = value;
548
+ if (customTransformer && customTransformer.isApplicable(value)) {
549
+ result = customTransformer.serialize(result);
550
+ }
551
+ return stringify(result);
552
+ }
553
+ /**
554
+ * Parses the given JSON string and returns the object the JSON content represents.
555
+ * By default javascript-style comments and trailing commas are allowed.
556
+ *
557
+ * @param strData - JSON content as string
558
+ * @param options - JSON parse options
559
+ * @returns Object the JSON content represents
560
+ */
561
+ static parseJson(strData, options) {
562
+ try {
563
+ if (options?.expectComments === false) {
564
+ return _StormJSON.instance.parse(strData);
565
+ }
566
+ } catch {
567
+ }
568
+ const errors = [];
569
+ const opts = {
570
+ allowTrailingComma: true,
571
+ ...options
572
+ };
573
+ const result = (0, import_jsonc_parser2.parse)(strData, errors, opts);
574
+ if (errors.length > 0 && errors[0]) {
575
+ throw new Error(formatParseError(strData, errors[0]));
576
+ }
577
+ return result;
578
+ }
579
+ /**
580
+ * Register a custom schema with superjson
581
+ *
582
+ * @param name - The name of the schema
583
+ * @param serialize - The function to serialize the schema
584
+ * @param deserialize - The function to deserialize the schema
585
+ * @param isApplicable - The function to check if the schema is applicable
586
+ */
587
+ static register(name, serialize, deserialize, isApplicable) {
588
+ _StormJSON.instance.registerCustom({
589
+ isApplicable,
590
+ serialize,
591
+ deserialize
592
+ }, name);
593
+ }
594
+ /**
595
+ * Register a class with superjson
596
+ *
597
+ * @param classConstructor - The class constructor to register
598
+ */
599
+ static registerClass(classConstructor, options) {
600
+ _StormJSON.instance.registerClass(classConstructor, {
601
+ identifier: isString(options) ? options : options?.identifier || classConstructor.name,
602
+ allowProps: options && isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : [
603
+ "__typename"
604
+ ]
605
+ });
606
+ }
607
+ constructor() {
608
+ super({
609
+ dedupe: true
610
+ });
611
+ }
612
+ };
613
+ StormJSON.instance.registerCustom({
614
+ isApplicable: /* @__PURE__ */ __name((v) => import_node_buffer.Buffer.isBuffer(v), "isApplicable"),
615
+ serialize: /* @__PURE__ */ __name((v) => v.toString("base64"), "serialize"),
616
+ deserialize: /* @__PURE__ */ __name((v) => import_node_buffer.Buffer.from(v, "base64"), "deserialize")
617
+ }, "Bytes");
618
+
619
+ // ../type-checks/src/is-error.ts
620
+ var isError = /* @__PURE__ */ __name((obj) => {
621
+ if (!isObject(obj)) {
622
+ return false;
623
+ }
624
+ const tag = getObjectTag(obj);
625
+ return tag === "[object Error]" || tag === "[object DOMException]" || typeof obj?.message === "string" && typeof obj?.name === "string" && !isPlainObject(obj);
626
+ }, "isError");
627
+
628
+ // ../fs/src/read-file.ts
629
+ var import_node_fs = require("fs");
630
+ var import_promises = require("fs/promises");
631
+ var readFile = /* @__PURE__ */ __name(async (filePath) => {
632
+ try {
633
+ if (!filePath) {
634
+ throw new Error("No file path provided to read data");
635
+ }
636
+ return await (0, import_promises.readFile)(filePath, {
637
+ encoding: "utf8"
638
+ });
639
+ } catch {
640
+ throw new Error("An error occurred writing data to file");
641
+ }
642
+ }, "readFile");
643
+ async function readJsonFile(path, options) {
644
+ const content = await readFile(path);
645
+ if (options) {
646
+ options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
647
+ }
648
+ try {
649
+ return StormJSON.parseJson(content, options);
650
+ } catch (error) {
651
+ if (isError(error)) {
652
+ error.message = error.message.replace("JSON", path);
653
+ throw error;
654
+ }
655
+ throw new Error(`Failed to parse JSON: ${path}`);
656
+ }
657
+ }
658
+ __name(readJsonFile, "readJsonFile");
659
+
660
+ // ../path/src/file-path-fns.ts
661
+ var import_node_path = require("path");
662
+
663
+ // ../path/src/is-file.ts
664
+ var import_node_fs2 = require("fs");
665
+
666
+ // ../path/src/join-paths.ts
667
+ var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
668
+ function normalizeWindowsPath(input = "") {
669
+ if (!input) {
670
+ return input;
671
+ }
672
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
673
+ }
674
+ __name(normalizeWindowsPath, "normalizeWindowsPath");
675
+ var _UNC_REGEX = /^[/\\]{2}/;
676
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
677
+ var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
678
+ var isAbsolute = /* @__PURE__ */ __name(function(p) {
679
+ return _IS_ABSOLUTE_RE.test(p);
680
+ }, "isAbsolute");
681
+ var correctPaths = /* @__PURE__ */ __name(function(path) {
682
+ if (!path || path.length === 0) {
683
+ return ".";
684
+ }
685
+ path = normalizeWindowsPath(path);
686
+ const isUNCPath = path.match(_UNC_REGEX);
687
+ const isPathAbsolute = isAbsolute(path);
688
+ const trailingSeparator = path[path.length - 1] === "/";
689
+ path = normalizeString(path, !isPathAbsolute);
690
+ if (path.length === 0) {
691
+ if (isPathAbsolute) {
692
+ return "/";
693
+ }
694
+ return trailingSeparator ? "./" : ".";
695
+ }
696
+ if (trailingSeparator) {
697
+ path += "/";
698
+ }
699
+ if (_DRIVE_LETTER_RE.test(path)) {
700
+ path += "/";
701
+ }
702
+ if (isUNCPath) {
703
+ if (!isPathAbsolute) {
704
+ return `//./${path}`;
705
+ }
706
+ return `//${path}`;
707
+ }
708
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
709
+ }, "correctPaths");
710
+ var joinPaths = /* @__PURE__ */ __name(function(...segments) {
711
+ let path = "";
712
+ for (const seg of segments) {
713
+ if (!seg) {
714
+ continue;
715
+ }
716
+ if (path.length > 0) {
717
+ const pathTrailing = path[path.length - 1] === "/";
718
+ const segLeading = seg[0] === "/";
719
+ const both = pathTrailing && segLeading;
720
+ if (both) {
721
+ path += seg.slice(1);
722
+ } else {
723
+ path += pathTrailing || segLeading ? seg : `/${seg}`;
724
+ }
725
+ } else {
726
+ path += seg;
727
+ }
728
+ }
729
+ return correctPaths(path);
730
+ }, "joinPaths");
731
+ function normalizeString(path, allowAboveRoot) {
732
+ let res = "";
733
+ let lastSegmentLength = 0;
734
+ let lastSlash = -1;
735
+ let dots = 0;
736
+ let char = null;
737
+ for (let index = 0; index <= path.length; ++index) {
738
+ if (index < path.length) {
739
+ char = path[index];
740
+ } else if (char === "/") {
741
+ break;
742
+ } else {
743
+ char = "/";
744
+ }
745
+ if (char === "/") {
746
+ if (lastSlash === index - 1 || dots === 1) {
747
+ } else if (dots === 2) {
748
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
749
+ if (res.length > 2) {
750
+ const lastSlashIndex = res.lastIndexOf("/");
751
+ if (lastSlashIndex === -1) {
752
+ res = "";
753
+ lastSegmentLength = 0;
754
+ } else {
755
+ res = res.slice(0, lastSlashIndex);
756
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
757
+ }
758
+ lastSlash = index;
759
+ dots = 0;
760
+ continue;
761
+ } else if (res.length > 0) {
762
+ res = "";
763
+ lastSegmentLength = 0;
764
+ lastSlash = index;
765
+ dots = 0;
766
+ continue;
767
+ }
768
+ }
769
+ if (allowAboveRoot) {
770
+ res += res.length > 0 ? "/.." : "..";
771
+ lastSegmentLength = 2;
772
+ }
773
+ } else {
774
+ if (res.length > 0) {
775
+ res += `/${path.slice(lastSlash + 1, index)}`;
776
+ } else {
777
+ res = path.slice(lastSlash + 1, index);
778
+ }
779
+ lastSegmentLength = index - lastSlash - 1;
780
+ }
781
+ lastSlash = index;
782
+ dots = 0;
783
+ } else if (char === "." && dots !== -1) {
784
+ ++dots;
785
+ } else {
786
+ dots = -1;
787
+ }
788
+ }
789
+ return res;
790
+ }
791
+ __name(normalizeString, "normalizeString");
792
+
793
+ // ../path/src/regex.ts
794
+ var DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
795
+ var DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
796
+ var UNC_REGEX = /^[/\\]{2}/;
797
+ var ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
798
+
799
+ // ../path/src/slash.ts
800
+ function slash(path) {
801
+ if (path.startsWith("\\\\?\\")) {
802
+ return path;
803
+ }
804
+ return path.replace(/\\/g, "/");
805
+ }
806
+ __name(slash, "slash");
807
+
808
+ // ../path/src/is-file.ts
809
+ function isAbsolutePath(path) {
810
+ return ABSOLUTE_PATH_REGEX.test(slash(path));
811
+ }
812
+ __name(isAbsolutePath, "isAbsolutePath");
813
+
814
+ // ../path/src/correct-path.ts
815
+ function normalizeWindowsPath2(input = "") {
816
+ if (!input) {
817
+ return input;
818
+ }
819
+ return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
820
+ }
821
+ __name(normalizeWindowsPath2, "normalizeWindowsPath");
822
+ function correctPath(path) {
823
+ if (!path || path.length === 0) {
824
+ return ".";
825
+ }
826
+ path = normalizeWindowsPath2(path);
827
+ const isUNCPath = path.match(UNC_REGEX);
828
+ const isPathAbsolute = isAbsolutePath(path);
829
+ const trailingSeparator = path.endsWith("/");
830
+ path = normalizeString2(path, !isPathAbsolute);
831
+ if (path.length === 0) {
832
+ if (isPathAbsolute) {
833
+ return "/";
834
+ }
835
+ return trailingSeparator ? "./" : ".";
836
+ }
837
+ if (trailingSeparator) {
838
+ path += "/";
839
+ }
840
+ if (DRIVE_LETTER_REGEX.test(path)) {
841
+ path += "/";
842
+ }
843
+ if (isUNCPath) {
844
+ if (!isPathAbsolute) {
845
+ return `//./${path}`;
846
+ }
847
+ return `//${path}`;
848
+ }
849
+ return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
850
+ }
851
+ __name(correctPath, "correctPath");
852
+ function normalizeString2(path, allowAboveRoot) {
853
+ let res = "";
854
+ let lastSegmentLength = 0;
855
+ let lastSlash = -1;
856
+ let dots = 0;
857
+ let char = null;
858
+ for (let index = 0; index <= path.length; ++index) {
859
+ if (index < path.length) {
860
+ char = path[index];
861
+ } else if (char === "/") {
862
+ break;
863
+ } else {
864
+ char = "/";
865
+ }
866
+ if (char === "/") {
867
+ if (lastSlash === index - 1 || dots === 1) {
868
+ } else if (dots === 2) {
869
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
870
+ if (res.length > 2) {
871
+ const lastSlashIndex = res.lastIndexOf("/");
872
+ if (lastSlashIndex === -1) {
873
+ res = "";
874
+ lastSegmentLength = 0;
875
+ } else {
876
+ res = res.slice(0, lastSlashIndex);
877
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
878
+ }
879
+ lastSlash = index;
880
+ dots = 0;
881
+ continue;
882
+ } else if (res.length > 0) {
883
+ res = "";
884
+ lastSegmentLength = 0;
885
+ lastSlash = index;
886
+ dots = 0;
887
+ continue;
888
+ }
889
+ }
890
+ if (allowAboveRoot) {
891
+ res += res.length > 0 ? "/.." : "..";
892
+ lastSegmentLength = 2;
893
+ }
894
+ } else {
895
+ if (res.length > 0) {
896
+ res += `/${path.slice(lastSlash + 1, index)}`;
897
+ } else {
898
+ res = path.slice(lastSlash + 1, index);
899
+ }
900
+ lastSegmentLength = index - lastSlash - 1;
901
+ }
902
+ lastSlash = index;
903
+ dots = 0;
904
+ } else if (char === "." && dots !== -1) {
905
+ ++dots;
906
+ } else {
907
+ dots = -1;
908
+ }
909
+ }
910
+ return res;
911
+ }
912
+ __name(normalizeString2, "normalizeString");
913
+
914
+ // ../path/src/get-workspace-root.ts
915
+ var import_config_tools = require("@storm-software/config-tools");
916
+
917
+ // ../path/src/file-path-fns.ts
918
+ function findFileName(filePath, options = {}) {
919
+ const { requireExtension = false, withExtension = true } = options;
920
+ const result = normalizeWindowsPath2(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
921
+ if (requireExtension === true && !result.includes(".")) {
922
+ return EMPTY_STRING;
923
+ }
924
+ if (withExtension === false && result.includes(".")) {
925
+ return result.substring(0, result.lastIndexOf(".")) || EMPTY_STRING;
926
+ }
927
+ return result;
928
+ }
929
+ __name(findFileName, "findFileName");
930
+ function findFilePath(filePath) {
931
+ const normalizedPath = normalizeWindowsPath2(filePath);
932
+ const result = normalizedPath.replace(findFileName(normalizedPath, {
933
+ requireExtension: true
934
+ }), "");
935
+ return result === "/" ? result : result.replace(/\/$/, "");
936
+ }
937
+ __name(findFilePath, "findFilePath");
938
+
939
+ // bin/capnpc.ts
940
+ var import_commander = require("commander");
941
+ var import_typescript = __toESM(require("typescript"), 1);
942
+
943
+ // ../path/src/exists.ts
944
+ var import_node_fs3 = require("fs");
945
+ var import_promises2 = require("fs/promises");
946
+ var existsSync2 = /* @__PURE__ */ __name((filePath) => {
947
+ return (0, import_node_fs3.existsSync)(filePath);
948
+ }, "existsSync");
949
+ var exists = /* @__PURE__ */ __name(async (filePath) => {
950
+ return (0, import_promises2.access)(filePath, import_promises2.constants.F_OK).then(() => true).catch(() => false);
951
+ }, "exists");
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
+ var import_promises4 = require("fs/promises");
972
+ var writeFile = /* @__PURE__ */ __name(async (filePath, content = "", options = {}) => {
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");
986
+
987
+ // src/compile.ts
988
+ var import_compiler = require("capnp-es/compiler");
989
+ var import_node_buffer2 = require("buffer");
990
+ var import_node_child_process = require("child_process");
991
+ var import_node_fs6 = require("fs");
992
+ async function readStdin() {
993
+ if (process.stdin.isTTY) {
994
+ return import_node_buffer2.Buffer.alloc(0);
995
+ }
996
+ const chunks = [];
997
+ process.stdin.on("data", (chunk) => {
998
+ chunks.push(chunk);
999
+ });
1000
+ await new Promise((resolve) => {
1001
+ process.stdin.on("end", resolve);
1002
+ });
1003
+ const reqBuffer = import_node_buffer2.Buffer.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
1004
+ let i = 0;
1005
+ for (const chunk of chunks) {
1006
+ chunk.copy(reqBuffer, i);
1007
+ i += chunk.byteLength;
1008
+ }
1009
+ return reqBuffer;
1010
+ }
1011
+ __name(readStdin, "readStdin");
1012
+ async function capnpc(options) {
1013
+ try {
1014
+ const { outputPath, tsconfig, sourcePath = [] } = options;
1015
+ let dataBuf = await readStdin();
1016
+ if (dataBuf.byteLength === 0) {
1017
+ const opts = [];
1018
+ if (outputPath) {
1019
+ opts.push(`-o-:${outputPath}`);
1020
+ } else {
1021
+ opts.push("-o-");
1022
+ }
1023
+ dataBuf = await new Promise((resolve) => {
1024
+ (0, import_node_child_process.exec)(`capnpc ${opts.join(" ")} ${sourcePath.join(" ")}`, {
1025
+ encoding: "buffer"
1026
+ }, (error, stdout, stderr) => {
1027
+ if (stderr.length > 0) {
1028
+ process.stderr.write(stderr);
1029
+ }
1030
+ if (error) {
1031
+ throw error;
1032
+ }
1033
+ resolve(stdout);
1034
+ });
1035
+ });
1036
+ }
1037
+ const result = await (0, import_compiler.compileAll)(dataBuf, {
1038
+ ts: options.ts ?? true,
1039
+ js: options.js ?? false,
1040
+ dts: options.dts ?? true,
1041
+ tsconfig: tsconfig?.options
1042
+ });
1043
+ for (const [fileName, content] of result.files) {
1044
+ let filePath = fileName;
1045
+ if (!(0, import_node_fs6.existsSync)(findFilePath(filePath))) {
1046
+ const fullPath = `/${filePath}`;
1047
+ if ((0, import_node_fs6.existsSync)(findFilePath(fullPath))) {
1048
+ filePath = fullPath;
1049
+ }
1050
+ }
1051
+ if (outputPath) {
1052
+ filePath = joinPaths(outputPath, fileName);
1053
+ }
1054
+ if (!(0, import_node_fs6.existsSync)(findFilePath(filePath))) {
1055
+ await createDirectory(findFilePath(filePath));
1056
+ }
1057
+ await writeFile(
1058
+ filePath,
1059
+ // https://github.com/microsoft/TypeScript/issues/54632
1060
+ content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
1061
+ );
1062
+ }
1063
+ return result;
1064
+ } catch (error) {
1065
+ if (error instanceof Error) {
1066
+ console.error(`Error: ${error.message}`);
1067
+ if (error.stack) {
1068
+ console.error(error.stack);
1069
+ }
1070
+ } else {
1071
+ console.error("An unknown error occurred:", error);
1072
+ }
1073
+ throw error;
1074
+ }
1075
+ }
1076
+ __name(capnpc, "capnpc");
1077
+
1078
+ // bin/capnpc.ts
1079
+ function createProgram() {
1080
+ (0, import_console.writeInfo)("\u26A1 Running Storm Cap'n Proto Compiler Tools", {
1081
+ logLevel: "all"
1082
+ });
1083
+ const root = (0, import_utilities.findWorkspaceRootSafe)(process.cwd());
1084
+ process.env.STORM_WORKSPACE_ROOT ??= root;
1085
+ process.env.NX_WORKSPACE_ROOT_PATH ??= root;
1086
+ if (root) {
1087
+ process.chdir(root);
1088
+ }
1089
+ const program = new import_commander.Command("storm-capnpc");
1090
+ program.version("1.0.0", "-v --version", "display CLI version");
1091
+ const tsOption = new import_commander.Option("--ts", "An indicator to generate TypeScript files").default(true);
1092
+ const jsOption = new import_commander.Option("--js", "An indicator to generate JavaScript files").default(false);
1093
+ const dtsOption = new import_commander.Option("--dts", "An indicator to generate TypeScript declaration files").default(true);
1094
+ 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) => {
1095
+ if (val.startsWith("-I") || val.startsWith("--import-path")) {
1096
+ return val.split(",").map((dir) => dir.trim());
1097
+ }
1098
+ return [
1099
+ val.trim()
1100
+ ];
1101
+ });
1102
+ 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);
1103
+ const standardImportOption = new import_commander.Option("--standard-import", "Add default import paths; use only those specified by -I").default(true);
1104
+ const outputPathOption = new import_commander.Option("-o --output-path <path>", "The directory to output the generated files to").default(process.cwd());
1105
+ const sourceOption = new import_commander.Option("--source-path <path...>", "The directories containing the Cap'n Proto schema files to compile (default: current working directory)").default([
1106
+ joinPaths(process.cwd(), "**/*.capnp")
1107
+ ]).argParser((val) => {
1108
+ if (val.startsWith("--source") || val.startsWith("-s")) {
1109
+ return val.split(",").map((dir) => dir.trim());
1110
+ }
1111
+ return [
1112
+ val.trim()
1113
+ ];
1114
+ });
1115
+ const tsconfigPathOption = new import_commander.Option("--tsconfig-path <path>", "The path to the TypeScript configuration file to use for compilation").default(joinPaths(process.cwd(), "tsconfig.json"));
1116
+ program.command("compile", {
1117
+ isDefault: true
1118
+ }).description("Run the Storm Cap'n Proto compiler").addOption(sourceOption).addOption(outputPathOption).addOption(importPathOption).addOption(tsconfigPathOption).addOption(generateId).addOption(standardImportOption).addOption(tsOption).addOption(jsOption).addOption(dtsOption).action(compileAction).showSuggestionAfterError(true).showHelpAfterError(true);
1119
+ return program;
1120
+ }
1121
+ __name(createProgram, "createProgram");
1122
+ async function compileAction(options) {
1123
+ (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 to ${options.outputPath}...`, {
1124
+ logLevel: "all"
1125
+ });
1126
+ const resolvedTsconfig = await readJsonFile(options.tsconfigPath);
1127
+ const tsconfig = import_typescript.default.parseJsonConfigFileContent(resolvedTsconfig, import_typescript.default.sys, findFilePath(options.tsconfigPath));
1128
+ const sourcefiles = [];
1129
+ for (const sourcePath of options.sourcePath) {
1130
+ if (!sourcePath) {
1131
+ (0, import_console.writeFatal)(`\u274C The source path "${sourcePath}" is invalid. Please provide a valid path.`, {
1132
+ logLevel: "all"
1133
+ });
1134
+ return;
1135
+ }
1136
+ sourcefiles.push(...await listFiles(sourcePath));
1137
+ }
1138
+ if (sourcefiles.length === 0) {
1139
+ (0, import_console.writeFatal)(`\u274C No Cap'n Proto schema files found in the specified source paths: ${options.sourcePath.join(", ")}. Please ensure that the paths are correct and contain .capnp files.`, {
1140
+ logLevel: "all"
1141
+ });
1142
+ return;
1143
+ }
1144
+ const result = await capnpc({
1145
+ ...options,
1146
+ tsconfig,
1147
+ sourcePath: sourcefiles
1148
+ });
1149
+ if (result.files.size === 0) {
1150
+ (0, import_console.writeInfo)("\u26A0\uFE0F No files were generated. Please check your schema files.", {
1151
+ logLevel: "all"
1152
+ });
1153
+ return;
1154
+ }
1155
+ (0, import_console.writeSuccess)("\u26A1 Storm Cap'n Proto Compiler completed successfully.", {
1156
+ logLevel: "all"
1157
+ });
1158
+ }
1159
+ __name(compileAction, "compileAction");
1160
+ void (async () => {
1161
+ try {
1162
+ (0, import_utilities.handleProcess)();
1163
+ const program = createProgram();
1164
+ await program.parseAsync(process.argv);
1165
+ (0, import_utilities.exitWithSuccess)();
1166
+ } catch (error) {
1167
+ (0, import_console.writeFatal)(`A fatal error occurred while running the Storm Cap'n Proto compiler tool:
1168
+ ${error?.message ? error.message : JSON.stringify(error)}${error?.stack ? `
1169
+ Stack Trace: ${error.stack}` : ""}`, {
1170
+ logLevel: "all"
1171
+ });
1172
+ (0, import_utilities.exitWithError)();
1173
+ process.exit(1);
1174
+ }
1175
+ })();
1176
+ // Annotate the CommonJS export names for ESM import in node:
1177
+ 0 && (module.exports = {
1178
+ createProgram
1179
+ });