@y/y 14.0.0-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +1406 -0
- package/dist/Skip-j0kX7pdq.js +12173 -0
- package/dist/Skip-j0kX7pdq.js.map +1 -0
- package/dist/Skip-wRT7BKFP.js +11877 -0
- package/dist/Skip-wRT7BKFP.js.map +1 -0
- package/dist/index-DyTeTfmj.js +163 -0
- package/dist/index-DyTeTfmj.js.map +1 -0
- package/dist/index-R7GxO-36.js +165 -0
- package/dist/index-R7GxO-36.js.map +1 -0
- package/dist/internals.cjs +286 -0
- package/dist/internals.cjs.map +1 -0
- package/dist/internals.mjs +25 -0
- package/dist/internals.mjs.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/internals.d.ts +43 -0
- package/dist/src/internals.d.ts.map +1 -0
- package/dist/src/structs/AbstractStruct.d.ts +42 -0
- package/dist/src/structs/AbstractStruct.d.ts.map +1 -0
- package/dist/src/structs/ContentAny.d.ts +67 -0
- package/dist/src/structs/ContentAny.d.ts.map +1 -0
- package/dist/src/structs/ContentBinary.d.ts +64 -0
- package/dist/src/structs/ContentBinary.d.ts.map +1 -0
- package/dist/src/structs/ContentDeleted.d.ts +64 -0
- package/dist/src/structs/ContentDeleted.d.ts.map +1 -0
- package/dist/src/structs/ContentDoc.d.ts +72 -0
- package/dist/src/structs/ContentDoc.d.ts.map +1 -0
- package/dist/src/structs/ContentEmbed.d.ts +67 -0
- package/dist/src/structs/ContentEmbed.d.ts.map +1 -0
- package/dist/src/structs/ContentFormat.d.ts +69 -0
- package/dist/src/structs/ContentFormat.d.ts.map +1 -0
- package/dist/src/structs/ContentJSON.d.ts +70 -0
- package/dist/src/structs/ContentJSON.d.ts.map +1 -0
- package/dist/src/structs/ContentString.d.ts +70 -0
- package/dist/src/structs/ContentString.d.ts.map +1 -0
- package/dist/src/structs/ContentType.d.ts +83 -0
- package/dist/src/structs/ContentType.d.ts.map +1 -0
- package/dist/src/structs/GC.d.ts +31 -0
- package/dist/src/structs/GC.d.ts.map +1 -0
- package/dist/src/structs/Item.d.ts +212 -0
- package/dist/src/structs/Item.d.ts.map +1 -0
- package/dist/src/structs/Skip.d.ts +33 -0
- package/dist/src/structs/Skip.d.ts.map +1 -0
- package/dist/src/types/AbstractType.d.ts +239 -0
- package/dist/src/types/AbstractType.d.ts.map +1 -0
- package/dist/src/types/YArray.d.ts +128 -0
- package/dist/src/types/YArray.d.ts.map +1 -0
- package/dist/src/types/YMap.d.ts +112 -0
- package/dist/src/types/YMap.d.ts.map +1 -0
- package/dist/src/types/YText.d.ts +216 -0
- package/dist/src/types/YText.d.ts.map +1 -0
- package/dist/src/types/YXmlElement.d.ts +106 -0
- package/dist/src/types/YXmlElement.d.ts.map +1 -0
- package/dist/src/types/YXmlFragment.d.ts +143 -0
- package/dist/src/types/YXmlFragment.d.ts.map +1 -0
- package/dist/src/types/YXmlHook.d.ts +32 -0
- package/dist/src/types/YXmlHook.d.ts.map +1 -0
- package/dist/src/types/YXmlText.d.ts +34 -0
- package/dist/src/types/YXmlText.d.ts.map +1 -0
- package/dist/src/utils/AbstractConnector.d.ts +20 -0
- package/dist/src/utils/AbstractConnector.d.ts.map +1 -0
- package/dist/src/utils/AttributionManager.d.ts +224 -0
- package/dist/src/utils/AttributionManager.d.ts.map +1 -0
- package/dist/src/utils/Doc.d.ts +267 -0
- package/dist/src/utils/Doc.d.ts.map +1 -0
- package/dist/src/utils/EventHandler.d.ts +19 -0
- package/dist/src/utils/EventHandler.d.ts.map +1 -0
- package/dist/src/utils/ID.d.ts +26 -0
- package/dist/src/utils/ID.d.ts.map +1 -0
- package/dist/src/utils/IdMap.d.ts +161 -0
- package/dist/src/utils/IdMap.d.ts.map +1 -0
- package/dist/src/utils/IdSet.d.ts +163 -0
- package/dist/src/utils/IdSet.d.ts.map +1 -0
- package/dist/src/utils/RelativePosition.d.ts +91 -0
- package/dist/src/utils/RelativePosition.d.ts.map +1 -0
- package/dist/src/utils/Snapshot.d.ts +40 -0
- package/dist/src/utils/Snapshot.d.ts.map +1 -0
- package/dist/src/utils/StructSet.d.ts +27 -0
- package/dist/src/utils/StructSet.d.ts.map +1 -0
- package/dist/src/utils/StructStore.d.ts +41 -0
- package/dist/src/utils/StructStore.d.ts.map +1 -0
- package/dist/src/utils/Transaction.d.ts +136 -0
- package/dist/src/utils/Transaction.d.ts.map +1 -0
- package/dist/src/utils/UndoManager.d.ts +188 -0
- package/dist/src/utils/UndoManager.d.ts.map +1 -0
- package/dist/src/utils/UpdateDecoder.d.ts +167 -0
- package/dist/src/utils/UpdateDecoder.d.ts.map +1 -0
- package/dist/src/utils/UpdateEncoder.d.ts +164 -0
- package/dist/src/utils/UpdateEncoder.d.ts.map +1 -0
- package/dist/src/utils/YEvent.d.ts +120 -0
- package/dist/src/utils/YEvent.d.ts.map +1 -0
- package/dist/src/utils/delta-helpers.d.ts +6 -0
- package/dist/src/utils/delta-helpers.d.ts.map +1 -0
- package/dist/src/utils/encoding.d.ts +30 -0
- package/dist/src/utils/encoding.d.ts.map +1 -0
- package/dist/src/utils/isParentOf.d.ts +3 -0
- package/dist/src/utils/isParentOf.d.ts.map +1 -0
- package/dist/src/utils/logging.d.ts +3 -0
- package/dist/src/utils/logging.d.ts.map +1 -0
- package/dist/src/utils/types.d.ts +7 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/src/utils/updates.d.ts +89 -0
- package/dist/src/utils/updates.d.ts.map +1 -0
- package/dist/testHelper.cjs +780 -0
- package/dist/testHelper.cjs.map +1 -0
- package/dist/testHelper.mjs +617 -0
- package/dist/testHelper.mjs.map +1 -0
- package/dist/tests/IdMap.tests.d.ts +9 -0
- package/dist/tests/IdMap.tests.d.ts.map +1 -0
- package/dist/tests/IdSet.tests.d.ts +9 -0
- package/dist/tests/IdSet.tests.d.ts.map +1 -0
- package/dist/tests/attribution.tests.d.ts +8 -0
- package/dist/tests/attribution.tests.d.ts.map +1 -0
- package/dist/tests/compatibility.tests.d.ts +5 -0
- package/dist/tests/compatibility.tests.d.ts.map +1 -0
- package/dist/tests/delta.tests.d.ts +7 -0
- package/dist/tests/delta.tests.d.ts.map +1 -0
- package/dist/tests/doc.tests.d.ts +13 -0
- package/dist/tests/doc.tests.d.ts.map +1 -0
- package/dist/tests/encoding.tests.d.ts +5 -0
- package/dist/tests/encoding.tests.d.ts.map +1 -0
- package/dist/tests/index.d.ts +2 -0
- package/dist/tests/index.d.ts.map +1 -0
- package/dist/tests/relativePositions.tests.d.ts +11 -0
- package/dist/tests/relativePositions.tests.d.ts.map +1 -0
- package/dist/tests/snapshot.tests.d.ts +13 -0
- package/dist/tests/snapshot.tests.d.ts.map +1 -0
- package/dist/tests/testHelper.d.ts +167 -0
- package/dist/tests/testHelper.d.ts.map +1 -0
- package/dist/tests/undo-redo.tests.d.ts +27 -0
- package/dist/tests/undo-redo.tests.d.ts.map +1 -0
- package/dist/tests/updates.tests.d.ts +24 -0
- package/dist/tests/updates.tests.d.ts.map +1 -0
- package/dist/tests/y-array.tests.d.ts +45 -0
- package/dist/tests/y-array.tests.d.ts.map +1 -0
- package/dist/tests/y-map.tests.d.ts +45 -0
- package/dist/tests/y-map.tests.d.ts.map +1 -0
- package/dist/tests/y-text.tests.d.ts +49 -0
- package/dist/tests/y-text.tests.d.ts.map +1 -0
- package/dist/tests/y-xml.tests.d.ts +15 -0
- package/dist/tests/y-xml.tests.d.ts.map +1 -0
- package/dist/yjs.cjs +151 -0
- package/dist/yjs.cjs.map +1 -0
- package/dist/yjs.mjs +26 -0
- package/dist/yjs.mjs.map +1 -0
- package/package.json +101 -0
- package/src/index.js +153 -0
- package/src/internals.js +44 -0
- package/src/structs/AbstractStruct.js +59 -0
- package/src/structs/ContentAny.js +115 -0
- package/src/structs/ContentBinary.js +93 -0
- package/src/structs/ContentDeleted.js +101 -0
- package/src/structs/ContentDoc.js +141 -0
- package/src/structs/ContentEmbed.js +98 -0
- package/src/structs/ContentFormat.js +105 -0
- package/src/structs/ContentJSON.js +119 -0
- package/src/structs/ContentString.js +113 -0
- package/src/structs/ContentType.js +176 -0
- package/src/structs/GC.js +80 -0
- package/src/structs/Item.js +845 -0
- package/src/structs/Skip.js +75 -0
- package/src/types/AbstractType.js +1434 -0
- package/src/types/YArray.js +270 -0
- package/src/types/YMap.js +244 -0
- package/src/types/YText.js +934 -0
- package/src/types/YXmlElement.js +227 -0
- package/src/types/YXmlFragment.js +266 -0
- package/src/types/YXmlHook.js +68 -0
- package/src/types/YXmlText.js +66 -0
- package/src/utils/AbstractConnector.js +25 -0
- package/src/utils/AttributionManager.js +619 -0
- package/src/utils/Doc.js +372 -0
- package/src/utils/EventHandler.js +87 -0
- package/src/utils/ID.js +89 -0
- package/src/utils/IdMap.js +629 -0
- package/src/utils/IdSet.js +823 -0
- package/src/utils/RelativePosition.js +352 -0
- package/src/utils/Snapshot.js +220 -0
- package/src/utils/StructSet.js +137 -0
- package/src/utils/StructStore.js +289 -0
- package/src/utils/Transaction.js +489 -0
- package/src/utils/UndoManager.js +391 -0
- package/src/utils/UpdateDecoder.js +281 -0
- package/src/utils/UpdateEncoder.js +320 -0
- package/src/utils/YEvent.js +216 -0
- package/src/utils/delta-helpers.js +54 -0
- package/src/utils/encoding.js +623 -0
- package/src/utils/isParentOf.js +21 -0
- package/src/utils/logging.js +21 -0
- package/src/utils/types.js +28 -0
- package/src/utils/updates.js +715 -0
- package/tests/testHelper.js +600 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A transaction is created for every change on the Yjs model. It is possible
|
|
3
|
+
* to bundle changes on the Yjs model in a single transaction to
|
|
4
|
+
* minimize the number on messages sent and the number of observer calls.
|
|
5
|
+
* If possible the user of this library should bundle as many changes as
|
|
6
|
+
* possible. Here is an example to illustrate the advantages of bundling:
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const ydoc = new Y.Doc()
|
|
10
|
+
* const map = ydoc.getMap('map')
|
|
11
|
+
* // Log content when change is triggered
|
|
12
|
+
* map.observe(() => {
|
|
13
|
+
* console.log('change triggered')
|
|
14
|
+
* })
|
|
15
|
+
* // Each change on the map type triggers a log message:
|
|
16
|
+
* map.set('a', 0) // => "change triggered"
|
|
17
|
+
* map.set('b', 0) // => "change triggered"
|
|
18
|
+
* // When put in a transaction, it will trigger the log after the transaction:
|
|
19
|
+
* ydoc.transact(() => {
|
|
20
|
+
* map.set('a', 1)
|
|
21
|
+
* map.set('b', 1)
|
|
22
|
+
* }) // => "change triggered"
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export class Transaction {
|
|
27
|
+
/**
|
|
28
|
+
* @param {Doc} doc
|
|
29
|
+
* @param {any} origin
|
|
30
|
+
* @param {boolean} local
|
|
31
|
+
*/
|
|
32
|
+
constructor(doc: Doc, origin: any, local: boolean);
|
|
33
|
+
/**
|
|
34
|
+
* The Yjs instance.
|
|
35
|
+
* @type {Doc}
|
|
36
|
+
*/
|
|
37
|
+
doc: Doc;
|
|
38
|
+
/**
|
|
39
|
+
* Describes the set of deleted items by ids
|
|
40
|
+
*/
|
|
41
|
+
deleteSet: IdSet;
|
|
42
|
+
/**
|
|
43
|
+
* Describes the set of items that are cleaned up / deleted by ids. It is a subset of
|
|
44
|
+
* this.deleteSet
|
|
45
|
+
*/
|
|
46
|
+
cleanUps: IdSet;
|
|
47
|
+
/**
|
|
48
|
+
* Describes the set of inserted items by ids
|
|
49
|
+
*/
|
|
50
|
+
insertSet: IdSet;
|
|
51
|
+
/**
|
|
52
|
+
* Holds the state before the transaction started.
|
|
53
|
+
* @type {Map<Number,Number>?}
|
|
54
|
+
*/
|
|
55
|
+
_beforeState: Map<number, number> | null;
|
|
56
|
+
/**
|
|
57
|
+
* Holds the state after the transaction.
|
|
58
|
+
* @type {Map<Number,Number>?}
|
|
59
|
+
*/
|
|
60
|
+
_afterState: Map<number, number> | null;
|
|
61
|
+
/**
|
|
62
|
+
* All types that were directly modified (property added or child
|
|
63
|
+
* inserted/deleted). New types are not included in this Set.
|
|
64
|
+
* Maps from type to parentSubs (`item.parentSub = null` for YArray)
|
|
65
|
+
* @type {Map<import('../utils/types.js').YType,Set<String|null>>}
|
|
66
|
+
*/
|
|
67
|
+
changed: Map<import("../utils/types.js").YType, Set<string | null>>;
|
|
68
|
+
/**
|
|
69
|
+
* Stores the events for the types that observe also child elements.
|
|
70
|
+
* It is mainly used by `observeDeep`.
|
|
71
|
+
* @type {Map<import('../utils/types.js').YType,Array<YEvent<any>>>}
|
|
72
|
+
*/
|
|
73
|
+
changedParentTypes: Map<import("../utils/types.js").YType, Array<YEvent<any>>>;
|
|
74
|
+
/**
|
|
75
|
+
* @type {Array<AbstractStruct>}
|
|
76
|
+
*/
|
|
77
|
+
_mergeStructs: Array<AbstractStruct>;
|
|
78
|
+
/**
|
|
79
|
+
* @type {any}
|
|
80
|
+
*/
|
|
81
|
+
origin: any;
|
|
82
|
+
/**
|
|
83
|
+
* Stores meta information on the transaction
|
|
84
|
+
* @type {Map<any,any>}
|
|
85
|
+
*/
|
|
86
|
+
meta: Map<any, any>;
|
|
87
|
+
/**
|
|
88
|
+
* Whether this change originates from this doc.
|
|
89
|
+
* @type {boolean}
|
|
90
|
+
*/
|
|
91
|
+
local: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* @type {Set<Doc>}
|
|
94
|
+
*/
|
|
95
|
+
subdocsAdded: Set<Doc>;
|
|
96
|
+
/**
|
|
97
|
+
* @type {Set<Doc>}
|
|
98
|
+
*/
|
|
99
|
+
subdocsRemoved: Set<Doc>;
|
|
100
|
+
/**
|
|
101
|
+
* @type {Set<Doc>}
|
|
102
|
+
*/
|
|
103
|
+
subdocsLoaded: Set<Doc>;
|
|
104
|
+
/**
|
|
105
|
+
* @type {boolean}
|
|
106
|
+
*/
|
|
107
|
+
_needFormattingCleanup: boolean;
|
|
108
|
+
_done: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Holds the state before the transaction started.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated
|
|
113
|
+
* @type {Map<Number,Number>}
|
|
114
|
+
*/
|
|
115
|
+
get beforeState(): Map<number, number>;
|
|
116
|
+
/**
|
|
117
|
+
* Holds the state after the transaction.
|
|
118
|
+
*
|
|
119
|
+
* @deprecated
|
|
120
|
+
* @type {Map<Number,Number>}
|
|
121
|
+
*/
|
|
122
|
+
get afterState(): Map<number, number>;
|
|
123
|
+
}
|
|
124
|
+
export function writeUpdateMessageFromTransaction(encoder: UpdateEncoderV1 | UpdateEncoderV2, transaction: Transaction): boolean;
|
|
125
|
+
export function nextID(transaction: Transaction): import("./ID.js").ID;
|
|
126
|
+
export function addChangedTypeToTransaction(transaction: Transaction, type: import("../utils/types.js").YType, parentSub: string | null): void;
|
|
127
|
+
export function tryGc(tr: Transaction, idset: IdSet, gcFilter: (arg0: Item) => boolean): void;
|
|
128
|
+
export function transact<T>(doc: Doc, f: (arg0: Transaction) => T, origin?: any, local?: boolean): T;
|
|
129
|
+
import { Doc } from '../internals.js';
|
|
130
|
+
import { IdSet } from '../internals.js';
|
|
131
|
+
import { YEvent } from '../internals.js';
|
|
132
|
+
import { AbstractStruct } from '../internals.js';
|
|
133
|
+
import { UpdateEncoderV1 } from '../internals.js';
|
|
134
|
+
import { UpdateEncoderV2 } from '../internals.js';
|
|
135
|
+
import { Item } from '../internals.js';
|
|
136
|
+
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../src/utils/Transaction.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACE;;;;OAIG;IACH,iBAJW,GAAG,UACH,GAAG,SACH,OAAO,EA+EjB;IA5EC;;;OAGG;IACH,KAFU,GAAG,CAEC;IACd;;OAEG;IACH,iBAA8B;IAC9B;;;OAGG;IACH,gBAA6B;IAC7B;;OAEG;IACH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BAAiB;sBAAjB,iBAAiB;uBAAjB,iBAAiB;+BAAjB,iBAAiB;gCAAjB,iBAAiB;gCAAjB,iBAAiB;qBAAjB,iBAAiB"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
export class StackItem {
|
|
2
|
+
/**
|
|
3
|
+
* @param {IdSet} deletions
|
|
4
|
+
* @param {IdSet} insertions
|
|
5
|
+
*/
|
|
6
|
+
constructor(deletions: IdSet, insertions: IdSet);
|
|
7
|
+
insertions: IdSet;
|
|
8
|
+
deletions: IdSet;
|
|
9
|
+
/**
|
|
10
|
+
* Use this to save and restore metadata like selection range
|
|
11
|
+
*/
|
|
12
|
+
meta: Map<any, any>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} UndoManagerOptions
|
|
16
|
+
* @property {number} [UndoManagerOptions.captureTimeout=500]
|
|
17
|
+
* @property {function(Transaction):boolean} [UndoManagerOptions.captureTransaction] Do not capture changes of a Transaction if result false.
|
|
18
|
+
* @property {function(Item):boolean} [UndoManagerOptions.deleteFilter=()=>true] Sometimes
|
|
19
|
+
* it is necessary to filter what an Undo/Redo operation can delete. If this
|
|
20
|
+
* filter returns false, the type/item won't be deleted even it is in the
|
|
21
|
+
* undo/redo scope.
|
|
22
|
+
* @property {Set<any>} [UndoManagerOptions.trackedOrigins=new Set([null])]
|
|
23
|
+
* @property {boolean} [ignoreRemoteMapChanges] Experimental. By default, the UndoManager will never overwrite remote changes. Enable this property to enable overwriting remote changes on key-value changes (Y.Map, properties on Y.Xml, etc..).
|
|
24
|
+
* @property {Doc} [doc] The document that this UndoManager operates on. Only needed if typeScope is empty.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} StackItemEvent
|
|
28
|
+
* @property {StackItem} StackItemEvent.stackItem
|
|
29
|
+
* @property {any} StackItemEvent.origin
|
|
30
|
+
* @property {'undo'|'redo'} StackItemEvent.type
|
|
31
|
+
* @property {Map<import('../utils/types.js').YType,Array<YEvent<any>>>} StackItemEvent.changedParentTypes
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Fires 'stack-item-added' event when a stack item was added to either the undo- or
|
|
35
|
+
* the redo-stack. You may store additional stack information via the
|
|
36
|
+
* metadata property on `event.stackItem.meta` (it is a `Map` of metadata properties).
|
|
37
|
+
* Fires 'stack-item-popped' event when a stack item was popped from either the
|
|
38
|
+
* undo- or the redo-stack. You may restore the saved stack information from `event.stackItem.meta`.
|
|
39
|
+
*
|
|
40
|
+
* @extends {ObservableV2<{'stack-item-added':function(StackItemEvent, UndoManager):void, 'stack-item-popped': function(StackItemEvent, UndoManager):void, 'stack-cleared': function({ undoStackCleared: boolean, redoStackCleared: boolean }):void, 'stack-item-updated': function(StackItemEvent, UndoManager):void }>}
|
|
41
|
+
*/
|
|
42
|
+
export class UndoManager extends ObservableV2<{
|
|
43
|
+
'stack-item-added': (arg0: StackItemEvent, arg1: UndoManager) => void;
|
|
44
|
+
'stack-item-popped': (arg0: StackItemEvent, arg1: UndoManager) => void;
|
|
45
|
+
'stack-cleared': (arg0: {
|
|
46
|
+
undoStackCleared: boolean;
|
|
47
|
+
redoStackCleared: boolean;
|
|
48
|
+
}) => void;
|
|
49
|
+
'stack-item-updated': (arg0: StackItemEvent, arg1: UndoManager) => void;
|
|
50
|
+
}> {
|
|
51
|
+
/**
|
|
52
|
+
* @param {Doc|import('../utils/types.js').YType|Array<import('../utils/types.js').YType>} typeScope Limits the scope of the UndoManager. If this is set to a ydoc instance, all changes on that ydoc will be undone. If set to a specific type, only changes on that type or its children will be undone. Also accepts an array of types.
|
|
53
|
+
* @param {UndoManagerOptions} options
|
|
54
|
+
*/
|
|
55
|
+
constructor(typeScope: Doc | import("../utils/types.js").YType | Array<import("../utils/types.js").YType>, { captureTimeout, captureTransaction, deleteFilter, trackedOrigins, ignoreRemoteMapChanges, doc }?: UndoManagerOptions);
|
|
56
|
+
/**
|
|
57
|
+
* @type {Array<import('../utils/types.js').YType | Doc>}
|
|
58
|
+
*/
|
|
59
|
+
scope: Array<import("../utils/types.js").YType | Doc>;
|
|
60
|
+
doc: Doc;
|
|
61
|
+
deleteFilter: (arg0: Item) => boolean;
|
|
62
|
+
trackedOrigins: Set<any>;
|
|
63
|
+
captureTransaction: (arg0: Transaction) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @type {Array<StackItem>}
|
|
66
|
+
*/
|
|
67
|
+
undoStack: Array<StackItem>;
|
|
68
|
+
/**
|
|
69
|
+
* @type {Array<StackItem>}
|
|
70
|
+
*/
|
|
71
|
+
redoStack: Array<StackItem>;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the client is currently undoing (calling UndoManager.undo)
|
|
74
|
+
*
|
|
75
|
+
* @type {boolean}
|
|
76
|
+
*/
|
|
77
|
+
undoing: boolean;
|
|
78
|
+
redoing: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* The currently popped stack item if UndoManager.undoing or UndoManager.redoing
|
|
81
|
+
*
|
|
82
|
+
* @type {StackItem|null}
|
|
83
|
+
*/
|
|
84
|
+
currStackItem: StackItem | null;
|
|
85
|
+
lastChange: number;
|
|
86
|
+
ignoreRemoteMapChanges: boolean;
|
|
87
|
+
captureTimeout: number;
|
|
88
|
+
/**
|
|
89
|
+
* @param {Transaction} transaction
|
|
90
|
+
*/
|
|
91
|
+
afterTransactionHandler: (transaction: Transaction) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Extend the scope.
|
|
94
|
+
*
|
|
95
|
+
* @param {Array<import('../utils/types.js').YType | Doc> | import('../utils/types.js').YType | Doc} ytypes
|
|
96
|
+
*/
|
|
97
|
+
addToScope(ytypes: Array<import("../utils/types.js").YType | Doc> | import("../utils/types.js").YType | Doc): void;
|
|
98
|
+
/**
|
|
99
|
+
* @param {any} origin
|
|
100
|
+
*/
|
|
101
|
+
addTrackedOrigin(origin: any): void;
|
|
102
|
+
/**
|
|
103
|
+
* @param {any} origin
|
|
104
|
+
*/
|
|
105
|
+
removeTrackedOrigin(origin: any): void;
|
|
106
|
+
clear(clearUndoStack?: boolean, clearRedoStack?: boolean): void;
|
|
107
|
+
/**
|
|
108
|
+
* UndoManager merges Undo-StackItem if they are created within time-gap
|
|
109
|
+
* smaller than `options.captureTimeout`. Call `um.stopCapturing()` so that the next
|
|
110
|
+
* StackItem won't be merged.
|
|
111
|
+
*
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* // without stopCapturing
|
|
115
|
+
* ytext.insert(0, 'a')
|
|
116
|
+
* ytext.insert(1, 'b')
|
|
117
|
+
* um.undo()
|
|
118
|
+
* ytext.toString() // => '' (note that 'ab' was removed)
|
|
119
|
+
* // with stopCapturing
|
|
120
|
+
* ytext.insert(0, 'a')
|
|
121
|
+
* um.stopCapturing()
|
|
122
|
+
* ytext.insert(0, 'b')
|
|
123
|
+
* um.undo()
|
|
124
|
+
* ytext.toString() // => 'a' (note that only 'b' was removed)
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
stopCapturing(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Undo last changes on type.
|
|
130
|
+
*
|
|
131
|
+
* @return {StackItem?} Returns StackItem if a change was applied
|
|
132
|
+
*/
|
|
133
|
+
undo(): StackItem | null;
|
|
134
|
+
/**
|
|
135
|
+
* Redo last undo operation.
|
|
136
|
+
*
|
|
137
|
+
* @return {StackItem?} Returns StackItem if a change was applied
|
|
138
|
+
*/
|
|
139
|
+
redo(): StackItem | null;
|
|
140
|
+
/**
|
|
141
|
+
* Are undo steps available?
|
|
142
|
+
*
|
|
143
|
+
* @return {boolean} `true` if undo is possible
|
|
144
|
+
*/
|
|
145
|
+
canUndo(): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Are redo steps available?
|
|
148
|
+
*
|
|
149
|
+
* @return {boolean} `true` if redo is possible
|
|
150
|
+
*/
|
|
151
|
+
canRedo(): boolean;
|
|
152
|
+
}
|
|
153
|
+
export type UndoManagerOptions = {
|
|
154
|
+
captureTimeout?: number | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Do not capture changes of a Transaction if result false.
|
|
157
|
+
*/
|
|
158
|
+
captureTransaction?: ((arg0: Transaction) => boolean) | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Sometimes
|
|
161
|
+
* it is necessary to filter what an Undo/Redo operation can delete. If this
|
|
162
|
+
* filter returns false, the type/item won't be deleted even it is in the
|
|
163
|
+
* undo/redo scope.
|
|
164
|
+
*/
|
|
165
|
+
deleteFilter?: ((arg0: Item) => boolean) | undefined;
|
|
166
|
+
trackedOrigins?: Set<any> | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Experimental. By default, the UndoManager will never overwrite remote changes. Enable this property to enable overwriting remote changes on key-value changes (Y.Map, properties on Y.Xml, etc..).
|
|
169
|
+
*/
|
|
170
|
+
ignoreRemoteMapChanges?: boolean | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* The document that this UndoManager operates on. Only needed if typeScope is empty.
|
|
173
|
+
*/
|
|
174
|
+
doc?: Doc | undefined;
|
|
175
|
+
};
|
|
176
|
+
export type StackItemEvent = {
|
|
177
|
+
stackItem: StackItem;
|
|
178
|
+
origin: any;
|
|
179
|
+
type: "undo" | "redo";
|
|
180
|
+
changedParentTypes: Map<import("../utils/types.js").YType, Array<YEvent<any>>>;
|
|
181
|
+
};
|
|
182
|
+
import { IdSet } from '../internals.js';
|
|
183
|
+
import { ObservableV2 } from 'lib0/observable';
|
|
184
|
+
import { Doc } from '../internals.js';
|
|
185
|
+
import { Item } from '../internals.js';
|
|
186
|
+
import { Transaction } from '../internals.js';
|
|
187
|
+
import { YEvent } from '../internals.js';
|
|
188
|
+
//# sourceMappingURL=UndoManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UndoManager.d.ts","sourceRoot":"","sources":["../../../src/utils/UndoManager.js"],"names":[],"mappings":"AAkBA;IACE;;;OAGG;IACH,uBAHW,KAAK,cACL,KAAK,EASf;IANC,kBAA4B;IAC5B,iBAA0B;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;;OAEG;IACH,4BAFW,GAAG,QAIb;IAED,gEAcC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sBAEC;IAED;;;;OAIG;IACH,QAFY,SAAS,OAAC,CAWrB;IAED;;;;OAIG;IACH,QAFY,SAAS,OAAC,CAWrB;IAED;;;;OAIG;IACH,WAFY,OAAO,CAIlB;IAED;;;;OAIG;IACH,WAFY,OAAO,CAIlB;CAOF;;;;;;iCApQsB,WAAW,KAAE,OAAO;;;;;;;2BACpB,IAAI,KAAE,OAAO;;;;;;;;;;;;eAWtB,SAAS;YACT,GAAG;UACH,MAAM,GAAC,MAAM;wBACb,GAAG,CAAC,OAAO,mBAAmB,EAAE,KAAK,EAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;;sBAtIhE,iBAAiB;6BAKK,iBAAiB;oBALvC,iBAAiB;qBAAjB,iBAAiB;4BAAjB,iBAAiB;uBAAjB,iBAAiB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export class DSDecoderV1 {
|
|
2
|
+
/**
|
|
3
|
+
* @param {decoding.Decoder} decoder
|
|
4
|
+
*/
|
|
5
|
+
constructor(decoder: decoding.Decoder);
|
|
6
|
+
restDecoder: decoding.Decoder<ArrayBufferLike>;
|
|
7
|
+
resetDsCurVal(): void;
|
|
8
|
+
/**
|
|
9
|
+
* @return {number}
|
|
10
|
+
*/
|
|
11
|
+
readDsClock(): number;
|
|
12
|
+
/**
|
|
13
|
+
* @return {number}
|
|
14
|
+
*/
|
|
15
|
+
readDsLen(): number;
|
|
16
|
+
}
|
|
17
|
+
export class UpdateDecoderV1 extends DSDecoderV1 {
|
|
18
|
+
/**
|
|
19
|
+
* @return {ID}
|
|
20
|
+
*/
|
|
21
|
+
readLeftID(): ID;
|
|
22
|
+
/**
|
|
23
|
+
* @return {ID}
|
|
24
|
+
*/
|
|
25
|
+
readRightID(): ID;
|
|
26
|
+
/**
|
|
27
|
+
* Read the next client id.
|
|
28
|
+
* Use this in favor of readID whenever possible to reduce the number of objects created.
|
|
29
|
+
*/
|
|
30
|
+
readClient(): number;
|
|
31
|
+
/**
|
|
32
|
+
* @return {number} info An unsigned 8-bit integer
|
|
33
|
+
*/
|
|
34
|
+
readInfo(): number;
|
|
35
|
+
/**
|
|
36
|
+
* @return {string}
|
|
37
|
+
*/
|
|
38
|
+
readString(): string;
|
|
39
|
+
/**
|
|
40
|
+
* @return {boolean} isKey
|
|
41
|
+
*/
|
|
42
|
+
readParentInfo(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @return {number} info An unsigned 8-bit integer
|
|
45
|
+
*/
|
|
46
|
+
readTypeRef(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Write len of a struct - well suited for Opt RLE encoder.
|
|
49
|
+
*
|
|
50
|
+
* @return {number} len
|
|
51
|
+
*/
|
|
52
|
+
readLen(): number;
|
|
53
|
+
/**
|
|
54
|
+
* @return {any}
|
|
55
|
+
*/
|
|
56
|
+
readAny(): any;
|
|
57
|
+
/**
|
|
58
|
+
* @return {Uint8Array}
|
|
59
|
+
*/
|
|
60
|
+
readBuf(): Uint8Array;
|
|
61
|
+
/**
|
|
62
|
+
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
63
|
+
*
|
|
64
|
+
* @return {any}
|
|
65
|
+
*/
|
|
66
|
+
readJSON(): any;
|
|
67
|
+
/**
|
|
68
|
+
* @return {string}
|
|
69
|
+
*/
|
|
70
|
+
readKey(): string;
|
|
71
|
+
}
|
|
72
|
+
export class DSDecoderV2 {
|
|
73
|
+
/**
|
|
74
|
+
* @param {decoding.Decoder} decoder
|
|
75
|
+
*/
|
|
76
|
+
constructor(decoder: decoding.Decoder);
|
|
77
|
+
/**
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private dsCurrVal;
|
|
81
|
+
restDecoder: decoding.Decoder<ArrayBufferLike>;
|
|
82
|
+
resetDsCurVal(): void;
|
|
83
|
+
/**
|
|
84
|
+
* @return {number}
|
|
85
|
+
*/
|
|
86
|
+
readDsClock(): number;
|
|
87
|
+
/**
|
|
88
|
+
* @return {number}
|
|
89
|
+
*/
|
|
90
|
+
readDsLen(): number;
|
|
91
|
+
}
|
|
92
|
+
export class UpdateDecoderV2 extends DSDecoderV2 {
|
|
93
|
+
/**
|
|
94
|
+
* List of cached keys. If the keys[id] does not exist, we read a new key
|
|
95
|
+
* from stringEncoder and push it to keys.
|
|
96
|
+
*
|
|
97
|
+
* @type {Array<string>}
|
|
98
|
+
*/
|
|
99
|
+
keys: Array<string>;
|
|
100
|
+
keyClockDecoder: decoding.IntDiffOptRleDecoder;
|
|
101
|
+
clientDecoder: decoding.UintOptRleDecoder;
|
|
102
|
+
leftClockDecoder: decoding.IntDiffOptRleDecoder;
|
|
103
|
+
rightClockDecoder: decoding.IntDiffOptRleDecoder;
|
|
104
|
+
infoDecoder: decoding.RleDecoder<number>;
|
|
105
|
+
stringDecoder: decoding.StringDecoder;
|
|
106
|
+
parentInfoDecoder: decoding.RleDecoder<number>;
|
|
107
|
+
typeRefDecoder: decoding.UintOptRleDecoder;
|
|
108
|
+
lenDecoder: decoding.UintOptRleDecoder;
|
|
109
|
+
/**
|
|
110
|
+
* @return {ID}
|
|
111
|
+
*/
|
|
112
|
+
readLeftID(): ID;
|
|
113
|
+
/**
|
|
114
|
+
* @return {ID}
|
|
115
|
+
*/
|
|
116
|
+
readRightID(): ID;
|
|
117
|
+
/**
|
|
118
|
+
* Read the next client id.
|
|
119
|
+
* Use this in favor of readID whenever possible to reduce the number of objects created.
|
|
120
|
+
*/
|
|
121
|
+
readClient(): number;
|
|
122
|
+
/**
|
|
123
|
+
* @return {number} info An unsigned 8-bit integer
|
|
124
|
+
*/
|
|
125
|
+
readInfo(): number;
|
|
126
|
+
/**
|
|
127
|
+
* @return {string}
|
|
128
|
+
*/
|
|
129
|
+
readString(): string;
|
|
130
|
+
/**
|
|
131
|
+
* @return {boolean}
|
|
132
|
+
*/
|
|
133
|
+
readParentInfo(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* @return {number} An unsigned 8-bit integer
|
|
136
|
+
*/
|
|
137
|
+
readTypeRef(): number;
|
|
138
|
+
/**
|
|
139
|
+
* Write len of a struct - well suited for Opt RLE encoder.
|
|
140
|
+
*
|
|
141
|
+
* @return {number}
|
|
142
|
+
*/
|
|
143
|
+
readLen(): number;
|
|
144
|
+
/**
|
|
145
|
+
* @return {any}
|
|
146
|
+
*/
|
|
147
|
+
readAny(): any;
|
|
148
|
+
/**
|
|
149
|
+
* @return {Uint8Array}
|
|
150
|
+
*/
|
|
151
|
+
readBuf(): Uint8Array;
|
|
152
|
+
/**
|
|
153
|
+
* This is mainly here for legacy purposes.
|
|
154
|
+
*
|
|
155
|
+
* Initial we incoded objects using JSON. Now we use the much faster lib0/any-encoder. This method mainly exists for legacy purposes for the v1 encoder.
|
|
156
|
+
*
|
|
157
|
+
* @return {any}
|
|
158
|
+
*/
|
|
159
|
+
readJSON(): any;
|
|
160
|
+
/**
|
|
161
|
+
* @return {string}
|
|
162
|
+
*/
|
|
163
|
+
readKey(): string;
|
|
164
|
+
}
|
|
165
|
+
import * as decoding from 'lib0/decoding';
|
|
166
|
+
import { ID } from '../internals.js';
|
|
167
|
+
//# sourceMappingURL=UpdateDecoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateDecoder.d.ts","sourceRoot":"","sources":["../../../src/utils/UpdateDecoder.js"],"names":[],"mappings":"AAMA;IACE;;OAEG;IACH,qBAFW,QAAQ,CAAC,OAAO,EAI1B;IADC,+CAA0B;IAG5B,sBAEC;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;OAEG;IACH,aAFY,MAAM,CAIjB;CACF;AAED;IACE;;OAEG;IACH,cAFY,EAAE,CAIb;IAED;;OAEG;IACH,eAFY,EAAE,CAIb;IAED;;;OAGG;IACH,qBAEC;IAED;;OAEG;IACH,YAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,MAAM,CAIjB;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,WAFY,MAAM,CAIjB;IAED;;OAEG;IACH,WAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,UAAU,CAIrB;IAED;;;;OAIG;IACH,YAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,MAAM,CAIjB;CACF;AAED;IACE;;OAEG;IACH,qBAFW,QAAQ,CAAC,OAAO,EAQ1B;IALC;;OAEG;IACH,kBAAkB;IAClB,+CAA0B;IAG5B,sBAEC;IAED;;OAEG;IACH,eAFY,MAAM,CAKjB;IAED;;OAEG;IACH,aAFY,MAAM,CAMjB;CACF;AAED;IAMI;;;;;OAKG;IACH,MAFU,KAAK,CAAC,MAAM,CAAC,CAET;IAEd,+CAA6F;IAC7F,0CAAwF;IACxF,gDAA8F;IAC9F,iDAA+F;IAC/F,yCAAmG;IACnG,sCAAoF;IACpF,+CAAyG;IACzG,2CAAyF;IACzF,uCAAqF;IAGvF;;OAEG;IACH,cAFY,EAAE,CAIb;IAED;;OAEG;IACH,eAFY,EAAE,CAIb;IAED;;;OAGG;IACH,qBAEC;IAED;;OAEG;IACH,YAFY,MAAM,CAIjB;IAED;;OAEG;IACH,cAFY,MAAM,CAIjB;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;OAEG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,WAFY,MAAM,CAIjB;IAED;;OAEG;IACH,WAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,UAAU,CAIrB;IAED;;;;;;OAMG;IACH,YAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,MAAM,CAWjB;CACF;0BAvRyB,eAAe;mBAGlC,iBAAiB"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export class IdSetEncoderV1 {
|
|
2
|
+
restEncoder: encoding.Encoder;
|
|
3
|
+
toUint8Array(): Uint8Array<ArrayBuffer>;
|
|
4
|
+
resetIdSetCurVal(): void;
|
|
5
|
+
/**
|
|
6
|
+
* @param {number} clock
|
|
7
|
+
*/
|
|
8
|
+
writeIdSetClock(clock: number): void;
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} len
|
|
11
|
+
*/
|
|
12
|
+
writeIdSetLen(len: number): void;
|
|
13
|
+
}
|
|
14
|
+
export class UpdateEncoderV1 extends IdSetEncoderV1 {
|
|
15
|
+
/**
|
|
16
|
+
* @param {ID} id
|
|
17
|
+
*/
|
|
18
|
+
writeLeftID(id: ID): void;
|
|
19
|
+
/**
|
|
20
|
+
* @param {ID} id
|
|
21
|
+
*/
|
|
22
|
+
writeRightID(id: ID): void;
|
|
23
|
+
/**
|
|
24
|
+
* Use writeClient and writeClock instead of writeID if possible.
|
|
25
|
+
* @param {number} client
|
|
26
|
+
*/
|
|
27
|
+
writeClient(client: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* @param {number} info An unsigned 8-bit integer
|
|
30
|
+
*/
|
|
31
|
+
writeInfo(info: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} s
|
|
34
|
+
*/
|
|
35
|
+
writeString(s: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* @param {boolean} isYKey
|
|
38
|
+
*/
|
|
39
|
+
writeParentInfo(isYKey: boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
* @param {number} info An unsigned 8-bit integer
|
|
42
|
+
*/
|
|
43
|
+
writeTypeRef(info: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Write len of a struct - well suited for Opt RLE encoder.
|
|
46
|
+
*
|
|
47
|
+
* @param {number} len
|
|
48
|
+
*/
|
|
49
|
+
writeLen(len: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* @param {any} any
|
|
52
|
+
*/
|
|
53
|
+
writeAny(any: any): void;
|
|
54
|
+
/**
|
|
55
|
+
* @param {Uint8Array} buf
|
|
56
|
+
*/
|
|
57
|
+
writeBuf(buf: Uint8Array): void;
|
|
58
|
+
/**
|
|
59
|
+
* @param {any} embed
|
|
60
|
+
*/
|
|
61
|
+
writeJSON(embed: any): void;
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} key
|
|
64
|
+
*/
|
|
65
|
+
writeKey(key: string): void;
|
|
66
|
+
}
|
|
67
|
+
export class IdSetEncoderV2 {
|
|
68
|
+
restEncoder: encoding.Encoder;
|
|
69
|
+
dsCurrVal: number;
|
|
70
|
+
toUint8Array(): Uint8Array<ArrayBuffer>;
|
|
71
|
+
resetIdSetCurVal(): void;
|
|
72
|
+
/**
|
|
73
|
+
* @param {number} clock
|
|
74
|
+
*/
|
|
75
|
+
writeIdSetClock(clock: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* @param {number} len
|
|
78
|
+
*/
|
|
79
|
+
writeIdSetLen(len: number): void;
|
|
80
|
+
}
|
|
81
|
+
export class UpdateEncoderV2 extends IdSetEncoderV2 {
|
|
82
|
+
/**
|
|
83
|
+
* @type {Map<string,number>}
|
|
84
|
+
*/
|
|
85
|
+
keyMap: Map<string, number>;
|
|
86
|
+
/**
|
|
87
|
+
* Refers to the next unique key-identifier to me used.
|
|
88
|
+
* See writeKey method for more information.
|
|
89
|
+
*
|
|
90
|
+
* @type {number}
|
|
91
|
+
*/
|
|
92
|
+
keyClock: number;
|
|
93
|
+
keyClockEncoder: encoding.IntDiffOptRleEncoder;
|
|
94
|
+
clientEncoder: encoding.UintOptRleEncoder;
|
|
95
|
+
leftClockEncoder: encoding.IntDiffOptRleEncoder;
|
|
96
|
+
rightClockEncoder: encoding.IntDiffOptRleEncoder;
|
|
97
|
+
infoEncoder: encoding.RleEncoder<number>;
|
|
98
|
+
stringEncoder: encoding.StringEncoder;
|
|
99
|
+
parentInfoEncoder: encoding.RleEncoder<number>;
|
|
100
|
+
typeRefEncoder: encoding.UintOptRleEncoder;
|
|
101
|
+
lenEncoder: encoding.UintOptRleEncoder;
|
|
102
|
+
/**
|
|
103
|
+
* @param {ID} id
|
|
104
|
+
*/
|
|
105
|
+
writeLeftID(id: ID): void;
|
|
106
|
+
/**
|
|
107
|
+
* @param {ID} id
|
|
108
|
+
*/
|
|
109
|
+
writeRightID(id: ID): void;
|
|
110
|
+
/**
|
|
111
|
+
* @param {number} client
|
|
112
|
+
*/
|
|
113
|
+
writeClient(client: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* @param {number} info An unsigned 8-bit integer
|
|
116
|
+
*/
|
|
117
|
+
writeInfo(info: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} s
|
|
120
|
+
*/
|
|
121
|
+
writeString(s: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* @param {boolean} isYKey
|
|
124
|
+
*/
|
|
125
|
+
writeParentInfo(isYKey: boolean): void;
|
|
126
|
+
/**
|
|
127
|
+
* @param {number} info An unsigned 8-bit integer
|
|
128
|
+
*/
|
|
129
|
+
writeTypeRef(info: number): void;
|
|
130
|
+
/**
|
|
131
|
+
* Write len of a struct - well suited for Opt RLE encoder.
|
|
132
|
+
*
|
|
133
|
+
* @param {number} len
|
|
134
|
+
*/
|
|
135
|
+
writeLen(len: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* @param {any} any
|
|
138
|
+
*/
|
|
139
|
+
writeAny(any: any): void;
|
|
140
|
+
/**
|
|
141
|
+
* @param {Uint8Array} buf
|
|
142
|
+
*/
|
|
143
|
+
writeBuf(buf: Uint8Array): void;
|
|
144
|
+
/**
|
|
145
|
+
* This is mainly here for legacy purposes.
|
|
146
|
+
*
|
|
147
|
+
* Initial we incoded objects using JSON. Now we use the much faster lib0/any-encoder. This method mainly exists for legacy purposes for the v1 encoder.
|
|
148
|
+
*
|
|
149
|
+
* @param {any} embed
|
|
150
|
+
*/
|
|
151
|
+
writeJSON(embed: any): void;
|
|
152
|
+
/**
|
|
153
|
+
* Property keys are often reused. For example, in y-prosemirror the key `bold` might
|
|
154
|
+
* occur very often. For a 3d application, the key `position` might occur very often.
|
|
155
|
+
*
|
|
156
|
+
* We cache these keys in a Map and refer to them via a unique number.
|
|
157
|
+
*
|
|
158
|
+
* @param {string} key
|
|
159
|
+
*/
|
|
160
|
+
writeKey(key: string): void;
|
|
161
|
+
}
|
|
162
|
+
import * as encoding from 'lib0/encoding';
|
|
163
|
+
import { ID } from '../internals.js';
|
|
164
|
+
//# sourceMappingURL=UpdateEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateEncoder.d.ts","sourceRoot":"","sources":["../../../src/utils/UpdateEncoder.js"],"names":[],"mappings":"AAOA;IAEI,8BAA2C;IAG7C,wCAEC;IAED,yBAEC;IAED;;OAEG;IACH,uBAFW,MAAM,QAIhB;IAED;;OAEG;IACH,mBAFW,MAAM,QAIhB;CACF;AAED;IACE;;OAEG;IACH,gBAFW,EAAE,QAKZ;IAED;;OAEG;IACH,iBAFW,EAAE,QAKZ;IAED;;;OAGG;IACH,oBAFW,MAAM,QAIhB;IAED;;OAEG;IACH,gBAFW,MAAM,QAIhB;IAED;;OAEG;IACH,eAFW,MAAM,QAIhB;IAED;;OAEG;IACH,wBAFW,OAAO,QAIjB;IAED;;OAEG;IACH,mBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,cAFW,MAAM,QAIhB;IAED;;OAEG;IACH,cAFW,GAAG,QAIb;IAED;;OAEG;IACH,cAFW,UAAU,QAIpB;IAED;;OAEG;IACH,iBAFW,GAAG,QAIb;IAED;;OAEG;IACH,cAFW,MAAM,QAIhB;CACF;AAED;IAEI,8BAA2C;IAC3C,kBAAkB;IAGpB,wCAEC;IAED,yBAEC;IAED;;OAEG;IACH,uBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,mBAFW,MAAM,QAQhB;CACF;AAED;IAGI;;OAEG;IACH,QAFU,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC,CAEL;IACvB;;;;;OAKG;IACH,UAFU,MAAM,CAEC;IACjB,+CAA0D;IAC1D,0CAAqD;IACrD,gDAA2D;IAC3D,iDAA4D;I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