novy-syndicate/src/gen/box-protocol.ts

64 lines
2.0 KiB
TypeScript

import * as _ from "@preserves/core";
import * as _i_Actor from "../runtime/actor";
export const $BoxState = Symbol.for("BoxState");
export const $SetBox = Symbol.for("SetBox");
export type _embedded = _i_Actor.Ref;
export type _val = _.Value<_embedded>;
export type BoxState = {"value": number};
export type SetBox = {"value": number};
export function BoxState(value: number): BoxState {return {"value": value};}
export function SetBox(value: number): SetBox {return {"value": value};}
export function asBoxState(v: _val): BoxState {
let result = toBoxState(v);
if (result === void 0) throw new TypeError(`Invalid BoxState: ${_.stringify(v)}`);
return result;
}
export function toBoxState(v: _val): undefined | BoxState {
let result: undefined | BoxState;
if (_.Record.isRecord<_val, _.Tuple<_val>, _embedded>(v)) {
let _tmp0: (null) | undefined;
_tmp0 = _.is(v.label, $BoxState) ? null : void 0;
if (_tmp0 !== void 0) {
let _tmp1: (number) | undefined;
_tmp1 = typeof v[0] === 'number' ? v[0] : void 0;
if (_tmp1 !== void 0) {result = {"value": _tmp1};};
};
};
return result;
}
export function fromBoxState(_v: BoxState): _val {return _.Record($BoxState, [_v["value"]]);}
export function asSetBox(v: _val): SetBox {
let result = toSetBox(v);
if (result === void 0) throw new TypeError(`Invalid SetBox: ${_.stringify(v)}`);
return result;
}
export function toSetBox(v: _val): undefined | SetBox {
let result: undefined | SetBox;
if (_.Record.isRecord<_val, _.Tuple<_val>, _embedded>(v)) {
let _tmp0: (null) | undefined;
_tmp0 = _.is(v.label, $SetBox) ? null : void 0;
if (_tmp0 !== void 0) {
let _tmp1: (number) | undefined;
_tmp1 = typeof v[0] === 'number' ? v[0] : void 0;
if (_tmp1 !== void 0) {result = {"value": _tmp1};};
};
};
return result;
}
export function fromSetBox(_v: SetBox): _val {return _.Record($SetBox, [_v["value"]]);}