@y/y 14.0.0-16 → 14.0.0-18

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 (68) hide show
  1. package/dist/{index-DyTeTfmj.js → index-BV-j5wdP.js} +2 -2
  2. package/dist/{index-R7GxO-36.js.map → index-BV-j5wdP.js.map} +1 -1
  3. package/dist/{internals.mjs → internals.js} +1 -1
  4. package/dist/internals.js.map +1 -0
  5. package/dist/{testHelper.mjs → testHelper.js} +2 -2
  6. package/dist/testHelper.js.map +1 -0
  7. package/dist/{yjs.mjs → yjs.js} +2 -2
  8. package/dist/yjs.js.map +1 -0
  9. package/package.json +9 -18
  10. package/dist/Skip-j0kX7pdq.js +0 -12173
  11. package/dist/Skip-j0kX7pdq.js.map +0 -1
  12. package/dist/index-DyTeTfmj.js.map +0 -1
  13. package/dist/index-R7GxO-36.js +0 -165
  14. package/dist/internals.cjs +0 -286
  15. package/dist/internals.cjs.map +0 -1
  16. package/dist/internals.mjs.map +0 -1
  17. package/dist/testHelper.cjs +0 -780
  18. package/dist/testHelper.cjs.map +0 -1
  19. package/dist/testHelper.mjs.map +0 -1
  20. package/dist/yjs.cjs +0 -151
  21. package/dist/yjs.cjs.map +0 -1
  22. package/dist/yjs.mjs.map +0 -1
  23. package/src/index.js +0 -153
  24. package/src/internals.js +0 -44
  25. package/src/structs/AbstractStruct.js +0 -59
  26. package/src/structs/ContentAny.js +0 -115
  27. package/src/structs/ContentBinary.js +0 -93
  28. package/src/structs/ContentDeleted.js +0 -101
  29. package/src/structs/ContentDoc.js +0 -141
  30. package/src/structs/ContentEmbed.js +0 -98
  31. package/src/structs/ContentFormat.js +0 -105
  32. package/src/structs/ContentJSON.js +0 -119
  33. package/src/structs/ContentString.js +0 -113
  34. package/src/structs/ContentType.js +0 -176
  35. package/src/structs/GC.js +0 -80
  36. package/src/structs/Item.js +0 -845
  37. package/src/structs/Skip.js +0 -75
  38. package/src/types/AbstractType.js +0 -1434
  39. package/src/types/YArray.js +0 -270
  40. package/src/types/YMap.js +0 -244
  41. package/src/types/YText.js +0 -934
  42. package/src/types/YXmlElement.js +0 -227
  43. package/src/types/YXmlFragment.js +0 -266
  44. package/src/types/YXmlHook.js +0 -68
  45. package/src/types/YXmlText.js +0 -66
  46. package/src/utils/AbstractConnector.js +0 -25
  47. package/src/utils/AttributionManager.js +0 -619
  48. package/src/utils/Doc.js +0 -372
  49. package/src/utils/EventHandler.js +0 -87
  50. package/src/utils/ID.js +0 -89
  51. package/src/utils/IdMap.js +0 -629
  52. package/src/utils/IdSet.js +0 -823
  53. package/src/utils/RelativePosition.js +0 -352
  54. package/src/utils/Snapshot.js +0 -220
  55. package/src/utils/StructSet.js +0 -137
  56. package/src/utils/StructStore.js +0 -289
  57. package/src/utils/Transaction.js +0 -489
  58. package/src/utils/UndoManager.js +0 -391
  59. package/src/utils/UpdateDecoder.js +0 -281
  60. package/src/utils/UpdateEncoder.js +0 -320
  61. package/src/utils/YEvent.js +0 -216
  62. package/src/utils/delta-helpers.js +0 -54
  63. package/src/utils/encoding.js +0 -623
  64. package/src/utils/isParentOf.js +0 -21
  65. package/src/utils/logging.js +0 -21
  66. package/src/utils/types.js +0 -28
  67. package/src/utils/updates.js +0 -715
  68. package/tests/testHelper.js +0 -600
