@stryke/capnp 0.4.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4758 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28; var _class29; var _class30; var _class31; var _class32; var _class33; var _class34; var _class35; var _class36; var _class37; var _class38; var _class39; var _class40; var _class41; var _class42; var _class43; var _class44;
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+ var _chunkIVTBYMMNcjs = require('./chunk-IVTBYMMN.cjs');
126
+
127
+ // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=53996ae63a1465953815fff49405f2224c85d26eeeff469d2b1f87e1c2af451d_typescript@5.8.3/node_modules/capnp-es/dist/shared/capnp-es.UAt3nLGq.mjs
128
+ var Interface = (_class = class extends _chunkIVTBYMMNcjs.Pointer {
129
+ static {
130
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Interface");
131
+ }
132
+ static __initStatic() {this._capnp = {
133
+ displayName: "Interface"
134
+ }}
135
+ static __initStatic2() {this.getCapID = getCapID}
136
+ static __initStatic3() {this.getAsInterface = getAsInterface}
137
+ static __initStatic4() {this.isInterface = isInterface}
138
+ static __initStatic5() {this.getClient = getClient}
139
+ constructor(segment, byteOffset, depthLimit = _chunkIVTBYMMNcjs.MAX_DEPTH) {
140
+ super(segment, byteOffset, depthLimit);
141
+ }
142
+ static fromPointer(p) {
143
+ return getAsInterface(p);
144
+ }
145
+ getCapId() {
146
+ return getCapID(this);
147
+ }
148
+ getClient() {
149
+ return getClient(this);
150
+ }
151
+ [Symbol.for("nodejs.util.inspect.custom")]() {
152
+ return _chunkIVTBYMMNcjs.format.call(void 0,
153
+ "Interface_%d@%a,%d,limit:%x",
154
+ this.segment.id,
155
+ this.byteOffset,
156
+ this.getCapId(),
157
+ this._capnp.depthLimit
158
+ );
159
+ }
160
+ }, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class.__initStatic5(), _class);
161
+ function getAsInterface(p) {
162
+ if (_chunkIVTBYMMNcjs.getTargetPointerType.call(void 0, p) === _chunkIVTBYMMNcjs.PointerType.OTHER) {
163
+ return new Interface(p.segment, p.byteOffset, p._capnp.depthLimit);
164
+ }
165
+ return null;
166
+ }
167
+ _chunkIVTBYMMNcjs.__name.call(void 0, getAsInterface, "getAsInterface");
168
+ function isInterface(p) {
169
+ return _chunkIVTBYMMNcjs.getTargetPointerType.call(void 0, p) === _chunkIVTBYMMNcjs.PointerType.OTHER;
170
+ }
171
+ _chunkIVTBYMMNcjs.__name.call(void 0, isInterface, "isInterface");
172
+ function getCapID(i) {
173
+ if (i.segment.getUint32(i.byteOffset) !== _chunkIVTBYMMNcjs.PointerType.OTHER) {
174
+ return -1;
175
+ }
176
+ return i.segment.getUint32(i.byteOffset + 4);
177
+ }
178
+ _chunkIVTBYMMNcjs.__name.call(void 0, getCapID, "getCapID");
179
+ function getClient(i) {
180
+ const capID = getCapID(i);
181
+ const { capTable } = i.segment.message._capnp;
182
+ if (!capTable) {
183
+ return null;
184
+ }
185
+ return capTable[capID];
186
+ }
187
+ _chunkIVTBYMMNcjs.__name.call(void 0, getClient, "getClient");
188
+ function isFuncCall(call) {
189
+ return !isDataCall(call);
190
+ }
191
+ _chunkIVTBYMMNcjs.__name.call(void 0, isFuncCall, "isFuncCall");
192
+ function isDataCall(call) {
193
+ return !!call.params;
194
+ }
195
+ _chunkIVTBYMMNcjs.__name.call(void 0, isDataCall, "isDataCall");
196
+ function copyCall(call) {
197
+ if (isDataCall(call)) {
198
+ return call;
199
+ }
200
+ return {
201
+ method: call.method,
202
+ params: placeParams(call, void 0)
203
+ };
204
+ }
205
+ _chunkIVTBYMMNcjs.__name.call(void 0, copyCall, "copyCall");
206
+ function placeParams(call, contentPtr) {
207
+ if (isDataCall(call)) {
208
+ return call.params;
209
+ }
210
+ let p;
211
+ if (contentPtr) {
212
+ p = new call.method.ParamsClass(
213
+ contentPtr.segment,
214
+ contentPtr.byteOffset,
215
+ contentPtr._capnp.depthLimit
216
+ );
217
+ } else {
218
+ const msg = new (0, _chunkIVTBYMMNcjs.Message)();
219
+ p = new call.method.ParamsClass(msg.getSegment(0), 0);
220
+ }
221
+ _chunkIVTBYMMNcjs.initStruct.call(void 0, call.method.ParamsClass._capnp.size, p);
222
+ if (call.paramsFunc) {
223
+ call.paramsFunc(p);
224
+ }
225
+ return p;
226
+ }
227
+ _chunkIVTBYMMNcjs.__name.call(void 0, placeParams, "placeParams");
228
+ function pointerToStruct(p) {
229
+ if (_chunkIVTBYMMNcjs.getTargetPointerType.call(void 0, p) === _chunkIVTBYMMNcjs.PointerType.STRUCT) {
230
+ return new (0, _chunkIVTBYMMNcjs.Struct)(
231
+ p.segment,
232
+ p.byteOffset,
233
+ p._capnp.depthLimit,
234
+ p._capnp.compositeIndex
235
+ );
236
+ }
237
+ return null;
238
+ }
239
+ _chunkIVTBYMMNcjs.__name.call(void 0, pointerToStruct, "pointerToStruct");
240
+ function transformPtr(p, transform) {
241
+ if (transform.length === 0) {
242
+ return p;
243
+ }
244
+ let s = pointerToStruct(p);
245
+ if (!s) {
246
+ return p;
247
+ }
248
+ for (const op of transform) {
249
+ s = _chunkIVTBYMMNcjs.getPointer.call(void 0, op.field, s);
250
+ }
251
+ return s;
252
+ }
253
+ _chunkIVTBYMMNcjs.__name.call(void 0, transformPtr, "transformPtr");
254
+ var Deferred = class _Deferred {
255
+ static {
256
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Deferred");
257
+ }
258
+ static fromPromise(p) {
259
+ const d = new _Deferred();
260
+ p.then(d.resolve, d.reject);
261
+ return d;
262
+ }
263
+
264
+
265
+
266
+ constructor() {
267
+ this.promise = new Promise((a, b) => {
268
+ this.resolve = a;
269
+ this.reject = b;
270
+ });
271
+ }
272
+ };
273
+ var ImmediateAnswer = class extends _chunkIVTBYMMNcjs.FixedAnswer {
274
+ static {
275
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "ImmediateAnswer");
276
+ }
277
+ constructor(s) {
278
+ super();
279
+ this.s = s;
280
+ }
281
+ structSync() {
282
+ return this.s;
283
+ }
284
+ findClient(transform) {
285
+ const p = transformPtr(this.s, transform);
286
+ return _chunkIVTBYMMNcjs.getInterfaceClientOrNull.call(void 0, p);
287
+ }
288
+ pipelineCall(transform, call) {
289
+ return this.findClient(transform).call(call);
290
+ }
291
+ pipelineClose(transform) {
292
+ this.findClient(transform).close();
293
+ }
294
+ };
295
+ var Queue = (_class2 = class {
296
+ static {
297
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Queue");
298
+ }
299
+ // creates a new queue that starts with n elements.
300
+ // The interface's length must not change over the course of
301
+ // the queue's usage.
302
+ constructor(q, n) {;_class2.prototype.__init.call(this);
303
+ this.q = q;
304
+ this.n = n;
305
+ this.cap = q.len();
306
+ }
307
+ __init() {this.start = 0}
308
+
309
+ // len returns the length of the queue. This is different from the underlying
310
+ // interface's length, which is the queue's capacity.
311
+ len() {
312
+ return this.n;
313
+ }
314
+ // push reserves space for an element on the queue, returning its index.
315
+ // if the queue is full, push returns -1.
316
+ push() {
317
+ if (this.n >= this.cap) {
318
+ return -1;
319
+ }
320
+ const i = (this.start + this.n) % this.cap;
321
+ this.n++;
322
+ return i;
323
+ }
324
+ // front returns the index of the front of the queue, or -1 if the queue is empty.
325
+ front() {
326
+ if (this.n === 0) {
327
+ return -1;
328
+ }
329
+ return this.start;
330
+ }
331
+ // pop pops an element from the queue, returning whether it succeeded.
332
+ pop() {
333
+ if (this.n === 0) {
334
+ return false;
335
+ }
336
+ this.q.clear(this.start);
337
+ this.start = (this.start + 1) % this.cap;
338
+ this.n--;
339
+ return true;
340
+ }
341
+ }, _class2);
342
+ var EmbargoClient = class {
343
+ static {
344
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "EmbargoClient");
345
+ }
346
+
347
+
348
+
349
+ constructor(client, queue) {
350
+ this._client = client;
351
+ this.calls = queue.copy();
352
+ this.q = new Queue(this.calls, this.calls.len());
353
+ this.flushQueue();
354
+ }
355
+ flushQueue() {
356
+ let c = null;
357
+ {
358
+ const i = this.q.front();
359
+ if (i !== -1) {
360
+ c = this.calls.data[i];
361
+ }
362
+ }
363
+ while (c && c.call) {
364
+ const ans = this._client.call(c.call);
365
+ void (async (f, ans2) => {
366
+ try {
367
+ f.fulfill(await ans2.struct());
368
+ } catch (error_) {
369
+ f.reject(error_);
370
+ }
371
+ })(c.f, ans);
372
+ this.q.pop();
373
+ {
374
+ const i = this.q.front();
375
+ c = i === -1 ? null : this.calls.data[i];
376
+ }
377
+ }
378
+ }
379
+ // client returns the underlying client if the embargo has
380
+ // been lifted and null otherwise
381
+ client() {
382
+ return this.isPassthrough() ? this._client : null;
383
+ }
384
+ isPassthrough() {
385
+ return this.q.len() === 0;
386
+ }
387
+ // call either queues a call to the underlying client or starts a
388
+ // call if the embargo has been lifted
389
+ call(call) {
390
+ if (this.isPassthrough()) {
391
+ return this._client.call(call);
392
+ }
393
+ return this.push(call);
394
+ }
395
+ push(_call) {
396
+ const f = new Fulfiller();
397
+ const call = copyCall(_call);
398
+ const i = this.q.push();
399
+ if (i === -1) {
400
+ return new (0, _chunkIVTBYMMNcjs.ErrorAnswer)(new Error(_chunkIVTBYMMNcjs.RPC_CALL_QUEUE_FULL));
401
+ }
402
+ this.calls.data[i] = {
403
+ call,
404
+ f
405
+ };
406
+ return f;
407
+ }
408
+ close() {
409
+ while (this.q.len() > 0) {
410
+ const first = this.calls.data[this.q.front()];
411
+ if (!first) {
412
+ throw new Error(_chunkIVTBYMMNcjs.INVARIANT_UNREACHABLE_CODE);
413
+ }
414
+ first.f.reject(new Error(_chunkIVTBYMMNcjs.RPC_QUEUE_CALL_CANCEL));
415
+ this.q.pop();
416
+ }
417
+ this._client.close();
418
+ }
419
+ };
420
+ var Ecalls = class _Ecalls {
421
+ static {
422
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Ecalls");
423
+ }
424
+
425
+ constructor(data) {
426
+ this.data = data;
427
+ }
428
+ static copyOf(data) {
429
+ return new _Ecalls([...data]);
430
+ }
431
+ len() {
432
+ return this.data.length;
433
+ }
434
+ clear(i) {
435
+ this.data[i] = null;
436
+ }
437
+ copy() {
438
+ return _Ecalls.copyOf(this.data);
439
+ }
440
+ };
441
+ var callQueueSize = 64;
442
+ var Fulfiller = (_class3 = class _Fulfiller {constructor() { _class3.prototype.__init2.call(this);_class3.prototype.__init3.call(this);_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this); }
443
+ static {
444
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Fulfiller");
445
+ }
446
+ __init2() {this.resolved = false}
447
+
448
+ __init3() {this.queue = []}
449
+ __init4() {this.queueCap = callQueueSize}
450
+ __init5() {this.deferred = new Deferred()}
451
+ fulfill(s) {
452
+ this.answer = new ImmediateAnswer(s);
453
+ const queues = this.emptyQueue(s);
454
+ const msgcap = s.segment.message._capnp;
455
+ if (!msgcap.capTable) {
456
+ msgcap.capTable = [];
457
+ }
458
+ const ctab = msgcap.capTable;
459
+ for (const _capIdx of Object.keys(queues)) {
460
+ const capIdx = +_capIdx;
461
+ const q = queues[capIdx];
462
+ const client = ctab[capIdx];
463
+ if (!client) {
464
+ throw new Error(_chunkIVTBYMMNcjs.INVARIANT_UNREACHABLE_CODE);
465
+ }
466
+ ctab[capIdx] = new EmbargoClient(client, q);
467
+ }
468
+ this.deferred.resolve(s);
469
+ }
470
+ reject(err) {
471
+ this.deferred.reject(err);
472
+ }
473
+ peek() {
474
+ return this.answer;
475
+ }
476
+ async struct() {
477
+ return await this.deferred.promise;
478
+ }
479
+ // pipelineCall calls pipelineCall on the fulfilled answer or
480
+ // queues the call if f has not been fulfilled
481
+ pipelineCall(transform, call) {
482
+ {
483
+ const a = this.peek();
484
+ if (a) {
485
+ return a.pipelineCall(transform, call);
486
+ }
487
+ }
488
+ if (this.queue.length === this.queueCap) {
489
+ return new (0, _chunkIVTBYMMNcjs.ErrorAnswer)(new Error(_chunkIVTBYMMNcjs.RPC_CALL_QUEUE_FULL));
490
+ }
491
+ const cc = copyCall(call);
492
+ const g = new _Fulfiller();
493
+ this.queue.push({
494
+ call: cc,
495
+ f: g,
496
+ transform
497
+ });
498
+ return g;
499
+ }
500
+ // pipelineClose waits until f is resolved and then calls
501
+ // pipelineClose on the fulfilled answer
502
+ // FIXME: should this be async?
503
+ pipelineClose(transform) {
504
+ const onFinally = /* @__PURE__ */ _chunkIVTBYMMNcjs.__name.call(void 0, () => {
505
+ if (this.answer) {
506
+ this.answer.pipelineClose(transform);
507
+ }
508
+ }, "onFinally");
509
+ this.deferred.promise.then(onFinally, onFinally);
510
+ }
511
+ // emptyQueue splits the queue by which capability it targets and
512
+ // drops any invalid calls. Once this function returns, f.queue will
513
+ // be nil.
514
+ emptyQueue(s) {
515
+ const qs = {};
516
+ for (let i = 0; i < this.queue.length; i++) {
517
+ const pc = this.queue[i];
518
+ let c;
519
+ try {
520
+ c = transformPtr(s, pc.transform);
521
+ } catch (error_) {
522
+ pc.f.reject(error_);
523
+ continue;
524
+ }
525
+ const iface = Interface.fromPointer(c);
526
+ if (!iface) {
527
+ pc.f.reject(new Error(_chunkIVTBYMMNcjs.RPC_NULL_CLIENT));
528
+ continue;
529
+ }
530
+ const cn = iface.getCapId();
531
+ if (!qs[cn]) {
532
+ qs[cn] = new Ecalls([]);
533
+ }
534
+ qs[cn].data.push(pc);
535
+ }
536
+ this.queue = [];
537
+ return qs;
538
+ }
539
+ }, _class3);
540
+ var PipelineClient = class {
541
+ static {
542
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "PipelineClient");
543
+ }
544
+ constructor(pipeline) {
545
+ this.pipeline = pipeline;
546
+ }
547
+ transform() {
548
+ return this.pipeline.transform();
549
+ }
550
+ call(call) {
551
+ return this.pipeline.answer.pipelineCall(this.transform(), call);
552
+ }
553
+ close() {
554
+ this.pipeline.answer.pipelineClose(this.transform());
555
+ }
556
+ };
557
+ var Pipeline = class _Pipeline {
558
+ static {
559
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Pipeline");
560
+ }
561
+ // Returns a new Pipeline based on an answer
562
+ constructor(ResultsClass, answer, op, parent) {
563
+ this.ResultsClass = ResultsClass;
564
+ this.answer = answer;
565
+ this.parent = parent;
566
+ this.op = op || { field: 0 };
567
+ }
568
+
569
+
570
+ // transform returns the operations needed to transform the root answer
571
+ // into the value p represents.
572
+ transform() {
573
+ const xform = [];
574
+ for (let q = this; q.parent; q = q.parent) {
575
+ xform.unshift(q.op);
576
+ }
577
+ return xform;
578
+ }
579
+ // Struct waits until the answer is resolved and returns the struct
580
+ // this pipeline represents.
581
+ async struct() {
582
+ const s = await this.answer.struct();
583
+ const t = transformPtr(s, this.transform());
584
+ if (!t) {
585
+ if (this.op.defaultValue) {
586
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, this.op.defaultValue, t);
587
+ } else {
588
+ _chunkIVTBYMMNcjs.initStruct.call(void 0, this.ResultsClass._capnp.size, t);
589
+ }
590
+ }
591
+ return _chunkIVTBYMMNcjs.getAs.call(void 0, this.ResultsClass, t);
592
+ }
593
+ // client returns the client version of this pipeline
594
+ client() {
595
+ if (!this.pipelineClient) {
596
+ this.pipelineClient = new PipelineClient(this);
597
+ }
598
+ return this.pipelineClient;
599
+ }
600
+ // getPipeline returns a derived pipeline which yields the pointer field given
601
+ getPipeline(ResultsClass, off, defaultValue) {
602
+ return new _Pipeline(
603
+ ResultsClass,
604
+ this.answer,
605
+ { field: off, defaultValue },
606
+ this
607
+ );
608
+ }
609
+ };
610
+ var MethodError = class extends Error {
611
+ static {
612
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "MethodError");
613
+ }
614
+ constructor(method, message) {
615
+ super(
616
+ _chunkIVTBYMMNcjs.format.call(void 0,
617
+ _chunkIVTBYMMNcjs.RPC_METHOD_ERROR,
618
+ method.interfaceName,
619
+ method.methodName,
620
+ message
621
+ )
622
+ );
623
+ this.method = method;
624
+ }
625
+ };
626
+ var Registry = (_class4 = class {
627
+ static {
628
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Registry");
629
+ }
630
+ static __initStatic6() {this.interfaces = /* @__PURE__ */ new Map()}
631
+ static register(id, def) {
632
+ this.interfaces.set(id, def);
633
+ }
634
+ static lookup(id) {
635
+ return this.interfaces.get(id);
636
+ }
637
+ }, _class4.__initStatic6(), _class4);
638
+ var Server = class {
639
+ static {
640
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Server");
641
+ }
642
+ constructor(target, methods) {
643
+ this.target = target;
644
+ this.methods = methods;
645
+ }
646
+ startCall(call) {
647
+ const msg = new (0, _chunkIVTBYMMNcjs.Message)();
648
+ const results = msg.initRoot(call.method.ResultsClass);
649
+ call.serverMethod.impl.call(this.target, call.params, results).then(() => call.answer.fulfill(results)).catch((error_) => call.answer.reject(error_));
650
+ }
651
+ call(call) {
652
+ const serverMethod = this.methods[call.method.methodId];
653
+ if (!serverMethod) {
654
+ return new (0, _chunkIVTBYMMNcjs.ErrorAnswer)(
655
+ new MethodError(call.method, _chunkIVTBYMMNcjs.RPC_METHOD_NOT_IMPLEMENTED)
656
+ );
657
+ }
658
+ const serverCall = {
659
+ ...copyCall(call),
660
+ answer: new Fulfiller(),
661
+ serverMethod
662
+ };
663
+ this.startCall(serverCall);
664
+ return serverCall.answer;
665
+ }
666
+ close() {
667
+ }
668
+ };
669
+
670
+ // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=53996ae63a1465953815fff49405f2224c85d26eeeff469d2b1f87e1c2af451d_typescript@5.8.3/node_modules/capnp-es/dist/capnp/rpc.mjs
671
+ var _capnpFileId = BigInt("0xb312981b2552a250");
672
+ var Message_Which = {
673
+ /**
674
+ * The sender previously received this message from the peer but didn't understand it or doesn't
675
+ * yet implement the functionality that was requested. So, the sender is echoing the message
676
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
677
+ * had taken some appropriate "null" action.
678
+ *
679
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
680
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
681
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
682
+ * had resolved, thus avoiding a leak.
683
+ *
684
+ * For any message type that introduces a question, if the message comes back unimplemented,
685
+ * the original sender may simply treat it as if the question failed with an exception.
686
+ *
687
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
688
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
689
+ * a gray area; different implementations may take different approaches.
690
+ *
691
+ */
692
+ UNIMPLEMENTED: 0,
693
+ /**
694
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
695
+ * because the sender received an invalid or nonsensical message or because the sender had an
696
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
697
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
698
+ * of a time buffer they want to offer for the client to receive the `abort` before the
699
+ * connection is reset).
700
+ *
701
+ */
702
+ ABORT: 1,
703
+ /**
704
+ * Request the peer's bootstrap interface.
705
+ *
706
+ */
707
+ BOOTSTRAP: 8,
708
+ /**
709
+ * Begin a method call.
710
+ *
711
+ */
712
+ CALL: 2,
713
+ /**
714
+ * Complete a method call.
715
+ *
716
+ */
717
+ RETURN: 3,
718
+ /**
719
+ * Release a returned answer / cancel a call.
720
+ *
721
+ */
722
+ FINISH: 4,
723
+ /**
724
+ * Resolve a previously-sent promise.
725
+ *
726
+ */
727
+ RESOLVE: 5,
728
+ /**
729
+ * Release a capability so that the remote object can be deallocated.
730
+ *
731
+ */
732
+ RELEASE: 6,
733
+ /**
734
+ * Lift an embargo used to enforce E-order over promise resolution.
735
+ *
736
+ */
737
+ DISEMBARGO: 13,
738
+ /**
739
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
740
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
741
+ * implemented.
742
+ *
743
+ */
744
+ OBSOLETE_SAVE: 7,
745
+ /**
746
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
747
+ *
748
+ */
749
+ OBSOLETE_DELETE: 9,
750
+ /**
751
+ * Provide a capability to a third party.
752
+ *
753
+ */
754
+ PROVIDE: 10,
755
+ /**
756
+ * Accept a capability provided by a third party.
757
+ *
758
+ */
759
+ ACCEPT: 11,
760
+ /**
761
+ * Directly connect to the common root of two or more proxied caps.
762
+ *
763
+ */
764
+ JOIN: 12
765
+ };
766
+ var Message2 = (_class5 = class _Message extends _chunkIVTBYMMNcjs.Struct {
767
+ static {
768
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Message");
769
+ }
770
+ static __initStatic7() {this.UNIMPLEMENTED = Message_Which.UNIMPLEMENTED}
771
+ static __initStatic8() {this.ABORT = Message_Which.ABORT}
772
+ static __initStatic9() {this.BOOTSTRAP = Message_Which.BOOTSTRAP}
773
+ static __initStatic10() {this.CALL = Message_Which.CALL}
774
+ static __initStatic11() {this.RETURN = Message_Which.RETURN}
775
+ static __initStatic12() {this.FINISH = Message_Which.FINISH}
776
+ static __initStatic13() {this.RESOLVE = Message_Which.RESOLVE}
777
+ static __initStatic14() {this.RELEASE = Message_Which.RELEASE}
778
+ static __initStatic15() {this.DISEMBARGO = Message_Which.DISEMBARGO}
779
+ static __initStatic16() {this.OBSOLETE_SAVE = Message_Which.OBSOLETE_SAVE}
780
+ static __initStatic17() {this.OBSOLETE_DELETE = Message_Which.OBSOLETE_DELETE}
781
+ static __initStatic18() {this.PROVIDE = Message_Which.PROVIDE}
782
+ static __initStatic19() {this.ACCEPT = Message_Which.ACCEPT}
783
+ static __initStatic20() {this.JOIN = Message_Which.JOIN}
784
+ static __initStatic21() {this._capnp = {
785
+ displayName: "Message",
786
+ id: "91b79f1f808db032",
787
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
788
+ }}
789
+ _adoptUnimplemented(value) {
790
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 0, this);
791
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
792
+ }
793
+ _disownUnimplemented() {
794
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.unimplemented);
795
+ }
796
+ /**
797
+ * The sender previously received this message from the peer but didn't understand it or doesn't
798
+ * yet implement the functionality that was requested. So, the sender is echoing the message
799
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
800
+ * had taken some appropriate "null" action.
801
+ *
802
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
803
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
804
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
805
+ * had resolved, thus avoiding a leak.
806
+ *
807
+ * For any message type that introduces a question, if the message comes back unimplemented,
808
+ * the original sender may simply treat it as if the question failed with an exception.
809
+ *
810
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
811
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
812
+ * a gray area; different implementations may take different approaches.
813
+ *
814
+ */
815
+ get unimplemented() {
816
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "unimplemented", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 0, this);
817
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, _Message, this);
818
+ }
819
+ _hasUnimplemented() {
820
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
821
+ }
822
+ _initUnimplemented() {
823
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 0, this);
824
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, _Message, this);
825
+ }
826
+ get _isUnimplemented() {
827
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 0;
828
+ }
829
+ set unimplemented(value) {
830
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 0, this);
831
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
832
+ }
833
+ _adoptAbort(value) {
834
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 1, this);
835
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
836
+ }
837
+ _disownAbort() {
838
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.abort);
839
+ }
840
+ /**
841
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
842
+ * because the sender received an invalid or nonsensical message or because the sender had an
843
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
844
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
845
+ * of a time buffer they want to offer for the client to receive the `abort` before the
846
+ * connection is reset).
847
+ *
848
+ */
849
+ get abort() {
850
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "abort", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 1, this);
851
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Exception, this);
852
+ }
853
+ _hasAbort() {
854
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
855
+ }
856
+ _initAbort() {
857
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 1, this);
858
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Exception, this);
859
+ }
860
+ get _isAbort() {
861
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 1;
862
+ }
863
+ set abort(value) {
864
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 1, this);
865
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
866
+ }
867
+ _adoptBootstrap(value) {
868
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 8, this);
869
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
870
+ }
871
+ _disownBootstrap() {
872
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.bootstrap);
873
+ }
874
+ /**
875
+ * Request the peer's bootstrap interface.
876
+ *
877
+ */
878
+ get bootstrap() {
879
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "bootstrap", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 8, this);
880
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Bootstrap, this);
881
+ }
882
+ _hasBootstrap() {
883
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
884
+ }
885
+ _initBootstrap() {
886
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 8, this);
887
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Bootstrap, this);
888
+ }
889
+ get _isBootstrap() {
890
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 8;
891
+ }
892
+ set bootstrap(value) {
893
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 8, this);
894
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
895
+ }
896
+ _adoptCall(value) {
897
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 2, this);
898
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
899
+ }
900
+ _disownCall() {
901
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.call);
902
+ }
903
+ /**
904
+ * Begin a method call.
905
+ *
906
+ */
907
+ get call() {
908
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "call", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 2, this);
909
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Call, this);
910
+ }
911
+ _hasCall() {
912
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
913
+ }
914
+ _initCall() {
915
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 2, this);
916
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Call, this);
917
+ }
918
+ get _isCall() {
919
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 2;
920
+ }
921
+ set call(value) {
922
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 2, this);
923
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
924
+ }
925
+ _adoptReturn(value) {
926
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 3, this);
927
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
928
+ }
929
+ _disownReturn() {
930
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.return);
931
+ }
932
+ /**
933
+ * Complete a method call.
934
+ *
935
+ */
936
+ get return() {
937
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "return", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 3, this);
938
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Return, this);
939
+ }
940
+ _hasReturn() {
941
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
942
+ }
943
+ _initReturn() {
944
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 3, this);
945
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Return, this);
946
+ }
947
+ get _isReturn() {
948
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 3;
949
+ }
950
+ set return(value) {
951
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 3, this);
952
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
953
+ }
954
+ _adoptFinish(value) {
955
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 4, this);
956
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
957
+ }
958
+ _disownFinish() {
959
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.finish);
960
+ }
961
+ /**
962
+ * Release a returned answer / cancel a call.
963
+ *
964
+ */
965
+ get finish() {
966
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "finish", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 4, this);
967
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Finish, this);
968
+ }
969
+ _hasFinish() {
970
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
971
+ }
972
+ _initFinish() {
973
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 4, this);
974
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Finish, this);
975
+ }
976
+ get _isFinish() {
977
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 4;
978
+ }
979
+ set finish(value) {
980
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 4, this);
981
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
982
+ }
983
+ _adoptResolve(value) {
984
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 5, this);
985
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
986
+ }
987
+ _disownResolve() {
988
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.resolve);
989
+ }
990
+ /**
991
+ * Resolve a previously-sent promise.
992
+ *
993
+ */
994
+ get resolve() {
995
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "resolve", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 5, this);
996
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Resolve, this);
997
+ }
998
+ _hasResolve() {
999
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1000
+ }
1001
+ _initResolve() {
1002
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 5, this);
1003
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Resolve, this);
1004
+ }
1005
+ get _isResolve() {
1006
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 5;
1007
+ }
1008
+ set resolve(value) {
1009
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 5, this);
1010
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1011
+ }
1012
+ _adoptRelease(value) {
1013
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 6, this);
1014
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1015
+ }
1016
+ _disownRelease() {
1017
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.release);
1018
+ }
1019
+ /**
1020
+ * Release a capability so that the remote object can be deallocated.
1021
+ *
1022
+ */
1023
+ get release() {
1024
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "release", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 6, this);
1025
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Release, this);
1026
+ }
1027
+ _hasRelease() {
1028
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1029
+ }
1030
+ _initRelease() {
1031
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 6, this);
1032
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Release, this);
1033
+ }
1034
+ get _isRelease() {
1035
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 6;
1036
+ }
1037
+ set release(value) {
1038
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 6, this);
1039
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1040
+ }
1041
+ _adoptDisembargo(value) {
1042
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 13, this);
1043
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1044
+ }
1045
+ _disownDisembargo() {
1046
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.disembargo);
1047
+ }
1048
+ /**
1049
+ * Lift an embargo used to enforce E-order over promise resolution.
1050
+ *
1051
+ */
1052
+ get disembargo() {
1053
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "disembargo", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 13, this);
1054
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Disembargo, this);
1055
+ }
1056
+ _hasDisembargo() {
1057
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1058
+ }
1059
+ _initDisembargo() {
1060
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 13, this);
1061
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Disembargo, this);
1062
+ }
1063
+ get _isDisembargo() {
1064
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 13;
1065
+ }
1066
+ set disembargo(value) {
1067
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 13, this);
1068
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1069
+ }
1070
+ _adoptObsoleteSave(value) {
1071
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 7, this);
1072
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1073
+ }
1074
+ _disownObsoleteSave() {
1075
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.obsoleteSave);
1076
+ }
1077
+ /**
1078
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
1079
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
1080
+ * implemented.
1081
+ *
1082
+ */
1083
+ get obsoleteSave() {
1084
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "obsoleteSave", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 7, this);
1085
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
1086
+ }
1087
+ _hasObsoleteSave() {
1088
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1089
+ }
1090
+ get _isObsoleteSave() {
1091
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 7;
1092
+ }
1093
+ set obsoleteSave(value) {
1094
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 7, this);
1095
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1096
+ }
1097
+ _adoptObsoleteDelete(value) {
1098
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 9, this);
1099
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1100
+ }
1101
+ _disownObsoleteDelete() {
1102
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.obsoleteDelete);
1103
+ }
1104
+ /**
1105
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
1106
+ *
1107
+ */
1108
+ get obsoleteDelete() {
1109
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "obsoleteDelete", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 9, this);
1110
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
1111
+ }
1112
+ _hasObsoleteDelete() {
1113
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1114
+ }
1115
+ get _isObsoleteDelete() {
1116
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 9;
1117
+ }
1118
+ set obsoleteDelete(value) {
1119
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 9, this);
1120
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1121
+ }
1122
+ _adoptProvide(value) {
1123
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 10, this);
1124
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1125
+ }
1126
+ _disownProvide() {
1127
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.provide);
1128
+ }
1129
+ /**
1130
+ * Provide a capability to a third party.
1131
+ *
1132
+ */
1133
+ get provide() {
1134
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "provide", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 10, this);
1135
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Provide, this);
1136
+ }
1137
+ _hasProvide() {
1138
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1139
+ }
1140
+ _initProvide() {
1141
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 10, this);
1142
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Provide, this);
1143
+ }
1144
+ get _isProvide() {
1145
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 10;
1146
+ }
1147
+ set provide(value) {
1148
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 10, this);
1149
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1150
+ }
1151
+ _adoptAccept(value) {
1152
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 11, this);
1153
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1154
+ }
1155
+ _disownAccept() {
1156
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.accept);
1157
+ }
1158
+ /**
1159
+ * Accept a capability provided by a third party.
1160
+ *
1161
+ */
1162
+ get accept() {
1163
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "accept", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 11, this);
1164
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Accept, this);
1165
+ }
1166
+ _hasAccept() {
1167
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1168
+ }
1169
+ _initAccept() {
1170
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 11, this);
1171
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Accept, this);
1172
+ }
1173
+ get _isAccept() {
1174
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 11;
1175
+ }
1176
+ set accept(value) {
1177
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 11, this);
1178
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1179
+ }
1180
+ _adoptJoin(value) {
1181
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 12, this);
1182
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1183
+ }
1184
+ _disownJoin() {
1185
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.join);
1186
+ }
1187
+ /**
1188
+ * Directly connect to the common root of two or more proxied caps.
1189
+ *
1190
+ */
1191
+ get join() {
1192
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "join", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 12, this);
1193
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Join, this);
1194
+ }
1195
+ _hasJoin() {
1196
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1197
+ }
1198
+ _initJoin() {
1199
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 12, this);
1200
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Join, this);
1201
+ }
1202
+ get _isJoin() {
1203
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 12;
1204
+ }
1205
+ set join(value) {
1206
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 12, this);
1207
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1208
+ }
1209
+ toString() {
1210
+ return "Message_" + super.toString();
1211
+ }
1212
+ which() {
1213
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this);
1214
+ }
1215
+ }, _class5.__initStatic7(), _class5.__initStatic8(), _class5.__initStatic9(), _class5.__initStatic10(), _class5.__initStatic11(), _class5.__initStatic12(), _class5.__initStatic13(), _class5.__initStatic14(), _class5.__initStatic15(), _class5.__initStatic16(), _class5.__initStatic17(), _class5.__initStatic18(), _class5.__initStatic19(), _class5.__initStatic20(), _class5.__initStatic21(), _class5);
1216
+ var Bootstrap = (_class6 = class extends _chunkIVTBYMMNcjs.Struct {
1217
+ static {
1218
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Bootstrap");
1219
+ }
1220
+ static __initStatic22() {this._capnp = {
1221
+ displayName: "Bootstrap",
1222
+ id: "e94ccf8031176ec4",
1223
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
1224
+ }}
1225
+ /**
1226
+ * A new question ID identifying this request, which will eventually receive a Return message
1227
+ * containing the restored capability.
1228
+ *
1229
+ */
1230
+ get questionId() {
1231
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
1232
+ }
1233
+ set questionId(value) {
1234
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
1235
+ }
1236
+ _adoptDeprecatedObjectId(value) {
1237
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1238
+ }
1239
+ _disownDeprecatedObjectId() {
1240
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.deprecatedObjectId);
1241
+ }
1242
+ /**
1243
+ * ** DEPRECATED **
1244
+ *
1245
+ * A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies
1246
+ * which one to return. If this pointer is null, then the default bootstrap interface is returned.
1247
+ *
1248
+ * As of version 0.5, use of this field is deprecated. If a service wants to export multiple
1249
+ * bootstrap interfaces, it should instead define a single bootstrap interface that has methods
1250
+ * that return each of the other interfaces.
1251
+ *
1252
+ * **History**
1253
+ *
1254
+ * In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`.
1255
+ * At the time, it was thought that this would eventually serve as the way to restore SturdyRefs
1256
+ * (level 2). Meanwhile, an application could offer its "main" interface on a well-known
1257
+ * (non-secret) SturdyRef.
1258
+ *
1259
+ * Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only
1260
+ * used to obtain the main interface. Since most applications had only one main interface that
1261
+ * they wanted to restore, they tended to designate this with a null `objectId`.
1262
+ *
1263
+ * Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting
1264
+ * multiple main interfaces by allowing them to be exported under string names. In this case,
1265
+ * `objectId` was a Text value specifying the name.
1266
+ *
1267
+ * All of this proved problematic for several reasons:
1268
+ *
1269
+ * - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what
1270
+ * machine to connect to and would be able to immediately restore a SturdyRef on connection.
1271
+ * However, in practice, the ability to restore SturdyRefs is itself a capability that may
1272
+ * require going through an authentication process to obtain. Thus, it makes more sense to
1273
+ * define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is
1274
+ * offered as the vat's bootstrap interface, then this is equivalent to the old arrangement.
1275
+ *
1276
+ * - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the
1277
+ * practice of exporting singleton services with string names. If singleton services are desired,
1278
+ * it is better to have one main interface that has methods that can be used to obtain each
1279
+ * service, in order to get all the usual benefits of schemas and type checking.
1280
+ *
1281
+ * - Overloading "Restore" also had a security problem: Often, "main" or "well-known"
1282
+ * capabilities exported by a vat are in fact not public: they are intended to be accessed only
1283
+ * by clients who are capable of forming a connection to the vat. This can lead to trouble if
1284
+ * the client itself has other clients and wishes to forward some `Restore` requests from those
1285
+ * external clients -- it has to be very careful not to allow through `Restore` requests
1286
+ * addressing the default capability.
1287
+ *
1288
+ * For example, consider the case of a sandboxed Sandstorm application and its supervisor. The
1289
+ * application exports a default capability to its supervisor that provides access to
1290
+ * functionality that only the supervisor is supposed to access. Meanwhile, though, applications
1291
+ * may publish other capabilities that may be persistent, in which case the application needs
1292
+ * to field `Restore` requests that could come from anywhere. These requests of course have to
1293
+ * pass through the supervisor, as all communications with the outside world must. But, the
1294
+ * supervisor has to be careful not to honor an external request addressing the application's
1295
+ * default capability, since this capability is privileged. Unfortunately, the default
1296
+ * capability cannot be given an unguessable name, because then the supervisor itself would not
1297
+ * be able to address it!
1298
+ *
1299
+ * As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for
1300
+ * use in restoring SturdyRefs.
1301
+ *
1302
+ * Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a
1303
+ * SturdyRef, but indicated that the client would not restore the ref again in the future. This
1304
+ * operation was never implemented, so it was removed entirely. If a "delete" operation is desired,
1305
+ * it should exist as a method on the same interface that handles restoring SturdyRefs. However,
1306
+ * the utility of such an operation is questionable. You wouldn't be able to rely on it for
1307
+ * garbage collection since a client could always disappear permanently without remembering to
1308
+ * delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to
1309
+ * design systems such that SturdyRefs never represent "owned" pointers.
1310
+ *
1311
+ * For example, say a SturdyRef points to an image file hosted on some server. That image file
1312
+ * should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by
1313
+ * a user who can delete the image at any time. If the user deletes the image, the SturdyRef
1314
+ * stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the
1315
+ * existence of the image in its collection.
1316
+ *
1317
+ */
1318
+ get deprecatedObjectId() {
1319
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
1320
+ }
1321
+ _hasDeprecatedObjectId() {
1322
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1323
+ }
1324
+ set deprecatedObjectId(value) {
1325
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1326
+ }
1327
+ toString() {
1328
+ return "Bootstrap_" + super.toString();
1329
+ }
1330
+ }, _class6.__initStatic22(), _class6);
1331
+ var Call_SendResultsTo_Which = {
1332
+ /**
1333
+ * Send the return message back to the caller (the usual).
1334
+ *
1335
+ */
1336
+ CALLER: 0,
1337
+ /**
1338
+ * **(level 1)**
1339
+ *
1340
+ * Don't actually return the results to the sender. Instead, hold on to them and await
1341
+ * instructions from the sender regarding what to do with them. In particular, the sender
1342
+ * may subsequently send a `Return` for some other call (which the receiver had previously made
1343
+ * to the sender) with `takeFromOtherQuestion` set. The results from this call are then used
1344
+ * as the results of the other call.
1345
+ *
1346
+ * When `yourself` is used, the receiver must still send a `Return` for the call, but sets the
1347
+ * field `resultsSentElsewhere` in that `Return` rather than including the results.
1348
+ *
1349
+ * This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up
1350
+ * returning the result of a call from Vat B back to Vat A.
1351
+ *
1352
+ * In particular, the most common use case for this feature is when Vat A makes a call to a
1353
+ * promise in Vat B, and then that promise ends up resolving to a capability back in Vat A.
1354
+ * Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself`
1355
+ * in the calls so that the results need not pass back through Vat B.
1356
+ *
1357
+ * For example:
1358
+ * - Alice, in Vat A, calls foo() on Bob in Vat B.
1359
+ * - Alice makes a pipelined call bar() on the promise returned by foo().
1360
+ * - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next
1361
+ * to Alice).
1362
+ * - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'().
1363
+ * Notice that bar() and bar'() are travelling in opposite directions on the same network
1364
+ * link.
1365
+ * - The `Call` for bar'() has `sendResultsTo` set to `yourself`.
1366
+ * - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results,
1367
+ * with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return,
1368
+ * as doing so would introduce unnecessary round trip latency.
1369
+ * - Vat A receives bar'() and delivers it to Carol.
1370
+ * - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere`
1371
+ * set in place of results.
1372
+ * - Vat A sends a `Finish` for the bar() call to Vat B.
1373
+ * - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'().
1374
+ *
1375
+ */
1376
+ YOURSELF: 1,
1377
+ /**
1378
+ * **(level 3)**
1379
+ *
1380
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
1381
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
1382
+ * to it, rather than to the sender of the `Call`.
1383
+ *
1384
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
1385
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
1386
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
1387
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
1388
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
1389
+ *
1390
+ */
1391
+ THIRD_PARTY: 2
1392
+ };
1393
+ var Call_SendResultsTo = (_class7 = class extends _chunkIVTBYMMNcjs.Struct {
1394
+ static {
1395
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Call_SendResultsTo");
1396
+ }
1397
+ static __initStatic23() {this.CALLER = Call_SendResultsTo_Which.CALLER}
1398
+ static __initStatic24() {this.YOURSELF = Call_SendResultsTo_Which.YOURSELF}
1399
+ static __initStatic25() {this.THIRD_PARTY = Call_SendResultsTo_Which.THIRD_PARTY}
1400
+ static __initStatic26() {this._capnp = {
1401
+ displayName: "sendResultsTo",
1402
+ id: "dae8b0f61aab5f99",
1403
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(24, 3)
1404
+ }}
1405
+ get _isCaller() {
1406
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 0;
1407
+ }
1408
+ set caller(_) {
1409
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 0, this);
1410
+ }
1411
+ get _isYourself() {
1412
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 1;
1413
+ }
1414
+ set yourself(_) {
1415
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 1, this);
1416
+ }
1417
+ _adoptThirdParty(value) {
1418
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 2, this);
1419
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 2, this));
1420
+ }
1421
+ _disownThirdParty() {
1422
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.thirdParty);
1423
+ }
1424
+ /**
1425
+ * **(level 3)**
1426
+ *
1427
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
1428
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
1429
+ * to it, rather than to the sender of the `Call`.
1430
+ *
1431
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
1432
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
1433
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
1434
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
1435
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
1436
+ *
1437
+ */
1438
+ get thirdParty() {
1439
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "thirdParty", _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this), 2, this);
1440
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 2, this);
1441
+ }
1442
+ _hasThirdParty() {
1443
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 2, this));
1444
+ }
1445
+ get _isThirdParty() {
1446
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 2;
1447
+ }
1448
+ set thirdParty(value) {
1449
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 2, this);
1450
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 2, this));
1451
+ }
1452
+ toString() {
1453
+ return "Call_SendResultsTo_" + super.toString();
1454
+ }
1455
+ which() {
1456
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this);
1457
+ }
1458
+ }, _class7.__initStatic23(), _class7.__initStatic24(), _class7.__initStatic25(), _class7.__initStatic26(), _class7);
1459
+ var Call = (_class8 = class _Call extends _chunkIVTBYMMNcjs.Struct {
1460
+ static {
1461
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Call");
1462
+ }
1463
+ static __initStatic27() {this._capnp = {
1464
+ displayName: "Call",
1465
+ id: "836a53ce789d4cd4",
1466
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(24, 3),
1467
+ defaultAllowThirdPartyTailCall: _chunkIVTBYMMNcjs.getBitMask.call(void 0, false, 0),
1468
+ defaultNoPromisePipelining: _chunkIVTBYMMNcjs.getBitMask.call(void 0, false, 1),
1469
+ defaultOnlyPromisePipeline: _chunkIVTBYMMNcjs.getBitMask.call(void 0, false, 2)
1470
+ }}
1471
+ /**
1472
+ * A number, chosen by the caller, that identifies this call in future messages. This number
1473
+ * must be different from all other calls originating from the same end of the connection (but
1474
+ * may overlap with question IDs originating from the opposite end). A fine strategy is to use
1475
+ * sequential question IDs, but the recipient should not assume this.
1476
+ *
1477
+ * A question ID can be reused once both:
1478
+ * - A matching Return has been received from the callee.
1479
+ * - A matching Finish has been sent from the caller.
1480
+ *
1481
+ */
1482
+ get questionId() {
1483
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
1484
+ }
1485
+ set questionId(value) {
1486
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
1487
+ }
1488
+ _adoptTarget(value) {
1489
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1490
+ }
1491
+ _disownTarget() {
1492
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.target);
1493
+ }
1494
+ /**
1495
+ * The object that should receive this call.
1496
+ *
1497
+ */
1498
+ get target() {
1499
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, MessageTarget, this);
1500
+ }
1501
+ _hasTarget() {
1502
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1503
+ }
1504
+ _initTarget() {
1505
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, MessageTarget, this);
1506
+ }
1507
+ set target(value) {
1508
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1509
+ }
1510
+ /**
1511
+ * The type ID of the interface being called. Each capability may implement multiple interfaces.
1512
+ *
1513
+ */
1514
+ get interfaceId() {
1515
+ return _chunkIVTBYMMNcjs.getUint64.call(void 0, 8, this);
1516
+ }
1517
+ set interfaceId(value) {
1518
+ _chunkIVTBYMMNcjs.setUint64.call(void 0, 8, value, this);
1519
+ }
1520
+ /**
1521
+ * The ordinal number of the method to call within the requested interface.
1522
+ *
1523
+ */
1524
+ get methodId() {
1525
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this);
1526
+ }
1527
+ set methodId(value) {
1528
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, value, this);
1529
+ }
1530
+ /**
1531
+ * Indicates whether or not the receiver is allowed to send a `Return` containing
1532
+ * `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee
1533
+ * will have to proxy the return in the case of a tail call to a third-party vat.
1534
+ *
1535
+ */
1536
+ get allowThirdPartyTailCall() {
1537
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 128, this, _Call._capnp.defaultAllowThirdPartyTailCall);
1538
+ }
1539
+ set allowThirdPartyTailCall(value) {
1540
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 128, value, this, _Call._capnp.defaultAllowThirdPartyTailCall);
1541
+ }
1542
+ /**
1543
+ * If true, the sender promises that it won't make any promise-pipelined calls on the results of
1544
+ * this call. If it breaks this promise, the receiver may throw an arbitrary error from such
1545
+ * calls.
1546
+ *
1547
+ * The receiver may use this as an optimization, by skipping the bookkeeping needed for pipelining
1548
+ * when no pipelined calls are expected. The sender typically sets this to false when the method's
1549
+ * schema does not specify any return capabilities.
1550
+ *
1551
+ */
1552
+ get noPromisePipelining() {
1553
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 129, this, _Call._capnp.defaultNoPromisePipelining);
1554
+ }
1555
+ set noPromisePipelining(value) {
1556
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 129, value, this, _Call._capnp.defaultNoPromisePipelining);
1557
+ }
1558
+ /**
1559
+ * If true, the sender only plans to use this call to make pipelined calls. The receiver need not
1560
+ * send a `Return` message (but is still allowed to do so).
1561
+ *
1562
+ * Since the sender does not know whether a `Return` will be sent, it must release all state
1563
+ * related to the call when it sends `Finish`. However, in the case that the callee does not
1564
+ * recognize this hint and chooses to send a `Return`, then technically the caller is not allowed
1565
+ * to reuse the question ID until it receives said `Return`. This creates a conundrum: How does
1566
+ * the caller decide when it's OK to reuse the ID? To sidestep the problem, the C++ implementation
1567
+ * uses high-numbered IDs (with the high-order bit set) for such calls, and cycles through the
1568
+ * IDs in order. If all 2^31 IDs in this space are used without ever seeing a `Return`, then the
1569
+ * implementation assumes that the other end is in fact honoring the hint, and the ID counter is
1570
+ * allowed to loop around. If a `Return` is ever seen when `onlyPromisePipeline` was set, then
1571
+ * the implementation stops using this hint.
1572
+ *
1573
+ */
1574
+ get onlyPromisePipeline() {
1575
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 130, this, _Call._capnp.defaultOnlyPromisePipeline);
1576
+ }
1577
+ set onlyPromisePipeline(value) {
1578
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 130, value, this, _Call._capnp.defaultOnlyPromisePipeline);
1579
+ }
1580
+ _adoptParams(value) {
1581
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
1582
+ }
1583
+ _disownParams() {
1584
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.params);
1585
+ }
1586
+ /**
1587
+ * The call parameters. `params.content` is a struct whose fields correspond to the parameters of
1588
+ * the method.
1589
+ *
1590
+ */
1591
+ get params() {
1592
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 1, Payload, this);
1593
+ }
1594
+ _hasParams() {
1595
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
1596
+ }
1597
+ _initParams() {
1598
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 1, Payload, this);
1599
+ }
1600
+ set params(value) {
1601
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
1602
+ }
1603
+ /**
1604
+ * Where should the return message be sent?
1605
+ *
1606
+ */
1607
+ get sendResultsTo() {
1608
+ return _chunkIVTBYMMNcjs.getAs.call(void 0, Call_SendResultsTo, this);
1609
+ }
1610
+ _initSendResultsTo() {
1611
+ return _chunkIVTBYMMNcjs.getAs.call(void 0, Call_SendResultsTo, this);
1612
+ }
1613
+ toString() {
1614
+ return "Call_" + super.toString();
1615
+ }
1616
+ }, _class8.__initStatic27(), _class8);
1617
+ var Return_Which = {
1618
+ /**
1619
+ * Equal to the QuestionId of the corresponding `Call` message.
1620
+ *
1621
+ */
1622
+ RESULTS: 0,
1623
+ /**
1624
+ * If true, all capabilities that were in the params should be considered released. The sender
1625
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
1626
+ * should always set this true. This defaults true because if level 0 implementations forget to
1627
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
1628
+ * to set it to false they'll quickly get errors.
1629
+ *
1630
+ * The receiver should act as if the sender had sent a release message with count=1 for each
1631
+ * CapDescriptor in the original Call message.
1632
+ *
1633
+ */
1634
+ EXCEPTION: 1,
1635
+ /**
1636
+ * The result.
1637
+ *
1638
+ * For regular method calls, `results.content` points to the result struct.
1639
+ *
1640
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
1641
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
1642
+ * index 0. A `Finish` is still required in this case.
1643
+ *
1644
+ */
1645
+ CANCELED: 2,
1646
+ /**
1647
+ * Indicates that the call failed and explains why.
1648
+ *
1649
+ */
1650
+ RESULTS_SENT_ELSEWHERE: 3,
1651
+ /**
1652
+ * Indicates that the call was canceled due to the caller sending a Finish message
1653
+ * before the call had completed.
1654
+ *
1655
+ */
1656
+ TAKE_FROM_OTHER_QUESTION: 4,
1657
+ /**
1658
+ * This is set when returning from a `Call` that had `sendResultsTo` set to something other
1659
+ * than `caller`.
1660
+ *
1661
+ * It doesn't matter too much when this is sent, as the receiver doesn't need to do anything
1662
+ * with it, but the C++ implementation appears to wait for the call to finish before sending
1663
+ * this.
1664
+ *
1665
+ */
1666
+ ACCEPT_FROM_THIRD_PARTY: 5
1667
+ };
1668
+ var Return = (_class9 = class _Return extends _chunkIVTBYMMNcjs.Struct {
1669
+ static {
1670
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Return");
1671
+ }
1672
+ static __initStatic28() {this.RESULTS = Return_Which.RESULTS}
1673
+ static __initStatic29() {this.EXCEPTION = Return_Which.EXCEPTION}
1674
+ static __initStatic30() {this.CANCELED = Return_Which.CANCELED}
1675
+ static __initStatic31() {this.RESULTS_SENT_ELSEWHERE = Return_Which.RESULTS_SENT_ELSEWHERE}
1676
+ static __initStatic32() {this.TAKE_FROM_OTHER_QUESTION = Return_Which.TAKE_FROM_OTHER_QUESTION}
1677
+ static __initStatic33() {this.ACCEPT_FROM_THIRD_PARTY = Return_Which.ACCEPT_FROM_THIRD_PARTY}
1678
+ static __initStatic34() {this._capnp = {
1679
+ displayName: "Return",
1680
+ id: "9e19b28d3db3573a",
1681
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(16, 1),
1682
+ defaultReleaseParamCaps: _chunkIVTBYMMNcjs.getBitMask.call(void 0, true, 0),
1683
+ defaultNoFinishNeeded: _chunkIVTBYMMNcjs.getBitMask.call(void 0, false, 1)
1684
+ }}
1685
+ /**
1686
+ * Equal to the QuestionId of the corresponding `Call` message.
1687
+ *
1688
+ */
1689
+ get answerId() {
1690
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
1691
+ }
1692
+ set answerId(value) {
1693
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
1694
+ }
1695
+ /**
1696
+ * If true, all capabilities that were in the params should be considered released. The sender
1697
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
1698
+ * should always set this true. This defaults true because if level 0 implementations forget to
1699
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
1700
+ * to set it to false they'll quickly get errors.
1701
+ *
1702
+ * The receiver should act as if the sender had sent a release message with count=1 for each
1703
+ * CapDescriptor in the original Call message.
1704
+ *
1705
+ */
1706
+ get releaseParamCaps() {
1707
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 32, this, _Return._capnp.defaultReleaseParamCaps);
1708
+ }
1709
+ set releaseParamCaps(value) {
1710
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 32, value, this, _Return._capnp.defaultReleaseParamCaps);
1711
+ }
1712
+ /**
1713
+ * If true, the sender does not need the receiver to send a `Finish` message; its answer table
1714
+ * entry has already been cleaned up. This implies that the results do not contain any
1715
+ * capabilities, since the `Finish` message would normally release those capabilities from
1716
+ * promise pipelining responsibility. The caller may still send a `Finish` message if it wants,
1717
+ * which will be silently ignored by the callee.
1718
+ *
1719
+ */
1720
+ get noFinishNeeded() {
1721
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 33, this, _Return._capnp.defaultNoFinishNeeded);
1722
+ }
1723
+ set noFinishNeeded(value) {
1724
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 33, value, this, _Return._capnp.defaultNoFinishNeeded);
1725
+ }
1726
+ _adoptResults(value) {
1727
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 0, this);
1728
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1729
+ }
1730
+ _disownResults() {
1731
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.results);
1732
+ }
1733
+ /**
1734
+ * The result.
1735
+ *
1736
+ * For regular method calls, `results.content` points to the result struct.
1737
+ *
1738
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
1739
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
1740
+ * index 0. A `Finish` is still required in this case.
1741
+ *
1742
+ */
1743
+ get results() {
1744
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "results", _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this), 0, this);
1745
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Payload, this);
1746
+ }
1747
+ _hasResults() {
1748
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1749
+ }
1750
+ _initResults() {
1751
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 0, this);
1752
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Payload, this);
1753
+ }
1754
+ get _isResults() {
1755
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 0;
1756
+ }
1757
+ set results(value) {
1758
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 0, this);
1759
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1760
+ }
1761
+ _adoptException(value) {
1762
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 1, this);
1763
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1764
+ }
1765
+ _disownException() {
1766
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.exception);
1767
+ }
1768
+ /**
1769
+ * Indicates that the call failed and explains why.
1770
+ *
1771
+ */
1772
+ get exception() {
1773
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "exception", _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this), 1, this);
1774
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Exception, this);
1775
+ }
1776
+ _hasException() {
1777
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1778
+ }
1779
+ _initException() {
1780
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 1, this);
1781
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Exception, this);
1782
+ }
1783
+ get _isException() {
1784
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 1;
1785
+ }
1786
+ set exception(value) {
1787
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 1, this);
1788
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1789
+ }
1790
+ get _isCanceled() {
1791
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 2;
1792
+ }
1793
+ set canceled(_) {
1794
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 2, this);
1795
+ }
1796
+ get _isResultsSentElsewhere() {
1797
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 3;
1798
+ }
1799
+ set resultsSentElsewhere(_) {
1800
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 3, this);
1801
+ }
1802
+ /**
1803
+ * The sender has also sent (before this message) a `Call` with the given question ID and with
1804
+ * `sendResultsTo.yourself` set, and the results of that other call should be used as the
1805
+ * results here. `takeFromOtherQuestion` can only used once per question.
1806
+ *
1807
+ */
1808
+ get takeFromOtherQuestion() {
1809
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "takeFromOtherQuestion", _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this), 4, this);
1810
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 8, this);
1811
+ }
1812
+ get _isTakeFromOtherQuestion() {
1813
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 4;
1814
+ }
1815
+ set takeFromOtherQuestion(value) {
1816
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 4, this);
1817
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 8, value, this);
1818
+ }
1819
+ _adoptAcceptFromThirdParty(value) {
1820
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 5, this);
1821
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1822
+ }
1823
+ _disownAcceptFromThirdParty() {
1824
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.acceptFromThirdParty);
1825
+ }
1826
+ /**
1827
+ * **(level 3)**
1828
+ *
1829
+ * The caller should contact a third-party vat to pick up the results. An `Accept` message
1830
+ * sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`.
1831
+ * It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set.
1832
+ *
1833
+ */
1834
+ get acceptFromThirdParty() {
1835
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "acceptFromThirdParty", _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this), 5, this);
1836
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
1837
+ }
1838
+ _hasAcceptFromThirdParty() {
1839
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1840
+ }
1841
+ get _isAcceptFromThirdParty() {
1842
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this) === 5;
1843
+ }
1844
+ set acceptFromThirdParty(value) {
1845
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 6, 5, this);
1846
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1847
+ }
1848
+ toString() {
1849
+ return "Return_" + super.toString();
1850
+ }
1851
+ which() {
1852
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 6, this);
1853
+ }
1854
+ }, _class9.__initStatic28(), _class9.__initStatic29(), _class9.__initStatic30(), _class9.__initStatic31(), _class9.__initStatic32(), _class9.__initStatic33(), _class9.__initStatic34(), _class9);
1855
+ var Finish = (_class10 = class _Finish extends _chunkIVTBYMMNcjs.Struct {
1856
+ static {
1857
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Finish");
1858
+ }
1859
+ static __initStatic35() {this._capnp = {
1860
+ displayName: "Finish",
1861
+ id: "d37d2eb2c2f80e63",
1862
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 0),
1863
+ defaultReleaseResultCaps: _chunkIVTBYMMNcjs.getBitMask.call(void 0, true, 0),
1864
+ defaultRequireEarlyCancellationWorkaround: _chunkIVTBYMMNcjs.getBitMask.call(void 0, true, 1)
1865
+ }}
1866
+ /**
1867
+ * ID of the call whose result is to be released.
1868
+ *
1869
+ */
1870
+ get questionId() {
1871
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
1872
+ }
1873
+ set questionId(value) {
1874
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
1875
+ }
1876
+ /**
1877
+ * If true, all capabilities that were in the results should be considered released. The sender
1878
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
1879
+ * should always set this true. This defaults true because if level 0 implementations forget to
1880
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
1881
+ * set it false they'll quickly get errors.
1882
+ *
1883
+ */
1884
+ get releaseResultCaps() {
1885
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 32, this, _Finish._capnp.defaultReleaseResultCaps);
1886
+ }
1887
+ set releaseResultCaps(value) {
1888
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 32, value, this, _Finish._capnp.defaultReleaseResultCaps);
1889
+ }
1890
+ /**
1891
+ * If true, if the RPC system receives this Finish message before the original call has even been
1892
+ * delivered, it should defer cancellation util after delivery. In particular, this gives the
1893
+ * destination object a chance to opt out of cancellation, e.g. as controlled by the
1894
+ * `allowCancellation` annotation defined in `c++.capnp`.
1895
+ *
1896
+ * This is a work-around. Versions 1.0 and up of Cap'n Proto always set this to false. However,
1897
+ * older versions of Cap'n Proto unintentionally exhibited this errant behavior by default, and
1898
+ * as a result programs built with older versions could be inadvertently relying on their peers
1899
+ * to implement the behavior. The purpose of this flag is to let newer versions know when the
1900
+ * peer is an older version, so that it can attempt to work around the issue.
1901
+ *
1902
+ * See also comments in handleFinish() in rpc.c++ for more details.
1903
+ *
1904
+ */
1905
+ get requireEarlyCancellationWorkaround() {
1906
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 33, this, _Finish._capnp.defaultRequireEarlyCancellationWorkaround);
1907
+ }
1908
+ set requireEarlyCancellationWorkaround(value) {
1909
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 33, value, this, _Finish._capnp.defaultRequireEarlyCancellationWorkaround);
1910
+ }
1911
+ toString() {
1912
+ return "Finish_" + super.toString();
1913
+ }
1914
+ }, _class10.__initStatic35(), _class10);
1915
+ var Resolve_Which = {
1916
+ /**
1917
+ * The ID of the promise to be resolved.
1918
+ *
1919
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1920
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1921
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1922
+ * `ExportId` again until it has been released and recycled.
1923
+ *
1924
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1925
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1926
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1927
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1928
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1929
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1930
+ *
1931
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1932
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1933
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1934
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1935
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1936
+ * receiver should simply release the capability to which the promise resolved.
1937
+ *
1938
+ */
1939
+ CAP: 0,
1940
+ /**
1941
+ * The object to which the promise resolved.
1942
+ *
1943
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
1944
+ * simply forward all messages to the capability designated by `cap`. This is true even if
1945
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
1946
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
1947
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
1948
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
1949
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
1950
+ * if that object is itself a promise.
1951
+ *
1952
+ */
1953
+ EXCEPTION: 1
1954
+ };
1955
+ var Resolve = (_class11 = class extends _chunkIVTBYMMNcjs.Struct {
1956
+ static {
1957
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Resolve");
1958
+ }
1959
+ static __initStatic36() {this.CAP = Resolve_Which.CAP}
1960
+ static __initStatic37() {this.EXCEPTION = Resolve_Which.EXCEPTION}
1961
+ static __initStatic38() {this._capnp = {
1962
+ displayName: "Resolve",
1963
+ id: "bbc29655fa89086e",
1964
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
1965
+ }}
1966
+ /**
1967
+ * The ID of the promise to be resolved.
1968
+ *
1969
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1970
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1971
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1972
+ * `ExportId` again until it has been released and recycled.
1973
+ *
1974
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1975
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1976
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1977
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1978
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1979
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1980
+ *
1981
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1982
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1983
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1984
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1985
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1986
+ * receiver should simply release the capability to which the promise resolved.
1987
+ *
1988
+ */
1989
+ get promiseId() {
1990
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
1991
+ }
1992
+ set promiseId(value) {
1993
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
1994
+ }
1995
+ _adoptCap(value) {
1996
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 0, this);
1997
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
1998
+ }
1999
+ _disownCap() {
2000
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.cap);
2001
+ }
2002
+ /**
2003
+ * The object to which the promise resolved.
2004
+ *
2005
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
2006
+ * simply forward all messages to the capability designated by `cap`. This is true even if
2007
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
2008
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
2009
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
2010
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
2011
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
2012
+ * if that object is itself a promise.
2013
+ *
2014
+ */
2015
+ get cap() {
2016
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "cap", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 0, this);
2017
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, CapDescriptor, this);
2018
+ }
2019
+ _hasCap() {
2020
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2021
+ }
2022
+ _initCap() {
2023
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 0, this);
2024
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, CapDescriptor, this);
2025
+ }
2026
+ get _isCap() {
2027
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 0;
2028
+ }
2029
+ set cap(value) {
2030
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 0, this);
2031
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2032
+ }
2033
+ _adoptException(value) {
2034
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2035
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2036
+ }
2037
+ _disownException() {
2038
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.exception);
2039
+ }
2040
+ /**
2041
+ * Indicates that the promise was broken.
2042
+ *
2043
+ */
2044
+ get exception() {
2045
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "exception", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 1, this);
2046
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, Exception, this);
2047
+ }
2048
+ _hasException() {
2049
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2050
+ }
2051
+ _initException() {
2052
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2053
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, Exception, this);
2054
+ }
2055
+ get _isException() {
2056
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 1;
2057
+ }
2058
+ set exception(value) {
2059
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2060
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2061
+ }
2062
+ toString() {
2063
+ return "Resolve_" + super.toString();
2064
+ }
2065
+ which() {
2066
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this);
2067
+ }
2068
+ }, _class11.__initStatic36(), _class11.__initStatic37(), _class11.__initStatic38(), _class11);
2069
+ var Release = (_class12 = class extends _chunkIVTBYMMNcjs.Struct {
2070
+ static {
2071
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Release");
2072
+ }
2073
+ static __initStatic39() {this._capnp = {
2074
+ displayName: "Release",
2075
+ id: "ad1a6c0d7dd07497",
2076
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 0)
2077
+ }}
2078
+ /**
2079
+ * What to release.
2080
+ *
2081
+ */
2082
+ get id() {
2083
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2084
+ }
2085
+ set id(value) {
2086
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2087
+ }
2088
+ /**
2089
+ * The amount by which to decrement the reference count. The export is only actually released
2090
+ * when the reference count reaches zero.
2091
+ *
2092
+ */
2093
+ get referenceCount() {
2094
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 4, this);
2095
+ }
2096
+ set referenceCount(value) {
2097
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 4, value, this);
2098
+ }
2099
+ toString() {
2100
+ return "Release_" + super.toString();
2101
+ }
2102
+ }, _class12.__initStatic39(), _class12);
2103
+ var Disembargo_Context_Which = {
2104
+ /**
2105
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
2106
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
2107
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
2108
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
2109
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
2110
+ * the value is unambiguous.
2111
+ *
2112
+ * The receiver must verify that the target capability actually resolves back to the sender's
2113
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
2114
+ *
2115
+ */
2116
+ SENDER_LOOPBACK: 0,
2117
+ /**
2118
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
2119
+ * this capability, and that Disembargo is now being echoed back.
2120
+ *
2121
+ */
2122
+ RECEIVER_LOOPBACK: 1,
2123
+ /**
2124
+ * **(level 3)**
2125
+ *
2126
+ * The sender is requesting a disembargo on a promise that is known to resolve to a third-party
2127
+ * capability that the sender is currently in the process of accepting (using `Accept`).
2128
+ * The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The
2129
+ * receiver should now send a `Disembargo` with `provide` set to the question ID of that
2130
+ * `Provide` message.
2131
+ *
2132
+ * See `Accept.embargo` for an example.
2133
+ *
2134
+ */
2135
+ ACCEPT: 2,
2136
+ /**
2137
+ * **(level 3)**
2138
+ *
2139
+ * The sender is requesting a disembargo on a capability currently being provided to a third
2140
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
2141
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
2142
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
2143
+ * an example.
2144
+ *
2145
+ */
2146
+ PROVIDE: 3
2147
+ };
2148
+ var Disembargo_Context = (_class13 = class extends _chunkIVTBYMMNcjs.Struct {
2149
+ static {
2150
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Disembargo_Context");
2151
+ }
2152
+ static __initStatic40() {this.SENDER_LOOPBACK = Disembargo_Context_Which.SENDER_LOOPBACK}
2153
+ static __initStatic41() {this.RECEIVER_LOOPBACK = Disembargo_Context_Which.RECEIVER_LOOPBACK}
2154
+ static __initStatic42() {this.ACCEPT = Disembargo_Context_Which.ACCEPT}
2155
+ static __initStatic43() {this.PROVIDE = Disembargo_Context_Which.PROVIDE}
2156
+ static __initStatic44() {this._capnp = {
2157
+ displayName: "context",
2158
+ id: "d562b4df655bdd4d",
2159
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
2160
+ }}
2161
+ /**
2162
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
2163
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
2164
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
2165
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
2166
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
2167
+ * the value is unambiguous.
2168
+ *
2169
+ * The receiver must verify that the target capability actually resolves back to the sender's
2170
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
2171
+ *
2172
+ */
2173
+ get senderLoopback() {
2174
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "senderLoopback", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 0, this);
2175
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2176
+ }
2177
+ get _isSenderLoopback() {
2178
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 0;
2179
+ }
2180
+ set senderLoopback(value) {
2181
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 0, this);
2182
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2183
+ }
2184
+ /**
2185
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
2186
+ * this capability, and that Disembargo is now being echoed back.
2187
+ *
2188
+ */
2189
+ get receiverLoopback() {
2190
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "receiverLoopback", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 1, this);
2191
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2192
+ }
2193
+ get _isReceiverLoopback() {
2194
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 1;
2195
+ }
2196
+ set receiverLoopback(value) {
2197
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2198
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2199
+ }
2200
+ get _isAccept() {
2201
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 2;
2202
+ }
2203
+ set accept(_) {
2204
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 2, this);
2205
+ }
2206
+ /**
2207
+ * **(level 3)**
2208
+ *
2209
+ * The sender is requesting a disembargo on a capability currently being provided to a third
2210
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
2211
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
2212
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
2213
+ * an example.
2214
+ *
2215
+ */
2216
+ get provide() {
2217
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "provide", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 3, this);
2218
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2219
+ }
2220
+ get _isProvide() {
2221
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 3;
2222
+ }
2223
+ set provide(value) {
2224
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 3, this);
2225
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2226
+ }
2227
+ toString() {
2228
+ return "Disembargo_Context_" + super.toString();
2229
+ }
2230
+ which() {
2231
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this);
2232
+ }
2233
+ }, _class13.__initStatic40(), _class13.__initStatic41(), _class13.__initStatic42(), _class13.__initStatic43(), _class13.__initStatic44(), _class13);
2234
+ var Disembargo = (_class14 = class extends _chunkIVTBYMMNcjs.Struct {
2235
+ static {
2236
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Disembargo");
2237
+ }
2238
+ static __initStatic45() {this._capnp = {
2239
+ displayName: "Disembargo",
2240
+ id: "f964368b0fbd3711",
2241
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
2242
+ }}
2243
+ _adoptTarget(value) {
2244
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2245
+ }
2246
+ _disownTarget() {
2247
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.target);
2248
+ }
2249
+ /**
2250
+ * What is to be disembargoed.
2251
+ *
2252
+ */
2253
+ get target() {
2254
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, MessageTarget, this);
2255
+ }
2256
+ _hasTarget() {
2257
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2258
+ }
2259
+ _initTarget() {
2260
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, MessageTarget, this);
2261
+ }
2262
+ set target(value) {
2263
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2264
+ }
2265
+ get context() {
2266
+ return _chunkIVTBYMMNcjs.getAs.call(void 0, Disembargo_Context, this);
2267
+ }
2268
+ _initContext() {
2269
+ return _chunkIVTBYMMNcjs.getAs.call(void 0, Disembargo_Context, this);
2270
+ }
2271
+ toString() {
2272
+ return "Disembargo_" + super.toString();
2273
+ }
2274
+ }, _class14.__initStatic45(), _class14);
2275
+ var Provide = (_class15 = class extends _chunkIVTBYMMNcjs.Struct {
2276
+ static {
2277
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Provide");
2278
+ }
2279
+ static __initStatic46() {this._capnp = {
2280
+ displayName: "Provide",
2281
+ id: "9c6a046bfbc1ac5a",
2282
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 2)
2283
+ }}
2284
+ /**
2285
+ * Question ID to be held open until the recipient has received the capability. A result will be
2286
+ * returned once the third party has successfully received the capability. The sender must at some
2287
+ * point send a `Finish` message as with any other call, and that message can be used to cancel the
2288
+ * whole operation.
2289
+ *
2290
+ */
2291
+ get questionId() {
2292
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2293
+ }
2294
+ set questionId(value) {
2295
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2296
+ }
2297
+ _adoptTarget(value) {
2298
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2299
+ }
2300
+ _disownTarget() {
2301
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.target);
2302
+ }
2303
+ /**
2304
+ * What is to be provided to the third party.
2305
+ *
2306
+ */
2307
+ get target() {
2308
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, MessageTarget, this);
2309
+ }
2310
+ _hasTarget() {
2311
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2312
+ }
2313
+ _initTarget() {
2314
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, MessageTarget, this);
2315
+ }
2316
+ set target(value) {
2317
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2318
+ }
2319
+ _adoptRecipient(value) {
2320
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2321
+ }
2322
+ _disownRecipient() {
2323
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.recipient);
2324
+ }
2325
+ /**
2326
+ * Identity of the third party that is expected to pick up the capability.
2327
+ *
2328
+ */
2329
+ get recipient() {
2330
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this);
2331
+ }
2332
+ _hasRecipient() {
2333
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2334
+ }
2335
+ set recipient(value) {
2336
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2337
+ }
2338
+ toString() {
2339
+ return "Provide_" + super.toString();
2340
+ }
2341
+ }, _class15.__initStatic46(), _class15);
2342
+ var Accept = (_class16 = class extends _chunkIVTBYMMNcjs.Struct {
2343
+ static {
2344
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Accept");
2345
+ }
2346
+ static __initStatic47() {this._capnp = {
2347
+ displayName: "Accept",
2348
+ id: "d4c9b56290554016",
2349
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
2350
+ }}
2351
+ /**
2352
+ * A new question ID identifying this accept message, which will eventually receive a Return
2353
+ * message containing the provided capability (or the call result in the case of a redirected
2354
+ * return).
2355
+ *
2356
+ */
2357
+ get questionId() {
2358
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2359
+ }
2360
+ set questionId(value) {
2361
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2362
+ }
2363
+ _adoptProvision(value) {
2364
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2365
+ }
2366
+ _disownProvision() {
2367
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.provision);
2368
+ }
2369
+ /**
2370
+ * Identifies the provided object to be picked up.
2371
+ *
2372
+ */
2373
+ get provision() {
2374
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
2375
+ }
2376
+ _hasProvision() {
2377
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2378
+ }
2379
+ set provision(value) {
2380
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2381
+ }
2382
+ /**
2383
+ * If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent,
2384
+ * and any pipelined calls will not be delivered, until the embargo is released. The receiver
2385
+ * (the capability host) will expect the provider (the vat that sent the `Provide` message) to
2386
+ * eventually send a `Disembargo` message with the field `context.provide` set to the question ID
2387
+ * of the original `Provide` message. At that point, the embargo is released and the queued
2388
+ * messages are delivered.
2389
+ *
2390
+ * For example:
2391
+ * - Alice, in Vat A, holds a promise P, which currently points toward Vat B.
2392
+ * - Alice calls foo() on P. The `Call` message is sent to Vat B.
2393
+ * - The promise P in Vat B ends up resolving to Carol, in Vat C.
2394
+ * - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient.
2395
+ * - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a
2396
+ * `ThirdPartyCapId` identifying Carol in Vat C.
2397
+ * - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that
2398
+ * it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept`
2399
+ * message.
2400
+ * - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set.
2401
+ * - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't
2402
+ * know anything about the mechanics of promise resolution happening under the hood, but she
2403
+ * expects that bar() will be delivered after foo() because that is the order in which she
2404
+ * initiated the calls.
2405
+ * - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which
2406
+ * hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability
2407
+ * are embargoed, Vat C does not deliver the call yet.
2408
+ * - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C.
2409
+ * - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the
2410
+ * question ID of the `Provide` message it had sent previously.
2411
+ * - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo()
2412
+ * before delivering bar().
2413
+ * - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from
2414
+ * Vat A, as well as deliver bar().
2415
+ *
2416
+ */
2417
+ get embargo() {
2418
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 32, this);
2419
+ }
2420
+ set embargo(value) {
2421
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 32, value, this);
2422
+ }
2423
+ toString() {
2424
+ return "Accept_" + super.toString();
2425
+ }
2426
+ }, _class16.__initStatic47(), _class16);
2427
+ var Join = (_class17 = class extends _chunkIVTBYMMNcjs.Struct {
2428
+ static {
2429
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Join");
2430
+ }
2431
+ static __initStatic48() {this._capnp = {
2432
+ displayName: "Join",
2433
+ id: "fbe1980490e001af",
2434
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 2)
2435
+ }}
2436
+ /**
2437
+ * Question ID used to respond to this Join. (Note that this ID only identifies one part of the
2438
+ * request for one hop; each part has a different ID and relayed copies of the request have
2439
+ * (probably) different IDs still.)
2440
+ *
2441
+ * The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult`
2442
+ * is relayed from the joined object's host, possibly with transformation applied as needed
2443
+ * by the network.
2444
+ *
2445
+ * Like any return, the result must be released using a `Finish`. However, this release
2446
+ * should not occur until the joiner has either successfully connected to the joined object.
2447
+ * Vats relaying a `Join` message similarly must not release the result they receive until the
2448
+ * return they relayed back towards the joiner has itself been released. This allows the
2449
+ * joined object's host to detect when the Join operation is canceled before completing -- if
2450
+ * it receives a `Finish` for one of the join results before the joiner successfully
2451
+ * connects. It can then free any resources it had allocated as part of the join.
2452
+ *
2453
+ */
2454
+ get questionId() {
2455
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2456
+ }
2457
+ set questionId(value) {
2458
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2459
+ }
2460
+ _adoptTarget(value) {
2461
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2462
+ }
2463
+ _disownTarget() {
2464
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.target);
2465
+ }
2466
+ /**
2467
+ * The capability to join.
2468
+ *
2469
+ */
2470
+ get target() {
2471
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, MessageTarget, this);
2472
+ }
2473
+ _hasTarget() {
2474
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2475
+ }
2476
+ _initTarget() {
2477
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, MessageTarget, this);
2478
+ }
2479
+ set target(value) {
2480
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2481
+ }
2482
+ _adoptKeyPart(value) {
2483
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2484
+ }
2485
+ _disownKeyPart() {
2486
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.keyPart);
2487
+ }
2488
+ /**
2489
+ * A part of the join key. These combine to form the complete join key, which is used to establish
2490
+ * a direct connection.
2491
+ *
2492
+ */
2493
+ get keyPart() {
2494
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this);
2495
+ }
2496
+ _hasKeyPart() {
2497
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2498
+ }
2499
+ set keyPart(value) {
2500
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2501
+ }
2502
+ toString() {
2503
+ return "Join_" + super.toString();
2504
+ }
2505
+ }, _class17.__initStatic48(), _class17);
2506
+ var MessageTarget_Which = {
2507
+ /**
2508
+ * This message is to a capability or promise previously imported by the caller (exported by
2509
+ * the receiver).
2510
+ *
2511
+ */
2512
+ IMPORTED_CAP: 0,
2513
+ /**
2514
+ * This message is to a capability that is expected to be returned by another call that has not
2515
+ * yet been completed.
2516
+ *
2517
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
2518
+ * that initial startup doesn't require a round trip.
2519
+ *
2520
+ */
2521
+ PROMISED_ANSWER: 1
2522
+ };
2523
+ var MessageTarget = (_class18 = class extends _chunkIVTBYMMNcjs.Struct {
2524
+ static {
2525
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "MessageTarget");
2526
+ }
2527
+ static __initStatic49() {this.IMPORTED_CAP = MessageTarget_Which.IMPORTED_CAP}
2528
+ static __initStatic50() {this.PROMISED_ANSWER = MessageTarget_Which.PROMISED_ANSWER}
2529
+ static __initStatic51() {this._capnp = {
2530
+ displayName: "MessageTarget",
2531
+ id: "95bc14545813fbc1",
2532
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
2533
+ }}
2534
+ /**
2535
+ * This message is to a capability or promise previously imported by the caller (exported by
2536
+ * the receiver).
2537
+ *
2538
+ */
2539
+ get importedCap() {
2540
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "importedCap", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 0, this);
2541
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2542
+ }
2543
+ get _isImportedCap() {
2544
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 0;
2545
+ }
2546
+ set importedCap(value) {
2547
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 0, this);
2548
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2549
+ }
2550
+ _adoptPromisedAnswer(value) {
2551
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2552
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2553
+ }
2554
+ _disownPromisedAnswer() {
2555
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.promisedAnswer);
2556
+ }
2557
+ /**
2558
+ * This message is to a capability that is expected to be returned by another call that has not
2559
+ * yet been completed.
2560
+ *
2561
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
2562
+ * that initial startup doesn't require a round trip.
2563
+ *
2564
+ */
2565
+ get promisedAnswer() {
2566
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "promisedAnswer", _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this), 1, this);
2567
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, PromisedAnswer, this);
2568
+ }
2569
+ _hasPromisedAnswer() {
2570
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2571
+ }
2572
+ _initPromisedAnswer() {
2573
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2574
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, PromisedAnswer, this);
2575
+ }
2576
+ get _isPromisedAnswer() {
2577
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this) === 1;
2578
+ }
2579
+ set promisedAnswer(value) {
2580
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, 1, this);
2581
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2582
+ }
2583
+ toString() {
2584
+ return "MessageTarget_" + super.toString();
2585
+ }
2586
+ which() {
2587
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this);
2588
+ }
2589
+ }, _class18.__initStatic49(), _class18.__initStatic50(), _class18.__initStatic51(), _class18);
2590
+ var Payload = (_class19 = class _Payload extends _chunkIVTBYMMNcjs.Struct {
2591
+ static {
2592
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Payload");
2593
+ }
2594
+ static __initStatic52() {this._capnp = {
2595
+ displayName: "Payload",
2596
+ id: "9a0e61223d96743b",
2597
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(0, 2)
2598
+ }}
2599
+
2600
+ _adoptContent(value) {
2601
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2602
+ }
2603
+ _disownContent() {
2604
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.content);
2605
+ }
2606
+ /**
2607
+ * Some Cap'n Proto data structure. Capability pointers embedded in this structure index into
2608
+ * `capTable`.
2609
+ *
2610
+ */
2611
+ get content() {
2612
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
2613
+ }
2614
+ _hasContent() {
2615
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2616
+ }
2617
+ set content(value) {
2618
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2619
+ }
2620
+ _adoptCapTable(value) {
2621
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2622
+ }
2623
+ _disownCapTable() {
2624
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.capTable);
2625
+ }
2626
+ /**
2627
+ * Descriptors corresponding to the cap pointers in `content`.
2628
+ *
2629
+ */
2630
+ get capTable() {
2631
+ return _chunkIVTBYMMNcjs.getList.call(void 0, 1, _Payload._CapTable, this);
2632
+ }
2633
+ _hasCapTable() {
2634
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2635
+ }
2636
+ _initCapTable(length) {
2637
+ return _chunkIVTBYMMNcjs.initList.call(void 0, 1, _Payload._CapTable, length, this);
2638
+ }
2639
+ set capTable(value) {
2640
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 1, this));
2641
+ }
2642
+ toString() {
2643
+ return "Payload_" + super.toString();
2644
+ }
2645
+ }, _class19.__initStatic52(), _class19);
2646
+ var CapDescriptor_Which = {
2647
+ /**
2648
+ * There is no capability here. This `CapDescriptor` should not appear in the payload content.
2649
+ * A `none` CapDescriptor can be generated when an application inserts a capability into a
2650
+ * message and then later changes its mind and removes it -- rewriting all of the other
2651
+ * capability pointers may be hard, so instead a tombstone is left, similar to the way a removed
2652
+ * struct or list instance is zeroed out of the message but the space is not reclaimed.
2653
+ * Hopefully this is unusual.
2654
+ *
2655
+ */
2656
+ NONE: 0,
2657
+ /**
2658
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
2659
+ * newly allocated table entry, or an existing entry (increments the reference count).
2660
+ *
2661
+ */
2662
+ SENDER_HOSTED: 1,
2663
+ /**
2664
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
2665
+ * message at a future point in time to replace this promise. Note that even if the same
2666
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
2667
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
2668
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
2669
+ *
2670
+ */
2671
+ SENDER_PROMISE: 2,
2672
+ /**
2673
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
2674
+ *
2675
+ */
2676
+ RECEIVER_HOSTED: 3,
2677
+ /**
2678
+ * A capability expected to be returned in the results of a currently-outstanding call posed
2679
+ * by the sender.
2680
+ *
2681
+ */
2682
+ RECEIVER_ANSWER: 4,
2683
+ /**
2684
+ * **(level 3)**
2685
+ *
2686
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
2687
+ * to form a direct connection to a third party to pick up the capability.
2688
+ *
2689
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
2690
+ * `vine` instead.
2691
+ *
2692
+ */
2693
+ THIRD_PARTY_HOSTED: 5
2694
+ };
2695
+ var CapDescriptor = (_class20 = class _CapDescriptor extends _chunkIVTBYMMNcjs.Struct {
2696
+ static {
2697
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "CapDescriptor");
2698
+ }
2699
+ static __initStatic53() {this.NONE = CapDescriptor_Which.NONE}
2700
+ static __initStatic54() {this.SENDER_HOSTED = CapDescriptor_Which.SENDER_HOSTED}
2701
+ static __initStatic55() {this.SENDER_PROMISE = CapDescriptor_Which.SENDER_PROMISE}
2702
+ static __initStatic56() {this.RECEIVER_HOSTED = CapDescriptor_Which.RECEIVER_HOSTED}
2703
+ static __initStatic57() {this.RECEIVER_ANSWER = CapDescriptor_Which.RECEIVER_ANSWER}
2704
+ static __initStatic58() {this.THIRD_PARTY_HOSTED = CapDescriptor_Which.THIRD_PARTY_HOSTED}
2705
+ static __initStatic59() {this._capnp = {
2706
+ displayName: "CapDescriptor",
2707
+ id: "8523ddc40b86b8b0",
2708
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1),
2709
+ defaultAttachedFd: _chunkIVTBYMMNcjs.getUint8Mask.call(void 0, 255)
2710
+ }}
2711
+ get _isNone() {
2712
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 0;
2713
+ }
2714
+ set none(_) {
2715
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 0, this);
2716
+ }
2717
+ /**
2718
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
2719
+ * newly allocated table entry, or an existing entry (increments the reference count).
2720
+ *
2721
+ */
2722
+ get senderHosted() {
2723
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "senderHosted", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 1, this);
2724
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 4, this);
2725
+ }
2726
+ get _isSenderHosted() {
2727
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 1;
2728
+ }
2729
+ set senderHosted(value) {
2730
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 1, this);
2731
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 4, value, this);
2732
+ }
2733
+ /**
2734
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
2735
+ * message at a future point in time to replace this promise. Note that even if the same
2736
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
2737
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
2738
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
2739
+ *
2740
+ */
2741
+ get senderPromise() {
2742
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "senderPromise", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 2, this);
2743
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 4, this);
2744
+ }
2745
+ get _isSenderPromise() {
2746
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 2;
2747
+ }
2748
+ set senderPromise(value) {
2749
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 2, this);
2750
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 4, value, this);
2751
+ }
2752
+ /**
2753
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
2754
+ *
2755
+ */
2756
+ get receiverHosted() {
2757
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "receiverHosted", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 3, this);
2758
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 4, this);
2759
+ }
2760
+ get _isReceiverHosted() {
2761
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 3;
2762
+ }
2763
+ set receiverHosted(value) {
2764
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 3, this);
2765
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 4, value, this);
2766
+ }
2767
+ _adoptReceiverAnswer(value) {
2768
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 4, this);
2769
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2770
+ }
2771
+ _disownReceiverAnswer() {
2772
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.receiverAnswer);
2773
+ }
2774
+ /**
2775
+ * A capability expected to be returned in the results of a currently-outstanding call posed
2776
+ * by the sender.
2777
+ *
2778
+ */
2779
+ get receiverAnswer() {
2780
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "receiverAnswer", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 4, this);
2781
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, PromisedAnswer, this);
2782
+ }
2783
+ _hasReceiverAnswer() {
2784
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2785
+ }
2786
+ _initReceiverAnswer() {
2787
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 4, this);
2788
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, PromisedAnswer, this);
2789
+ }
2790
+ get _isReceiverAnswer() {
2791
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 4;
2792
+ }
2793
+ set receiverAnswer(value) {
2794
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 4, this);
2795
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2796
+ }
2797
+ _adoptThirdPartyHosted(value) {
2798
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 5, this);
2799
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2800
+ }
2801
+ _disownThirdPartyHosted() {
2802
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.thirdPartyHosted);
2803
+ }
2804
+ /**
2805
+ * **(level 3)**
2806
+ *
2807
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
2808
+ * to form a direct connection to a third party to pick up the capability.
2809
+ *
2810
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
2811
+ * `vine` instead.
2812
+ *
2813
+ */
2814
+ get thirdPartyHosted() {
2815
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "thirdPartyHosted", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 5, this);
2816
+ return _chunkIVTBYMMNcjs.getStruct.call(void 0, 0, ThirdPartyCapDescriptor, this);
2817
+ }
2818
+ _hasThirdPartyHosted() {
2819
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2820
+ }
2821
+ _initThirdPartyHosted() {
2822
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 5, this);
2823
+ return _chunkIVTBYMMNcjs.initStructAt.call(void 0, 0, ThirdPartyCapDescriptor, this);
2824
+ }
2825
+ get _isThirdPartyHosted() {
2826
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 5;
2827
+ }
2828
+ set thirdPartyHosted(value) {
2829
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 5, this);
2830
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2831
+ }
2832
+ /**
2833
+ * If the RPC message in which this CapDescriptor was delivered also had file descriptors
2834
+ * attached, and `fd` is a valid index into the list of attached file descriptors, then
2835
+ * that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds
2836
+ * for said list, then no FD is attached.
2837
+ *
2838
+ * For example, if the RPC message arrived over a Unix socket, then file descriptors may be
2839
+ * attached by sending an SCM_RIGHTS ancillary message attached to the data bytes making up the
2840
+ * raw message. Receivers who wish to opt into FD passing should arrange to receive SCM_RIGHTS
2841
+ * whenever receiving an RPC message. Senders who wish to send FDs need not verify whether the
2842
+ * receiver knows how to receive them, because the operating system will automatically discard
2843
+ * ancillary messages like SCM_RIGHTS if the receiver doesn't ask to receive them, including
2844
+ * automatically closing any FDs.
2845
+ *
2846
+ * It is up to the application protocol to define what capabilities are expected to have file
2847
+ * descriptors attached, and what those FDs mean. But, for example, an application could use this
2848
+ * to open a file on disk and then transmit the open file descriptor to a sandboxed process that
2849
+ * does not otherwise have permission to access the filesystem directly. This is usually an
2850
+ * optimization: the sending process could instead provide an RPC interface supporting all the
2851
+ * operations needed (such as reading and writing a file), but by passing the file descriptor
2852
+ * directly, the recipient can often perform operations much more efficiently. Application
2853
+ * designers are encouraged to provide such RPC interfaces and automatically fall back to them
2854
+ * when FD passing is not available, so that the application can still work when the parties are
2855
+ * remote over a network.
2856
+ *
2857
+ * An attached FD is most often associated with a `senderHosted` descriptor. It could also make
2858
+ * sense in the case of `thirdPartyHosted`: in this case, the sender is forwarding the FD that
2859
+ * they received from the third party, so that the receiver can start using it without first
2860
+ * interacting with the third party. This is an optional optimization -- the middleman may choose
2861
+ * not to forward capabilities, in which case the receiver will need to complete the handshake
2862
+ * with the third party directly before receiving the FD. If an implementation receives a second
2863
+ * attached FD after having already received one previously (e.g. both in a `thirdPartyHosted`
2864
+ * CapDescriptor and then later again when receiving the final capability directly from the
2865
+ * third party), the implementation should discard the later FD and stick with the original. At
2866
+ * present, there is no known reason why other capability types (e.g. `receiverHosted`) would want
2867
+ * to carry an attached FD, but we reserve the right to define a meaning for this in the future.
2868
+ *
2869
+ * Each file descriptor attached to the message must be used in no more than one CapDescriptor,
2870
+ * so that the receiver does not need to use dup() or refcounting to handle the possibility of
2871
+ * multiple capabilities using the same descriptor. If multiple CapDescriptors do point to the
2872
+ * same FD index, then the receiver can arbitrarily choose which capability ends up having the
2873
+ * FD attached.
2874
+ *
2875
+ * To mitigate DoS attacks, RPC implementations should limit the number of FDs they are willing to
2876
+ * receive in a single message to a small value. If a message happens to contain more than that,
2877
+ * the list is truncated. Moreover, in some cases, FD passing needs to be blocked entirely for
2878
+ * security or implementation reasons, in which case the list may be truncated to zero. Hence,
2879
+ * `attachedFd` might point past the end of the list, which the implementation should treat as if
2880
+ * no FD was attached at all.
2881
+ *
2882
+ * The type of this field was chosen to be UInt8 because Linux supports sending only a maximum
2883
+ * of 253 file descriptors in an SCM_RIGHTS message anyway, and CapDescriptor had two bytes of
2884
+ * padding left -- so after adding this, there is still one byte for a future feature.
2885
+ * Conveniently, this also means we're able to use 0xff as the default value, which will always
2886
+ * be out-of-range (of course, the implementation should explicitly enforce that 255 descriptors
2887
+ * cannot be sent at once, rather than relying on Linux to do so).
2888
+ *
2889
+ */
2890
+ get attachedFd() {
2891
+ return _chunkIVTBYMMNcjs.getUint8.call(void 0, 2, this, _CapDescriptor._capnp.defaultAttachedFd);
2892
+ }
2893
+ set attachedFd(value) {
2894
+ _chunkIVTBYMMNcjs.setUint8.call(void 0, 2, value, this, _CapDescriptor._capnp.defaultAttachedFd);
2895
+ }
2896
+ toString() {
2897
+ return "CapDescriptor_" + super.toString();
2898
+ }
2899
+ which() {
2900
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this);
2901
+ }
2902
+ }, _class20.__initStatic53(), _class20.__initStatic54(), _class20.__initStatic55(), _class20.__initStatic56(), _class20.__initStatic57(), _class20.__initStatic58(), _class20.__initStatic59(), _class20);
2903
+ var PromisedAnswer_Op_Which = {
2904
+ /**
2905
+ * Does nothing. This member is mostly defined so that we can make `Op` a union even
2906
+ * though (as of this writing) only one real operation is defined.
2907
+ *
2908
+ */
2909
+ NOOP: 0,
2910
+ /**
2911
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
2912
+ * a field ordinal, so that the receiver does not need to understand the schema.
2913
+ *
2914
+ */
2915
+ GET_POINTER_FIELD: 1
2916
+ };
2917
+ var PromisedAnswer_Op = (_class21 = class extends _chunkIVTBYMMNcjs.Struct {
2918
+ static {
2919
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "PromisedAnswer_Op");
2920
+ }
2921
+ static __initStatic60() {this.NOOP = PromisedAnswer_Op_Which.NOOP}
2922
+ static __initStatic61() {this.GET_POINTER_FIELD = PromisedAnswer_Op_Which.GET_POINTER_FIELD}
2923
+ static __initStatic62() {this._capnp = {
2924
+ displayName: "Op",
2925
+ id: "f316944415569081",
2926
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 0)
2927
+ }}
2928
+ get _isNoop() {
2929
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 0;
2930
+ }
2931
+ set noop(_) {
2932
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 0, this);
2933
+ }
2934
+ /**
2935
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
2936
+ * a field ordinal, so that the receiver does not need to understand the schema.
2937
+ *
2938
+ */
2939
+ get getPointerField() {
2940
+ _chunkIVTBYMMNcjs.testWhich.call(void 0, "getPointerField", _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this), 1, this);
2941
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 2, this);
2942
+ }
2943
+ get _isGetPointerField() {
2944
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this) === 1;
2945
+ }
2946
+ set getPointerField(value) {
2947
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 0, 1, this);
2948
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 2, value, this);
2949
+ }
2950
+ toString() {
2951
+ return "PromisedAnswer_Op_" + super.toString();
2952
+ }
2953
+ which() {
2954
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 0, this);
2955
+ }
2956
+ }, _class21.__initStatic60(), _class21.__initStatic61(), _class21.__initStatic62(), _class21);
2957
+ var PromisedAnswer = (_class22 = class _PromisedAnswer extends _chunkIVTBYMMNcjs.Struct {
2958
+ static {
2959
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "PromisedAnswer");
2960
+ }
2961
+ static __initStatic63() {this.Op = PromisedAnswer_Op}
2962
+ static __initStatic64() {this._capnp = {
2963
+ displayName: "PromisedAnswer",
2964
+ id: "d800b1d6cd6f1ca0",
2965
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
2966
+ }}
2967
+
2968
+ /**
2969
+ * ID of the question (in the sender's question table / receiver's answer table) whose answer is
2970
+ * expected to contain the capability.
2971
+ *
2972
+ */
2973
+ get questionId() {
2974
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
2975
+ }
2976
+ set questionId(value) {
2977
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
2978
+ }
2979
+ _adoptTransform(value) {
2980
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2981
+ }
2982
+ _disownTransform() {
2983
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.transform);
2984
+ }
2985
+ /**
2986
+ * Operations / transformations to apply to the result in order to get the capability actually
2987
+ * being addressed. E.g. if the result is a struct and you want to call a method on a capability
2988
+ * pointed to by a field of the struct, you need a `getPointerField` op.
2989
+ *
2990
+ */
2991
+ get transform() {
2992
+ return _chunkIVTBYMMNcjs.getList.call(void 0, 0, _PromisedAnswer._Transform, this);
2993
+ }
2994
+ _hasTransform() {
2995
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
2996
+ }
2997
+ _initTransform(length) {
2998
+ return _chunkIVTBYMMNcjs.initList.call(void 0, 0, _PromisedAnswer._Transform, length, this);
2999
+ }
3000
+ set transform(value) {
3001
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
3002
+ }
3003
+ toString() {
3004
+ return "PromisedAnswer_" + super.toString();
3005
+ }
3006
+ }, _class22.__initStatic63(), _class22.__initStatic64(), _class22);
3007
+ var ThirdPartyCapDescriptor = (_class23 = class extends _chunkIVTBYMMNcjs.Struct {
3008
+ static {
3009
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "ThirdPartyCapDescriptor");
3010
+ }
3011
+ static __initStatic65() {this._capnp = {
3012
+ displayName: "ThirdPartyCapDescriptor",
3013
+ id: "d37007fde1f0027d",
3014
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 1)
3015
+ }}
3016
+ _adoptId(value) {
3017
+ _chunkIVTBYMMNcjs.adopt.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
3018
+ }
3019
+ _disownId() {
3020
+ return _chunkIVTBYMMNcjs.disown.call(void 0, this.id);
3021
+ }
3022
+ /**
3023
+ * Identifies the third-party host and the specific capability to accept from it.
3024
+ *
3025
+ */
3026
+ get id() {
3027
+ return _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this);
3028
+ }
3029
+ _hasId() {
3030
+ return !_chunkIVTBYMMNcjs.isNull.call(void 0, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
3031
+ }
3032
+ set id(value) {
3033
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, _chunkIVTBYMMNcjs.getPointer.call(void 0, 0, this));
3034
+ }
3035
+ /**
3036
+ * A proxy for the third-party object exported by the sender. In CapTP terminology this is called
3037
+ * a "vine", because it is an indirect reference to the third-party object that snakes through the
3038
+ * sender vat. This serves two purposes:
3039
+ *
3040
+ * * Level 1 and 2 implementations that don't understand how to connect to a third party may
3041
+ * simply send calls to the vine. Such calls will be forwarded to the third-party by the
3042
+ * sender.
3043
+ *
3044
+ * * Level 3 implementations must release the vine only once they have successfully picked up the
3045
+ * object from the third party. This ensures that the capability is not released by the sender
3046
+ * prematurely.
3047
+ *
3048
+ * The sender will close the `Provide` request that it has sent to the third party as soon as
3049
+ * it receives either a `Call` or a `Release` message directed at the vine.
3050
+ *
3051
+ */
3052
+ get vineId() {
3053
+ return _chunkIVTBYMMNcjs.getUint32.call(void 0, 0, this);
3054
+ }
3055
+ set vineId(value) {
3056
+ _chunkIVTBYMMNcjs.setUint32.call(void 0, 0, value, this);
3057
+ }
3058
+ toString() {
3059
+ return "ThirdPartyCapDescriptor_" + super.toString();
3060
+ }
3061
+ }, _class23.__initStatic65(), _class23);
3062
+ var Exception_Type = {
3063
+ /**
3064
+ * A generic problem occurred, and it is believed that if the operation were repeated without
3065
+ * any change in the state of the world, the problem would occur again.
3066
+ *
3067
+ * A client might respond to this error by logging it for investigation by the developer and/or
3068
+ * displaying it to the user.
3069
+ *
3070
+ */
3071
+ FAILED: 0,
3072
+ /**
3073
+ * The request was rejected due to a temporary lack of resources.
3074
+ *
3075
+ * Examples include:
3076
+ * - There's not enough CPU time to keep up with incoming requests, so some are rejected.
3077
+ * - The server ran out of RAM or disk space during the request.
3078
+ * - The operation timed out (took significantly longer than it should have).
3079
+ *
3080
+ * A client might respond to this error by scheduling to retry the operation much later. The
3081
+ * client should NOT retry again immediately since this would likely exacerbate the problem.
3082
+ *
3083
+ */
3084
+ OVERLOADED: 1,
3085
+ /**
3086
+ * The method failed because a connection to some necessary capability was lost.
3087
+ *
3088
+ * Examples include:
3089
+ * - The client introduced the server to a third-party capability, the connection to that third
3090
+ * party was subsequently lost, and then the client requested that the server use the dead
3091
+ * capability for something.
3092
+ * - The client previously requested that the server obtain a capability from some third party.
3093
+ * The server returned a capability to an object wrapping the third-party capability. Later,
3094
+ * the server's connection to the third party was lost.
3095
+ * - The capability has been revoked. Revocation does not necessarily mean that the client is
3096
+ * no longer authorized to use the capability; it is often used simply as a way to force the
3097
+ * client to repeat the setup process, perhaps to efficiently move them to a new back-end or
3098
+ * get them to recognize some other change that has occurred.
3099
+ *
3100
+ * A client should normally respond to this error by releasing all capabilities it is currently
3101
+ * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
3102
+ * repeating the method calls used to create them originally. In other words, disconnect and
3103
+ * start over. This should in turn cause the server to obtain a new copy of the capability that
3104
+ * it lost, thus making everything work.
3105
+ *
3106
+ * If the client receives another `disconnected` error in the process of rebuilding the
3107
+ * capability and retrying the call, it should treat this as an `overloaded` error: the network
3108
+ * is currently unreliable, possibly due to load or other temporary issues.
3109
+ *
3110
+ */
3111
+ DISCONNECTED: 2,
3112
+ /**
3113
+ * The server doesn't implement the requested method. If there is some other method that the
3114
+ * client could call (perhaps an older and/or slower interface), it should try that instead.
3115
+ * Otherwise, this should be treated like `failed`.
3116
+ *
3117
+ */
3118
+ UNIMPLEMENTED: 3
3119
+ };
3120
+ var Exception = (_class24 = class extends _chunkIVTBYMMNcjs.Struct {
3121
+ static {
3122
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Exception");
3123
+ }
3124
+ static __initStatic66() {this.Type = Exception_Type}
3125
+ static __initStatic67() {this._capnp = {
3126
+ displayName: "Exception",
3127
+ id: "d625b7063acf691a",
3128
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(8, 2)
3129
+ }}
3130
+ /**
3131
+ * Human-readable failure description.
3132
+ *
3133
+ */
3134
+ get reason() {
3135
+ return _chunkIVTBYMMNcjs.getText.call(void 0, 0, this);
3136
+ }
3137
+ set reason(value) {
3138
+ _chunkIVTBYMMNcjs.setText.call(void 0, 0, value, this);
3139
+ }
3140
+ /**
3141
+ * The type of the error. The purpose of this enum is not to describe the error itself, but
3142
+ * rather to describe how the client might want to respond to the error.
3143
+ *
3144
+ */
3145
+ get type() {
3146
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 4, this);
3147
+ }
3148
+ set type(value) {
3149
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 4, value, this);
3150
+ }
3151
+ /**
3152
+ * OBSOLETE. Ignore.
3153
+ *
3154
+ */
3155
+ get obsoleteIsCallersFault() {
3156
+ return _chunkIVTBYMMNcjs.getBit.call(void 0, 0, this);
3157
+ }
3158
+ set obsoleteIsCallersFault(value) {
3159
+ _chunkIVTBYMMNcjs.setBit.call(void 0, 0, value, this);
3160
+ }
3161
+ /**
3162
+ * OBSOLETE. See `type` instead.
3163
+ *
3164
+ */
3165
+ get obsoleteDurability() {
3166
+ return _chunkIVTBYMMNcjs.getUint16.call(void 0, 2, this);
3167
+ }
3168
+ set obsoleteDurability(value) {
3169
+ _chunkIVTBYMMNcjs.setUint16.call(void 0, 2, value, this);
3170
+ }
3171
+ /**
3172
+ * Stack trace text from the remote server. The format is not specified. By default,
3173
+ * implementations do not provide stack traces; the application must explicitly enable them
3174
+ * when desired.
3175
+ *
3176
+ */
3177
+ get trace() {
3178
+ return _chunkIVTBYMMNcjs.getText.call(void 0, 1, this);
3179
+ }
3180
+ set trace(value) {
3181
+ _chunkIVTBYMMNcjs.setText.call(void 0, 1, value, this);
3182
+ }
3183
+ toString() {
3184
+ return "Exception_" + super.toString();
3185
+ }
3186
+ }, _class24.__initStatic66(), _class24.__initStatic67(), _class24);
3187
+ Payload._CapTable = _chunkIVTBYMMNcjs.CompositeList.call(void 0, CapDescriptor);
3188
+ PromisedAnswer._Transform = _chunkIVTBYMMNcjs.CompositeList.call(void 0, PromisedAnswer_Op);
3189
+
3190
+ // ../../node_modules/.pnpm/capnp-es@0.0.11_patch_hash=53996ae63a1465953815fff49405f2224c85d26eeeff469d2b1f87e1c2af451d_typescript@5.8.3/node_modules/capnp-es/dist/index.mjs
3191
+ var Void = (_class25 = class extends _chunkIVTBYMMNcjs.Struct {
3192
+ static {
3193
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Void");
3194
+ }
3195
+ static __initStatic68() {this._capnp = {
3196
+ displayName: "Void",
3197
+ id: "0",
3198
+ size: new (0, _chunkIVTBYMMNcjs.ObjectSize)(0, 0)
3199
+ }}
3200
+ }, _class25.__initStatic68(), _class25);
3201
+ var utils = {
3202
+ __proto__: null,
3203
+ PointerAllocationResult: _chunkIVTBYMMNcjs.PointerAllocationResult,
3204
+ add: _chunkIVTBYMMNcjs.add,
3205
+ adopt: _chunkIVTBYMMNcjs.adopt,
3206
+ checkDataBounds: _chunkIVTBYMMNcjs.checkDataBounds,
3207
+ checkPointerBounds: _chunkIVTBYMMNcjs.checkPointerBounds,
3208
+ copyFrom: _chunkIVTBYMMNcjs.copyFrom,
3209
+ copyFromInterface: _chunkIVTBYMMNcjs.copyFromInterface,
3210
+ copyFromList: _chunkIVTBYMMNcjs.copyFromList,
3211
+ copyFromStruct: _chunkIVTBYMMNcjs.copyFromStruct,
3212
+ disown: _chunkIVTBYMMNcjs.disown,
3213
+ dump: _chunkIVTBYMMNcjs.dump,
3214
+ erase: _chunkIVTBYMMNcjs.erase,
3215
+ erasePointer: _chunkIVTBYMMNcjs.erasePointer,
3216
+ followFar: _chunkIVTBYMMNcjs.followFar,
3217
+ followFars: _chunkIVTBYMMNcjs.followFars,
3218
+ getAs: _chunkIVTBYMMNcjs.getAs,
3219
+ getBit: _chunkIVTBYMMNcjs.getBit,
3220
+ getCapabilityId: _chunkIVTBYMMNcjs.getCapabilityId,
3221
+ getContent: _chunkIVTBYMMNcjs.getContent,
3222
+ getData: _chunkIVTBYMMNcjs.getData,
3223
+ getDataSection: _chunkIVTBYMMNcjs.getDataSection,
3224
+ getFarSegmentId: _chunkIVTBYMMNcjs.getFarSegmentId,
3225
+ getFloat32: _chunkIVTBYMMNcjs.getFloat32,
3226
+ getFloat64: _chunkIVTBYMMNcjs.getFloat64,
3227
+ getInt16: _chunkIVTBYMMNcjs.getInt16,
3228
+ getInt32: _chunkIVTBYMMNcjs.getInt32,
3229
+ getInt64: _chunkIVTBYMMNcjs.getInt64,
3230
+ getInt8: _chunkIVTBYMMNcjs.getInt8,
3231
+ getInterfaceClientOrNull: _chunkIVTBYMMNcjs.getInterfaceClientOrNull,
3232
+ getInterfaceClientOrNullAt: _chunkIVTBYMMNcjs.getInterfaceClientOrNullAt,
3233
+ getInterfacePointer: _chunkIVTBYMMNcjs.getInterfacePointer,
3234
+ getList: _chunkIVTBYMMNcjs.getList,
3235
+ getListByteLength: _chunkIVTBYMMNcjs.getListByteLength,
3236
+ getListElementByteLength: _chunkIVTBYMMNcjs.getListElementByteLength,
3237
+ getListElementSize: _chunkIVTBYMMNcjs.getListElementSize,
3238
+ getListLength: _chunkIVTBYMMNcjs.getListLength,
3239
+ getOffsetWords: _chunkIVTBYMMNcjs.getOffsetWords,
3240
+ getPointer: _chunkIVTBYMMNcjs.getPointer,
3241
+ getPointerAs: _chunkIVTBYMMNcjs.getPointerAs,
3242
+ getPointerSection: _chunkIVTBYMMNcjs.getPointerSection,
3243
+ getPointerType: _chunkIVTBYMMNcjs.getPointerType,
3244
+ getSize: _chunkIVTBYMMNcjs.getSize,
3245
+ getStruct: _chunkIVTBYMMNcjs.getStruct,
3246
+ getStructDataWords: _chunkIVTBYMMNcjs.getStructDataWords,
3247
+ getStructPointerLength: _chunkIVTBYMMNcjs.getStructPointerLength,
3248
+ getStructSize: _chunkIVTBYMMNcjs.getStructSize,
3249
+ getTargetCompositeListSize: _chunkIVTBYMMNcjs.getTargetCompositeListSize,
3250
+ getTargetCompositeListTag: _chunkIVTBYMMNcjs.getTargetCompositeListTag,
3251
+ getTargetListElementSize: _chunkIVTBYMMNcjs.getTargetListElementSize,
3252
+ getTargetListLength: _chunkIVTBYMMNcjs.getTargetListLength,
3253
+ getTargetPointerType: _chunkIVTBYMMNcjs.getTargetPointerType,
3254
+ getTargetStructSize: _chunkIVTBYMMNcjs.getTargetStructSize,
3255
+ getText: _chunkIVTBYMMNcjs.getText,
3256
+ getUint16: _chunkIVTBYMMNcjs.getUint16,
3257
+ getUint32: _chunkIVTBYMMNcjs.getUint32,
3258
+ getUint64: _chunkIVTBYMMNcjs.getUint64,
3259
+ getUint8: _chunkIVTBYMMNcjs.getUint8,
3260
+ initData: _chunkIVTBYMMNcjs.initData,
3261
+ initList: _chunkIVTBYMMNcjs.initList,
3262
+ initPointer: _chunkIVTBYMMNcjs.initPointer,
3263
+ initStruct: _chunkIVTBYMMNcjs.initStruct,
3264
+ initStructAt: _chunkIVTBYMMNcjs.initStructAt,
3265
+ isDoubleFar: _chunkIVTBYMMNcjs.isDoubleFar,
3266
+ isNull: _chunkIVTBYMMNcjs.isNull,
3267
+ relocateTo: _chunkIVTBYMMNcjs.relocateTo,
3268
+ resize: _chunkIVTBYMMNcjs.resize,
3269
+ setBit: _chunkIVTBYMMNcjs.setBit,
3270
+ setFarPointer: _chunkIVTBYMMNcjs.setFarPointer,
3271
+ setFloat32: _chunkIVTBYMMNcjs.setFloat32,
3272
+ setFloat64: _chunkIVTBYMMNcjs.setFloat64,
3273
+ setInt16: _chunkIVTBYMMNcjs.setInt16,
3274
+ setInt32: _chunkIVTBYMMNcjs.setInt32,
3275
+ setInt64: _chunkIVTBYMMNcjs.setInt64,
3276
+ setInt8: _chunkIVTBYMMNcjs.setInt8,
3277
+ setInterfacePointer: _chunkIVTBYMMNcjs.setInterfacePointer,
3278
+ setListPointer: _chunkIVTBYMMNcjs.setListPointer,
3279
+ setStructPointer: _chunkIVTBYMMNcjs.setStructPointer,
3280
+ setText: _chunkIVTBYMMNcjs.setText,
3281
+ setUint16: _chunkIVTBYMMNcjs.setUint16,
3282
+ setUint32: _chunkIVTBYMMNcjs.setUint32,
3283
+ setUint64: _chunkIVTBYMMNcjs.setUint64,
3284
+ setUint8: _chunkIVTBYMMNcjs.setUint8,
3285
+ testWhich: _chunkIVTBYMMNcjs.testWhich,
3286
+ trackPointerAllocation: _chunkIVTBYMMNcjs.trackPointerAllocation,
3287
+ validate: _chunkIVTBYMMNcjs.validate
3288
+ };
3289
+ function PointerList(PointerClass) {
3290
+ return (_class26 = class extends _chunkIVTBYMMNcjs.List {
3291
+ static __initStatic69() {this._capnp = {
3292
+ displayName: `List<${PointerClass._capnp.displayName}>`,
3293
+ size: _chunkIVTBYMMNcjs.ListElementSize.POINTER
3294
+ }}
3295
+ get(index) {
3296
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3297
+ return new PointerClass(
3298
+ c.segment,
3299
+ c.byteOffset + index * 8,
3300
+ this._capnp.depthLimit - 1
3301
+ );
3302
+ }
3303
+ set(index, value) {
3304
+ _chunkIVTBYMMNcjs.copyFrom.call(void 0, value, this.get(index));
3305
+ }
3306
+ [Symbol.toStringTag]() {
3307
+ return `Pointer_${super.toString()},cls:${PointerClass.toString()}`;
3308
+ }
3309
+ }, _class26.__initStatic69(), _class26);
3310
+ }
3311
+ _chunkIVTBYMMNcjs.__name.call(void 0, PointerList, "PointerList");
3312
+ var AnyPointerList = PointerList(_chunkIVTBYMMNcjs.Pointer);
3313
+ var BoolList = (_class27 = class extends _chunkIVTBYMMNcjs.List {
3314
+ static {
3315
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "BoolList");
3316
+ }
3317
+ static __initStatic70() {this._capnp = {
3318
+ displayName: "List<boolean>",
3319
+ size: _chunkIVTBYMMNcjs.ListElementSize.BIT
3320
+ }}
3321
+ get(index) {
3322
+ const bitMask = 1 << index % 8;
3323
+ const byteOffset = index >>> 3;
3324
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3325
+ const v = c.segment.getUint8(c.byteOffset + byteOffset);
3326
+ return (v & bitMask) !== 0;
3327
+ }
3328
+ set(index, value) {
3329
+ const bitMask = 1 << index % 8;
3330
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3331
+ const byteOffset = c.byteOffset + (index >>> 3);
3332
+ const v = c.segment.getUint8(byteOffset);
3333
+ c.segment.setUint8(byteOffset, value ? v | bitMask : v & ~bitMask);
3334
+ }
3335
+ [Symbol.toStringTag]() {
3336
+ return `Bool_${super.toString()}`;
3337
+ }
3338
+ }, _class27.__initStatic70(), _class27);
3339
+ var DataList = PointerList(_chunkIVTBYMMNcjs.Data);
3340
+ var Float32List = (_class28 = class extends _chunkIVTBYMMNcjs.List {
3341
+ static {
3342
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Float32List");
3343
+ }
3344
+ static __initStatic71() {this._capnp = {
3345
+ displayName: "List<Float32>",
3346
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_4
3347
+ }}
3348
+ get(index) {
3349
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3350
+ return c.segment.getFloat32(c.byteOffset + index * 4);
3351
+ }
3352
+ set(index, value) {
3353
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3354
+ c.segment.setFloat32(c.byteOffset + index * 4, value);
3355
+ }
3356
+ [Symbol.toStringTag]() {
3357
+ return `Float32_${super.toString()}`;
3358
+ }
3359
+ }, _class28.__initStatic71(), _class28);
3360
+ var Float64List = (_class29 = class extends _chunkIVTBYMMNcjs.List {
3361
+ static {
3362
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Float64List");
3363
+ }
3364
+ static __initStatic72() {this._capnp = {
3365
+ displayName: "List<Float64>",
3366
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_8
3367
+ }}
3368
+ get(index) {
3369
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3370
+ return c.segment.getFloat64(c.byteOffset + index * 8);
3371
+ }
3372
+ set(index, value) {
3373
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3374
+ c.segment.setFloat64(c.byteOffset + index * 8, value);
3375
+ }
3376
+ [Symbol.toStringTag]() {
3377
+ return `Float64_${super.toString()}`;
3378
+ }
3379
+ }, _class29.__initStatic72(), _class29);
3380
+ var Int8List = (_class30 = class extends _chunkIVTBYMMNcjs.List {
3381
+ static {
3382
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Int8List");
3383
+ }
3384
+ static __initStatic73() {this._capnp = {
3385
+ displayName: "List<Int8>",
3386
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE
3387
+ }}
3388
+ get(index) {
3389
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3390
+ return c.segment.getInt8(c.byteOffset + index);
3391
+ }
3392
+ set(index, value) {
3393
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3394
+ c.segment.setInt8(c.byteOffset + index, value);
3395
+ }
3396
+ [Symbol.toStringTag]() {
3397
+ return `Int8_${super.toString()}`;
3398
+ }
3399
+ }, _class30.__initStatic73(), _class30);
3400
+ var Int16List = (_class31 = class extends _chunkIVTBYMMNcjs.List {
3401
+ static {
3402
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Int16List");
3403
+ }
3404
+ static __initStatic74() {this._capnp = {
3405
+ displayName: "List<Int16>",
3406
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_2
3407
+ }}
3408
+ get(index) {
3409
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3410
+ return c.segment.getInt16(c.byteOffset + index * 2);
3411
+ }
3412
+ set(index, value) {
3413
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3414
+ c.segment.setInt16(c.byteOffset + index * 2, value);
3415
+ }
3416
+ [Symbol.toStringTag]() {
3417
+ return `Int16_${super.toString()}`;
3418
+ }
3419
+ }, _class31.__initStatic74(), _class31);
3420
+ var Int32List = (_class32 = class extends _chunkIVTBYMMNcjs.List {
3421
+ static {
3422
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Int32List");
3423
+ }
3424
+ static __initStatic75() {this._capnp = {
3425
+ displayName: "List<Int32>",
3426
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_4
3427
+ }}
3428
+ get(index) {
3429
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3430
+ return c.segment.getInt32(c.byteOffset + index * 4);
3431
+ }
3432
+ set(index, value) {
3433
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3434
+ c.segment.setInt32(c.byteOffset + index * 4, value);
3435
+ }
3436
+ [Symbol.toStringTag]() {
3437
+ return `Int32_${super.toString()}`;
3438
+ }
3439
+ }, _class32.__initStatic75(), _class32);
3440
+ var Int64List = (_class33 = class extends _chunkIVTBYMMNcjs.List {
3441
+ static {
3442
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Int64List");
3443
+ }
3444
+ static __initStatic76() {this._capnp = {
3445
+ displayName: "List<Int64>",
3446
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_8
3447
+ }}
3448
+ get(index) {
3449
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3450
+ return c.segment.getInt64(c.byteOffset + index * 8);
3451
+ }
3452
+ set(index, value) {
3453
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3454
+ c.segment.setInt64(c.byteOffset + index * 8, value);
3455
+ }
3456
+ [Symbol.toStringTag]() {
3457
+ return `Int64_${super.toString()}`;
3458
+ }
3459
+ }, _class33.__initStatic76(), _class33);
3460
+ var InterfaceList = PointerList(Interface);
3461
+ var TextList = (_class34 = class extends _chunkIVTBYMMNcjs.List {
3462
+ static {
3463
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "TextList");
3464
+ }
3465
+ static __initStatic77() {this._capnp = {
3466
+ displayName: "List<Text>",
3467
+ size: _chunkIVTBYMMNcjs.ListElementSize.POINTER
3468
+ }}
3469
+ get(index) {
3470
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3471
+ c.byteOffset += index * 8;
3472
+ return _chunkIVTBYMMNcjs.Text.fromPointer(c).get(0);
3473
+ }
3474
+ set(index, value) {
3475
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3476
+ c.byteOffset += index * 8;
3477
+ _chunkIVTBYMMNcjs.Text.fromPointer(c).set(0, value);
3478
+ }
3479
+ [Symbol.toStringTag]() {
3480
+ return `Text_${super.toString()}`;
3481
+ }
3482
+ }, _class34.__initStatic77(), _class34);
3483
+ var Uint8List = (_class35 = class extends _chunkIVTBYMMNcjs.List {
3484
+ static {
3485
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Uint8List");
3486
+ }
3487
+ static __initStatic78() {this._capnp = {
3488
+ displayName: "List<Uint8>",
3489
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE
3490
+ }}
3491
+ get(index) {
3492
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3493
+ return c.segment.getUint8(c.byteOffset + index);
3494
+ }
3495
+ set(index, value) {
3496
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3497
+ c.segment.setUint8(c.byteOffset + index, value);
3498
+ }
3499
+ [Symbol.toStringTag]() {
3500
+ return `Uint8_${super.toString()}`;
3501
+ }
3502
+ }, _class35.__initStatic78(), _class35);
3503
+ var Uint16List = (_class36 = class extends _chunkIVTBYMMNcjs.List {
3504
+ static {
3505
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Uint16List");
3506
+ }
3507
+ static __initStatic79() {this._capnp = {
3508
+ displayName: "List<Uint16>",
3509
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_2
3510
+ }}
3511
+ get(index) {
3512
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3513
+ return c.segment.getUint16(c.byteOffset + index * 2);
3514
+ }
3515
+ set(index, value) {
3516
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3517
+ c.segment.setUint16(c.byteOffset + index * 2, value);
3518
+ }
3519
+ [Symbol.toStringTag]() {
3520
+ return `Uint16_${super.toString()}`;
3521
+ }
3522
+ }, _class36.__initStatic79(), _class36);
3523
+ var Uint32List = (_class37 = class extends _chunkIVTBYMMNcjs.List {
3524
+ static {
3525
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Uint32List");
3526
+ }
3527
+ static __initStatic80() {this._capnp = {
3528
+ displayName: "List<Uint32>",
3529
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_4
3530
+ }}
3531
+ get(index) {
3532
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3533
+ return c.segment.getUint32(c.byteOffset + index * 4);
3534
+ }
3535
+ set(index, value) {
3536
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3537
+ c.segment.setUint32(c.byteOffset + index * 4, value);
3538
+ }
3539
+ [Symbol.toStringTag]() {
3540
+ return `Uint32_${super.toString()}`;
3541
+ }
3542
+ }, _class37.__initStatic80(), _class37);
3543
+ var Uint64List = (_class38 = class extends _chunkIVTBYMMNcjs.List {
3544
+ static {
3545
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Uint64List");
3546
+ }
3547
+ static __initStatic81() {this._capnp = {
3548
+ displayName: "List<Uint64>",
3549
+ size: _chunkIVTBYMMNcjs.ListElementSize.BYTE_8
3550
+ }}
3551
+ get(index) {
3552
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3553
+ return c.segment.getUint64(c.byteOffset + index * 8);
3554
+ }
3555
+ set(index, value) {
3556
+ const c = _chunkIVTBYMMNcjs.getContent.call(void 0, this);
3557
+ c.segment.setUint64(c.byteOffset + index * 8, value);
3558
+ }
3559
+ [Symbol.toStringTag]() {
3560
+ return `Uint64_${super.toString()}`;
3561
+ }
3562
+ }, _class38.__initStatic81(), _class38);
3563
+ var VoidList = PointerList(Void);
3564
+ function isSameClient(c, d) {
3565
+ const norm = /* @__PURE__ */ _chunkIVTBYMMNcjs.__name.call(void 0, (c2) => {
3566
+ return c2;
3567
+ }, "norm");
3568
+ return norm(c) === norm(d);
3569
+ }
3570
+ _chunkIVTBYMMNcjs.__name.call(void 0, isSameClient, "isSameClient");
3571
+ function clientFromResolution(transform, obj, err) {
3572
+ if (err) {
3573
+ return new (0, _chunkIVTBYMMNcjs.ErrorClient)(err);
3574
+ }
3575
+ if (!obj) {
3576
+ return new (0, _chunkIVTBYMMNcjs.ErrorClient)(new Error(`null obj!`));
3577
+ }
3578
+ const out = transformPtr(obj, transform);
3579
+ return _chunkIVTBYMMNcjs.getInterfaceClientOrNull.call(void 0, out);
3580
+ }
3581
+ _chunkIVTBYMMNcjs.__name.call(void 0, clientFromResolution, "clientFromResolution");
3582
+ var IDGen = (_class39 = class {constructor() { _class39.prototype.__init6.call(this);_class39.prototype.__init7.call(this); }
3583
+ static {
3584
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "IDGen");
3585
+ }
3586
+ __init6() {this.i = 0}
3587
+ __init7() {this.free = []}
3588
+ next() {
3589
+ return _nullishCoalesce(this.free.pop(), () => ( this.i++));
3590
+ }
3591
+ remove(i) {
3592
+ this.free.push(i);
3593
+ }
3594
+ }, _class39);
3595
+ var Ref = class {
3596
+ static {
3597
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Ref");
3598
+ }
3599
+ constructor(rc, finalize) {
3600
+ this.rc = rc;
3601
+ const closeState = { closed: false };
3602
+ this.closeState = closeState;
3603
+ finalize(this, () => {
3604
+ if (!closeState.closed) {
3605
+ closeState.closed = true;
3606
+ rc.decref();
3607
+ }
3608
+ });
3609
+ }
3610
+
3611
+ call(cl) {
3612
+ return this.rc.call(cl);
3613
+ }
3614
+ client() {
3615
+ return this.rc._client;
3616
+ }
3617
+ close() {
3618
+ if (!this.closeState.closed) {
3619
+ this.closeState.closed = true;
3620
+ this.rc.decref();
3621
+ }
3622
+ }
3623
+ };
3624
+ var RefCount = class _RefCount {
3625
+ static {
3626
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "RefCount");
3627
+ }
3628
+
3629
+
3630
+
3631
+ constructor(c, _finalize) {
3632
+ this._client = c;
3633
+ this.finalize = _finalize;
3634
+ this.refs = 1;
3635
+ }
3636
+ // New creates a reference counter and the first client reference.
3637
+ static new(c, finalize) {
3638
+ const rc = new _RefCount(c, finalize);
3639
+ const ref = rc.newRef();
3640
+ return [rc, ref];
3641
+ }
3642
+ call(cl) {
3643
+ return this._client.call(cl);
3644
+ }
3645
+ client() {
3646
+ return this._client;
3647
+ }
3648
+ close() {
3649
+ this._client.close();
3650
+ }
3651
+ ref() {
3652
+ if (this.refs <= 0) {
3653
+ return new (0, _chunkIVTBYMMNcjs.ErrorClient)(new Error(_chunkIVTBYMMNcjs.RPC_ZERO_REF));
3654
+ }
3655
+ this.refs++;
3656
+ return this.newRef();
3657
+ }
3658
+ newRef() {
3659
+ return new Ref(this, this.finalize);
3660
+ }
3661
+ decref() {
3662
+ this.refs--;
3663
+ if (this.refs === 0) {
3664
+ this._client.close();
3665
+ }
3666
+ }
3667
+ };
3668
+ var RPCError = class extends Error {
3669
+ static {
3670
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "RPCError");
3671
+ }
3672
+ constructor(exception) {
3673
+ super(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_ERROR, exception.reason));
3674
+ this.exception = exception;
3675
+ }
3676
+ };
3677
+ function toException(exc, err) {
3678
+ if (err instanceof RPCError) {
3679
+ exc.reason = err.exception.reason;
3680
+ exc.type = err.exception.type;
3681
+ return;
3682
+ }
3683
+ exc.reason = err.message;
3684
+ exc.type = Exception.Type.FAILED;
3685
+ }
3686
+ _chunkIVTBYMMNcjs.__name.call(void 0, toException, "toException");
3687
+ function newMessage() {
3688
+ return new (0, _chunkIVTBYMMNcjs.Message)().initRoot(Message2);
3689
+ }
3690
+ _chunkIVTBYMMNcjs.__name.call(void 0, newMessage, "newMessage");
3691
+ function newFinishMessage(questionID, release) {
3692
+ const m = newMessage();
3693
+ const f = m._initFinish();
3694
+ f.questionId = questionID;
3695
+ f.releaseResultCaps = release;
3696
+ return m;
3697
+ }
3698
+ _chunkIVTBYMMNcjs.__name.call(void 0, newFinishMessage, "newFinishMessage");
3699
+ function newUnimplementedMessage(m) {
3700
+ const n = newMessage();
3701
+ n.unimplemented = m;
3702
+ return n;
3703
+ }
3704
+ _chunkIVTBYMMNcjs.__name.call(void 0, newUnimplementedMessage, "newUnimplementedMessage");
3705
+ function newReturnMessage(id) {
3706
+ const m = newMessage();
3707
+ const ret = m._initReturn();
3708
+ ret.answerId = id;
3709
+ return m;
3710
+ }
3711
+ _chunkIVTBYMMNcjs.__name.call(void 0, newReturnMessage, "newReturnMessage");
3712
+ function setReturnException(ret, err) {
3713
+ const exc = ret._initException();
3714
+ toException(exc, err);
3715
+ return exc;
3716
+ }
3717
+ _chunkIVTBYMMNcjs.__name.call(void 0, setReturnException, "setReturnException");
3718
+ function newDisembargoMessage(which, id) {
3719
+ const m = newMessage();
3720
+ const dis = m._initDisembargo();
3721
+ const ctx = dis._initContext();
3722
+ switch (which) {
3723
+ case Disembargo_Context_Which.SENDER_LOOPBACK: {
3724
+ ctx.senderLoopback = id;
3725
+ break;
3726
+ }
3727
+ case Disembargo_Context_Which.RECEIVER_LOOPBACK: {
3728
+ ctx.receiverLoopback = id;
3729
+ break;
3730
+ }
3731
+ default: {
3732
+ throw new Error(_chunkIVTBYMMNcjs.INVARIANT_UNREACHABLE_CODE);
3733
+ }
3734
+ }
3735
+ return m;
3736
+ }
3737
+ _chunkIVTBYMMNcjs.__name.call(void 0, newDisembargoMessage, "newDisembargoMessage");
3738
+ function transformToPromisedAnswer(answer, transform) {
3739
+ const opList = answer._initTransform(transform.length);
3740
+ for (const [i, op] of transform.entries()) {
3741
+ opList.get(i).getPointerField = op.field;
3742
+ }
3743
+ }
3744
+ _chunkIVTBYMMNcjs.__name.call(void 0, transformToPromisedAnswer, "transformToPromisedAnswer");
3745
+ function promisedAnswerOpsToTransform(list) {
3746
+ const transform = [];
3747
+ for (const op of list) {
3748
+ switch (op.which()) {
3749
+ case PromisedAnswer_Op.GET_POINTER_FIELD: {
3750
+ transform.push({
3751
+ field: op.getPointerField
3752
+ });
3753
+ break;
3754
+ }
3755
+ case PromisedAnswer_Op.NOOP: {
3756
+ break;
3757
+ }
3758
+ }
3759
+ }
3760
+ return transform;
3761
+ }
3762
+ _chunkIVTBYMMNcjs.__name.call(void 0, promisedAnswerOpsToTransform, "promisedAnswerOpsToTransform");
3763
+ var QuestionState = /* @__PURE__ */ ((QuestionState2) => {
3764
+ QuestionState2[QuestionState2["IN_PROGRESS"] = 0] = "IN_PROGRESS";
3765
+ QuestionState2[QuestionState2["RESOLVED"] = 1] = "RESOLVED";
3766
+ QuestionState2[QuestionState2["CANCELED"] = 2] = "CANCELED";
3767
+ return QuestionState2;
3768
+ })(QuestionState || {});
3769
+ var Question = (_class40 = class {
3770
+ static {
3771
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Question");
3772
+ }
3773
+ constructor(conn, id, method) {;_class40.prototype.__init8.call(this);_class40.prototype.__init9.call(this);_class40.prototype.__init10.call(this);_class40.prototype.__init11.call(this);
3774
+ this.conn = conn;
3775
+ this.id = id;
3776
+ this.method = method;
3777
+ }
3778
+ __init8() {this.paramCaps = []}
3779
+ __init9() {this.state = 0}
3780
+
3781
+
3782
+ __init10() {this.derived = []}
3783
+ __init11() {this.deferred = new Deferred()}
3784
+ async struct() {
3785
+ return await this.deferred.promise;
3786
+ }
3787
+ // start signals the question has been sent
3788
+ start() {
3789
+ }
3790
+ // fulfill is called to resolve a question successfully.
3791
+ // The caller must be holding onto q.conn.mu.
3792
+ fulfill(obj) {
3793
+ if (this.state !== 0) {
3794
+ throw new Error(_chunkIVTBYMMNcjs.RPC_FULFILL_ALREADY_CALLED);
3795
+ }
3796
+ if (this.method) {
3797
+ this.obj = _chunkIVTBYMMNcjs.getAs.call(void 0, this.method.ResultsClass, obj);
3798
+ } else {
3799
+ this.obj = obj;
3800
+ }
3801
+ this.state = 1;
3802
+ this.deferred.resolve(this.obj);
3803
+ }
3804
+ // reject is called to resolve a question with failure
3805
+ reject(err) {
3806
+ if (!err) {
3807
+ throw new Error(`Question.reject called with null`);
3808
+ }
3809
+ if (this.state !== 0) {
3810
+ throw new Error(`Question.reject called more than once`);
3811
+ }
3812
+ this.err = err;
3813
+ this.state = 1;
3814
+ this.deferred.reject(err);
3815
+ }
3816
+ // cancel is called to resolve a question with cancellation.
3817
+ cancel(err) {
3818
+ if (this.state === 0) {
3819
+ this.err = err;
3820
+ this.state = 2;
3821
+ this.deferred.reject(err);
3822
+ return true;
3823
+ }
3824
+ return false;
3825
+ }
3826
+ pipelineCall(transform, call) {
3827
+ if (this.conn.findQuestion(this.id) !== this) {
3828
+ if (this.state === 0) {
3829
+ throw new Error(`question popped but not done`);
3830
+ }
3831
+ const client = clientFromResolution(transform, this.obj, this.err);
3832
+ return client.call(call);
3833
+ }
3834
+ const pipeq = this.conn.newQuestion(call.method);
3835
+ const msg = newMessage();
3836
+ const msgCall = msg._initCall();
3837
+ msgCall.questionId = pipeq.id;
3838
+ msgCall.interfaceId = call.method.interfaceId;
3839
+ msgCall.methodId = call.method.methodId;
3840
+ const target = msgCall._initTarget();
3841
+ const a = target._initPromisedAnswer();
3842
+ a.questionId = this.id;
3843
+ transformToPromisedAnswer(a, transform);
3844
+ const payload = msgCall._initParams();
3845
+ this.conn.fillParams(payload, call);
3846
+ this.conn.sendMessage(msg);
3847
+ this.addPromise(transform);
3848
+ return pipeq;
3849
+ }
3850
+ addPromise(transform) {
3851
+ for (const d of this.derived) {
3852
+ if (transformsEqual(transform, d)) {
3853
+ return;
3854
+ }
3855
+ }
3856
+ this.derived.push(transform);
3857
+ }
3858
+ pipelineClose() {
3859
+ throw new Error(_chunkIVTBYMMNcjs.NOT_IMPLEMENTED);
3860
+ }
3861
+ }, _class40);
3862
+ function transformsEqual(t, u) {
3863
+ if (t.length !== u.length) {
3864
+ return false;
3865
+ }
3866
+ for (const [i, element_] of t.entries()) {
3867
+ if (element_.field !== u[i].field) {
3868
+ return false;
3869
+ }
3870
+ }
3871
+ return true;
3872
+ }
3873
+ _chunkIVTBYMMNcjs.__name.call(void 0, transformsEqual, "transformsEqual");
3874
+ var Qcalls = class _Qcalls {
3875
+ static {
3876
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Qcalls");
3877
+ }
3878
+ constructor(data) {
3879
+ this.data = data;
3880
+ }
3881
+ static copyOf(data) {
3882
+ return new _Qcalls([...data]);
3883
+ }
3884
+ len() {
3885
+ return this.data.length;
3886
+ }
3887
+ clear(i) {
3888
+ this.data[i] = null;
3889
+ }
3890
+ copy() {
3891
+ return _Qcalls.copyOf(this.data);
3892
+ }
3893
+ };
3894
+ function joinAnswer(fl, answer) {
3895
+ answer.struct().then((obj) => {
3896
+ fl.fulfill(obj);
3897
+ }).catch((error_) => {
3898
+ fl.reject(error_);
3899
+ });
3900
+ }
3901
+ _chunkIVTBYMMNcjs.__name.call(void 0, joinAnswer, "joinAnswer");
3902
+ var callQueueSize2 = 64;
3903
+ var QueueClient = class {
3904
+ static {
3905
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "QueueClient");
3906
+ }
3907
+ constructor(conn, client, calls) {
3908
+ this.conn = conn;
3909
+ this._client = client;
3910
+ this.calls = Qcalls.copyOf(calls);
3911
+ this.q = new Queue(this.calls, callQueueSize2);
3912
+ }
3913
+
3914
+
3915
+
3916
+ pushCall(call) {
3917
+ const f = new Fulfiller();
3918
+ try {
3919
+ call = copyCall(call);
3920
+ } catch (error_) {
3921
+ return new (0, _chunkIVTBYMMNcjs.ErrorAnswer)(error_);
3922
+ }
3923
+ const i = this.q.push();
3924
+ if (i === -1) {
3925
+ return new (0, _chunkIVTBYMMNcjs.ErrorAnswer)(new Error(_chunkIVTBYMMNcjs.RPC_CALL_QUEUE_FULL));
3926
+ }
3927
+ this.calls.data[i] = {
3928
+ call,
3929
+ f
3930
+ };
3931
+ return f;
3932
+ }
3933
+ pushEmbargo(id, tgt) {
3934
+ const i = this.q.push();
3935
+ if (i === -1) {
3936
+ throw new Error(_chunkIVTBYMMNcjs.RPC_CALL_QUEUE_FULL);
3937
+ }
3938
+ this.calls.data[i] = {
3939
+ embargoID: id,
3940
+ embargoTarget: tgt
3941
+ };
3942
+ }
3943
+ flushQueue() {
3944
+ let c = null;
3945
+ {
3946
+ const i = this.q.front();
3947
+ if (i !== -1) {
3948
+ c = this.calls.data[i];
3949
+ }
3950
+ }
3951
+ while (c) {
3952
+ this.handle(c);
3953
+ this.q.pop();
3954
+ {
3955
+ const i = this.q.front();
3956
+ c = i === -1 ? null : this.calls.data[i];
3957
+ }
3958
+ }
3959
+ }
3960
+ handle(c) {
3961
+ if (!c) {
3962
+ return;
3963
+ }
3964
+ if (isRemoteCall(c)) {
3965
+ const answer = this._client.call(c.call);
3966
+ joinAnswer(c.a, answer);
3967
+ } else if (isLocalCall(c)) {
3968
+ const answer = this._client.call(c.call);
3969
+ joinAnswer(c.f, answer);
3970
+ } else if (isDisembargo(c)) {
3971
+ const msg = newDisembargoMessage(
3972
+ Disembargo_Context_Which.RECEIVER_LOOPBACK,
3973
+ c.embargoID
3974
+ );
3975
+ msg.disembargo.target = c.embargoTarget;
3976
+ this.conn.sendMessage(msg);
3977
+ }
3978
+ }
3979
+ isPassthrough() {
3980
+ return this.q.len() === 0;
3981
+ }
3982
+ call(call) {
3983
+ if (this.isPassthrough()) {
3984
+ return this._client.call(call);
3985
+ }
3986
+ return this.pushCall(call);
3987
+ }
3988
+ // close releases any resources associated with this client.
3989
+ // No further calls to the client should be made after calling Close.
3990
+ close() {
3991
+ }
3992
+ };
3993
+ var AnswerEntry = (_class41 = class {
3994
+ static {
3995
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "AnswerEntry");
3996
+ }
3997
+
3998
+
3999
+ __init12() {this.resultCaps = []}
4000
+ __init13() {this.done = false}
4001
+
4002
+
4003
+ __init14() {this.deferred = new Deferred()}
4004
+ __init15() {this.queue = []}
4005
+ constructor(conn, id) {;_class41.prototype.__init12.call(this);_class41.prototype.__init13.call(this);_class41.prototype.__init14.call(this);_class41.prototype.__init15.call(this);
4006
+ this.conn = conn;
4007
+ this.id = id;
4008
+ }
4009
+ // fulfill is called to resolve an answer successfully.
4010
+ fulfill(obj) {
4011
+ if (this.done) {
4012
+ throw new Error(`answer.fulfill called more than once`);
4013
+ }
4014
+ this.done = true;
4015
+ this.obj = obj;
4016
+ const retmsg = newReturnMessage(this.id);
4017
+ const ret = retmsg.return;
4018
+ const payload = ret._initResults();
4019
+ payload.content = obj;
4020
+ let firstErr;
4021
+ try {
4022
+ this.conn.makeCapTable(ret.segment, (len) => payload._initCapTable(len));
4023
+ this.deferred.resolve(obj);
4024
+ this.conn.sendMessage(retmsg);
4025
+ } catch (error_) {
4026
+ if (!firstErr) {
4027
+ firstErr = error_;
4028
+ }
4029
+ }
4030
+ const [queues, queuesErr] = this.emptyQueue(obj);
4031
+ if (queuesErr && !firstErr) {
4032
+ firstErr = queuesErr;
4033
+ }
4034
+ const objcap = obj.segment.message._capnp;
4035
+ if (!objcap.capTable) {
4036
+ objcap.capTable = [];
4037
+ }
4038
+ for (const capIdxStr of Object.keys(queues)) {
4039
+ const capIdx = Number(capIdxStr);
4040
+ const q = queues[capIdx];
4041
+ if (objcap.capTable === null) throw new Error(_chunkIVTBYMMNcjs.INVARIANT_UNREACHABLE_CODE);
4042
+ objcap.capTable[capIdx] = new QueueClient(
4043
+ this.conn,
4044
+ objcap.capTable[capIdx],
4045
+ q
4046
+ );
4047
+ }
4048
+ if (firstErr) {
4049
+ throw firstErr;
4050
+ }
4051
+ }
4052
+ // reject is called to resolve an answer with failure.
4053
+ reject(err) {
4054
+ if (!err) {
4055
+ throw new Error(`answer.reject called with nil`);
4056
+ }
4057
+ if (this.done) {
4058
+ throw new Error(`answer.reject claled more than once`);
4059
+ }
4060
+ const m = newReturnMessage(this.id);
4061
+ const mret = m.return;
4062
+ setReturnException(mret, err);
4063
+ this.err = err;
4064
+ this.done = true;
4065
+ this.deferred.reject(err);
4066
+ let firstErr;
4067
+ try {
4068
+ this.conn.sendMessage(m);
4069
+ } catch (error_) {
4070
+ firstErr = error_;
4071
+ }
4072
+ for (let i = 0; i < this.queue.length; i++) {
4073
+ const qa = this.queue[i];
4074
+ try {
4075
+ if (qa.qcall && isRemoteCall(qa.qcall)) {
4076
+ qa.qcall.a.reject(err);
4077
+ }
4078
+ } catch (error_) {
4079
+ if (!firstErr) {
4080
+ firstErr = error_;
4081
+ }
4082
+ }
4083
+ }
4084
+ this.queue = [];
4085
+ if (firstErr) {
4086
+ throw firstErr;
4087
+ }
4088
+ }
4089
+ // emptyQueue splits the queue by which capability it targets
4090
+ // and drops any invalid calls. Once this function returns,
4091
+ // this.queue will be empty.
4092
+ emptyQueue(obj) {
4093
+ let firstErr;
4094
+ const qs = {};
4095
+ for (let i = 0; i < this.queue.length; i++) {
4096
+ const pc = this.queue[i];
4097
+ if (!isRemoteCall(pc.qcall)) {
4098
+ continue;
4099
+ }
4100
+ if (!pc.qcall.a) {
4101
+ continue;
4102
+ }
4103
+ let c;
4104
+ try {
4105
+ c = transformPtr(obj, pc.transform);
4106
+ } catch (error_) {
4107
+ try {
4108
+ pc.qcall.a.reject(error_);
4109
+ } catch (error_2) {
4110
+ if (!firstErr) {
4111
+ firstErr = error_2;
4112
+ }
4113
+ }
4114
+ continue;
4115
+ }
4116
+ const ci = Interface.fromPointer(c);
4117
+ if (!ci) {
4118
+ try {
4119
+ pc.qcall.a.reject(new Error(_chunkIVTBYMMNcjs.RPC_NULL_CLIENT));
4120
+ } catch (error_) {
4121
+ if (!firstErr) {
4122
+ firstErr = error_;
4123
+ }
4124
+ }
4125
+ continue;
4126
+ }
4127
+ const cn = ci.getCapId();
4128
+ if (!qs[cn]) {
4129
+ qs[cn] = [];
4130
+ }
4131
+ qs[cn].push(pc.qcall);
4132
+ }
4133
+ this.queue = [];
4134
+ return [qs, firstErr];
4135
+ }
4136
+ queueCall(call, transform, a) {
4137
+ if (this.queue.length >= callQueueSize2) {
4138
+ throw new Error(_chunkIVTBYMMNcjs.RPC_CALL_QUEUE_FULL);
4139
+ }
4140
+ const qcall = {
4141
+ a,
4142
+ call: copyCall(call)
4143
+ };
4144
+ const pcall = {
4145
+ qcall,
4146
+ transform
4147
+ };
4148
+ this.queue.push(pcall);
4149
+ }
4150
+ }, _class41);
4151
+ function isRemoteCall(a) {
4152
+ return !!a.a;
4153
+ }
4154
+ _chunkIVTBYMMNcjs.__name.call(void 0, isRemoteCall, "isRemoteCall");
4155
+ function isLocalCall(a) {
4156
+ return !!a.f;
4157
+ }
4158
+ _chunkIVTBYMMNcjs.__name.call(void 0, isLocalCall, "isLocalCall");
4159
+ function isDisembargo(a) {
4160
+ return !!a.embargoTarget;
4161
+ }
4162
+ _chunkIVTBYMMNcjs.__name.call(void 0, isDisembargo, "isDisembargo");
4163
+ var ImportClient = (_class42 = class {
4164
+ static {
4165
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "ImportClient");
4166
+ }
4167
+ constructor(conn, id) {;_class42.prototype.__init16.call(this);
4168
+ this.conn = conn;
4169
+ this.id = id;
4170
+ }
4171
+ __init16() {this.closed = false}
4172
+ call(cl) {
4173
+ if (this.closed) {
4174
+ return new (0, _chunkIVTBYMMNcjs.ErrorAnswer)(new Error(_chunkIVTBYMMNcjs.RPC_IMPORT_CLOSED));
4175
+ }
4176
+ const q = this.conn.newQuestion(cl.method);
4177
+ const msg = newMessage();
4178
+ const msgCall = msg._initCall();
4179
+ msgCall.questionId = q.id;
4180
+ msgCall.interfaceId = cl.method.interfaceId;
4181
+ msgCall.methodId = cl.method.methodId;
4182
+ const target = msgCall._initTarget();
4183
+ target.importedCap = this.id;
4184
+ const payload = msgCall._initParams();
4185
+ this.conn.fillParams(payload, cl);
4186
+ this.conn.sendMessage(msg);
4187
+ return q;
4188
+ }
4189
+ close() {
4190
+ }
4191
+ }, _class42);
4192
+ var LocalAnswerClient = class {
4193
+ static {
4194
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "LocalAnswerClient");
4195
+ }
4196
+ constructor(a, transform) {
4197
+ this.a = a;
4198
+ this.transform = transform;
4199
+ }
4200
+ call(call) {
4201
+ if (this.a.done) {
4202
+ return clientFromResolution(this.transform, this.a.obj, this.a.err).call(
4203
+ call
4204
+ );
4205
+ }
4206
+ return new Fulfiller();
4207
+ }
4208
+ close() {
4209
+ throw new Error(_chunkIVTBYMMNcjs.NOT_IMPLEMENTED);
4210
+ }
4211
+ };
4212
+ var ConnWeakRefRegistry = globalThis.FinalizationRegistry ? new FinalizationRegistry((cb) => cb()) : void 0;
4213
+ var ConDefaultFinalize = /* @__PURE__ */ _chunkIVTBYMMNcjs.__name.call(void 0, (obj, finalizer) => {
4214
+ _optionalChain([ConnWeakRefRegistry, 'optionalAccess', _2 => _2.register, 'call', _3 => _3(obj, finalizer)]);
4215
+ }, "ConDefaultFinalize");
4216
+ var Conn = (_class43 = class {
4217
+ static {
4218
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "Conn");
4219
+ }
4220
+ /**
4221
+ * Create a new connection
4222
+ * @param transport The transport used to receive/send messages.
4223
+ * @param finalize Weak reference implementation. Compatible with
4224
+ * the 'weak' module on node.js (just add weak as a dependency and pass
4225
+ * require("weak")), but alternative implementations can be provided for
4226
+ * other platforms like Electron. Defaults to using FinalizationRegistry if
4227
+ * available.
4228
+ * @returns A new connection.
4229
+ */
4230
+ constructor(transport, finalize = ConDefaultFinalize) {;_class43.prototype.__init17.call(this);_class43.prototype.__init18.call(this);_class43.prototype.__init19.call(this);_class43.prototype.__init20.call(this);_class43.prototype.__init21.call(this);_class43.prototype.__init22.call(this);_class43.prototype.__init23.call(this);
4231
+ this.transport = transport;
4232
+ this.finalize = finalize;
4233
+ this.startWork();
4234
+ }
4235
+ __init17() {this.questionID = new IDGen()}
4236
+ __init18() {this.questions = []}
4237
+ __init19() {this.answers = {}}
4238
+ __init20() {this.exportID = new IDGen()}
4239
+ __init21() {this.exports = []}
4240
+ __init22() {this.imports = {}}
4241
+
4242
+
4243
+ __init23() {this.working = false}
4244
+ bootstrap(InterfaceClass) {
4245
+ const q = this.newQuestion();
4246
+ const msg = newMessage();
4247
+ const boot = msg._initBootstrap();
4248
+ boot.questionId = q.id;
4249
+ this.sendMessage(msg);
4250
+ return new InterfaceClass.Client(new Pipeline(_chunkIVTBYMMNcjs.AnyStruct, q).client());
4251
+ }
4252
+ initMain(InterfaceClass, target) {
4253
+ this.main = new InterfaceClass.Server(target);
4254
+ this.addExport(this.main);
4255
+ }
4256
+ startWork() {
4257
+ this.work().catch((error_) => {
4258
+ if (this.onError) {
4259
+ this.onError(error_);
4260
+ } else if (error_ !== void 0) {
4261
+ throw error_;
4262
+ }
4263
+ });
4264
+ }
4265
+ sendReturnException(id, err) {
4266
+ const m = newReturnMessage(id);
4267
+ setReturnException(m.return, err);
4268
+ this.sendMessage(m);
4269
+ }
4270
+ handleBootstrapMessage(m) {
4271
+ const boot = m.bootstrap;
4272
+ const id = boot.questionId;
4273
+ const ret = newReturnMessage(id);
4274
+ ret.return.releaseParamCaps = false;
4275
+ const a = this.insertAnswer(id);
4276
+ if (a === null) {
4277
+ return this.sendReturnException(id, new Error(_chunkIVTBYMMNcjs.RPC_QUESTION_ID_REUSED));
4278
+ }
4279
+ if (this.main === void 0) {
4280
+ return a.reject(new Error(_chunkIVTBYMMNcjs.RPC_NO_MAIN_INTERFACE));
4281
+ }
4282
+ const msg = new (0, _chunkIVTBYMMNcjs.Message)();
4283
+ msg.addCap(this.main);
4284
+ a.fulfill(new Interface(msg.getSegment(0), 0));
4285
+ }
4286
+ handleFinishMessage(m) {
4287
+ const { finish } = m;
4288
+ const id = finish.questionId;
4289
+ const a = this.popAnswer(id);
4290
+ if (a === null) {
4291
+ throw new Error(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_FINISH_UNKNOWN_ANSWER, id));
4292
+ }
4293
+ if (finish.releaseResultCaps) {
4294
+ const caps = a.resultCaps;
4295
+ let i = caps.length;
4296
+ while (--i >= 0) {
4297
+ this.releaseExport(i, 1);
4298
+ }
4299
+ }
4300
+ }
4301
+ handleMessage(m) {
4302
+ switch (m.which()) {
4303
+ case Message2.UNIMPLEMENTED: {
4304
+ break;
4305
+ }
4306
+ case Message2.BOOTSTRAP: {
4307
+ this.handleBootstrapMessage(m);
4308
+ break;
4309
+ }
4310
+ case Message2.ABORT: {
4311
+ this.shutdown(new RPCError(m.abort));
4312
+ break;
4313
+ }
4314
+ case Message2.FINISH: {
4315
+ this.handleFinishMessage(m);
4316
+ break;
4317
+ }
4318
+ case Message2.RETURN: {
4319
+ this.handleReturnMessage(m);
4320
+ break;
4321
+ }
4322
+ case Message2.CALL: {
4323
+ this.handleCallMessage(m);
4324
+ break;
4325
+ }
4326
+ }
4327
+ }
4328
+ handleReturnMessage(m) {
4329
+ const ret = m.return;
4330
+ const id = ret.answerId;
4331
+ const q = this.popQuestion(id);
4332
+ if (!q) {
4333
+ throw new Error(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_RETURN_FOR_UNKNOWN_QUESTION, id));
4334
+ }
4335
+ if (ret.releaseParamCaps) {
4336
+ for (let i = 0; i < q.paramCaps.length; i++) {
4337
+ this.releaseExport(id, 1);
4338
+ }
4339
+ }
4340
+ let releaseResultCaps = true;
4341
+ switch (ret.which()) {
4342
+ case Return.RESULTS: {
4343
+ releaseResultCaps = false;
4344
+ const { results } = ret;
4345
+ this.populateMessageCapTable(results);
4346
+ const { content } = results;
4347
+ q.fulfill(content);
4348
+ break;
4349
+ }
4350
+ case Return.EXCEPTION: {
4351
+ const exc = ret.exception;
4352
+ const err = q.method ? new MethodError(q.method, exc.reason) : new RPCError(exc);
4353
+ q.reject(err);
4354
+ break;
4355
+ }
4356
+ }
4357
+ const fin = newFinishMessage(id, releaseResultCaps);
4358
+ this.sendMessage(fin);
4359
+ }
4360
+ handleCallMessage(m) {
4361
+ const mcall = m.call;
4362
+ const mt = mcall.target;
4363
+ if (mt.which() !== MessageTarget.IMPORTED_CAP && mt.which() !== MessageTarget.PROMISED_ANSWER) {
4364
+ const um = newUnimplementedMessage(m);
4365
+ this.sendMessage(um);
4366
+ return;
4367
+ }
4368
+ const mparams = mcall.params;
4369
+ try {
4370
+ this.populateMessageCapTable(mparams);
4371
+ } catch (e2) {
4372
+ const um = newUnimplementedMessage(m);
4373
+ this.sendMessage(um);
4374
+ return;
4375
+ }
4376
+ const id = mcall.questionId;
4377
+ const a = this.insertAnswer(id);
4378
+ if (!a) {
4379
+ throw new Error(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_QUESTION_ID_REUSED, id));
4380
+ }
4381
+ const interfaceDef = Registry.lookup(mcall.interfaceId);
4382
+ if (!interfaceDef) {
4383
+ const um = newUnimplementedMessage(m);
4384
+ this.sendMessage(um);
4385
+ return;
4386
+ }
4387
+ const method = interfaceDef.methods[mcall.methodId];
4388
+ if (!method) {
4389
+ const um = newUnimplementedMessage(m);
4390
+ this.sendMessage(um);
4391
+ return;
4392
+ }
4393
+ const paramContent = mparams.content;
4394
+ const call = {
4395
+ method,
4396
+ params: _chunkIVTBYMMNcjs.getAs.call(void 0, method.ParamsClass, paramContent)
4397
+ };
4398
+ try {
4399
+ this.routeCallMessage(a, mt, call);
4400
+ } catch (error_) {
4401
+ a.reject(error_);
4402
+ }
4403
+ }
4404
+ routeCallMessage(result, mt, cl) {
4405
+ switch (mt.which()) {
4406
+ case MessageTarget.IMPORTED_CAP: {
4407
+ const id = mt.importedCap;
4408
+ const e = this.findExport(id);
4409
+ if (!e) {
4410
+ throw new Error(_chunkIVTBYMMNcjs.RPC_BAD_TARGET);
4411
+ }
4412
+ const answer = this.call(e.client, cl);
4413
+ joinAnswer(result, answer);
4414
+ break;
4415
+ }
4416
+ case MessageTarget.PROMISED_ANSWER: {
4417
+ const mpromise = mt.promisedAnswer;
4418
+ const id = mpromise.questionId;
4419
+ if (id === result.id) {
4420
+ throw new Error(_chunkIVTBYMMNcjs.RPC_BAD_TARGET);
4421
+ }
4422
+ const pa = this.answers[id];
4423
+ if (!pa) {
4424
+ throw new Error(_chunkIVTBYMMNcjs.RPC_BAD_TARGET);
4425
+ }
4426
+ const mtrans = mpromise.transform;
4427
+ const transform = promisedAnswerOpsToTransform(mtrans);
4428
+ if (pa.done) {
4429
+ const { obj, err } = pa;
4430
+ const client = clientFromResolution(transform, obj, err);
4431
+ const answer = this.call(client, cl);
4432
+ joinAnswer(result, answer);
4433
+ } else {
4434
+ pa.queueCall(cl, transform, result);
4435
+ }
4436
+ break;
4437
+ }
4438
+ default: {
4439
+ throw new Error(_chunkIVTBYMMNcjs.INVARIANT_UNREACHABLE_CODE);
4440
+ }
4441
+ }
4442
+ }
4443
+ populateMessageCapTable(payload) {
4444
+ const msg = payload.segment.message;
4445
+ const ctab = payload.capTable;
4446
+ for (const desc of ctab) {
4447
+ switch (desc.which()) {
4448
+ case CapDescriptor.NONE: {
4449
+ msg.addCap(null);
4450
+ break;
4451
+ }
4452
+ case CapDescriptor.SENDER_HOSTED: {
4453
+ const id = desc.senderHosted;
4454
+ const client = this.addImport(id);
4455
+ msg.addCap(client);
4456
+ break;
4457
+ }
4458
+ case CapDescriptor.SENDER_PROMISE: {
4459
+ const id = desc.senderPromise;
4460
+ const client = this.addImport(id);
4461
+ msg.addCap(client);
4462
+ break;
4463
+ }
4464
+ case CapDescriptor.RECEIVER_HOSTED: {
4465
+ const id = desc.receiverHosted;
4466
+ const e = this.findExport(id);
4467
+ if (!e) {
4468
+ throw new Error(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_UNKNOWN_EXPORT_ID, id));
4469
+ }
4470
+ msg.addCap(e.rc.ref());
4471
+ break;
4472
+ }
4473
+ case CapDescriptor.RECEIVER_ANSWER: {
4474
+ const recvAns = desc.receiverAnswer;
4475
+ const id = recvAns.questionId;
4476
+ const a = this.answers[id];
4477
+ if (!a) {
4478
+ throw new Error(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_UNKNOWN_ANSWER_ID, id));
4479
+ }
4480
+ const recvTransform = recvAns.transform;
4481
+ const transform = promisedAnswerOpsToTransform(recvTransform);
4482
+ msg.addCap(answerPipelineClient(a, transform));
4483
+ break;
4484
+ }
4485
+ default: {
4486
+ throw new Error(_chunkIVTBYMMNcjs.format.call(void 0, _chunkIVTBYMMNcjs.RPC_UNKNOWN_CAP_DESCRIPTOR, desc.which()));
4487
+ }
4488
+ }
4489
+ }
4490
+ }
4491
+ addImport(id) {
4492
+ const importEntry = this.imports[id];
4493
+ if (importEntry) {
4494
+ importEntry.refs++;
4495
+ return importEntry.rc.ref();
4496
+ }
4497
+ const client = new ImportClient(this, id);
4498
+ const [rc, ref] = RefCount.new(client, this.finalize);
4499
+ this.imports[id] = {
4500
+ rc,
4501
+ refs: 1
4502
+ };
4503
+ return ref;
4504
+ }
4505
+ findExport(id) {
4506
+ if (id > this.exports.length) {
4507
+ return null;
4508
+ }
4509
+ return this.exports[id];
4510
+ }
4511
+ addExport(client) {
4512
+ for (let i = 0; i < this.exports.length; i++) {
4513
+ const e = this.exports[i];
4514
+ if (e && isSameClient(e.rc._client, client)) {
4515
+ e.wireRefs++;
4516
+ return i;
4517
+ }
4518
+ }
4519
+ const id = this.exportID.next();
4520
+ const [rc, ref] = RefCount.new(client, this.finalize);
4521
+ const _export = {
4522
+ client: ref,
4523
+ id,
4524
+ rc,
4525
+ wireRefs: 1
4526
+ };
4527
+ if (id === this.exports.length) {
4528
+ this.exports.push(_export);
4529
+ } else {
4530
+ this.exports[id] = _export;
4531
+ }
4532
+ return id;
4533
+ }
4534
+ releaseExport(id, refs) {
4535
+ const e = this.findExport(id);
4536
+ if (!e) {
4537
+ return;
4538
+ }
4539
+ e.wireRefs -= refs;
4540
+ if (e.wireRefs > 0) {
4541
+ return;
4542
+ }
4543
+ if (e.wireRefs < 0) {
4544
+ this.error(`warning: export ${id} has negative refcount (${e.wireRefs})`);
4545
+ }
4546
+ e.client.close();
4547
+ this.exports[id] = null;
4548
+ this.exportID.remove(id);
4549
+ }
4550
+ error(s) {
4551
+ console.error(s);
4552
+ }
4553
+ newQuestion(method) {
4554
+ const id = this.questionID.next();
4555
+ const q = new Question(this, id, method);
4556
+ if (id === this.questions.length) {
4557
+ this.questions.push(q);
4558
+ } else {
4559
+ this.questions[id] = q;
4560
+ }
4561
+ return q;
4562
+ }
4563
+ findQuestion(id) {
4564
+ if (id > this.questions.length) {
4565
+ return null;
4566
+ }
4567
+ return this.questions[id];
4568
+ }
4569
+ popQuestion(id) {
4570
+ const q = this.findQuestion(id);
4571
+ if (!q) {
4572
+ return q;
4573
+ }
4574
+ this.questions[id] = null;
4575
+ this.questionID.remove(id);
4576
+ return q;
4577
+ }
4578
+ // TODO: cancel context?
4579
+ insertAnswer(id) {
4580
+ if (this.answers[id]) {
4581
+ return null;
4582
+ }
4583
+ const a = new AnswerEntry(this, id);
4584
+ this.answers[id] = a;
4585
+ return a;
4586
+ }
4587
+ popAnswer(id) {
4588
+ const a = this.answers[id];
4589
+ delete this.answers[id];
4590
+ return a;
4591
+ }
4592
+ shutdown(_err) {
4593
+ this.transport.close();
4594
+ }
4595
+ call(client, call) {
4596
+ return client.call(call);
4597
+ }
4598
+ fillParams(payload, cl) {
4599
+ const params = placeParams(cl, payload.content);
4600
+ payload.content = params;
4601
+ this.makeCapTable(
4602
+ payload.segment,
4603
+ (length) => payload._initCapTable(length)
4604
+ );
4605
+ }
4606
+ makeCapTable(s, init) {
4607
+ const msgtab = s.message._capnp.capTable;
4608
+ if (!msgtab) {
4609
+ return;
4610
+ }
4611
+ const t = init(msgtab.length);
4612
+ for (const [i, client] of msgtab.entries()) {
4613
+ const desc = t.get(i);
4614
+ if (!client) {
4615
+ desc.none = true;
4616
+ continue;
4617
+ }
4618
+ this.descriptorForClient(desc, client);
4619
+ }
4620
+ }
4621
+ // descriptorForClient fills desc for client, adding it to the export
4622
+ // table if necessary. The caller must be holding onto c.mu.
4623
+ descriptorForClient(desc, _client) {
4624
+ {
4625
+ dig: for (let client = _client; ; ) {
4626
+ if (client instanceof ImportClient) {
4627
+ if (client.conn !== this) {
4628
+ break dig;
4629
+ }
4630
+ desc.receiverHosted = client.id;
4631
+ return;
4632
+ } else if (client instanceof Ref) {
4633
+ client = client.client();
4634
+ } else if (client instanceof PipelineClient) {
4635
+ const p = client.pipeline;
4636
+ const ans = p.answer;
4637
+ const transform = p.transform();
4638
+ if (ans instanceof _chunkIVTBYMMNcjs.FixedAnswer) {
4639
+ let s;
4640
+ let err;
4641
+ try {
4642
+ s = ans.structSync();
4643
+ } catch (error_) {
4644
+ err = error_;
4645
+ }
4646
+ client = clientFromResolution(transform, s, err);
4647
+ } else if (ans instanceof Question) {
4648
+ if (ans.state !== QuestionState.IN_PROGRESS) {
4649
+ client = clientFromResolution(transform, ans.obj, ans.err);
4650
+ continue;
4651
+ }
4652
+ if (ans.conn !== this) {
4653
+ break dig;
4654
+ }
4655
+ const a = desc._initReceiverAnswer();
4656
+ a.questionId = ans.id;
4657
+ transformToPromisedAnswer(a, p.transform());
4658
+ return;
4659
+ } else {
4660
+ break dig;
4661
+ }
4662
+ } else {
4663
+ break dig;
4664
+ }
4665
+ }
4666
+ }
4667
+ const id = this.addExport(_client);
4668
+ desc.senderHosted = id;
4669
+ }
4670
+ sendMessage(msg) {
4671
+ this.transport.sendMessage(msg);
4672
+ }
4673
+ async work() {
4674
+ this.working = true;
4675
+ while (this.working) {
4676
+ try {
4677
+ const m = await this.transport.recvMessage();
4678
+ this.handleMessage(m);
4679
+ } catch (error_) {
4680
+ if (error_ !== void 0) {
4681
+ throw error_;
4682
+ }
4683
+ this.working = false;
4684
+ }
4685
+ }
4686
+ }
4687
+ }, _class43);
4688
+ function answerPipelineClient(a, transform) {
4689
+ return new LocalAnswerClient(a, transform);
4690
+ }
4691
+ _chunkIVTBYMMNcjs.__name.call(void 0, answerPipelineClient, "answerPipelineClient");
4692
+ var DeferredTransport = (_class44 = class {constructor() { _class44.prototype.__init24.call(this);_class44.prototype.__init25.call(this);_class44.prototype.__init26.call(this); }
4693
+ static {
4694
+ _chunkIVTBYMMNcjs.__name.call(void 0, this, "DeferredTransport");
4695
+ }
4696
+
4697
+ __init24() {this.closed = false}
4698
+ close() {
4699
+ this.closed = true;
4700
+ _optionalChain([this, 'access', _13 => _13.d, 'optionalAccess', _14 => _14.reject, 'call', _15 => _15()]);
4701
+ }
4702
+ recvMessage() {
4703
+ if (this.closed) {
4704
+ return Promise.reject();
4705
+ }
4706
+ if (this.d) {
4707
+ this.d.reject();
4708
+ }
4709
+ this.d = new Deferred();
4710
+ return this.d.promise;
4711
+ }
4712
+ __init25() {this.reject = /* @__PURE__ */ _chunkIVTBYMMNcjs.__name.call(void 0, (err) => {
4713
+ _optionalChain([this, 'access', _16 => _16.d, 'optionalAccess', _17 => _17.reject, 'call', _18 => _18(err)]);
4714
+ }, "reject")}
4715
+ __init26() {this.resolve = /* @__PURE__ */ _chunkIVTBYMMNcjs.__name.call(void 0, (buf) => {
4716
+ try {
4717
+ _optionalChain([this, 'access', _19 => _19.d, 'optionalAccess', _20 => _20.resolve, 'call', _21 => _21(new (0, _chunkIVTBYMMNcjs.Message)(buf, false).getRoot(Message2))]);
4718
+ } catch (error_) {
4719
+ _optionalChain([this, 'access', _22 => _22.d, 'optionalAccess', _23 => _23.reject, 'call', _24 => _24(error_)]);
4720
+ }
4721
+ }, "resolve")}
4722
+ }, _class44);
4723
+
4724
+
4725
+
4726
+
4727
+
4728
+
4729
+
4730
+
4731
+
4732
+
4733
+
4734
+
4735
+
4736
+
4737
+
4738
+
4739
+
4740
+
4741
+
4742
+
4743
+
4744
+
4745
+
4746
+
4747
+
4748
+
4749
+
4750
+
4751
+
4752
+
4753
+
4754
+
4755
+
4756
+
4757
+
4758
+ exports.Interface = Interface; exports.isFuncCall = isFuncCall; exports.isDataCall = isDataCall; exports.copyCall = copyCall; exports.placeParams = placeParams; exports.Deferred = Deferred; exports.Pipeline = Pipeline; exports.Registry = Registry; exports.Server = Server; exports.Void = Void; exports.utils = utils; exports.PointerList = PointerList; exports.AnyPointerList = AnyPointerList; exports.BoolList = BoolList; exports.DataList = DataList; exports.Float32List = Float32List; exports.Float64List = Float64List; exports.Int8List = Int8List; exports.Int16List = Int16List; exports.Int32List = Int32List; exports.Int64List = Int64List; exports.InterfaceList = InterfaceList; exports.TextList = TextList; exports.Uint8List = Uint8List; exports.Uint16List = Uint16List; exports.Uint32List = Uint32List; exports.Uint64List = Uint64List; exports.VoidList = VoidList; exports.isSameClient = isSameClient; exports.clientFromResolution = clientFromResolution; exports.Conn = Conn; exports.answerPipelineClient = answerPipelineClient; exports.DeferredTransport = DeferredTransport;