@stryke/capnp 0.10.0 → 0.10.2

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