@stryke/capnp 0.6.3 → 0.8.0

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