@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.
@@ -1,4980 +0,0 @@
1
- import {
2
- CompositeList,
3
- Message,
4
- ObjectSize,
5
- Struct,
6
- __name,
7
- adopt,
8
- copyFrom,
9
- disown,
10
- format,
11
- getAs,
12
- getBit,
13
- getData,
14
- getFloat32,
15
- getFloat64,
16
- getInt16,
17
- getInt32,
18
- getInt64,
19
- getInt8,
20
- getList,
21
- getPointer,
22
- getStruct,
23
- getText,
24
- getUint16,
25
- getUint16Mask,
26
- getUint32,
27
- getUint64,
28
- getUint8,
29
- initData,
30
- initList,
31
- initStructAt,
32
- isNull,
33
- pad,
34
- setBit,
35
- setFloat32,
36
- setFloat64,
37
- setInt16,
38
- setInt32,
39
- setInt64,
40
- setInt8,
41
- setText,
42
- setUint16,
43
- setUint32,
44
- setUint64,
45
- setUint8,
46
- testWhich
47
- } from "./chunk-N5AOPRAP.js";
48
-
49
- // ../path/src/exists.ts
50
- import { existsSync as existsSyncFs } from "node:fs";
51
- import { access, constants } from "node:fs/promises";
52
- var existsSync = /* @__PURE__ */ __name((filePath) => {
53
- return existsSyncFs(filePath);
54
- }, "existsSync");
55
- var exists = /* @__PURE__ */ __name(async (filePath) => {
56
- return access(filePath, constants.F_OK).then(() => true).catch(() => false);
57
- }, "exists");
58
-
59
- // ../fs/src/helpers.ts
60
- import { parseTar, parseTarGzip } from "nanotar";
61
- import { createWriteStream, mkdirSync, rmSync } from "node:fs";
62
- import { mkdir, readFile, rm } from "node:fs/promises";
63
- async function createDirectory(path) {
64
- if (await exists(path)) {
65
- return;
66
- }
67
- return mkdir(path, {
68
- recursive: true
69
- });
70
- }
71
- __name(createDirectory, "createDirectory");
72
-
73
- // ../fs/src/write-file.ts
74
- import { stringify as stringifyToml } from "@ltd/j-toml";
75
-
76
- // ../type-checks/src/get-object-tag.ts
77
- var getObjectTag = /* @__PURE__ */ __name((value) => {
78
- if (value == null) {
79
- return value === void 0 ? "[object Undefined]" : "[object Null]";
80
- }
81
- return Object.prototype.toString.call(value);
82
- }, "getObjectTag");
83
-
84
- // ../type-checks/src/is-plain-object.ts
85
- var isObjectLike = /* @__PURE__ */ __name((obj) => {
86
- return typeof obj === "object" && obj !== null;
87
- }, "isObjectLike");
88
- var isPlainObject = /* @__PURE__ */ __name((obj) => {
89
- if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") {
90
- return false;
91
- }
92
- if (Object.getPrototypeOf(obj) === null) {
93
- return true;
94
- }
95
- let proto = obj;
96
- while (Object.getPrototypeOf(proto) !== null) {
97
- proto = Object.getPrototypeOf(proto);
98
- }
99
- return Object.getPrototypeOf(obj) === proto;
100
- }, "isPlainObject");
101
-
102
- // ../type-checks/src/is-object.ts
103
- var isObject = /* @__PURE__ */ __name((value) => {
104
- try {
105
- return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
106
- } catch {
107
- return false;
108
- }
109
- }, "isObject");
110
-
111
- // ../type-checks/src/is-string.ts
112
- var isString = /* @__PURE__ */ __name((value) => {
113
- try {
114
- return typeof value === "string";
115
- } catch {
116
- return false;
117
- }
118
- }, "isString");
119
-
120
- // ../json/src/storm-json.ts
121
- import { parse as parse2 } from "jsonc-parser";
122
- import { Buffer } from "node:buffer";
123
- import SuperJSON from "superjson";
124
-
125
- // ../types/src/base.ts
126
- var EMPTY_STRING = "";
127
- var $NestedValue = Symbol("NestedValue");
128
-
129
- // ../json/src/utils/strip-comments.ts
130
- var singleComment = Symbol("singleComment");
131
- var multiComment = Symbol("multiComment");
132
- function stripWithoutWhitespace() {
133
- return "";
134
- }
135
- __name(stripWithoutWhitespace, "stripWithoutWhitespace");
136
- function stripWithWhitespace(value, start, end) {
137
- return value.slice(start, end).replace(/\S/g, " ");
138
- }
139
- __name(stripWithWhitespace, "stripWithWhitespace");
140
- function isEscaped(value, quotePosition) {
141
- let index = quotePosition - 1;
142
- let backslashCount = 0;
143
- while (value[index] === "\\") {
144
- index -= 1;
145
- backslashCount += 1;
146
- }
147
- return Boolean(backslashCount % 2);
148
- }
149
- __name(isEscaped, "isEscaped");
150
- function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
151
- if (typeof value !== "string") {
152
- throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
153
- }
154
- const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
155
- let isInsideString = false;
156
- let isInsideComment = false;
157
- let offset = 0;
158
- let buffer = "";
159
- let result = "";
160
- let commaIndex = -1;
161
- for (let index = 0; index < value.length; index++) {
162
- const currentCharacter = value[index];
163
- const nextCharacter = value[index + 1];
164
- if (!isInsideComment && currentCharacter === '"') {
165
- const escaped = isEscaped(value, index);
166
- if (!escaped) {
167
- isInsideString = !isInsideString;
168
- }
169
- }
170
- if (isInsideString) {
171
- continue;
172
- }
173
- if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "//") {
174
- buffer += value.slice(offset, index);
175
- offset = index;
176
- isInsideComment = singleComment;
177
- index++;
178
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "\r\n") {
179
- index++;
180
- isInsideComment = false;
181
- buffer += strip(value, offset, index);
182
- offset = index;
183
- } else if (isInsideComment === singleComment && currentCharacter === "\n") {
184
- isInsideComment = false;
185
- buffer += strip(value, offset, index);
186
- offset = index;
187
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "/*") {
188
- buffer += value.slice(offset, index);
189
- offset = index;
190
- isInsideComment = multiComment;
191
- index++;
192
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "*/") {
193
- index++;
194
- isInsideComment = false;
195
- buffer += strip(value, offset, index + 1);
196
- offset = index + 1;
197
- } else if (trailingCommas && !isInsideComment) {
198
- if (commaIndex !== -1) {
199
- if (currentCharacter === "}" || currentCharacter === "]") {
200
- buffer += value.slice(offset, index);
201
- result += strip(buffer, 0, 1) + buffer.slice(1);
202
- buffer = "";
203
- offset = index;
204
- commaIndex = -1;
205
- } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
206
- buffer += value.slice(offset, index);
207
- offset = index;
208
- commaIndex = -1;
209
- }
210
- } else if (currentCharacter === ",") {
211
- result += buffer + value.slice(offset, index);
212
- buffer = "";
213
- offset = index;
214
- commaIndex = index;
215
- }
216
- }
217
- }
218
- return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
219
- }
220
- __name(stripComments, "stripComments");
221
-
222
- // ../json/src/utils/parse.ts
223
- 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*:/;
224
- 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*:/;
225
- var JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
226
- function jsonParseTransform(key, value) {
227
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
228
- console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
229
- return;
230
- }
231
- return value;
232
- }
233
- __name(jsonParseTransform, "jsonParseTransform");
234
- function parse(value, options = {}) {
235
- if (typeof value !== "string") {
236
- return value;
237
- }
238
- let stripped = stripComments(value);
239
- if (stripped[0] === '"' && stripped[stripped.length - 1] === '"' && !stripped.includes("\\")) {
240
- return stripped.slice(1, -1);
241
- }
242
- stripped = stripped.trim();
243
- if (stripped.length <= 9) {
244
- switch (stripped.toLowerCase()) {
245
- case "true": {
246
- return true;
247
- }
248
- case "false": {
249
- return false;
250
- }
251
- case "undefined": {
252
- return void 0;
253
- }
254
- case "null": {
255
- return null;
256
- }
257
- case "nan": {
258
- return Number.NaN;
259
- }
260
- case "infinity": {
261
- return Number.POSITIVE_INFINITY;
262
- }
263
- case "-infinity": {
264
- return Number.NEGATIVE_INFINITY;
265
- }
266
- }
267
- }
268
- if (!JsonSigRx.test(stripped)) {
269
- if (options.strict) {
270
- throw new Error("Invalid JSON");
271
- }
272
- return stripped;
273
- }
274
- try {
275
- if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
276
- if (options.strict) {
277
- throw new Error("Possible prototype pollution");
278
- }
279
- return JSON.parse(stripped, jsonParseTransform);
280
- }
281
- return JSON.parse(stripped);
282
- } catch (error) {
283
- if (options.strict) {
284
- throw error;
285
- }
286
- return value;
287
- }
288
- }
289
- __name(parse, "parse");
290
-
291
- // ../json/src/utils/parse-error.ts
292
- import { printParseErrorCode } from "jsonc-parser";
293
- import { LinesAndColumns } from "lines-and-columns";
294
-
295
- // ../json/src/utils/code-frames.ts
296
- var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
297
- function getMarkerLines(loc, source, opts = {}) {
298
- const startLoc = {
299
- column: 0,
300
- line: -1,
301
- ...loc.start
302
- };
303
- const endLoc = {
304
- ...startLoc,
305
- ...loc.end
306
- };
307
- const { linesAbove = 2, linesBelow = 3 } = opts || {};
308
- const startLine = startLoc.line;
309
- const startColumn = startLoc.column;
310
- const endLine = endLoc.line;
311
- const endColumn = endLoc.column;
312
- let start = Math.max(startLine - (linesAbove + 1), 0);
313
- let end = Math.min(source.length, endLine + linesBelow);
314
- if (startLine === -1) {
315
- start = 0;
316
- }
317
- if (endLine === -1) {
318
- end = source.length;
319
- }
320
- const lineDiff = endLine - startLine;
321
- const markerLines = {};
322
- if (lineDiff) {
323
- for (let i = 0; i <= lineDiff; i++) {
324
- const lineNumber = i + startLine;
325
- if (!startColumn) {
326
- markerLines[lineNumber] = true;
327
- } else if (i === 0) {
328
- const sourceLength = source[lineNumber - 1]?.length ?? 0;
329
- markerLines[lineNumber] = [
330
- startColumn,
331
- sourceLength - startColumn + 1
332
- ];
333
- } else if (i === lineDiff) {
334
- markerLines[lineNumber] = [
335
- 0,
336
- endColumn
337
- ];
338
- } else {
339
- const sourceLength = source[lineNumber - i]?.length ?? 0;
340
- markerLines[lineNumber] = [
341
- 0,
342
- sourceLength
343
- ];
344
- }
345
- }
346
- } else if (startColumn === endColumn) {
347
- markerLines[startLine] = startColumn ? [
348
- startColumn,
349
- 0
350
- ] : true;
351
- } else {
352
- markerLines[startLine] = [
353
- startColumn,
354
- endColumn - startColumn
355
- ];
356
- }
357
- return {
358
- start,
359
- end,
360
- markerLines
361
- };
362
- }
363
- __name(getMarkerLines, "getMarkerLines");
364
- function codeFrameColumns(rawLines, loc, opts = {}) {
365
- const lines = rawLines.split(NEWLINE);
366
- const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
367
- const numberMaxWidth = String(end).length;
368
- const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;
369
- const frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
370
- const number = start + 1 + index;
371
- const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
372
- const gutter = ` ${paddedNumber} | `;
373
- const hasMarker = Boolean(markerLines[number] ?? false);
374
- if (hasMarker) {
375
- let markerLine = "";
376
- if (Array.isArray(hasMarker)) {
377
- const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
378
- const numberOfMarkers = hasMarker[1] || 1;
379
- markerLine = [
380
- "\n ",
381
- gutter.replace(/\d/g, " "),
382
- markerSpacing,
383
- "^".repeat(numberOfMarkers)
384
- ].join("");
385
- }
386
- return [
387
- ">",
388
- gutter,
389
- line,
390
- markerLine
391
- ].join("");
392
- }
393
- return ` ${gutter}${line}`;
394
- }).join("\n");
395
- return frame;
396
- }
397
- __name(codeFrameColumns, "codeFrameColumns");
398
-
399
- // ../json/src/utils/parse-error.ts
400
- function formatParseError(input, parseError) {
401
- const { error, offset, length } = parseError;
402
- const result = new LinesAndColumns(input).locationForIndex(offset);
403
- let line = result?.line ?? 0;
404
- let column = result?.column ?? 0;
405
- line++;
406
- column++;
407
- return `${printParseErrorCode(error)} in JSON at ${line}:${column}
408
- ${codeFrameColumns(input, {
409
- start: {
410
- line,
411
- column
412
- },
413
- end: {
414
- line,
415
- column: column + length
416
- }
417
- })}
418
- `;
419
- }
420
- __name(formatParseError, "formatParseError");
421
-
422
- // ../type-checks/src/is-number.ts
423
- var isNumber = /* @__PURE__ */ __name((value) => {
424
- try {
425
- return value instanceof Number || typeof value === "number" || Number(value) === value;
426
- } catch {
427
- return false;
428
- }
429
- }, "isNumber");
430
-
431
- // ../type-checks/src/is-undefined.ts
432
- var isUndefined = /* @__PURE__ */ __name((value) => {
433
- return value === void 0;
434
- }, "isUndefined");
435
-
436
- // ../json/src/utils/stringify.ts
437
- var invalidKeyChars = [
438
- "@",
439
- "/",
440
- "#",
441
- "$",
442
- " ",
443
- ":",
444
- ";",
445
- ",",
446
- ".",
447
- "!",
448
- "?",
449
- "&",
450
- "=",
451
- "+",
452
- "-",
453
- "*",
454
- "%",
455
- "^",
456
- "~",
457
- "|",
458
- "\\",
459
- '"',
460
- "'",
461
- "`",
462
- "{",
463
- "}",
464
- "[",
465
- "]",
466
- "(",
467
- ")",
468
- "<",
469
- ">"
470
- ];
471
- var stringify = /* @__PURE__ */ __name((value, spacing = 2) => {
472
- const space = isNumber(spacing) ? " ".repeat(spacing) : spacing;
473
- switch (value) {
474
- case null: {
475
- return "null";
476
- }
477
- case void 0: {
478
- return '"undefined"';
479
- }
480
- case true: {
481
- return "true";
482
- }
483
- case false: {
484
- return "false";
485
- }
486
- case Number.POSITIVE_INFINITY: {
487
- return "infinity";
488
- }
489
- case Number.NEGATIVE_INFINITY: {
490
- return "-infinity";
491
- }
492
- }
493
- if (Array.isArray(value)) {
494
- return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
495
- }
496
- if (value instanceof Uint8Array) {
497
- return value.toString();
498
- }
499
- switch (typeof value) {
500
- case "number": {
501
- return `${value}`;
502
- }
503
- case "string": {
504
- return JSON.stringify(value);
505
- }
506
- case "object": {
507
- const keys = Object.keys(value).filter((key) => !isUndefined(value[key]));
508
- return `{${space}${keys.map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
509
- }
510
- default:
511
- return "null";
512
- }
513
- }, "stringify");
514
-
515
- // ../json/src/storm-json.ts
516
- var StormJSON = class _StormJSON extends SuperJSON {
517
- static {
518
- __name(this, "StormJSON");
519
- }
520
- static #instance;
521
- static get instance() {
522
- if (!_StormJSON.#instance) {
523
- _StormJSON.#instance = new _StormJSON();
524
- }
525
- return _StormJSON.#instance;
526
- }
527
- /**
528
- * Deserialize the given value with superjson using the given metadata
529
- */
530
- static deserialize(payload) {
531
- return _StormJSON.instance.deserialize(payload);
532
- }
533
- /**
534
- * Serialize the given value with superjson
535
- */
536
- static serialize(object) {
537
- return _StormJSON.instance.serialize(object);
538
- }
539
- /**
540
- * Parse the given string value with superjson using the given metadata
541
- *
542
- * @param value - The string value to parse
543
- * @returns The parsed data
544
- */
545
- static parse(value) {
546
- return parse(value);
547
- }
548
- /**
549
- * Serializes the given data to a JSON string.
550
- * By default the JSON string is formatted with a 2 space indentation to be easy readable.
551
- *
552
- * @param value - Object which should be serialized to JSON
553
- * @param _options - JSON serialize options
554
- * @returns the formatted JSON representation of the object
555
- */
556
- static stringify(value, _options) {
557
- const customTransformer = _StormJSON.instance.customTransformerRegistry.findApplicable(value);
558
- let result = value;
559
- if (customTransformer && customTransformer.isApplicable(value)) {
560
- result = customTransformer.serialize(result);
561
- }
562
- return stringify(result);
563
- }
564
- /**
565
- * Parses the given JSON string and returns the object the JSON content represents.
566
- * By default javascript-style comments and trailing commas are allowed.
567
- *
568
- * @param strData - JSON content as string
569
- * @param options - JSON parse options
570
- * @returns Object the JSON content represents
571
- */
572
- static parseJson(strData, options) {
573
- try {
574
- if (options?.expectComments === false) {
575
- return _StormJSON.instance.parse(strData);
576
- }
577
- } catch {
578
- }
579
- const errors = [];
580
- const opts = {
581
- allowTrailingComma: true,
582
- ...options
583
- };
584
- const result = parse2(strData, errors, opts);
585
- if (errors.length > 0 && errors[0]) {
586
- throw new Error(formatParseError(strData, errors[0]));
587
- }
588
- return result;
589
- }
590
- /**
591
- * Register a custom schema with superjson
592
- *
593
- * @param name - The name of the schema
594
- * @param serialize - The function to serialize the schema
595
- * @param deserialize - The function to deserialize the schema
596
- * @param isApplicable - The function to check if the schema is applicable
597
- */
598
- static register(name, serialize, deserialize, isApplicable) {
599
- _StormJSON.instance.registerCustom({
600
- isApplicable,
601
- serialize,
602
- deserialize
603
- }, name);
604
- }
605
- /**
606
- * Register a class with superjson
607
- *
608
- * @param classConstructor - The class constructor to register
609
- */
610
- static registerClass(classConstructor, options) {
611
- _StormJSON.instance.registerClass(classConstructor, {
612
- identifier: isString(options) ? options : options?.identifier || classConstructor.name,
613
- allowProps: options && isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : [
614
- "__typename"
615
- ]
616
- });
617
- }
618
- constructor() {
619
- super({
620
- dedupe: true
621
- });
622
- }
623
- };
624
- StormJSON.instance.registerCustom({
625
- isApplicable: /* @__PURE__ */ __name((v) => Buffer.isBuffer(v), "isApplicable"),
626
- serialize: /* @__PURE__ */ __name((v) => v.toString("base64"), "serialize"),
627
- deserialize: /* @__PURE__ */ __name((v) => Buffer.from(v, "base64"), "deserialize")
628
- }, "Bytes");
629
-
630
- // ../path/src/is-file.ts
631
- import { lstatSync, statSync } from "node:fs";
632
-
633
- // ../path/src/join-paths.ts
634
- var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
635
- function normalizeWindowsPath(input = "") {
636
- if (!input) {
637
- return input;
638
- }
639
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
640
- }
641
- __name(normalizeWindowsPath, "normalizeWindowsPath");
642
- var _UNC_REGEX = /^[/\\]{2}/;
643
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
644
- var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
645
- var isAbsolute = /* @__PURE__ */ __name(function(p) {
646
- return _IS_ABSOLUTE_RE.test(p);
647
- }, "isAbsolute");
648
- var correctPaths = /* @__PURE__ */ __name(function(path) {
649
- if (!path || path.length === 0) {
650
- return ".";
651
- }
652
- path = normalizeWindowsPath(path);
653
- const isUNCPath = path.match(_UNC_REGEX);
654
- const isPathAbsolute = isAbsolute(path);
655
- const trailingSeparator = path[path.length - 1] === "/";
656
- path = normalizeString(path, !isPathAbsolute);
657
- if (path.length === 0) {
658
- if (isPathAbsolute) {
659
- return "/";
660
- }
661
- return trailingSeparator ? "./" : ".";
662
- }
663
- if (trailingSeparator) {
664
- path += "/";
665
- }
666
- if (_DRIVE_LETTER_RE.test(path)) {
667
- path += "/";
668
- }
669
- if (isUNCPath) {
670
- if (!isPathAbsolute) {
671
- return `//./${path}`;
672
- }
673
- return `//${path}`;
674
- }
675
- return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
676
- }, "correctPaths");
677
- var joinPaths = /* @__PURE__ */ __name(function(...segments) {
678
- let path = "";
679
- for (const seg of segments) {
680
- if (!seg) {
681
- continue;
682
- }
683
- if (path.length > 0) {
684
- const pathTrailing = path[path.length - 1] === "/";
685
- const segLeading = seg[0] === "/";
686
- const both = pathTrailing && segLeading;
687
- if (both) {
688
- path += seg.slice(1);
689
- } else {
690
- path += pathTrailing || segLeading ? seg : `/${seg}`;
691
- }
692
- } else {
693
- path += seg;
694
- }
695
- }
696
- return correctPaths(path);
697
- }, "joinPaths");
698
- function normalizeString(path, allowAboveRoot) {
699
- let res = "";
700
- let lastSegmentLength = 0;
701
- let lastSlash = -1;
702
- let dots = 0;
703
- let char = null;
704
- for (let index = 0; index <= path.length; ++index) {
705
- if (index < path.length) {
706
- char = path[index];
707
- } else if (char === "/") {
708
- break;
709
- } else {
710
- char = "/";
711
- }
712
- if (char === "/") {
713
- if (lastSlash === index - 1 || dots === 1) {
714
- } else if (dots === 2) {
715
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
716
- if (res.length > 2) {
717
- const lastSlashIndex = res.lastIndexOf("/");
718
- if (lastSlashIndex === -1) {
719
- res = "";
720
- lastSegmentLength = 0;
721
- } else {
722
- res = res.slice(0, lastSlashIndex);
723
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
724
- }
725
- lastSlash = index;
726
- dots = 0;
727
- continue;
728
- } else if (res.length > 0) {
729
- res = "";
730
- lastSegmentLength = 0;
731
- lastSlash = index;
732
- dots = 0;
733
- continue;
734
- }
735
- }
736
- if (allowAboveRoot) {
737
- res += res.length > 0 ? "/.." : "..";
738
- lastSegmentLength = 2;
739
- }
740
- } else {
741
- if (res.length > 0) {
742
- res += `/${path.slice(lastSlash + 1, index)}`;
743
- } else {
744
- res = path.slice(lastSlash + 1, index);
745
- }
746
- lastSegmentLength = index - lastSlash - 1;
747
- }
748
- lastSlash = index;
749
- dots = 0;
750
- } else if (char === "." && dots !== -1) {
751
- ++dots;
752
- } else {
753
- dots = -1;
754
- }
755
- }
756
- return res;
757
- }
758
- __name(normalizeString, "normalizeString");
759
-
760
- // ../path/src/regex.ts
761
- var DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
762
- var DRIVE_LETTER_REGEX = /^[A-Z]:$/i;
763
- var UNC_REGEX = /^[/\\]{2}/;
764
- var ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
765
-
766
- // ../path/src/slash.ts
767
- function slash(path) {
768
- if (path.startsWith("\\\\?\\")) {
769
- return path;
770
- }
771
- return path.replace(/\\/g, "/");
772
- }
773
- __name(slash, "slash");
774
-
775
- // ../path/src/is-file.ts
776
- function isAbsolutePath(path) {
777
- return ABSOLUTE_PATH_REGEX.test(slash(path));
778
- }
779
- __name(isAbsolutePath, "isAbsolutePath");
780
-
781
- // ../path/src/correct-path.ts
782
- function normalizeWindowsPath2(input = "") {
783
- if (!input) {
784
- return input;
785
- }
786
- return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
787
- }
788
- __name(normalizeWindowsPath2, "normalizeWindowsPath");
789
- function correctPath(path) {
790
- if (!path || path.length === 0) {
791
- return ".";
792
- }
793
- path = normalizeWindowsPath2(path);
794
- const isUNCPath = path.match(UNC_REGEX);
795
- const isPathAbsolute = isAbsolutePath(path);
796
- const trailingSeparator = path.endsWith("/");
797
- path = normalizeString2(path, !isPathAbsolute);
798
- if (path.length === 0) {
799
- if (isPathAbsolute) {
800
- return "/";
801
- }
802
- return trailingSeparator ? "./" : ".";
803
- }
804
- if (trailingSeparator) {
805
- path += "/";
806
- }
807
- if (DRIVE_LETTER_REGEX.test(path)) {
808
- path += "/";
809
- }
810
- if (isUNCPath) {
811
- if (!isPathAbsolute) {
812
- return `//./${path}`;
813
- }
814
- return `//${path}`;
815
- }
816
- return !path.startsWith("/") && isPathAbsolute && !DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
817
- }
818
- __name(correctPath, "correctPath");
819
- function normalizeString2(path, allowAboveRoot) {
820
- let res = "";
821
- let lastSegmentLength = 0;
822
- let lastSlash = -1;
823
- let dots = 0;
824
- let char = null;
825
- for (let index = 0; index <= path.length; ++index) {
826
- if (index < path.length) {
827
- char = path[index];
828
- } else if (char === "/") {
829
- break;
830
- } else {
831
- char = "/";
832
- }
833
- if (char === "/") {
834
- if (lastSlash === index - 1 || dots === 1) {
835
- } else if (dots === 2) {
836
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
837
- if (res.length > 2) {
838
- const lastSlashIndex = res.lastIndexOf("/");
839
- if (lastSlashIndex === -1) {
840
- res = "";
841
- lastSegmentLength = 0;
842
- } else {
843
- res = res.slice(0, lastSlashIndex);
844
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
845
- }
846
- lastSlash = index;
847
- dots = 0;
848
- continue;
849
- } else if (res.length > 0) {
850
- res = "";
851
- lastSegmentLength = 0;
852
- lastSlash = index;
853
- dots = 0;
854
- continue;
855
- }
856
- }
857
- if (allowAboveRoot) {
858
- res += res.length > 0 ? "/.." : "..";
859
- lastSegmentLength = 2;
860
- }
861
- } else {
862
- if (res.length > 0) {
863
- res += `/${path.slice(lastSlash + 1, index)}`;
864
- } else {
865
- res = path.slice(lastSlash + 1, index);
866
- }
867
- lastSegmentLength = index - lastSlash - 1;
868
- }
869
- lastSlash = index;
870
- dots = 0;
871
- } else if (char === "." && dots !== -1) {
872
- ++dots;
873
- } else {
874
- dots = -1;
875
- }
876
- }
877
- return res;
878
- }
879
- __name(normalizeString2, "normalizeString");
880
-
881
- // ../path/src/file-path-fns.ts
882
- import { relative } from "node:path";
883
-
884
- // ../path/src/get-workspace-root.ts
885
- import { findWorkspaceRootSafe } from "@storm-software/config-tools";
886
-
887
- // ../path/src/file-path-fns.ts
888
- function findFileName(filePath, options = {}) {
889
- const { requireExtension = false, withExtension = true } = options;
890
- const result = normalizeWindowsPath2(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
891
- if (requireExtension === true && !result.includes(".")) {
892
- return EMPTY_STRING;
893
- }
894
- if (withExtension === false && result.includes(".")) {
895
- return result.substring(0, result.lastIndexOf(".")) || EMPTY_STRING;
896
- }
897
- return result;
898
- }
899
- __name(findFileName, "findFileName");
900
- function findFilePath(filePath) {
901
- const normalizedPath = normalizeWindowsPath2(filePath);
902
- const result = normalizedPath.replace(findFileName(normalizedPath, {
903
- requireExtension: true
904
- }), "");
905
- return result === "/" ? result : result.replace(/\/$/, "");
906
- }
907
- __name(findFilePath, "findFilePath");
908
-
909
- // ../fs/src/write-file.ts
910
- import defu from "defu";
911
- import { writeFileSync as writeFileSyncFs } from "node:fs";
912
- import { writeFile as writeFileFs } from "node:fs/promises";
913
- var writeFile = /* @__PURE__ */ __name(async (filePath, content = "", options = {}) => {
914
- if (!filePath) {
915
- throw new Error("No file path provided to read data");
916
- }
917
- const directory = findFilePath(correctPath(filePath));
918
- if (!existsSync(directory)) {
919
- if (options.createDirectory !== false) {
920
- await createDirectory(directory);
921
- } else {
922
- throw new Error(`Directory ${directory} does not exist`);
923
- }
924
- }
925
- return writeFileFs(filePath, content || "", options);
926
- }, "writeFile");
927
-
928
- // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=8f737a83e1b5be10396ff9b257b56b8b8e7a3dbd2754765e9b1e2019839e9c31_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
929
- import ts from "typescript";
930
-
931
- // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=8f737a83e1b5be10396ff9b257b56b8b8e7a3dbd2754765e9b1e2019839e9c31_typescript@5.8.3/node_modules/capnp-es/dist/capnp/schema.mjs
932
- var _capnpFileId = BigInt("0xa93fc509624c72d9");
933
- var Node_Parameter = class extends Struct {
934
- static {
935
- __name(this, "Node_Parameter");
936
- }
937
- static _capnp = {
938
- displayName: "Parameter",
939
- id: "b9521bccf10fa3b1",
940
- size: new ObjectSize(0, 1)
941
- };
942
- get name() {
943
- return getText(0, this);
944
- }
945
- set name(value) {
946
- setText(0, value, this);
947
- }
948
- toString() {
949
- return "Node_Parameter_" + super.toString();
950
- }
951
- };
952
- var Node_NestedNode = class extends Struct {
953
- static {
954
- __name(this, "Node_NestedNode");
955
- }
956
- static _capnp = {
957
- displayName: "NestedNode",
958
- id: "debf55bbfa0fc242",
959
- size: new ObjectSize(8, 1)
960
- };
961
- /**
962
- * Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically.
963
- *
964
- * (On Zooko's triangle, this is the node's petname according to its parent scope.)
965
- *
966
- */
967
- get name() {
968
- return getText(0, this);
969
- }
970
- set name(value) {
971
- setText(0, value, this);
972
- }
973
- /**
974
- * ID of the nested node. Typically, the target node's scopeId points back to this node, but
975
- * robust code should avoid relying on this.
976
- *
977
- */
978
- get id() {
979
- return getUint64(0, this);
980
- }
981
- set id(value) {
982
- setUint64(0, value, this);
983
- }
984
- toString() {
985
- return "Node_NestedNode_" + super.toString();
986
- }
987
- };
988
- var Node_SourceInfo_Member = class extends Struct {
989
- static {
990
- __name(this, "Node_SourceInfo_Member");
991
- }
992
- static _capnp = {
993
- displayName: "Member",
994
- id: "c2ba9038898e1fa2",
995
- size: new ObjectSize(0, 1)
996
- };
997
- /**
998
- * Doc comment on the member.
999
- *
1000
- */
1001
- get docComment() {
1002
- return getText(0, this);
1003
- }
1004
- set docComment(value) {
1005
- setText(0, value, this);
1006
- }
1007
- toString() {
1008
- return "Node_SourceInfo_Member_" + super.toString();
1009
- }
1010
- };
1011
- var Node_SourceInfo = class _Node_SourceInfo extends Struct {
1012
- static {
1013
- __name(this, "Node_SourceInfo");
1014
- }
1015
- static Member = Node_SourceInfo_Member;
1016
- static _capnp = {
1017
- displayName: "SourceInfo",
1018
- id: "f38e1de3041357ae",
1019
- size: new ObjectSize(8, 2)
1020
- };
1021
- static _Members;
1022
- /**
1023
- * ID of the Node which this info describes.
1024
- *
1025
- */
1026
- get id() {
1027
- return getUint64(0, this);
1028
- }
1029
- set id(value) {
1030
- setUint64(0, value, this);
1031
- }
1032
- /**
1033
- * The top-level doc comment for the Node.
1034
- *
1035
- */
1036
- get docComment() {
1037
- return getText(0, this);
1038
- }
1039
- set docComment(value) {
1040
- setText(0, value, this);
1041
- }
1042
- _adoptMembers(value) {
1043
- adopt(value, getPointer(1, this));
1044
- }
1045
- _disownMembers() {
1046
- return disown(this.members);
1047
- }
1048
- /**
1049
- * Information about each member -- i.e. fields (for structs), enumerants (for enums), or
1050
- * methods (for interfaces).
1051
- *
1052
- * This list is the same length and order as the corresponding list in the Node, i.e.
1053
- * Node.struct.fields, Node.enum.enumerants, or Node.interface.methods.
1054
- *
1055
- */
1056
- get members() {
1057
- return getList(1, _Node_SourceInfo._Members, this);
1058
- }
1059
- _hasMembers() {
1060
- return !isNull(getPointer(1, this));
1061
- }
1062
- _initMembers(length) {
1063
- return initList(1, _Node_SourceInfo._Members, length, this);
1064
- }
1065
- set members(value) {
1066
- copyFrom(value, getPointer(1, this));
1067
- }
1068
- toString() {
1069
- return "Node_SourceInfo_" + super.toString();
1070
- }
1071
- };
1072
- var Node_Struct = class _Node_Struct extends Struct {
1073
- static {
1074
- __name(this, "Node_Struct");
1075
- }
1076
- static _capnp = {
1077
- displayName: "struct",
1078
- id: "9ea0b19b37fb4435",
1079
- size: new ObjectSize(40, 6)
1080
- };
1081
- static _Fields;
1082
- /**
1083
- * Size of the data section, in words.
1084
- *
1085
- */
1086
- get dataWordCount() {
1087
- return getUint16(14, this);
1088
- }
1089
- set dataWordCount(value) {
1090
- setUint16(14, value, this);
1091
- }
1092
- /**
1093
- * Size of the pointer section, in pointers (which are one word each).
1094
- *
1095
- */
1096
- get pointerCount() {
1097
- return getUint16(24, this);
1098
- }
1099
- set pointerCount(value) {
1100
- setUint16(24, value, this);
1101
- }
1102
- /**
1103
- * The preferred element size to use when encoding a list of this struct. If this is anything
1104
- * other than `inlineComposite` then the struct is one word or less in size and is a candidate
1105
- * for list packing optimization.
1106
- *
1107
- */
1108
- get preferredListEncoding() {
1109
- return getUint16(26, this);
1110
- }
1111
- set preferredListEncoding(value) {
1112
- setUint16(26, value, this);
1113
- }
1114
- /**
1115
- * If true, then this "struct" node is actually not an independent node, but merely represents
1116
- * some named union or group within a particular parent struct. This node's scopeId refers
1117
- * to the parent struct, which may itself be a union/group in yet another struct.
1118
- *
1119
- * All group nodes share the same dataWordCount and pointerCount as the top-level
1120
- * struct, and their fields live in the same ordinal and offset spaces as all other fields in
1121
- * the struct.
1122
- *
1123
- * Note that a named union is considered a special kind of group -- in fact, a named union
1124
- * is exactly equivalent to a group that contains nothing but an unnamed union.
1125
- *
1126
- */
1127
- get isGroup() {
1128
- return getBit(224, this);
1129
- }
1130
- set isGroup(value) {
1131
- setBit(224, value, this);
1132
- }
1133
- /**
1134
- * Number of fields in this struct which are members of an anonymous union, and thus may
1135
- * overlap. If this is non-zero, then a 16-bit discriminant is present indicating which
1136
- * of the overlapping fields is active. This can never be 1 -- if it is non-zero, it must be
1137
- * two or more.
1138
- *
1139
- * Note that the fields of an unnamed union are considered fields of the scope containing the
1140
- * union -- an unnamed union is not its own group. So, a top-level struct may contain a
1141
- * non-zero discriminant count. Named unions, on the other hand, are equivalent to groups
1142
- * containing unnamed unions. So, a named union has its own independent schema node, with
1143
- * `isGroup` = true.
1144
- *
1145
- */
1146
- get discriminantCount() {
1147
- return getUint16(30, this);
1148
- }
1149
- set discriminantCount(value) {
1150
- setUint16(30, value, this);
1151
- }
1152
- /**
1153
- * If `discriminantCount` is non-zero, this is the offset of the union discriminant, in
1154
- * multiples of 16 bits.
1155
- *
1156
- */
1157
- get discriminantOffset() {
1158
- return getUint32(32, this);
1159
- }
1160
- set discriminantOffset(value) {
1161
- setUint32(32, value, this);
1162
- }
1163
- _adoptFields(value) {
1164
- adopt(value, getPointer(3, this));
1165
- }
1166
- _disownFields() {
1167
- return disown(this.fields);
1168
- }
1169
- /**
1170
- * Fields defined within this scope (either the struct's top-level fields, or the fields of
1171
- * a particular group; see `isGroup`).
1172
- *
1173
- * The fields are sorted by ordinal number, but note that because groups share the same
1174
- * ordinal space, the field's index in this list is not necessarily exactly its ordinal.
1175
- * On the other hand, the field's position in this list does remain the same even as the
1176
- * protocol evolves, since it is not possible to insert or remove an earlier ordinal.
1177
- * Therefore, for most use cases, if you want to identify a field by number, it may make the
1178
- * most sense to use the field's index in this list rather than its ordinal.
1179
- *
1180
- */
1181
- get fields() {
1182
- return getList(3, _Node_Struct._Fields, this);
1183
- }
1184
- _hasFields() {
1185
- return !isNull(getPointer(3, this));
1186
- }
1187
- _initFields(length) {
1188
- return initList(3, _Node_Struct._Fields, length, this);
1189
- }
1190
- set fields(value) {
1191
- copyFrom(value, getPointer(3, this));
1192
- }
1193
- toString() {
1194
- return "Node_Struct_" + super.toString();
1195
- }
1196
- };
1197
- var Node_Enum = class _Node_Enum extends Struct {
1198
- static {
1199
- __name(this, "Node_Enum");
1200
- }
1201
- static _capnp = {
1202
- displayName: "enum",
1203
- id: "b54ab3364333f598",
1204
- size: new ObjectSize(40, 6)
1205
- };
1206
- static _Enumerants;
1207
- _adoptEnumerants(value) {
1208
- adopt(value, getPointer(3, this));
1209
- }
1210
- _disownEnumerants() {
1211
- return disown(this.enumerants);
1212
- }
1213
- /**
1214
- * Enumerants ordered by numeric value (ordinal).
1215
- *
1216
- */
1217
- get enumerants() {
1218
- return getList(3, _Node_Enum._Enumerants, this);
1219
- }
1220
- _hasEnumerants() {
1221
- return !isNull(getPointer(3, this));
1222
- }
1223
- _initEnumerants(length) {
1224
- return initList(3, _Node_Enum._Enumerants, length, this);
1225
- }
1226
- set enumerants(value) {
1227
- copyFrom(value, getPointer(3, this));
1228
- }
1229
- toString() {
1230
- return "Node_Enum_" + super.toString();
1231
- }
1232
- };
1233
- var Node_Interface = class _Node_Interface extends Struct {
1234
- static {
1235
- __name(this, "Node_Interface");
1236
- }
1237
- static _capnp = {
1238
- displayName: "interface",
1239
- id: "e82753cff0c2218f",
1240
- size: new ObjectSize(40, 6)
1241
- };
1242
- static _Methods;
1243
- static _Superclasses;
1244
- _adoptMethods(value) {
1245
- adopt(value, getPointer(3, this));
1246
- }
1247
- _disownMethods() {
1248
- return disown(this.methods);
1249
- }
1250
- /**
1251
- * Methods ordered by ordinal.
1252
- *
1253
- */
1254
- get methods() {
1255
- return getList(3, _Node_Interface._Methods, this);
1256
- }
1257
- _hasMethods() {
1258
- return !isNull(getPointer(3, this));
1259
- }
1260
- _initMethods(length) {
1261
- return initList(3, _Node_Interface._Methods, length, this);
1262
- }
1263
- set methods(value) {
1264
- copyFrom(value, getPointer(3, this));
1265
- }
1266
- _adoptSuperclasses(value) {
1267
- adopt(value, getPointer(4, this));
1268
- }
1269
- _disownSuperclasses() {
1270
- return disown(this.superclasses);
1271
- }
1272
- /**
1273
- * Superclasses of this interface.
1274
- *
1275
- */
1276
- get superclasses() {
1277
- return getList(4, _Node_Interface._Superclasses, this);
1278
- }
1279
- _hasSuperclasses() {
1280
- return !isNull(getPointer(4, this));
1281
- }
1282
- _initSuperclasses(length) {
1283
- return initList(4, _Node_Interface._Superclasses, length, this);
1284
- }
1285
- set superclasses(value) {
1286
- copyFrom(value, getPointer(4, this));
1287
- }
1288
- toString() {
1289
- return "Node_Interface_" + super.toString();
1290
- }
1291
- };
1292
- var Node_Const = class extends Struct {
1293
- static {
1294
- __name(this, "Node_Const");
1295
- }
1296
- static _capnp = {
1297
- displayName: "const",
1298
- id: "b18aa5ac7a0d9420",
1299
- size: new ObjectSize(40, 6)
1300
- };
1301
- _adoptType(value) {
1302
- adopt(value, getPointer(3, this));
1303
- }
1304
- _disownType() {
1305
- return disown(this.type);
1306
- }
1307
- get type() {
1308
- return getStruct(3, Type, this);
1309
- }
1310
- _hasType() {
1311
- return !isNull(getPointer(3, this));
1312
- }
1313
- _initType() {
1314
- return initStructAt(3, Type, this);
1315
- }
1316
- set type(value) {
1317
- copyFrom(value, getPointer(3, this));
1318
- }
1319
- _adoptValue(value) {
1320
- adopt(value, getPointer(4, this));
1321
- }
1322
- _disownValue() {
1323
- return disown(this.value);
1324
- }
1325
- get value() {
1326
- return getStruct(4, Value, this);
1327
- }
1328
- _hasValue() {
1329
- return !isNull(getPointer(4, this));
1330
- }
1331
- _initValue() {
1332
- return initStructAt(4, Value, this);
1333
- }
1334
- set value(value) {
1335
- copyFrom(value, getPointer(4, this));
1336
- }
1337
- toString() {
1338
- return "Node_Const_" + super.toString();
1339
- }
1340
- };
1341
- var Node_Annotation = class extends Struct {
1342
- static {
1343
- __name(this, "Node_Annotation");
1344
- }
1345
- static _capnp = {
1346
- displayName: "annotation",
1347
- id: "ec1619d4400a0290",
1348
- size: new ObjectSize(40, 6)
1349
- };
1350
- _adoptType(value) {
1351
- adopt(value, getPointer(3, this));
1352
- }
1353
- _disownType() {
1354
- return disown(this.type);
1355
- }
1356
- get type() {
1357
- return getStruct(3, Type, this);
1358
- }
1359
- _hasType() {
1360
- return !isNull(getPointer(3, this));
1361
- }
1362
- _initType() {
1363
- return initStructAt(3, Type, this);
1364
- }
1365
- set type(value) {
1366
- copyFrom(value, getPointer(3, this));
1367
- }
1368
- get targetsFile() {
1369
- return getBit(112, this);
1370
- }
1371
- set targetsFile(value) {
1372
- setBit(112, value, this);
1373
- }
1374
- get targetsConst() {
1375
- return getBit(113, this);
1376
- }
1377
- set targetsConst(value) {
1378
- setBit(113, value, this);
1379
- }
1380
- get targetsEnum() {
1381
- return getBit(114, this);
1382
- }
1383
- set targetsEnum(value) {
1384
- setBit(114, value, this);
1385
- }
1386
- get targetsEnumerant() {
1387
- return getBit(115, this);
1388
- }
1389
- set targetsEnumerant(value) {
1390
- setBit(115, value, this);
1391
- }
1392
- get targetsStruct() {
1393
- return getBit(116, this);
1394
- }
1395
- set targetsStruct(value) {
1396
- setBit(116, value, this);
1397
- }
1398
- get targetsField() {
1399
- return getBit(117, this);
1400
- }
1401
- set targetsField(value) {
1402
- setBit(117, value, this);
1403
- }
1404
- get targetsUnion() {
1405
- return getBit(118, this);
1406
- }
1407
- set targetsUnion(value) {
1408
- setBit(118, value, this);
1409
- }
1410
- get targetsGroup() {
1411
- return getBit(119, this);
1412
- }
1413
- set targetsGroup(value) {
1414
- setBit(119, value, this);
1415
- }
1416
- get targetsInterface() {
1417
- return getBit(120, this);
1418
- }
1419
- set targetsInterface(value) {
1420
- setBit(120, value, this);
1421
- }
1422
- get targetsMethod() {
1423
- return getBit(121, this);
1424
- }
1425
- set targetsMethod(value) {
1426
- setBit(121, value, this);
1427
- }
1428
- get targetsParam() {
1429
- return getBit(122, this);
1430
- }
1431
- set targetsParam(value) {
1432
- setBit(122, value, this);
1433
- }
1434
- get targetsAnnotation() {
1435
- return getBit(123, this);
1436
- }
1437
- set targetsAnnotation(value) {
1438
- setBit(123, value, this);
1439
- }
1440
- toString() {
1441
- return "Node_Annotation_" + super.toString();
1442
- }
1443
- };
1444
- var Node_Which = {
1445
- FILE: 0,
1446
- /**
1447
- * Name to present to humans to identify this Node. You should not attempt to parse this. Its
1448
- * format could change. It is not guaranteed to be unique.
1449
- *
1450
- * (On Zooko's triangle, this is the node's nickname.)
1451
- *
1452
- */
1453
- STRUCT: 1,
1454
- /**
1455
- * If you want a shorter version of `displayName` (just naming this node, without its surrounding
1456
- * scope), chop off this many characters from the beginning of `displayName`.
1457
- *
1458
- */
1459
- ENUM: 2,
1460
- /**
1461
- * ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
1462
- * at this node, but robust code should avoid relying on this (and, in fact, group nodes are not
1463
- * listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
1464
- * zero if the node has no parent, which is normally only the case with files, but should be
1465
- * allowed for any kind of node (in order to make runtime type generation easier).
1466
- *
1467
- */
1468
- INTERFACE: 3,
1469
- /**
1470
- * List of nodes nested within this node, along with the names under which they were declared.
1471
- *
1472
- */
1473
- CONST: 4,
1474
- /**
1475
- * Annotations applied to this node.
1476
- *
1477
- */
1478
- ANNOTATION: 5
1479
- };
1480
- var Node = class _Node extends Struct {
1481
- static {
1482
- __name(this, "Node");
1483
- }
1484
- static FILE = Node_Which.FILE;
1485
- static STRUCT = Node_Which.STRUCT;
1486
- static ENUM = Node_Which.ENUM;
1487
- static INTERFACE = Node_Which.INTERFACE;
1488
- static CONST = Node_Which.CONST;
1489
- static ANNOTATION = Node_Which.ANNOTATION;
1490
- static Parameter = Node_Parameter;
1491
- static NestedNode = Node_NestedNode;
1492
- static SourceInfo = Node_SourceInfo;
1493
- static _capnp = {
1494
- displayName: "Node",
1495
- id: "e682ab4cf923a417",
1496
- size: new ObjectSize(40, 6)
1497
- };
1498
- static _Parameters;
1499
- static _NestedNodes;
1500
- static _Annotations;
1501
- get id() {
1502
- return getUint64(0, this);
1503
- }
1504
- set id(value) {
1505
- setUint64(0, value, this);
1506
- }
1507
- /**
1508
- * Name to present to humans to identify this Node. You should not attempt to parse this. Its
1509
- * format could change. It is not guaranteed to be unique.
1510
- *
1511
- * (On Zooko's triangle, this is the node's nickname.)
1512
- *
1513
- */
1514
- get displayName() {
1515
- return getText(0, this);
1516
- }
1517
- set displayName(value) {
1518
- setText(0, value, this);
1519
- }
1520
- /**
1521
- * If you want a shorter version of `displayName` (just naming this node, without its surrounding
1522
- * scope), chop off this many characters from the beginning of `displayName`.
1523
- *
1524
- */
1525
- get displayNamePrefixLength() {
1526
- return getUint32(8, this);
1527
- }
1528
- set displayNamePrefixLength(value) {
1529
- setUint32(8, value, this);
1530
- }
1531
- /**
1532
- * ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
1533
- * at this node, but robust code should avoid relying on this (and, in fact, group nodes are not
1534
- * listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
1535
- * zero if the node has no parent, which is normally only the case with files, but should be
1536
- * allowed for any kind of node (in order to make runtime type generation easier).
1537
- *
1538
- */
1539
- get scopeId() {
1540
- return getUint64(16, this);
1541
- }
1542
- set scopeId(value) {
1543
- setUint64(16, value, this);
1544
- }
1545
- _adoptParameters(value) {
1546
- adopt(value, getPointer(5, this));
1547
- }
1548
- _disownParameters() {
1549
- return disown(this.parameters);
1550
- }
1551
- /**
1552
- * If this node is parameterized (generic), the list of parameters. Empty for non-generic types.
1553
- *
1554
- */
1555
- get parameters() {
1556
- return getList(5, _Node._Parameters, this);
1557
- }
1558
- _hasParameters() {
1559
- return !isNull(getPointer(5, this));
1560
- }
1561
- _initParameters(length) {
1562
- return initList(5, _Node._Parameters, length, this);
1563
- }
1564
- set parameters(value) {
1565
- copyFrom(value, getPointer(5, this));
1566
- }
1567
- /**
1568
- * True if this node is generic, meaning that it or one of its parent scopes has a non-empty
1569
- * `parameters`.
1570
- *
1571
- */
1572
- get isGeneric() {
1573
- return getBit(288, this);
1574
- }
1575
- set isGeneric(value) {
1576
- setBit(288, value, this);
1577
- }
1578
- _adoptNestedNodes(value) {
1579
- adopt(value, getPointer(1, this));
1580
- }
1581
- _disownNestedNodes() {
1582
- return disown(this.nestedNodes);
1583
- }
1584
- /**
1585
- * List of nodes nested within this node, along with the names under which they were declared.
1586
- *
1587
- */
1588
- get nestedNodes() {
1589
- return getList(1, _Node._NestedNodes, this);
1590
- }
1591
- _hasNestedNodes() {
1592
- return !isNull(getPointer(1, this));
1593
- }
1594
- _initNestedNodes(length) {
1595
- return initList(1, _Node._NestedNodes, length, this);
1596
- }
1597
- set nestedNodes(value) {
1598
- copyFrom(value, getPointer(1, this));
1599
- }
1600
- _adoptAnnotations(value) {
1601
- adopt(value, getPointer(2, this));
1602
- }
1603
- _disownAnnotations() {
1604
- return disown(this.annotations);
1605
- }
1606
- /**
1607
- * Annotations applied to this node.
1608
- *
1609
- */
1610
- get annotations() {
1611
- return getList(2, _Node._Annotations, this);
1612
- }
1613
- _hasAnnotations() {
1614
- return !isNull(getPointer(2, this));
1615
- }
1616
- _initAnnotations(length) {
1617
- return initList(2, _Node._Annotations, length, this);
1618
- }
1619
- set annotations(value) {
1620
- copyFrom(value, getPointer(2, this));
1621
- }
1622
- get _isFile() {
1623
- return getUint16(12, this) === 0;
1624
- }
1625
- set file(_) {
1626
- setUint16(12, 0, this);
1627
- }
1628
- get struct() {
1629
- testWhich("struct", getUint16(12, this), 1, this);
1630
- return getAs(Node_Struct, this);
1631
- }
1632
- _initStruct() {
1633
- setUint16(12, 1, this);
1634
- return getAs(Node_Struct, this);
1635
- }
1636
- get _isStruct() {
1637
- return getUint16(12, this) === 1;
1638
- }
1639
- set struct(_) {
1640
- setUint16(12, 1, this);
1641
- }
1642
- get enum() {
1643
- testWhich("enum", getUint16(12, this), 2, this);
1644
- return getAs(Node_Enum, this);
1645
- }
1646
- _initEnum() {
1647
- setUint16(12, 2, this);
1648
- return getAs(Node_Enum, this);
1649
- }
1650
- get _isEnum() {
1651
- return getUint16(12, this) === 2;
1652
- }
1653
- set enum(_) {
1654
- setUint16(12, 2, this);
1655
- }
1656
- get interface() {
1657
- testWhich("interface", getUint16(12, this), 3, this);
1658
- return getAs(Node_Interface, this);
1659
- }
1660
- _initInterface() {
1661
- setUint16(12, 3, this);
1662
- return getAs(Node_Interface, this);
1663
- }
1664
- get _isInterface() {
1665
- return getUint16(12, this) === 3;
1666
- }
1667
- set interface(_) {
1668
- setUint16(12, 3, this);
1669
- }
1670
- get const() {
1671
- testWhich("const", getUint16(12, this), 4, this);
1672
- return getAs(Node_Const, this);
1673
- }
1674
- _initConst() {
1675
- setUint16(12, 4, this);
1676
- return getAs(Node_Const, this);
1677
- }
1678
- get _isConst() {
1679
- return getUint16(12, this) === 4;
1680
- }
1681
- set const(_) {
1682
- setUint16(12, 4, this);
1683
- }
1684
- get annotation() {
1685
- testWhich("annotation", getUint16(12, this), 5, this);
1686
- return getAs(Node_Annotation, this);
1687
- }
1688
- _initAnnotation() {
1689
- setUint16(12, 5, this);
1690
- return getAs(Node_Annotation, this);
1691
- }
1692
- get _isAnnotation() {
1693
- return getUint16(12, this) === 5;
1694
- }
1695
- set annotation(_) {
1696
- setUint16(12, 5, this);
1697
- }
1698
- toString() {
1699
- return "Node_" + super.toString();
1700
- }
1701
- which() {
1702
- return getUint16(12, this);
1703
- }
1704
- };
1705
- var Field_Slot = class extends Struct {
1706
- static {
1707
- __name(this, "Field_Slot");
1708
- }
1709
- static _capnp = {
1710
- displayName: "slot",
1711
- id: "c42305476bb4746f",
1712
- size: new ObjectSize(24, 4)
1713
- };
1714
- /**
1715
- * Offset, in units of the field's size, from the beginning of the section in which the field
1716
- * resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the
1717
- * beginning of the data section.
1718
- *
1719
- */
1720
- get offset() {
1721
- return getUint32(4, this);
1722
- }
1723
- set offset(value) {
1724
- setUint32(4, value, this);
1725
- }
1726
- _adoptType(value) {
1727
- adopt(value, getPointer(2, this));
1728
- }
1729
- _disownType() {
1730
- return disown(this.type);
1731
- }
1732
- get type() {
1733
- return getStruct(2, Type, this);
1734
- }
1735
- _hasType() {
1736
- return !isNull(getPointer(2, this));
1737
- }
1738
- _initType() {
1739
- return initStructAt(2, Type, this);
1740
- }
1741
- set type(value) {
1742
- copyFrom(value, getPointer(2, this));
1743
- }
1744
- _adoptDefaultValue(value) {
1745
- adopt(value, getPointer(3, this));
1746
- }
1747
- _disownDefaultValue() {
1748
- return disown(this.defaultValue);
1749
- }
1750
- get defaultValue() {
1751
- return getStruct(3, Value, this);
1752
- }
1753
- _hasDefaultValue() {
1754
- return !isNull(getPointer(3, this));
1755
- }
1756
- _initDefaultValue() {
1757
- return initStructAt(3, Value, this);
1758
- }
1759
- set defaultValue(value) {
1760
- copyFrom(value, getPointer(3, this));
1761
- }
1762
- /**
1763
- * Whether the default value was specified explicitly. Non-explicit default values are always
1764
- * zero or empty values. Usually, whether the default value was explicit shouldn't matter.
1765
- * The main use case for this flag is for structs representing method parameters:
1766
- * explicitly-defaulted parameters may be allowed to be omitted when calling the method.
1767
- *
1768
- */
1769
- get hadExplicitDefault() {
1770
- return getBit(128, this);
1771
- }
1772
- set hadExplicitDefault(value) {
1773
- setBit(128, value, this);
1774
- }
1775
- toString() {
1776
- return "Field_Slot_" + super.toString();
1777
- }
1778
- };
1779
- var Field_Group = class extends Struct {
1780
- static {
1781
- __name(this, "Field_Group");
1782
- }
1783
- static _capnp = {
1784
- displayName: "group",
1785
- id: "cafccddb68db1d11",
1786
- size: new ObjectSize(24, 4)
1787
- };
1788
- /**
1789
- * The ID of the group's node.
1790
- *
1791
- */
1792
- get typeId() {
1793
- return getUint64(16, this);
1794
- }
1795
- set typeId(value) {
1796
- setUint64(16, value, this);
1797
- }
1798
- toString() {
1799
- return "Field_Group_" + super.toString();
1800
- }
1801
- };
1802
- var Field_Ordinal_Which = {
1803
- IMPLICIT: 0,
1804
- /**
1805
- * The original ordinal number given to the field. You probably should NOT use this; if you need
1806
- * a numeric identifier for a field, use its position within the field array for its scope.
1807
- * The ordinal is given here mainly just so that the original schema text can be reproduced given
1808
- * the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job.
1809
- *
1810
- */
1811
- EXPLICIT: 1
1812
- };
1813
- var Field_Ordinal = class extends Struct {
1814
- static {
1815
- __name(this, "Field_Ordinal");
1816
- }
1817
- static IMPLICIT = Field_Ordinal_Which.IMPLICIT;
1818
- static EXPLICIT = Field_Ordinal_Which.EXPLICIT;
1819
- static _capnp = {
1820
- displayName: "ordinal",
1821
- id: "bb90d5c287870be6",
1822
- size: new ObjectSize(24, 4)
1823
- };
1824
- get _isImplicit() {
1825
- return getUint16(10, this) === 0;
1826
- }
1827
- set implicit(_) {
1828
- setUint16(10, 0, this);
1829
- }
1830
- /**
1831
- * The original ordinal number given to the field. You probably should NOT use this; if you need
1832
- * a numeric identifier for a field, use its position within the field array for its scope.
1833
- * The ordinal is given here mainly just so that the original schema text can be reproduced given
1834
- * the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job.
1835
- *
1836
- */
1837
- get explicit() {
1838
- testWhich("explicit", getUint16(10, this), 1, this);
1839
- return getUint16(12, this);
1840
- }
1841
- get _isExplicit() {
1842
- return getUint16(10, this) === 1;
1843
- }
1844
- set explicit(value) {
1845
- setUint16(10, 1, this);
1846
- setUint16(12, value, this);
1847
- }
1848
- toString() {
1849
- return "Field_Ordinal_" + super.toString();
1850
- }
1851
- which() {
1852
- return getUint16(10, this);
1853
- }
1854
- };
1855
- var Field_Which = {
1856
- SLOT: 0,
1857
- /**
1858
- * Indicates where this member appeared in the code, relative to other members.
1859
- * Code ordering may have semantic relevance -- programmers tend to place related fields
1860
- * together. So, using code ordering makes sense in human-readable formats where ordering is
1861
- * otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum
1862
- * value is count(members) - 1. Fields that are members of a union are only ordered relative to
1863
- * the other members of that union, so the maximum value there is count(union.members).
1864
- *
1865
- */
1866
- GROUP: 1
1867
- };
1868
- var Field = class _Field extends Struct {
1869
- static {
1870
- __name(this, "Field");
1871
- }
1872
- static NO_DISCRIMINANT = 65535;
1873
- static SLOT = Field_Which.SLOT;
1874
- static GROUP = Field_Which.GROUP;
1875
- static _capnp = {
1876
- displayName: "Field",
1877
- id: "9aad50a41f4af45f",
1878
- size: new ObjectSize(24, 4),
1879
- defaultDiscriminantValue: getUint16Mask(65535)
1880
- };
1881
- static _Annotations;
1882
- get name() {
1883
- return getText(0, this);
1884
- }
1885
- set name(value) {
1886
- setText(0, value, this);
1887
- }
1888
- /**
1889
- * Indicates where this member appeared in the code, relative to other members.
1890
- * Code ordering may have semantic relevance -- programmers tend to place related fields
1891
- * together. So, using code ordering makes sense in human-readable formats where ordering is
1892
- * otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum
1893
- * value is count(members) - 1. Fields that are members of a union are only ordered relative to
1894
- * the other members of that union, so the maximum value there is count(union.members).
1895
- *
1896
- */
1897
- get codeOrder() {
1898
- return getUint16(0, this);
1899
- }
1900
- set codeOrder(value) {
1901
- setUint16(0, value, this);
1902
- }
1903
- _adoptAnnotations(value) {
1904
- adopt(value, getPointer(1, this));
1905
- }
1906
- _disownAnnotations() {
1907
- return disown(this.annotations);
1908
- }
1909
- get annotations() {
1910
- return getList(1, _Field._Annotations, this);
1911
- }
1912
- _hasAnnotations() {
1913
- return !isNull(getPointer(1, this));
1914
- }
1915
- _initAnnotations(length) {
1916
- return initList(1, _Field._Annotations, length, this);
1917
- }
1918
- set annotations(value) {
1919
- copyFrom(value, getPointer(1, this));
1920
- }
1921
- /**
1922
- * If the field is in a union, this is the value which the union's discriminant should take when
1923
- * the field is active. If the field is not in a union, this is 0xffff.
1924
- *
1925
- */
1926
- get discriminantValue() {
1927
- return getUint16(2, this, _Field._capnp.defaultDiscriminantValue);
1928
- }
1929
- set discriminantValue(value) {
1930
- setUint16(2, value, this, _Field._capnp.defaultDiscriminantValue);
1931
- }
1932
- /**
1933
- * A regular, non-group, non-fixed-list field.
1934
- *
1935
- */
1936
- get slot() {
1937
- testWhich("slot", getUint16(8, this), 0, this);
1938
- return getAs(Field_Slot, this);
1939
- }
1940
- _initSlot() {
1941
- setUint16(8, 0, this);
1942
- return getAs(Field_Slot, this);
1943
- }
1944
- get _isSlot() {
1945
- return getUint16(8, this) === 0;
1946
- }
1947
- set slot(_) {
1948
- setUint16(8, 0, this);
1949
- }
1950
- /**
1951
- * A group.
1952
- *
1953
- */
1954
- get group() {
1955
- testWhich("group", getUint16(8, this), 1, this);
1956
- return getAs(Field_Group, this);
1957
- }
1958
- _initGroup() {
1959
- setUint16(8, 1, this);
1960
- return getAs(Field_Group, this);
1961
- }
1962
- get _isGroup() {
1963
- return getUint16(8, this) === 1;
1964
- }
1965
- set group(_) {
1966
- setUint16(8, 1, this);
1967
- }
1968
- get ordinal() {
1969
- return getAs(Field_Ordinal, this);
1970
- }
1971
- _initOrdinal() {
1972
- return getAs(Field_Ordinal, this);
1973
- }
1974
- toString() {
1975
- return "Field_" + super.toString();
1976
- }
1977
- which() {
1978
- return getUint16(8, this);
1979
- }
1980
- };
1981
- var Enumerant = class _Enumerant extends Struct {
1982
- static {
1983
- __name(this, "Enumerant");
1984
- }
1985
- static _capnp = {
1986
- displayName: "Enumerant",
1987
- id: "978a7cebdc549a4d",
1988
- size: new ObjectSize(8, 2)
1989
- };
1990
- static _Annotations;
1991
- get name() {
1992
- return getText(0, this);
1993
- }
1994
- set name(value) {
1995
- setText(0, value, this);
1996
- }
1997
- /**
1998
- * Specifies order in which the enumerants were declared in the code.
1999
- * Like utils.Field.codeOrder.
2000
- *
2001
- */
2002
- get codeOrder() {
2003
- return getUint16(0, this);
2004
- }
2005
- set codeOrder(value) {
2006
- setUint16(0, value, this);
2007
- }
2008
- _adoptAnnotations(value) {
2009
- adopt(value, getPointer(1, this));
2010
- }
2011
- _disownAnnotations() {
2012
- return disown(this.annotations);
2013
- }
2014
- get annotations() {
2015
- return getList(1, _Enumerant._Annotations, this);
2016
- }
2017
- _hasAnnotations() {
2018
- return !isNull(getPointer(1, this));
2019
- }
2020
- _initAnnotations(length) {
2021
- return initList(1, _Enumerant._Annotations, length, this);
2022
- }
2023
- set annotations(value) {
2024
- copyFrom(value, getPointer(1, this));
2025
- }
2026
- toString() {
2027
- return "Enumerant_" + super.toString();
2028
- }
2029
- };
2030
- var Superclass = class extends Struct {
2031
- static {
2032
- __name(this, "Superclass");
2033
- }
2034
- static _capnp = {
2035
- displayName: "Superclass",
2036
- id: "a9962a9ed0a4d7f8",
2037
- size: new ObjectSize(8, 1)
2038
- };
2039
- get id() {
2040
- return getUint64(0, this);
2041
- }
2042
- set id(value) {
2043
- setUint64(0, value, this);
2044
- }
2045
- _adoptBrand(value) {
2046
- adopt(value, getPointer(0, this));
2047
- }
2048
- _disownBrand() {
2049
- return disown(this.brand);
2050
- }
2051
- get brand() {
2052
- return getStruct(0, Brand, this);
2053
- }
2054
- _hasBrand() {
2055
- return !isNull(getPointer(0, this));
2056
- }
2057
- _initBrand() {
2058
- return initStructAt(0, Brand, this);
2059
- }
2060
- set brand(value) {
2061
- copyFrom(value, getPointer(0, this));
2062
- }
2063
- toString() {
2064
- return "Superclass_" + super.toString();
2065
- }
2066
- };
2067
- var Method = class _Method extends Struct {
2068
- static {
2069
- __name(this, "Method");
2070
- }
2071
- static _capnp = {
2072
- displayName: "Method",
2073
- id: "9500cce23b334d80",
2074
- size: new ObjectSize(24, 5)
2075
- };
2076
- static _ImplicitParameters;
2077
- static _Annotations;
2078
- get name() {
2079
- return getText(0, this);
2080
- }
2081
- set name(value) {
2082
- setText(0, value, this);
2083
- }
2084
- /**
2085
- * Specifies order in which the methods were declared in the code.
2086
- * Like utils.Field.codeOrder.
2087
- *
2088
- */
2089
- get codeOrder() {
2090
- return getUint16(0, this);
2091
- }
2092
- set codeOrder(value) {
2093
- setUint16(0, value, this);
2094
- }
2095
- _adoptImplicitParameters(value) {
2096
- adopt(value, getPointer(4, this));
2097
- }
2098
- _disownImplicitParameters() {
2099
- return disown(this.implicitParameters);
2100
- }
2101
- /**
2102
- * The parameters listed in [] (typically, type / generic parameters), whose bindings are intended
2103
- * to be inferred rather than specified explicitly, although not all languages support this.
2104
- *
2105
- */
2106
- get implicitParameters() {
2107
- return getList(4, _Method._ImplicitParameters, this);
2108
- }
2109
- _hasImplicitParameters() {
2110
- return !isNull(getPointer(4, this));
2111
- }
2112
- _initImplicitParameters(length) {
2113
- return initList(4, _Method._ImplicitParameters, length, this);
2114
- }
2115
- set implicitParameters(value) {
2116
- copyFrom(value, getPointer(4, this));
2117
- }
2118
- /**
2119
- * ID of the parameter struct type. If a named parameter list was specified in the method
2120
- * declaration (rather than a single struct parameter type) then a corresponding struct type is
2121
- * auto-generated. Such an auto-generated type will not be listed in the interface's
2122
- * `nestedNodes` and its `scopeId` will be zero -- it is completely detached from the namespace.
2123
- * (Awkwardly, it does of course inherit generic parameters from the method's scope, which makes
2124
- * this a situation where you can't just climb the scope chain to find where a particular
2125
- * generic parameter was introduced. Making the `scopeId` zero was a mistake.)
2126
- *
2127
- */
2128
- get paramStructType() {
2129
- return getUint64(8, this);
2130
- }
2131
- set paramStructType(value) {
2132
- setUint64(8, value, this);
2133
- }
2134
- _adoptParamBrand(value) {
2135
- adopt(value, getPointer(2, this));
2136
- }
2137
- _disownParamBrand() {
2138
- return disown(this.paramBrand);
2139
- }
2140
- /**
2141
- * Brand of param struct type.
2142
- *
2143
- */
2144
- get paramBrand() {
2145
- return getStruct(2, Brand, this);
2146
- }
2147
- _hasParamBrand() {
2148
- return !isNull(getPointer(2, this));
2149
- }
2150
- _initParamBrand() {
2151
- return initStructAt(2, Brand, this);
2152
- }
2153
- set paramBrand(value) {
2154
- copyFrom(value, getPointer(2, this));
2155
- }
2156
- /**
2157
- * ID of the return struct type; similar to `paramStructType`.
2158
- *
2159
- */
2160
- get resultStructType() {
2161
- return getUint64(16, this);
2162
- }
2163
- set resultStructType(value) {
2164
- setUint64(16, value, this);
2165
- }
2166
- _adoptResultBrand(value) {
2167
- adopt(value, getPointer(3, this));
2168
- }
2169
- _disownResultBrand() {
2170
- return disown(this.resultBrand);
2171
- }
2172
- /**
2173
- * Brand of result struct type.
2174
- *
2175
- */
2176
- get resultBrand() {
2177
- return getStruct(3, Brand, this);
2178
- }
2179
- _hasResultBrand() {
2180
- return !isNull(getPointer(3, this));
2181
- }
2182
- _initResultBrand() {
2183
- return initStructAt(3, Brand, this);
2184
- }
2185
- set resultBrand(value) {
2186
- copyFrom(value, getPointer(3, this));
2187
- }
2188
- _adoptAnnotations(value) {
2189
- adopt(value, getPointer(1, this));
2190
- }
2191
- _disownAnnotations() {
2192
- return disown(this.annotations);
2193
- }
2194
- get annotations() {
2195
- return getList(1, _Method._Annotations, this);
2196
- }
2197
- _hasAnnotations() {
2198
- return !isNull(getPointer(1, this));
2199
- }
2200
- _initAnnotations(length) {
2201
- return initList(1, _Method._Annotations, length, this);
2202
- }
2203
- set annotations(value) {
2204
- copyFrom(value, getPointer(1, this));
2205
- }
2206
- toString() {
2207
- return "Method_" + super.toString();
2208
- }
2209
- };
2210
- var Type_List = class extends Struct {
2211
- static {
2212
- __name(this, "Type_List");
2213
- }
2214
- static _capnp = {
2215
- displayName: "list",
2216
- id: "87e739250a60ea97",
2217
- size: new ObjectSize(24, 1)
2218
- };
2219
- _adoptElementType(value) {
2220
- adopt(value, getPointer(0, this));
2221
- }
2222
- _disownElementType() {
2223
- return disown(this.elementType);
2224
- }
2225
- get elementType() {
2226
- return getStruct(0, Type, this);
2227
- }
2228
- _hasElementType() {
2229
- return !isNull(getPointer(0, this));
2230
- }
2231
- _initElementType() {
2232
- return initStructAt(0, Type, this);
2233
- }
2234
- set elementType(value) {
2235
- copyFrom(value, getPointer(0, this));
2236
- }
2237
- toString() {
2238
- return "Type_List_" + super.toString();
2239
- }
2240
- };
2241
- var Type_Enum = class extends Struct {
2242
- static {
2243
- __name(this, "Type_Enum");
2244
- }
2245
- static _capnp = {
2246
- displayName: "enum",
2247
- id: "9e0e78711a7f87a9",
2248
- size: new ObjectSize(24, 1)
2249
- };
2250
- get typeId() {
2251
- return getUint64(8, this);
2252
- }
2253
- set typeId(value) {
2254
- setUint64(8, value, this);
2255
- }
2256
- _adoptBrand(value) {
2257
- adopt(value, getPointer(0, this));
2258
- }
2259
- _disownBrand() {
2260
- return disown(this.brand);
2261
- }
2262
- get brand() {
2263
- return getStruct(0, Brand, this);
2264
- }
2265
- _hasBrand() {
2266
- return !isNull(getPointer(0, this));
2267
- }
2268
- _initBrand() {
2269
- return initStructAt(0, Brand, this);
2270
- }
2271
- set brand(value) {
2272
- copyFrom(value, getPointer(0, this));
2273
- }
2274
- toString() {
2275
- return "Type_Enum_" + super.toString();
2276
- }
2277
- };
2278
- var Type_Struct = class extends Struct {
2279
- static {
2280
- __name(this, "Type_Struct");
2281
- }
2282
- static _capnp = {
2283
- displayName: "struct",
2284
- id: "ac3a6f60ef4cc6d3",
2285
- size: new ObjectSize(24, 1)
2286
- };
2287
- get typeId() {
2288
- return getUint64(8, this);
2289
- }
2290
- set typeId(value) {
2291
- setUint64(8, value, this);
2292
- }
2293
- _adoptBrand(value) {
2294
- adopt(value, getPointer(0, this));
2295
- }
2296
- _disownBrand() {
2297
- return disown(this.brand);
2298
- }
2299
- get brand() {
2300
- return getStruct(0, Brand, this);
2301
- }
2302
- _hasBrand() {
2303
- return !isNull(getPointer(0, this));
2304
- }
2305
- _initBrand() {
2306
- return initStructAt(0, Brand, this);
2307
- }
2308
- set brand(value) {
2309
- copyFrom(value, getPointer(0, this));
2310
- }
2311
- toString() {
2312
- return "Type_Struct_" + super.toString();
2313
- }
2314
- };
2315
- var Type_Interface = class extends Struct {
2316
- static {
2317
- __name(this, "Type_Interface");
2318
- }
2319
- static _capnp = {
2320
- displayName: "interface",
2321
- id: "ed8bca69f7fb0cbf",
2322
- size: new ObjectSize(24, 1)
2323
- };
2324
- get typeId() {
2325
- return getUint64(8, this);
2326
- }
2327
- set typeId(value) {
2328
- setUint64(8, value, this);
2329
- }
2330
- _adoptBrand(value) {
2331
- adopt(value, getPointer(0, this));
2332
- }
2333
- _disownBrand() {
2334
- return disown(this.brand);
2335
- }
2336
- get brand() {
2337
- return getStruct(0, Brand, this);
2338
- }
2339
- _hasBrand() {
2340
- return !isNull(getPointer(0, this));
2341
- }
2342
- _initBrand() {
2343
- return initStructAt(0, Brand, this);
2344
- }
2345
- set brand(value) {
2346
- copyFrom(value, getPointer(0, this));
2347
- }
2348
- toString() {
2349
- return "Type_Interface_" + super.toString();
2350
- }
2351
- };
2352
- var Type_AnyPointer_Unconstrained_Which = {
2353
- /**
2354
- * truly AnyPointer
2355
- *
2356
- */
2357
- ANY_KIND: 0,
2358
- /**
2359
- * AnyStruct
2360
- *
2361
- */
2362
- STRUCT: 1,
2363
- /**
2364
- * AnyList
2365
- *
2366
- */
2367
- LIST: 2,
2368
- /**
2369
- * Capability
2370
- *
2371
- */
2372
- CAPABILITY: 3
2373
- };
2374
- var Type_AnyPointer_Unconstrained = class extends Struct {
2375
- static {
2376
- __name(this, "Type_AnyPointer_Unconstrained");
2377
- }
2378
- static ANY_KIND = Type_AnyPointer_Unconstrained_Which.ANY_KIND;
2379
- static STRUCT = Type_AnyPointer_Unconstrained_Which.STRUCT;
2380
- static LIST = Type_AnyPointer_Unconstrained_Which.LIST;
2381
- static CAPABILITY = Type_AnyPointer_Unconstrained_Which.CAPABILITY;
2382
- static _capnp = {
2383
- displayName: "unconstrained",
2384
- id: "8e3b5f79fe593656",
2385
- size: new ObjectSize(24, 1)
2386
- };
2387
- get _isAnyKind() {
2388
- return getUint16(10, this) === 0;
2389
- }
2390
- set anyKind(_) {
2391
- setUint16(10, 0, this);
2392
- }
2393
- get _isStruct() {
2394
- return getUint16(10, this) === 1;
2395
- }
2396
- set struct(_) {
2397
- setUint16(10, 1, this);
2398
- }
2399
- get _isList() {
2400
- return getUint16(10, this) === 2;
2401
- }
2402
- set list(_) {
2403
- setUint16(10, 2, this);
2404
- }
2405
- get _isCapability() {
2406
- return getUint16(10, this) === 3;
2407
- }
2408
- set capability(_) {
2409
- setUint16(10, 3, this);
2410
- }
2411
- toString() {
2412
- return "Type_AnyPointer_Unconstrained_" + super.toString();
2413
- }
2414
- which() {
2415
- return getUint16(10, this);
2416
- }
2417
- };
2418
- var Type_AnyPointer_Parameter = class extends Struct {
2419
- static {
2420
- __name(this, "Type_AnyPointer_Parameter");
2421
- }
2422
- static _capnp = {
2423
- displayName: "parameter",
2424
- id: "9dd1f724f4614a85",
2425
- size: new ObjectSize(24, 1)
2426
- };
2427
- /**
2428
- * ID of the generic type whose parameter we're referencing. This should be a parent of the
2429
- * current scope.
2430
- *
2431
- */
2432
- get scopeId() {
2433
- return getUint64(16, this);
2434
- }
2435
- set scopeId(value) {
2436
- setUint64(16, value, this);
2437
- }
2438
- /**
2439
- * Index of the parameter within the generic type's parameter list.
2440
- *
2441
- */
2442
- get parameterIndex() {
2443
- return getUint16(10, this);
2444
- }
2445
- set parameterIndex(value) {
2446
- setUint16(10, value, this);
2447
- }
2448
- toString() {
2449
- return "Type_AnyPointer_Parameter_" + super.toString();
2450
- }
2451
- };
2452
- var Type_AnyPointer_ImplicitMethodParameter = class extends Struct {
2453
- static {
2454
- __name(this, "Type_AnyPointer_ImplicitMethodParameter");
2455
- }
2456
- static _capnp = {
2457
- displayName: "implicitMethodParameter",
2458
- id: "baefc9120c56e274",
2459
- size: new ObjectSize(24, 1)
2460
- };
2461
- get parameterIndex() {
2462
- return getUint16(10, this);
2463
- }
2464
- set parameterIndex(value) {
2465
- setUint16(10, value, this);
2466
- }
2467
- toString() {
2468
- return "Type_AnyPointer_ImplicitMethodParameter_" + super.toString();
2469
- }
2470
- };
2471
- var Type_AnyPointer_Which = {
2472
- /**
2473
- * A regular AnyPointer.
2474
- *
2475
- * The name "unconstrained" means as opposed to constraining it to match a type parameter.
2476
- * In retrospect this name is probably a poor choice given that it may still be constrained
2477
- * to be a struct, list, or capability.
2478
- *
2479
- */
2480
- UNCONSTRAINED: 0,
2481
- /**
2482
- * This is actually a reference to a type parameter defined within this scope.
2483
- *
2484
- */
2485
- PARAMETER: 1,
2486
- /**
2487
- * This is actually a reference to an implicit (generic) parameter of a method. The only
2488
- * legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
2489
- *
2490
- */
2491
- IMPLICIT_METHOD_PARAMETER: 2
2492
- };
2493
- var Type_AnyPointer = class extends Struct {
2494
- static {
2495
- __name(this, "Type_AnyPointer");
2496
- }
2497
- static UNCONSTRAINED = Type_AnyPointer_Which.UNCONSTRAINED;
2498
- static PARAMETER = Type_AnyPointer_Which.PARAMETER;
2499
- static IMPLICIT_METHOD_PARAMETER = Type_AnyPointer_Which.IMPLICIT_METHOD_PARAMETER;
2500
- static _capnp = {
2501
- displayName: "anyPointer",
2502
- id: "c2573fe8a23e49f1",
2503
- size: new ObjectSize(24, 1)
2504
- };
2505
- /**
2506
- * A regular AnyPointer.
2507
- *
2508
- * The name "unconstrained" means as opposed to constraining it to match a type parameter.
2509
- * In retrospect this name is probably a poor choice given that it may still be constrained
2510
- * to be a struct, list, or capability.
2511
- *
2512
- */
2513
- get unconstrained() {
2514
- testWhich("unconstrained", getUint16(8, this), 0, this);
2515
- return getAs(Type_AnyPointer_Unconstrained, this);
2516
- }
2517
- _initUnconstrained() {
2518
- setUint16(8, 0, this);
2519
- return getAs(Type_AnyPointer_Unconstrained, this);
2520
- }
2521
- get _isUnconstrained() {
2522
- return getUint16(8, this) === 0;
2523
- }
2524
- set unconstrained(_) {
2525
- setUint16(8, 0, this);
2526
- }
2527
- /**
2528
- * This is actually a reference to a type parameter defined within this scope.
2529
- *
2530
- */
2531
- get parameter() {
2532
- testWhich("parameter", getUint16(8, this), 1, this);
2533
- return getAs(Type_AnyPointer_Parameter, this);
2534
- }
2535
- _initParameter() {
2536
- setUint16(8, 1, this);
2537
- return getAs(Type_AnyPointer_Parameter, this);
2538
- }
2539
- get _isParameter() {
2540
- return getUint16(8, this) === 1;
2541
- }
2542
- set parameter(_) {
2543
- setUint16(8, 1, this);
2544
- }
2545
- /**
2546
- * This is actually a reference to an implicit (generic) parameter of a method. The only
2547
- * legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
2548
- *
2549
- */
2550
- get implicitMethodParameter() {
2551
- testWhich("implicitMethodParameter", getUint16(8, this), 2, this);
2552
- return getAs(Type_AnyPointer_ImplicitMethodParameter, this);
2553
- }
2554
- _initImplicitMethodParameter() {
2555
- setUint16(8, 2, this);
2556
- return getAs(Type_AnyPointer_ImplicitMethodParameter, this);
2557
- }
2558
- get _isImplicitMethodParameter() {
2559
- return getUint16(8, this) === 2;
2560
- }
2561
- set implicitMethodParameter(_) {
2562
- setUint16(8, 2, this);
2563
- }
2564
- toString() {
2565
- return "Type_AnyPointer_" + super.toString();
2566
- }
2567
- which() {
2568
- return getUint16(8, this);
2569
- }
2570
- };
2571
- var Type_Which = {
2572
- VOID: 0,
2573
- BOOL: 1,
2574
- INT8: 2,
2575
- INT16: 3,
2576
- INT32: 4,
2577
- INT64: 5,
2578
- UINT8: 6,
2579
- UINT16: 7,
2580
- UINT32: 8,
2581
- UINT64: 9,
2582
- FLOAT32: 10,
2583
- FLOAT64: 11,
2584
- TEXT: 12,
2585
- DATA: 13,
2586
- LIST: 14,
2587
- ENUM: 15,
2588
- STRUCT: 16,
2589
- INTERFACE: 17,
2590
- ANY_POINTER: 18
2591
- };
2592
- var Type = class extends Struct {
2593
- static {
2594
- __name(this, "Type");
2595
- }
2596
- static VOID = Type_Which.VOID;
2597
- static BOOL = Type_Which.BOOL;
2598
- static INT8 = Type_Which.INT8;
2599
- static INT16 = Type_Which.INT16;
2600
- static INT32 = Type_Which.INT32;
2601
- static INT64 = Type_Which.INT64;
2602
- static UINT8 = Type_Which.UINT8;
2603
- static UINT16 = Type_Which.UINT16;
2604
- static UINT32 = Type_Which.UINT32;
2605
- static UINT64 = Type_Which.UINT64;
2606
- static FLOAT32 = Type_Which.FLOAT32;
2607
- static FLOAT64 = Type_Which.FLOAT64;
2608
- static TEXT = Type_Which.TEXT;
2609
- static DATA = Type_Which.DATA;
2610
- static LIST = Type_Which.LIST;
2611
- static ENUM = Type_Which.ENUM;
2612
- static STRUCT = Type_Which.STRUCT;
2613
- static INTERFACE = Type_Which.INTERFACE;
2614
- static ANY_POINTER = Type_Which.ANY_POINTER;
2615
- static _capnp = {
2616
- displayName: "Type",
2617
- id: "d07378ede1f9cc60",
2618
- size: new ObjectSize(24, 1)
2619
- };
2620
- get _isVoid() {
2621
- return getUint16(0, this) === 0;
2622
- }
2623
- set void(_) {
2624
- setUint16(0, 0, this);
2625
- }
2626
- get _isBool() {
2627
- return getUint16(0, this) === 1;
2628
- }
2629
- set bool(_) {
2630
- setUint16(0, 1, this);
2631
- }
2632
- get _isInt8() {
2633
- return getUint16(0, this) === 2;
2634
- }
2635
- set int8(_) {
2636
- setUint16(0, 2, this);
2637
- }
2638
- get _isInt16() {
2639
- return getUint16(0, this) === 3;
2640
- }
2641
- set int16(_) {
2642
- setUint16(0, 3, this);
2643
- }
2644
- get _isInt32() {
2645
- return getUint16(0, this) === 4;
2646
- }
2647
- set int32(_) {
2648
- setUint16(0, 4, this);
2649
- }
2650
- get _isInt64() {
2651
- return getUint16(0, this) === 5;
2652
- }
2653
- set int64(_) {
2654
- setUint16(0, 5, this);
2655
- }
2656
- get _isUint8() {
2657
- return getUint16(0, this) === 6;
2658
- }
2659
- set uint8(_) {
2660
- setUint16(0, 6, this);
2661
- }
2662
- get _isUint16() {
2663
- return getUint16(0, this) === 7;
2664
- }
2665
- set uint16(_) {
2666
- setUint16(0, 7, this);
2667
- }
2668
- get _isUint32() {
2669
- return getUint16(0, this) === 8;
2670
- }
2671
- set uint32(_) {
2672
- setUint16(0, 8, this);
2673
- }
2674
- get _isUint64() {
2675
- return getUint16(0, this) === 9;
2676
- }
2677
- set uint64(_) {
2678
- setUint16(0, 9, this);
2679
- }
2680
- get _isFloat32() {
2681
- return getUint16(0, this) === 10;
2682
- }
2683
- set float32(_) {
2684
- setUint16(0, 10, this);
2685
- }
2686
- get _isFloat64() {
2687
- return getUint16(0, this) === 11;
2688
- }
2689
- set float64(_) {
2690
- setUint16(0, 11, this);
2691
- }
2692
- get _isText() {
2693
- return getUint16(0, this) === 12;
2694
- }
2695
- set text(_) {
2696
- setUint16(0, 12, this);
2697
- }
2698
- get _isData() {
2699
- return getUint16(0, this) === 13;
2700
- }
2701
- set data(_) {
2702
- setUint16(0, 13, this);
2703
- }
2704
- get list() {
2705
- testWhich("list", getUint16(0, this), 14, this);
2706
- return getAs(Type_List, this);
2707
- }
2708
- _initList() {
2709
- setUint16(0, 14, this);
2710
- return getAs(Type_List, this);
2711
- }
2712
- get _isList() {
2713
- return getUint16(0, this) === 14;
2714
- }
2715
- set list(_) {
2716
- setUint16(0, 14, this);
2717
- }
2718
- get enum() {
2719
- testWhich("enum", getUint16(0, this), 15, this);
2720
- return getAs(Type_Enum, this);
2721
- }
2722
- _initEnum() {
2723
- setUint16(0, 15, this);
2724
- return getAs(Type_Enum, this);
2725
- }
2726
- get _isEnum() {
2727
- return getUint16(0, this) === 15;
2728
- }
2729
- set enum(_) {
2730
- setUint16(0, 15, this);
2731
- }
2732
- get struct() {
2733
- testWhich("struct", getUint16(0, this), 16, this);
2734
- return getAs(Type_Struct, this);
2735
- }
2736
- _initStruct() {
2737
- setUint16(0, 16, this);
2738
- return getAs(Type_Struct, this);
2739
- }
2740
- get _isStruct() {
2741
- return getUint16(0, this) === 16;
2742
- }
2743
- set struct(_) {
2744
- setUint16(0, 16, this);
2745
- }
2746
- get interface() {
2747
- testWhich("interface", getUint16(0, this), 17, this);
2748
- return getAs(Type_Interface, this);
2749
- }
2750
- _initInterface() {
2751
- setUint16(0, 17, this);
2752
- return getAs(Type_Interface, this);
2753
- }
2754
- get _isInterface() {
2755
- return getUint16(0, this) === 17;
2756
- }
2757
- set interface(_) {
2758
- setUint16(0, 17, this);
2759
- }
2760
- get anyPointer() {
2761
- testWhich("anyPointer", getUint16(0, this), 18, this);
2762
- return getAs(Type_AnyPointer, this);
2763
- }
2764
- _initAnyPointer() {
2765
- setUint16(0, 18, this);
2766
- return getAs(Type_AnyPointer, this);
2767
- }
2768
- get _isAnyPointer() {
2769
- return getUint16(0, this) === 18;
2770
- }
2771
- set anyPointer(_) {
2772
- setUint16(0, 18, this);
2773
- }
2774
- toString() {
2775
- return "Type_" + super.toString();
2776
- }
2777
- which() {
2778
- return getUint16(0, this);
2779
- }
2780
- };
2781
- var Brand_Scope_Which = {
2782
- /**
2783
- * ID of the scope to which these params apply.
2784
- *
2785
- */
2786
- BIND: 0,
2787
- /**
2788
- * List of parameter bindings.
2789
- *
2790
- */
2791
- INHERIT: 1
2792
- };
2793
- var Brand_Scope = class _Brand_Scope extends Struct {
2794
- static {
2795
- __name(this, "Brand_Scope");
2796
- }
2797
- static BIND = Brand_Scope_Which.BIND;
2798
- static INHERIT = Brand_Scope_Which.INHERIT;
2799
- static _capnp = {
2800
- displayName: "Scope",
2801
- id: "abd73485a9636bc9",
2802
- size: new ObjectSize(16, 1)
2803
- };
2804
- static _Bind;
2805
- /**
2806
- * ID of the scope to which these params apply.
2807
- *
2808
- */
2809
- get scopeId() {
2810
- return getUint64(0, this);
2811
- }
2812
- set scopeId(value) {
2813
- setUint64(0, value, this);
2814
- }
2815
- _adoptBind(value) {
2816
- setUint16(8, 0, this);
2817
- adopt(value, getPointer(0, this));
2818
- }
2819
- _disownBind() {
2820
- return disown(this.bind);
2821
- }
2822
- /**
2823
- * List of parameter bindings.
2824
- *
2825
- */
2826
- get bind() {
2827
- testWhich("bind", getUint16(8, this), 0, this);
2828
- return getList(0, _Brand_Scope._Bind, this);
2829
- }
2830
- _hasBind() {
2831
- return !isNull(getPointer(0, this));
2832
- }
2833
- _initBind(length) {
2834
- setUint16(8, 0, this);
2835
- return initList(0, _Brand_Scope._Bind, length, this);
2836
- }
2837
- get _isBind() {
2838
- return getUint16(8, this) === 0;
2839
- }
2840
- set bind(value) {
2841
- setUint16(8, 0, this);
2842
- copyFrom(value, getPointer(0, this));
2843
- }
2844
- get _isInherit() {
2845
- return getUint16(8, this) === 1;
2846
- }
2847
- set inherit(_) {
2848
- setUint16(8, 1, this);
2849
- }
2850
- toString() {
2851
- return "Brand_Scope_" + super.toString();
2852
- }
2853
- which() {
2854
- return getUint16(8, this);
2855
- }
2856
- };
2857
- var Brand_Binding_Which = {
2858
- UNBOUND: 0,
2859
- TYPE: 1
2860
- };
2861
- var Brand_Binding = class extends Struct {
2862
- static {
2863
- __name(this, "Brand_Binding");
2864
- }
2865
- static UNBOUND = Brand_Binding_Which.UNBOUND;
2866
- static TYPE = Brand_Binding_Which.TYPE;
2867
- static _capnp = {
2868
- displayName: "Binding",
2869
- id: "c863cd16969ee7fc",
2870
- size: new ObjectSize(8, 1)
2871
- };
2872
- get _isUnbound() {
2873
- return getUint16(0, this) === 0;
2874
- }
2875
- set unbound(_) {
2876
- setUint16(0, 0, this);
2877
- }
2878
- _adoptType(value) {
2879
- setUint16(0, 1, this);
2880
- adopt(value, getPointer(0, this));
2881
- }
2882
- _disownType() {
2883
- return disown(this.type);
2884
- }
2885
- get type() {
2886
- testWhich("type", getUint16(0, this), 1, this);
2887
- return getStruct(0, Type, this);
2888
- }
2889
- _hasType() {
2890
- return !isNull(getPointer(0, this));
2891
- }
2892
- _initType() {
2893
- setUint16(0, 1, this);
2894
- return initStructAt(0, Type, this);
2895
- }
2896
- get _isType() {
2897
- return getUint16(0, this) === 1;
2898
- }
2899
- set type(value) {
2900
- setUint16(0, 1, this);
2901
- copyFrom(value, getPointer(0, this));
2902
- }
2903
- toString() {
2904
- return "Brand_Binding_" + super.toString();
2905
- }
2906
- which() {
2907
- return getUint16(0, this);
2908
- }
2909
- };
2910
- var Brand = class _Brand extends Struct {
2911
- static {
2912
- __name(this, "Brand");
2913
- }
2914
- static Scope = Brand_Scope;
2915
- static Binding = Brand_Binding;
2916
- static _capnp = {
2917
- displayName: "Brand",
2918
- id: "903455f06065422b",
2919
- size: new ObjectSize(0, 1)
2920
- };
2921
- static _Scopes;
2922
- _adoptScopes(value) {
2923
- adopt(value, getPointer(0, this));
2924
- }
2925
- _disownScopes() {
2926
- return disown(this.scopes);
2927
- }
2928
- /**
2929
- * For each of the target type and each of its parent scopes, a parameterization may be included
2930
- * in this list. If no parameterization is included for a particular relevant scope, then either
2931
- * that scope has no parameters or all parameters should be considered to be `AnyPointer`.
2932
- *
2933
- */
2934
- get scopes() {
2935
- return getList(0, _Brand._Scopes, this);
2936
- }
2937
- _hasScopes() {
2938
- return !isNull(getPointer(0, this));
2939
- }
2940
- _initScopes(length) {
2941
- return initList(0, _Brand._Scopes, length, this);
2942
- }
2943
- set scopes(value) {
2944
- copyFrom(value, getPointer(0, this));
2945
- }
2946
- toString() {
2947
- return "Brand_" + super.toString();
2948
- }
2949
- };
2950
- var Value_Which = {
2951
- VOID: 0,
2952
- BOOL: 1,
2953
- INT8: 2,
2954
- INT16: 3,
2955
- INT32: 4,
2956
- INT64: 5,
2957
- UINT8: 6,
2958
- UINT16: 7,
2959
- UINT32: 8,
2960
- UINT64: 9,
2961
- FLOAT32: 10,
2962
- FLOAT64: 11,
2963
- TEXT: 12,
2964
- DATA: 13,
2965
- LIST: 14,
2966
- ENUM: 15,
2967
- STRUCT: 16,
2968
- /**
2969
- * The only interface value that can be represented statically is "null", whose methods always
2970
- * throw exceptions.
2971
- *
2972
- */
2973
- INTERFACE: 17,
2974
- ANY_POINTER: 18
2975
- };
2976
- var Value = class extends Struct {
2977
- static {
2978
- __name(this, "Value");
2979
- }
2980
- static VOID = Value_Which.VOID;
2981
- static BOOL = Value_Which.BOOL;
2982
- static INT8 = Value_Which.INT8;
2983
- static INT16 = Value_Which.INT16;
2984
- static INT32 = Value_Which.INT32;
2985
- static INT64 = Value_Which.INT64;
2986
- static UINT8 = Value_Which.UINT8;
2987
- static UINT16 = Value_Which.UINT16;
2988
- static UINT32 = Value_Which.UINT32;
2989
- static UINT64 = Value_Which.UINT64;
2990
- static FLOAT32 = Value_Which.FLOAT32;
2991
- static FLOAT64 = Value_Which.FLOAT64;
2992
- static TEXT = Value_Which.TEXT;
2993
- static DATA = Value_Which.DATA;
2994
- static LIST = Value_Which.LIST;
2995
- static ENUM = Value_Which.ENUM;
2996
- static STRUCT = Value_Which.STRUCT;
2997
- static INTERFACE = Value_Which.INTERFACE;
2998
- static ANY_POINTER = Value_Which.ANY_POINTER;
2999
- static _capnp = {
3000
- displayName: "Value",
3001
- id: "ce23dcd2d7b00c9b",
3002
- size: new ObjectSize(16, 1)
3003
- };
3004
- get _isVoid() {
3005
- return getUint16(0, this) === 0;
3006
- }
3007
- set void(_) {
3008
- setUint16(0, 0, this);
3009
- }
3010
- get bool() {
3011
- testWhich("bool", getUint16(0, this), 1, this);
3012
- return getBit(16, this);
3013
- }
3014
- get _isBool() {
3015
- return getUint16(0, this) === 1;
3016
- }
3017
- set bool(value) {
3018
- setUint16(0, 1, this);
3019
- setBit(16, value, this);
3020
- }
3021
- get int8() {
3022
- testWhich("int8", getUint16(0, this), 2, this);
3023
- return getInt8(2, this);
3024
- }
3025
- get _isInt8() {
3026
- return getUint16(0, this) === 2;
3027
- }
3028
- set int8(value) {
3029
- setUint16(0, 2, this);
3030
- setInt8(2, value, this);
3031
- }
3032
- get int16() {
3033
- testWhich("int16", getUint16(0, this), 3, this);
3034
- return getInt16(2, this);
3035
- }
3036
- get _isInt16() {
3037
- return getUint16(0, this) === 3;
3038
- }
3039
- set int16(value) {
3040
- setUint16(0, 3, this);
3041
- setInt16(2, value, this);
3042
- }
3043
- get int32() {
3044
- testWhich("int32", getUint16(0, this), 4, this);
3045
- return getInt32(4, this);
3046
- }
3047
- get _isInt32() {
3048
- return getUint16(0, this) === 4;
3049
- }
3050
- set int32(value) {
3051
- setUint16(0, 4, this);
3052
- setInt32(4, value, this);
3053
- }
3054
- get int64() {
3055
- testWhich("int64", getUint16(0, this), 5, this);
3056
- return getInt64(8, this);
3057
- }
3058
- get _isInt64() {
3059
- return getUint16(0, this) === 5;
3060
- }
3061
- set int64(value) {
3062
- setUint16(0, 5, this);
3063
- setInt64(8, value, this);
3064
- }
3065
- get uint8() {
3066
- testWhich("uint8", getUint16(0, this), 6, this);
3067
- return getUint8(2, this);
3068
- }
3069
- get _isUint8() {
3070
- return getUint16(0, this) === 6;
3071
- }
3072
- set uint8(value) {
3073
- setUint16(0, 6, this);
3074
- setUint8(2, value, this);
3075
- }
3076
- get uint16() {
3077
- testWhich("uint16", getUint16(0, this), 7, this);
3078
- return getUint16(2, this);
3079
- }
3080
- get _isUint16() {
3081
- return getUint16(0, this) === 7;
3082
- }
3083
- set uint16(value) {
3084
- setUint16(0, 7, this);
3085
- setUint16(2, value, this);
3086
- }
3087
- get uint32() {
3088
- testWhich("uint32", getUint16(0, this), 8, this);
3089
- return getUint32(4, this);
3090
- }
3091
- get _isUint32() {
3092
- return getUint16(0, this) === 8;
3093
- }
3094
- set uint32(value) {
3095
- setUint16(0, 8, this);
3096
- setUint32(4, value, this);
3097
- }
3098
- get uint64() {
3099
- testWhich("uint64", getUint16(0, this), 9, this);
3100
- return getUint64(8, this);
3101
- }
3102
- get _isUint64() {
3103
- return getUint16(0, this) === 9;
3104
- }
3105
- set uint64(value) {
3106
- setUint16(0, 9, this);
3107
- setUint64(8, value, this);
3108
- }
3109
- get float32() {
3110
- testWhich("float32", getUint16(0, this), 10, this);
3111
- return getFloat32(4, this);
3112
- }
3113
- get _isFloat32() {
3114
- return getUint16(0, this) === 10;
3115
- }
3116
- set float32(value) {
3117
- setUint16(0, 10, this);
3118
- setFloat32(4, value, this);
3119
- }
3120
- get float64() {
3121
- testWhich("float64", getUint16(0, this), 11, this);
3122
- return getFloat64(8, this);
3123
- }
3124
- get _isFloat64() {
3125
- return getUint16(0, this) === 11;
3126
- }
3127
- set float64(value) {
3128
- setUint16(0, 11, this);
3129
- setFloat64(8, value, this);
3130
- }
3131
- get text() {
3132
- testWhich("text", getUint16(0, this), 12, this);
3133
- return getText(0, this);
3134
- }
3135
- get _isText() {
3136
- return getUint16(0, this) === 12;
3137
- }
3138
- set text(value) {
3139
- setUint16(0, 12, this);
3140
- setText(0, value, this);
3141
- }
3142
- _adoptData(value) {
3143
- setUint16(0, 13, this);
3144
- adopt(value, getPointer(0, this));
3145
- }
3146
- _disownData() {
3147
- return disown(this.data);
3148
- }
3149
- get data() {
3150
- testWhich("data", getUint16(0, this), 13, this);
3151
- return getData(0, this);
3152
- }
3153
- _hasData() {
3154
- return !isNull(getPointer(0, this));
3155
- }
3156
- _initData(length) {
3157
- setUint16(0, 13, this);
3158
- return initData(0, length, this);
3159
- }
3160
- get _isData() {
3161
- return getUint16(0, this) === 13;
3162
- }
3163
- set data(value) {
3164
- setUint16(0, 13, this);
3165
- copyFrom(value, getPointer(0, this));
3166
- }
3167
- _adoptList(value) {
3168
- setUint16(0, 14, this);
3169
- adopt(value, getPointer(0, this));
3170
- }
3171
- _disownList() {
3172
- return disown(this.list);
3173
- }
3174
- get list() {
3175
- testWhich("list", getUint16(0, this), 14, this);
3176
- return getPointer(0, this);
3177
- }
3178
- _hasList() {
3179
- return !isNull(getPointer(0, this));
3180
- }
3181
- get _isList() {
3182
- return getUint16(0, this) === 14;
3183
- }
3184
- set list(value) {
3185
- setUint16(0, 14, this);
3186
- copyFrom(value, getPointer(0, this));
3187
- }
3188
- get enum() {
3189
- testWhich("enum", getUint16(0, this), 15, this);
3190
- return getUint16(2, this);
3191
- }
3192
- get _isEnum() {
3193
- return getUint16(0, this) === 15;
3194
- }
3195
- set enum(value) {
3196
- setUint16(0, 15, this);
3197
- setUint16(2, value, this);
3198
- }
3199
- _adoptStruct(value) {
3200
- setUint16(0, 16, this);
3201
- adopt(value, getPointer(0, this));
3202
- }
3203
- _disownStruct() {
3204
- return disown(this.struct);
3205
- }
3206
- get struct() {
3207
- testWhich("struct", getUint16(0, this), 16, this);
3208
- return getPointer(0, this);
3209
- }
3210
- _hasStruct() {
3211
- return !isNull(getPointer(0, this));
3212
- }
3213
- get _isStruct() {
3214
- return getUint16(0, this) === 16;
3215
- }
3216
- set struct(value) {
3217
- setUint16(0, 16, this);
3218
- copyFrom(value, getPointer(0, this));
3219
- }
3220
- get _isInterface() {
3221
- return getUint16(0, this) === 17;
3222
- }
3223
- set interface(_) {
3224
- setUint16(0, 17, this);
3225
- }
3226
- _adoptAnyPointer(value) {
3227
- setUint16(0, 18, this);
3228
- adopt(value, getPointer(0, this));
3229
- }
3230
- _disownAnyPointer() {
3231
- return disown(this.anyPointer);
3232
- }
3233
- get anyPointer() {
3234
- testWhich("anyPointer", getUint16(0, this), 18, this);
3235
- return getPointer(0, this);
3236
- }
3237
- _hasAnyPointer() {
3238
- return !isNull(getPointer(0, this));
3239
- }
3240
- get _isAnyPointer() {
3241
- return getUint16(0, this) === 18;
3242
- }
3243
- set anyPointer(value) {
3244
- setUint16(0, 18, this);
3245
- copyFrom(value, getPointer(0, this));
3246
- }
3247
- toString() {
3248
- return "Value_" + super.toString();
3249
- }
3250
- which() {
3251
- return getUint16(0, this);
3252
- }
3253
- };
3254
- var Annotation = class extends Struct {
3255
- static {
3256
- __name(this, "Annotation");
3257
- }
3258
- static _capnp = {
3259
- displayName: "Annotation",
3260
- id: "f1c8950dab257542",
3261
- size: new ObjectSize(8, 2)
3262
- };
3263
- /**
3264
- * ID of the annotation node.
3265
- *
3266
- */
3267
- get id() {
3268
- return getUint64(0, this);
3269
- }
3270
- set id(value) {
3271
- setUint64(0, value, this);
3272
- }
3273
- _adoptBrand(value) {
3274
- adopt(value, getPointer(1, this));
3275
- }
3276
- _disownBrand() {
3277
- return disown(this.brand);
3278
- }
3279
- /**
3280
- * Brand of the annotation.
3281
- *
3282
- * Note that the annotation itself is not allowed to be parameterized, but its scope might be.
3283
- *
3284
- */
3285
- get brand() {
3286
- return getStruct(1, Brand, this);
3287
- }
3288
- _hasBrand() {
3289
- return !isNull(getPointer(1, this));
3290
- }
3291
- _initBrand() {
3292
- return initStructAt(1, Brand, this);
3293
- }
3294
- set brand(value) {
3295
- copyFrom(value, getPointer(1, this));
3296
- }
3297
- _adoptValue(value) {
3298
- adopt(value, getPointer(0, this));
3299
- }
3300
- _disownValue() {
3301
- return disown(this.value);
3302
- }
3303
- get value() {
3304
- return getStruct(0, Value, this);
3305
- }
3306
- _hasValue() {
3307
- return !isNull(getPointer(0, this));
3308
- }
3309
- _initValue() {
3310
- return initStructAt(0, Value, this);
3311
- }
3312
- set value(value) {
3313
- copyFrom(value, getPointer(0, this));
3314
- }
3315
- toString() {
3316
- return "Annotation_" + super.toString();
3317
- }
3318
- };
3319
- var ElementSize = {
3320
- /**
3321
- * aka "void", but that's a keyword.
3322
- *
3323
- */
3324
- EMPTY: 0,
3325
- BIT: 1,
3326
- BYTE: 2,
3327
- TWO_BYTES: 3,
3328
- FOUR_BYTES: 4,
3329
- EIGHT_BYTES: 5,
3330
- POINTER: 6,
3331
- INLINE_COMPOSITE: 7
3332
- };
3333
- var CapnpVersion = class extends Struct {
3334
- static {
3335
- __name(this, "CapnpVersion");
3336
- }
3337
- static _capnp = {
3338
- displayName: "CapnpVersion",
3339
- id: "d85d305b7d839963",
3340
- size: new ObjectSize(8, 0)
3341
- };
3342
- get major() {
3343
- return getUint16(0, this);
3344
- }
3345
- set major(value) {
3346
- setUint16(0, value, this);
3347
- }
3348
- get minor() {
3349
- return getUint8(2, this);
3350
- }
3351
- set minor(value) {
3352
- setUint8(2, value, this);
3353
- }
3354
- get micro() {
3355
- return getUint8(3, this);
3356
- }
3357
- set micro(value) {
3358
- setUint8(3, value, this);
3359
- }
3360
- toString() {
3361
- return "CapnpVersion_" + super.toString();
3362
- }
3363
- };
3364
- var CodeGeneratorRequest_RequestedFile_Import = class extends Struct {
3365
- static {
3366
- __name(this, "CodeGeneratorRequest_RequestedFile_Import");
3367
- }
3368
- static _capnp = {
3369
- displayName: "Import",
3370
- id: "ae504193122357e5",
3371
- size: new ObjectSize(8, 1)
3372
- };
3373
- /**
3374
- * ID of the imported file.
3375
- *
3376
- */
3377
- get id() {
3378
- return getUint64(0, this);
3379
- }
3380
- set id(value) {
3381
- setUint64(0, value, this);
3382
- }
3383
- /**
3384
- * Name which *this* file used to refer to the foreign file. This may be a relative name.
3385
- * This information is provided because it might be useful for code generation, e.g. to
3386
- * generate #include directives in C++. We don't put this in Node.file because this
3387
- * information is only meaningful at compile time anyway.
3388
- *
3389
- * (On Zooko's triangle, this is the import's petname according to the importing file.)
3390
- *
3391
- */
3392
- get name() {
3393
- return getText(0, this);
3394
- }
3395
- set name(value) {
3396
- setText(0, value, this);
3397
- }
3398
- toString() {
3399
- return "CodeGeneratorRequest_RequestedFile_Import_" + super.toString();
3400
- }
3401
- };
3402
- var CodeGeneratorRequest_RequestedFile = class _CodeGeneratorRequest_RequestedFile extends Struct {
3403
- static {
3404
- __name(this, "CodeGeneratorRequest_RequestedFile");
3405
- }
3406
- static Import = CodeGeneratorRequest_RequestedFile_Import;
3407
- static _capnp = {
3408
- displayName: "RequestedFile",
3409
- id: "cfea0eb02e810062",
3410
- size: new ObjectSize(8, 2)
3411
- };
3412
- static _Imports;
3413
- /**
3414
- * ID of the file.
3415
- *
3416
- */
3417
- get id() {
3418
- return getUint64(0, this);
3419
- }
3420
- set id(value) {
3421
- setUint64(0, value, this);
3422
- }
3423
- /**
3424
- * Name of the file as it appeared on the command-line (minus the src-prefix). You may use
3425
- * this to decide where to write the output.
3426
- *
3427
- */
3428
- get filename() {
3429
- return getText(0, this);
3430
- }
3431
- set filename(value) {
3432
- setText(0, value, this);
3433
- }
3434
- _adoptImports(value) {
3435
- adopt(value, getPointer(1, this));
3436
- }
3437
- _disownImports() {
3438
- return disown(this.imports);
3439
- }
3440
- /**
3441
- * List of all imported paths seen in this file.
3442
- *
3443
- */
3444
- get imports() {
3445
- return getList(1, _CodeGeneratorRequest_RequestedFile._Imports, this);
3446
- }
3447
- _hasImports() {
3448
- return !isNull(getPointer(1, this));
3449
- }
3450
- _initImports(length) {
3451
- return initList(1, _CodeGeneratorRequest_RequestedFile._Imports, length, this);
3452
- }
3453
- set imports(value) {
3454
- copyFrom(value, getPointer(1, this));
3455
- }
3456
- toString() {
3457
- return "CodeGeneratorRequest_RequestedFile_" + super.toString();
3458
- }
3459
- };
3460
- var CodeGeneratorRequest = class _CodeGeneratorRequest extends Struct {
3461
- static {
3462
- __name(this, "CodeGeneratorRequest");
3463
- }
3464
- static RequestedFile = CodeGeneratorRequest_RequestedFile;
3465
- static _capnp = {
3466
- displayName: "CodeGeneratorRequest",
3467
- id: "bfc546f6210ad7ce",
3468
- size: new ObjectSize(0, 4)
3469
- };
3470
- static _Nodes;
3471
- static _SourceInfo;
3472
- static _RequestedFiles;
3473
- _adoptCapnpVersion(value) {
3474
- adopt(value, getPointer(2, this));
3475
- }
3476
- _disownCapnpVersion() {
3477
- return disown(this.capnpVersion);
3478
- }
3479
- /**
3480
- * Version of the `capnp` executable. Generally, code generators should ignore this, but the code
3481
- * generators that ship with `capnp` itself will print a warning if this mismatches since that
3482
- * probably indicates something is misconfigured.
3483
- *
3484
- * The first version of 'capnp' to set this was 0.6.0. So, if it's missing, the compiler version
3485
- * is older than that.
3486
- *
3487
- */
3488
- get capnpVersion() {
3489
- return getStruct(2, CapnpVersion, this);
3490
- }
3491
- _hasCapnpVersion() {
3492
- return !isNull(getPointer(2, this));
3493
- }
3494
- _initCapnpVersion() {
3495
- return initStructAt(2, CapnpVersion, this);
3496
- }
3497
- set capnpVersion(value) {
3498
- copyFrom(value, getPointer(2, this));
3499
- }
3500
- _adoptNodes(value) {
3501
- adopt(value, getPointer(0, this));
3502
- }
3503
- _disownNodes() {
3504
- return disown(this.nodes);
3505
- }
3506
- /**
3507
- * All nodes parsed by the compiler, including for the files on the command line and their
3508
- * imports.
3509
- *
3510
- */
3511
- get nodes() {
3512
- return getList(0, _CodeGeneratorRequest._Nodes, this);
3513
- }
3514
- _hasNodes() {
3515
- return !isNull(getPointer(0, this));
3516
- }
3517
- _initNodes(length) {
3518
- return initList(0, _CodeGeneratorRequest._Nodes, length, this);
3519
- }
3520
- set nodes(value) {
3521
- copyFrom(value, getPointer(0, this));
3522
- }
3523
- _adoptSourceInfo(value) {
3524
- adopt(value, getPointer(3, this));
3525
- }
3526
- _disownSourceInfo() {
3527
- return disown(this.sourceInfo);
3528
- }
3529
- /**
3530
- * Information about the original source code for each node, where available. This array may be
3531
- * omitted or may be missing some nodes if no info is available for them.
3532
- *
3533
- */
3534
- get sourceInfo() {
3535
- return getList(3, _CodeGeneratorRequest._SourceInfo, this);
3536
- }
3537
- _hasSourceInfo() {
3538
- return !isNull(getPointer(3, this));
3539
- }
3540
- _initSourceInfo(length) {
3541
- return initList(3, _CodeGeneratorRequest._SourceInfo, length, this);
3542
- }
3543
- set sourceInfo(value) {
3544
- copyFrom(value, getPointer(3, this));
3545
- }
3546
- _adoptRequestedFiles(value) {
3547
- adopt(value, getPointer(1, this));
3548
- }
3549
- _disownRequestedFiles() {
3550
- return disown(this.requestedFiles);
3551
- }
3552
- /**
3553
- * Files which were listed on the command line.
3554
- *
3555
- */
3556
- get requestedFiles() {
3557
- return getList(1, _CodeGeneratorRequest._RequestedFiles, this);
3558
- }
3559
- _hasRequestedFiles() {
3560
- return !isNull(getPointer(1, this));
3561
- }
3562
- _initRequestedFiles(length) {
3563
- return initList(1, _CodeGeneratorRequest._RequestedFiles, length, this);
3564
- }
3565
- set requestedFiles(value) {
3566
- copyFrom(value, getPointer(1, this));
3567
- }
3568
- toString() {
3569
- return "CodeGeneratorRequest_" + super.toString();
3570
- }
3571
- };
3572
- Node_SourceInfo._Members = CompositeList(Node_SourceInfo_Member);
3573
- Node_Struct._Fields = CompositeList(Field);
3574
- Node_Enum._Enumerants = CompositeList(Enumerant);
3575
- Node_Interface._Methods = CompositeList(Method);
3576
- Node_Interface._Superclasses = CompositeList(Superclass);
3577
- Node._Parameters = CompositeList(Node_Parameter);
3578
- Node._NestedNodes = CompositeList(Node_NestedNode);
3579
- Node._Annotations = CompositeList(Annotation);
3580
- Field._Annotations = CompositeList(Annotation);
3581
- Enumerant._Annotations = CompositeList(Annotation);
3582
- Method._ImplicitParameters = CompositeList(Node_Parameter);
3583
- Method._Annotations = CompositeList(Annotation);
3584
- Brand_Scope._Bind = CompositeList(Brand_Binding);
3585
- Brand._Scopes = CompositeList(Brand_Scope);
3586
- CodeGeneratorRequest_RequestedFile._Imports = CompositeList(CodeGeneratorRequest_RequestedFile_Import);
3587
- CodeGeneratorRequest._Nodes = CompositeList(Node);
3588
- CodeGeneratorRequest._SourceInfo = CompositeList(Node_SourceInfo);
3589
- CodeGeneratorRequest._RequestedFiles = CompositeList(CodeGeneratorRequest_RequestedFile);
3590
-
3591
- // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=8f737a83e1b5be10396ff9b257b56b8b8e7a3dbd2754765e9b1e2019839e9c31_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.CbTQkT9D.mjs
3592
- var GEN_EXPLICIT_DEFAULT_NON_PRIMITIVE = "CAPNP-ES000 Don't know how to generate a %s field with an explicit default value.";
3593
- var GEN_FIELD_NON_INLINE_STRUCT_LIST = "CAPNP-ES001 Don't know how to generate non-inline struct lists.";
3594
- var GEN_NODE_LOOKUP_FAIL = "CAPNP-ES002 Failed to look up node id %s.";
3595
- var GEN_NODE_UNKNOWN_TYPE = `CAPNP-ES003 Don't know how to generate a "%s" node.`;
3596
- var GEN_SERIALIZE_UNKNOWN_VALUE = "CAPNP-ES004 Don't know how to serialize a value of kind %s.";
3597
- var GEN_UNKNOWN_STRUCT_FIELD = "CAPNP-ES005 Don't know how to generate a struct field of kind %d.";
3598
- var GEN_UNKNOWN_TYPE = "CAPNP-ES006 Unknown slot type encountered: %d";
3599
- var GEN_UNSUPPORTED_LIST_ELEMENT_TYPE = "CAPNP-ES007 Encountered an unsupported list element type: %d";
3600
- var GEN_TS_EMIT_FAILED = "CAPNP-ES009 Failed to transpile emitted schema source code; see above for error messages.";
3601
- var GEN_UNKNOWN_DEFAULT = "CAPNP-ES010 Don't know how to generate a default value for %s fields.";
3602
- var ConcreteListType = {
3603
- [Type.ANY_POINTER]: "$.AnyPointerList",
3604
- [Type.BOOL]: "$.BoolList",
3605
- [Type.DATA]: "$.DataList",
3606
- [Type.ENUM]: "$.Uint16List",
3607
- [Type.FLOAT32]: "$.Float32List",
3608
- [Type.FLOAT64]: "$.Float64List",
3609
- [Type.INT16]: "$.Int16List",
3610
- [Type.INT32]: "$.Int32List",
3611
- [Type.INT64]: "$.Int64List",
3612
- [Type.INT8]: "$.Int8List",
3613
- [Type.INTERFACE]: "$.InterfaceList",
3614
- [Type.LIST]: "$.PointerList",
3615
- [Type.STRUCT]: "$.CompositeList",
3616
- [Type.TEXT]: "$.TextList",
3617
- [Type.UINT16]: "$.Uint16List",
3618
- [Type.UINT32]: "$.Uint32List",
3619
- [Type.UINT64]: "$.Uint64List",
3620
- [Type.UINT8]: "$.Uint8List",
3621
- [Type.VOID]: "$.VoidList"
3622
- };
3623
- var Primitives = {
3624
- [Type.BOOL]: {
3625
- byteLength: 1,
3626
- getter: "getBit",
3627
- mask: "getBitMask",
3628
- setter: "setBit"
3629
- },
3630
- [Type.ENUM]: {
3631
- byteLength: 2,
3632
- getter: "getUint16",
3633
- mask: "getUint16Mask",
3634
- setter: "setUint16"
3635
- },
3636
- [Type.FLOAT32]: {
3637
- byteLength: 4,
3638
- getter: "getFloat32",
3639
- mask: "getFloat32Mask",
3640
- setter: "setFloat32"
3641
- },
3642
- [Type.FLOAT64]: {
3643
- byteLength: 8,
3644
- getter: "getFloat64",
3645
- mask: "getFloat64Mask",
3646
- setter: "setFloat64"
3647
- },
3648
- [Type.INT16]: {
3649
- byteLength: 2,
3650
- getter: "getInt16",
3651
- mask: "getInt16Mask",
3652
- setter: "setInt16"
3653
- },
3654
- [Type.INT32]: {
3655
- byteLength: 4,
3656
- getter: "getInt32",
3657
- mask: "getInt32Mask",
3658
- setter: "setInt32"
3659
- },
3660
- [Type.INT64]: {
3661
- byteLength: 8,
3662
- getter: "getInt64",
3663
- mask: "getInt64Mask",
3664
- setter: "setInt64"
3665
- },
3666
- [Type.INT8]: {
3667
- byteLength: 1,
3668
- getter: "getInt8",
3669
- mask: "getInt8Mask",
3670
- setter: "setInt8"
3671
- },
3672
- [Type.UINT16]: {
3673
- byteLength: 2,
3674
- getter: "getUint16",
3675
- mask: "getUint16Mask",
3676
- setter: "setUint16"
3677
- },
3678
- [Type.UINT32]: {
3679
- byteLength: 4,
3680
- getter: "getUint32",
3681
- mask: "getUint32Mask",
3682
- setter: "setUint32"
3683
- },
3684
- [Type.UINT64]: {
3685
- byteLength: 8,
3686
- getter: "getUint64",
3687
- mask: "getUint64Mask",
3688
- setter: "setUint64"
3689
- },
3690
- [Type.UINT8]: {
3691
- byteLength: 1,
3692
- getter: "getUint8",
3693
- mask: "getUint8Mask",
3694
- setter: "setUint8"
3695
- },
3696
- [Type.VOID]: {
3697
- byteLength: 0,
3698
- getter: "getVoid",
3699
- mask: "getVoidMask",
3700
- setter: "setVoid"
3701
- }
3702
- };
3703
- var SOURCE_COMMENT = `/* eslint-disable */
3704
- // biome-ignore lint: disable
3705
-
3706
- // Generated by Storm Stack
3707
- // Note: Do not edit this file manually - it will be overwritten automatically
3708
-
3709
- `;
3710
- var TS_FILE_ID = "e37ded525a68a7c9";
3711
- var hex2dec;
3712
- var hasRequiredHex2dec;
3713
- function requireHex2dec() {
3714
- if (hasRequiredHex2dec) return hex2dec;
3715
- hasRequiredHex2dec = 1;
3716
- function add(x, y, base) {
3717
- var z = [];
3718
- var n = Math.max(x.length, y.length);
3719
- var carry = 0;
3720
- var i = 0;
3721
- while (i < n || carry) {
3722
- var xi = i < x.length ? x[i] : 0;
3723
- var yi = i < y.length ? y[i] : 0;
3724
- var zi = carry + xi + yi;
3725
- z.push(zi % base);
3726
- carry = Math.floor(zi / base);
3727
- i++;
3728
- }
3729
- return z;
3730
- }
3731
- __name(add, "add");
3732
- function multiplyByNumber(num, x, base) {
3733
- if (num < 0) return null;
3734
- if (num == 0) return [];
3735
- var result = [];
3736
- var power = x;
3737
- while (true) {
3738
- if (num & 1) {
3739
- result = add(result, power, base);
3740
- }
3741
- num = num >> 1;
3742
- if (num === 0) break;
3743
- power = add(power, power, base);
3744
- }
3745
- return result;
3746
- }
3747
- __name(multiplyByNumber, "multiplyByNumber");
3748
- function parseToDigitsArray(str, base) {
3749
- var digits = str.split("");
3750
- var ary = [];
3751
- for (var i = digits.length - 1; i >= 0; i--) {
3752
- var n = parseInt(digits[i], base);
3753
- if (isNaN(n)) return null;
3754
- ary.push(n);
3755
- }
3756
- return ary;
3757
- }
3758
- __name(parseToDigitsArray, "parseToDigitsArray");
3759
- function convertBase(str, fromBase, toBase) {
3760
- var digits = parseToDigitsArray(str, fromBase);
3761
- if (digits === null) return null;
3762
- var outArray = [];
3763
- var power = [1];
3764
- for (var i = 0; i < digits.length; i++) {
3765
- if (digits[i]) {
3766
- outArray = add(outArray, multiplyByNumber(digits[i], power, toBase), toBase);
3767
- }
3768
- power = multiplyByNumber(fromBase, power, toBase);
3769
- }
3770
- var out = "";
3771
- for (var i = outArray.length - 1; i >= 0; i--) {
3772
- out += outArray[i].toString(toBase);
3773
- }
3774
- if (out === "") {
3775
- out = "0";
3776
- }
3777
- return out;
3778
- }
3779
- __name(convertBase, "convertBase");
3780
- function decToHex(decStr, opts) {
3781
- var hidePrefix = opts && opts.prefix === false;
3782
- var hex = convertBase(decStr, 10, 16);
3783
- return hex ? hidePrefix ? hex : "0x" + hex : null;
3784
- }
3785
- __name(decToHex, "decToHex");
3786
- function hexToDec(hexStr) {
3787
- if (hexStr.substring(0, 2) === "0x") hexStr = hexStr.substring(2);
3788
- hexStr = hexStr.toLowerCase();
3789
- return convertBase(hexStr, 16, 10);
3790
- }
3791
- __name(hexToDec, "hexToDec");
3792
- hex2dec = {
3793
- hexToDec,
3794
- decToHex
3795
- };
3796
- return hex2dec;
3797
- }
3798
- __name(requireHex2dec, "requireHex2dec");
3799
- var hex2decExports = requireHex2dec();
3800
- function c2s(s) {
3801
- return splitCamel(s).map((x) => x.toUpperCase()).join("_");
3802
- }
3803
- __name(c2s, "c2s");
3804
- function c2t(s) {
3805
- return s[0].toUpperCase() + s.slice(1);
3806
- }
3807
- __name(c2t, "c2t");
3808
- function splitCamel(s) {
3809
- let wasLo = false;
3810
- return s.split("").reduce((a, c) => {
3811
- const lo = c.toUpperCase() !== c;
3812
- const up = c.toLowerCase() !== c;
3813
- if (a.length === 0 || wasLo && up) {
3814
- a.push(c);
3815
- } else {
3816
- const i = a.length - 1;
3817
- a[i] = a[i] + c;
3818
- }
3819
- wasLo = lo;
3820
- return a;
3821
- }, []);
3822
- }
3823
- __name(splitCamel, "splitCamel");
3824
- function hexToBigInt(hexString) {
3825
- return BigInt(hex2decExports.hexToDec(hexString));
3826
- }
3827
- __name(hexToBigInt, "hexToBigInt");
3828
- function compareCodeOrder(a, b) {
3829
- return a.codeOrder - b.codeOrder;
3830
- }
3831
- __name(compareCodeOrder, "compareCodeOrder");
3832
- function getConcreteListType(ctx, type) {
3833
- if (!type._isList) {
3834
- return getJsType(ctx, type, false);
3835
- }
3836
- const { elementType } = type.list;
3837
- const elementTypeWhich = elementType.which();
3838
- if (elementTypeWhich === Type.LIST) {
3839
- return `$.PointerList(${getConcreteListType(ctx, elementType)})`;
3840
- } else if (elementTypeWhich === Type.STRUCT) {
3841
- const structNode = lookupNode(ctx, elementType.struct.typeId);
3842
- if (structNode.struct.preferredListEncoding !== ElementSize.INLINE_COMPOSITE) {
3843
- throw new Error(GEN_FIELD_NON_INLINE_STRUCT_LIST);
3844
- }
3845
- return `$.CompositeList(${getJsType(ctx, elementType, false)})`;
3846
- }
3847
- return ConcreteListType[elementTypeWhich];
3848
- }
3849
- __name(getConcreteListType, "getConcreteListType");
3850
- function getDisplayNamePrefix(node) {
3851
- return node.displayName.slice(node.displayNamePrefixLength);
3852
- }
3853
- __name(getDisplayNamePrefix, "getDisplayNamePrefix");
3854
- function getFullClassName(node) {
3855
- return node.displayName.split(":")[1].split(".").map((s) => c2t(s)).join("_");
3856
- }
3857
- __name(getFullClassName, "getFullClassName");
3858
- function getJsType(ctx, type, constructor) {
3859
- const whichType = type.which();
3860
- switch (whichType) {
3861
- case Type.ANY_POINTER: {
3862
- return "$.Pointer";
3863
- }
3864
- case Type.BOOL: {
3865
- return "boolean";
3866
- }
3867
- case Type.DATA: {
3868
- return "$.Data";
3869
- }
3870
- case Type.ENUM: {
3871
- return getFullClassName(lookupNode(ctx, type.enum.typeId));
3872
- }
3873
- case Type.FLOAT32:
3874
- case Type.FLOAT64:
3875
- case Type.INT16:
3876
- case Type.INT32:
3877
- case Type.INT8:
3878
- case Type.UINT16:
3879
- case Type.UINT32:
3880
- case Type.UINT8: {
3881
- return "number";
3882
- }
3883
- case Type.UINT64:
3884
- case Type.INT64: {
3885
- return "bigint";
3886
- }
3887
- case Type.INTERFACE: {
3888
- return getFullClassName(lookupNode(ctx, type.interface.typeId));
3889
- }
3890
- case Type.LIST: {
3891
- return `$.List${constructor ? "Ctor" : ""}<${getJsType(ctx, type.list.elementType, false)}>`;
3892
- }
3893
- case Type.STRUCT: {
3894
- const c = getFullClassName(lookupNode(ctx, type.struct.typeId));
3895
- return constructor ? `$.StructCtor<${c}>` : c;
3896
- }
3897
- case Type.TEXT: {
3898
- return "string";
3899
- }
3900
- case Type.VOID: {
3901
- return "$.Void";
3902
- }
3903
- default: {
3904
- throw new Error(format(GEN_UNKNOWN_TYPE, whichType));
3905
- }
3906
- }
3907
- }
3908
- __name(getJsType, "getJsType");
3909
- function getUnnamedUnionFields(node) {
3910
- return node.struct.fields.filter(
3911
- (field) => field.discriminantValue !== Field.NO_DISCRIMINANT
3912
- );
3913
- }
3914
- __name(getUnnamedUnionFields, "getUnnamedUnionFields");
3915
- function hasNode(ctx, lookup) {
3916
- const id = typeof lookup === "bigint" ? lookup : lookup.id;
3917
- return ctx.nodes.some((n) => n.id === id);
3918
- }
3919
- __name(hasNode, "hasNode");
3920
- function loadRequestedFile(req, file) {
3921
- const ctx = new CodeGeneratorFileContext(req, file);
3922
- const schema2 = lookupNode(ctx, file.id);
3923
- ctx.tsPath = schema2.displayName.replace(/\.capnp$/, "") + ".ts";
3924
- return ctx;
3925
- }
3926
- __name(loadRequestedFile, "loadRequestedFile");
3927
- function lookupNode(ctx, lookup) {
3928
- const id = typeof lookup === "bigint" ? lookup : lookup.id;
3929
- const node = ctx.nodes.find((n) => n.id === id);
3930
- if (node === void 0) {
3931
- throw new Error(format(GEN_NODE_LOOKUP_FAIL, id));
3932
- }
3933
- return node;
3934
- }
3935
- __name(lookupNode, "lookupNode");
3936
- function lookupNodeSourceInfo(ctx, lookup) {
3937
- const id = typeof lookup === "bigint" ? lookup : lookup.id;
3938
- return ctx.req.sourceInfo.find((s) => s.id === id);
3939
- }
3940
- __name(lookupNodeSourceInfo, "lookupNodeSourceInfo");
3941
- function needsConcreteListClass(field) {
3942
- if (!field._isSlot) {
3943
- return false;
3944
- }
3945
- const slotType = field.slot.type;
3946
- if (!slotType._isList) {
3947
- return false;
3948
- }
3949
- const { elementType } = slotType.list;
3950
- return elementType._isStruct || elementType._isList;
3951
- }
3952
- __name(needsConcreteListClass, "needsConcreteListClass");
3953
- function createBigInt(value) {
3954
- let v = value.toString(16);
3955
- let sign = "";
3956
- if (v[0] === "-") {
3957
- v = v.slice(1);
3958
- sign = "-";
3959
- }
3960
- return `${sign}BigInt("0x${v}")`;
3961
- }
3962
- __name(createBigInt, "createBigInt");
3963
- function extractJSDocs(sourceInfo) {
3964
- const docComment = sourceInfo?.docComment;
3965
- if (!docComment) {
3966
- return "";
3967
- }
3968
- return "/**\n" + docComment.toString().split("\n").map((l) => `* ${l}`).join("\n") + "\n*/";
3969
- }
3970
- __name(extractJSDocs, "extractJSDocs");
3971
- function generateEnumNode(ctx, className, parentNode, fields) {
3972
- const fieldIndexInCodeOrder = fields.map(({ codeOrder }, fieldIndex) => ({ fieldIndex, codeOrder })).sort(compareCodeOrder).map(({ fieldIndex }) => fieldIndex);
3973
- const sourceInfo = lookupNodeSourceInfo(ctx, parentNode);
3974
- const propInits = fieldIndexInCodeOrder.map((index) => {
3975
- const field = fields[index];
3976
- const docComment = extractJSDocs(sourceInfo?.members.at(index));
3977
- const key = c2s(field.name);
3978
- const val = field.discriminantValue || index;
3979
- return `
3980
- ${docComment}
3981
- ${key}: ${val}`;
3982
- });
3983
- ctx.codeParts.push(`
3984
- export const ${className} = {
3985
- ${propInits.join(",\n")}
3986
- } as const;
3987
-
3988
- export type ${className} = (typeof ${className})[keyof typeof ${className}];
3989
- `);
3990
- }
3991
- __name(generateEnumNode, "generateEnumNode");
3992
- function generateInterfaceClasses(ctx, node) {
3993
- generateMethodStructs(ctx, node);
3994
- generateClient(ctx, node);
3995
- generateServer(ctx, node);
3996
- }
3997
- __name(generateInterfaceClasses, "generateInterfaceClasses");
3998
- function generateMethodStructs(ctx, node) {
3999
- for (const method of node.interface.methods) {
4000
- const paramNode = lookupNode(ctx, method.paramStructType);
4001
- const resultNode = lookupNode(ctx, method.resultStructType);
4002
- generateNode(ctx, paramNode);
4003
- generateNode(ctx, resultNode);
4004
- generateResultPromise(ctx, resultNode);
4005
- }
4006
- }
4007
- __name(generateMethodStructs, "generateMethodStructs");
4008
- function generateServer(ctx, node) {
4009
- const fullClassName = getFullClassName(node);
4010
- const serverName = `${fullClassName}$Server`;
4011
- const serverTargetName = `${serverName}$Target`;
4012
- const clientName = `${fullClassName}$Client`;
4013
- const methodSignatures = node.interface.methods.map((method) => {
4014
- const paramTypeName = getFullClassName(
4015
- lookupNode(ctx, method.paramStructType)
4016
- );
4017
- const resultTypeName = getFullClassName(
4018
- lookupNode(ctx, method.resultStructType)
4019
- );
4020
- return `${method.name}(params: ${paramTypeName}, results: ${resultTypeName}): Promise<void>;`;
4021
- }).join("\n");
4022
- ctx.codeParts.push(`
4023
- export interface ${serverTargetName} {
4024
- ${methodSignatures}
4025
- }`);
4026
- const members = [];
4027
- members.push(`public override readonly target: ${serverTargetName};`);
4028
- const codeServerMethods = [];
4029
- let index = 0;
4030
- for (const method of node.interface.methods) {
4031
- codeServerMethods.push(`{
4032
- ...${clientName}.methods[${index}],
4033
- impl: target.${method.name}
4034
- }`);
4035
- index++;
4036
- }
4037
- members.push(`
4038
- constructor(target: ${serverTargetName}) {
4039
- super(target, [
4040
- ${codeServerMethods.join(",\n")}
4041
- ]);
4042
- this.target = target;
4043
- }
4044
- client(): ${clientName} {
4045
- return new ${clientName}(this);
4046
- }
4047
- `);
4048
- ctx.codeParts.push(`
4049
- export class ${serverName} extends $.Server {
4050
- ${members.join("\n")}
4051
- }
4052
- `);
4053
- }
4054
- __name(generateServer, "generateServer");
4055
- function generateClient(ctx, node) {
4056
- const fullClassName = getFullClassName(node);
4057
- const clientName = `${fullClassName}$Client`;
4058
- const members = [];
4059
- members.push(`
4060
- client: $.Client;
4061
- static readonly interfaceId: bigint = ${createBigInt(node.id)};
4062
- constructor(client: $.Client) {
4063
- this.client = client;
4064
- }
4065
- `);
4066
- const methods = [];
4067
- const methodDefs = [];
4068
- const methodDefTypes = [];
4069
- for (let index = 0; index < node.interface.methods.length; index++) {
4070
- generateClientMethod(
4071
- ctx,
4072
- node,
4073
- clientName,
4074
- methods,
4075
- methodDefs,
4076
- methodDefTypes,
4077
- index
4078
- );
4079
- }
4080
- members.push(`
4081
- static readonly methods:[
4082
- ${methodDefTypes.join(",\n")}
4083
- ] = [
4084
- ${methodDefs.join(",\n")}
4085
- ];
4086
- ${methods.join("\n")}
4087
- `);
4088
- ctx.codeParts.push(`
4089
- export class ${clientName} {
4090
- ${members.join("\n")}
4091
- }
4092
- $.Registry.register(${clientName}.interfaceId, ${clientName});
4093
- `);
4094
- }
4095
- __name(generateClient, "generateClient");
4096
- function generateResultPromise(ctx, node) {
4097
- const nodeId = node.id;
4098
- if (ctx.generatedResultsPromiseIds.has(nodeId)) {
4099
- return;
4100
- }
4101
- ctx.generatedResultsPromiseIds.add(nodeId);
4102
- const resultsClassName = getFullClassName(node);
4103
- const fullClassName = `${resultsClassName}$Promise`;
4104
- const members = [];
4105
- members.push(`
4106
- pipeline: $.Pipeline<any, any, ${resultsClassName}>;
4107
- constructor(pipeline: $.Pipeline<any, any, ${resultsClassName}>) {
4108
- this.pipeline = pipeline;
4109
- }
4110
- `);
4111
- const { struct } = node;
4112
- const fields = struct.fields.toArray().sort(compareCodeOrder);
4113
- const generatePromiseFieldMethod = /* @__PURE__ */ __name((field) => {
4114
- let jsType;
4115
- let isInterface = false;
4116
- let slot;
4117
- if (field._isSlot) {
4118
- slot = field.slot;
4119
- const slotType = slot.type;
4120
- if (slotType.which() !== Type.INTERFACE) {
4121
- return;
4122
- }
4123
- isInterface = true;
4124
- jsType = getJsType(ctx, slotType, false);
4125
- } else if (field._isGroup) {
4126
- return;
4127
- } else {
4128
- throw new Error(format(GEN_UNKNOWN_STRUCT_FIELD, field.which()));
4129
- }
4130
- const promisedJsType = jsType;
4131
- if (isInterface) {
4132
- jsType = `${jsType}$Client`;
4133
- }
4134
- const { name } = field;
4135
- const properName = c2t(name);
4136
- members.push(`
4137
- get${properName}(): ${jsType} {
4138
- return new ${jsType}(this.pipeline.getPipeline(${promisedJsType}, ${slot.offset}).client());
4139
- }
4140
- `);
4141
- }, "generatePromiseFieldMethod");
4142
- for (const field of fields) {
4143
- generatePromiseFieldMethod(field);
4144
- }
4145
- members.push(`
4146
- async promise(): Promise<${resultsClassName}> {
4147
- return await this.pipeline.struct();
4148
- }
4149
- `);
4150
- ctx.codeParts.push(`
4151
- export class ${fullClassName} {
4152
- ${members.join("\n")}
4153
- }
4154
- `);
4155
- }
4156
- __name(generateResultPromise, "generateResultPromise");
4157
- function generateClientMethod(ctx, node, clientName, methodsCode, methodDefs, methodDefTypes, index) {
4158
- const method = node.interface.methods[index];
4159
- const { name } = method;
4160
- const paramTypeName = getFullClassName(
4161
- lookupNode(ctx, method.paramStructType)
4162
- );
4163
- const resultTypeName = getFullClassName(
4164
- lookupNode(ctx, method.resultStructType)
4165
- );
4166
- methodDefTypes.push(`$.Method<${paramTypeName}, ${resultTypeName}>`);
4167
- methodDefs.push(`{
4168
- ParamsClass: ${paramTypeName},
4169
- ResultsClass: ${resultTypeName},
4170
- interfaceId: ${clientName}.interfaceId,
4171
- methodId: ${index},
4172
- interfaceName: "${node.displayName}",
4173
- methodName: "${method.name}"
4174
- }`);
4175
- const docComment = extractJSDocs(
4176
- lookupNodeSourceInfo(ctx, node)?.members.at(index)
4177
- );
4178
- methodsCode.push(`
4179
- ${docComment}
4180
- ${name}(paramsFunc?: (params: ${paramTypeName}) => void): ${resultTypeName}$Promise {
4181
- const answer = this.client.call({
4182
- method: ${clientName}.methods[${index}],
4183
- paramsFunc: paramsFunc
4184
- });
4185
- const pipeline = new $.Pipeline(${resultTypeName}, answer);
4186
- return new ${resultTypeName}$Promise(pipeline);
4187
- }
4188
- `);
4189
- }
4190
- __name(generateClientMethod, "generateClientMethod");
4191
- function generateStructNode(ctx, node) {
4192
- const displayNamePrefix = getDisplayNamePrefix(node);
4193
- const fullClassName = getFullClassName(node);
4194
- const nestedNodes = node.nestedNodes.map(({ id }) => lookupNode(ctx, id)).filter((node2) => !node2._isConst && !node2._isAnnotation);
4195
- const nodeId = node.id;
4196
- const nodeIdHex = nodeId.toString(16);
4197
- const unionFields = getUnnamedUnionFields(node);
4198
- const { struct } = node;
4199
- const { dataWordCount, discriminantCount, discriminantOffset, pointerCount } = struct;
4200
- const dataByteLength = dataWordCount * 8;
4201
- const fields = struct.fields.toArray();
4202
- const fieldIndexInCodeOrder = fields.map(({ codeOrder }, fieldIndex) => ({ fieldIndex, codeOrder })).sort(compareCodeOrder).map(({ fieldIndex }) => fieldIndex);
4203
- const concreteLists = fields.filter((field) => needsConcreteListClass(field)).sort(compareCodeOrder);
4204
- const consts = ctx.nodes.filter(
4205
- (node2) => node2.scopeId === nodeId && node2._isConst
4206
- );
4207
- const hasUnnamedUnion = discriminantCount !== 0;
4208
- if (hasUnnamedUnion) {
4209
- generateEnumNode(ctx, fullClassName + "_Which", node, unionFields);
4210
- }
4211
- const members = [];
4212
- members.push(
4213
- ...consts.map((node2) => {
4214
- const name = c2s(getDisplayNamePrefix(node2));
4215
- const value = createValue(node2.const.value);
4216
- return `static readonly ${name} = ${value}`;
4217
- }),
4218
- ...unionFields.sort(compareCodeOrder).map((field) => createUnionConstProperty(fullClassName, field)),
4219
- ...nestedNodes.map((node2) => createNestedNodeProperty(node2))
4220
- );
4221
- const defaultValues = [];
4222
- for (const index of fieldIndexInCodeOrder) {
4223
- const field = fields[index];
4224
- if (field._isSlot && field.slot.hadExplicitDefault && field.slot.type.which() !== Type.VOID) {
4225
- defaultValues.push(generateDefaultValue(field));
4226
- }
4227
- }
4228
- members.push(
4229
- `
4230
- public static override readonly _capnp = {
4231
- displayName: "${displayNamePrefix}",
4232
- id: "${nodeIdHex}",
4233
- size: new $.ObjectSize(${dataByteLength}, ${pointerCount}),
4234
- ${defaultValues.join(",")}
4235
- }`,
4236
- ...concreteLists.map((field) => createConcreteListProperty(ctx, field))
4237
- );
4238
- for (const index of fieldIndexInCodeOrder) {
4239
- const field = fields[index];
4240
- generateStructFieldMethods(ctx, members, node, field, index);
4241
- }
4242
- members.push(
4243
- `public override toString(): string { return "${fullClassName}_" + super.toString(); }`
4244
- );
4245
- if (hasUnnamedUnion) {
4246
- members.push(`
4247
- which(): ${fullClassName}_Which {
4248
- return $.utils.getUint16(${discriminantOffset * 2}, this) as ${fullClassName}_Which;
4249
- }
4250
- `);
4251
- }
4252
- const docComment = extractJSDocs(lookupNodeSourceInfo(ctx, node));
4253
- const classCode = `
4254
- ${docComment}
4255
- export class ${fullClassName} extends $.Struct {
4256
- ${members.join("\n")}
4257
- }`;
4258
- ctx.codeParts.push(classCode);
4259
- ctx.concreteLists.push(
4260
- ...concreteLists.map((field) => [
4261
- fullClassName,
4262
- field
4263
- ])
4264
- );
4265
- }
4266
- __name(generateStructNode, "generateStructNode");
4267
- function generateStructFieldMethods(ctx, members, node, field, fieldIndex) {
4268
- let jsType;
4269
- let whichType;
4270
- if (field._isSlot) {
4271
- const slotType = field.slot.type;
4272
- jsType = getJsType(ctx, slotType, false);
4273
- whichType = slotType.which();
4274
- } else if (field._isGroup) {
4275
- jsType = getFullClassName(lookupNode(ctx, field.group.typeId));
4276
- whichType = "group";
4277
- } else {
4278
- throw new Error(format(GEN_UNKNOWN_STRUCT_FIELD, field.which()));
4279
- }
4280
- const isInterface = whichType === Type.INTERFACE;
4281
- if (isInterface) {
4282
- jsType = `${jsType}$Client`;
4283
- }
4284
- const { discriminantOffset } = node.struct;
4285
- const { name } = field;
4286
- const accessorName = name === "constructor" ? "$constructor" : name;
4287
- const capitalizedName = c2t(name);
4288
- const { discriminantValue } = field;
4289
- const fullClassName = getFullClassName(node);
4290
- const hadExplicitDefault = field._isSlot && field.slot.hadExplicitDefault;
4291
- const maybeDefaultArg = hadExplicitDefault ? `, ${fullClassName}._capnp.default${capitalizedName}` : "";
4292
- const union = discriminantValue !== Field.NO_DISCRIMINANT;
4293
- const offset = field._isSlot ? field.slot.offset : 0;
4294
- let adopt2 = false;
4295
- let disown2 = false;
4296
- let has = false;
4297
- let init;
4298
- let get;
4299
- let set;
4300
- switch (whichType) {
4301
- case Type.ANY_POINTER: {
4302
- adopt2 = true;
4303
- disown2 = true;
4304
- has = true;
4305
- get = `$.utils.getPointer(${offset}, this${maybeDefaultArg})`;
4306
- set = `$.utils.copyFrom(value, ${get})`;
4307
- break;
4308
- }
4309
- case Type.BOOL:
4310
- case Type.ENUM:
4311
- case Type.FLOAT32:
4312
- case Type.FLOAT64:
4313
- case Type.INT16:
4314
- case Type.INT32:
4315
- case Type.INT64:
4316
- case Type.INT8:
4317
- case Type.UINT16:
4318
- case Type.UINT32:
4319
- case Type.UINT64:
4320
- case Type.UINT8: {
4321
- const { byteLength, getter, setter } = Primitives[whichType];
4322
- const byteOffset = offset * byteLength;
4323
- get = `$.utils.${getter}(${byteOffset}, this${maybeDefaultArg})`;
4324
- set = `$.utils.${setter}(${byteOffset}, value, this${maybeDefaultArg})`;
4325
- if (whichType === Type.ENUM) {
4326
- get = `${get} as ${jsType}`;
4327
- }
4328
- break;
4329
- }
4330
- case Type.DATA: {
4331
- adopt2 = true;
4332
- disown2 = true;
4333
- has = true;
4334
- get = `$.utils.getData(${offset}, this${maybeDefaultArg})`;
4335
- set = `$.utils.copyFrom(value, $.utils.getPointer(${offset}, this))`;
4336
- init = `$.utils.initData(${offset}, length, this)`;
4337
- break;
4338
- }
4339
- case Type.INTERFACE: {
4340
- get = `new ${jsType}($.utils.getInterfaceClientOrNullAt(${offset}, this))`;
4341
- set = `$.utils.setInterfacePointer(this.segment.message.addCap(value.client), $.utils.getPointer(${offset}, this))`;
4342
- break;
4343
- }
4344
- case Type.LIST: {
4345
- const elementType = field.slot.type.list.elementType.which();
4346
- let listClass = ConcreteListType[elementType];
4347
- if (elementType === Type.LIST || elementType === Type.STRUCT) {
4348
- listClass = `${fullClassName}._${capitalizedName}`;
4349
- } else if (listClass === void 0) {
4350
- throw new Error(
4351
- format(GEN_UNSUPPORTED_LIST_ELEMENT_TYPE, elementType)
4352
- );
4353
- }
4354
- adopt2 = true;
4355
- disown2 = true;
4356
- has = true;
4357
- get = `$.utils.getList(${offset}, ${listClass}, this${maybeDefaultArg})`;
4358
- set = `$.utils.copyFrom(value, $.utils.getPointer(${offset}, this))`;
4359
- init = `$.utils.initList(${offset}, ${listClass}, length, this)`;
4360
- if (elementType === Type.ENUM) {
4361
- get = `${get} as ${jsType}`;
4362
- init = `${init} as ${jsType}`;
4363
- }
4364
- break;
4365
- }
4366
- case Type.STRUCT: {
4367
- adopt2 = true;
4368
- disown2 = true;
4369
- has = true;
4370
- get = `$.utils.getStruct(${offset}, ${jsType}, this${maybeDefaultArg})`;
4371
- set = `$.utils.copyFrom(value, $.utils.getPointer(${offset}, this))`;
4372
- init = `$.utils.initStructAt(${offset}, ${jsType}, this)`;
4373
- break;
4374
- }
4375
- case Type.TEXT: {
4376
- get = `$.utils.getText(${offset}, this${maybeDefaultArg})`;
4377
- set = `$.utils.setText(${offset}, value, this)`;
4378
- break;
4379
- }
4380
- case Type.VOID: {
4381
- break;
4382
- }
4383
- case "group": {
4384
- if (hadExplicitDefault) {
4385
- throw new Error(format(GEN_EXPLICIT_DEFAULT_NON_PRIMITIVE, "group"));
4386
- }
4387
- get = `$.utils.getAs(${jsType}, this)`;
4388
- init = get;
4389
- break;
4390
- }
4391
- }
4392
- if (adopt2) {
4393
- members.push(`
4394
- _adopt${capitalizedName}(value: $.Orphan<${jsType}>): void {
4395
- ${union ? `$.utils.setUint16(${discriminantOffset * 2}, ${discriminantValue}, this);` : ""}
4396
- $.utils.adopt(value, $.utils.getPointer(${offset}, this));
4397
- }
4398
- `);
4399
- }
4400
- if (disown2) {
4401
- members.push(`
4402
- _disown${capitalizedName}(): $.Orphan<${jsType}> {
4403
- return $.utils.disown(this.${name === "constructor" ? `$${name}` : name});
4404
- }
4405
- `);
4406
- }
4407
- if (get) {
4408
- const docComment = extractJSDocs(
4409
- lookupNodeSourceInfo(ctx, node)?.members.at(fieldIndex)
4410
- );
4411
- members.push(`
4412
- ${docComment}
4413
- get ${accessorName}(): ${jsType} {
4414
- ${union ? `$.utils.testWhich(${JSON.stringify(name)}, $.utils.getUint16(${discriminantOffset * 2}, this), ${discriminantValue}, this);` : ""}
4415
- return ${get};
4416
- }
4417
- `);
4418
- }
4419
- if (has) {
4420
- members.push(`
4421
- _has${capitalizedName}(): boolean {
4422
- return !$.utils.isNull($.utils.getPointer(${offset}, this));
4423
- }
4424
- `);
4425
- }
4426
- if (init) {
4427
- const params = whichType === Type.DATA || whichType === Type.LIST ? `length: number` : "";
4428
- members.push(`
4429
- _init${capitalizedName}(${params}): ${jsType} {
4430
- ${union ? `$.utils.setUint16(${discriminantOffset * 2}, ${discriminantValue}, this);` : ""}
4431
- return ${init};
4432
- }
4433
- `);
4434
- }
4435
- if (union) {
4436
- members.push(`
4437
- get _is${capitalizedName}(): boolean {
4438
- return $.utils.getUint16(${discriminantOffset * 2}, this) === ${discriminantValue};
4439
- }
4440
- `);
4441
- }
4442
- if (set || union) {
4443
- const param = set ? `value: ${jsType}` : `_: true`;
4444
- members.push(`
4445
- set ${accessorName}(${param}) {
4446
- ${union ? `$.utils.setUint16(${discriminantOffset * 2}, ${discriminantValue}, this);` : ""}
4447
- ${set ? `${set};` : ""}
4448
- }
4449
- `);
4450
- }
4451
- }
4452
- __name(generateStructFieldMethods, "generateStructFieldMethods");
4453
- function generateDefaultValue(field) {
4454
- const { name, slot } = field;
4455
- const whichSlotType = slot.type.which();
4456
- const primitive = Primitives[whichSlotType];
4457
- let initializer;
4458
- switch (whichSlotType) {
4459
- case Type_Which.ANY_POINTER:
4460
- case Type_Which.DATA:
4461
- case Type_Which.LIST:
4462
- case Type_Which.STRUCT:
4463
- case Type_Which.INTERFACE: {
4464
- initializer = createValue(slot.defaultValue);
4465
- break;
4466
- }
4467
- case Type_Which.TEXT: {
4468
- initializer = JSON.stringify(slot.defaultValue.text);
4469
- break;
4470
- }
4471
- case Type_Which.BOOL: {
4472
- const value = createValue(slot.defaultValue);
4473
- const bitOffset = slot.offset % 8;
4474
- initializer = `$.${primitive.mask}(${value}, ${bitOffset})`;
4475
- break;
4476
- }
4477
- case Type_Which.ENUM:
4478
- case Type_Which.FLOAT32:
4479
- case Type_Which.FLOAT64:
4480
- case Type_Which.INT16:
4481
- case Type_Which.INT32:
4482
- case Type_Which.INT64:
4483
- case Type_Which.INT8:
4484
- case Type_Which.UINT16:
4485
- case Type_Which.UINT32:
4486
- case Type_Which.UINT64:
4487
- case Type_Which.UINT8: {
4488
- const value = createValue(slot.defaultValue);
4489
- initializer = `$.${primitive.mask}(${value})`;
4490
- break;
4491
- }
4492
- default: {
4493
- throw new Error(
4494
- format(
4495
- GEN_UNKNOWN_DEFAULT,
4496
- whichSlotType
4497
- )
4498
- );
4499
- }
4500
- }
4501
- return `default${c2t(name)}: ${initializer}`;
4502
- }
4503
- __name(generateDefaultValue, "generateDefaultValue");
4504
- function createConcreteListProperty(ctx, field) {
4505
- const name = `_${c2t(field.name)}`;
4506
- const type = getJsType(ctx, field.slot.type, true);
4507
- return `static ${name}: ${type};`;
4508
- }
4509
- __name(createConcreteListProperty, "createConcreteListProperty");
4510
- function createUnionConstProperty(fullClassName, field) {
4511
- const name = c2s(field.name);
4512
- const initializer = `${fullClassName}_Which.${name}`;
4513
- return `static readonly ${name} = ${initializer};`;
4514
- }
4515
- __name(createUnionConstProperty, "createUnionConstProperty");
4516
- function createValue(value) {
4517
- let p;
4518
- switch (value.which()) {
4519
- case Value.BOOL: {
4520
- return value.bool ? `true` : `false`;
4521
- }
4522
- case Value.ENUM: {
4523
- return String(value.enum);
4524
- }
4525
- case Value.FLOAT32: {
4526
- return String(value.float32);
4527
- }
4528
- case Value.FLOAT64: {
4529
- return String(value.float64);
4530
- }
4531
- case Value.INT8: {
4532
- return String(value.int8);
4533
- }
4534
- case Value.INT16: {
4535
- return String(value.int16);
4536
- }
4537
- case Value.INT32: {
4538
- return String(value.int32);
4539
- }
4540
- case Value.INT64: {
4541
- return createBigInt(value.int64);
4542
- }
4543
- case Value.UINT8: {
4544
- return String(value.uint8);
4545
- }
4546
- case Value.UINT16: {
4547
- return String(value.uint16);
4548
- }
4549
- case Value.UINT32: {
4550
- return String(value.uint32);
4551
- }
4552
- case Value.UINT64: {
4553
- return createBigInt(value.uint64);
4554
- }
4555
- case Value.TEXT: {
4556
- return JSON.stringify(value.text);
4557
- }
4558
- case Value.VOID: {
4559
- return "undefined";
4560
- }
4561
- case Value.ANY_POINTER: {
4562
- p = value.anyPointer;
4563
- break;
4564
- }
4565
- case Value.DATA: {
4566
- p = value.data;
4567
- break;
4568
- }
4569
- case Value.LIST: {
4570
- p = value.list;
4571
- break;
4572
- }
4573
- case Value.STRUCT: {
4574
- p = value.struct;
4575
- break;
4576
- }
4577
- case Value.INTERFACE: {
4578
- testWhich("interface", getUint16(0, value), 17, value);
4579
- p = getPointer(0, value);
4580
- break;
4581
- }
4582
- default: {
4583
- throw new Error(format(GEN_SERIALIZE_UNKNOWN_VALUE, value.which()));
4584
- }
4585
- }
4586
- const message = new Message();
4587
- message.setRoot(p);
4588
- const buf = new Uint8Array(message.toPackedArrayBuffer());
4589
- const values = [];
4590
- for (let i = 0; i < buf.byteLength; i++) {
4591
- values.push(`0x${pad(buf[i].toString(16), 2)}`);
4592
- }
4593
- return `$.readRawPointer(new Uint8Array([${values.join(",")}]).buffer)`;
4594
- }
4595
- __name(createValue, "createValue");
4596
- function createNestedNodeProperty(node) {
4597
- const name = getDisplayNamePrefix(node);
4598
- const initializer = getFullClassName(node);
4599
- return `static readonly ${name} = ${initializer};`;
4600
- }
4601
- __name(createNestedNodeProperty, "createNestedNodeProperty");
4602
- function generateInterfaceNode(ctx, node) {
4603
- const displayNamePrefix = getDisplayNamePrefix(node);
4604
- const fullClassName = getFullClassName(node);
4605
- const nestedNodes = node.nestedNodes.map((n) => lookupNode(ctx, n)).filter((n) => !n._isConst && !n._isAnnotation);
4606
- const nodeId = node.id;
4607
- const nodeIdHex = nodeId.toString(16);
4608
- const consts = ctx.nodes.filter((n) => n.scopeId === nodeId && n._isConst);
4609
- const members = [];
4610
- members.push(
4611
- ...consts.map((node2) => {
4612
- const name = c2s(getDisplayNamePrefix(node2));
4613
- const value = createValue(node2.const.value);
4614
- return `static readonly ${name} = ${value}`;
4615
- }),
4616
- ...nestedNodes.map((node2) => createNestedNodeProperty(node2)),
4617
- `static readonly Client = ${fullClassName}$Client;
4618
- static readonly Server = ${fullClassName}$Server;
4619
- public static override readonly _capnp = {
4620
- displayName: "${displayNamePrefix}",
4621
- id: "${nodeIdHex}",
4622
- size: new $.ObjectSize(0, 0),
4623
- }
4624
- public override toString(): string { return "${fullClassName}_" + super.toString(); }`
4625
- );
4626
- const docComment = extractJSDocs(lookupNodeSourceInfo(ctx, node));
4627
- const classCode = `
4628
- ${docComment}
4629
- export class ${fullClassName} extends $.Interface {
4630
- ${members.join("\n")}
4631
- }`;
4632
- generateInterfaceClasses(ctx, node);
4633
- ctx.codeParts.push(classCode);
4634
- }
4635
- __name(generateInterfaceNode, "generateInterfaceNode");
4636
- function generateNode(ctx, node) {
4637
- const nodeId = node.id;
4638
- const nodeIdHex = nodeId.toString(16);
4639
- if (ctx.generatedNodeIds.has(nodeIdHex)) {
4640
- return;
4641
- }
4642
- ctx.generatedNodeIds.add(nodeIdHex);
4643
- const nestedNodes = node.nestedNodes.map((node2) => lookupNode(ctx, node2));
4644
- for (const nestedNode of nestedNodes) {
4645
- generateNode(ctx, nestedNode);
4646
- }
4647
- const groupNodes = ctx.nodes.filter(
4648
- (node2) => node2.scopeId === nodeId && node2._isStruct && node2.struct.isGroup
4649
- );
4650
- for (const groupNode of groupNodes) {
4651
- generateNode(ctx, groupNode);
4652
- }
4653
- const nodeType = node.which();
4654
- switch (nodeType) {
4655
- case Node.STRUCT: {
4656
- generateStructNode(ctx, node);
4657
- break;
4658
- }
4659
- case Node.CONST: {
4660
- break;
4661
- }
4662
- case Node.ENUM: {
4663
- generateEnumNode(
4664
- ctx,
4665
- getFullClassName(node),
4666
- node,
4667
- node.enum.enumerants.toArray()
4668
- );
4669
- break;
4670
- }
4671
- case Node.INTERFACE: {
4672
- generateInterfaceNode(ctx, node);
4673
- break;
4674
- }
4675
- case Node.ANNOTATION: {
4676
- break;
4677
- }
4678
- // case s.Node.FILE:
4679
- default: {
4680
- throw new Error(
4681
- format(
4682
- GEN_NODE_UNKNOWN_TYPE,
4683
- nodeType
4684
- /* s.Node_Which[whichNode] */
4685
- )
4686
- );
4687
- }
4688
- }
4689
- }
4690
- __name(generateNode, "generateNode");
4691
- var CodeGeneratorContext = class {
4692
- static {
4693
- __name(this, "CodeGeneratorContext");
4694
- }
4695
- files = [];
4696
- };
4697
- var CodeGeneratorFileContext = class {
4698
- static {
4699
- __name(this, "CodeGeneratorFileContext");
4700
- }
4701
- constructor(req, file) {
4702
- this.req = req;
4703
- this.file = file;
4704
- this.nodes = req.nodes.toArray();
4705
- this.imports = file.imports.toArray();
4706
- }
4707
- // inputs
4708
- nodes;
4709
- imports;
4710
- // outputs
4711
- concreteLists = [];
4712
- generatedNodeIds = /* @__PURE__ */ new Set();
4713
- generatedResultsPromiseIds = /* @__PURE__ */ new Set();
4714
- tsPath = "";
4715
- codeParts = [];
4716
- toString() {
4717
- return this.file?.filename ?? "CodeGeneratorFileContext()";
4718
- }
4719
- };
4720
- function generateFileId(ctx) {
4721
- ctx.codeParts.push(
4722
- `export const _capnpFileId = BigInt("0x${ctx.file.id.toString(16)}");`
4723
- );
4724
- }
4725
- __name(generateFileId, "generateFileId");
4726
- function generateConcreteListInitializer(ctx, fullClassName, field) {
4727
- const name = `_${c2t(field.name)}`;
4728
- const type = getConcreteListType(ctx, field.slot.type);
4729
- ctx.codeParts.push(`${fullClassName}.${name} = ${type};`);
4730
- }
4731
- __name(generateConcreteListInitializer, "generateConcreteListInitializer");
4732
- function generateCapnpImport(ctx) {
4733
- const fileNode = lookupNode(ctx, ctx.file);
4734
- const tsFileId = hexToBigInt(TS_FILE_ID);
4735
- const tsAnnotationFile = ctx.nodes.find((n) => n.id === tsFileId);
4736
- const tsImportPathAnnotation = tsAnnotationFile?.nestedNodes.find(
4737
- (n) => n.name === "importPath"
4738
- );
4739
- const importAnnotation = tsImportPathAnnotation && fileNode.annotations.find((a) => a.id === tsImportPathAnnotation.id);
4740
- const importPath = importAnnotation === void 0 ? "storm-capnp" : importAnnotation.value.text;
4741
- ctx.codeParts.push(`import * as $ from '${importPath}';`);
4742
- }
4743
- __name(generateCapnpImport, "generateCapnpImport");
4744
- function generateNestedImports(ctx) {
4745
- for (const imp of ctx.imports) {
4746
- const { name } = imp;
4747
- let importPath;
4748
- if (name.startsWith("/capnp/")) {
4749
- importPath = `storm-capnp/capnp/${name.slice(7).replace(/\.capnp$/, "")}`;
4750
- } else {
4751
- importPath = name.replace(/\.capnp$/, ".js");
4752
- if (importPath[0] !== ".") {
4753
- importPath = `./${importPath}`;
4754
- }
4755
- }
4756
- const importNode = lookupNode(ctx, imp);
4757
- const imports = getImportNodes(ctx, importNode).flatMap((node) => {
4758
- const fullClassName = getFullClassName(node);
4759
- if (node._isInterface) {
4760
- return [fullClassName, `${fullClassName}$Client`];
4761
- }
4762
- return fullClassName;
4763
- }).sort().join(", ");
4764
- if (imports.length === 0) {
4765
- continue;
4766
- }
4767
- ctx.codeParts.push(`import { ${imports} } from "${importPath}";`);
4768
- }
4769
- }
4770
- __name(generateNestedImports, "generateNestedImports");
4771
- function getImportNodes(ctx, node, visitedIds = /* @__PURE__ */ new Set()) {
4772
- visitedIds.add(node.id);
4773
- const nestedNodes = node.nestedNodes.filter(({ id }) => hasNode(ctx, id));
4774
- const newNestedNodes = nestedNodes.filter(({ id }) => !visitedIds.has(id));
4775
- const nodes = newNestedNodes.map(({ id }) => lookupNode(ctx, id)).filter((node2) => node2._isStruct || node2._isEnum || node2._isInterface);
4776
- return nodes.concat(
4777
- nodes.flatMap((node2) => getImportNodes(ctx, node2, visitedIds))
4778
- );
4779
- }
4780
- __name(getImportNodes, "getImportNodes");
4781
- async function compileAll(codeGenRequest, opts) {
4782
- const req = new Message(codeGenRequest, false).getRoot(
4783
- CodeGeneratorRequest
4784
- );
4785
- const ctx = new CodeGeneratorContext();
4786
- ctx.files = req.requestedFiles.map((file) => loadRequestedFile(req, file));
4787
- const files = new Map(
4788
- ctx.files.map((file) => [file.tsPath, compileFile(file)])
4789
- );
4790
- tsCompile(files, opts?.dts === true, opts?.js === true, opts?.tsconfig);
4791
- if (!opts?.ts) {
4792
- for (const [fileName] of files) {
4793
- if (fileName.endsWith(".ts") && !fileName.endsWith(".d.ts")) {
4794
- files.delete(fileName);
4795
- }
4796
- }
4797
- }
4798
- return {
4799
- ctx,
4800
- files
4801
- };
4802
- }
4803
- __name(compileAll, "compileAll");
4804
- function compileFile(ctx) {
4805
- generateCapnpImport(ctx);
4806
- generateNestedImports(ctx);
4807
- generateFileId(ctx);
4808
- const nestedNodes = lookupNode(ctx, ctx.file).nestedNodes.map(
4809
- (n) => lookupNode(ctx, n)
4810
- );
4811
- for (const node of nestedNodes) {
4812
- generateNode(ctx, node);
4813
- }
4814
- for (const [fullClassName, field] of ctx.concreteLists) {
4815
- generateConcreteListInitializer(ctx, fullClassName, field);
4816
- }
4817
- const sourceFile = ts.createSourceFile(
4818
- ctx.tsPath,
4819
- ctx.codeParts.map((p) => p.toString()).join(""),
4820
- ts.ScriptTarget.Latest,
4821
- false,
4822
- ts.ScriptKind.TS
4823
- );
4824
- return SOURCE_COMMENT + ts.createPrinter().printFile(sourceFile);
4825
- }
4826
- __name(compileFile, "compileFile");
4827
- function tsCompile(files, dts, js, tsconfig) {
4828
- if (!dts && !js) {
4829
- return;
4830
- }
4831
- const compileOptions = {
4832
- moduleResolution: ts.ModuleResolutionKind.Bundler,
4833
- target: ts.ScriptTarget.ESNext,
4834
- strict: true,
4835
- ...tsconfig,
4836
- noEmitOnError: false,
4837
- noFallthroughCasesInSwitch: true,
4838
- preserveConstEnums: true,
4839
- noImplicitReturns: true,
4840
- noUnusedLocals: false,
4841
- noUnusedParameters: false,
4842
- removeComments: false,
4843
- skipLibCheck: true,
4844
- sourceMap: false,
4845
- emitDeclarationOnly: dts && !js,
4846
- declaration: dts
4847
- };
4848
- const compilerHost = ts.createCompilerHost(compileOptions);
4849
- compilerHost.writeFile = (fileName, declaration) => {
4850
- files.set(fileName, declaration);
4851
- };
4852
- const _readFile = compilerHost.readFile;
4853
- compilerHost.readFile = (filename) => {
4854
- if (files.has(filename)) {
4855
- return files.get(filename);
4856
- }
4857
- return _readFile(filename);
4858
- };
4859
- const program = ts.createProgram(
4860
- [...files.keys()],
4861
- compileOptions,
4862
- compilerHost
4863
- );
4864
- const emitResult = program.emit();
4865
- const allDiagnostics = [
4866
- ...ts.getPreEmitDiagnostics(program),
4867
- ...emitResult.diagnostics
4868
- ];
4869
- if (allDiagnostics.length > 0) {
4870
- for (const diagnostic of allDiagnostics) {
4871
- const message = ts.flattenDiagnosticMessageText(
4872
- diagnostic.messageText,
4873
- "\n"
4874
- );
4875
- if (diagnostic.file && diagnostic.start) {
4876
- const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
4877
- console.log(
4878
- `${diagnostic.file.fileName}:${line + 1}:${character + 1} ${message}`
4879
- );
4880
- } else {
4881
- console.log(`==> ${message}`);
4882
- }
4883
- }
4884
- throw new Error(GEN_TS_EMIT_FAILED);
4885
- }
4886
- }
4887
- __name(tsCompile, "tsCompile");
4888
-
4889
- // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=8f737a83e1b5be10396ff9b257b56b8b8e7a3dbd2754765e9b1e2019839e9c31_typescript@5.8.3/node_modules/capnp-es/dist/compiler/index.mjs
4890
- import "typescript";
4891
-
4892
- // src/compile.ts
4893
- import { Buffer as Buffer2 } from "node:buffer";
4894
- import { exec } from "node:child_process";
4895
- import { existsSync as existsSync2 } from "node:fs";
4896
- async function capnpc(options) {
4897
- try {
4898
- const { output, tsconfig, schema = [] } = options;
4899
- let dataBuf = Buffer2.alloc(0);
4900
- if (!process.stdin.isTTY) {
4901
- const chunks = [];
4902
- process.stdin.on("data", (chunk) => {
4903
- chunks.push(chunk);
4904
- });
4905
- await new Promise((resolve) => {
4906
- process.stdin.on("end", resolve);
4907
- });
4908
- const reqBuffer = Buffer2.alloc(chunks.reduce((l, chunk) => l + chunk.byteLength, 0));
4909
- let i = 0;
4910
- for (const chunk of chunks) {
4911
- chunk.copy(reqBuffer, i);
4912
- i += chunk.byteLength;
4913
- }
4914
- dataBuf = reqBuffer;
4915
- }
4916
- if (dataBuf.byteLength === 0) {
4917
- const opts = [];
4918
- if (output) {
4919
- opts.push(`-o-:${output}`);
4920
- } else {
4921
- opts.push("-o-");
4922
- }
4923
- dataBuf = await new Promise((resolve) => {
4924
- exec(`capnpc ${opts.join(" ")} ${schema.join(" ")}`, {
4925
- encoding: "buffer"
4926
- }, (error, stdout, stderr) => {
4927
- if (stderr.length > 0) {
4928
- process.stderr.write(stderr);
4929
- }
4930
- if (error) {
4931
- throw error;
4932
- }
4933
- resolve(stdout);
4934
- });
4935
- });
4936
- }
4937
- const result = await compileAll(dataBuf, {
4938
- ts: options.ts ?? true,
4939
- js: options.js ?? false,
4940
- dts: options.dts ?? true,
4941
- tsconfig: tsconfig?.options
4942
- });
4943
- for (const [fileName, content] of result.files) {
4944
- let filePath = fileName;
4945
- if (!existsSync2(findFilePath(filePath))) {
4946
- const fullPath = `/${filePath}`;
4947
- if (existsSync2(findFilePath(fullPath))) {
4948
- filePath = fullPath;
4949
- }
4950
- }
4951
- if (output) {
4952
- filePath = joinPaths(output, fileName);
4953
- }
4954
- if (!existsSync2(findFilePath(filePath))) {
4955
- await createDirectory(findFilePath(filePath));
4956
- }
4957
- await writeFile(
4958
- filePath,
4959
- // https://github.com/microsoft/TypeScript/issues/54632
4960
- content.replace(/^\s+/gm, (match) => " ".repeat(match.length / 2))
4961
- );
4962
- }
4963
- return result;
4964
- } catch (error) {
4965
- if (error instanceof Error) {
4966
- console.error(`Error: ${error.message}`);
4967
- if (error.stack) {
4968
- console.error(error.stack);
4969
- }
4970
- } else {
4971
- console.error("An unknown error occurred:", error);
4972
- }
4973
- throw error;
4974
- }
4975
- }
4976
- __name(capnpc, "capnpc");
4977
-
4978
- export {
4979
- capnpc
4980
- };