@univerjs-procollaborationclassesTransformservice

@univerjs-pro/collaboration v0.5.0-beta.1Docs


Class: TransformService

This service’s responsibility is to transform mutations (changesets).

Features could register transform algorithms to this service, so this the service could transform more mutations.

This should be used both on client and server.

This service is also business-agnostic, so it could be used in docs, sheets and slides.

Extends

Implements

Constructors

new TransformService()

new TransformService(): TransformService

Returns

TransformService

Inherited from

Disposable.constructor

Properties

PropertyModifierTypeDefault valueInherited fromDefined in
_disposedprotectedbooleanfalseDisposable._disposedsubmodules/univer/packages/core/src/shared/lifecycle.ts:93

Methods

dispose()

dispose(): void

Returns

void

Overrides

Disposable.dispose

Defined in

packages/collaboration/src/services/transform/transform.service.ts:119


disposeWithMe()

disposeWithMe(disposable): IDisposable

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

Disposable.disposeWithMe

Defined in

submodules/univer/packages/core/src/shared/lifecycle.ts:96


ensureNotDisposed()

protected ensureNotDisposed(): void

Returns

void

Inherited from

Disposable.ensureNotDisposed

Defined in

submodules/univer/packages/core/src/shared/lifecycle.ts:100


registerTransformAlgorithm()

registerTransformAlgorithm(algorithm): void

Register an algorithm to transform two kinds of mutations.

Note that this method is not the same as other registering methods in Univer, it wouldn’t return a disposable, because it would cause critical problems if you unregister a transform algorithm.

Parameters

ParameterType
algorithmIMutationTransformAlgorithm<any, any>

Returns

void

Implementation of

ITransformService.registerTransformAlgorithm

Defined in

packages/collaboration/src/services/transform/transform.service.ts:123


transformChangesets()

transformChangesets(c1, c2)

transformChangesets(c1, c2): ITransformChangesetsResult

Internal

Transform two arrays of changesets

Parameters
ParameterType
c1IChangeset[]
c2IChangeset[]
Returns

ITransformChangesetsResult

Implementation of

ITransformService.transformChangesets

Defined in

packages/collaboration/src/services/transform/transform.service.ts:280

transformChangesets(c1, c2, onlyLater)

transformChangesets(
   c1, 
   c2, 
onlyLater): IFailureTransformChangesetsResult | Omit<ISuccessTransformChangesetsResult, "c1Prime">
Parameters
ParameterType
c1IChangeset[]
c2IChangeset[]
onlyLatertrue
Returns

IFailureTransformChangesetsResult | Omit<ISuccessTransformChangesetsResult, "c1Prime">

Implementation of

ITransformService.transformChangesets

Defined in

packages/collaboration/src/services/transform/transform.service.ts:281


transformMutation()

transformMutation(m1, m2)

transformMutation(m1, m2): ITransformMutationResult

Internal

Transform two single mutations. Note that m1Prime and m2Prime may not be single mutations. 1x1 may result in nxn.

Visualization:

               /\
          m1  /  \  m2
             /    \
             \    /
   m2Prime    \  /    m1Prime
               /
Parameters
ParameterType
m1IMutationInfo<object>
m2IMutationInfo<object>
Returns

ITransformMutationResult

Implementation of

ITransformService.transformMutation

Defined in

packages/collaboration/src/services/transform/transform.service.ts:137

transformMutation(m1, m2, onlyLater)

transformMutation(
   m1, 
   m2, 
onlyLater): IFailureTransformMutationResult | Omit<ISuccessTransformMutationResult, "m1Prime">
Parameters
ParameterType
m1IMutationInfo<object>
m2IMutationInfo<object>
onlyLatertrue
Returns

IFailureTransformMutationResult | Omit<ISuccessTransformMutationResult, "m1Prime">

Implementation of

ITransformService.transformMutation

Defined in

packages/collaboration/src/services/transform/transform.service.ts:138


transformMutations()

transformMutations(m1, m2)

transformMutations(m1, m2): ITransformMutationsResult

Internal

Transform two array of mutations. Not that the time complexity (also memory complexity) of this method is O(m*n), in which m & n are numbers of mutations in each array.

Visualization:

               /\
          m1  /  \  m2
             /    \
            /\    /\
           /  \  /  \
          /    /    \
          \    /\    /
           \  /  \  /
            /    /
             \    /
              \  /
    m2Prime    /    m1Prime
Parameters
ParameterType
m1IMutationInfo<object>[]
m2IMutationInfo<object>[]
Returns

ITransformMutationsResult

Implementation of

ITransformService.transformMutations

Defined in

packages/collaboration/src/services/transform/transform.service.ts:158

transformMutations(m1, m2, onlyLater)

transformMutations(
   m1, 
   m2, 
onlyLater): IFailureTransformMutationsResult | Omit<ISuccessTransformMutationsResult, "m1Prime">
Parameters
ParameterType
m1IMutationInfo<object>[]
m2IMutationInfo<object>[]
onlyLatertrue
Returns

IFailureTransformMutationsResult | Omit<ISuccessTransformMutationsResult, "m1Prime">

Implementation of

ITransformService.transformMutations

Defined in

packages/collaboration/src/services/transform/transform.service.ts:159


transformMutationsWithChangeset()

transformMutationsWithChangeset(c1, m2): ITransformMutationsWithChangesetResult

Internal

Transform mutations with changesets. We only wants transformed mutations here.

Parameters

ParameterType
c1IChangeset
m2IMutationInfo<object>[]

Returns

ITransformMutationsWithChangesetResult

Implementation of

ITransformService.transformMutationsWithChangeset

Defined in

packages/collaboration/src/services/transform/transform.service.ts:337