@coast-team/mute-core
Advanced tools
Comparing version 10.0.0-experiment-3.2 to 10.0.0-experiment-3.3
@@ -5,2 +5,21 @@ # Change Log | ||
<a name="10.0.0-experiment-3.3"></a> | ||
# [10.0.0-experiment-3.3](https://github.com/coast-team/mute-core/compare/v10.0.0-experiment-3.2...v10.0.0-experiment-3.3) (2019-12-19) | ||
### Bug Fixes | ||
* **rename:** share rename operations to other nodes ([ac0d64f](https://github.com/coast-team/mute-core/commit/ac0d64f)) | ||
* **rls-richoperation:** check that dependencies is a map int -> int ([cb436ef](https://github.com/coast-team/mute-core/commit/cb436ef)) | ||
### Features | ||
* **crdt-impl:** add RLSDocument ([0c2510c](https://github.com/coast-team/mute-core/commit/0c2510c)) | ||
* **renamablelogootsplit:** add RLSRichOperation ([92fcbe8](https://github.com/coast-team/mute-core/commit/92fcbe8)) | ||
* **renamablelogootsplit:** add RLSState ([70a4a1e](https://github.com/coast-team/mute-core/commit/70a4a1e)) | ||
* **renamablelogootsplit:** add support ([2e7abf4](https://github.com/coast-team/mute-core/commit/2e7abf4)) | ||
<a name="10.0.0-experiment-3.2"></a> | ||
@@ -7,0 +26,0 @@ # [10.0.0-experiment-3.2](https://github.com/coast-team/mute-core/compare/v10.0.0-2.2...v10.0.0-experiment-3.2) (2019-09-25) |
@@ -56,7 +56,7 @@ import { Observable, Subject } from 'rxjs'; | ||
abstract computeDependencies(operation: Op): Map<number, number>; | ||
protected updateState(richOp: RichOperation<Op>): void; | ||
private applyRichOperations; | ||
private bufferOperation; | ||
private updateState; | ||
private isDeliverable; | ||
private hasDeliveredDependencies; | ||
} |
@@ -9,2 +9,3 @@ import { Observable, Subject } from 'rxjs'; | ||
import { LSDocService, LSState } from './LogootSplit'; | ||
import { RLSDocService, RLSState } from './RenamableLogootSplit'; | ||
import { Strategy } from './Strategy'; | ||
@@ -16,2 +17,3 @@ export declare type DocServiceStrategyMethod<Seq, Op> = (strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: StateTypes, collaboratorService: CollaboratorsService) => DocService<Seq, Op>; | ||
static createDocService(strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: FIFODLSState, collaboratorService: CollaboratorsService): FIFODLSDocService; | ||
static createDocService(strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: RLSState, collaboratorService: CollaboratorsService): RLSDocService; | ||
} |
@@ -6,8 +6,9 @@ import { SafeAny } from 'safe-any'; | ||
import { LSState } from './LogootSplit/LSState'; | ||
import { RLSState } from './RenamableLogootSplit'; | ||
import { Strategy } from './Strategy'; | ||
export declare type StateTypes = LSState | DLSState | FIFODLSState; | ||
export declare type StateTypes = LSState | DLSState | FIFODLSState | RLSState; | ||
export declare class StateStrategy { | ||
static fromPlain<Seq, Op>(strat: Strategy, o: SafeAny<StateJSON<Seq, Op>>): LSState | DLSState | FIFODLSState | null; | ||
static emptyState(strat: Strategy): LSState | DLSState | FIFODLSState | null; | ||
static fromPlain<Seq, Op>(strat: Strategy, o: SafeAny<StateJSON<Seq, Op>>): LSState | DLSState | FIFODLSState | RLSState | null; | ||
static emptyState(strat: Strategy): LSState | DLSState | FIFODLSState | RLSState | null; | ||
static getStr(state: StateTypes): string | undefined; | ||
} |
export declare enum Strategy { | ||
LOGOOTSPLIT = 100, | ||
DOTTEDLOGOOTSPLIT = 101, | ||
FIFODOTTEDLOGOOTSPLIT = 102 | ||
FIFODOTTEDLOGOOTSPLIT = 102, | ||
RENAMABLELOGOOTSPLIT = 103 | ||
} |
import { DeltaEditableReplicatedList, SimpleDotPos } from 'dotted-logootsplit'; | ||
import { OpEditableReplicatedList } from 'dotted-logootsplit/dist/types/core/op-replicated-list'; | ||
import { LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs'; | ||
import { LogootSOperation, LogootSRopes, RenamableListOperation, RenamableReplicableList, TextOperation } from 'mute-structs'; | ||
import { Observable } from 'rxjs'; | ||
@@ -14,3 +14,3 @@ import { ICollaborator } from './collaborators'; | ||
import { collaborator as proto } from './proto'; | ||
export declare type MuteCoreTypes = MuteCore<LogootSRopes, LogootSOperation> | MuteCore<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation> | MuteCore<DeltaEditableReplicatedList<SimpleDotPos, string>, BlockOperation>; | ||
export declare type MuteCoreTypes = MuteCore<LogootSRopes, LogootSOperation> | MuteCore<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation> | MuteCore<DeltaEditableReplicatedList<SimpleDotPos, string>, BlockOperation> | MuteCore<RenamableReplicableList, RenamableListOperation>; | ||
export interface SessionParameters { | ||
@@ -17,0 +17,0 @@ strategy: Strategy; |
@@ -13,2 +13,5 @@ import * as $protobuf from "protobufjs"; | ||
richDottedLogootsOpsMsg?: (sync.IRichDottedLogootSOperationMsg|null); | ||
/** RichOperationMsg richRenamableLogootSOpMsg */ | ||
richRenamableLogootSOpMsg?: (sync.IRichRenamableLogootSOperationMsg|null); | ||
} | ||
@@ -31,4 +34,7 @@ | ||
/** RichOperationMsg richRenamableLogootSOpMsg. */ | ||
public richRenamableLogootSOpMsg?: (sync.IRichRenamableLogootSOperationMsg|null); | ||
/** RichOperationMsg type. */ | ||
public type?: ("richLogootSOpsMsg"|"richDottedLogootsOpsMsg"); | ||
public type?: ("richLogootSOpsMsg"|"richDottedLogootsOpsMsg"|"richRenamableLogootSOpMsg"); | ||
@@ -876,2 +882,347 @@ /** | ||
} | ||
/** Properties of a RichRenamableLogootSOperationMsg. */ | ||
interface IRichRenamableLogootSOperationMsg { | ||
/** RichRenamableLogootSOperationMsg id */ | ||
id?: (number|null); | ||
/** RichRenamableLogootSOperationMsg clock */ | ||
clock?: (number|null); | ||
/** RichRenamableLogootSOperationMsg dependencies */ | ||
dependencies?: ({ [k: string]: number }|null); | ||
/** RichRenamableLogootSOperationMsg renamableLogootSAdd */ | ||
renamableLogootSAdd?: (sync.IRenamableLogootSAddMsg|null); | ||
/** RichRenamableLogootSOperationMsg renamableLogootSDel */ | ||
renamableLogootSDel?: (sync.IRenamableLogootSDelMsg|null); | ||
/** RichRenamableLogootSOperationMsg logootSRename */ | ||
logootSRename?: (sync.ILogootSRenameMsg|null); | ||
} | ||
/** Represents a RichRenamableLogootSOperationMsg. */ | ||
class RichRenamableLogootSOperationMsg implements IRichRenamableLogootSOperationMsg { | ||
/** | ||
* Constructs a new RichRenamableLogootSOperationMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRichRenamableLogootSOperationMsg); | ||
/** RichRenamableLogootSOperationMsg id. */ | ||
public id: number; | ||
/** RichRenamableLogootSOperationMsg clock. */ | ||
public clock: number; | ||
/** RichRenamableLogootSOperationMsg dependencies. */ | ||
public dependencies: { [k: string]: number }; | ||
/** RichRenamableLogootSOperationMsg renamableLogootSAdd. */ | ||
public renamableLogootSAdd?: (sync.IRenamableLogootSAddMsg|null); | ||
/** RichRenamableLogootSOperationMsg renamableLogootSDel. */ | ||
public renamableLogootSDel?: (sync.IRenamableLogootSDelMsg|null); | ||
/** RichRenamableLogootSOperationMsg logootSRename. */ | ||
public logootSRename?: (sync.ILogootSRenameMsg|null); | ||
/** RichRenamableLogootSOperationMsg type. */ | ||
public type?: ("renamableLogootSAdd"|"renamableLogootSDel"|"logootSRename"); | ||
/** | ||
* Creates a new RichRenamableLogootSOperationMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RichRenamableLogootSOperationMsg instance | ||
*/ | ||
public static create(properties?: sync.IRichRenamableLogootSOperationMsg): sync.RichRenamableLogootSOperationMsg; | ||
/** | ||
* Encodes the specified RichRenamableLogootSOperationMsg message. Does not implicitly {@link sync.RichRenamableLogootSOperationMsg.verify|verify} messages. | ||
* @param message RichRenamableLogootSOperationMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRichRenamableLogootSOperationMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RichRenamableLogootSOperationMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RichRenamableLogootSOperationMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.RichRenamableLogootSOperationMsg; | ||
} | ||
/** Properties of an EpochMsg. */ | ||
interface IEpochMsg { | ||
/** EpochMsg id */ | ||
id?: (sync.IEpochIdMsg|null); | ||
/** EpochMsg parentId */ | ||
parentId?: (sync.IEpochIdMsg|null); | ||
} | ||
/** Represents an EpochMsg. */ | ||
class EpochMsg implements IEpochMsg { | ||
/** | ||
* Constructs a new EpochMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IEpochMsg); | ||
/** EpochMsg id. */ | ||
public id?: (sync.IEpochIdMsg|null); | ||
/** EpochMsg parentId. */ | ||
public parentId?: (sync.IEpochIdMsg|null); | ||
/** | ||
* Creates a new EpochMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns EpochMsg instance | ||
*/ | ||
public static create(properties?: sync.IEpochMsg): sync.EpochMsg; | ||
/** | ||
* Encodes the specified EpochMsg message. Does not implicitly {@link sync.EpochMsg.verify|verify} messages. | ||
* @param message EpochMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IEpochMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes an EpochMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns EpochMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.EpochMsg; | ||
} | ||
/** Properties of an EpochIdMsg. */ | ||
interface IEpochIdMsg { | ||
/** EpochIdMsg replicaNumber */ | ||
replicaNumber?: (number|null); | ||
/** EpochIdMsg epochNumber */ | ||
epochNumber?: (number|null); | ||
} | ||
/** Represents an EpochIdMsg. */ | ||
class EpochIdMsg implements IEpochIdMsg { | ||
/** | ||
* Constructs a new EpochIdMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IEpochIdMsg); | ||
/** EpochIdMsg replicaNumber. */ | ||
public replicaNumber: number; | ||
/** EpochIdMsg epochNumber. */ | ||
public epochNumber: number; | ||
/** | ||
* Creates a new EpochIdMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns EpochIdMsg instance | ||
*/ | ||
public static create(properties?: sync.IEpochIdMsg): sync.EpochIdMsg; | ||
/** | ||
* Encodes the specified EpochIdMsg message. Does not implicitly {@link sync.EpochIdMsg.verify|verify} messages. | ||
* @param message EpochIdMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IEpochIdMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes an EpochIdMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns EpochIdMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.EpochIdMsg; | ||
} | ||
/** Properties of a RenamableLogootSAddMsg. */ | ||
interface IRenamableLogootSAddMsg { | ||
/** RenamableLogootSAddMsg op */ | ||
op?: (sync.ILogootSAddMsg|null); | ||
/** RenamableLogootSAddMsg epoch */ | ||
epoch?: (sync.IEpochMsg|null); | ||
} | ||
/** Represents a RenamableLogootSAddMsg. */ | ||
class RenamableLogootSAddMsg implements IRenamableLogootSAddMsg { | ||
/** | ||
* Constructs a new RenamableLogootSAddMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRenamableLogootSAddMsg); | ||
/** RenamableLogootSAddMsg op. */ | ||
public op?: (sync.ILogootSAddMsg|null); | ||
/** RenamableLogootSAddMsg epoch. */ | ||
public epoch?: (sync.IEpochMsg|null); | ||
/** | ||
* Creates a new RenamableLogootSAddMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RenamableLogootSAddMsg instance | ||
*/ | ||
public static create(properties?: sync.IRenamableLogootSAddMsg): sync.RenamableLogootSAddMsg; | ||
/** | ||
* Encodes the specified RenamableLogootSAddMsg message. Does not implicitly {@link sync.RenamableLogootSAddMsg.verify|verify} messages. | ||
* @param message RenamableLogootSAddMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRenamableLogootSAddMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RenamableLogootSAddMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RenamableLogootSAddMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.RenamableLogootSAddMsg; | ||
} | ||
/** Properties of a RenamableLogootSDelMsg. */ | ||
interface IRenamableLogootSDelMsg { | ||
/** RenamableLogootSDelMsg op */ | ||
op?: (sync.ILogootSDelMsg|null); | ||
/** RenamableLogootSDelMsg epoch */ | ||
epoch?: (sync.IEpochMsg|null); | ||
} | ||
/** Represents a RenamableLogootSDelMsg. */ | ||
class RenamableLogootSDelMsg implements IRenamableLogootSDelMsg { | ||
/** | ||
* Constructs a new RenamableLogootSDelMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRenamableLogootSDelMsg); | ||
/** RenamableLogootSDelMsg op. */ | ||
public op?: (sync.ILogootSDelMsg|null); | ||
/** RenamableLogootSDelMsg epoch. */ | ||
public epoch?: (sync.IEpochMsg|null); | ||
/** | ||
* Creates a new RenamableLogootSDelMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RenamableLogootSDelMsg instance | ||
*/ | ||
public static create(properties?: sync.IRenamableLogootSDelMsg): sync.RenamableLogootSDelMsg; | ||
/** | ||
* Encodes the specified RenamableLogootSDelMsg message. Does not implicitly {@link sync.RenamableLogootSDelMsg.verify|verify} messages. | ||
* @param message RenamableLogootSDelMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRenamableLogootSDelMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RenamableLogootSDelMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RenamableLogootSDelMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.RenamableLogootSDelMsg; | ||
} | ||
/** Properties of a LogootSRenameMsg. */ | ||
interface ILogootSRenameMsg { | ||
/** LogootSRenameMsg replicaNumber */ | ||
replicaNumber?: (number|null); | ||
/** LogootSRenameMsg clock */ | ||
clock?: (number|null); | ||
/** LogootSRenameMsg renamedIdIntervals */ | ||
renamedIdIntervals?: (sync.IIdentifierIntervalMsg[]|null); | ||
/** LogootSRenameMsg epoch */ | ||
epoch?: (sync.IEpochMsg|null); | ||
} | ||
/** Represents a LogootSRenameMsg. */ | ||
class LogootSRenameMsg implements ILogootSRenameMsg { | ||
/** | ||
* Constructs a new LogootSRenameMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.ILogootSRenameMsg); | ||
/** LogootSRenameMsg replicaNumber. */ | ||
public replicaNumber: number; | ||
/** LogootSRenameMsg clock. */ | ||
public clock: number; | ||
/** LogootSRenameMsg renamedIdIntervals. */ | ||
public renamedIdIntervals: sync.IIdentifierIntervalMsg[]; | ||
/** LogootSRenameMsg epoch. */ | ||
public epoch?: (sync.IEpochMsg|null); | ||
/** | ||
* Creates a new LogootSRenameMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns LogootSRenameMsg instance | ||
*/ | ||
public static create(properties?: sync.ILogootSRenameMsg): sync.LogootSRenameMsg; | ||
/** | ||
* Encodes the specified LogootSRenameMsg message. Does not implicitly {@link sync.LogootSRenameMsg.verify|verify} messages. | ||
* @param message LogootSRenameMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.ILogootSRenameMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a LogootSRenameMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns LogootSRenameMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.LogootSRenameMsg; | ||
} | ||
} | ||
@@ -878,0 +1229,0 @@ |
export { FIFODLSSync } from './FIFODLSSync'; | ||
export { LSSync } from './LSSync'; | ||
export { DLSSync } from './DLSSync'; | ||
export { RLSSync } from './RLSSync'; |
{ | ||
"name": "@coast-team/mute-core", | ||
"description": "Core component of MUTE collaborative editor", | ||
"version": "10.0.0-experiment-3.2", | ||
"version": "10.0.0-experiment-3.3", | ||
"main": "./dist/mute-core.node.es5.cjs.js", | ||
@@ -56,3 +56,3 @@ "module": "./dist/mutecore.node.es5.esm.js", | ||
"dotted-logootsplit": "^0.3.0", | ||
"mute-structs": "^1.1.0", | ||
"mute-structs": "^2.0.0-7", | ||
"rxjs": "^6.5.2", | ||
@@ -59,0 +59,0 @@ "safe-any": "^1.0.2" |
@@ -180,2 +180,9 @@ import { Observable, Subject } from 'rxjs' | ||
protected updateState(richOp: RichOperation<Op>) { | ||
console.assert(this.isDeliverable(richOp)) | ||
const { id, clock } = richOp | ||
this.vector.set(id, clock) | ||
this.richOperations.push(richOp) | ||
} | ||
private applyRichOperations(richOps: Array<RichOperation<Op>>) { | ||
@@ -229,9 +236,2 @@ setTimeout(() => { | ||
private updateState(richOp: RichOperation<Op>) { | ||
console.assert(this.isDeliverable(richOp)) | ||
const { id, clock } = richOp | ||
this.vector.set(id, clock) | ||
this.richOperations.push(richOp) | ||
} | ||
private isDeliverable({ id, clock, dependencies }: RichOperation<Op>) { | ||
@@ -238,0 +238,0 @@ return this.vector.isDeliverable(id, clock) && this.hasDeliveredDependencies(dependencies) |
@@ -6,3 +6,3 @@ import { Observable, Subject } from 'rxjs' | ||
import { IMessageIn, IMessageOut } from '../misc' | ||
import { DLSSync, FIFODLSSync, LSSync } from '../syncImpl' | ||
import { DLSSync, FIFODLSSync, LSSync, RLSSync } from '../syncImpl' | ||
import { DLSDocService, DLSDocument, DLSState, DLSSyncMessage } from './DottedLogootSplit' | ||
@@ -16,2 +16,3 @@ import { | ||
import { LSDocService, LSDocument, LSState, LSSyncMessage } from './LogootSplit' | ||
import { RLSDocService, RLSDocument, RLSState, RLSSyncMessage } from './RenamableLogootSplit' | ||
import { Strategy } from './Strategy' | ||
@@ -53,2 +54,10 @@ | ||
): FIFODLSDocService | ||
static createDocService( | ||
strat: Strategy, | ||
messageIn$: Observable<IMessageIn>, | ||
messageOut$: Subject<IMessageOut>, | ||
id: number, | ||
state: RLSState, | ||
collaboratorService: CollaboratorsService | ||
): RLSDocService | ||
static createDocService<Seq, Op>( | ||
@@ -61,3 +70,3 @@ strat: Strategy, | ||
collaboratorService: CollaboratorsService | ||
): LSDocService | DLSDocService | FIFODLSDocService { | ||
): LSDocService | DLSDocService | FIFODLSDocService | RLSDocService { | ||
switch (strat) { | ||
@@ -103,7 +112,23 @@ case Strategy.LOGOOTSPLIT: | ||
collaboratorService | ||
) | ||
const syncMessage = new FIFODLSSyncMessage(messageIn$, messageOut$) | ||
return new FIFODLSDocService(id, collaboratorService, document, sync, syncMessage) | ||
} else { | ||
throw new Error('State is not an instanceof DLSState') | ||
} | ||
case Strategy.RENAMABLELOGOOTSPLIT: | ||
if (state instanceof RLSState) { | ||
const document = new RLSDocument(state.sequenceCRDT) | ||
const sync = new RLSSync( | ||
id, | ||
state.networkClock, | ||
state.vector, | ||
state.remoteOperations, | ||
collaboratorService, | ||
new Set() | ||
) | ||
const syncMessage = new FIFODLSSyncMessage(messageIn$, messageOut$) | ||
return new FIFODLSDocService(id, collaboratorService, document, sync, syncMessage) | ||
const syncMessage = new RLSSyncMessage(messageIn$, messageOut$) | ||
return new RLSDocService(id, collaboratorService, document, sync, syncMessage) | ||
} else { | ||
throw new Error('State is not an instanceof DLSState') | ||
throw new Error('State is not an instanceof RLSState') | ||
} | ||
@@ -110,0 +135,0 @@ default: |
@@ -34,7 +34,3 @@ import { LogootSOperation, LogootSRopes } from 'mute-structs' | ||
const vector = new Map(o.vector) | ||
const logootsRopes = LogootSRopes.fromPlain( | ||
o.sequenceCRDT.replicaNumber, | ||
o.sequenceCRDT.clock, | ||
o.sequenceCRDT | ||
) | ||
const logootsRopes = LogootSRopes.fromPlain(o.sequenceCRDT) | ||
if (!logootsRopes) { | ||
@@ -41,0 +37,0 @@ return null |
@@ -6,5 +6,6 @@ import { SafeAny } from 'safe-any' | ||
import { LSState } from './LogootSplit/LSState' | ||
import { RLSState } from './RenamableLogootSplit' | ||
import { Strategy } from './Strategy' | ||
export type StateTypes = LSState | DLSState | FIFODLSState | ||
export type StateTypes = LSState | DLSState | FIFODLSState | RLSState | ||
@@ -37,2 +38,5 @@ interface IStateFactory<T> { | ||
break | ||
case Strategy.RENAMABLELOGOOTSPLIT: | ||
state = createState(RLSState, o) | ||
break | ||
default: | ||
@@ -57,2 +61,5 @@ state = null | ||
break | ||
case Strategy.RENAMABLELOGOOTSPLIT: | ||
state = createEmptyState(RLSState) | ||
break | ||
default: | ||
@@ -66,3 +73,3 @@ state = null | ||
static getStr(state: StateTypes): string | undefined { | ||
if (state instanceof LSState) { | ||
if (state instanceof LSState || state instanceof RLSState) { | ||
return state.sequenceCRDT.str | ||
@@ -69,0 +76,0 @@ } else if (state instanceof DLSState) { |
@@ -5,2 +5,3 @@ export enum Strategy { | ||
FIFODOTTEDLOGOOTSPLIT, | ||
RENAMABLELOGOOTSPLIT, | ||
} |
import { DeltaEditableReplicatedList, SimpleDotPos } from 'dotted-logootsplit' | ||
import { OpEditableReplicatedList } from 'dotted-logootsplit/dist/types/core/op-replicated-list' | ||
import { LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs' | ||
import { | ||
LogootSOperation, | ||
LogootSRopes, | ||
RenamableListOperation, | ||
RenamableReplicableList, | ||
TextOperation, | ||
} from 'mute-structs' | ||
import { Observable, Subject } from 'rxjs' | ||
@@ -12,2 +18,3 @@ import { CollaboratorsService, ICollaborator } from './collaborators' | ||
import { LSDocService, LSState } from './crdtImpl/LogootSplit' | ||
import { RLSDocService, RLSState } from './crdtImpl/RenamableLogootSplit' | ||
import { | ||
@@ -30,2 +37,3 @@ FixDataState, | ||
| MuteCore<DeltaEditableReplicatedList<SimpleDotPos, string>, BlockOperation> | ||
| MuteCore<RenamableReplicableList, RenamableListOperation> | ||
@@ -275,4 +283,22 @@ export interface SessionParameters { | ||
) | ||
case Strategy.RENAMABLELOGOOTSPLIT: | ||
return new MuteCore<RenamableReplicableList, RenamableListOperation>( | ||
constructorParam, | ||
(strat, messageIn$, messageOut$, id, state, collaboratorService): RLSDocService => { | ||
if (state instanceof RLSState) { | ||
return DocServiceStrategy.createDocService( | ||
strat, | ||
messageIn$, | ||
messageOut$, | ||
id, | ||
state, | ||
collaboratorService | ||
) | ||
} else { | ||
throw new Error('') | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} |
@@ -13,2 +13,5 @@ import * as $protobuf from "protobufjs"; | ||
richDottedLogootsOpsMsg?: (sync.IRichDottedLogootSOperationMsg|null); | ||
/** RichOperationMsg richRenamableLogootSOpMsg */ | ||
richRenamableLogootSOpMsg?: (sync.IRichRenamableLogootSOperationMsg|null); | ||
} | ||
@@ -31,4 +34,7 @@ | ||
/** RichOperationMsg richRenamableLogootSOpMsg. */ | ||
public richRenamableLogootSOpMsg?: (sync.IRichRenamableLogootSOperationMsg|null); | ||
/** RichOperationMsg type. */ | ||
public type?: ("richLogootSOpsMsg"|"richDottedLogootsOpsMsg"); | ||
public type?: ("richLogootSOpsMsg"|"richDottedLogootsOpsMsg"|"richRenamableLogootSOpMsg"); | ||
@@ -876,2 +882,347 @@ /** | ||
} | ||
/** Properties of a RichRenamableLogootSOperationMsg. */ | ||
interface IRichRenamableLogootSOperationMsg { | ||
/** RichRenamableLogootSOperationMsg id */ | ||
id?: (number|null); | ||
/** RichRenamableLogootSOperationMsg clock */ | ||
clock?: (number|null); | ||
/** RichRenamableLogootSOperationMsg dependencies */ | ||
dependencies?: ({ [k: string]: number }|null); | ||
/** RichRenamableLogootSOperationMsg renamableLogootSAdd */ | ||
renamableLogootSAdd?: (sync.IRenamableLogootSAddMsg|null); | ||
/** RichRenamableLogootSOperationMsg renamableLogootSDel */ | ||
renamableLogootSDel?: (sync.IRenamableLogootSDelMsg|null); | ||
/** RichRenamableLogootSOperationMsg logootSRename */ | ||
logootSRename?: (sync.ILogootSRenameMsg|null); | ||
} | ||
/** Represents a RichRenamableLogootSOperationMsg. */ | ||
class RichRenamableLogootSOperationMsg implements IRichRenamableLogootSOperationMsg { | ||
/** | ||
* Constructs a new RichRenamableLogootSOperationMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRichRenamableLogootSOperationMsg); | ||
/** RichRenamableLogootSOperationMsg id. */ | ||
public id: number; | ||
/** RichRenamableLogootSOperationMsg clock. */ | ||
public clock: number; | ||
/** RichRenamableLogootSOperationMsg dependencies. */ | ||
public dependencies: { [k: string]: number }; | ||
/** RichRenamableLogootSOperationMsg renamableLogootSAdd. */ | ||
public renamableLogootSAdd?: (sync.IRenamableLogootSAddMsg|null); | ||
/** RichRenamableLogootSOperationMsg renamableLogootSDel. */ | ||
public renamableLogootSDel?: (sync.IRenamableLogootSDelMsg|null); | ||
/** RichRenamableLogootSOperationMsg logootSRename. */ | ||
public logootSRename?: (sync.ILogootSRenameMsg|null); | ||
/** RichRenamableLogootSOperationMsg type. */ | ||
public type?: ("renamableLogootSAdd"|"renamableLogootSDel"|"logootSRename"); | ||
/** | ||
* Creates a new RichRenamableLogootSOperationMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RichRenamableLogootSOperationMsg instance | ||
*/ | ||
public static create(properties?: sync.IRichRenamableLogootSOperationMsg): sync.RichRenamableLogootSOperationMsg; | ||
/** | ||
* Encodes the specified RichRenamableLogootSOperationMsg message. Does not implicitly {@link sync.RichRenamableLogootSOperationMsg.verify|verify} messages. | ||
* @param message RichRenamableLogootSOperationMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRichRenamableLogootSOperationMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RichRenamableLogootSOperationMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RichRenamableLogootSOperationMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.RichRenamableLogootSOperationMsg; | ||
} | ||
/** Properties of an EpochMsg. */ | ||
interface IEpochMsg { | ||
/** EpochMsg id */ | ||
id?: (sync.IEpochIdMsg|null); | ||
/** EpochMsg parentId */ | ||
parentId?: (sync.IEpochIdMsg|null); | ||
} | ||
/** Represents an EpochMsg. */ | ||
class EpochMsg implements IEpochMsg { | ||
/** | ||
* Constructs a new EpochMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IEpochMsg); | ||
/** EpochMsg id. */ | ||
public id?: (sync.IEpochIdMsg|null); | ||
/** EpochMsg parentId. */ | ||
public parentId?: (sync.IEpochIdMsg|null); | ||
/** | ||
* Creates a new EpochMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns EpochMsg instance | ||
*/ | ||
public static create(properties?: sync.IEpochMsg): sync.EpochMsg; | ||
/** | ||
* Encodes the specified EpochMsg message. Does not implicitly {@link sync.EpochMsg.verify|verify} messages. | ||
* @param message EpochMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IEpochMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes an EpochMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns EpochMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.EpochMsg; | ||
} | ||
/** Properties of an EpochIdMsg. */ | ||
interface IEpochIdMsg { | ||
/** EpochIdMsg replicaNumber */ | ||
replicaNumber?: (number|null); | ||
/** EpochIdMsg epochNumber */ | ||
epochNumber?: (number|null); | ||
} | ||
/** Represents an EpochIdMsg. */ | ||
class EpochIdMsg implements IEpochIdMsg { | ||
/** | ||
* Constructs a new EpochIdMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IEpochIdMsg); | ||
/** EpochIdMsg replicaNumber. */ | ||
public replicaNumber: number; | ||
/** EpochIdMsg epochNumber. */ | ||
public epochNumber: number; | ||
/** | ||
* Creates a new EpochIdMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns EpochIdMsg instance | ||
*/ | ||
public static create(properties?: sync.IEpochIdMsg): sync.EpochIdMsg; | ||
/** | ||
* Encodes the specified EpochIdMsg message. Does not implicitly {@link sync.EpochIdMsg.verify|verify} messages. | ||
* @param message EpochIdMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IEpochIdMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes an EpochIdMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns EpochIdMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.EpochIdMsg; | ||
} | ||
/** Properties of a RenamableLogootSAddMsg. */ | ||
interface IRenamableLogootSAddMsg { | ||
/** RenamableLogootSAddMsg op */ | ||
op?: (sync.ILogootSAddMsg|null); | ||
/** RenamableLogootSAddMsg epoch */ | ||
epoch?: (sync.IEpochMsg|null); | ||
} | ||
/** Represents a RenamableLogootSAddMsg. */ | ||
class RenamableLogootSAddMsg implements IRenamableLogootSAddMsg { | ||
/** | ||
* Constructs a new RenamableLogootSAddMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRenamableLogootSAddMsg); | ||
/** RenamableLogootSAddMsg op. */ | ||
public op?: (sync.ILogootSAddMsg|null); | ||
/** RenamableLogootSAddMsg epoch. */ | ||
public epoch?: (sync.IEpochMsg|null); | ||
/** | ||
* Creates a new RenamableLogootSAddMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RenamableLogootSAddMsg instance | ||
*/ | ||
public static create(properties?: sync.IRenamableLogootSAddMsg): sync.RenamableLogootSAddMsg; | ||
/** | ||
* Encodes the specified RenamableLogootSAddMsg message. Does not implicitly {@link sync.RenamableLogootSAddMsg.verify|verify} messages. | ||
* @param message RenamableLogootSAddMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRenamableLogootSAddMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RenamableLogootSAddMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RenamableLogootSAddMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.RenamableLogootSAddMsg; | ||
} | ||
/** Properties of a RenamableLogootSDelMsg. */ | ||
interface IRenamableLogootSDelMsg { | ||
/** RenamableLogootSDelMsg op */ | ||
op?: (sync.ILogootSDelMsg|null); | ||
/** RenamableLogootSDelMsg epoch */ | ||
epoch?: (sync.IEpochMsg|null); | ||
} | ||
/** Represents a RenamableLogootSDelMsg. */ | ||
class RenamableLogootSDelMsg implements IRenamableLogootSDelMsg { | ||
/** | ||
* Constructs a new RenamableLogootSDelMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRenamableLogootSDelMsg); | ||
/** RenamableLogootSDelMsg op. */ | ||
public op?: (sync.ILogootSDelMsg|null); | ||
/** RenamableLogootSDelMsg epoch. */ | ||
public epoch?: (sync.IEpochMsg|null); | ||
/** | ||
* Creates a new RenamableLogootSDelMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RenamableLogootSDelMsg instance | ||
*/ | ||
public static create(properties?: sync.IRenamableLogootSDelMsg): sync.RenamableLogootSDelMsg; | ||
/** | ||
* Encodes the specified RenamableLogootSDelMsg message. Does not implicitly {@link sync.RenamableLogootSDelMsg.verify|verify} messages. | ||
* @param message RenamableLogootSDelMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRenamableLogootSDelMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RenamableLogootSDelMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RenamableLogootSDelMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.RenamableLogootSDelMsg; | ||
} | ||
/** Properties of a LogootSRenameMsg. */ | ||
interface ILogootSRenameMsg { | ||
/** LogootSRenameMsg replicaNumber */ | ||
replicaNumber?: (number|null); | ||
/** LogootSRenameMsg clock */ | ||
clock?: (number|null); | ||
/** LogootSRenameMsg renamedIdIntervals */ | ||
renamedIdIntervals?: (sync.IIdentifierIntervalMsg[]|null); | ||
/** LogootSRenameMsg epoch */ | ||
epoch?: (sync.IEpochMsg|null); | ||
} | ||
/** Represents a LogootSRenameMsg. */ | ||
class LogootSRenameMsg implements ILogootSRenameMsg { | ||
/** | ||
* Constructs a new LogootSRenameMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.ILogootSRenameMsg); | ||
/** LogootSRenameMsg replicaNumber. */ | ||
public replicaNumber: number; | ||
/** LogootSRenameMsg clock. */ | ||
public clock: number; | ||
/** LogootSRenameMsg renamedIdIntervals. */ | ||
public renamedIdIntervals: sync.IIdentifierIntervalMsg[]; | ||
/** LogootSRenameMsg epoch. */ | ||
public epoch?: (sync.IEpochMsg|null); | ||
/** | ||
* Creates a new LogootSRenameMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns LogootSRenameMsg instance | ||
*/ | ||
public static create(properties?: sync.ILogootSRenameMsg): sync.LogootSRenameMsg; | ||
/** | ||
* Encodes the specified LogootSRenameMsg message. Does not implicitly {@link sync.LogootSRenameMsg.verify|verify} messages. | ||
* @param message LogootSRenameMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.ILogootSRenameMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a LogootSRenameMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns LogootSRenameMsg | ||
* @throws {Error} If the payload is not a reader or valid buffer | ||
* @throws {$protobuf.util.ProtocolError} If required fields are missing | ||
*/ | ||
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): sync.LogootSRenameMsg; | ||
} | ||
} | ||
@@ -878,0 +1229,0 @@ |
export { FIFODLSSync } from './FIFODLSSync' | ||
export { LSSync } from './LSSync' | ||
export { DLSSync } from './DLSSync' | ||
export { RLSSync } from './RLSSync' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8313934
169
70381
+ Addedmute-structs@2.0.5(transitive)
- Removedmute-structs@1.1.0(transitive)
Updatedmute-structs@^2.0.0-7