@stryke/capnp
Version:
A package to assist in running the Cap'n Proto compiler and creating Cap'n Proto serialization protocol schemas.
172 lines (150 loc) • 5.64 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); var _class; var _class2; var _class3; var _class4;
var _chunk3Y2DQ67Zcjs = require('./chunk-3Y2DQ67Z.cjs');
var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
// schemas/persistent.ts
var _capnpFileId = BigInt("0xb8630836983feed7");
var Persistent_SaveParams = (_class = class extends _chunk3Y2DQ67Zcjs.Struct {
static {
_chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent_SaveParams");
}
static __initStatic() {this._capnp = {
displayName: "SaveParams",
id: "f76fba59183073a5",
size: new (0, _chunk3Y2DQ67Zcjs.ObjectSize)(0, 1)
}}
_adoptSealFor(value) {
_chunk3Y2DQ67Zcjs.utils.adopt(value, _chunk3Y2DQ67Zcjs.utils.getPointer(0, this));
}
_disownSealFor() {
return _chunk3Y2DQ67Zcjs.utils.disown(this.sealFor);
}
/**
* Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
* to mitigate damage when a SturdyRef is leaked. See comments above.
*
* Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
* realm does allow a null owner, this should indicate that anyone is allowed to restore the
* ref.
*
*/
get sealFor() {
return _chunk3Y2DQ67Zcjs.utils.getPointer(0, this);
}
_hasSealFor() {
return !_chunk3Y2DQ67Zcjs.utils.isNull(_chunk3Y2DQ67Zcjs.utils.getPointer(0, this));
}
set sealFor(value) {
_chunk3Y2DQ67Zcjs.utils.copyFrom(value, _chunk3Y2DQ67Zcjs.utils.getPointer(0, this));
}
toString() {
return "Persistent_SaveParams_" + super.toString();
}
}, _class.__initStatic(), _class);
var Persistent_SaveResults = (_class2 = class extends _chunk3Y2DQ67Zcjs.Struct {
static {
_chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent_SaveResults");
}
static __initStatic2() {this._capnp = {
displayName: "SaveResults",
id: "b76848c18c40efbf",
size: new (0, _chunk3Y2DQ67Zcjs.ObjectSize)(0, 1)
}}
_adoptSturdyRef(value) {
_chunk3Y2DQ67Zcjs.utils.adopt(value, _chunk3Y2DQ67Zcjs.utils.getPointer(0, this));
}
_disownSturdyRef() {
return _chunk3Y2DQ67Zcjs.utils.disown(this.sturdyRef);
}
get sturdyRef() {
return _chunk3Y2DQ67Zcjs.utils.getPointer(0, this);
}
_hasSturdyRef() {
return !_chunk3Y2DQ67Zcjs.utils.isNull(_chunk3Y2DQ67Zcjs.utils.getPointer(0, this));
}
set sturdyRef(value) {
_chunk3Y2DQ67Zcjs.utils.copyFrom(value, _chunk3Y2DQ67Zcjs.utils.getPointer(0, this));
}
toString() {
return "Persistent_SaveResults_" + super.toString();
}
}, _class2.__initStatic2(), _class2);
var Persistent_SaveResults$Promise = class {
static {
_chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent_SaveResults$Promise");
}
constructor(pipeline) {
this.pipeline = pipeline;
}
async promise() {
return await this.pipeline.struct();
}
};
var Persistent$Client = (_class3 = class _Persistent$Client {
static {
_chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent$Client");
}
static __initStatic3() {this.interfaceId = BigInt("0xc8cb212fcd9f5691")}
constructor(client) {
this.client = client;
}
static __initStatic4() {this.methods = [
{
ParamsClass: Persistent_SaveParams,
ResultsClass: Persistent_SaveResults,
interfaceId: _Persistent$Client.interfaceId,
methodId: 0,
interfaceName: "packages/capnp/schemas/persistent.capnp:Persistent",
methodName: "save"
}
]}
/**
* Save a capability persistently so that it can be restored by a future connection. Not all
* capabilities can be saved -- application interfaces should define which capabilities support
* this and which do not.
*
*/
save(paramsFunc) {
const answer = this.client.call({
method: _Persistent$Client.methods[0],
paramsFunc
});
const pipeline = new (0, _chunk3Y2DQ67Zcjs.Pipeline)(Persistent_SaveResults, answer);
return new Persistent_SaveResults$Promise(pipeline);
}
}, _class3.__initStatic3(), _class3.__initStatic4(), _class3);
_chunk3Y2DQ67Zcjs.Registry.register(Persistent$Client.interfaceId, Persistent$Client);
var Persistent$Server = class extends _chunk3Y2DQ67Zcjs.Server {
static {
_chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent$Server");
}
constructor(target) {
super(target, [
{
...Persistent$Client.methods[0],
impl: target.save
}
]);
this.target = target;
}
client() {
return new Persistent$Client(this);
}
};
var Persistent = (_class4 = class extends _chunk3Y2DQ67Zcjs.Interface {
static {
_chunkUSNT2KNTcjs.__name.call(void 0, this, "Persistent");
}
static __initStatic5() {this.SaveParams = Persistent_SaveParams}
static __initStatic6() {this.SaveResults = Persistent_SaveResults}
static __initStatic7() {this.Client = Persistent$Client}
static __initStatic8() {this.Server = Persistent$Server}
static __initStatic9() {this._capnp = {
displayName: "Persistent",
id: "c8cb212fcd9f5691",
size: new (0, _chunk3Y2DQ67Zcjs.ObjectSize)(0, 0)
}}
toString() {
return "Persistent_" + super.toString();
}
}, _class4.__initStatic5(), _class4.__initStatic6(), _class4.__initStatic7(), _class4.__initStatic8(), _class4.__initStatic9(), _class4);
exports.Persistent = Persistent; exports.Persistent$Client = Persistent$Client; exports.Persistent$Server = Persistent$Server; exports.Persistent_SaveParams = Persistent_SaveParams; exports.Persistent_SaveResults = Persistent_SaveResults; exports.Persistent_SaveResults$Promise = Persistent_SaveResults$Promise; exports._capnpFileId = _capnpFileId;