@coast-team/mute-core
Advanced tools
Comparing version 9.1.6 to 10.0.0-1
@@ -5,18 +5,42 @@ # Change Log | ||
<a name="10.0.0-1"></a> | ||
# [10.0.0-1](https://github.com/coast-team/mute-core/compare/v9.1.6...v10.0.0-1) (2019-03-29) | ||
### Bug Fixes | ||
- **dependencies:** fix bug in richoperation fromPlain ([08a4903](https://github.com/coast-team/mute-core/commit/08a4903)) | ||
- **id:** fix problem with int32 id in dotted, and repair digest ([31102a1](https://github.com/coast-team/mute-core/commit/31102a1)) | ||
### Features | ||
- **dotted:** add all class for dottedLogootsplit ([554084b](https://github.com/coast-team/mute-core/commit/554084b)) | ||
<a name="10.0.0-0"></a> | ||
# [10.0.0-0](https://github.com/coast-team/mute-core/compare/v9.1.6...v10.0.0-0) (2019-03-29) | ||
### Bug Fixes | ||
- **dependencies:** fix bug in richoperation fromPlain ([08a4903](https://github.com/coast-team/mute-core/commit/08a4903)) | ||
- **id:** fix problem with int32 id in dotted, and repair digest ([31102a1](https://github.com/coast-team/mute-core/commit/31102a1)) | ||
### Features | ||
- **dotted:** add all class for dottedLogootsplit ([554084b](https://github.com/coast-team/mute-core/commit/554084b)) | ||
<a name="9.1.6"></a> | ||
## [9.1.6](https://github.com/coast-team/mute-core/compare/v9.1.5...v9.1.6) (2019-01-22) | ||
<a name="9.1.5"></a> | ||
<a name="9.1.5"></a> | ||
## [9.1.5](https://github.com/coast-team/mute-core/compare/v9.1.4...v9.1.5) (2019-01-22) | ||
<a name="9.1.4"></a> | ||
<a name="9.1.4"></a> | ||
## [9.1.4](https://github.com/coast-team/mute-core/compare/v9.1.3...v9.1.4) (2019-01-21) | ||
<a name="9.1.3"></a> | ||
<a name="9.1.3"></a> | ||
## [9.1.3](https://github.com/coast-team/mute-core/compare/v9.1.2...v9.1.3) (2019-01-21) |
@@ -53,2 +53,3 @@ import { Identifier, TextOperation } from 'mute-structs'; | ||
abstract indexFromId(id: sync.IdentifierMsg): number; | ||
abstract getDigest(): number; | ||
} |
import { Observable, Subject } from 'rxjs'; | ||
import { StateTypes } from '.'; | ||
import { CollaboratorsService } from '../collaborators'; | ||
import { DocService, State } from '../core'; | ||
import { DocService } from '../core'; | ||
import { IMessageIn, IMessageOut } from '../misc'; | ||
import { LSDocService } from './LogootSplit'; | ||
import { DLSDocService, DLSState } from './DottedLogootSplit'; | ||
import { LSDocService, LSState } from './LogootSplit'; | ||
import { Strategy } from './Strategy'; | ||
export declare type DocServiceStrategyMethod<Seq, Op> = (strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: StateTypes, collaboratorService: CollaboratorsService) => DocService<Seq, Op>; | ||
export declare class DocServiceStrategy { | ||
static createDocService<Seq, Op>(strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: State<Seq, Op>, collaboratorService: CollaboratorsService): LSDocService; | ||
static createDocService(strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: LSState, collaboratorService: CollaboratorsService): LSDocService; | ||
static createDocService(strat: Strategy, messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>, id: number, state: DLSState, collaboratorService: CollaboratorsService): DLSDocService; | ||
} |
@@ -10,2 +10,3 @@ import { LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs'; | ||
indexFromId(id: sync.IdentifierMsg): number; | ||
getDigest(): number; | ||
} |
import { SafeAny } from 'safe-any'; | ||
import { RichOperation } from '../core'; | ||
import { DLSRichOperation } from './DottedLogootSplit'; | ||
import { LSRichOperation } from './LogootSplit'; | ||
@@ -7,3 +8,3 @@ import { Strategy } from './Strategy'; | ||
export declare class RichOperationStrategy { | ||
static fromPlain<Op>(strat: Strategy, o: SafeAny<RichOperation<Op>>): LSRichOperation | null; | ||
static fromPlain<Op>(strat: Strategy, o: SafeAny<RichOperation<Op>>): LSRichOperation | DLSRichOperation | null; | ||
} |
import { SafeAny } from 'safe-any'; | ||
import { StateJSON } from '../core'; | ||
import { DLSState } from './DottedLogootSplit'; | ||
import { LSState } from './LogootSplit/LSState'; | ||
import { Strategy } from './Strategy'; | ||
export declare type StateTypes = LSState; | ||
export declare type StateTypes = LSState | DLSState; | ||
export declare class StateStrategy { | ||
static fromPlain<Seq, Op>(strat: Strategy, o: SafeAny<StateJSON<Seq, Op>>): LSState | null; | ||
static emptyState(strat: Strategy): LSState | null; | ||
static fromPlain<Seq, Op>(strat: Strategy, o: SafeAny<StateJSON<Seq, Op>>): LSState | DLSState | null; | ||
static emptyState(strat: Strategy): LSState | DLSState | null; | ||
static getStr(state: StateTypes): string | undefined; | ||
} |
export declare enum Strategy { | ||
LOGOOTSPLIT = 100 | ||
LOGOOTSPLIT = 100, | ||
DOTTEDLOGOOTSPLIT = 101 | ||
} |
@@ -0,1 +1,3 @@ | ||
import { SimpleDotPos } from 'dotted-logootsplit'; | ||
import { OpEditableReplicatedList } from 'dotted-logootsplit/dist/types/core/op-replicated-list'; | ||
import { LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs'; | ||
@@ -6,2 +8,3 @@ import { Observable } from 'rxjs'; | ||
import { DocServiceStrategyMethod, StateTypes, Strategy } from './crdtImpl'; | ||
import { BlockOperation } from './crdtImpl/DottedLogootSplit/DLSRichOperation'; | ||
import { FixDataState, LogState, MetaDataMessage, TitleState } from './doc'; | ||
@@ -11,3 +14,3 @@ import { LocalOperation, RemoteOperation } from './logs'; | ||
import { collaborator as proto } from './proto'; | ||
export declare type MuteCoreTypes = MuteCore<LogootSRopes, LogootSOperation>; | ||
export declare type MuteCoreTypes = MuteCore<LogootSRopes, LogootSOperation> | MuteCore<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation>; | ||
export interface SessionParameters { | ||
@@ -55,3 +58,3 @@ strategy: Strategy; | ||
export declare class MuteCoreFactory { | ||
static createMuteCore(constructorParam: SessionParameters): MuteCore<LogootSRopes, LogootSOperation>; | ||
static createMuteCore(constructorParam: SessionParameters): MuteCoreTypes; | ||
} |
@@ -10,2 +10,5 @@ import * as $protobuf from "protobufjs"; | ||
richLogootSOpsMsg?: (sync.IRichLogootSOperationMsg|null); | ||
/** RichOperationMsg richDottedLogootsOpsMsg */ | ||
richDottedLogootsOpsMsg?: (sync.IRichDottedLogootSOperationMsg|null); | ||
} | ||
@@ -25,4 +28,7 @@ | ||
/** RichOperationMsg richDottedLogootsOpsMsg. */ | ||
public richDottedLogootsOpsMsg?: (sync.IRichDottedLogootSOperationMsg|null); | ||
/** RichOperationMsg type. */ | ||
public type?: "richLogootSOpsMsg"; | ||
public type?: ("richLogootSOpsMsg"|"richDottedLogootsOpsMsg"); | ||
@@ -600,2 +606,272 @@ /** | ||
} | ||
/** Properties of a RichDottedLogootSOperationMsg. */ | ||
interface IRichDottedLogootSOperationMsg { | ||
/** RichDottedLogootSOperationMsg id */ | ||
id?: (number|null); | ||
/** RichDottedLogootSOperationMsg clock */ | ||
clock?: (number|null); | ||
/** RichDottedLogootSOperationMsg blockOperationMsg */ | ||
blockOperationMsg?: (sync.IDottedLogootSBlockMsg|null); | ||
/** RichDottedLogootSOperationMsg dependencies */ | ||
dependencies?: ({ [k: string]: number }|null); | ||
} | ||
/** Represents a RichDottedLogootSOperationMsg. */ | ||
class RichDottedLogootSOperationMsg implements IRichDottedLogootSOperationMsg { | ||
/** | ||
* Constructs a new RichDottedLogootSOperationMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRichDottedLogootSOperationMsg); | ||
/** RichDottedLogootSOperationMsg id. */ | ||
public id: number; | ||
/** RichDottedLogootSOperationMsg clock. */ | ||
public clock: number; | ||
/** RichDottedLogootSOperationMsg blockOperationMsg. */ | ||
public blockOperationMsg?: (sync.IDottedLogootSBlockMsg|null); | ||
/** RichDottedLogootSOperationMsg dependencies. */ | ||
public dependencies: { [k: string]: number }; | ||
/** | ||
* Creates a new RichDottedLogootSOperationMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RichDottedLogootSOperationMsg instance | ||
*/ | ||
public static create(properties?: sync.IRichDottedLogootSOperationMsg): sync.RichDottedLogootSOperationMsg; | ||
/** | ||
* Encodes the specified RichDottedLogootSOperationMsg message. Does not implicitly {@link sync.RichDottedLogootSOperationMsg.verify|verify} messages. | ||
* @param message RichDottedLogootSOperationMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRichDottedLogootSOperationMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RichDottedLogootSOperationMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RichDottedLogootSOperationMsg | ||
* @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.RichDottedLogootSOperationMsg; | ||
} | ||
/** Properties of a DottedLogootSBlockMsg. */ | ||
interface IDottedLogootSBlockMsg { | ||
/** DottedLogootSBlockMsg lowerPos */ | ||
lowerPos?: (sync.ISimpleDotPos|null); | ||
/** DottedLogootSBlockMsg content */ | ||
content?: (string|null); | ||
/** DottedLogootSBlockMsg concatLength */ | ||
concatLength?: (sync.IConcatLength|null); | ||
} | ||
/** Represents a DottedLogootSBlockMsg. */ | ||
class DottedLogootSBlockMsg implements IDottedLogootSBlockMsg { | ||
/** | ||
* Constructs a new DottedLogootSBlockMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IDottedLogootSBlockMsg); | ||
/** DottedLogootSBlockMsg lowerPos. */ | ||
public lowerPos?: (sync.ISimpleDotPos|null); | ||
/** DottedLogootSBlockMsg content. */ | ||
public content: string; | ||
/** DottedLogootSBlockMsg concatLength. */ | ||
public concatLength?: (sync.IConcatLength|null); | ||
/** DottedLogootSBlockMsg type. */ | ||
public type?: ("content"|"concatLength"); | ||
/** | ||
* Creates a new DottedLogootSBlockMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns DottedLogootSBlockMsg instance | ||
*/ | ||
public static create(properties?: sync.IDottedLogootSBlockMsg): sync.DottedLogootSBlockMsg; | ||
/** | ||
* Encodes the specified DottedLogootSBlockMsg message. Does not implicitly {@link sync.DottedLogootSBlockMsg.verify|verify} messages. | ||
* @param message DottedLogootSBlockMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IDottedLogootSBlockMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a DottedLogootSBlockMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns DottedLogootSBlockMsg | ||
* @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.DottedLogootSBlockMsg; | ||
} | ||
/** Properties of a ConcatLength. */ | ||
interface IConcatLength { | ||
/** ConcatLength length */ | ||
length?: (number|null); | ||
} | ||
/** Represents a ConcatLength. */ | ||
class ConcatLength implements IConcatLength { | ||
/** | ||
* Constructs a new ConcatLength. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IConcatLength); | ||
/** ConcatLength length. */ | ||
public length: number; | ||
/** | ||
* Creates a new ConcatLength instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns ConcatLength instance | ||
*/ | ||
public static create(properties?: sync.IConcatLength): sync.ConcatLength; | ||
/** | ||
* Encodes the specified ConcatLength message. Does not implicitly {@link sync.ConcatLength.verify|verify} messages. | ||
* @param message ConcatLength message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IConcatLength, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a ConcatLength message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns ConcatLength | ||
* @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.ConcatLength; | ||
} | ||
/** Properties of a SimpleDotPosPart. */ | ||
interface ISimpleDotPosPart { | ||
/** SimpleDotPosPart priority */ | ||
priority?: (number|null); | ||
/** SimpleDotPosPart replica */ | ||
replica?: (number|null); | ||
/** SimpleDotPosPart seq */ | ||
seq?: (number|null); | ||
} | ||
/** Represents a SimpleDotPosPart. */ | ||
class SimpleDotPosPart implements ISimpleDotPosPart { | ||
/** | ||
* Constructs a new SimpleDotPosPart. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.ISimpleDotPosPart); | ||
/** SimpleDotPosPart priority. */ | ||
public priority: number; | ||
/** SimpleDotPosPart replica. */ | ||
public replica: number; | ||
/** SimpleDotPosPart seq. */ | ||
public seq: number; | ||
/** | ||
* Creates a new SimpleDotPosPart instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns SimpleDotPosPart instance | ||
*/ | ||
public static create(properties?: sync.ISimpleDotPosPart): sync.SimpleDotPosPart; | ||
/** | ||
* Encodes the specified SimpleDotPosPart message. Does not implicitly {@link sync.SimpleDotPosPart.verify|verify} messages. | ||
* @param message SimpleDotPosPart message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.ISimpleDotPosPart, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a SimpleDotPosPart message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns SimpleDotPosPart | ||
* @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.SimpleDotPosPart; | ||
} | ||
/** Properties of a SimpleDotPos. */ | ||
interface ISimpleDotPos { | ||
/** SimpleDotPos parts */ | ||
parts?: (sync.ISimpleDotPosPart[]|null); | ||
} | ||
/** Represents a SimpleDotPos. */ | ||
class SimpleDotPos implements ISimpleDotPos { | ||
/** | ||
* Constructs a new SimpleDotPos. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.ISimpleDotPos); | ||
/** SimpleDotPos parts. */ | ||
public parts: sync.ISimpleDotPosPart[]; | ||
/** | ||
* Creates a new SimpleDotPos instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns SimpleDotPos instance | ||
*/ | ||
public static create(properties?: sync.ISimpleDotPos): sync.SimpleDotPos; | ||
/** | ||
* Encodes the specified SimpleDotPos message. Does not implicitly {@link sync.SimpleDotPos.verify|verify} messages. | ||
* @param message SimpleDotPos message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.ISimpleDotPos, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a SimpleDotPos message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns SimpleDotPos | ||
* @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.SimpleDotPos; | ||
} | ||
} | ||
@@ -602,0 +878,0 @@ |
export { FIFOSync } from './FIFOSync'; | ||
export { LSSync } from './LSSync'; | ||
export { DLSSync } from './DLSSync'; |
{ | ||
"name": "@coast-team/mute-core", | ||
"description": "Core component of MUTE collaborative editor", | ||
"version": "9.1.6", | ||
"version": "10.0.0-1", | ||
"main": "./dist/mute-core.node.es5.cjs.js", | ||
@@ -55,3 +55,4 @@ "module": "./dist/mutecore.node.es5.esm.js", | ||
"dependencies": { | ||
"mute-structs": "^0.5.4", | ||
"dotted-logootsplit": "^0.1.0", | ||
"mute-structs": "^1.0.0", | ||
"rxjs": "^6.3.3", | ||
@@ -71,6 +72,6 @@ "safe-any": "^1.0.2" | ||
"markdownlint-cli": "^0.13.0", | ||
"prettier": "^1.15.3", | ||
"prettier": "^1.16.0", | ||
"protobufjs": "^6.8.8", | ||
"rollup": "^0.65.2", | ||
"rollup-plugin-cleanup": "^3.1.0", | ||
"rollup-plugin-cleanup": "^3.1.1", | ||
"rollup-plugin-commonjs": "^9.1.6", | ||
@@ -84,3 +85,3 @@ "rollup-plugin-filesize": "^4.0.1", | ||
"tslint-config-prettier": "^1.17.0", | ||
"typescript": "^3.2.2" | ||
"typescript": "^3.2.4" | ||
}, | ||
@@ -110,4 +111,3 @@ "ava": { | ||
"prettier --write --list-different", | ||
"git add", | ||
"markdownlint" | ||
"git add" | ||
], | ||
@@ -114,0 +114,0 @@ "*.ts": [ |
import { Identifier, TextOperation } from 'mute-structs' | ||
import { Observable, Subject } from 'rxjs' | ||
import { debounceTime } from 'rxjs/operators' | ||
import { ICollaborator } from '../collaborators' | ||
@@ -42,2 +43,6 @@ import { Disposable } from '../misc' | ||
this.updateSubject = new Subject() | ||
this.newSub = this.updateSubject.pipe(debounceTime(1000)).subscribe(() => { | ||
this.digestSubject.next(this.getDigest()) | ||
}) | ||
} | ||
@@ -110,2 +115,4 @@ | ||
public abstract indexFromId(id: sync.IdentifierMsg): number | ||
public abstract getDigest(): number | ||
} |
@@ -6,3 +6,4 @@ import { Observable, Subject } from 'rxjs' | ||
import { IMessageIn, IMessageOut } from '../misc' | ||
import { LSSync } from '../syncImpl' | ||
import { DLSSync, LSSync } from '../syncImpl' | ||
import { DLSDocService, DLSDocument, DLSState, DLSSyncMessage } from './DottedLogootSplit' | ||
import { LSDocService, LSDocument, LSState, LSSyncMessage } from './LogootSplit' | ||
@@ -21,2 +22,18 @@ import { Strategy } from './Strategy' | ||
export class DocServiceStrategy { | ||
static createDocService( | ||
strat: Strategy, | ||
messageIn$: Observable<IMessageIn>, | ||
messageOut$: Subject<IMessageOut>, | ||
id: number, | ||
state: LSState, | ||
collaboratorService: CollaboratorsService | ||
): LSDocService | ||
static createDocService( | ||
strat: Strategy, | ||
messageIn$: Observable<IMessageIn>, | ||
messageOut$: Subject<IMessageOut>, | ||
id: number, | ||
state: DLSState, | ||
collaboratorService: CollaboratorsService | ||
): DLSDocService | ||
static createDocService<Seq, Op>( | ||
@@ -29,3 +46,3 @@ strat: Strategy, | ||
collaboratorService: CollaboratorsService | ||
) { | ||
): LSDocService | DLSDocService { | ||
switch (strat) { | ||
@@ -47,2 +64,18 @@ case Strategy.LOGOOTSPLIT: | ||
} | ||
case Strategy.DOTTEDLOGOOTSPLIT: | ||
if (state instanceof DLSState) { | ||
const document = new DLSDocument(state.sequenceCRDT) | ||
const sync = new DLSSync( | ||
id, | ||
state.networkClock, | ||
state.vector, | ||
state.remoteOperations, | ||
collaboratorService | ||
) | ||
const syncMessage = new DLSSyncMessage(messageIn$, messageOut$) | ||
return new DLSDocService(id, collaboratorService, document, sync, syncMessage) | ||
} else { | ||
throw new Error('State is not an instanceof DLSState') | ||
} | ||
break | ||
default: | ||
@@ -49,0 +82,0 @@ throw new Error("This strategy doesn't exist") |
@@ -40,2 +40,6 @@ import { Identifier, LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs' | ||
} | ||
public getDigest(): number { | ||
return this.doc.digest() | ||
} | ||
} |
import { SafeAny } from 'safe-any' | ||
import { RichOperation } from '../core' | ||
import { DLSRichOperation } from './DottedLogootSplit' | ||
import { LSRichOperation } from './LogootSplit' | ||
@@ -23,2 +24,5 @@ import { Strategy } from './Strategy' | ||
break | ||
case Strategy.DOTTEDLOGOOTSPLIT: | ||
rop = createRichOperation(DLSRichOperation, o) | ||
break | ||
default: | ||
@@ -25,0 +29,0 @@ rop = null |
import { SafeAny } from 'safe-any' | ||
import { StateJSON } from '../core' | ||
import { DLSState } from './DottedLogootSplit' | ||
import { LSState } from './LogootSplit/LSState' | ||
import { Strategy } from './Strategy' | ||
export type StateTypes = LSState | ||
export type StateTypes = LSState | DLSState | ||
@@ -28,2 +29,5 @@ interface IStateFactory<T> { | ||
break | ||
case Strategy.DOTTEDLOGOOTSPLIT: | ||
state = createState(DLSState, o) | ||
break | ||
default: | ||
@@ -42,2 +46,5 @@ state = null | ||
break | ||
case Strategy.DOTTEDLOGOOTSPLIT: | ||
state = createEmptyState(DLSState) | ||
break | ||
default: | ||
@@ -53,2 +60,4 @@ state = null | ||
return state.sequenceCRDT.str | ||
} else if (state instanceof DLSState) { | ||
return state.sequenceCRDT.concatenated('') | ||
} else { | ||
@@ -55,0 +64,0 @@ return undefined |
export enum Strategy { | ||
LOGOOTSPLIT = 100, | ||
DOTTEDLOGOOTSPLIT, | ||
} |
@@ -0,1 +1,3 @@ | ||
import { SimpleDotPos } from 'dotted-logootsplit' | ||
import { OpEditableReplicatedList } from 'dotted-logootsplit/dist/types/core/op-replicated-list' | ||
import { LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs' | ||
@@ -6,3 +8,5 @@ import { Observable, Subject } from 'rxjs' | ||
import { DocServiceStrategy, DocServiceStrategyMethod, StateTypes, Strategy } from './crdtImpl' | ||
import { LSState } from './crdtImpl/LogootSplit' | ||
import { DLSDocService, DLSState } from './crdtImpl/DottedLogootSplit' | ||
import { BlockOperation } from './crdtImpl/DottedLogootSplit/DLSRichOperation' | ||
import { LSDocService, LSState } from './crdtImpl/LogootSplit' | ||
import { FixDataState, LogState, MetaDataMessage, MetaDataService, TitleState } from './doc' | ||
@@ -13,3 +17,5 @@ import { LocalOperation, RemoteOperation } from './logs' | ||
export type MuteCoreTypes = MuteCore<LogootSRopes, LogootSOperation> | ||
export type MuteCoreTypes = | ||
| MuteCore<LogootSRopes, LogootSOperation> | ||
| MuteCore<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation> | ||
@@ -190,15 +196,42 @@ export interface SessionParameters { | ||
export class MuteCoreFactory { | ||
static createMuteCore(constructorParam: SessionParameters) { | ||
static createMuteCore(constructorParam: SessionParameters): MuteCoreTypes { | ||
switch (constructorParam.strategy) { | ||
case Strategy.LOGOOTSPLIT: | ||
if (constructorParam.docContent instanceof LSState) { | ||
return new MuteCore<LogootSRopes, LogootSOperation>( | ||
constructorParam, | ||
DocServiceStrategy.createDocService | ||
) | ||
} else { | ||
throw new Error('') | ||
} | ||
return new MuteCore<LogootSRopes, LogootSOperation>( | ||
constructorParam, | ||
(strat, messageIn$, messageOut$, id, state, collaboratorService): LSDocService => { | ||
if (state instanceof LSState) { | ||
return DocServiceStrategy.createDocService( | ||
strat, | ||
messageIn$, | ||
messageOut$, | ||
id, | ||
state, | ||
collaboratorService | ||
) | ||
} else { | ||
throw new Error('') | ||
} | ||
} | ||
) | ||
case Strategy.DOTTEDLOGOOTSPLIT: | ||
return new MuteCore<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation>( | ||
constructorParam, | ||
(strat, messageIn$, messageOut$, id, state, collaboratorService): DLSDocService => { | ||
if (state instanceof DLSState) { | ||
return DocServiceStrategy.createDocService( | ||
strat, | ||
messageIn$, | ||
messageOut$, | ||
id, | ||
state, | ||
collaboratorService | ||
) | ||
} else { | ||
throw new Error('') | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} |
@@ -10,2 +10,5 @@ import * as $protobuf from "protobufjs"; | ||
richLogootSOpsMsg?: (sync.IRichLogootSOperationMsg|null); | ||
/** RichOperationMsg richDottedLogootsOpsMsg */ | ||
richDottedLogootsOpsMsg?: (sync.IRichDottedLogootSOperationMsg|null); | ||
} | ||
@@ -25,4 +28,7 @@ | ||
/** RichOperationMsg richDottedLogootsOpsMsg. */ | ||
public richDottedLogootsOpsMsg?: (sync.IRichDottedLogootSOperationMsg|null); | ||
/** RichOperationMsg type. */ | ||
public type?: "richLogootSOpsMsg"; | ||
public type?: ("richLogootSOpsMsg"|"richDottedLogootsOpsMsg"); | ||
@@ -600,2 +606,272 @@ /** | ||
} | ||
/** Properties of a RichDottedLogootSOperationMsg. */ | ||
interface IRichDottedLogootSOperationMsg { | ||
/** RichDottedLogootSOperationMsg id */ | ||
id?: (number|null); | ||
/** RichDottedLogootSOperationMsg clock */ | ||
clock?: (number|null); | ||
/** RichDottedLogootSOperationMsg blockOperationMsg */ | ||
blockOperationMsg?: (sync.IDottedLogootSBlockMsg|null); | ||
/** RichDottedLogootSOperationMsg dependencies */ | ||
dependencies?: ({ [k: string]: number }|null); | ||
} | ||
/** Represents a RichDottedLogootSOperationMsg. */ | ||
class RichDottedLogootSOperationMsg implements IRichDottedLogootSOperationMsg { | ||
/** | ||
* Constructs a new RichDottedLogootSOperationMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IRichDottedLogootSOperationMsg); | ||
/** RichDottedLogootSOperationMsg id. */ | ||
public id: number; | ||
/** RichDottedLogootSOperationMsg clock. */ | ||
public clock: number; | ||
/** RichDottedLogootSOperationMsg blockOperationMsg. */ | ||
public blockOperationMsg?: (sync.IDottedLogootSBlockMsg|null); | ||
/** RichDottedLogootSOperationMsg dependencies. */ | ||
public dependencies: { [k: string]: number }; | ||
/** | ||
* Creates a new RichDottedLogootSOperationMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns RichDottedLogootSOperationMsg instance | ||
*/ | ||
public static create(properties?: sync.IRichDottedLogootSOperationMsg): sync.RichDottedLogootSOperationMsg; | ||
/** | ||
* Encodes the specified RichDottedLogootSOperationMsg message. Does not implicitly {@link sync.RichDottedLogootSOperationMsg.verify|verify} messages. | ||
* @param message RichDottedLogootSOperationMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IRichDottedLogootSOperationMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a RichDottedLogootSOperationMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns RichDottedLogootSOperationMsg | ||
* @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.RichDottedLogootSOperationMsg; | ||
} | ||
/** Properties of a DottedLogootSBlockMsg. */ | ||
interface IDottedLogootSBlockMsg { | ||
/** DottedLogootSBlockMsg lowerPos */ | ||
lowerPos?: (sync.ISimpleDotPos|null); | ||
/** DottedLogootSBlockMsg content */ | ||
content?: (string|null); | ||
/** DottedLogootSBlockMsg concatLength */ | ||
concatLength?: (sync.IConcatLength|null); | ||
} | ||
/** Represents a DottedLogootSBlockMsg. */ | ||
class DottedLogootSBlockMsg implements IDottedLogootSBlockMsg { | ||
/** | ||
* Constructs a new DottedLogootSBlockMsg. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IDottedLogootSBlockMsg); | ||
/** DottedLogootSBlockMsg lowerPos. */ | ||
public lowerPos?: (sync.ISimpleDotPos|null); | ||
/** DottedLogootSBlockMsg content. */ | ||
public content: string; | ||
/** DottedLogootSBlockMsg concatLength. */ | ||
public concatLength?: (sync.IConcatLength|null); | ||
/** DottedLogootSBlockMsg type. */ | ||
public type?: ("content"|"concatLength"); | ||
/** | ||
* Creates a new DottedLogootSBlockMsg instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns DottedLogootSBlockMsg instance | ||
*/ | ||
public static create(properties?: sync.IDottedLogootSBlockMsg): sync.DottedLogootSBlockMsg; | ||
/** | ||
* Encodes the specified DottedLogootSBlockMsg message. Does not implicitly {@link sync.DottedLogootSBlockMsg.verify|verify} messages. | ||
* @param message DottedLogootSBlockMsg message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IDottedLogootSBlockMsg, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a DottedLogootSBlockMsg message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns DottedLogootSBlockMsg | ||
* @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.DottedLogootSBlockMsg; | ||
} | ||
/** Properties of a ConcatLength. */ | ||
interface IConcatLength { | ||
/** ConcatLength length */ | ||
length?: (number|null); | ||
} | ||
/** Represents a ConcatLength. */ | ||
class ConcatLength implements IConcatLength { | ||
/** | ||
* Constructs a new ConcatLength. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.IConcatLength); | ||
/** ConcatLength length. */ | ||
public length: number; | ||
/** | ||
* Creates a new ConcatLength instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns ConcatLength instance | ||
*/ | ||
public static create(properties?: sync.IConcatLength): sync.ConcatLength; | ||
/** | ||
* Encodes the specified ConcatLength message. Does not implicitly {@link sync.ConcatLength.verify|verify} messages. | ||
* @param message ConcatLength message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.IConcatLength, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a ConcatLength message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns ConcatLength | ||
* @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.ConcatLength; | ||
} | ||
/** Properties of a SimpleDotPosPart. */ | ||
interface ISimpleDotPosPart { | ||
/** SimpleDotPosPart priority */ | ||
priority?: (number|null); | ||
/** SimpleDotPosPart replica */ | ||
replica?: (number|null); | ||
/** SimpleDotPosPart seq */ | ||
seq?: (number|null); | ||
} | ||
/** Represents a SimpleDotPosPart. */ | ||
class SimpleDotPosPart implements ISimpleDotPosPart { | ||
/** | ||
* Constructs a new SimpleDotPosPart. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.ISimpleDotPosPart); | ||
/** SimpleDotPosPart priority. */ | ||
public priority: number; | ||
/** SimpleDotPosPart replica. */ | ||
public replica: number; | ||
/** SimpleDotPosPart seq. */ | ||
public seq: number; | ||
/** | ||
* Creates a new SimpleDotPosPart instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns SimpleDotPosPart instance | ||
*/ | ||
public static create(properties?: sync.ISimpleDotPosPart): sync.SimpleDotPosPart; | ||
/** | ||
* Encodes the specified SimpleDotPosPart message. Does not implicitly {@link sync.SimpleDotPosPart.verify|verify} messages. | ||
* @param message SimpleDotPosPart message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.ISimpleDotPosPart, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a SimpleDotPosPart message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns SimpleDotPosPart | ||
* @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.SimpleDotPosPart; | ||
} | ||
/** Properties of a SimpleDotPos. */ | ||
interface ISimpleDotPos { | ||
/** SimpleDotPos parts */ | ||
parts?: (sync.ISimpleDotPosPart[]|null); | ||
} | ||
/** Represents a SimpleDotPos. */ | ||
class SimpleDotPos implements ISimpleDotPos { | ||
/** | ||
* Constructs a new SimpleDotPos. | ||
* @param [properties] Properties to set | ||
*/ | ||
constructor(properties?: sync.ISimpleDotPos); | ||
/** SimpleDotPos parts. */ | ||
public parts: sync.ISimpleDotPosPart[]; | ||
/** | ||
* Creates a new SimpleDotPos instance using the specified properties. | ||
* @param [properties] Properties to set | ||
* @returns SimpleDotPos instance | ||
*/ | ||
public static create(properties?: sync.ISimpleDotPos): sync.SimpleDotPos; | ||
/** | ||
* Encodes the specified SimpleDotPos message. Does not implicitly {@link sync.SimpleDotPos.verify|verify} messages. | ||
* @param message SimpleDotPos message or plain object to encode | ||
* @param [writer] Writer to encode to | ||
* @returns Writer | ||
*/ | ||
public static encode(message: sync.ISimpleDotPos, writer?: $protobuf.Writer): $protobuf.Writer; | ||
/** | ||
* Decodes a SimpleDotPos message from the specified reader or buffer. | ||
* @param reader Reader or buffer to decode from | ||
* @param [length] Message length if known beforehand | ||
* @returns SimpleDotPos | ||
* @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.SimpleDotPos; | ||
} | ||
} | ||
@@ -602,0 +878,0 @@ |
export { FIFOSync } from './FIFOSync' | ||
export { LSSync } from './LSSync' | ||
export { DLSSync } from './DLSSync' |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6354284
135
54500
0
4
2
+ Addeddotted-logootsplit@^0.1.0
+ Addeddotted-logootsplit@0.1.0(transitive)
+ Addedmute-structs@1.1.0(transitive)
- Removedmute-structs@0.5.8(transitive)
Updatedmute-structs@^1.0.0