32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { Handle, Ref } from 'actor';
|
|
import { Record, Value } from 'preserves';
|
|
|
|
export const _Assert = Symbol.for('assert');
|
|
export const Assert = Record.makeConstructor<{assertion: Value<WireRef>, handle: Handle}, WireRef>()(
|
|
_Assert, ['assertion', 'handle']);
|
|
|
|
export const _Retract = Symbol.for('retract');
|
|
export const Retract = Record.makeConstructor<{handle: Handle}, WireRef>()(
|
|
_Retract, ['handle']);
|
|
|
|
export const _Message = Symbol.for('message');
|
|
export const Message = Record.makeConstructor<{body: Value<WireRef>}, WireRef>()(
|
|
_Message, ['body']);
|
|
|
|
export const _Sync = Symbol.for('sync');
|
|
export const Sync = Record.makeConstructor<{peer: WireRef}, WireRef>()(
|
|
_Sync, ['peer']);
|
|
|
|
export type EntityMessage =
|
|
| Record<typeof _Assert, [Value<WireRef>, Handle], WireRef>
|
|
| Record<typeof _Retract, [Handle], WireRef>
|
|
| Record<typeof _Message, [Value<WireRef>], WireRef>
|
|
| Record<typeof _Sync, [WireRef], WireRef>;
|
|
|
|
export type TurnMessage = Array<[Oid, EntityMessage]>;
|
|
|
|
export type Oid = number;
|
|
export type RefLocation = "mine" | "your";
|
|
export type WireRef = { loc: RefLocation, oid: Oid };
|
|
export type WireSymbol = { name: WireRef, ref: Ref, count: number };
|