lib0 0.2.115-3 → 0.2.115-5
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/coverage/tmp/coverage-42121-1764767245409-0.json +1 -0
- package/coverage/tmp/{coverage-32703-1763495370274-0.json → coverage-42122-1764767192180-0.json} +1 -1
- package/delta/binding.d.ts +11 -9
- package/delta/binding.d.ts.map +1 -1
- package/delta/binding.js +5 -2
- package/delta/binding.test.d.ts.map +1 -1
- package/delta/delta-pitch.test.d.ts +5 -0
- package/delta/delta-pitch.test.d.ts.map +1 -0
- package/delta/{d2.d.ts → delta.d.ts} +117 -34
- package/delta/delta.d.ts.map +1 -0
- package/delta/{d2.js → delta.js} +247 -55
- package/delta/{d2.test.d.ts → delta.test.d.ts} +6 -1
- package/delta/delta.test.d.ts.map +1 -0
- package/delta/t3.test.d.ts +1 -1
- package/delta/t3.test.d.ts.map +1 -1
- package/dist/array.cjs +17 -60
- package/dist/array.cjs.map +1 -1
- package/dist/binding.cjs +114 -28
- package/dist/binding.cjs.map +1 -1
- package/dist/{broadcastchannel-d0c108a2.cjs → broadcastchannel-94897809.cjs} +2 -2
- package/dist/{broadcastchannel-d0c108a2.cjs.map → broadcastchannel-94897809.cjs.map} +1 -1
- package/dist/broadcastchannel.cjs +6 -6
- package/dist/{buffer-7f6fa8fa.cjs → buffer-8d110bf4.cjs} +2 -2
- package/dist/{buffer-7f6fa8fa.cjs.map → buffer-8d110bf4.cjs.map} +1 -1
- package/dist/buffer.cjs +5 -5
- package/dist/cache.cjs +3 -3
- package/dist/component.cjs +12 -8
- package/dist/component.cjs.map +1 -1
- package/dist/delta/binding.d.ts +11 -9
- package/dist/delta/binding.d.ts.map +1 -1
- package/dist/delta/binding.test.d.ts.map +1 -1
- package/dist/delta/delta-pitch.test.d.ts +5 -0
- package/dist/delta/delta-pitch.test.d.ts.map +1 -0
- package/dist/delta/{d2.d.ts → delta.d.ts} +117 -34
- package/dist/delta/delta.d.ts.map +1 -0
- package/dist/delta/{d2.test.d.ts → delta.test.d.ts} +6 -1
- package/dist/delta/delta.test.d.ts.map +1 -0
- package/dist/delta/t3.test.d.ts +1 -1
- package/dist/delta/t3.test.d.ts.map +1 -1
- package/dist/{d2.cjs → delta.cjs} +256 -60
- package/dist/delta.cjs.map +1 -0
- package/dist/{diff-1832cb43.cjs → diff-dc7bdc65.cjs} +2 -2
- package/dist/{diff-1832cb43.cjs.map → diff-dc7bdc65.cjs.map} +1 -1
- package/dist/diff.cjs +4 -4
- package/dist/{dom-f5047a64.cjs → dom-cad267af.cjs} +1 -1
- package/dist/{dom-f5047a64.cjs.map → dom-cad267af.cjs.map} +1 -1
- package/dist/dom.cjs +12 -5
- package/dist/dom.cjs.map +1 -1
- package/dist/{environment-90227ead.cjs → environment-98bcf64f.cjs} +2 -2
- package/dist/{environment-90227ead.cjs.map → environment-98bcf64f.cjs.map} +1 -1
- package/dist/environment.cjs +4 -4
- package/dist/equality.cjs +34 -0
- package/dist/equality.cjs.map +1 -0
- package/dist/fingerprint.cjs +44 -0
- package/dist/fingerprint.cjs.map +1 -0
- package/dist/{function-e7d18feb.cjs → function-b4e49016.cjs} +6 -6
- package/dist/function-b4e49016.cjs.map +1 -0
- package/dist/function.cjs +3 -3
- package/dist/index.cjs +9 -9
- package/dist/indexeddbV2.cjs +2 -2
- package/dist/jwt.cjs +5 -5
- package/dist/list.cjs +18 -5
- package/dist/list.cjs.map +1 -1
- package/dist/list.d.ts +9 -2
- package/dist/list.d.ts.map +1 -1
- package/dist/list.test.d.ts.map +1 -1
- package/dist/logging.cjs +11 -5
- package/dist/logging.cjs.map +1 -1
- package/dist/logging.common.cjs +4 -4
- package/dist/logging.node.cjs +4 -4
- package/dist/map.cjs +7 -314
- package/dist/map.cjs.map +1 -1
- package/dist/{object-18980796.cjs → object-dec41ef9.cjs} +3 -3
- package/dist/object-dec41ef9.cjs.map +1 -0
- package/dist/object.cjs +2 -2
- package/dist/object.d.ts.map +1 -1
- package/dist/performance.node.cjs +3 -3
- package/dist/pledge.cjs +2 -2
- package/dist/{prng-99204216.cjs → prng-aa81e812.cjs} +2 -2
- package/dist/{prng-99204216.cjs.map → prng-aa81e812.cjs.map} +1 -1
- package/dist/prng.cjs +6 -6
- package/dist/rabin-gf2-polynomial.cjs +5 -5
- package/dist/rabin-uncached.cjs +5 -5
- package/dist/rabin.cjs +5 -5
- package/dist/schema.cjs +202 -22
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +86 -29
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.test.d.ts +4 -0
- package/dist/schema.test.d.ts.map +1 -1
- package/dist/testing.cjs +9 -9
- package/dist/testing.cjs.map +1 -1
- package/dist/{traits.d.ts → trait/equality.d.ts} +1 -1
- package/dist/trait/equality.d.ts.map +1 -0
- package/dist/trait/fingerprint.d.ts +13 -0
- package/dist/trait/fingerprint.d.ts.map +1 -0
- package/dist/trait/traits.d.ts +3 -0
- package/dist/trait/traits.d.ts.map +1 -0
- package/dist/trait/traits.test.d.ts +5 -0
- package/dist/trait/traits.test.d.ts.map +1 -0
- package/dist/traits.cjs +23 -26
- package/dist/traits.cjs.map +1 -1
- package/dist/url.cjs +2 -2
- package/function.js +4 -4
- package/list.d.ts +9 -2
- package/list.d.ts.map +1 -1
- package/list.js +17 -3
- package/list.test.d.ts.map +1 -1
- package/object.d.ts.map +1 -1
- package/object.js +2 -2
- package/package.json +8 -10
- package/schema.d.ts +86 -29
- package/schema.d.ts.map +1 -1
- package/schema.js +191 -20
- package/schema.test.d.ts +4 -0
- package/schema.test.d.ts.map +1 -1
- package/test.html +2 -4
- package/test.js +7 -13
- package/testing.js +3 -3
- package/{traits.d.ts → trait/equality.d.ts} +1 -1
- package/trait/equality.d.ts.map +1 -0
- package/trait/fingerprint.d.ts +13 -0
- package/trait/fingerprint.d.ts.map +1 -0
- package/trait/fingerprint.js +21 -0
- package/trait/traits.d.ts +3 -0
- package/trait/traits.d.ts.map +1 -0
- package/trait/traits.js +2 -0
- package/trait/traits.test.d.ts +5 -0
- package/{traits.test.d.ts.map → trait/traits.test.d.ts.map} +1 -1
- package/delta/abstract-array.d.ts +0 -166
- package/delta/abstract-array.d.ts.map +0 -1
- package/delta/abstract-array.js +0 -421
- package/delta/abstract.d.ts +0 -69
- package/delta/abstract.d.ts.map +0 -1
- package/delta/abstract.js +0 -102
- package/delta/array.d.ts +0 -23
- package/delta/array.d.ts.map +0 -1
- package/delta/array.js +0 -45
- package/delta/array.test.d.ts +0 -2
- package/delta/array.test.d.ts.map +0 -1
- package/delta/d2.d.ts.map +0 -1
- package/delta/d2.test.d.ts.map +0 -1
- package/delta/index.d.ts +0 -14
- package/delta/index.d.ts.map +0 -1
- package/delta/index.js +0 -79
- package/delta/map.d.ts +0 -226
- package/delta/map.d.ts.map +0 -1
- package/delta/map.js +0 -304
- package/delta/node.d.ts +0 -117
- package/delta/node.d.ts.map +0 -1
- package/delta/node.js +0 -183
- package/delta/node.test.d.ts +0 -4
- package/delta/node.test.d.ts.map +0 -1
- package/delta/ops.d.ts +0 -464
- package/delta/ops.d.ts.map +0 -1
- package/delta/ops.js +0 -544
- package/delta/t2.d.ts +0 -184
- package/delta/t2.d.ts.map +0 -1
- package/delta/t2.js +0 -890
- package/delta/text.d.ts +0 -43
- package/delta/text.d.ts.map +0 -1
- package/delta/text.js +0 -54
- package/delta/text.test.d.ts +0 -6
- package/delta/text.test.d.ts.map +0 -1
- package/delta/transformer.d.ts +0 -164
- package/delta/transformer.d.ts.map +0 -1
- package/delta/transformer.js +0 -888
- package/delta/transformer.test.d.ts +0 -13
- package/delta/transformer.test.d.ts.map +0 -1
- package/delta/value.d.ts +0 -84
- package/delta/value.d.ts.map +0 -1
- package/delta/value.js +0 -168
- package/dist/abstract-array.cjs +0 -433
- package/dist/abstract-array.cjs.map +0 -1
- package/dist/abstract.cjs +0 -122
- package/dist/abstract.cjs.map +0 -1
- package/dist/array2.cjs +0 -26
- package/dist/array2.cjs.map +0 -1
- package/dist/d2.cjs.map +0 -1
- package/dist/delta/abstract-array.d.ts +0 -166
- package/dist/delta/abstract-array.d.ts.map +0 -1
- package/dist/delta/abstract.d.ts +0 -69
- package/dist/delta/abstract.d.ts.map +0 -1
- package/dist/delta/array.d.ts +0 -23
- package/dist/delta/array.d.ts.map +0 -1
- package/dist/delta/array.test.d.ts +0 -2
- package/dist/delta/array.test.d.ts.map +0 -1
- package/dist/delta/d2.d.ts.map +0 -1
- package/dist/delta/d2.test.d.ts.map +0 -1
- package/dist/delta/index.d.ts +0 -14
- package/dist/delta/index.d.ts.map +0 -1
- package/dist/delta/map.d.ts +0 -226
- package/dist/delta/map.d.ts.map +0 -1
- package/dist/delta/node.d.ts +0 -117
- package/dist/delta/node.d.ts.map +0 -1
- package/dist/delta/node.test.d.ts +0 -4
- package/dist/delta/node.test.d.ts.map +0 -1
- package/dist/delta/ops.d.ts +0 -464
- package/dist/delta/ops.d.ts.map +0 -1
- package/dist/delta/t2.d.ts +0 -184
- package/dist/delta/t2.d.ts.map +0 -1
- package/dist/delta/text.d.ts +0 -43
- package/dist/delta/text.d.ts.map +0 -1
- package/dist/delta/text.test.d.ts +0 -6
- package/dist/delta/text.test.d.ts.map +0 -1
- package/dist/delta/transformer.d.ts +0 -164
- package/dist/delta/transformer.d.ts.map +0 -1
- package/dist/delta/transformer.test.d.ts +0 -13
- package/dist/delta/transformer.test.d.ts.map +0 -1
- package/dist/delta/value.d.ts +0 -84
- package/dist/delta/value.d.ts.map +0 -1
- package/dist/function-e7d18feb.cjs.map +0 -1
- package/dist/index2.cjs +0 -71
- package/dist/index2.cjs.map +0 -1
- package/dist/map2.cjs +0 -15
- package/dist/map2.cjs.map +0 -1
- package/dist/node.cjs +0 -206
- package/dist/node.cjs.map +0 -1
- package/dist/object-18980796.cjs.map +0 -1
- package/dist/ops.cjs +0 -575
- package/dist/ops.cjs.map +0 -1
- package/dist/t2.cjs +0 -932
- package/dist/t2.cjs.map +0 -1
- package/dist/text.cjs +0 -79
- package/dist/text.cjs.map +0 -1
- package/dist/traits.d.ts.map +0 -1
- package/dist/traits.test.d.ts +0 -4
- package/dist/traits.test.d.ts.map +0 -1
- package/dist/transformer.cjs +0 -930
- package/dist/transformer.cjs.map +0 -1
- package/dist/value.cjs +0 -187
- package/dist/value.cjs.map +0 -1
- package/traits.d.ts.map +0 -1
- package/traits.test.d.ts +0 -4
- /package/{traits.js → trait/equality.js} +0 -0
package/delta/abstract-array.js
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import * as s from '../schema.js'
|
|
2
|
-
import * as d from './abstract.js'
|
|
3
|
-
import * as traits from '../traits.js'
|
|
4
|
-
import * as object from '../object.js'
|
|
5
|
-
import * as fun from '../function.js'
|
|
6
|
-
import * as array from '../array.js'
|
|
7
|
-
import * as dops from './ops.js'
|
|
8
|
-
import * as error from '../error.js'
|
|
9
|
-
import * as math from '../math.js'
|
|
10
|
-
import { InsertOp, DeleteOp, RetainOp, ModifyOp, TextOp } from './ops.js'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {Array<dops.DeltaJsonOp>} DeltaJson
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @template {'array' | 'text' | 'custom'} Type
|
|
18
|
-
* @template {dops.AbstractDeltaArrayOps<any>} OPS
|
|
19
|
-
* @extends {d.AbstractDelta}
|
|
20
|
-
*/
|
|
21
|
-
export class AbstractDeltaArray extends d.AbstractDelta {
|
|
22
|
-
/**
|
|
23
|
-
* @param {Type} type
|
|
24
|
-
*/
|
|
25
|
-
constructor (type) {
|
|
26
|
-
super()
|
|
27
|
-
this.type = type
|
|
28
|
-
/**
|
|
29
|
-
* @type {Array<OPS>}
|
|
30
|
-
*/
|
|
31
|
-
this.ops = []
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
isEmpty () {
|
|
35
|
-
return this.ops.length === 0
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @template M
|
|
40
|
-
* @param {(d:OPS) => dops.AbstractDeltaArrayOps<M>} f
|
|
41
|
-
* @return {AbstractDeltaArrayBuilder<Type,M>}
|
|
42
|
-
*/
|
|
43
|
-
map (f) {
|
|
44
|
-
const d = /** @type {AbstractDeltaArrayBuilder<Type,any>} */ (new /** @type {any} */ (this.constructor)(this.type))
|
|
45
|
-
d.ops = this.ops.map(f)
|
|
46
|
-
d.lastOp = d.ops[d.ops.length - 1] ?? null
|
|
47
|
-
return d
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* Iterate through the changes. There are two approches to iterate through the changes. The
|
|
53
|
-
* following examples achieve the same thing:
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* d.forEach((op, index) => {
|
|
57
|
-
* if (op instanceof delta.InsertArrayOp) {
|
|
58
|
-
* op.insert
|
|
59
|
-
* } else if (op instanceof delta.RetainOp ) {
|
|
60
|
-
* op.retain
|
|
61
|
-
* } else if (op instanceof delta.DeleteOp) {
|
|
62
|
-
* op.delete
|
|
63
|
-
* }
|
|
64
|
-
* })
|
|
65
|
-
*
|
|
66
|
-
* The second approach doesn't require instanceof checks.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* d.forEach(null,
|
|
70
|
-
* (insertOp, index) => insertOp.insert,
|
|
71
|
-
* (retainOp, index) => insertOp.retain
|
|
72
|
-
* (deleteOp, index) => insertOp.delete
|
|
73
|
-
* )
|
|
74
|
-
*
|
|
75
|
-
* @param {null|((d:OPS,index:number)=>void)} f
|
|
76
|
-
* @param {null|((insertOp:Extract<OPS,InsertOp<any>|TextOp>,index:number)=>void)} insertHandler
|
|
77
|
-
* @param {null|((retainOp:RetainOp,index:number)=>void)} retainHandler
|
|
78
|
-
* @param {null|((deleteOp:DeleteOp,index:number)=>void)} deleteHandler
|
|
79
|
-
* @param {null|((modifyOp:OPS extends ModifyOp<infer M> ? ModifyOp<M> : never,index:number)=>void)} modifyHandler
|
|
80
|
-
*/
|
|
81
|
-
forEach (f = null, insertHandler = null, retainHandler = null, deleteHandler = null, modifyHandler = null) {
|
|
82
|
-
for (
|
|
83
|
-
let i = 0, index = 0, op = this.ops[i];
|
|
84
|
-
i < this.ops.length;
|
|
85
|
-
i++, index += op.length, op = this.ops[i]
|
|
86
|
-
) {
|
|
87
|
-
f?.(op, index)
|
|
88
|
-
switch (op.constructor) {
|
|
89
|
-
case RetainOp:
|
|
90
|
-
retainHandler?.(/** @type {RetainOp} */ (op), index)
|
|
91
|
-
break
|
|
92
|
-
case DeleteOp:
|
|
93
|
-
deleteHandler?.(/** @type {DeleteOp} */ (op), index)
|
|
94
|
-
break
|
|
95
|
-
case ModifyOp:
|
|
96
|
-
modifyHandler?.(/** @type {any}) */ (op), index)
|
|
97
|
-
break
|
|
98
|
-
default:
|
|
99
|
-
insertHandler?.(/** @type {any} */ (op), index)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @param {AbstractDeltaArray<Type, OPS>} other
|
|
106
|
-
* @return {boolean}
|
|
107
|
-
*/
|
|
108
|
-
equals (other) {
|
|
109
|
-
return this[traits.EqualityTraitSymbol](other)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @returns {DeltaJson}
|
|
114
|
-
*/
|
|
115
|
-
toJSON () {
|
|
116
|
-
return this.ops.map(o => o.toJSON())
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
get size () {
|
|
120
|
-
return this.ops.length
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @param {AbstractDeltaArray<Type,OPS>} other
|
|
125
|
-
*/
|
|
126
|
-
[traits.EqualityTraitSymbol] (other) {
|
|
127
|
-
return fun.equalityDeep(this.ops, other.ops)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @template {'text' | 'array' | 'custom'} Type
|
|
133
|
-
* @template {dops.AbstractDeltaArrayOps<any>} OPS
|
|
134
|
-
* @extends {AbstractDeltaArray<Type,OPS>}
|
|
135
|
-
*/
|
|
136
|
-
export class AbstractDeltaArrayBuilder extends AbstractDeltaArray {
|
|
137
|
-
/**
|
|
138
|
-
* @param {Type} type
|
|
139
|
-
* @param {s.Schema<OPS extends dops.AbstractDeltaArrayOps<infer V> ? V : never>} $insert
|
|
140
|
-
*/
|
|
141
|
-
constructor (type, $insert) {
|
|
142
|
-
super(type)
|
|
143
|
-
this.$insert = $insert
|
|
144
|
-
/**
|
|
145
|
-
* @type {dops.FormattingAttributes?}
|
|
146
|
-
*/
|
|
147
|
-
this.usedAttributes = null
|
|
148
|
-
/**
|
|
149
|
-
* @type {d.Attribution?}
|
|
150
|
-
*/
|
|
151
|
-
this.usedAttribution = null
|
|
152
|
-
/**
|
|
153
|
-
* @type {dops.AbstractDeltaArrayOps<any>?}
|
|
154
|
-
*/
|
|
155
|
-
this.lastOp = null
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @return {this}
|
|
160
|
-
*/
|
|
161
|
-
clone () {
|
|
162
|
-
const d = /** @type {this} */ (new AbstractDeltaArrayBuilder(this.type, this.$insert))
|
|
163
|
-
d.ops = /** @type {OPS[]} */ (this.ops.map(op => op.clone()))
|
|
164
|
-
d.origin = this.origin
|
|
165
|
-
d.isDiff = this.isDiff
|
|
166
|
-
return d
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @param {dops.FormattingAttributes?} attributes
|
|
171
|
-
* @return {this}
|
|
172
|
-
*/
|
|
173
|
-
useAttributes (attributes) {
|
|
174
|
-
this.usedAttributes = attributes
|
|
175
|
-
return this
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @param {string} name
|
|
180
|
-
* @param {any} value
|
|
181
|
-
*/
|
|
182
|
-
updateUsedAttributes (name, value) {
|
|
183
|
-
if (value == null) {
|
|
184
|
-
this.usedAttributes = object.assign({}, this.usedAttributes)
|
|
185
|
-
delete this.usedAttributes?.[name]
|
|
186
|
-
if (object.isEmpty(this.usedAttributes)) {
|
|
187
|
-
this.usedAttributes = null
|
|
188
|
-
}
|
|
189
|
-
} else if (!fun.equalityDeep(this.usedAttributes?.[name], value)) {
|
|
190
|
-
this.usedAttributes = object.assign({}, this.usedAttributes)
|
|
191
|
-
this.usedAttributes[name] = value
|
|
192
|
-
}
|
|
193
|
-
return this
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* @template {keyof d.Attribution} NAME
|
|
198
|
-
* @param {NAME} name
|
|
199
|
-
* @param {d.Attribution[NAME]?} value
|
|
200
|
-
*/
|
|
201
|
-
updateUsedAttribution (name, value) {
|
|
202
|
-
if (value == null) {
|
|
203
|
-
this.usedAttribution = object.assign({}, this.usedAttribution)
|
|
204
|
-
delete this.usedAttribution?.[name]
|
|
205
|
-
if (object.isEmpty(this.usedAttribution)) {
|
|
206
|
-
this.usedAttribution = null
|
|
207
|
-
}
|
|
208
|
-
} else if (!fun.equalityDeep(this.usedAttribution?.[name], value)) {
|
|
209
|
-
this.usedAttribution = object.assign({}, this.usedAttribution)
|
|
210
|
-
this.usedAttribution[name] = value
|
|
211
|
-
}
|
|
212
|
-
return this
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @param {d.Attribution?} attribution
|
|
217
|
-
*/
|
|
218
|
-
useAttribution (attribution) {
|
|
219
|
-
this.usedAttribution = attribution
|
|
220
|
-
return this
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* @param {(OPS extends TextOp ? string : never) | (OPS extends InsertOp<infer Content> ? Array<Content> : never) } insert
|
|
225
|
-
* @param {dops.FormattingAttributes?} attributes
|
|
226
|
-
* @param {d.Attribution?} attribution
|
|
227
|
-
* @return {this}
|
|
228
|
-
*/
|
|
229
|
-
insert (insert, attributes = null, attribution = null) {
|
|
230
|
-
const mergedAttributes = d.mergeAttrs(this.usedAttributes, attributes)
|
|
231
|
-
const mergedAttribution = d.mergeAttrs(this.usedAttribution, attribution)
|
|
232
|
-
/**
|
|
233
|
-
* @param {TextOp | InsertOp<any>} lastOp
|
|
234
|
-
*/
|
|
235
|
-
const checkMergedEquals = lastOp => (mergedAttributes === lastOp.attributes || fun.equalityDeep(mergedAttributes, lastOp.attributes)) && (mergedAttribution === lastOp.attribution || fun.equalityDeep(mergedAttribution, lastOp.attribution))
|
|
236
|
-
if (s.$string.check(insert)) {
|
|
237
|
-
if (dops.$textOp.check(this.lastOp) && checkMergedEquals(this.lastOp)) {
|
|
238
|
-
this.lastOp.insert += insert
|
|
239
|
-
} else if (insert.length > 0) {
|
|
240
|
-
this.ops.push(this.lastOp = /** @type {OPS} */ (new TextOp(insert, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution)))
|
|
241
|
-
}
|
|
242
|
-
} else if (array.isArray(insert)) {
|
|
243
|
-
insert.forEach(/** @param {any} ins */ ins => this.$insert.expect(ins))
|
|
244
|
-
if (dops.$insertOp.check(this.lastOp) && checkMergedEquals(this.lastOp)) {
|
|
245
|
-
this.lastOp.insert.push(...insert)
|
|
246
|
-
} else if (insert.length > 0) {
|
|
247
|
-
this.ops.push(this.lastOp = /** @type {OPS} */ (new InsertOp(insert, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution)))
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return this
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* @param {OPS extends ModifyOp<infer Mod> ? Mod : never } modify
|
|
255
|
-
* @param {dops.FormattingAttributes?} attributes
|
|
256
|
-
* @param {d.Attribution?} attribution
|
|
257
|
-
* @return {this}
|
|
258
|
-
*/
|
|
259
|
-
modify (modify, attributes = null, attribution = null) {
|
|
260
|
-
const mergedAttributes = d.mergeAttrs(this.usedAttributes, attributes)
|
|
261
|
-
const mergedAttribution = d.mergeAttrs(this.usedAttribution, attribution)
|
|
262
|
-
this.ops.push(this.lastOp = /** @type {OPS} */ (new ModifyOp(modify, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution)))
|
|
263
|
-
return this
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @param {number} retain
|
|
268
|
-
* @param {dops.FormattingAttributes?} attributes
|
|
269
|
-
* @param {d.Attribution?} attribution
|
|
270
|
-
* @return {this}
|
|
271
|
-
*/
|
|
272
|
-
retain (retain, attributes = null, attribution = null) {
|
|
273
|
-
const mergedAttributes = d.mergeAttrs(this.usedAttributes, attributes)
|
|
274
|
-
const mergedAttribution = d.mergeAttrs(this.usedAttribution, attribution)
|
|
275
|
-
if (this.lastOp instanceof RetainOp && fun.equalityDeep(mergedAttributes, this.lastOp.attributes) && fun.equalityDeep(mergedAttribution, this.lastOp.attribution)) {
|
|
276
|
-
this.lastOp.retain += retain
|
|
277
|
-
} else if (retain > 0) {
|
|
278
|
-
// @ts-ignore
|
|
279
|
-
this.ops.push(this.lastOp = new RetainOp(retain, mergedAttributes, mergedAttribution))
|
|
280
|
-
}
|
|
281
|
-
return this
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @param {number} len
|
|
286
|
-
* @return {this}
|
|
287
|
-
*/
|
|
288
|
-
delete (len) {
|
|
289
|
-
if (this.lastOp instanceof DeleteOp) {
|
|
290
|
-
this.lastOp.delete += len
|
|
291
|
-
} else if (len > 0) {
|
|
292
|
-
// @ts-ignore
|
|
293
|
-
this.ops.push(this.lastOp = new DeleteOp(len))
|
|
294
|
-
}
|
|
295
|
-
return this
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* @todo this is basically untested and is in dire need of randomized testing.
|
|
300
|
-
* @param {AbstractDeltaArray<Type, OPS>} other
|
|
301
|
-
*/
|
|
302
|
-
apply (other) {
|
|
303
|
-
let opsI = 0
|
|
304
|
-
let offset = 0
|
|
305
|
-
other.forEach(
|
|
306
|
-
null,
|
|
307
|
-
insertOp => {
|
|
308
|
-
const o = this.ops[opsI]
|
|
309
|
-
if (offset === 0) {
|
|
310
|
-
this.ops.splice(opsI, 0, /** @type {OPS} */ (insertOp.clone()))
|
|
311
|
-
opsI++
|
|
312
|
-
} else {
|
|
313
|
-
const cpy = o.clone()
|
|
314
|
-
cpy._splice(0, offset)
|
|
315
|
-
o._splice(offset, o.length - offset)
|
|
316
|
-
this.ops.splice(opsI + 1, 0, /** @type {OPS} */ (insertOp.clone()), /** @type {OPS} */ (cpy))
|
|
317
|
-
opsI += 2
|
|
318
|
-
offset = 0
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
|
-
retainOp => {
|
|
322
|
-
let skipLen = retainOp.length
|
|
323
|
-
let o = this.ops[opsI]
|
|
324
|
-
while (o.length - offset <= skipLen) {
|
|
325
|
-
skipLen -= o.length - offset
|
|
326
|
-
o = this.ops[++opsI]
|
|
327
|
-
offset = 0
|
|
328
|
-
}
|
|
329
|
-
offset = skipLen
|
|
330
|
-
},
|
|
331
|
-
deleteOp => {
|
|
332
|
-
let remainingLen = deleteOp.length
|
|
333
|
-
while (remainingLen > 0) {
|
|
334
|
-
const o = this.ops[opsI]
|
|
335
|
-
if (o instanceof DeleteOp) {
|
|
336
|
-
const delLen = o.length - offset
|
|
337
|
-
// the same content can't be deleted twice, remove duplicated deletes
|
|
338
|
-
if (delLen >= remainingLen) {
|
|
339
|
-
offset = 0
|
|
340
|
-
opsI++
|
|
341
|
-
} else {
|
|
342
|
-
offset += remainingLen
|
|
343
|
-
}
|
|
344
|
-
remainingLen -= delLen
|
|
345
|
-
} else { // insert / embed / retain / modify ⇒ replace
|
|
346
|
-
// case1: delete o fully
|
|
347
|
-
// case2: delete some part of beginning
|
|
348
|
-
// case3: delete some part of end
|
|
349
|
-
// case4: delete some part of center
|
|
350
|
-
const delLen = math.min(o.length - offset, remainingLen)
|
|
351
|
-
if (o.length === delLen) {
|
|
352
|
-
// case 1
|
|
353
|
-
offset = 0
|
|
354
|
-
this.ops.splice(opsI, 1)
|
|
355
|
-
} else if (offset === 0) {
|
|
356
|
-
// case 2
|
|
357
|
-
offset = 0
|
|
358
|
-
o._splice(0, delLen)
|
|
359
|
-
} else if (offset + delLen === o.length) {
|
|
360
|
-
// case 3
|
|
361
|
-
o._splice(offset, delLen)
|
|
362
|
-
offset = 0
|
|
363
|
-
opsI++
|
|
364
|
-
} else {
|
|
365
|
-
// case 4
|
|
366
|
-
o._splice(offset, delLen)
|
|
367
|
-
}
|
|
368
|
-
remainingLen -= delLen
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
modifyOp => {
|
|
373
|
-
if (opsI >= this.ops.length) {
|
|
374
|
-
this.ops.push(/** @type {OPS} */ (modifyOp.clone()))
|
|
375
|
-
return
|
|
376
|
-
}
|
|
377
|
-
let o = this.ops[opsI]
|
|
378
|
-
if (dops.$modifyOp.check(o)) {
|
|
379
|
-
o.modify.apply(modifyOp.modify)
|
|
380
|
-
} else if (dops.$insertOp.check(o)) {
|
|
381
|
-
const d = o.insert[offset]
|
|
382
|
-
d.apply(modifyOp.modify)
|
|
383
|
-
} else if (dops.$retainOp.check(o)) {
|
|
384
|
-
if (offset > 0) {
|
|
385
|
-
const cpy = o.clone()
|
|
386
|
-
cpy._splice(0, offset)
|
|
387
|
-
o._splice(offset, o.length - offset)
|
|
388
|
-
this.ops.splice(opsI + 1, 0, /** @type {OPS} */ (cpy))
|
|
389
|
-
opsI++
|
|
390
|
-
o = /** @type {OPS} */ (cpy)
|
|
391
|
-
offset = 0
|
|
392
|
-
}
|
|
393
|
-
if (o.length === 1) {
|
|
394
|
-
this.ops[opsI] = /** @type {OPS} */ (modifyOp.clone())
|
|
395
|
-
opsI++
|
|
396
|
-
} else {
|
|
397
|
-
this.ops.splice(opsI, 0, /** @type {OPS} */ (modifyOp.clone()))
|
|
398
|
-
o._splice(0, 1)
|
|
399
|
-
opsI++
|
|
400
|
-
}
|
|
401
|
-
} else if (dops.$deleteOp.check(o)) {
|
|
402
|
-
// nop
|
|
403
|
-
} else {
|
|
404
|
-
error.unexpectedCase()
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
)
|
|
408
|
-
this.lastOp = this.ops[this.ops.length - 1]
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* @return {Type extends 'array' ? (OPS extends dops.InsertOp<infer C> ? import('./array.js').DeltaArray<C> : never) : (Type extends 'text' ? (OPS extends dops.DeltaTextOps<infer Embeds> ? import('./text.js').DeltaText<Embeds> : never) : AbstractDeltaArray<Type,OPS>)}
|
|
413
|
-
*/
|
|
414
|
-
done () {
|
|
415
|
-
while (this.lastOp != null && this.lastOp instanceof RetainOp && this.lastOp.attributes === null && this.lastOp.attribution === null) {
|
|
416
|
-
this.ops.pop()
|
|
417
|
-
this.lastOp = this.ops[this.ops.length - 1] ?? null
|
|
418
|
-
}
|
|
419
|
-
return /** @type {any} */ (this)
|
|
420
|
-
}
|
|
421
|
-
}
|
package/delta/abstract.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export const $attribution: s.Schema<{
|
|
2
|
-
insert?: string[] | undefined;
|
|
3
|
-
insertAt?: number | undefined;
|
|
4
|
-
delete?: string[] | undefined;
|
|
5
|
-
deleteAt?: number | undefined;
|
|
6
|
-
attributes?: {
|
|
7
|
-
[x: string]: string[];
|
|
8
|
-
} | undefined;
|
|
9
|
-
attributesAt?: number | undefined;
|
|
10
|
-
}>;
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {s.TypeOf<$attribution>} Attribution
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* @implements {traits.EqualityTrait}
|
|
16
|
-
*/
|
|
17
|
-
export class AbstractDelta implements traits.EqualityTrait {
|
|
18
|
-
remote: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* @type {any} origin
|
|
21
|
-
*/
|
|
22
|
-
origin: any;
|
|
23
|
-
isDiff: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* @return {any}
|
|
26
|
-
*/
|
|
27
|
-
toJSON(): any;
|
|
28
|
-
/**
|
|
29
|
-
* @return {boolean}
|
|
30
|
-
*/
|
|
31
|
-
isEmpty(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* @param {AbstractDelta} other
|
|
34
|
-
* @param {boolean} priority
|
|
35
|
-
*/
|
|
36
|
-
rebase(other: AbstractDelta, priority: boolean): void;
|
|
37
|
-
/**
|
|
38
|
-
* @param {AbstractDelta} other
|
|
39
|
-
*/
|
|
40
|
-
apply(other: AbstractDelta): void;
|
|
41
|
-
/**
|
|
42
|
-
* @return {this}
|
|
43
|
-
*/
|
|
44
|
-
clone(): this;
|
|
45
|
-
/**
|
|
46
|
-
* @param {any} _other
|
|
47
|
-
* @return {boolean}
|
|
48
|
-
*/
|
|
49
|
-
[traits.EqualityTraitSymbol](_other: any): boolean;
|
|
50
|
-
}
|
|
51
|
-
export const $delta: s.Schema<AbstractDelta>;
|
|
52
|
-
export const $$delta: s.Schema<s.$InstanceOf<AbstractDelta>>;
|
|
53
|
-
export function mergeAttrs<T extends {
|
|
54
|
-
[key: string]: any;
|
|
55
|
-
}>(a: T | null, b: T | null): T | null;
|
|
56
|
-
export function mergeDeltas<D extends AbstractDelta | null>(a: D, b: D): D;
|
|
57
|
-
export type Attribution = s.TypeOf<s.Schema<{
|
|
58
|
-
insert?: string[] | undefined;
|
|
59
|
-
insertAt?: number | undefined;
|
|
60
|
-
delete?: string[] | undefined;
|
|
61
|
-
deleteAt?: number | undefined;
|
|
62
|
-
attributes?: {
|
|
63
|
-
[x: string]: string[];
|
|
64
|
-
} | undefined;
|
|
65
|
-
attributesAt?: number | undefined;
|
|
66
|
-
}>>;
|
|
67
|
-
import * as s from '../schema.js';
|
|
68
|
-
import * as traits from '../traits.js';
|
|
69
|
-
//# sourceMappingURL=abstract.d.ts.map
|
package/delta/abstract.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["abstract.js"],"names":[],"mappings":"AAKA;;;;;;;;;GAOE;AAEF;;GAEG;AAEH;;GAEG;AACH,sCAFgB,MAAM,CAAC,aAAa;IAIhC,gBAAmB;IACnB;;OAEG;IACH,QAFU,GAAG,CAEK;IAClB,gBAAkB;IAGpB;;OAEG;IACH,UAFY,GAAG,CAId;IAED;;OAEG;IACH,WAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,cAHW,aAAa,YACb,OAAO,QAIjB;IAED;;OAEG;IACH,aAFW,aAAa,QAIvB;IAED;;OAEG;IACH,SAFY,IAAI,CAIf;IAED;;;OAGG;IACH,qCAHW,GAAG,GACF,OAAO,CAIlB;CACF;AAED,6CAAkD;AAClD,sBAAkC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAuF;AASxJ,2BAJ+B,CAAC,SAA1B;IAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAG,KAC1B,CAAC,GAAG,IAAI,KACR,CAAC,GAAG,IAAI,YAE0F;AAQtG,4BALuB,CAAC,SAAjB,aAAa,OAAE,KAClB,CAAC,KACD,CAAC,GACA,CAAC,CASZ;0BAtFY,CAAC,CAAC,MAAM;;;;;;;;;GAAc;mBAZhB,cAAc;wBAFT,cAAc"}
|
package/delta/abstract.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as object from '../object.js'
|
|
2
|
-
import * as traits from '../traits.js'
|
|
3
|
-
import * as error from '../error.js'
|
|
4
|
-
import * as s from '../schema.js'
|
|
5
|
-
|
|
6
|
-
export const $attribution = s.$object({
|
|
7
|
-
insert: s.$array(s.$string).optional,
|
|
8
|
-
insertAt: s.$number.optional,
|
|
9
|
-
delete: s.$array(s.$string).optional,
|
|
10
|
-
deleteAt: s.$number.optional,
|
|
11
|
-
attributes: s.$record(s.$string, s.$array(s.$string)).optional,
|
|
12
|
-
attributesAt: s.$number.optional
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {s.TypeOf<$attribution>} Attribution
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @implements {traits.EqualityTrait}
|
|
21
|
-
*/
|
|
22
|
-
export class AbstractDelta {
|
|
23
|
-
constructor () {
|
|
24
|
-
this.remote = false
|
|
25
|
-
/**
|
|
26
|
-
* @type {any} origin
|
|
27
|
-
*/
|
|
28
|
-
this.origin = null
|
|
29
|
-
this.isDiff = true
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @return {any}
|
|
34
|
-
*/
|
|
35
|
-
toJSON () {
|
|
36
|
-
error.methodUnimplemented()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @return {boolean}
|
|
41
|
-
*/
|
|
42
|
-
isEmpty () {
|
|
43
|
-
error.methodUnimplemented()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @param {AbstractDelta} other
|
|
48
|
-
* @param {boolean} priority
|
|
49
|
-
*/
|
|
50
|
-
rebase (other, priority) {
|
|
51
|
-
error.methodUnimplemented()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @param {AbstractDelta} other
|
|
56
|
-
*/
|
|
57
|
-
apply (other) {
|
|
58
|
-
error.methodUnimplemented()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @return {this}
|
|
63
|
-
*/
|
|
64
|
-
clone () {
|
|
65
|
-
error.methodUnimplemented()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @param {any} _other
|
|
70
|
-
* @return {boolean}
|
|
71
|
-
*/
|
|
72
|
-
[traits.EqualityTraitSymbol] (_other) {
|
|
73
|
-
error.methodUnimplemented()
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const $delta = s.$instanceOf(AbstractDelta)
|
|
78
|
-
export const $$delta = /** @type {s.Schema<s.$InstanceOf<AbstractDelta>>} */ (s.$constructedBy(s.$InstanceOf, s => s.shape.prototype instanceof AbstractDelta))
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Helper function to merge attribution and attributes. The latter input "wins".
|
|
82
|
-
*
|
|
83
|
-
* @template {{ [key: string]: any }} T
|
|
84
|
-
* @param {T | null} a
|
|
85
|
-
* @param {T | null} b
|
|
86
|
-
*/
|
|
87
|
-
export const mergeAttrs = (a, b) => object.isEmpty(a) ? b : (object.isEmpty(b) ? a : object.assign({}, a, b))
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @template {AbstractDelta?} D
|
|
91
|
-
* @param {D} a
|
|
92
|
-
* @param {D} b
|
|
93
|
-
* @return {D}
|
|
94
|
-
*/
|
|
95
|
-
export const mergeDeltas = (a, b) => {
|
|
96
|
-
if (a != null && b != null) {
|
|
97
|
-
const c = /** @type {D & AbstractDelta} */ (a.clone())
|
|
98
|
-
c.apply(b)
|
|
99
|
-
return c
|
|
100
|
-
}
|
|
101
|
-
return a == null ? b : (a || null)
|
|
102
|
-
}
|
package/delta/array.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template ArrayContent
|
|
3
|
-
* @template {boolean} [WithText=false]
|
|
4
|
-
* @extends AbstractDeltaArrayBuilder<'array', import('./ops.js').DeltaArrayOps<ArrayContent,WithText>>
|
|
5
|
-
*/
|
|
6
|
-
export class DeltaArray<ArrayContent, WithText extends boolean = false> extends AbstractDeltaArrayBuilder<"array", ops.DeltaArrayOps<ArrayContent, WithText>> {
|
|
7
|
-
/**
|
|
8
|
-
* @param {s.Schema<ArrayContent>} $insert
|
|
9
|
-
* @param {WithText} withText
|
|
10
|
-
*/
|
|
11
|
-
constructor($insert: s.Schema<ArrayContent>, withText: WithText);
|
|
12
|
-
withText: WithText;
|
|
13
|
-
}
|
|
14
|
-
export function $array<ArrayContent, WithText extends boolean = false>($insert: s.Schema<ArrayContent>, withText?: WithText): s.Schema<DeltaArray<ArrayContent, WithText>>;
|
|
15
|
-
/**
|
|
16
|
-
* @type {s.Schema<DeltaArray<any,any>>}
|
|
17
|
-
*/
|
|
18
|
-
export const $arrayAny: s.Schema<DeltaArray<any, any>>;
|
|
19
|
-
export function array<V = any, WithText extends boolean = any>($insert?: s.Schema<V>, withText?: WithText): DeltaArray<V, WithText>;
|
|
20
|
-
import * as ops from './ops.js';
|
|
21
|
-
import { AbstractDeltaArrayBuilder } from './abstract-array.js';
|
|
22
|
-
import * as s from '../schema.js';
|
|
23
|
-
//# sourceMappingURL=array.d.ts.map
|
package/delta/array.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["array.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAJa,YAAY,EACD,QAAQ,SAAnB,OAAS;IAIpB;;;OAGG;IACH,qBAHW,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,YACtB,QAAQ,EAKlB;IADC,mBAAwB;CAE3B;AASM,uBANM,YAAY,EACD,QAAQ,SAAnB,OAAS,mBACX,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,aACtB,QAAQ,GACP,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAMpD;AACJ;;GAEG;AACH,wBAFU,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAC,GAAG,CAAC,CAAC,CAEwE;AASxG,sBANO,CAAC,QACS,QAAQ,SAAnB,OAAS,kBACX,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aACX,QAAQ,GACP,UAAU,CAAC,CAAC,EAAC,QAAQ,CAAC,CAEoG;qBA1CjH,UAAU;0CADW,qBAAqB;mBAD5C,cAAc"}
|
package/delta/array.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as s from '../schema.js'
|
|
2
|
-
import { AbstractDeltaArrayBuilder } from './abstract-array.js'
|
|
3
|
-
import * as ops from './ops.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @template ArrayContent
|
|
7
|
-
* @template {boolean} [WithText=false]
|
|
8
|
-
* @extends AbstractDeltaArrayBuilder<'array', import('./ops.js').DeltaArrayOps<ArrayContent,WithText>>
|
|
9
|
-
*/
|
|
10
|
-
export class DeltaArray extends AbstractDeltaArrayBuilder {
|
|
11
|
-
/**
|
|
12
|
-
* @param {s.Schema<ArrayContent>} $insert
|
|
13
|
-
* @param {WithText} withText
|
|
14
|
-
*/
|
|
15
|
-
constructor ($insert, withText) {
|
|
16
|
-
super('array', $insert)
|
|
17
|
-
this.withText = withText
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @template ArrayContent
|
|
23
|
-
* @template {boolean} [WithText=false]
|
|
24
|
-
* @param {s.Schema<ArrayContent>} $insert
|
|
25
|
-
* @param {WithText} [withText]
|
|
26
|
-
* @return {s.Schema<DeltaArray<ArrayContent, WithText>>}
|
|
27
|
-
*/
|
|
28
|
-
export const $array = ($insert, withText) => /** @type {any} */ (s.$instanceOf(AbstractDeltaArrayBuilder, o => o.type === 'array' && o.ops.every(op => {
|
|
29
|
-
if (ops.$textOp.check(op)) return !!withText
|
|
30
|
-
if (ops.$insertOp.check(op)) return op.insert.every(opi => $insert.check(opi))
|
|
31
|
-
return true
|
|
32
|
-
})))
|
|
33
|
-
/**
|
|
34
|
-
* @type {s.Schema<DeltaArray<any,any>>}
|
|
35
|
-
*/
|
|
36
|
-
export const $arrayAny = /** @type {any} */ (s.$instanceOf(AbstractDeltaArrayBuilder, o => o.type === 'array'))
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @template [V=any]
|
|
40
|
-
* @template {boolean} [WithText=any]
|
|
41
|
-
* @param {s.Schema<V>} $insert
|
|
42
|
-
* @param {WithText} [withText]
|
|
43
|
-
* @return {DeltaArray<V,WithText>}
|
|
44
|
-
*/
|
|
45
|
-
export const array = ($insert = s.$any, withText) => /** @type {DeltaArray<V,WithText>} */ (new DeltaArray($insert, withText ?? true))
|
package/delta/array.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.test.d.ts","sourceRoot":"","sources":["array.test.js"],"names":[],"mappings":""}
|