@y/y 14.0.0-rc.2 → 14.0.0-rc.20
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/README.md +36 -12
- package/dist/src/index.d.ts +24 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/structs/AbstractStruct.d.ts +14 -17
- package/dist/src/structs/AbstractStruct.d.ts.map +1 -1
- package/dist/src/structs/GC.d.ts +9 -14
- package/dist/src/structs/GC.d.ts.map +1 -1
- package/dist/src/structs/Item.d.ts +569 -31
- package/dist/src/structs/Item.d.ts.map +1 -1
- package/dist/src/structs/Skip.d.ts +9 -11
- package/dist/src/structs/Skip.d.ts.map +1 -1
- package/dist/src/utils/BlockSet.d.ts +8 -7
- package/dist/src/utils/BlockSet.d.ts.map +1 -1
- package/dist/src/utils/Doc.d.ts +4 -9
- package/dist/src/utils/Doc.d.ts.map +1 -1
- package/dist/src/utils/ID.d.ts +0 -1
- package/dist/src/utils/ID.d.ts.map +1 -1
- package/dist/src/utils/RelativePosition.d.ts +2 -5
- package/dist/src/utils/RelativePosition.d.ts.map +1 -1
- package/dist/src/utils/Renderer.d.ts +144 -0
- package/dist/src/utils/Renderer.d.ts.map +1 -0
- package/dist/src/utils/Snapshot.d.ts +7 -11
- package/dist/src/utils/Snapshot.d.ts.map +1 -1
- package/dist/src/utils/StructStore.d.ts +45 -23
- package/dist/src/utils/StructStore.d.ts.map +1 -1
- package/dist/src/utils/Transaction.d.ts +11 -21
- package/dist/src/utils/Transaction.d.ts.map +1 -1
- package/dist/src/utils/UndoManager.d.ts +13 -14
- package/dist/src/utils/UndoManager.d.ts.map +1 -1
- package/dist/src/utils/UpdateDecoder.d.ts +1 -1
- package/dist/src/utils/UpdateDecoder.d.ts.map +1 -1
- package/dist/src/utils/UpdateEncoder.d.ts +0 -1
- package/dist/src/utils/UpdateEncoder.d.ts.map +1 -1
- package/dist/src/utils/YEvent.d.ts +22 -26
- package/dist/src/utils/YEvent.d.ts.map +1 -1
- package/dist/src/utils/content-helper.d.ts +2 -0
- package/dist/src/utils/content-helper.d.ts.map +1 -0
- package/dist/src/utils/delta-helpers.d.ts +2 -3
- package/dist/src/utils/delta-helpers.d.ts.map +1 -1
- package/dist/src/utils/encoding-helpers.d.ts +6 -0
- package/dist/src/utils/encoding-helpers.d.ts.map +1 -0
- package/dist/src/utils/encoding.d.ts +16 -18
- package/dist/src/utils/encoding.d.ts.map +1 -1
- package/dist/src/utils/ids.d.ts +331 -0
- package/dist/src/utils/ids.d.ts.map +1 -0
- package/dist/src/utils/isParentOf.d.ts +1 -2
- package/dist/src/utils/isParentOf.d.ts.map +1 -1
- package/dist/src/utils/logging.d.ts +0 -1
- package/dist/src/utils/logging.d.ts.map +1 -1
- package/dist/src/utils/meta.d.ts +15 -64
- package/dist/src/utils/meta.d.ts.map +1 -1
- package/dist/src/utils/renderer-helpers.d.ts +99 -0
- package/dist/src/utils/renderer-helpers.d.ts.map +1 -0
- package/dist/src/utils/schemas.d.ts +3 -0
- package/dist/src/utils/schemas.d.ts.map +1 -0
- package/dist/src/utils/transaction-helpers.d.ts +18 -0
- package/dist/src/utils/transaction-helpers.d.ts.map +1 -0
- package/dist/src/utils/updates.d.ts +19 -25
- package/dist/src/utils/updates.d.ts.map +1 -1
- package/dist/src/ytype.d.ts +55 -24
- package/dist/src/ytype.d.ts.map +1 -1
- package/global.d.ts +53 -0
- package/package.json +12 -16
- package/src/index.js +32 -124
- package/src/structs/AbstractStruct.js +21 -16
- package/src/structs/GC.js +15 -20
- package/src/structs/Item.js +992 -318
- package/src/structs/Skip.js +16 -19
- package/src/utils/BlockSet.js +20 -20
- package/src/utils/Doc.js +15 -29
- package/src/utils/ID.js +0 -2
- package/src/utils/RelativePosition.js +15 -25
- package/src/utils/{AttributionManager.js → Renderer.js} +42 -197
- package/src/utils/Snapshot.js +15 -37
- package/src/utils/StructStore.js +89 -227
- package/src/utils/Transaction.js +63 -307
- package/src/utils/UndoManager.js +157 -19
- package/src/utils/UpdateDecoder.js +2 -3
- package/src/utils/UpdateEncoder.js +0 -4
- package/src/utils/YEvent.js +20 -26
- package/src/utils/content-helper.js +0 -0
- package/src/utils/delta-helpers.js +21 -42
- package/src/utils/encoding-helpers.js +110 -0
- package/src/utils/encoding.js +197 -122
- package/src/utils/ids.js +1527 -0
- package/src/utils/isParentOf.js +2 -4
- package/src/utils/logging.js +0 -4
- package/src/utils/meta.js +57 -46
- package/src/utils/renderer-helpers.js +110 -0
- package/src/utils/schemas.js +3 -0
- package/src/utils/transaction-helpers.js +413 -0
- package/src/utils/updates.js +24 -146
- package/src/ytype.js +325 -117
- package/tests/testHelper.js +10 -12
- package/dist/src/internals.d.ts +0 -36
- package/dist/src/internals.d.ts.map +0 -1
- package/dist/src/structs/ContentAny.d.ts +0 -67
- package/dist/src/structs/ContentAny.d.ts.map +0 -1
- package/dist/src/structs/ContentBinary.d.ts +0 -64
- package/dist/src/structs/ContentBinary.d.ts.map +0 -1
- package/dist/src/structs/ContentDeleted.d.ts +0 -64
- package/dist/src/structs/ContentDeleted.d.ts.map +0 -1
- package/dist/src/structs/ContentDoc.d.ts +0 -72
- package/dist/src/structs/ContentDoc.d.ts.map +0 -1
- package/dist/src/structs/ContentEmbed.d.ts +0 -67
- package/dist/src/structs/ContentEmbed.d.ts.map +0 -1
- package/dist/src/structs/ContentFormat.d.ts +0 -69
- package/dist/src/structs/ContentFormat.d.ts.map +0 -1
- package/dist/src/structs/ContentJSON.d.ts +0 -70
- package/dist/src/structs/ContentJSON.d.ts.map +0 -1
- package/dist/src/structs/ContentString.d.ts +0 -70
- package/dist/src/structs/ContentString.d.ts.map +0 -1
- package/dist/src/structs/ContentType.d.ts +0 -77
- package/dist/src/structs/ContentType.d.ts.map +0 -1
- package/dist/src/utils/AttributionManager.d.ts +0 -238
- package/dist/src/utils/AttributionManager.d.ts.map +0 -1
- package/dist/src/utils/IdMap.d.ts +0 -164
- package/dist/src/utils/IdMap.d.ts.map +0 -1
- package/dist/src/utils/IdSet.d.ts +0 -163
- package/dist/src/utils/IdSet.d.ts.map +0 -1
- package/dist/tests/IdMap.tests.d.ts +0 -9
- package/dist/tests/IdMap.tests.d.ts.map +0 -1
- package/dist/tests/IdSet.tests.d.ts +0 -9
- package/dist/tests/IdSet.tests.d.ts.map +0 -1
- package/dist/tests/attribution.tests.d.ts +0 -9
- package/dist/tests/attribution.tests.d.ts.map +0 -1
- package/dist/tests/compatibility.tests.d.ts +0 -5
- package/dist/tests/compatibility.tests.d.ts.map +0 -1
- package/dist/tests/delta.tests.d.ts +0 -7
- package/dist/tests/delta.tests.d.ts.map +0 -1
- package/dist/tests/doc.tests.d.ts +0 -13
- package/dist/tests/doc.tests.d.ts.map +0 -1
- package/dist/tests/encoding.tests.d.ts +0 -5
- package/dist/tests/encoding.tests.d.ts.map +0 -1
- package/dist/tests/index.d.ts +0 -2
- package/dist/tests/index.d.ts.map +0 -1
- package/dist/tests/relativePositions.tests.d.ts +0 -11
- package/dist/tests/relativePositions.tests.d.ts.map +0 -1
- package/dist/tests/snapshot.tests.d.ts +0 -14
- package/dist/tests/snapshot.tests.d.ts.map +0 -1
- package/dist/tests/testHelper.d.ts +0 -171
- package/dist/tests/testHelper.d.ts.map +0 -1
- package/dist/tests/undo-redo.tests.d.ts +0 -27
- package/dist/tests/undo-redo.tests.d.ts.map +0 -1
- package/dist/tests/updates.tests.d.ts +0 -26
- package/dist/tests/updates.tests.d.ts.map +0 -1
- package/dist/tests/y-array.tests.d.ts +0 -43
- package/dist/tests/y-array.tests.d.ts.map +0 -1
- package/dist/tests/y-map.tests.d.ts +0 -42
- package/dist/tests/y-map.tests.d.ts.map +0 -1
- package/dist/tests/y-text.tests.d.ts +0 -49
- package/dist/tests/y-text.tests.d.ts.map +0 -1
- package/dist/tests/y-xml.tests.d.ts +0 -14
- package/dist/tests/y-xml.tests.d.ts.map +0 -1
- package/src/internals.js +0 -35
- package/src/structs/ContentAny.js +0 -115
- package/src/structs/ContentBinary.js +0 -93
- package/src/structs/ContentDeleted.js +0 -101
- package/src/structs/ContentDoc.js +0 -141
- package/src/structs/ContentEmbed.js +0 -98
- package/src/structs/ContentFormat.js +0 -105
- package/src/structs/ContentJSON.js +0 -119
- package/src/structs/ContentString.js +0 -113
- package/src/structs/ContentType.js +0 -152
- package/src/utils/IdMap.js +0 -673
- package/src/utils/IdSet.js +0 -825
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y/y",
|
|
3
|
-
"version": "14.0.0-rc.
|
|
3
|
+
"version": "14.0.0-rc.20",
|
|
4
4
|
"description": "Shared Editing Library",
|
|
5
|
-
"types": "./dist/src/index.d.ts",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"sideEffects": false,
|
|
8
7
|
"funding": {
|
|
@@ -13,9 +12,8 @@
|
|
|
13
12
|
"clean": "rm -rf dist",
|
|
14
13
|
"test": "NODE_ENV=development node ./tests/index.js --repetition-time 50",
|
|
15
14
|
"test-extensive": "node ./tests/index.js --production --repetition-time 10000",
|
|
16
|
-
"dist": "npm run clean &&
|
|
17
|
-
"
|
|
18
|
-
"lint": "markdownlint README.md && standard && tsc --skipLibCheck",
|
|
15
|
+
"dist": "npm run clean && PRODUCTION=1 tsc --noEmit false && test -e dist/src/index.d.ts",
|
|
16
|
+
"lint": "markdownlint README.md && standard && tsc && npx dpdm --exit-code circular:1 --warning false --tree false src/index.js",
|
|
19
17
|
"debug": "npm run gentesthtml && 0serve -o test.html",
|
|
20
18
|
"debug:node": "node --inspect-brk tests/index.js",
|
|
21
19
|
"trace-deopt": "clear && node --trace-deopt ./tests/index.js",
|
|
@@ -27,10 +25,6 @@
|
|
|
27
25
|
"types": "./dist/src/index.d.ts",
|
|
28
26
|
"default": "./src/index.js"
|
|
29
27
|
},
|
|
30
|
-
"./internals": {
|
|
31
|
-
"types": "./dist/src/internals.d.ts",
|
|
32
|
-
"default": "./src/internals.js"
|
|
33
|
-
},
|
|
34
28
|
"./meta": {
|
|
35
29
|
"types": "./dist/src/utils/meta.d.ts",
|
|
36
30
|
"default": "./src/utils/meta.js"
|
|
@@ -43,8 +37,9 @@
|
|
|
43
37
|
},
|
|
44
38
|
"files": [
|
|
45
39
|
"src",
|
|
46
|
-
"dist",
|
|
47
|
-
"tests/testHelper.js"
|
|
40
|
+
"dist/src",
|
|
41
|
+
"tests/testHelper.js",
|
|
42
|
+
"global.d.ts"
|
|
48
43
|
],
|
|
49
44
|
"dictionaries": {
|
|
50
45
|
"test": "tests"
|
|
@@ -76,19 +71,20 @@
|
|
|
76
71
|
},
|
|
77
72
|
"homepage": "https://docs.yjs.dev",
|
|
78
73
|
"dependencies": {
|
|
79
|
-
"lib0": "^1.0.0-rc.
|
|
74
|
+
"lib0": "^1.0.0-rc.15"
|
|
80
75
|
},
|
|
81
76
|
"devDependencies": {
|
|
82
77
|
"@types/node": "^22.14.1",
|
|
83
78
|
"@y/protocols": "^1.0.6-rc.1",
|
|
79
|
+
"@y/y": ".",
|
|
80
|
+
"dpdm": "^4.0.1",
|
|
84
81
|
"markdownlint": "^0.40.0",
|
|
85
|
-
"markdownlint-cli": "^0.
|
|
82
|
+
"markdownlint-cli": "^0.43.0",
|
|
86
83
|
"standard": "^17.1.2",
|
|
87
|
-
"typescript": "^5.9.3"
|
|
88
|
-
"@y/y": "."
|
|
84
|
+
"typescript": "^5.9.3"
|
|
89
85
|
},
|
|
90
86
|
"engines": {
|
|
91
87
|
"npm": ">=8.0.0",
|
|
92
|
-
"node": ">=
|
|
88
|
+
"node": ">=22.0.0"
|
|
93
89
|
}
|
|
94
90
|
}
|
package/src/index.js
CHANGED
|
@@ -1,132 +1,40 @@
|
|
|
1
|
+
/// <reference types="../global.d.ts" />
|
|
1
2
|
/** eslint-env browser */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
RelativePosition,
|
|
28
|
-
ID,
|
|
29
|
-
createID,
|
|
30
|
-
compareIDs,
|
|
31
|
-
getState,
|
|
32
|
-
Snapshot,
|
|
33
|
-
createSnapshot,
|
|
34
|
-
cleanupYTextFormatting,
|
|
35
|
-
snapshot,
|
|
36
|
-
emptySnapshot,
|
|
37
|
-
findRootTypeKey,
|
|
38
|
-
findIndexSS,
|
|
39
|
-
getItem,
|
|
40
|
-
getItemCleanStart,
|
|
41
|
-
getItemCleanEnd,
|
|
42
|
-
typeMapGetSnapshot,
|
|
43
|
-
typeMapGetAllSnapshot,
|
|
44
|
-
createDocFromSnapshot,
|
|
45
|
-
applyUpdate,
|
|
46
|
-
applyUpdateV2,
|
|
47
|
-
readUpdate,
|
|
48
|
-
readUpdateV2,
|
|
49
|
-
encodeStateAsUpdate,
|
|
50
|
-
encodeStateAsUpdateV2,
|
|
51
|
-
encodeStateVector,
|
|
52
|
-
UndoManager,
|
|
53
|
-
decodeSnapshot,
|
|
54
|
-
encodeSnapshot,
|
|
55
|
-
decodeSnapshotV2,
|
|
56
|
-
encodeSnapshotV2,
|
|
57
|
-
decodeStateVector,
|
|
58
|
-
logUpdate,
|
|
59
|
-
logUpdateV2,
|
|
60
|
-
decodeUpdate,
|
|
61
|
-
decodeUpdateV2,
|
|
62
|
-
relativePositionToJSON,
|
|
63
|
-
isParentOf,
|
|
64
|
-
equalSnapshots,
|
|
65
|
-
tryGc,
|
|
66
|
-
transact,
|
|
67
|
-
logType,
|
|
68
|
-
mergeUpdates,
|
|
69
|
-
mergeUpdatesV2,
|
|
70
|
-
encodeStateVectorFromUpdate,
|
|
71
|
-
encodeStateVectorFromUpdateV2,
|
|
72
|
-
encodeRelativePosition,
|
|
73
|
-
decodeRelativePosition,
|
|
74
|
-
diffUpdate,
|
|
75
|
-
diffUpdateV2,
|
|
76
|
-
convertUpdateFormatV1ToV2,
|
|
77
|
-
convertUpdateFormatV2ToV1,
|
|
78
|
-
obfuscateUpdate,
|
|
79
|
-
obfuscateUpdateV2,
|
|
80
|
-
UpdateEncoderV1,
|
|
81
|
-
UpdateEncoderV2,
|
|
82
|
-
UpdateDecoderV1,
|
|
83
|
-
UpdateDecoderV2,
|
|
84
|
-
snapshotContainsUpdate,
|
|
85
|
-
// idset
|
|
86
|
-
IdSet,
|
|
87
|
-
equalIdSets,
|
|
88
|
-
createDeleteSetFromStructStore,
|
|
89
|
-
IdMap,
|
|
90
|
-
createIdMap,
|
|
91
|
-
createContentAttribute,
|
|
92
|
-
createInsertSetFromStructStore,
|
|
93
|
-
diffIdMap,
|
|
94
|
-
diffIdSet,
|
|
95
|
-
ContentAttribute,
|
|
96
|
-
encodeIdMap,
|
|
97
|
-
createIdMapFromIdSet,
|
|
98
|
-
TwosetAttributionManager,
|
|
99
|
-
noAttributionsManager,
|
|
100
|
-
AbstractAttributionManager,
|
|
101
|
-
iterateStructsByIdSet,
|
|
102
|
-
createAttributionManagerFromDiff,
|
|
103
|
-
DiffAttributionManager,
|
|
104
|
-
createAttributionManagerFromSnapshots,
|
|
105
|
-
SnapshotAttributionManager,
|
|
106
|
-
createIdSet,
|
|
107
|
-
mergeIdSets,
|
|
108
|
-
cloneDoc,
|
|
109
|
-
createContentIdsFromUpdate,
|
|
110
|
-
createContentIdsFromUpdateV2,
|
|
111
|
-
insertIntoIdMap,
|
|
112
|
-
insertIntoIdSet,
|
|
113
|
-
mergeIdMaps,
|
|
114
|
-
readIdMap,
|
|
115
|
-
readIdSet,
|
|
116
|
-
decodeIdMap,
|
|
117
|
-
diffDocsToDelta,
|
|
118
|
-
getPathTo,
|
|
119
|
-
Attributions,
|
|
120
|
-
filterIdMap,
|
|
121
|
-
undoContentIds,
|
|
122
|
-
intersectUpdateWithContentIds,
|
|
123
|
-
intersectUpdateWithContentIdsV2,
|
|
124
|
-
createDocFromUpdate,
|
|
125
|
-
createDocFromUpdateV2
|
|
126
|
-
} from './internals.js'
|
|
4
|
+
// Order matters: follows internals.js ordering to avoid circular dependency issues
|
|
5
|
+
|
|
6
|
+
export { IdSet, equalIdSets, createDeleteSetFromStructStore, createInsertSetFromStructStore, diffIdSet, createIdSet, mergeIdSets, insertIntoIdSet, iterateStructsByIdSet, gcIdSet, readIdSet, writeIdSet, encodeIdSet, decodeIdSet, IdMap, createIdMap, createContentAttribute, ContentAttribute, diffIdMap, encodeIdMap, createIdMapFromIdSet, createIdSetFromIdMap, insertIntoIdMap, mergeIdMaps, readIdMap, writeIdMap, decodeIdMap, filterIdMap, intersectSets, intersectMaps } from './utils/ids.js'
|
|
7
|
+
export { Doc } from './utils/Doc.js'
|
|
8
|
+
export { UpdateDecoderV1, UpdateDecoderV2 } from './utils/UpdateDecoder.js'
|
|
9
|
+
export { UpdateEncoderV1, UpdateEncoderV2 } from './utils/UpdateEncoder.js'
|
|
10
|
+
export { applyUpdate, applyUpdateV2, readUpdate, readUpdateV2, encodeStateAsUpdate, encodeStateAsUpdateV2, encodeStateVector, decodeStateVector, diffUpdate, diffUpdateV2, mergeUpdates, mergeUpdatesV2, createDocFromUpdate, createDocFromUpdateV2, cloneDoc } from './utils/encoding.js'
|
|
11
|
+
export { ID, createID, compareIDs, findRootTypeKey } from './utils/ID.js'
|
|
12
|
+
export { isParentOf } from './utils/isParentOf.js'
|
|
13
|
+
export { logType } from './utils/logging.js'
|
|
14
|
+
export { createRelativePositionFromTypeIndex, createRelativePositionFromJSON, createAbsolutePositionFromRelativePosition, compareRelativePositions, AbsolutePosition, RelativePosition, relativePositionToJSON, encodeRelativePosition, decodeRelativePosition } from './utils/RelativePosition.js'
|
|
15
|
+
export { Snapshot, createSnapshot, snapshot, emptySnapshot, createDocFromSnapshot, decodeSnapshot, encodeSnapshot, decodeSnapshotV2, encodeSnapshotV2, equalSnapshots, snapshotContainsUpdate } from './utils/Snapshot.js'
|
|
16
|
+
export { findIndexSS, getItemCleanStart, getItemCleanEnd, tryGc } from './utils/transaction-helpers.js'
|
|
17
|
+
export { Transaction, transact, cleanupYTextFormatting } from './utils/Transaction.js'
|
|
18
|
+
export { UndoManager, undoContentIds } from './utils/UndoManager.js'
|
|
19
|
+
export { logUpdate, logUpdateV2, decodeUpdate, decodeUpdateV2, encodeStateVectorFromUpdate, encodeStateVectorFromUpdateV2, convertUpdateFormatV1ToV2, convertUpdateFormatV2ToV1, obfuscateUpdate, obfuscateUpdateV2, createContentIdsFromUpdate, createContentIdsFromUpdateV2, intersectUpdateWithContentIds, intersectUpdateWithContentIdsV2 } from './utils/updates.js'
|
|
20
|
+
export { YEvent, getPathTo } from './utils/YEvent.js'
|
|
21
|
+
export { TwosetRenderer, baseRenderer, AbstractRenderer, createDiffRenderer, DiffRenderer, createSnapshotRenderer, SnapshotRenderer, Attributions, $renderer } from './utils/Renderer.js'
|
|
22
|
+
export { diffDocsToDelta } from './utils/delta-helpers.js'
|
|
23
|
+
export { YType as Type, getTypeChildren, typeMapGetSnapshot, typeMapGetAllSnapshot, $ytype, $ytypeAny } from './ytype.js'
|
|
24
|
+
export { AbstractStruct } from './structs/AbstractStruct.js'
|
|
25
|
+
export { GC } from './structs/GC.js'
|
|
26
|
+
export { Item, ContentBinary, ContentDeleted, ContentDoc, ContentEmbed, ContentFormat, ContentJSON, ContentAny, ContentString, ContentType } from './structs/Item.js'
|
|
27
|
+
export { Skip } from './structs/Skip.js'
|
|
127
28
|
|
|
128
29
|
export * from './utils/meta.js'
|
|
129
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {import('./utils/ids.js').ContentIds} ContentIds
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {import('./utils/ids.js').ContentMap} ContentMap
|
|
36
|
+
*/
|
|
37
|
+
|
|
130
38
|
const glo = /** @type {any} */ (typeof globalThis !== 'undefined'
|
|
131
39
|
? globalThis
|
|
132
40
|
: typeof window !== 'undefined'
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UpdateEncoderV1, UpdateEncoderV2, ID, Transaction // eslint-disable-line
|
|
3
|
-
} from '../internals.js'
|
|
4
|
-
|
|
5
1
|
import * as error from 'lib0/error'
|
|
6
2
|
|
|
7
3
|
export class AbstractStruct {
|
|
@@ -25,35 +21,44 @@ export class AbstractStruct {
|
|
|
25
21
|
* Merge this struct with the item to the right.
|
|
26
22
|
* This method is already assuming that `this.id.clock + this.length === this.id.clock`.
|
|
27
23
|
* Also this method does *not* remove right from StructStore!
|
|
28
|
-
* @param {
|
|
24
|
+
* @param {GC|Item|Skip} _right
|
|
29
25
|
* @return {boolean} whether this merged with right
|
|
30
26
|
*/
|
|
31
|
-
mergeWith (
|
|
27
|
+
mergeWith (_right) {
|
|
32
28
|
return false
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
/**
|
|
36
|
-
* @param {UpdateEncoderV1 | UpdateEncoderV2}
|
|
37
|
-
* @param {number}
|
|
38
|
-
* @param {number}
|
|
32
|
+
* @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder The encoder to write data to.
|
|
33
|
+
* @param {number} _offset
|
|
34
|
+
* @param {number} _encodingRef
|
|
39
35
|
*/
|
|
40
|
-
write (
|
|
36
|
+
write (_encoder, _offset, _encodingRef) {
|
|
41
37
|
throw error.methodUnimplemented()
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
/**
|
|
45
|
-
* @param {Transaction}
|
|
46
|
-
* @param {number}
|
|
41
|
+
* @param {Transaction} _transaction
|
|
42
|
+
* @param {number} _offset
|
|
47
43
|
*/
|
|
48
|
-
integrate (
|
|
44
|
+
integrate (_transaction, _offset) {
|
|
49
45
|
throw error.methodUnimplemented()
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
/**
|
|
53
|
-
* @param {number}
|
|
54
|
-
* @return {
|
|
49
|
+
* @param {number} _diff
|
|
50
|
+
* @return {GC|Item|Skip}
|
|
55
51
|
*/
|
|
56
|
-
splice (
|
|
52
|
+
splice (_diff) {
|
|
57
53
|
throw error.methodUnimplemented()
|
|
58
54
|
}
|
|
59
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {IdSet} idSet
|
|
59
|
+
* @param {AbstractStruct} struct
|
|
60
|
+
*
|
|
61
|
+
* @private
|
|
62
|
+
* @function
|
|
63
|
+
*/
|
|
64
|
+
export const addStructToIdSet = (idSet, struct) => idSet.add(struct.id.client, struct.id.clock, struct.length)
|
package/src/structs/GC.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
addStruct,
|
|
4
|
-
addStructToIdSet,
|
|
5
|
-
addToIdSet,
|
|
6
|
-
createID,
|
|
7
|
-
UpdateEncoderV1, UpdateEncoderV2, StructStore, Transaction // eslint-disable-line
|
|
8
|
-
} from '../internals.js'
|
|
1
|
+
import { AbstractStruct, addStructToIdSet } from './AbstractStruct.js'
|
|
2
|
+
import { createID } from '../utils/ID.js'
|
|
9
3
|
|
|
10
4
|
export const structGCRefNumber = 0
|
|
11
5
|
|
|
@@ -20,7 +14,7 @@ export class GC extends AbstractStruct {
|
|
|
20
14
|
delete () {}
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
|
-
* @param {GC} right
|
|
17
|
+
* @param {GC | Skip | Item} right
|
|
24
18
|
* @return {boolean}
|
|
25
19
|
*/
|
|
26
20
|
mergeWith (right) {
|
|
@@ -40,9 +34,9 @@ export class GC extends AbstractStruct {
|
|
|
40
34
|
this.id.clock += offset
|
|
41
35
|
this.length -= offset
|
|
42
36
|
}
|
|
43
|
-
|
|
37
|
+
transaction.deleteSet.add(this.id.client, this.id.clock, this.length)
|
|
44
38
|
addStructToIdSet(transaction.insertSet, this)
|
|
45
|
-
|
|
39
|
+
transaction.doc.store.add(this)
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
/**
|
|
@@ -55,15 +49,6 @@ export class GC extends AbstractStruct {
|
|
|
55
49
|
encoder.writeLen(this.length - offset - offsetEnd)
|
|
56
50
|
}
|
|
57
51
|
|
|
58
|
-
/**
|
|
59
|
-
* @param {Transaction} _transaction
|
|
60
|
-
* @param {StructStore} _store
|
|
61
|
-
* @return {null | number}
|
|
62
|
-
*/
|
|
63
|
-
getMissing (_transaction, _store) {
|
|
64
|
-
return null
|
|
65
|
-
}
|
|
66
|
-
|
|
67
52
|
/**
|
|
68
53
|
* gc structs can't be spliced.
|
|
69
54
|
*
|
|
@@ -78,3 +63,13 @@ export class GC extends AbstractStruct {
|
|
|
78
63
|
return other
|
|
79
64
|
}
|
|
80
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @type {0}
|
|
69
|
+
*/
|
|
70
|
+
GC.prototype.ref = structGCRefNumber
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @type {false}
|
|
74
|
+
*/
|
|
75
|
+
GC.prototype.isItem = false
|