@@ -1,115 +0,0 @@
1
- import {
2
- UpdateEncoderV1, UpdateEncoderV2, UpdateDecoderV1, UpdateDecoderV2, Transaction, Item, StructStore // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as env from 'lib0/environment'
6
- import * as object from 'lib0/object'
7
-
8
- const isDevMode = env.getVariable('node_env') === 'development'
9
-
10
- export class ContentAny {
11
- /**
12
- * @param {Array<any>} arr
13
- */
14
- constructor (arr) {
15
- /**
16
- * @type {Array<any>}
17
- */
18
- this.arr = arr
19
- isDevMode && object.deepFreeze(arr)
20
- }
21
-
22
- /**
23
- * @return {number}
24
- */
25
- getLength () {
26
- return this.arr.length
27
- }
28
-
29
- /**
30
- * @return {Array<any>}
31
- */
32
- getContent () {
33
- return this.arr
34
- }
35
-
36
- /**
37
- * @return {boolean}
38
- */
39
- isCountable () {
40
- return true
41
- }
42
-
43
- /**
44
- * @return {ContentAny}
45
- */
46
- copy () {
47
- return new ContentAny(this.arr)
48
- }
49
-
50
- /**
51
- * @param {number} offset
52
- * @return {ContentAny}
53
- */
54
- splice (offset) {
55
- const right = new ContentAny(this.arr.slice(offset))
56
- this.arr = this.arr.slice(0, offset)
57
- return right
58
- }
59
-
60
- /**
61
- * @param {ContentAny} right
62
- * @return {boolean}
63
- */
64
- mergeWith (right) {
65
- this.arr = this.arr.concat(right.arr)
66
- return true
67
- }
68
-
69
- /**
70
- * @param {Transaction} transaction
71
- * @param {Item} item
72
- */
73
- integrate (transaction, item) {}
74
- /**
75
- * @param {Transaction} transaction
76
- */
77
- delete (transaction) {}
78
- /**
79
- * @param {Transaction} _tr
80
- */
81
- gc (_tr) {}
82
- /**
83
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
84
- * @param {number} offset
85
- * @param {number} offsetEnd
86
- */
87
- write (encoder, offset, offsetEnd) {
88
- const end = this.arr.length - offsetEnd
89
- encoder.writeLen(end - offset)
90
- for (let i = offset; i < end; i++) {
91
- const c = this.arr[i]
92
- encoder.writeAny(c)
93
- }
94
- }
95
-
96
- /**
97
- * @return {number}
98
- */
99
- getRef () {
100
- return 8
101
- }
102
- }
103
-
104
- /**
105
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
106
- * @return {ContentAny}
107
- */
108
- export const readContentAny = decoder => {
109
- const len = decoder.readLen()
110
- const cs = []
111
- for (let i = 0; i < len; i++) {
112
- cs.push(decoder.readAny())
113
- }
114
- return new ContentAny(cs)
115
- }
@@ -1,93 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
-
7
- export class ContentBinary {
8
- /**
9
- * @param {Uint8Array} content
10
- */
11
- constructor (content) {
12
- this.content = content
13
- }
14
-
15
- /**
16
- * @return {number}
17
- */
18
- getLength () {
19
- return 1
20
- }
21
-
22
- /**
23
- * @return {Array<any>}
24
- */
25
- getContent () {
26
- return [this.content]
27
- }
28
-
29
- /**
30
- * @return {boolean}
31
- */
32
- isCountable () {
33
- return true
34
- }
35
-
36
- /**
37
- * @return {ContentBinary}
38
- */
39
- copy () {
40
- return new ContentBinary(this.content)
41
- }
42
-
43
- /**
44
- * @param {number} offset
45
- * @return {ContentBinary}
46
- */
47
- splice (offset) {
48
- throw error.methodUnimplemented()
49
- }
50
-
51
- /**
52
- * @param {ContentBinary} right
53
- * @return {boolean}
54
- */
55
- mergeWith (right) {
56
- return false
57
- }
58
-
59
- /**
60
- * @param {Transaction} transaction
61
- * @param {Item} item
62
- */
63
- integrate (transaction, item) {}
64
- /**
65
- * @param {Transaction} transaction
66
- */
67
- delete (transaction) {}
68
- /**
69
- * @param {Transaction} _tr
70
- */
71
- gc (_tr) {}
72
- /**
73
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
74
- * @param {number} _offset
75
- * @param {number} _offsetEnd
76
- */
77
- write (encoder, _offset, _offsetEnd) {
78
- encoder.writeBuf(this.content)
79
- }
80
-
81
- /**
82
- * @return {number}
83
- */
84
- getRef () {
85
- return 3
86
- }
87
- }
88
-
89
- /**
90
- * @param {UpdateDecoderV1 | UpdateDecoderV2 } decoder
91
- * @return {ContentBinary}
92
- */
93
- export const readContentBinary = decoder => new ContentBinary(decoder.readBuf())
@@ -1,101 +0,0 @@
1
- import {
2
- addToIdSet,
3
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line
4
- } from '../internals.js'
5
-
6
- export class ContentDeleted {
7
- /**
8
- * @param {number} len
9
- */
10
- constructor (len) {
11
- this.len = len
12
- }
13
-
14
- /**
15
- * @return {number}
16
- */
17
- getLength () {
18
- return this.len
19
- }
20
-
21
- /**
22
- * @return {Array<any>}
23
- */
24
- getContent () {
25
- return []
26
- }
27
-
28
- /**
29
- * @return {boolean}
30
- */
31
- isCountable () {
32
- return false
33
- }
34
-
35
- /**
36
- * @return {ContentDeleted}
37
- */
38
- copy () {
39
- return new ContentDeleted(this.len)
40
- }
41
-
42
- /**
43
- * @param {number} offset
44
- * @return {ContentDeleted}
45
- */
46
- splice (offset) {
47
- const right = new ContentDeleted(this.len - offset)
48
- this.len = offset
49
- return right
50
- }
51
-
52
- /**
53
- * @param {ContentDeleted} right
54
- * @return {boolean}
55
- */
56
- mergeWith (right) {
57
- this.len += right.len
58
- return true
59
- }
60
-
61
- /**
62
- * @param {Transaction} transaction
63
- * @param {Item} item
64
- */
65
- integrate (transaction, item) {
66
- addToIdSet(transaction.deleteSet, item.id.client, item.id.clock, this.len)
67
- item.markDeleted()
68
- }
69
-
70
- /**
71
- * @param {Transaction} _transaction
72
- */
73
- delete (_transaction) {}
74
- /**
75
- * @param {Transaction} _tr
76
- */
77
- gc (_tr) {}
78
- /**
79
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
80
- * @param {number} offset
81
- * @param {number} offsetEnd
82
- */
83
- write (encoder, offset, offsetEnd) {
84
- encoder.writeLen(this.len - offset - offsetEnd)
85
- }
86
-
87
- /**
88
- * @return {number}
89
- */
90
- getRef () {
91
- return 1
92
- }
93
- }
94
-
95
- /**
96
- * @private
97
- *
98
- * @param {UpdateDecoderV1 | UpdateDecoderV2 } decoder
99
- * @return {ContentDeleted}
100
- */
101
- export const readContentDeleted = decoder => new ContentDeleted(decoder.readLen())
@@ -1,141 +0,0 @@
1
- import {
2
- Doc, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Transaction, Item // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
-
7
- /**
8
- * @param {string} guid
9
- * @param {Object<string, any>} opts
10
- */
11
- const createDocFromOpts = (guid, opts) => new Doc({ guid, ...opts, shouldLoad: opts.shouldLoad || opts.autoLoad || false })
12
-
13
- /**
14
- * @private
15
- */
16
- export class ContentDoc {
17
- /**
18
- * @param {Doc} doc
19
- */
20
- constructor (doc) {
21
- if (doc._item) {
22
- console.error('This document was already integrated as a sub-document. You should create a second instance instead with the same guid.')
23
- }
24
- /**
25
- * @type {Doc}
26
- */
27
- this.doc = doc
28
- /**
29
- * @type {any}
30
- */
31
- const opts = {}
32
- this.opts = opts
33
- if (!doc.gc) {
34
- opts.gc = false
35
- }
36
- if (doc.autoLoad) {
37
- opts.autoLoad = true
38
- }
39
- if (doc.meta !== null) {
40
- opts.meta = doc.meta
41
- }
42
- }
43
-
44
- /**
45
- * @return {number}
46
- */
47
- getLength () {
48
- return 1
49
- }
50
-
51
- /**
52
- * @return {Array<any>}
53
- */
54
- getContent () {
55
- return [this.doc]
56
- }
57
-
58
- /**
59
- * @return {boolean}
60
- */
61
- isCountable () {
62
- return true
63
- }
64
-
65
- /**
66
- * @return {ContentDoc}
67
- */
68
- copy () {
69
- return new ContentDoc(createDocFromOpts(this.doc.guid, this.opts))
70
- }
71
-
72
- /**
73
- * @param {number} offset
74
- * @return {ContentDoc}
75
- */
76
- splice (offset) {
77
- throw error.methodUnimplemented()
78
- }
79
-
80
- /**
81
- * @param {ContentDoc} right
82
- * @return {boolean}
83
- */
84
- mergeWith (right) {
85
- return false
86
- }
87
-
88
- /**
89
- * @param {Transaction} transaction
90
- * @param {Item} item
91
- */
92
- integrate (transaction, item) {
93
- // this needs to be reflected in doc.destroy as well
94
- this.doc._item = item
95
- transaction.subdocsAdded.add(this.doc)
96
- if (this.doc.shouldLoad) {
97
- transaction.subdocsLoaded.add(this.doc)
98
- }
99
- }
100
-
101
- /**
102
- * @param {Transaction} transaction
103
- */
104
- delete (transaction) {
105
- if (transaction.subdocsAdded.has(this.doc)) {
106
- transaction.subdocsAdded.delete(this.doc)
107
- } else {
108
- transaction.subdocsRemoved.add(this.doc)
109
- }
110
- }
111
-
112
- /**
113
- * @param {Transaction} _tr
114
- */
115
- gc (_tr) {}
116
-
117
- /**
118
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
119
- * @param {number} _offset
120
- * @param {number} _offsetEnd
121
- */
122
- write (encoder, _offset, _offsetEnd) {
123
- encoder.writeString(this.doc.guid)
124
- encoder.writeAny(this.opts)
125
- }
126
-
127
- /**
128
- * @return {number}
129
- */
130
- getRef () {
131
- return 9
132
- }
133
- }
134
-
135
- /**
136
- * @private
137
- *
138
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
139
- * @return {ContentDoc}
140
- */
141
- export const readContentDoc = decoder => new ContentDoc(createDocFromOpts(decoder.readString(), decoder.readAny()))
@@ -1,98 +0,0 @@
1
- import {
2
- UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
-
7
- /**
8
- * @private
9
- */
10
- export class ContentEmbed {
11
- /**
12
- * @param {Object} embed
13
- */
14
- constructor (embed) {
15
- this.embed = embed
16
- }
17
-
18
- /**
19
- * @return {number}
20
- */
21
- getLength () {
22
- return 1
23
- }
24
-
25
- /**
26
- * @return {Array<any>}
27
- */
28
- getContent () {
29
- return [this.embed]
30
- }
31
-
32
- /**
33
- * @return {boolean}
34
- */
35
- isCountable () {
36
- return true
37
- }
38
-
39
- /**
40
- * @return {ContentEmbed}
41
- */
42
- copy () {
43
- return new ContentEmbed(this.embed)
44
- }
45
-
46
- /**
47
- * @param {number} offset
48
- * @return {ContentEmbed}
49
- */
50
- splice (offset) {
51
- throw error.methodUnimplemented()
52
- }
53
-
54
- /**
55
- * @param {ContentEmbed} right
56
- * @return {boolean}
57
- */
58
- mergeWith (right) {
59
- return false
60
- }
61
-
62
- /**
63
- * @param {Transaction} transaction
64
- * @param {Item} item
65
- */
66
- integrate (transaction, item) {}
67
- /**
68
- * @param {Transaction} transaction
69
- */
70
- delete (transaction) {}
71
- /**
72
- * @param {Transaction} _tr
73
- */
74
- gc (_tr) {}
75
- /**
76
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
77
- * @param {number} _offset
78
- * @param {number} _offsetEnd
79
- */
80
- write (encoder, _offset, _offsetEnd) {
81
- encoder.writeJSON(this.embed)
82
- }
83
-
84
- /**
85
- * @return {number}
86
- */
87
- getRef () {
88
- return 5
89
- }
90
- }
91
-
92
- /**
93
- * @private
94
- *
95
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
96
- * @return {ContentEmbed}
97
- */
98
- export const readContentEmbed = decoder => new ContentEmbed(decoder.readJSON())
@@ -1,105 +0,0 @@
1
- import {
2
- YText, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Item, StructStore, Transaction // eslint-disable-line
3
- } from '../internals.js'
4
-
5
- import * as error from 'lib0/error'
6
-
7
- /**
8
- * @private
9
- */
10
- export class ContentFormat {
11
- /**
12
- * @param {string} key
13
- * @param {Object} value
14
- */
15
- constructor (key, value) {
16
- this.key = key
17
- this.value = value
18
- }
19
-
20
- /**
21
- * @return {number}
22
- */
23
- getLength () {
24
- return 1
25
- }
26
-
27
- /**
28
- * @return {Array<any>}
29
- */
30
- getContent () {
31
- return []
32
- }
33
-
34
- /**
35
- * @return {boolean}
36
- */
37
- isCountable () {
38
- return false
39
- }
40
-
41
- /**
42
- * @return {ContentFormat}
43
- */
44
- copy () {
45
- return new ContentFormat(this.key, this.value)
46
- }
47
-
48
- /**
49
- * @param {number} _offset
50
- * @return {ContentFormat}
51
- */
52
- splice (_offset) {
53
- throw error.methodUnimplemented()
54
- }
55
-
56
- /**
57
- * @param {ContentFormat} _right
58
- * @return {boolean}
59
- */
60
- mergeWith (_right) {
61
- return false
62
- }
63
-
64
- /**
65
- * @param {Transaction} _transaction
66
- * @param {Item} item
67
- */
68
- integrate (_transaction, item) {
69
- // @todo searchmarker are currently unsupported for rich text documents
70
- const p = /** @type {YText<any>} */ (item.parent)
71
- p._searchMarker = null
72
- p._hasFormatting = true
73
- }
74
-
75
- /**
76
- * @param {Transaction} _transaction
77
- */
78
- delete (_transaction) {}
79
- /**
80
- * @param {Transaction} _tr
81
- */
82
- gc (_tr) {}
83
- /**
84
- * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
85
- * @param {number} _offset
86
- * @param {number} _offsetEnd
87
- */
88
- write (encoder, _offset, _offsetEnd) {
89
- encoder.writeKey(this.key)
90
- encoder.writeJSON(this.value)
91
- }
92
-
93
- /**
94
- * @return {number}
95
- */
96
- getRef () {
97
- return 6
98
- }
99
- }
100
-
101
- /**
102
- * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
103
- * @return {ContentFormat}
104
- */
105
- export const readContentFormat = decoder => new ContentFormat(decoder.readKey(), decoder.readJSON())