@y/y
Version:
Shared Editing Library
171 lines • 6.67 kB
TypeScript
export * from "../src/index.js";
export let useV2: boolean;
export namespace encV1 {
let encodeStateAsUpdate: (doc: Y.Doc, encodedTargetStateVector?: Uint8Array) => Uint8Array<ArrayBuffer>;
let mergeUpdates: (updates: Array<Uint8Array<ArrayBuffer>>) => Uint8Array<ArrayBuffer>;
let applyUpdate: (ydoc: Y.Doc, update: Uint8Array, transactionOrigin?: any) => void;
let logUpdate: (update: Uint8Array) => void;
let updateEventName: "update";
let diffUpdate: (update: Uint8Array<ArrayBuffer>, sv: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>;
}
export namespace encV2 {
let encodeStateAsUpdate_1: (doc: Y.Doc, encodedTargetStateVector?: Uint8Array, encoder?: Y.UpdateEncoderV1 | Y.UpdateEncoderV2) => Uint8Array<ArrayBuffer>;
export { encodeStateAsUpdate_1 as encodeStateAsUpdate };
let mergeUpdates_1: (updates: Array<Uint8Array<ArrayBuffer>>, YDecoder?: typeof Y.UpdateDecoderV1 | typeof Y.UpdateDecoderV2, YEncoder?: typeof Y.UpdateEncoderV1 | typeof Y.UpdateEncoderV2) => Uint8Array<ArrayBuffer>;
export { mergeUpdates_1 as mergeUpdates };
let applyUpdate_1: (ydoc: Y.Doc, update: Uint8Array, transactionOrigin?: any, YDecoder?: typeof Y.UpdateDecoderV1 | typeof Y.UpdateDecoderV2) => void;
export { applyUpdate_1 as applyUpdate };
let logUpdate_1: (update: Uint8Array, YDecoder?: typeof Y.UpdateDecoderV2 | typeof Y.UpdateDecoderV1) => void;
export { logUpdate_1 as logUpdate };
let updateEventName_1: "updateV2";
export { updateEventName_1 as updateEventName };
let diffUpdate_1: (update: Uint8Array, sv: Uint8Array, YDecoder?: typeof Y.UpdateDecoderV1 | typeof Y.UpdateDecoderV2, YEncoder?: typeof Y.UpdateEncoderV1 | typeof Y.UpdateEncoderV2) => Uint8Array<ArrayBuffer>;
export { diffUpdate_1 as diffUpdate };
}
export namespace enc { }
/**
* @extends {Y.Doc}
*/
export class TestYInstance extends Y.Doc {
/**
* @param {TestConnector} testConnector
* @param {number} clientID
*/
constructor(testConnector: TestConnector, clientID: number);
userID: number;
/**
* @type {TestConnector}
*/
tc: TestConnector;
/**
* @type {Map<TestYInstance, Array<Uint8Array>>}
*/
receiving: Map<TestYInstance, Array<Uint8Array>>;
/**
* The list of received updates.
* We are going to merge them later using Y.mergeUpdates and check if the resulting document is correct.
* @type {Array<Uint8Array<ArrayBuffer>>}
*/
updates: Array<Uint8Array<ArrayBuffer>>;
/**
* Disconnect from TestConnector.
*/
disconnect(): void;
/**
* Append yourself to the list of known Y instances in testconnector.
* Also initiate sync with all clients.
*/
connect(): void;
/**
* Receive a message from another client. This message is only appended to the list of receiving messages.
* TestConnector decides when this client actually reads this message.
*
* @param {Uint8Array} message
* @param {TestYInstance} remoteClient
*/
_receive(message: Uint8Array, remoteClient: TestYInstance): void;
}
/**
* Keeps track of TestYInstances.
*
* The TestYInstances add/remove themselves from the list of connections maiained in this object.
* I think it makes sense. Deal with it.
*/
export class TestConnector {
/**
* @param {prng.PRNG} gen
*/
constructor(gen: prng.PRNG);
/**
* @type {Set<TestYInstance>}
*/
allConns: Set<TestYInstance>;
/**
* @type {Set<TestYInstance>}
*/
onlineConns: Set<TestYInstance>;
/**
* @type {prng.PRNG}
*/
prng: prng.PRNG;
/**
* Create a new Y instance and add it to the list of connections
* @param {number} clientID
*/
createY(clientID: number): TestYInstance;
/**
* Choose random connection and flush a random message from a random sender.
*
* If this function was unable to flush a message, because there are no more messages to flush, it returns false. true otherwise.
* @return {boolean}
*/
flushRandomMessage(): boolean;
/**
* @return {boolean} True iff this function actually flushed something
*/
flushAllMessages(): boolean;
reconnectAll(): void;
disconnectAll(): void;
syncAll(): void;
/**
* @return {boolean} Whether it was possible to disconnect a random connection.
*/
disconnectRandom(): boolean;
/**
* @return {boolean} Whether it was possible to reconnect a random connection.
*/
reconnectRandom(): boolean;
}
export function init<T>(tc: t.TestCase, { users }?: {
users?: number;
}, initTestObject?: InitTestObjectCallback<T>): {
testObjects: Array<any>;
testConnector: TestConnector;
users: Array<TestYInstance>;
array0: Y.Type<any>;
array1: Y.Type<any>;
array2: Y.Type<any>;
map0: Y.Type<any>;
map1: Y.Type<any>;
map2: Y.Type<any>;
map3: Y.Type<any>;
text0: Y.Type;
text1: Y.Type;
text2: Y.Type;
xml0: Y.Type;
xml1: Y.Type;
xml2: Y.Type;
};
export function compareIdSets(idSet1: Y.IdSet, idSet2: Y.IdSet): boolean;
export function _idmapAttrsEqual<T>(a: Array<Y.ContentAttribute<T>>, b: Array<Y.ContentAttribute<T>>): boolean;
export function validateIdMap<T>(idmap: Y.IdMap<T>): void;
export function compareIdmaps<T>(idmap1: Y.IdMap<T>, idmap2: Y.IdMap<T>): void;
export function createRandomIdSet(gen: prng.PRNG, clients: number, clockRange: number): Y.IdSet;
export function createRandomIdMap<T>(gen: prng.PRNG, clients: number, clockRange: number, attrChoices: Array<T>): Y.IdMap<T>;
export function compare(users: Array<TestYInstance>): void;
export function compareItemIDs(a: Y.Item | null, b: Y.Item | null): boolean;
export function compareStructStores(ss1: StructStore, ss2: StructStore): undefined;
export function applyRandomTests<T>(tc: t.TestCase, mods: Array<(arg0: Y.Doc, arg1: prng.PRNG, arg2: T) => void>, iterations: number, initTestObject?: InitTestObjectCallback<T>): {
testObjects: Array<any>;
testConnector: TestConnector;
users: Array<TestYInstance>;
array0: Y.Type<any>;
array1: Y.Type<any>;
array2: Y.Type<any>;
map0: Y.Type<any>;
map1: Y.Type<any>;
map2: Y.Type<any>;
map3: Y.Type<any>;
text0: Y.Type;
text1: Y.Type;
text2: Y.Type;
xml0: Y.Type;
xml1: Y.Type;
xml2: Y.Type;
};
export type InitTestObjectCallback<T> = (y: TestYInstance) => T;
export type ApplyRandomTestsResult = ReturnType<typeof applyRandomTests>;
import * as Y from '../src/index.js';
import * as prng from 'lib0/prng';
import * as t from 'lib0/testing';
//# sourceMappingURL=testHelper.d.ts.map