@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.
Files changed (166) hide show
  1. package/README.md +36 -12
  2. package/dist/src/index.d.ts +24 -1
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/structs/AbstractStruct.d.ts +14 -17
  5. package/dist/src/structs/AbstractStruct.d.ts.map +1 -1
  6. package/dist/src/structs/GC.d.ts +9 -14
  7. package/dist/src/structs/GC.d.ts.map +1 -1
  8. package/dist/src/structs/Item.d.ts +569 -31
  9. package/dist/src/structs/Item.d.ts.map +1 -1
  10. package/dist/src/structs/Skip.d.ts +9 -11
  11. package/dist/src/structs/Skip.d.ts.map +1 -1
  12. package/dist/src/utils/BlockSet.d.ts +8 -7
  13. package/dist/src/utils/BlockSet.d.ts.map +1 -1
  14. package/dist/src/utils/Doc.d.ts +4 -9
  15. package/dist/src/utils/Doc.d.ts.map +1 -1
  16. package/dist/src/utils/ID.d.ts +0 -1
  17. package/dist/src/utils/ID.d.ts.map +1 -1
  18. package/dist/src/utils/RelativePosition.d.ts +2 -5
  19. package/dist/src/utils/RelativePosition.d.ts.map +1 -1
  20. package/dist/src/utils/Renderer.d.ts +144 -0
  21. package/dist/src/utils/Renderer.d.ts.map +1 -0
  22. package/dist/src/utils/Snapshot.d.ts +7 -11
  23. package/dist/src/utils/Snapshot.d.ts.map +1 -1
  24. package/dist/src/utils/StructStore.d.ts +45 -23
  25. package/dist/src/utils/StructStore.d.ts.map +1 -1
  26. package/dist/src/utils/Transaction.d.ts +11 -21
  27. package/dist/src/utils/Transaction.d.ts.map +1 -1
  28. package/dist/src/utils/UndoManager.d.ts +13 -14
  29. package/dist/src/utils/UndoManager.d.ts.map +1 -1
  30. package/dist/src/utils/UpdateDecoder.d.ts +1 -1
  31. package/dist/src/utils/UpdateDecoder.d.ts.map +1 -1
  32. package/dist/src/utils/UpdateEncoder.d.ts +0 -1
  33. package/dist/src/utils/UpdateEncoder.d.ts.map +1 -1
  34. package/dist/src/utils/YEvent.d.ts +22 -26
  35. package/dist/src/utils/YEvent.d.ts.map +1 -1
  36. package/dist/src/utils/content-helper.d.ts +2 -0
  37. package/dist/src/utils/content-helper.d.ts.map +1 -0
  38. package/dist/src/utils/delta-helpers.d.ts +2 -3
  39. package/dist/src/utils/delta-helpers.d.ts.map +1 -1
  40. package/dist/src/utils/encoding-helpers.d.ts +6 -0
  41. package/dist/src/utils/encoding-helpers.d.ts.map +1 -0
  42. package/dist/src/utils/encoding.d.ts +16 -18
  43. package/dist/src/utils/encoding.d.ts.map +1 -1
  44. package/dist/src/utils/ids.d.ts +331 -0
  45. package/dist/src/utils/ids.d.ts.map +1 -0
  46. package/dist/src/utils/isParentOf.d.ts +1 -2
  47. package/dist/src/utils/isParentOf.d.ts.map +1 -1
  48. package/dist/src/utils/logging.d.ts +0 -1
  49. package/dist/src/utils/logging.d.ts.map +1 -1
  50. package/dist/src/utils/meta.d.ts +15 -64
  51. package/dist/src/utils/meta.d.ts.map +1 -1
  52. package/dist/src/utils/renderer-helpers.d.ts +99 -0
  53. package/dist/src/utils/renderer-helpers.d.ts.map +1 -0
  54. package/dist/src/utils/schemas.d.ts +3 -0
  55. package/dist/src/utils/schemas.d.ts.map +1 -0
  56. package/dist/src/utils/transaction-helpers.d.ts +18 -0
  57. package/dist/src/utils/transaction-helpers.d.ts.map +1 -0
  58. package/dist/src/utils/updates.d.ts +19 -25
  59. package/dist/src/utils/updates.d.ts.map +1 -1
  60. package/dist/src/ytype.d.ts +55 -24
  61. package/dist/src/ytype.d.ts.map +1 -1
  62. package/global.d.ts +53 -0
  63. package/package.json +12 -16
  64. package/src/index.js +32 -124
  65. package/src/structs/AbstractStruct.js +21 -16
  66. package/src/structs/GC.js +15 -20
  67. package/src/structs/Item.js +992 -318
  68. package/src/structs/Skip.js +16 -19
  69. package/src/utils/BlockSet.js +20 -20
  70. package/src/utils/Doc.js +15 -29
  71. package/src/utils/ID.js +0 -2
  72. package/src/utils/RelativePosition.js +15 -25
  73. package/src/utils/{AttributionManager.js → Renderer.js} +42 -197
  74. package/src/utils/Snapshot.js +15 -37
  75. package/src/utils/StructStore.js +89 -227
  76. package/src/utils/Transaction.js +63 -307
  77. package/src/utils/UndoManager.js +157 -19
  78. package/src/utils/UpdateDecoder.js +2 -3
  79. package/src/utils/UpdateEncoder.js +0 -4
  80. package/src/utils/YEvent.js +20 -26
  81. package/src/utils/content-helper.js +0 -0
  82. package/src/utils/delta-helpers.js +21 -42
  83. package/src/utils/encoding-helpers.js +110 -0
  84. package/src/utils/encoding.js +197 -122
  85. package/src/utils/ids.js +1527 -0
  86. package/src/utils/isParentOf.js +2 -4
  87. package/src/utils/logging.js +0 -4
  88. package/src/utils/meta.js +57 -46
  89. package/src/utils/renderer-helpers.js +110 -0
  90. package/src/utils/schemas.js +3 -0
  91. package/src/utils/transaction-helpers.js +413 -0
  92. package/src/utils/updates.js +24 -146
  93. package/src/ytype.js +325 -117
  94. package/tests/testHelper.js +10 -12
  95. package/dist/src/internals.d.ts +0 -36
  96. package/dist/src/internals.d.ts.map +0 -1
  97. package/dist/src/structs/ContentAny.d.ts +0 -67
  98. package/dist/src/structs/ContentAny.d.ts.map +0 -1
  99. package/dist/src/structs/ContentBinary.d.ts +0 -64
  100. package/dist/src/structs/ContentBinary.d.ts.map +0 -1
  101. package/dist/src/structs/ContentDeleted.d.ts +0 -64
  102. package/dist/src/structs/ContentDeleted.d.ts.map +0 -1
  103. package/dist/src/structs/ContentDoc.d.ts +0 -72
  104. package/dist/src/structs/ContentDoc.d.ts.map +0 -1
  105. package/dist/src/structs/ContentEmbed.d.ts +0 -67
  106. package/dist/src/structs/ContentEmbed.d.ts.map +0 -1
  107. package/dist/src/structs/ContentFormat.d.ts +0 -69
  108. package/dist/src/structs/ContentFormat.d.ts.map +0 -1
  109. package/dist/src/structs/ContentJSON.d.ts +0 -70
  110. package/dist/src/structs/ContentJSON.d.ts.map +0 -1
  111. package/dist/src/structs/ContentString.d.ts +0 -70
  112. package/dist/src/structs/ContentString.d.ts.map +0 -1
  113. package/dist/src/structs/ContentType.d.ts +0 -77
  114. package/dist/src/structs/ContentType.d.ts.map +0 -1
  115. package/dist/src/utils/AttributionManager.d.ts +0 -238
  116. package/dist/src/utils/AttributionManager.d.ts.map +0 -1
  117. package/dist/src/utils/IdMap.d.ts +0 -164
  118. package/dist/src/utils/IdMap.d.ts.map +0 -1
  119. package/dist/src/utils/IdSet.d.ts +0 -163
  120. package/dist/src/utils/IdSet.d.ts.map +0 -1
  121. package/dist/tests/IdMap.tests.d.ts +0 -9
  122. package/dist/tests/IdMap.tests.d.ts.map +0 -1
  123. package/dist/tests/IdSet.tests.d.ts +0 -9
  124. package/dist/tests/IdSet.tests.d.ts.map +0 -1
  125. package/dist/tests/attribution.tests.d.ts +0 -9
  126. package/dist/tests/attribution.tests.d.ts.map +0 -1
  127. package/dist/tests/compatibility.tests.d.ts +0 -5
  128. package/dist/tests/compatibility.tests.d.ts.map +0 -1
  129. package/dist/tests/delta.tests.d.ts +0 -7
  130. package/dist/tests/delta.tests.d.ts.map +0 -1
  131. package/dist/tests/doc.tests.d.ts +0 -13
  132. package/dist/tests/doc.tests.d.ts.map +0 -1
  133. package/dist/tests/encoding.tests.d.ts +0 -5
  134. package/dist/tests/encoding.tests.d.ts.map +0 -1
  135. package/dist/tests/index.d.ts +0 -2
  136. package/dist/tests/index.d.ts.map +0 -1
  137. package/dist/tests/relativePositions.tests.d.ts +0 -11
  138. package/dist/tests/relativePositions.tests.d.ts.map +0 -1
  139. package/dist/tests/snapshot.tests.d.ts +0 -14
  140. package/dist/tests/snapshot.tests.d.ts.map +0 -1
  141. package/dist/tests/testHelper.d.ts +0 -171
  142. package/dist/tests/testHelper.d.ts.map +0 -1
  143. package/dist/tests/undo-redo.tests.d.ts +0 -27
  144. package/dist/tests/undo-redo.tests.d.ts.map +0 -1
  145. package/dist/tests/updates.tests.d.ts +0 -26
  146. package/dist/tests/updates.tests.d.ts.map +0 -1
  147. package/dist/tests/y-array.tests.d.ts +0 -43
  148. package/dist/tests/y-array.tests.d.ts.map +0 -1
  149. package/dist/tests/y-map.tests.d.ts +0 -42
  150. package/dist/tests/y-map.tests.d.ts.map +0 -1
  151. package/dist/tests/y-text.tests.d.ts +0 -49
  152. package/dist/tests/y-text.tests.d.ts.map +0 -1
  153. package/dist/tests/y-xml.tests.d.ts +0 -14
  154. package/dist/tests/y-xml.tests.d.ts.map +0 -1
  155. package/src/internals.js +0 -35
  156. package/src/structs/ContentAny.js +0 -115
  157. package/src/structs/ContentBinary.js +0 -93
  158. package/src/structs/ContentDeleted.js +0 -101
  159. package/src/structs/ContentDoc.js +0 -141
  160. package/src/structs/ContentEmbed.js +0 -98
  161. package/src/structs/ContentFormat.js +0 -105
  162. package/src/structs/ContentJSON.js +0 -119
  163. package/src/structs/ContentString.js +0 -113
  164. package/src/structs/ContentType.js +0 -152
  165. package/src/utils/IdMap.js +0 -673
  166. 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.2",
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 && (tsc --skipLibCheck --noEmit false|| true)",
17
- "release": "PRODUCTION=1 npm run dist && test -e dist/src/index.d.ts && np",
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.5"
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.45.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": ">=16.0.0"
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
- export {
4
- Doc,
5
- Transaction,
6
- YType as Type,
7
- YEvent,
8
- Item,
9
- AbstractStruct,
10
- GC,
11
- Skip,
12
- ContentBinary,
13
- ContentDeleted,
14
- ContentDoc,
15
- ContentEmbed,
16
- ContentFormat,
17
- ContentJSON,
18
- ContentAny,
19
- ContentString,
20
- ContentType,
21
- getTypeChildren,
22
- createRelativePositionFromTypeIndex,
23
- createRelativePositionFromJSON,
24
- createAbsolutePositionFromRelativePosition,
25
- compareRelativePositions,
26
- AbsolutePosition,
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 {AbstractStruct} right
24
+ * @param {GC|Item|Skip} _right
29
25
  * @return {boolean} whether this merged with right
30
26
  */
31
- mergeWith (right) {
27
+ mergeWith (_right) {
32
28
  return false
33
29
  }
34
30
 
35
31
  /**
36
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
37
- * @param {number} offset
38
- * @param {number} encodingRef
32
+ * @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder The encoder to write data to.
33
+ * @param {number} _offset
34
+ * @param {number} _encodingRef
39
35
  */
40
- write (encoder, offset, encodingRef) {
36
+ write (_encoder, _offset, _encodingRef) {
41
37
  throw error.methodUnimplemented()
42
38
  }
43
39
 
44
40
  /**
45
- * @param {Transaction} transaction
46
- * @param {number} offset
41
+ * @param {Transaction} _transaction
42
+ * @param {number} _offset
47
43
  */
48
- integrate (transaction, offset) {
44
+ integrate (_transaction, _offset) {
49
45
  throw error.methodUnimplemented()
50
46
  }
51
47
 
52
48
  /**
53
- * @param {number} diff
54
- * @return {import('../internals.js').GC|import('../internals.js').Item}
49
+ * @param {number} _diff
50
+ * @return {GC|Item|Skip}
55
51
  */
56
- splice (diff) {
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
- AbstractStruct,
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
- addToIdSet(transaction.deleteSet, this.id.client, this.id.clock, this.length)
37
+ transaction.deleteSet.add(this.id.client, this.id.clock, this.length)
44
38
  addStructToIdSet(transaction.insertSet, this)
45
- addStruct(transaction.doc.store, this)
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