Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coast-team/mute-core

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coast-team/mute-core - npm Package Compare versions

Comparing version 10.0.0-1 to 10.0.0-experiment

dist/types/src/misc/IExperimentLogs.d.ts

279

CHANGELOG.md

@@ -5,2 +5,281 @@ # Change Log

<a name="10.0.0-experiment"></a>
# [10.0.0-experiment](https://github.com/coast-team/mute-core/compare/v10.0.0-1...v10.0.0-experiment) (2019-04-01)
<a name="9.1.6-experiment-1"></a>
## [9.1.6-experiment-1](https://github.com/coast-team/mute-core/compare/v9.1.6-experiment...v9.1.6-experiment-1) (2019-03-18)
### Bug Fixes
* **test:** fix test for release ([4c30589](https://github.com/coast-team/mute-core/commit/4c30589))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment-1"></a>
## [9.1.6-experiment-1](https://github.com/coast-team/mute-core/compare/v9.1.6-experiment...v9.1.6-experiment-1) (2019-03-18)
### Bug Fixes
* **test:** fix test for release ([4c30589](https://github.com/coast-team/mute-core/commit/4c30589))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<a name="9.1.6-experiment"></a>
## [9.1.6-experiment](https://github.com/coast-team/mute-core/compare/v9.1.6...v9.1.6-experiment) (2019-03-18)
### Bug Fixes
* **iexperimentallogs:** remove unused import ([2a852a1](https://github.com/coast-team/mute-core/commit/2a852a1))
### Features
* **logs:** add stream to get exepriment logs ([638993c](https://github.com/coast-team/mute-core/commit/638993c))
* **logs:** finalize stream in order to collect all information ([158962b](https://github.com/coast-team/mute-core/commit/158962b))
* **package:** update mute-structs ([8999ac7](https://github.com/coast-team/mute-core/commit/8999ac7))
* **struct:** add struct field in logs ([96d3482](https://github.com/coast-team/mute-core/commit/96d3482))
<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="10.0.0-1"></a>

@@ -7,0 +286,0 @@

3

dist/types/src/core/DocService.d.ts

@@ -6,2 +6,3 @@ import { TextOperation } from 'mute-structs';

import { Disposable } from '../misc';
import { IExperimentLogs } from '../misc/IExperimentLogs';
import { Document, Position } from './Document';

@@ -19,2 +20,3 @@ import { State } from './State';

protected _remoteOperationForLog: Subject<RemoteOperation<Op>>;
protected experimentalLogsSubject: Subject<IExperimentLogs>;
constructor(id: number, collaboratorService: CollaboratorsService, document: Document<Seq, Op>, sync: Sync<Op>, syncMessage: SyncMessage<Op>);

@@ -34,4 +36,5 @@ synchronize(): void;

readonly remoteOperationForLog$: Observable<RemoteOperation<Op>>;
readonly experimentsLogs$: Observable<IExperimentLogs>;
readonly digestUpdate$: Observable<number>;
dispose(): void;
}

42

dist/types/src/core/Document.d.ts

@@ -5,2 +5,3 @@ import { Identifier, TextOperation } from 'mute-structs';

import { Disposable } from '../misc';
import { IExperimentLogsDocument } from '../misc/IExperimentLogs';
import { sync } from '../proto';

@@ -12,20 +13,2 @@ export interface Position {

export declare abstract class Document<Seq, Op> extends Disposable {
protected _doc: Seq;
protected localOperationSubject: Subject<Op>;
protected remoteTextOperationSubject: Subject<{
collaborator: ICollaborator | undefined;
operations: TextOperation[];
}>;
protected localOperationLogsSubject: Subject<{
textop: TextOperation;
operation: Op;
}>;
protected remoteOperationLogsSubject: Subject<{
textop: TextOperation[];
operation: Op;
}>;
protected digestSubject: Subject<number>;
protected updateSubject: Subject<void>;
constructor(sequenceCRDT: Seq);
dispose(): void;
readonly doc: Seq;

@@ -51,3 +34,23 @@ localTextOperations$: Observable<TextOperation[]>;

readonly digest$: Observable<number>;
abstract handleLocalOperation(operation: TextOperation[]): void;
readonly experimentLogs$: Observable<IExperimentLogsDocument>;
protected _doc: Seq;
protected localOperationSubject: Subject<Op>;
protected remoteTextOperationSubject: Subject<{
collaborator: ICollaborator | undefined;
operations: TextOperation[];
}>;
protected localOperationLogsSubject: Subject<{
textop: TextOperation;
operation: Op;
}>;
protected remoteOperationLogsSubject: Subject<{
textop: TextOperation[];
operation: Op;
}>;
protected digestSubject: Subject<number>;
protected updateSubject: Subject<void>;
protected experimentLogsSubject: Subject<IExperimentLogsDocument>;
constructor(sequenceCRDT: Seq);
dispose(): void;
abstract handleLocalOperation(operation: TextOperation): Op;
abstract handleRemoteOperation(operation: Op): TextOperation[];

@@ -57,2 +60,3 @@ abstract positionFromIndex(index: number): Position | undefined;

abstract getDigest(): number;
protected abstract getStats(): any;
}
import { Observable, Subject } from 'rxjs';
import { CollaboratorsService, ICollaborator } from '../collaborators';
import { Disposable } from '../misc';
import { IExperimentLogsSync } from '../misc/IExperimentLogs';
import { ReplySyncEvent } from './ReplySyncEvent';

@@ -21,2 +22,3 @@ import { RichOperation } from './RichOperation';

protected localRichOperationsSubject: Subject<RichOperation<Op>>;
protected experimentLogsSubject: Subject<IExperimentLogsSync>;
protected remoteOperationsSubject: Subject<{

@@ -46,2 +48,3 @@ collaborator: ICollaborator | undefined;

}>;
readonly experimentLogs$: Observable<IExperimentLogsSync>;
readonly stateElements: SyncState<Op>;

@@ -48,0 +51,0 @@ remoteQuerySync$: Observable<StateVector>;

import { Observable, Subject } from 'rxjs';
import { IMessageIn, IMessageOut, Service } from '../misc';
import { IExperimentLogsSyncMessage } from '../misc/IExperimentLogs';
import { sync as proto } from '../proto';

@@ -12,2 +13,3 @@ import { ReplySyncEvent } from './ReplySyncEvent';

protected remoteReplySyncSubject: Subject<ReplySyncEvent<Op>>;
protected experimentLogsSubject: Subject<IExperimentLogsSyncMessage>;
constructor(messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>);

@@ -17,2 +19,3 @@ readonly remoteRichOperations$: Observable<RichOperation<Op>>;

readonly remoteReplySync$: Observable<ReplySyncEvent<Op>>;
readonly experimentLogs$: Observable<IExperimentLogsSyncMessage>;
localRichOperations$: Observable<RichOperation<Op>>;

@@ -19,0 +22,0 @@ querySync$: Observable<StateVector>;

@@ -8,3 +8,3 @@ import { SimpleDotPos } from 'dotted-logootsplit';

export declare class DLSDocument extends Document<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation> {
handleLocalOperation(operations: TextOperation[]): void;
handleLocalOperation(operation: TextOperation): BlockOperation;
handleRemoteOperation(operation: BlockOperation): TextOperation[];

@@ -14,2 +14,5 @@ positionFromIndex(_index: number): Position | undefined;

getDigest(): number;
protected getStats(): {
stats: string;
};
}

@@ -6,7 +6,22 @@ import { LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs';

constructor(rope: LogootSRopes);
handleLocalOperation(operations: TextOperation[]): void;
handleLocalOperation(operation: TextOperation): LogootSOperation;
handleRemoteOperation(operation: LogootSOperation): TextOperation[];
positionFromIndex(index: number): Position | undefined;
indexFromId(id: sync.IdentifierMsg): number;
getStats(): {
documentLength: number;
numberOfNodes: number;
treeHeight: number;
minIdentifierLength: number;
maxIdentifierLength: number;
meanIdentifierLength: number;
medianIdentifierLength: number;
repartitionIdentifierLength: [number, number][];
minNodeLength: number;
maxNodeLength: number;
meanNodeLength: number;
medianNodeLength: number;
repartitionNodeLength: [number, number][];
};
getDigest(): number;
}

@@ -12,2 +12,3 @@ import { SimpleDotPos } from 'dotted-logootsplit';

import { Disposable, IMessageIn, IMessageOut } from './misc';
import { IExperimentLogs } from './misc/IExperimentLogs';
import { collaborator as proto } from './proto';

@@ -38,2 +39,3 @@ export declare type MuteCoreTypes = MuteCore<LogootSRopes, LogootSOperation> | MuteCore<OpEditableReplicatedList<SimpleDotPos, string>, BlockOperation>;

readonly remoteOperationForLog: Observable<RemoteOperation<Op>>;
readonly experimentLogs$: Observable<IExperimentLogs>;
localTextOperations$: Observable<TextOperation[]>;

@@ -40,0 +42,0 @@ readonly remoteTextOperations$: Observable<{

{
"name": "@coast-team/mute-core",
"description": "Core component of MUTE collaborative editor",
"version": "10.0.0-1",
"version": "10.0.0-experiment",
"main": "./dist/mute-core.node.es5.cjs.js",

@@ -44,3 +44,3 @@ "module": "./dist/mutecore.node.es5.esm.js",

"check": "tsc --noEmit",
"lint": "tslint --fix -p tsconfig.json && prettier --write --list-different 'src/**/*.ts test/**/*.{ts}' './*.{ts,js,json,md}' './*.md' && markdownlint ./*.md",
"lint": "tslint --fix -p tsconfig.json && prettier --write --list-different 'src/**/*.ts test/**/*.{ts}' './*.{ts,js,json,md}'",
"pretest": "npm run build-test",

@@ -57,3 +57,3 @@ "test": "ava",

"dotted-logootsplit": "^0.1.0",
"mute-structs": "^1.0.0",
"mute-structs": "^1.1.0",
"rxjs": "^6.3.3",

@@ -60,0 +60,0 @@ "safe-any": "^1.0.2"

import { TextOperation } from 'mute-structs'
import { Observable, Subject, zip } from 'rxjs'
import { filter, first } from 'rxjs/operators'
import { CollaboratorsService, ICollaborator } from '../collaborators'
import { LocalOperation, RemoteOperation } from '../logs'
import { Disposable } from '../misc'
import { IExperimentLogs } from '../misc/IExperimentLogs'
import { Document, Position } from './Document'

@@ -22,2 +24,4 @@ import { State } from './State'

protected experimentalLogsSubject: Subject<IExperimentLogs>
constructor(

@@ -39,2 +43,3 @@ id: number,

this._remoteOperationForLog = new Subject()
this.experimentalLogsSubject = new Subject()

@@ -61,2 +66,54 @@ this.document.remoteOperations$ = this.sync.remoteOperations$

})
const experimentalLogZip = zip(this.sync.experimentLogs$, this.document.experimentLogs$)
this.newSub = this.syncMsg.experimentLogs$
.pipe(filter((sml) => sml.type === 'remote'))
.subscribe((syncMsgLog) => {
experimentalLogZip
.pipe(
filter(
([_sl, dl]) => dl.type === 'remote' && syncMsgLog.operation.operation === dl.operation
),
first()
)
.subscribe(([syncLog, docLog]) => {
this.experimentalLogsSubject.next({
type: 'remote',
site: this.id,
operation: syncMsgLog.operation,
vector: syncLog.vector,
time1: syncMsgLog.time1,
time2: syncMsgLog.time2,
time3: docLog.time3,
time4: docLog.time4,
stats: docLog.stats,
struct: docLog.struct,
})
})
})
this.newSub = experimentalLogZip
.pipe(filter(([_sl, dl]) => dl.type === 'local'))
.subscribe(([syncLog, docLog]) => {
this.syncMsg.experimentLogs$
.pipe(
filter((sml) => sml.type === 'local' && docLog.operation === sml.operation.operation),
first()
)
.subscribe((syncMsgLog) => {
this.experimentalLogsSubject.next({
type: 'local',
site: this.id,
operation: syncMsgLog.operation,
vector: syncLog.vector,
time1: syncMsgLog.time1,
time2: syncMsgLog.time2,
time3: docLog.time3,
time4: docLog.time4,
stats: docLog.stats,
struct: docLog.struct,
})
})
})
}

@@ -105,2 +162,6 @@

get experimentsLogs$() {
return this.experimentalLogsSubject.asObservable()
}
get digestUpdate$(): Observable<number> {

@@ -113,4 +174,5 @@ return this.document.digest$

this._remoteOperationForLog.complete()
this.experimentalLogsSubject.complete()
super.dispose()
}
}

@@ -6,2 +6,3 @@ import { Identifier, TextOperation } from 'mute-structs'

import { Disposable } from '../misc'
import { IExperimentLogsDocument } from '../misc/IExperimentLogs'
import { sync } from '../proto'

@@ -15,45 +16,2 @@

export abstract class Document<Seq, Op> extends Disposable {
protected _doc: Seq
protected localOperationSubject: Subject<Op>
protected remoteTextOperationSubject: Subject<{
collaborator: ICollaborator | undefined
operations: TextOperation[]
}>
protected localOperationLogsSubject: Subject<{ textop: TextOperation; operation: Op }>
protected remoteOperationLogsSubject: Subject<{
textop: TextOperation[]
operation: Op
}>
protected digestSubject: Subject<number>
protected updateSubject: Subject<void>
constructor(sequenceCRDT: Seq) {
super()
this._doc = sequenceCRDT
this.localOperationSubject = new Subject()
this.remoteTextOperationSubject = new Subject()
this.localOperationLogsSubject = new Subject()
this.remoteOperationLogsSubject = new Subject()
this.digestSubject = new Subject()
this.updateSubject = new Subject()
this.newSub = this.updateSubject.pipe(debounceTime(1000)).subscribe(() => {
this.digestSubject.next(this.getDigest())
})
}
dispose() {
this.localOperationSubject.complete()
this.remoteTextOperationSubject.complete()
this.digestSubject.complete()
this.updateSubject.complete()
super.dispose()
}
get doc(): Seq {

@@ -65,3 +23,17 @@ return this._doc

this.newSub = source.subscribe((textOperations) => {
this.handleLocalOperation(textOperations)
textOperations.forEach((ope) => {
const t4 = process.hrtime()
const remoteOp = this.handleLocalOperation(ope)
const t3 = process.hrtime()
this.experimentLogsSubject.next({
type: 'local',
operation: remoteOp,
time3: t3,
time4: t4,
stats: this.getStats(),
struct: this._doc,
})
this.localOperationLogsSubject.next({ textop: ope, operation: remoteOp })
this.localOperationSubject.next(remoteOp)
})
this.updateSubject.next()

@@ -86,3 +58,17 @@ })

const remoteOpes = operations
.map((operation) => this.handleRemoteOperation(operation))
.map((operation) => {
const t3 = process.hrtime()
const res = this.handleRemoteOperation(operation)
const t4 = process.hrtime()
this.experimentLogsSubject.next({
type: 'remote',
operation,
time3: t3,
time4: t4,
stats: this.getStats(),
struct: this._doc,
})
return res
})
.reduce((acc, textOps) => acc.concat(textOps), [])

@@ -113,3 +99,53 @@ this.remoteTextOperationSubject.next({ collaborator, operations: remoteOpes })

public abstract handleLocalOperation(operation: TextOperation[]): void
get experimentLogs$(): Observable<IExperimentLogsDocument> {
return this.experimentLogsSubject.asObservable()
}
protected _doc: Seq
protected localOperationSubject: Subject<Op>
protected remoteTextOperationSubject: Subject<{
collaborator: ICollaborator | undefined
operations: TextOperation[]
}>
protected localOperationLogsSubject: Subject<{ textop: TextOperation; operation: Op }>
protected remoteOperationLogsSubject: Subject<{
textop: TextOperation[]
operation: Op
}>
protected digestSubject: Subject<number>
protected updateSubject: Subject<void>
protected experimentLogsSubject: Subject<IExperimentLogsDocument>
constructor(sequenceCRDT: Seq) {
super()
this._doc = sequenceCRDT
this.localOperationSubject = new Subject()
this.remoteTextOperationSubject = new Subject()
this.localOperationLogsSubject = new Subject()
this.remoteOperationLogsSubject = new Subject()
this.digestSubject = new Subject()
this.updateSubject = new Subject()
this.experimentLogsSubject = new Subject()
this.newSub = this.updateSubject.pipe(debounceTime(1000)).subscribe(() => {
this.digestSubject.next(this.getDigest())
})
}
dispose() {
this.localOperationSubject.complete()
this.remoteTextOperationSubject.complete()
this.digestSubject.complete()
this.updateSubject.complete()
this.experimentLogsSubject.complete()
super.dispose()
}
public abstract handleLocalOperation(operation: TextOperation): Op
public abstract handleRemoteOperation(operation: Op): TextOperation[]

@@ -119,4 +155,5 @@

public abstract indexFromId(id: sync.IdentifierMsg): number
public abstract getDigest(): number
public abstract getDigest(): number
protected abstract getStats(): any
}

@@ -5,2 +5,3 @@ import { Observable, Subject } from 'rxjs'

import { Disposable } from '../misc'
import { IExperimentLogsSync } from '../misc/IExperimentLogs'
import { ReplySyncEvent } from './ReplySyncEvent'

@@ -27,2 +28,3 @@ import { RichOperation } from './RichOperation'

protected localRichOperationsSubject: Subject<RichOperation<Op>>
protected experimentLogsSubject: Subject<IExperimentLogsSync>
protected remoteOperationsSubject: Subject<{

@@ -64,2 +66,4 @@ collaborator: ICollaborator | undefined

this.experimentLogsSubject = new Subject()
// Initialize local state

@@ -102,2 +106,6 @@ this.richOperations = rOps

get experimentLogs$(): Observable<IExperimentLogsSync> {
return this.experimentLogsSubject.asObservable()
}
get stateElements(): SyncState<Op> {

@@ -140,2 +148,8 @@ return {

this.experimentLogsSubject.next({
type: 'local',
operation: richOp,
vector: Array.from(this.vector.asMap()),
})
this.updateState(richOp)

@@ -165,2 +179,3 @@ this.localRichOperationsSubject.next(richOp)

this.logsRemoteRichOperationsSubject.complete()
this.experimentLogsSubject.complete()
super.dispose()

@@ -183,2 +198,7 @@ }

const operation = op.operation
this.experimentLogsSubject.next({
type: 'remote',
operation: op,
vector: Array.from(this.vector.asMap()),
})
this.updateState(op)

@@ -185,0 +205,0 @@ operations.push(operation)

import { Observable, Subject, zip } from 'rxjs'
import { IMessageIn, IMessageOut, Service } from '../misc'
import { IExperimentLogsSyncMessage } from '../misc/IExperimentLogs'
import { sync as proto } from '../proto'

@@ -16,2 +17,4 @@ import { Streams } from '../Streams'

protected experimentLogsSubject: Subject<IExperimentLogsSyncMessage>
constructor(messageIn$: Observable<IMessageIn>, messageOut$: Subject<IMessageOut>) {

@@ -25,2 +28,4 @@ super(messageIn$, messageOut$, Streams.DOCUMENT_CONTENT, proto.SyncMsg)

this.experimentLogsSubject = new Subject()
// FIXME: should I save the subscription for later unsubscribe/subscribe?

@@ -30,3 +35,11 @@ this.newSub = this.messageIn$.subscribe(({ senderId, msg }) => {

case 'richOpMsg':
this.handleRichOpMsg(msg.richOpMsg as proto.RichOperationMsg)
const t1 = process.hrtime()
const richOpe = this.handleRichOpMsg(msg.richOpMsg as proto.RichOperationMsg)
const t2 = process.hrtime()
this.experimentLogsSubject.next({
type: 'remote',
operation: richOpe,
time1: t1,
time2: t2,
})
break

@@ -56,5 +69,18 @@ case 'querySync':

get experimentLogs$(): Observable<IExperimentLogsSyncMessage> {
return this.experimentLogsSubject.asObservable()
}
set localRichOperations$(source: Observable<RichOperation<Op>>) {
this.newSub = source.subscribe((richOp) => {
super.send({ richOpMsg: this.serializeRichOperation(richOp) })
const t2 = process.hrtime()
const richOpMsg = this.serializeRichOperation(richOp)
super.send({ richOpMsg })
const t1 = process.hrtime()
this.experimentLogsSubject.next({
type: 'local',
operation: richOp,
time1: t1,
time2: t2,
})
})

@@ -96,2 +122,3 @@ }

this.remoteReplySyncSubject.complete()
this.experimentLogsSubject.complete()
super.dispose()

@@ -107,4 +134,6 @@ }

private handleRichOpMsg(content: proto.RichOperationMsg): void {
this.remoteRichOperationSubject.next(this.deserializeRichOperation(content))
private handleRichOpMsg(content: proto.RichOperationMsg): RichOperation<Op> {
const richOp = this.deserializeRichOperation(content)
this.remoteRichOperationSubject.next(richOp)
return richOp
}

@@ -111,0 +140,0 @@

@@ -12,16 +12,18 @@ import { Del, Ins, SimpleDotPos } from 'dotted-logootsplit'

> {
public handleLocalOperation(operations: TextOperation[]): void {
operations.forEach((textOperation) => {
if (textOperation instanceof TextInsert) {
const blockOperation = this._doc.insertAt(textOperation.index, textOperation.content)
this.localOperationLogsSubject.next({ textop: textOperation, operation: blockOperation })
public handleLocalOperation(operation: TextOperation): BlockOperation {
if (operation instanceof TextInsert) {
const blockOperation = this._doc.insertAt(operation.index, operation.content)
this.localOperationLogsSubject.next({ textop: operation, operation: blockOperation })
this.localOperationSubject.next(blockOperation)
return blockOperation
} else if (operation instanceof TextDelete) {
const blockOperationList = this._doc.removeAt(operation.index, operation.length)
blockOperationList.forEach((blockOperation) => {
this.localOperationLogsSubject.next({ textop: operation, operation: blockOperation })
this.localOperationSubject.next(blockOperation)
} else if (textOperation instanceof TextDelete) {
const blockOperationList = this._doc.removeAt(textOperation.index, textOperation.length)
blockOperationList.forEach((blockOperation) => {
this.localOperationLogsSubject.next({ textop: textOperation, operation: blockOperation })
this.localOperationSubject.next(blockOperation)
})
}
})
})
return blockOperationList[0] // DOESNT SEEMS TO WORK !
} else {
throw new Error('operation is unknown')
}
}

@@ -55,2 +57,6 @@

}
protected getStats() {
return { stats: 'Not implemented yet' }
}
}

@@ -1,2 +0,2 @@

import { Identifier, LogootSOperation, LogootSRopes, TextOperation } from 'mute-structs'
import { Identifier, LogootSOperation, LogootSRopes, Stats, TextOperation } from 'mute-structs'
import { Document, Position } from '../../core'

@@ -11,8 +11,4 @@ import { sync } from '../../proto'

public handleLocalOperation(operations: TextOperation[]): void {
operations.forEach((textOperation) => {
const logootsop = textOperation.applyTo(this.doc)
this.localOperationLogsSubject.next({ textop: textOperation, operation: logootsop })
this.localOperationSubject.next(logootsop)
})
public handleLocalOperation(operation: TextOperation): LogootSOperation {
return operation.applyTo(this.doc)
}

@@ -42,2 +38,21 @@ public handleRemoteOperation(operation: LogootSOperation): TextOperation[] {

getStats() {
const stat = new Stats(this._doc)
return {
documentLength: stat.documentLength,
numberOfNodes: stat.numberOfNodes,
treeHeight: stat.treeHeight,
minIdentifierLength: stat.minIdentifierLength,
maxIdentifierLength: stat.maxIdentifierLength,
meanIdentifierLength: stat.meanIdentifierLength,
medianIdentifierLength: stat.medianIdentifierLength,
repartitionIdentifierLength: Array.from(stat.repartitionIdentifierLength),
minNodeLength: stat.minNodeLength,
maxNodeLength: stat.maxNodeLength,
meanNodeLength: stat.meanNodeLength,
medianNodeLength: stat.medianNodeLength,
repartitionNodeLength: Array.from(stat.repartitionNodeLength),
}
}
public getDigest(): number {

@@ -44,0 +59,0 @@ return this.doc.digest()

@@ -14,2 +14,3 @@ import { SimpleDotPos } from 'dotted-logootsplit'

import { Disposable, generateId, IMessageIn, IMessageOut } from './misc'
import { IExperimentLogs } from './misc/IExperimentLogs'
import { collaborator as proto } from './proto'

@@ -123,2 +124,5 @@

get experimentLogs$(): Observable<IExperimentLogs> {
return this.docService.experimentsLogs$
}
/*

@@ -125,0 +129,0 @@ * Doc observables

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc