lib0 0.2.116 → 1.0.0-0
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/package.json +160 -407
- package/{array.js → src/array.js} +6 -2
- package/{binary.js → src/binary.js} +29 -35
- package/{delta → src/delta}/delta.js +474 -410
- package/{environment.js → src/environment.js} +30 -16
- package/{hash → src/hash}/rabin.js +6 -6
- package/{schema.js → src/schema.js} +127 -58
- package/{string.js → src/string.js} +47 -26
- package/{testing.js → src/testing.js} +3 -1
- package/src/ts.js +46 -0
- package/{dist → types}/array.d.ts +1 -1
- package/types/array.d.ts.map +1 -0
- package/{dist → types}/binary.d.ts +31 -37
- package/types/binary.d.ts.map +1 -0
- package/types/broadcastchannel.d.ts.map +1 -0
- package/types/buffer.d.ts.map +1 -0
- package/types/cache.d.ts.map +1 -0
- package/types/component.d.ts.map +1 -0
- package/types/conditions.d.ts.map +1 -0
- package/types/decoding.d.ts.map +1 -0
- package/types/delta/delta.d.ts +87 -16
- package/types/delta/delta.d.ts.map +1 -1
- package/types/delta/t3.test.d.ts.map +1 -1
- package/types/diff.d.ts.map +1 -0
- package/types/dom.d.ts.map +1 -0
- package/types/encoding.d.ts.map +1 -0
- package/{environment.d.ts → types/environment.d.ts} +2 -0
- package/types/environment.d.ts.map +1 -0
- package/types/error.d.ts.map +1 -0
- package/types/eventloop.d.ts.map +1 -0
- package/{function.d.ts → types/function.d.ts} +1 -1
- package/types/function.d.ts.map +1 -0
- package/types/indexeddb.d.ts.map +1 -0
- package/types/indexeddbV2.d.ts.map +1 -0
- package/types/iterator.d.ts.map +1 -0
- package/types/json.d.ts.map +1 -0
- package/types/list.d.ts.map +1 -0
- package/types/logging.common.d.ts.map +1 -0
- package/types/logging.d.ts.map +1 -0
- package/types/logging.node.d.ts.map +1 -0
- package/types/map.d.ts.map +1 -0
- package/types/math.d.ts.map +1 -0
- package/types/metric.d.ts.map +1 -0
- package/types/mutex.d.ts.map +1 -0
- package/{number.d.ts → types/number.d.ts} +2 -2
- package/types/number.d.ts.map +1 -0
- package/types/object.d.ts.map +1 -0
- package/types/observable.d.ts.map +1 -0
- package/types/pair.d.ts.map +1 -0
- package/types/performance.d.ts.map +1 -0
- package/types/performance.node.d.ts.map +1 -0
- package/types/pledge.d.ts.map +1 -0
- package/types/prng.d.ts.map +1 -0
- package/types/promise.d.ts.map +1 -0
- package/types/queue.d.ts.map +1 -0
- package/types/random.d.ts.map +1 -0
- package/{schema.d.ts → types/schema.d.ts} +65 -59
- package/types/schema.d.ts.map +1 -0
- package/types/set.d.ts.map +1 -0
- package/types/sort.d.ts.map +1 -0
- package/types/statistics.d.ts.map +1 -0
- package/types/storage.d.ts.map +1 -0
- package/{string.d.ts → types/string.d.ts} +3 -8
- package/types/string.d.ts.map +1 -0
- package/types/symbol.d.ts.map +1 -0
- package/{testing.d.ts → types/testing.d.ts} +2 -1
- package/types/testing.d.ts.map +1 -0
- package/types/time.d.ts.map +1 -0
- package/types/trait/equality.d.ts.map +1 -1
- package/types/tree.d.ts.map +1 -0
- package/types/ts.d.ts +22 -0
- package/types/ts.d.ts.map +1 -0
- package/types/url.d.ts.map +1 -0
- package/types/webcrypto.d.ts.map +1 -0
- package/types/webcrypto.deno.d.ts.map +1 -0
- package/types/webcrypto.node.d.ts.map +1 -0
- package/types/webcrypto.react-native.d.ts.map +1 -0
- package/types/websocket.d.ts.map +1 -0
- package/.github/workflows/node.js.yml +0 -24
- package/.jsdoc.json +0 -18
- package/.vscode/launch.json +0 -17
- package/array.d.ts +0 -30
- package/array.d.ts.map +0 -1
- package/array.test.d.ts +0 -13
- package/array.test.d.ts.map +0 -1
- package/bin/0ecdsa-generate-keypair.d.ts +0 -3
- package/bin/0ecdsa-generate-keypair.d.ts.map +0 -1
- package/bin/0serve.d.ts +0 -3
- package/bin/0serve.d.ts.map +0 -1
- package/bin/gendocs.d.ts +0 -3
- package/bin/gendocs.d.ts.map +0 -1
- package/bin/gentesthtml.d.ts +0 -3
- package/bin/gentesthtml.d.ts.map +0 -1
- package/binary.d.ts +0 -87
- package/binary.d.ts.map +0 -1
- package/binary.test.d.ts +0 -4
- package/binary.test.d.ts.map +0 -1
- package/broadcastchannel.d.ts.map +0 -1
- package/broadcastchannel.test.d.ts +0 -3
- package/broadcastchannel.test.d.ts.map +0 -1
- package/buffer.d.ts.map +0 -1
- package/buffer.test.d.ts +0 -6
- package/buffer.test.d.ts.map +0 -1
- package/cache.d.ts.map +0 -1
- package/cache.test.d.ts +0 -3
- package/cache.test.d.ts.map +0 -1
- package/component.d.ts.map +0 -1
- package/conditions.d.ts.map +0 -1
- package/coverage/tmp/coverage-54474-1766470859038-0.json +0 -1
- package/crypto/aes-gcm.d.ts +0 -17
- package/crypto/aes-gcm.d.ts.map +0 -1
- package/crypto/common.d.ts +0 -3
- package/crypto/common.d.ts.map +0 -1
- package/crypto/ecdsa.d.ts +0 -17
- package/crypto/ecdsa.d.ts.map +0 -1
- package/crypto/jwt.d.ts +0 -10
- package/crypto/jwt.d.ts.map +0 -1
- package/crypto/rsa-oaep.d.ts +0 -13
- package/crypto/rsa-oaep.d.ts.map +0 -1
- package/crypto.test.d.ts +0 -9
- package/crypto.test.d.ts.map +0 -1
- package/decoding.d.ts.map +0 -1
- package/delta/binding.d.ts +0 -107
- package/delta/binding.d.ts.map +0 -1
- package/delta/binding.test.d.ts +0 -5
- package/delta/binding.test.d.ts.map +0 -1
- package/delta/delta-pitch.test.d.ts +0 -5
- package/delta/delta-pitch.test.d.ts.map +0 -1
- package/delta/delta.d.ts +0 -1008
- package/delta/delta.d.ts.map +0 -1
- package/delta/delta.test.d.ts +0 -28
- package/delta/delta.test.d.ts.map +0 -1
- package/delta/t3.test.d.ts +0 -19
- package/delta/t3.test.d.ts.map +0 -1
- package/deno.json +0 -12
- package/deno.lock +0 -122
- package/diff/patience.d.ts +0 -16
- package/diff/patience.d.ts.map +0 -1
- package/diff/patience.test.d.ts +0 -4
- package/diff/patience.test.d.ts.map +0 -1
- package/diff.d.ts.map +0 -1
- package/diff.test.d.ts +0 -6
- package/diff.test.d.ts.map +0 -1
- package/dist/aes-gcm.cjs +0 -171
- package/dist/aes-gcm.cjs.map +0 -1
- package/dist/array-78849c95.cjs +0 -260
- package/dist/array-78849c95.cjs.map +0 -1
- package/dist/array.cjs +0 -26
- package/dist/array.cjs.map +0 -1
- package/dist/array.d.ts.map +0 -1
- package/dist/array.test.d.ts +0 -13
- package/dist/array.test.d.ts.map +0 -1
- package/dist/bin/0ecdsa-generate-keypair.d.ts +0 -3
- package/dist/bin/0ecdsa-generate-keypair.d.ts.map +0 -1
- package/dist/bin/0serve.d.ts +0 -3
- package/dist/bin/0serve.d.ts.map +0 -1
- package/dist/bin/gendocs.d.ts +0 -3
- package/dist/bin/gendocs.d.ts.map +0 -1
- package/dist/bin/gentesthtml.d.ts +0 -3
- package/dist/bin/gentesthtml.d.ts.map +0 -1
- package/dist/binary-ac8e39e2.cjs +0 -229
- package/dist/binary-ac8e39e2.cjs.map +0 -1
- package/dist/binary.cjs +0 -74
- package/dist/binary.cjs.map +0 -1
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.test.d.ts +0 -4
- package/dist/binary.test.d.ts.map +0 -1
- package/dist/binding.cjs +0 -484
- package/dist/binding.cjs.map +0 -1
- package/dist/broadcastchannel-aca4f606.cjs +0 -128
- package/dist/broadcastchannel-aca4f606.cjs.map +0 -1
- package/dist/broadcastchannel.cjs +0 -29
- package/dist/broadcastchannel.cjs.map +0 -1
- package/dist/broadcastchannel.d.ts +0 -8
- package/dist/broadcastchannel.d.ts.map +0 -1
- package/dist/broadcastchannel.test.d.ts +0 -3
- package/dist/broadcastchannel.test.d.ts.map +0 -1
- package/dist/buffer-3e750729.cjs +0 -198
- package/dist/buffer-3e750729.cjs.map +0 -1
- package/dist/buffer.cjs +0 -38
- package/dist/buffer.cjs.map +0 -1
- package/dist/buffer.d.ts +0 -22
- package/dist/buffer.d.ts.map +0 -1
- package/dist/buffer.test.d.ts +0 -6
- package/dist/buffer.test.d.ts.map +0 -1
- package/dist/cache.cjs +0 -223
- package/dist/cache.cjs.map +0 -1
- package/dist/cache.d.ts +0 -52
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.test.d.ts +0 -3
- package/dist/cache.test.d.ts.map +0 -1
- package/dist/common.cjs +0 -47
- package/dist/common.cjs.map +0 -1
- package/dist/component.cjs +0 -437
- package/dist/component.cjs.map +0 -1
- package/dist/component.d.ts +0 -86
- package/dist/component.d.ts.map +0 -1
- package/dist/conditions-f5c0c102.cjs +0 -24
- package/dist/conditions-f5c0c102.cjs.map +0 -1
- package/dist/conditions.cjs +0 -10
- package/dist/conditions.cjs.map +0 -1
- package/dist/conditions.d.ts +0 -2
- package/dist/conditions.d.ts.map +0 -1
- package/dist/crypto/aes-gcm.d.ts +0 -17
- package/dist/crypto/aes-gcm.d.ts.map +0 -1
- package/dist/crypto/common.d.ts +0 -3
- package/dist/crypto/common.d.ts.map +0 -1
- package/dist/crypto/ecdsa.d.ts +0 -17
- package/dist/crypto/ecdsa.d.ts.map +0 -1
- package/dist/crypto/jwt.d.ts +0 -10
- package/dist/crypto/jwt.d.ts.map +0 -1
- package/dist/crypto/rsa-oaep.d.ts +0 -13
- package/dist/crypto/rsa-oaep.d.ts.map +0 -1
- package/dist/crypto.test.d.ts +0 -9
- package/dist/crypto.test.d.ts.map +0 -1
- package/dist/decoding-76e75827.cjs +0 -795
- package/dist/decoding-76e75827.cjs.map +0 -1
- package/dist/decoding.cjs +0 -55
- package/dist/decoding.cjs.map +0 -1
- package/dist/decoding.d.ts +0 -165
- package/dist/decoding.d.ts.map +0 -1
- package/dist/delta/binding.d.ts +0 -107
- package/dist/delta/binding.d.ts.map +0 -1
- package/dist/delta/binding.test.d.ts +0 -5
- package/dist/delta/binding.test.d.ts.map +0 -1
- package/dist/delta/delta-pitch.test.d.ts +0 -5
- package/dist/delta/delta-pitch.test.d.ts.map +0 -1
- package/dist/delta/delta.d.ts +0 -1008
- package/dist/delta/delta.d.ts.map +0 -1
- package/dist/delta/delta.test.d.ts +0 -28
- package/dist/delta/delta.test.d.ts.map +0 -1
- package/dist/delta/t3.test.d.ts +0 -19
- package/dist/delta/t3.test.d.ts.map +0 -1
- package/dist/delta.cjs +0 -2409
- package/dist/delta.cjs.map +0 -1
- package/dist/diff/patience.d.ts +0 -16
- package/dist/diff/patience.d.ts.map +0 -1
- package/dist/diff/patience.test.d.ts +0 -4
- package/dist/diff/patience.test.d.ts.map +0 -1
- package/dist/diff-9d236524.cjs +0 -162
- package/dist/diff-9d236524.cjs.map +0 -1
- package/dist/diff.cjs +0 -18
- package/dist/diff.cjs.map +0 -1
- package/dist/diff.d.ts +0 -36
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.test.d.ts +0 -6
- package/dist/diff.test.d.ts.map +0 -1
- package/dist/dom-7e625b09.cjs +0 -371
- package/dist/dom-7e625b09.cjs.map +0 -1
- package/dist/dom.cjs +0 -71
- package/dist/dom.cjs.map +0 -1
- package/dist/dom.d.ts.map +0 -1
- package/dist/ecdsa.cjs +0 -130
- package/dist/ecdsa.cjs.map +0 -1
- package/dist/encoding-1a745c43.cjs +0 -1025
- package/dist/encoding-1a745c43.cjs.map +0 -1
- package/dist/encoding.cjs +0 -54
- package/dist/encoding.cjs.map +0 -1
- package/dist/encoding.d.ts.map +0 -1
- package/dist/encoding.test.d.ts +0 -50
- package/dist/encoding.test.d.ts.map +0 -1
- package/dist/environment-1c97264d.cjs +0 -180
- package/dist/environment-1c97264d.cjs.map +0 -1
- package/dist/environment.cjs +0 -29
- package/dist/environment.cjs.map +0 -1
- package/dist/environment.d.ts +0 -19
- package/dist/environment.d.ts.map +0 -1
- package/dist/equality.cjs +0 -34
- package/dist/equality.cjs.map +0 -1
- package/dist/error-0c1f634f.cjs +0 -53
- package/dist/error-0c1f634f.cjs.map +0 -1
- package/dist/error.cjs +0 -13
- package/dist/error.cjs.map +0 -1
- package/dist/error.d.ts.map +0 -1
- package/dist/eventloop-a0168106.cjs +0 -151
- package/dist/eventloop-a0168106.cjs.map +0 -1
- package/dist/eventloop.cjs +0 -19
- package/dist/eventloop.cjs.map +0 -1
- package/dist/eventloop.d.ts.map +0 -1
- package/dist/eventloop.test.d.ts +0 -10
- package/dist/eventloop.test.d.ts.map +0 -1
- package/dist/fingerprint.cjs +0 -44
- package/dist/fingerprint.cjs.map +0 -1
- package/dist/function-314580f7.cjs +0 -223
- package/dist/function-314580f7.cjs.map +0 -1
- package/dist/function.cjs +0 -26
- package/dist/function.cjs.map +0 -1
- package/dist/function.d.ts +0 -19
- package/dist/function.d.ts.map +0 -1
- package/dist/function.test.d.ts +0 -5
- package/dist/function.test.d.ts.map +0 -1
- package/dist/hash/rabin-gf2-polynomial.d.ts +0 -45
- package/dist/hash/rabin-gf2-polynomial.d.ts.map +0 -1
- package/dist/hash/rabin-uncached.d.ts +0 -29
- package/dist/hash/rabin-uncached.d.ts.map +0 -1
- package/dist/hash/rabin.d.ts +0 -27
- package/dist/hash/rabin.d.ts.map +0 -1
- package/dist/hash/rabin.test.d.ts +0 -8
- package/dist/hash/rabin.test.d.ts.map +0 -1
- package/dist/hash/sha256.d.ts +0 -2
- package/dist/hash/sha256.d.ts.map +0 -1
- package/dist/hash/sha256.node.d.ts +0 -2
- package/dist/hash/sha256.node.d.ts.map +0 -1
- package/dist/hash/sha256.test.d.ts +0 -7
- package/dist/hash/sha256.test.d.ts.map +0 -1
- package/dist/index.cjs +0 -99
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -35
- package/dist/index.d.ts.map +0 -1
- package/dist/indexeddb-46d1e737.cjs +0 -311
- package/dist/indexeddb-46d1e737.cjs.map +0 -1
- package/dist/indexeddb.cjs +0 -37
- package/dist/indexeddb.cjs.map +0 -1
- package/dist/indexeddb.d.ts.map +0 -1
- package/dist/indexeddb.test.d.ts +0 -3
- package/dist/indexeddb.test.d.ts.map +0 -1
- package/dist/indexeddbV2.cjs +0 -288
- package/dist/indexeddbV2.cjs.map +0 -1
- package/dist/indexeddbV2.d.ts.map +0 -1
- package/dist/indexeddbV2.test.d.ts +0 -3
- package/dist/indexeddbV2.test.d.ts.map +0 -1
- package/dist/isomorphic.cjs +0 -17
- package/dist/isomorphic.cjs.map +0 -1
- package/dist/iterator-9fc627c1.cjs +0 -78
- package/dist/iterator-9fc627c1.cjs.map +0 -1
- package/dist/iterator.cjs +0 -13
- package/dist/iterator.cjs.map +0 -1
- package/dist/iterator.d.ts.map +0 -1
- package/dist/json-092190a1.cjs +0 -34
- package/dist/json-092190a1.cjs.map +0 -1
- package/dist/json.cjs +0 -11
- package/dist/json.cjs.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/jwt.cjs +0 -96
- package/dist/jwt.cjs.map +0 -1
- package/dist/list.cjs +0 -266
- package/dist/list.cjs.map +0 -1
- package/dist/list.d.ts.map +0 -1
- package/dist/list.test.d.ts +0 -6
- package/dist/list.test.d.ts.map +0 -1
- package/dist/logging.cjs +0 -428
- package/dist/logging.cjs.map +0 -1
- package/dist/logging.common.cjs +0 -132
- package/dist/logging.common.cjs.map +0 -1
- package/dist/logging.common.d.ts.map +0 -1
- package/dist/logging.d.ts.map +0 -1
- package/dist/logging.node.cjs +0 -203
- package/dist/logging.node.cjs.map +0 -1
- package/dist/logging.node.d.ts.map +0 -1
- package/dist/logging.test.d.ts +0 -3
- package/dist/logging.test.d.ts.map +0 -1
- package/dist/map-24d263c0.cjs +0 -139
- package/dist/map-24d263c0.cjs.map +0 -1
- package/dist/map.cjs +0 -15
- package/dist/map.cjs.map +0 -1
- package/dist/map.d.ts.map +0 -1
- package/dist/map.test.d.ts +0 -4
- package/dist/map.test.d.ts.map +0 -1
- package/dist/math-96d5e8c4.cjs +0 -103
- package/dist/math-96d5e8c4.cjs.map +0 -1
- package/dist/math.cjs +0 -26
- package/dist/math.cjs.map +0 -1
- package/dist/math.d.ts.map +0 -1
- package/dist/math.test.d.ts +0 -3
- package/dist/math.test.d.ts.map +0 -1
- package/dist/metric.cjs +0 -83
- package/dist/metric.cjs.map +0 -1
- package/dist/metric.d.ts.map +0 -1
- package/dist/metric.test.d.ts +0 -3
- package/dist/metric.test.d.ts.map +0 -1
- package/dist/mutex-63f09c81.cjs +0 -54
- package/dist/mutex-63f09c81.cjs.map +0 -1
- package/dist/mutex.cjs +0 -10
- package/dist/mutex.cjs.map +0 -1
- package/dist/mutex.d.ts.map +0 -1
- package/dist/mutex.test.d.ts +0 -3
- package/dist/mutex.test.d.ts.map +0 -1
- package/dist/number-1fb57bba.cjs +0 -64
- package/dist/number-1fb57bba.cjs.map +0 -1
- package/dist/number.cjs +0 -20
- package/dist/number.cjs.map +0 -1
- package/dist/number.d.ts +0 -10
- package/dist/number.d.ts.map +0 -1
- package/dist/number.test.d.ts +0 -4
- package/dist/number.test.d.ts.map +0 -1
- package/dist/object-c0c9435b.cjs +0 -212
- package/dist/object-c0c9435b.cjs.map +0 -1
- package/dist/object.cjs +0 -27
- package/dist/object.cjs.map +0 -1
- package/dist/object.d.ts.map +0 -1
- package/dist/object.test.d.ts +0 -6
- package/dist/object.test.d.ts.map +0 -1
- package/dist/observable.cjs +0 -169
- package/dist/observable.cjs.map +0 -1
- package/dist/observable.d.ts.map +0 -1
- package/dist/observable.test.d.ts +0 -3
- package/dist/observable.test.d.ts.map +0 -1
- package/dist/pair-ab022bc3.cjs +0 -69
- package/dist/pair-ab022bc3.cjs.map +0 -1
- package/dist/pair.cjs +0 -14
- package/dist/pair.cjs.map +0 -1
- package/dist/pair.d.ts.map +0 -1
- package/dist/pair.test.d.ts +0 -3
- package/dist/pair.test.d.ts.map +0 -1
- package/dist/patience.cjs +0 -236
- package/dist/patience.cjs.map +0 -1
- package/dist/performance.cjs +0 -14
- package/dist/performance.cjs.map +0 -1
- package/dist/performance.d.ts.map +0 -1
- package/dist/performance.node.cjs +0 -36
- package/dist/performance.node.cjs.map +0 -1
- package/dist/performance.node.d.ts.map +0 -1
- package/dist/pledge.cjs +0 -308
- package/dist/pledge.cjs.map +0 -1
- package/dist/pledge.d.ts.map +0 -1
- package/dist/pledge.test.d.ts +0 -6
- package/dist/pledge.test.d.ts.map +0 -1
- package/dist/prng/Mt19937.d.ts +0 -29
- package/dist/prng/Mt19937.d.ts.map +0 -1
- package/dist/prng/Xoroshiro128plus.d.ts +0 -27
- package/dist/prng/Xoroshiro128plus.d.ts.map +0 -1
- package/dist/prng/Xorshift32.d.ts +0 -21
- package/dist/prng/Xorshift32.d.ts.map +0 -1
- package/dist/prng-37d48618.cjs +0 -387
- package/dist/prng-37d48618.cjs.map +0 -1
- package/dist/prng.cjs +0 -44
- package/dist/prng.cjs.map +0 -1
- package/dist/prng.d.ts.map +0 -1
- package/dist/prng.test.d.ts +0 -6
- package/dist/prng.test.d.ts.map +0 -1
- package/dist/promise-cda7b9bb.cjs +0 -145
- package/dist/promise-cda7b9bb.cjs.map +0 -1
- package/dist/promise.cjs +0 -22
- package/dist/promise.cjs.map +0 -1
- package/dist/promise.d.ts.map +0 -1
- package/dist/promise.test.d.ts +0 -5
- package/dist/promise.test.d.ts.map +0 -1
- package/dist/queue.cjs +0 -97
- package/dist/queue.cjs.map +0 -1
- package/dist/queue.d.ts.map +0 -1
- package/dist/queue.test.d.ts +0 -3
- package/dist/queue.test.d.ts.map +0 -1
- package/dist/rabin-gf2-polynomial.cjs +0 -440
- package/dist/rabin-gf2-polynomial.cjs.map +0 -1
- package/dist/rabin-uncached.cjs +0 -90
- package/dist/rabin-uncached.cjs.map +0 -1
- package/dist/rabin.cjs +0 -128
- package/dist/rabin.cjs.map +0 -1
- package/dist/random.cjs +0 -48
- package/dist/random.cjs.map +0 -1
- package/dist/random.d.ts.map +0 -1
- package/dist/random.test.d.ts +0 -7
- package/dist/random.test.d.ts.map +0 -1
- package/dist/rollup.config.d.ts +0 -13
- package/dist/rollup.config.d.ts.map +0 -1
- package/dist/rsa-oaep.cjs +0 -112
- package/dist/rsa-oaep.cjs.map +0 -1
- package/dist/schema.cjs +0 -1223
- package/dist/schema.cjs.map +0 -1
- package/dist/schema.d.ts +0 -595
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.test.d.ts +0 -15
- package/dist/schema.test.d.ts.map +0 -1
- package/dist/set-5b47859e.cjs +0 -45
- package/dist/set-5b47859e.cjs.map +0 -1
- package/dist/set.cjs +0 -13
- package/dist/set.cjs.map +0 -1
- package/dist/set.d.ts.map +0 -1
- package/dist/set.test.d.ts +0 -3
- package/dist/set.test.d.ts.map +0 -1
- package/dist/sha256.cjs +0 -183
- package/dist/sha256.cjs.map +0 -1
- package/dist/sha256.node.cjs +0 -17
- package/dist/sha256.node.cjs.map +0 -1
- package/dist/sort-812cc211.cjs +0 -103
- package/dist/sort-812cc211.cjs.map +0 -1
- package/dist/sort.cjs +0 -13
- package/dist/sort.cjs.map +0 -1
- package/dist/sort.d.ts.map +0 -1
- package/dist/sort.test.d.ts +0 -7
- package/dist/sort.test.d.ts.map +0 -1
- package/dist/statistics-65f6114b.cjs +0 -32
- package/dist/statistics-65f6114b.cjs.map +0 -1
- package/dist/statistics.cjs +0 -12
- package/dist/statistics.cjs.map +0 -1
- package/dist/statistics.d.ts.map +0 -1
- package/dist/statistics.test.d.ts +0 -3
- package/dist/statistics.test.d.ts.map +0 -1
- package/dist/storage.cjs +0 -81
- package/dist/storage.cjs.map +0 -1
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.test.d.ts +0 -3
- package/dist/storage.test.d.ts.map +0 -1
- package/dist/string-fddc5f8b.cjs +0 -209
- package/dist/string-fddc5f8b.cjs.map +0 -1
- package/dist/string.cjs +0 -32
- package/dist/string.cjs.map +0 -1
- package/dist/string.d.ts +0 -28
- package/dist/string.d.ts.map +0 -1
- package/dist/string.test.d.ts +0 -9
- package/dist/string.test.d.ts.map +0 -1
- package/dist/symbol-9c439012.cjs +0 -29
- package/dist/symbol-9c439012.cjs.map +0 -1
- package/dist/symbol.cjs +0 -11
- package/dist/symbol.cjs.map +0 -1
- package/dist/symbol.d.ts.map +0 -1
- package/dist/symbol.test.d.ts +0 -3
- package/dist/symbol.test.d.ts.map +0 -1
- package/dist/testing.cjs +0 -709
- package/dist/testing.cjs.map +0 -1
- package/dist/testing.d.ts +0 -64
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.test.d.ts +0 -9
- package/dist/testing.test.d.ts.map +0 -1
- package/dist/time-d8438852.cjs +0 -63
- package/dist/time-d8438852.cjs.map +0 -1
- package/dist/time.cjs +0 -14
- package/dist/time.cjs.map +0 -1
- package/dist/time.d.ts.map +0 -1
- package/dist/time.test.d.ts +0 -4
- package/dist/time.test.d.ts.map +0 -1
- package/dist/trait/equality.d.ts +0 -6
- package/dist/trait/equality.d.ts.map +0 -1
- package/dist/trait/fingerprint.d.ts +0 -13
- package/dist/trait/fingerprint.d.ts.map +0 -1
- package/dist/trait/traits.d.ts +0 -3
- package/dist/trait/traits.d.ts.map +0 -1
- package/dist/trait/traits.test.d.ts +0 -5
- package/dist/trait/traits.test.d.ts.map +0 -1
- package/dist/traits.cjs +0 -31
- package/dist/traits.cjs.map +0 -1
- package/dist/tree-9f3c8837.cjs +0 -557
- package/dist/tree-9f3c8837.cjs.map +0 -1
- package/dist/tree.cjs +0 -10
- package/dist/tree.cjs.map +0 -1
- package/dist/tree.d.ts.map +0 -1
- package/dist/tree.test.d.ts +0 -2
- package/dist/tree.test.d.ts.map +0 -1
- package/dist/url.cjs +0 -46
- package/dist/url.cjs.map +0 -1
- package/dist/url.d.ts.map +0 -1
- package/dist/url.test.d.ts +0 -3
- package/dist/url.test.d.ts.map +0 -1
- package/dist/webcrypto.cjs +0 -12
- package/dist/webcrypto.cjs.map +0 -1
- package/dist/webcrypto.d.ts.map +0 -1
- package/dist/webcrypto.deno.cjs +0 -12
- package/dist/webcrypto.deno.cjs.map +0 -1
- package/dist/webcrypto.deno.d.ts.map +0 -1
- package/dist/webcrypto.node.cjs +0 -12
- package/dist/webcrypto.node.cjs.map +0 -1
- package/dist/webcrypto.node.d.ts.map +0 -1
- package/dist/webcrypto.react-native.cjs +0 -20
- package/dist/webcrypto.react-native.cjs.map +0 -1
- package/dist/webcrypto.react-native.d.ts.map +0 -1
- package/dist/websocket-b073d0fc.cjs +0 -157
- package/dist/websocket-b073d0fc.cjs.map +0 -1
- package/dist/websocket.cjs +0 -17
- package/dist/websocket.cjs.map +0 -1
- package/dist/websocket.d.ts.map +0 -1
- package/dom.d.ts +0 -60
- package/dom.d.ts.map +0 -1
- package/encoding.d.ts +0 -235
- package/encoding.d.ts.map +0 -1
- package/encoding.test.d.ts +0 -50
- package/encoding.test.d.ts.map +0 -1
- package/environment.d.ts.map +0 -1
- package/error.d.ts +0 -5
- package/error.d.ts.map +0 -1
- package/eventloop.d.ts +0 -16
- package/eventloop.d.ts.map +0 -1
- package/eventloop.test.d.ts +0 -10
- package/eventloop.test.d.ts.map +0 -1
- package/function.d.ts.map +0 -1
- package/function.test.d.ts +0 -5
- package/function.test.d.ts.map +0 -1
- package/hash/rabin-gf2-polynomial.d.ts +0 -45
- package/hash/rabin-gf2-polynomial.d.ts.map +0 -1
- package/hash/rabin-uncached.d.ts +0 -29
- package/hash/rabin-uncached.d.ts.map +0 -1
- package/hash/rabin.d.ts +0 -27
- package/hash/rabin.d.ts.map +0 -1
- package/hash/rabin.test.d.ts +0 -8
- package/hash/rabin.test.d.ts.map +0 -1
- package/hash/sha256.d.ts +0 -2
- package/hash/sha256.d.ts.map +0 -1
- package/hash/sha256.node.d.ts +0 -2
- package/hash/sha256.node.d.ts.map +0 -1
- package/hash/sha256.test.d.ts +0 -7
- package/hash/sha256.test.d.ts.map +0 -1
- package/index.d.ts +0 -35
- package/index.d.ts.map +0 -1
- package/index.js +0 -82
- package/indexeddb.d.ts +0 -34
- package/indexeddb.d.ts.map +0 -1
- package/indexeddb.test.d.ts +0 -3
- package/indexeddb.test.d.ts.map +0 -1
- package/indexeddbV2.d.ts +0 -35
- package/indexeddbV2.d.ts.map +0 -1
- package/indexeddbV2.test.d.ts +0 -3
- package/indexeddbV2.test.d.ts.map +0 -1
- package/isomorphic.js +0 -10
- package/iterator.d.ts +0 -5
- package/iterator.d.ts.map +0 -1
- package/json.d.ts +0 -23
- package/json.d.ts.map +0 -1
- package/list.d.ts +0 -55
- package/list.d.ts.map +0 -1
- package/list.test.d.ts +0 -6
- package/list.test.d.ts.map +0 -1
- package/logging.common.d.ts +0 -12
- package/logging.common.d.ts.map +0 -1
- package/logging.d.ts +0 -55
- package/logging.d.ts.map +0 -1
- package/logging.node.d.ts +0 -14
- package/logging.node.d.ts.map +0 -1
- package/logging.test.d.ts +0 -3
- package/logging.test.d.ts.map +0 -1
- package/map.d.ts +0 -8
- package/map.d.ts.map +0 -1
- package/map.test.d.ts +0 -4
- package/map.test.d.ts.map +0 -1
- package/math.d.ts +0 -23
- package/math.d.ts.map +0 -1
- package/math.test.d.ts +0 -3
- package/math.test.d.ts.map +0 -1
- package/metric.d.ts +0 -25
- package/metric.d.ts.map +0 -1
- package/metric.test.d.ts +0 -3
- package/metric.test.d.ts.map +0 -1
- package/mutex.d.ts +0 -3
- package/mutex.d.ts.map +0 -1
- package/mutex.test.d.ts +0 -3
- package/mutex.test.d.ts.map +0 -1
- package/number.d.ts.map +0 -1
- package/number.test.d.ts +0 -4
- package/number.test.d.ts.map +0 -1
- package/object.d.ts +0 -72
- package/object.d.ts.map +0 -1
- package/object.test.d.ts +0 -6
- package/object.test.d.ts.map +0 -1
- package/observable.d.ts +0 -86
- package/observable.d.ts.map +0 -1
- package/observable.test.d.ts +0 -3
- package/observable.test.d.ts.map +0 -1
- package/pair.d.ts +0 -22
- package/pair.d.ts.map +0 -1
- package/pair.test.d.ts +0 -3
- package/pair.test.d.ts.map +0 -1
- package/performance.d.ts +0 -4
- package/performance.d.ts.map +0 -1
- package/performance.node.d.ts +0 -14
- package/performance.node.d.ts.map +0 -1
- package/pledge.d.ts +0 -68
- package/pledge.d.ts.map +0 -1
- package/pledge.test.d.ts +0 -6
- package/pledge.test.d.ts.map +0 -1
- package/prng/Mt19937.d.ts +0 -29
- package/prng/Mt19937.d.ts.map +0 -1
- package/prng/Xoroshiro128plus.d.ts +0 -27
- package/prng/Xoroshiro128plus.d.ts.map +0 -1
- package/prng/Xorshift32.d.ts +0 -21
- package/prng/Xorshift32.d.ts.map +0 -1
- package/prng.d.ts +0 -44
- package/prng.d.ts.map +0 -1
- package/prng.test.d.ts +0 -6
- package/prng.test.d.ts.map +0 -1
- package/promise.d.ts +0 -22
- package/promise.d.ts.map +0 -1
- package/promise.test.d.ts +0 -5
- package/promise.test.d.ts.map +0 -1
- package/queue.d.ts +0 -34
- package/queue.d.ts.map +0 -1
- package/queue.test.d.ts +0 -3
- package/queue.test.d.ts.map +0 -1
- package/random.d.ts +0 -6
- package/random.d.ts.map +0 -1
- package/random.test.d.ts +0 -7
- package/random.test.d.ts.map +0 -1
- package/rollup.config.d.ts +0 -13
- package/rollup.config.d.ts.map +0 -1
- package/schema.d.ts.map +0 -1
- package/schema.test.d.ts +0 -15
- package/schema.test.d.ts.map +0 -1
- package/set.d.ts +0 -5
- package/set.d.ts.map +0 -1
- package/set.test.d.ts +0 -3
- package/set.test.d.ts.map +0 -1
- package/sort.d.ts +0 -4
- package/sort.d.ts.map +0 -1
- package/sort.test.d.ts +0 -7
- package/sort.test.d.ts.map +0 -1
- package/statistics.d.ts +0 -3
- package/statistics.d.ts.map +0 -1
- package/statistics.test.d.ts +0 -3
- package/statistics.test.d.ts.map +0 -1
- package/storage.d.ts +0 -15
- package/storage.d.ts.map +0 -1
- package/storage.test.d.ts +0 -3
- package/storage.test.d.ts.map +0 -1
- package/string.d.ts.map +0 -1
- package/string.test.d.ts +0 -9
- package/string.test.d.ts.map +0 -1
- package/symbol.d.ts +0 -11
- package/symbol.d.ts.map +0 -1
- package/symbol.test.d.ts +0 -3
- package/symbol.test.d.ts.map +0 -1
- package/test.d.ts +0 -2
- package/test.d.ts.map +0 -1
- package/test.html +0 -168
- package/test.js +0 -104
- package/testing.d.ts.map +0 -1
- package/testing.test.d.ts +0 -9
- package/testing.test.d.ts.map +0 -1
- package/time.d.ts +0 -9
- package/time.d.ts.map +0 -1
- package/time.test.d.ts +0 -4
- package/time.test.d.ts.map +0 -1
- package/trait/equality.d.ts +0 -6
- package/trait/equality.d.ts.map +0 -1
- package/trait/fingerprint.d.ts +0 -13
- package/trait/fingerprint.d.ts.map +0 -1
- package/trait/traits.d.ts +0 -3
- package/trait/traits.d.ts.map +0 -1
- package/trait/traits.test.d.ts +0 -5
- package/trait/traits.test.d.ts.map +0 -1
- package/tree.d.ts +0 -96
- package/tree.d.ts.map +0 -1
- package/tree.test.d.ts +0 -2
- package/tree.test.d.ts.map +0 -1
- package/url.d.ts +0 -7
- package/url.d.ts.map +0 -1
- package/url.test.d.ts +0 -3
- package/url.test.d.ts.map +0 -1
- package/webcrypto.d.ts +0 -3
- package/webcrypto.d.ts.map +0 -1
- package/webcrypto.deno.d.ts +0 -3
- package/webcrypto.deno.d.ts.map +0 -1
- package/webcrypto.node.d.ts +0 -3
- package/webcrypto.node.d.ts.map +0 -1
- package/webcrypto.react-native.d.ts +0 -3
- package/webcrypto.react-native.d.ts.map +0 -1
- package/websocket.d.ts +0 -38
- package/websocket.d.ts.map +0 -1
- /package/{bin → src/bin}/0ecdsa-generate-keypair.js +0 -0
- /package/{bin → src/bin}/0serve.js +0 -0
- /package/{bin → src/bin}/gendocs.js +0 -0
- /package/{bin → src/bin}/gentesthtml.js +0 -0
- /package/{broadcastchannel.js → src/broadcastchannel.js} +0 -0
- /package/{buffer.js → src/buffer.js} +0 -0
- /package/{cache.js → src/cache.js} +0 -0
- /package/{component.js → src/component.js} +0 -0
- /package/{conditions.js → src/conditions.js} +0 -0
- /package/{crypto → src/crypto}/aes-gcm.js +0 -0
- /package/{crypto → src/crypto}/common.js +0 -0
- /package/{crypto → src/crypto}/ecdsa.js +0 -0
- /package/{crypto → src/crypto}/jwt.js +0 -0
- /package/{crypto → src/crypto}/rsa-oaep.js +0 -0
- /package/{decoding.js → src/decoding.js} +0 -0
- /package/{delta → src/delta}/binding.js +0 -0
- /package/{delta → src/delta}/readme.md +0 -0
- /package/{diff → src/diff}/patience.js +0 -0
- /package/{diff.js → src/diff.js} +0 -0
- /package/{dom.js → src/dom.js} +0 -0
- /package/{encoding.js → src/encoding.js} +0 -0
- /package/{error.js → src/error.js} +0 -0
- /package/{eventloop.js → src/eventloop.js} +0 -0
- /package/{function.js → src/function.js} +0 -0
- /package/{hash → src/hash}/rabin-gf2-polynomial.js +0 -0
- /package/{hash → src/hash}/rabin-uncached.js +0 -0
- /package/{hash → src/hash}/sha256.js +0 -0
- /package/{hash → src/hash}/sha256.node.js +0 -0
- /package/{indexeddb.js → src/indexeddb.js} +0 -0
- /package/{indexeddbV2.js → src/indexeddbV2.js} +0 -0
- /package/{iterator.js → src/iterator.js} +0 -0
- /package/{json.js → src/json.js} +0 -0
- /package/{list.js → src/list.js} +0 -0
- /package/{logging.common.js → src/logging.common.js} +0 -0
- /package/{logging.js → src/logging.js} +0 -0
- /package/{logging.node.js → src/logging.node.js} +0 -0
- /package/{map.js → src/map.js} +0 -0
- /package/{math.js → src/math.js} +0 -0
- /package/{metric.js → src/metric.js} +0 -0
- /package/{mutex.js → src/mutex.js} +0 -0
- /package/{number.js → src/number.js} +0 -0
- /package/{object.js → src/object.js} +0 -0
- /package/{observable.js → src/observable.js} +0 -0
- /package/{pair.js → src/pair.js} +0 -0
- /package/{performance.js → src/performance.js} +0 -0
- /package/{performance.node.js → src/performance.node.js} +0 -0
- /package/{pledge.js → src/pledge.js} +0 -0
- /package/{prng → src/prng}/Mt19937.js +0 -0
- /package/{prng → src/prng}/Xoroshiro128plus.js +0 -0
- /package/{prng → src/prng}/Xorshift32.js +0 -0
- /package/{prng.js → src/prng.js} +0 -0
- /package/{promise.js → src/promise.js} +0 -0
- /package/{queue.js → src/queue.js} +0 -0
- /package/{random.js → src/random.js} +0 -0
- /package/{set.js → src/set.js} +0 -0
- /package/{sort.js → src/sort.js} +0 -0
- /package/{statistics.js → src/statistics.js} +0 -0
- /package/{storage.js → src/storage.js} +0 -0
- /package/{symbol.js → src/symbol.js} +0 -0
- /package/{time.js → src/time.js} +0 -0
- /package/{trait → src/trait}/equality.js +0 -0
- /package/{trait → src/trait}/fingerprint.js +0 -0
- /package/{trait → src/trait}/traits.js +0 -0
- /package/{tree.js → src/tree.js} +0 -0
- /package/{url.js → src/url.js} +0 -0
- /package/{webcrypto.deno.js → src/webcrypto.deno.js} +0 -0
- /package/{webcrypto.js → src/webcrypto.js} +0 -0
- /package/{webcrypto.node.js → src/webcrypto.node.js} +0 -0
- /package/{webcrypto.react-native.js → src/webcrypto.react-native.js} +0 -0
- /package/{websocket.js → src/websocket.js} +0 -0
- /package/{broadcastchannel.d.ts → types/broadcastchannel.d.ts} +0 -0
- /package/{buffer.d.ts → types/buffer.d.ts} +0 -0
- /package/{cache.d.ts → types/cache.d.ts} +0 -0
- /package/{component.d.ts → types/component.d.ts} +0 -0
- /package/{conditions.d.ts → types/conditions.d.ts} +0 -0
- /package/{decoding.d.ts → types/decoding.d.ts} +0 -0
- /package/{diff.d.ts → types/diff.d.ts} +0 -0
- /package/{dist → types}/dom.d.ts +0 -0
- /package/{dist → types}/encoding.d.ts +0 -0
- /package/{dist → types}/error.d.ts +0 -0
- /package/{dist → types}/eventloop.d.ts +0 -0
- /package/{dist → types}/indexeddb.d.ts +0 -0
- /package/{dist → types}/indexeddbV2.d.ts +0 -0
- /package/{dist → types}/iterator.d.ts +0 -0
- /package/{dist → types}/json.d.ts +0 -0
- /package/{dist → types}/list.d.ts +0 -0
- /package/{dist → types}/logging.common.d.ts +0 -0
- /package/{dist → types}/logging.d.ts +0 -0
- /package/{dist → types}/logging.node.d.ts +0 -0
- /package/{dist → types}/map.d.ts +0 -0
- /package/{dist → types}/math.d.ts +0 -0
- /package/{dist → types}/metric.d.ts +0 -0
- /package/{dist → types}/mutex.d.ts +0 -0
- /package/{dist → types}/object.d.ts +0 -0
- /package/{dist → types}/observable.d.ts +0 -0
- /package/{dist → types}/pair.d.ts +0 -0
- /package/{dist → types}/performance.d.ts +0 -0
- /package/{dist → types}/performance.node.d.ts +0 -0
- /package/{dist → types}/pledge.d.ts +0 -0
- /package/{dist → types}/prng.d.ts +0 -0
- /package/{dist → types}/promise.d.ts +0 -0
- /package/{dist → types}/queue.d.ts +0 -0
- /package/{dist → types}/random.d.ts +0 -0
- /package/{dist → types}/set.d.ts +0 -0
- /package/{dist → types}/sort.d.ts +0 -0
- /package/{dist → types}/statistics.d.ts +0 -0
- /package/{dist → types}/storage.d.ts +0 -0
- /package/{dist → types}/symbol.d.ts +0 -0
- /package/{dist → types}/time.d.ts +0 -0
- /package/{dist → types}/tree.d.ts +0 -0
- /package/{dist → types}/url.d.ts +0 -0
- /package/{dist → types}/webcrypto.d.ts +0 -0
- /package/{dist → types}/webcrypto.deno.d.ts +0 -0
- /package/{dist → types}/webcrypto.node.d.ts +0 -0
- /package/{dist → types}/webcrypto.react-native.d.ts +0 -0
- /package/{dist → types}/websocket.d.ts +0 -0
|
@@ -37,18 +37,14 @@ import * as prng from '../prng.js'
|
|
|
37
37
|
/**
|
|
38
38
|
* @type {s.Schema<Attribution>}
|
|
39
39
|
*/
|
|
40
|
-
export const $attribution = s.$object({
|
|
40
|
+
export const $attribution = /* @__PURE__ */(() => s.$object({
|
|
41
41
|
insert: s.$array(s.$string).optional,
|
|
42
42
|
insertAt: s.$number.optional,
|
|
43
43
|
delete: s.$array(s.$string).optional,
|
|
44
44
|
deleteAt: s.$number.optional,
|
|
45
45
|
format: s.$record(s.$string, s.$array(s.$string)).optional,
|
|
46
46
|
formatAt: s.$number.optional
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @typedef {s.Unwrap<$anyOp>} DeltaOps
|
|
51
|
-
*/
|
|
47
|
+
}))()
|
|
52
48
|
|
|
53
49
|
/**
|
|
54
50
|
* @typedef {{ [key: string]: any }} FormattingAttributes
|
|
@@ -76,7 +72,7 @@ export const $attribution = s.$object({
|
|
|
76
72
|
*/
|
|
77
73
|
|
|
78
74
|
/**
|
|
79
|
-
* @typedef {
|
|
75
|
+
* @typedef {SetAttrOp<any>|DeleteAttrOp<any>|ModifyAttrOp} AttrOpAny
|
|
80
76
|
*/
|
|
81
77
|
|
|
82
78
|
/**
|
|
@@ -86,11 +82,11 @@ export const $attribution = s.$object({
|
|
|
86
82
|
/**
|
|
87
83
|
* @type {s.Schema<DeltaAttrOpJSON>}
|
|
88
84
|
*/
|
|
89
|
-
export const $deltaMapChangeJson = s.$union(
|
|
85
|
+
export const $deltaMapChangeJson = /* @__PURE__ */(() => s.$union(
|
|
90
86
|
s.$object({ type: s.$literal('insert'), value: s.$any, prevValue: s.$any.optional, attribution: $attribution.optional }),
|
|
91
87
|
s.$object({ type: s.$literal('modify'), value: s.$any }),
|
|
92
88
|
s.$object({ type: s.$literal('delete'), prevValue: s.$any.optional, attribution: $attribution.optional })
|
|
93
|
-
)
|
|
89
|
+
))()
|
|
94
90
|
|
|
95
91
|
/**
|
|
96
92
|
* @template {{[key:string]: any} | null} Attrs
|
|
@@ -131,6 +127,10 @@ export class TextOp extends list.ListNode {
|
|
|
131
127
|
this._fingerprint = null
|
|
132
128
|
}
|
|
133
129
|
|
|
130
|
+
get $type () {
|
|
131
|
+
return $textOp
|
|
132
|
+
}
|
|
133
|
+
|
|
134
134
|
/**
|
|
135
135
|
* @param {string} newVal
|
|
136
136
|
*/
|
|
@@ -196,7 +196,7 @@ export class TextOp extends list.ListNode {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* @template {
|
|
199
|
+
* @template {any} ArrayContent
|
|
200
200
|
*/
|
|
201
201
|
export class InsertOp extends list.ListNode {
|
|
202
202
|
/**
|
|
@@ -227,6 +227,10 @@ export class InsertOp extends list.ListNode {
|
|
|
227
227
|
this._fingerprint = null
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
get $type () {
|
|
231
|
+
return $insertOp
|
|
232
|
+
}
|
|
233
|
+
|
|
230
234
|
/**
|
|
231
235
|
* @param {ArrayContent} newVal
|
|
232
236
|
*/
|
|
@@ -271,7 +275,7 @@ export class InsertOp extends list.ListNode {
|
|
|
271
275
|
encoding.writeVarUint(encoder, 1) // insertOp type: 1
|
|
272
276
|
encoding.writeVarUint(encoder, this.insert.length)
|
|
273
277
|
this.insert.forEach(ins => {
|
|
274
|
-
encoding.writeVarString(encoder, fingerprintTrait.fingerprint(ins))
|
|
278
|
+
encoding.writeVarString(encoder, fingerprintTrait.fingerprint(/** @type {any} */ (ins)))
|
|
275
279
|
})
|
|
276
280
|
encoding.writeAny(encoder, this.format)
|
|
277
281
|
})))
|
|
@@ -313,8 +317,7 @@ export class InsertOp extends list.ListNode {
|
|
|
313
317
|
}
|
|
314
318
|
|
|
315
319
|
/**
|
|
316
|
-
* @template {
|
|
317
|
-
* @template {string} [Text=never]
|
|
320
|
+
* @template {DeltaConf} [DConf={}]
|
|
318
321
|
*/
|
|
319
322
|
export class DeleteOp extends list.ListNode {
|
|
320
323
|
/**
|
|
@@ -324,7 +327,7 @@ export class DeleteOp extends list.ListNode {
|
|
|
324
327
|
super()
|
|
325
328
|
this.delete = len
|
|
326
329
|
/**
|
|
327
|
-
* @type {
|
|
330
|
+
* @type {Delta<DConf>?}
|
|
328
331
|
*/
|
|
329
332
|
this.prevValue = null
|
|
330
333
|
/**
|
|
@@ -333,6 +336,10 @@ export class DeleteOp extends list.ListNode {
|
|
|
333
336
|
this._fingerprint = null
|
|
334
337
|
}
|
|
335
338
|
|
|
339
|
+
get $type () {
|
|
340
|
+
return $deleteOp
|
|
341
|
+
}
|
|
342
|
+
|
|
336
343
|
/**
|
|
337
344
|
* @return {'delete'}
|
|
338
345
|
*/
|
|
@@ -358,7 +365,7 @@ export class DeleteOp extends list.ListNode {
|
|
|
358
365
|
* @param {number} len
|
|
359
366
|
*/
|
|
360
367
|
_splice (_offset, len) {
|
|
361
|
-
this.prevValue = /** @type {any} */ (this.prevValue
|
|
368
|
+
this.prevValue = /** @type {any} */ (this.prevValue ? slice(this.prevValue, _offset, len) : null)
|
|
362
369
|
this._fingerprint = null
|
|
363
370
|
this.delete -= len
|
|
364
371
|
return this
|
|
@@ -378,6 +385,11 @@ export class DeleteOp extends list.ListNode {
|
|
|
378
385
|
return this.delete === other.delete
|
|
379
386
|
}
|
|
380
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @param {number} start
|
|
390
|
+
* @param {number} end
|
|
391
|
+
* @return {DeleteOp}
|
|
392
|
+
*/
|
|
381
393
|
clone (start = 0, end = this.delete) {
|
|
382
394
|
return new DeleteOp(end - start)
|
|
383
395
|
}
|
|
@@ -412,6 +424,10 @@ export class RetainOp extends list.ListNode {
|
|
|
412
424
|
this._fingerprint = null
|
|
413
425
|
}
|
|
414
426
|
|
|
427
|
+
get $type () {
|
|
428
|
+
return $retainOp
|
|
429
|
+
}
|
|
430
|
+
|
|
415
431
|
/**
|
|
416
432
|
* @return {'retain'}
|
|
417
433
|
*/
|
|
@@ -467,7 +483,7 @@ export class RetainOp extends list.ListNode {
|
|
|
467
483
|
/**
|
|
468
484
|
* Delta that can be applied on a YType Embed
|
|
469
485
|
*
|
|
470
|
-
* @template {
|
|
486
|
+
* @template {Delta} [DTypes=DeltaAny]
|
|
471
487
|
*/
|
|
472
488
|
export class ModifyOp extends list.ListNode {
|
|
473
489
|
/**
|
|
@@ -498,6 +514,10 @@ export class ModifyOp extends list.ListNode {
|
|
|
498
514
|
this._fingerprint = null
|
|
499
515
|
}
|
|
500
516
|
|
|
517
|
+
get $type () {
|
|
518
|
+
return $modifyOp
|
|
519
|
+
}
|
|
520
|
+
|
|
501
521
|
/**
|
|
502
522
|
* @return {'modify'}
|
|
503
523
|
*/
|
|
@@ -568,10 +588,10 @@ export class ModifyOp extends list.ListNode {
|
|
|
568
588
|
}
|
|
569
589
|
|
|
570
590
|
/**
|
|
571
|
-
* @template {
|
|
591
|
+
* @template {any} [V=any]
|
|
572
592
|
* @template {string|number} [K=any]
|
|
573
593
|
*/
|
|
574
|
-
export class
|
|
594
|
+
export class SetAttrOp {
|
|
575
595
|
/**
|
|
576
596
|
* @param {K} key
|
|
577
597
|
* @param {V} value
|
|
@@ -605,6 +625,10 @@ export class AttrInsertOp {
|
|
|
605
625
|
this._fingerprint = null
|
|
606
626
|
}
|
|
607
627
|
|
|
628
|
+
get $type () {
|
|
629
|
+
return $setAttrOp
|
|
630
|
+
}
|
|
631
|
+
|
|
608
632
|
/**
|
|
609
633
|
* @return {'insert'}
|
|
610
634
|
*/
|
|
@@ -635,7 +659,7 @@ export class AttrInsertOp {
|
|
|
635
659
|
encoding.writeVarString(encoder, this.value.fingerprint)
|
|
636
660
|
} else {
|
|
637
661
|
encoding.writeUint8(encoder, 1)
|
|
638
|
-
encoding.writeAny(encoder, this.value)
|
|
662
|
+
encoding.writeAny(encoder, /** @type {any} */ (this.value))
|
|
639
663
|
}
|
|
640
664
|
})))
|
|
641
665
|
}
|
|
@@ -651,25 +675,25 @@ export class AttrInsertOp {
|
|
|
651
675
|
}
|
|
652
676
|
|
|
653
677
|
/**
|
|
654
|
-
* @param {
|
|
678
|
+
* @param {SetAttrOp<V>} other
|
|
655
679
|
*/
|
|
656
680
|
[equalityTrait.EqualityTraitSymbol] (other) {
|
|
657
681
|
return this.key === other.key && fun.equalityDeep(this.value, other.value) && fun.equalityDeep(this.attribution, other.attribution)
|
|
658
682
|
}
|
|
659
683
|
|
|
660
684
|
/**
|
|
661
|
-
* @return {
|
|
685
|
+
* @return {SetAttrOp<V,K>}
|
|
662
686
|
*/
|
|
663
687
|
clone () {
|
|
664
|
-
return new
|
|
688
|
+
return new SetAttrOp(this.key, _markMaybeDeltaAsDone(this.value), _markMaybeDeltaAsDone(this.prevValue), _cloneAttrs(this.attribution))
|
|
665
689
|
}
|
|
666
690
|
}
|
|
667
691
|
|
|
668
692
|
/**
|
|
669
|
-
* @template V
|
|
670
|
-
* @template {string|number} [K=string]
|
|
693
|
+
* @template [V=any]
|
|
694
|
+
* @template {string|number} [K=string|number]
|
|
671
695
|
*/
|
|
672
|
-
export class
|
|
696
|
+
export class DeleteAttrOp {
|
|
673
697
|
/**
|
|
674
698
|
* @param {K} key
|
|
675
699
|
* @param {V|undefined} prevValue
|
|
@@ -691,13 +715,17 @@ export class AttrDeleteOp {
|
|
|
691
715
|
this._fingerprint = null
|
|
692
716
|
}
|
|
693
717
|
|
|
694
|
-
get
|
|
718
|
+
get $type () {
|
|
719
|
+
return $deleteAttrOp
|
|
720
|
+
}
|
|
695
721
|
|
|
696
722
|
/**
|
|
697
723
|
* @type {'delete'}
|
|
698
724
|
*/
|
|
699
725
|
get type () { return 'delete' }
|
|
700
726
|
|
|
727
|
+
get value () { return undefined }
|
|
728
|
+
|
|
701
729
|
get fingerprint () {
|
|
702
730
|
return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
|
|
703
731
|
encoding.writeVarUint(encoder, 6) // map delete type: 6
|
|
@@ -716,14 +744,14 @@ export class AttrDeleteOp {
|
|
|
716
744
|
}
|
|
717
745
|
|
|
718
746
|
/**
|
|
719
|
-
* @param {
|
|
747
|
+
* @param {DeleteAttrOp<V>} other
|
|
720
748
|
*/
|
|
721
749
|
[equalityTrait.EqualityTraitSymbol] (other) {
|
|
722
750
|
return this.key === other.key && fun.equalityDeep(this.attribution, other.attribution)
|
|
723
751
|
}
|
|
724
752
|
|
|
725
753
|
clone () {
|
|
726
|
-
return new
|
|
754
|
+
return new DeleteAttrOp(this.key, _markMaybeDeltaAsDone(this.prevValue), _cloneAttrs(this.attribution))
|
|
727
755
|
}
|
|
728
756
|
}
|
|
729
757
|
|
|
@@ -731,7 +759,7 @@ export class AttrDeleteOp {
|
|
|
731
759
|
* @template {DeltaAny} [Modifier=DeltaAny]
|
|
732
760
|
* @template {string|number} [K=string]
|
|
733
761
|
*/
|
|
734
|
-
export class
|
|
762
|
+
export class ModifyAttrOp {
|
|
735
763
|
/**
|
|
736
764
|
* @param {K} key
|
|
737
765
|
* @param {Modifier} delta
|
|
@@ -753,6 +781,10 @@ export class AttrModifyOp {
|
|
|
753
781
|
this._fingerprint = null
|
|
754
782
|
}
|
|
755
783
|
|
|
784
|
+
get $type () {
|
|
785
|
+
return $modifyAttrOp
|
|
786
|
+
}
|
|
787
|
+
|
|
756
788
|
/**
|
|
757
789
|
* @type {'modify'}
|
|
758
790
|
*/
|
|
@@ -790,78 +822,59 @@ export class AttrModifyOp {
|
|
|
790
822
|
}
|
|
791
823
|
|
|
792
824
|
/**
|
|
793
|
-
* @param {
|
|
825
|
+
* @param {ModifyAttrOp<Modifier>} other
|
|
794
826
|
*/
|
|
795
827
|
[equalityTrait.EqualityTraitSymbol] (other) {
|
|
796
828
|
return this.key === other.key && this.value[equalityTrait.EqualityTraitSymbol](other.value)
|
|
797
829
|
}
|
|
798
830
|
|
|
799
831
|
/**
|
|
800
|
-
* @return {
|
|
832
|
+
* @return {ModifyAttrOp<Modifier,K>}
|
|
801
833
|
*/
|
|
802
834
|
clone () {
|
|
803
|
-
return new
|
|
835
|
+
return new ModifyAttrOp(this.key, /** @type {Modifier} */ (this.value.done()))
|
|
804
836
|
}
|
|
805
837
|
}
|
|
806
838
|
|
|
807
|
-
/**
|
|
808
|
-
|
|
809
|
-
*/
|
|
810
|
-
export const $deleteOp =
|
|
839
|
+
export const $insertOp = /** @type {s.Schema<InsertOp<any>>} */ (s.$type('insertOp'))
|
|
840
|
+
export const $modifyOp = /** @type {s.Schema<ModifyOp>} */ (s.$type('modifyOp'))
|
|
841
|
+
export const $textOp = /** @type {s.Schema<TextOp>} */ (s.$type('textOp'))
|
|
842
|
+
export const $deleteOp = /** @type {s.Schema<DeleteOp<any>>} */ (s.$type('deleteOp'))
|
|
843
|
+
export const $retainOp = /** @type {s.Schema<RetainOp>} */ (s.$type('retainOp'))
|
|
844
|
+
export const $anyOp = s.$union($insertOp, $deleteOp, $textOp, $modifyOp)
|
|
811
845
|
|
|
812
|
-
/**
|
|
813
|
-
|
|
814
|
-
*/
|
|
815
|
-
export const $
|
|
846
|
+
export const $setAttrOp = /** @type {s.Schema<SetAttrOp<any>>} */ (s.$type('setAttrOp'))
|
|
847
|
+
export const $modifyAttrOp = /** @type {s.Schema<ModifyAttrOp<any,string|number>>} */ (s.$type('modifyAttrOp'))
|
|
848
|
+
export const $deleteAttrOp = /** @type {s.Schema<DeleteAttrOp<any,string|number>>} */ (s.$type('deleteAttrOp'))
|
|
849
|
+
export const $anyAttrOp = s.$union($setAttrOp, $deleteAttrOp, $modifyAttrOp)
|
|
816
850
|
|
|
817
851
|
/**
|
|
818
852
|
* @template {fingerprintTrait.Fingerprintable} Content
|
|
819
853
|
* @param {s.Schema<Content>} $content
|
|
820
|
-
* @return {s.Schema<
|
|
821
|
-
*/
|
|
822
|
-
export const $insertOpWith = $content => s.$custom(o =>
|
|
823
|
-
o != null && (
|
|
824
|
-
(o.constructor === AttrInsertOp && $content.check(/** @type {AttrInsertOp<Content>} */ (o).value)) ||
|
|
825
|
-
(o.constructor === InsertOp && /** @type {InsertOp<Content>} */ (o).insert.every(ins => $content.check(ins)))
|
|
826
|
-
)
|
|
827
|
-
)
|
|
828
|
-
|
|
829
|
-
/**
|
|
830
|
-
* @type {s.Schema<TextOp>}
|
|
854
|
+
* @return {s.Schema<SetAttrOp<Content>>}
|
|
831
855
|
*/
|
|
832
|
-
export const $
|
|
856
|
+
export const $setAttrOpWith = $content => s.$custom(o => $setAttrOp.check(o) && $content.check(o.value))
|
|
833
857
|
|
|
834
858
|
/**
|
|
835
|
-
* @
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* @type {s.Schema<AttrModifyOp | ModifyOp>}
|
|
859
|
+
* @template {fingerprintTrait.Fingerprintable} Content
|
|
860
|
+
* @param {s.Schema<Content>} $content
|
|
861
|
+
* @return {s.Schema<InsertOp<Content>>}
|
|
841
862
|
*/
|
|
842
|
-
export const $
|
|
863
|
+
export const $insertOpWith = $content => s.$custom(o => $insertOp.check(o) && $content.check(o.insert.every(ins => $content.check(ins))))
|
|
843
864
|
|
|
844
865
|
/**
|
|
845
866
|
* @template {DeltaAny} Modify
|
|
846
867
|
* @param {s.Schema<Modify>} $content
|
|
847
|
-
* @return {s.Schema<
|
|
868
|
+
* @return {s.Schema<ModifyOp<Modify>>}
|
|
848
869
|
*/
|
|
849
|
-
export const $modifyOpWith = $content => s.$custom(o =>
|
|
850
|
-
o != null && (
|
|
851
|
-
(o.constructor === AttrModifyOp && $content.check(/** @type {AttrModifyOp<Modify>} */ (o).value)) ||
|
|
852
|
-
(o.constructor === ModifyOp && $content.check(/** @type {ModifyOp<Modify>} */ (o).value))
|
|
853
|
-
)
|
|
854
|
-
)
|
|
855
|
-
|
|
856
|
-
export const $anyOp = s.$union($insertOp, $deleteOp, $textOp, $modifyOp)
|
|
870
|
+
export const $modifyOpWith = $content => s.$custom(o => $modifyOp.check(o) && $content.check(o.value))
|
|
857
871
|
|
|
858
872
|
/**
|
|
859
|
-
* @template {
|
|
860
|
-
* @
|
|
861
|
-
* @
|
|
862
|
-
* ? never
|
|
863
|
-
* : (Array<(Extract<C1 | C2,Array<any>> extends Array<infer AC1> ? (unknown extends AC1 ? never : AC1) : never)>)} MergeListArrays
|
|
873
|
+
* @template {DeltaAny} Modify
|
|
874
|
+
* @param {s.Schema<Modify>} $content
|
|
875
|
+
* @return {s.Schema<ModifyAttrOp<Modify>>}
|
|
864
876
|
*/
|
|
877
|
+
export const $modifyAttrOpWith = $content => s.$custom(o => $modifyAttrOp.check(o) && $content.check(/** @type {ModifyAttrOp<Modify>} */ (o).value))
|
|
865
878
|
|
|
866
879
|
/**
|
|
867
880
|
* @template {{[Key in string|number]: any}} Attrs
|
|
@@ -877,40 +890,104 @@ export const $anyOp = s.$union($insertOp, $deleteOp, $textOp, $modifyOp)
|
|
|
877
890
|
*/
|
|
878
891
|
|
|
879
892
|
/**
|
|
880
|
-
* @
|
|
881
|
-
* @typedef {0 extends (1 & X) ? null : X} _AnyToNull
|
|
893
|
+
* @typedef {Delta<any>} DeltaAny
|
|
882
894
|
*/
|
|
883
895
|
|
|
884
896
|
/**
|
|
885
|
-
* @
|
|
886
|
-
* @typedef {_AnyToNull<Schema> extends null ? Delta<any,{[key:string|number]:any},any,string> : (Schema extends s.Schema<infer D> ? D : never)} AllowedDeltaFromSchema
|
|
897
|
+
* @typedef {DeltaBuilder<any>} DeltaBuilderAny
|
|
887
898
|
*/
|
|
888
899
|
|
|
889
900
|
/**
|
|
890
|
-
* @typedef {
|
|
901
|
+
* @typedef {object} DeltaConf
|
|
902
|
+
* @property {string} [DeltaConf.name]
|
|
903
|
+
* @property {fingerprintTrait.Fingerprintable} [DeltaConf.children=never]
|
|
904
|
+
* @property {boolean} [DeltaConf.text=never]
|
|
905
|
+
* @property {{[K:string|number]:fingerprintTrait.Fingerprintable}} [DeltaConf.attrs={}]
|
|
906
|
+
* @property {boolean} [DeltaConf.fixed=never]
|
|
907
|
+
* @property {boolean} [DeltaConf.recursiveChildren=false]
|
|
908
|
+
* @property {boolean} [DeltaConf.recursiveAttrs=false]
|
|
891
909
|
*/
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* @template {DeltaConf} DConf
|
|
913
|
+
* @typedef {DConf extends {name:infer Name} ? (unknown extends Name ? any : (Exclude<Name,undefined>)) : any} DeltaConfGetName
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* @template {DeltaConf} DConf
|
|
918
|
+
* @typedef {(DConf extends {children:infer Children} ? (unknown extends Children ? any : Children) : never) | (DConf extends {recursiveChildren:true} ? Delta<DConf> : never)} DeltaConfGetChildren
|
|
919
|
+
*/
|
|
920
|
+
|
|
892
921
|
/**
|
|
893
|
-
* @
|
|
922
|
+
* @template {DeltaConf} DConf
|
|
923
|
+
* @typedef {DConf extends {fixed:true} ? DeltaConfGetChildren<DConf> : any } DeltaConfGetAllowedChildren
|
|
894
924
|
*/
|
|
895
925
|
|
|
896
926
|
/**
|
|
897
|
-
* @template {
|
|
898
|
-
* @
|
|
899
|
-
* @template {fingerprintTrait.Fingerprintable} [Children=never]
|
|
900
|
-
* @template {string} [Text=never]
|
|
901
|
-
* @template {s.Schema<Delta<any,any,any,any,any>>|null} [Schema=any]
|
|
927
|
+
* @template {DeltaConf} DConf
|
|
928
|
+
* @typedef {0 extends (1 & DConf) ? string : (DConf extends {text:true} ? string : never)} DeltaConfGetText
|
|
902
929
|
*/
|
|
903
|
-
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* @template {DeltaConf} DConf
|
|
933
|
+
* @typedef {import('../ts.js').TypeIsAny<DConf, {[K:string|number]:any}, (DConf extends {attrs:infer Attrs} ? (Attrs extends undefined ? {} : Attrs) : {})>} DeltaConfGetAttrs
|
|
934
|
+
*/
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* @template {DeltaConf} DConf
|
|
938
|
+
* @typedef {DConf extends {fixed:true} ? DeltaConfGetAttrs<DConf> : {[K:string|number]:any}} DeltaConfGetAllowedAttrs
|
|
939
|
+
*/
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* @template {DeltaConf} DConf
|
|
943
|
+
* @typedef {0 extends (1 & DConf) ? true : (DConf extends { fixed: true } ? true : false)} DeltaConfGetFixed
|
|
944
|
+
*/
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* @template {DeltaConf} DConf
|
|
948
|
+
* @typedef {DConf extends {recursiveChildren:true} ? true : false} DeltaConfGetRecursiveChildren
|
|
949
|
+
*/
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* @template {DeltaConf} DConf
|
|
953
|
+
* @typedef {DConf extends {recursiveAttrs:true} ? true : false} DeltaConfigGetRecursiveAttrs
|
|
954
|
+
*/
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Transform Delta(Builder) to a normal delta.
|
|
958
|
+
*
|
|
959
|
+
* @template V
|
|
960
|
+
* @typedef {V extends never ? never : (import('../ts.js').TypeIsAny<V,any,V extends Delta<infer DConf> ? Delta<DConf> : V>)} _SanifyDelta
|
|
961
|
+
*/
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* @template {DeltaConf} DConf
|
|
965
|
+
* @typedef {import('../ts.js').Prettify<{[K in keyof DConf]: K extends 'attrs' ? import('../ts.js').Prettify<{ [KA in keyof DConf[K]]: _SanifyDelta<DConf[K][KA]> },1> : (K extends 'children' ? _SanifyDelta<DConf[K]> : DConf[K]) }, 1>} PrettifyDeltaConf
|
|
966
|
+
*/
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* @template {DeltaConf} D1
|
|
970
|
+
* @template {DeltaConf} D2
|
|
971
|
+
* @typedef {import('../ts.js').TypeIsAny<D1, any, PrettifyDeltaConf<{[K in (keyof D1|keyof D2)]: K extends keyof D2 ? D2[K] : (K extends keyof D1 ? D1[K] : never)}>>} DeltaConfOverwrite
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* @template {string} Name
|
|
976
|
+
* @template {{[K in string|number]:any}} Attrs
|
|
977
|
+
* @template Children
|
|
978
|
+
* @template {boolean} Text
|
|
979
|
+
*/
|
|
980
|
+
class DeltaData {
|
|
904
981
|
/**
|
|
905
|
-
* @param {
|
|
906
|
-
* @param {Schema}
|
|
982
|
+
* @param {string?} name
|
|
983
|
+
* @param {s.Schema<Delta<any>>?} $schema
|
|
907
984
|
*/
|
|
908
985
|
constructor (name, $schema) {
|
|
909
|
-
this.name =
|
|
910
|
-
this.$schema = $schema
|
|
986
|
+
this.name = /** @type {Name} */ (name)
|
|
987
|
+
this.$schema = $schema
|
|
911
988
|
/**
|
|
912
|
-
* @type {{ [K in keyof Attrs]?: K extends string|number ? (
|
|
913
|
-
*
|
|
989
|
+
* @type {{ [K in keyof Attrs]?: K extends string|number ? (SetAttrOp<Attrs[K],K>|DeleteAttrOp<Attrs[K],K>|(Attrs[K] extends never ? never : (Attrs[K] extends Delta ? ModifyAttrOp<Extract<Attrs[K],Delta>,K> : never))) : never }
|
|
990
|
+
* & { [Symbol.iterator]: () => Iterator<{ [K in keyof Attrs]: K extends string|number ? (SetAttrOp<Attrs[K],K>|DeleteAttrOp<Attrs[K],K>|(Attrs[K] extends never ? never : (Delta extends Attrs[K] ? ModifyAttrOp<Extract<Attrs[K],Delta>,K> : never))) : never }[keyof Attrs]> }
|
|
914
991
|
* }
|
|
915
992
|
*/
|
|
916
993
|
this.attrs = /** @type {any} */ ({
|
|
@@ -923,11 +1000,8 @@ export class Delta {
|
|
|
923
1000
|
|
|
924
1001
|
/**
|
|
925
1002
|
* @type {list.List<
|
|
926
|
-
* RetainOp
|
|
927
|
-
* | DeleteOp
|
|
928
|
-
* | (Text extends never ? never : TextOp)
|
|
929
|
-
* | (Children extends never ? never : InsertOp<Children>)
|
|
930
|
-
* | (Delta extends Children ? ModifyOp<Extract<Children,Delta<any,any,any,any,any>>> : never)
|
|
1003
|
+
* | (Text extends true ? (RetainOp|TextOp|DeleteOp<any>) : never)
|
|
1004
|
+
* | (RetainOp|InsertOp<Children>|DeleteOp<any>|(Delta extends Children ? ModifyOp<Extract<Children,Delta>> : never))
|
|
931
1005
|
* >}
|
|
932
1006
|
*/
|
|
933
1007
|
this.children = /** @type {any} */ (list.create())
|
|
@@ -942,7 +1016,19 @@ export class Delta {
|
|
|
942
1016
|
this._fingerprint = null
|
|
943
1017
|
this.isDone = false
|
|
944
1018
|
}
|
|
1019
|
+
}
|
|
945
1020
|
|
|
1021
|
+
/**
|
|
1022
|
+
* @template {DeltaConf} [DConf={}]
|
|
1023
|
+
* @extends {DeltaData<
|
|
1024
|
+
* DeltaConfGetName<DConf>,
|
|
1025
|
+
* DeltaConfGetAttrs<DConf>,
|
|
1026
|
+
* DeltaConfGetChildren<DConf>,
|
|
1027
|
+
* DConf extends {text:true} ? true : false
|
|
1028
|
+
* >}
|
|
1029
|
+
*/
|
|
1030
|
+
export class Delta extends DeltaData {
|
|
1031
|
+
get $type () { return $deltaAny }
|
|
946
1032
|
/**
|
|
947
1033
|
* @type {string}
|
|
948
1034
|
*/
|
|
@@ -1014,7 +1100,7 @@ export class Delta {
|
|
|
1014
1100
|
}
|
|
1015
1101
|
|
|
1016
1102
|
/**
|
|
1017
|
-
* @param {Delta<any
|
|
1103
|
+
* @param {Delta<any>} other
|
|
1018
1104
|
* @return {boolean}
|
|
1019
1105
|
*/
|
|
1020
1106
|
equals (other) {
|
|
@@ -1031,66 +1117,27 @@ export class Delta {
|
|
|
1031
1117
|
return this.name === other.name && fun.equalityDeep(this.attrs, other.attrs) && fun.equalityDeep(this.children, other.children) && this.childCnt === other.childCnt
|
|
1032
1118
|
}
|
|
1033
1119
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
// copy attrs
|
|
1050
|
-
for (const op of this.attrs) {
|
|
1051
|
-
cpy.attrs[op.key] = /** @type {any} */ (op.clone())
|
|
1052
|
-
}
|
|
1053
|
-
// copy children
|
|
1054
|
-
const slicedLen = end - start
|
|
1055
|
-
let remainingLen = slicedLen
|
|
1056
|
-
/**
|
|
1057
|
-
* @type {ChildrenOpAny?}
|
|
1058
|
-
*/
|
|
1059
|
-
let currNode = this.children.start
|
|
1060
|
-
let currNodeOffset = 0
|
|
1061
|
-
while (start > 0 && currNode != null) {
|
|
1062
|
-
if (currNode.length <= start) {
|
|
1063
|
-
start -= currNode.length
|
|
1064
|
-
currNode = currNode.next
|
|
1065
|
-
} else {
|
|
1066
|
-
currNodeOffset = start
|
|
1067
|
-
start = 0
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
if (currNodeOffset > 0 && currNode) {
|
|
1071
|
-
const ncpy = currNode.clone(currNodeOffset, currNodeOffset + math.min(remainingLen, currNode.length - currNodeOffset))
|
|
1072
|
-
list.pushEnd(cpy.children, ncpy)
|
|
1073
|
-
remainingLen -= ncpy.length
|
|
1074
|
-
currNode = currNode.next
|
|
1075
|
-
}
|
|
1076
|
-
while (currNode != null && currNode.length <= remainingLen) {
|
|
1077
|
-
list.pushEnd(cpy.children, currNode.clone())
|
|
1078
|
-
currNode = currNode.next
|
|
1079
|
-
}
|
|
1080
|
-
if (currNode != null && remainingLen > 0) {
|
|
1081
|
-
list.pushEnd(cpy.children, currNode.clone(0, remainingLen))
|
|
1082
|
-
}
|
|
1083
|
-
cpy.childCnt = slicedLen - remainingLen
|
|
1084
|
-
// @ts-ignore
|
|
1085
|
-
return cpy
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1120
|
+
// toString () {
|
|
1121
|
+
// /**
|
|
1122
|
+
// * @type {Array<[string|number,string]>}
|
|
1123
|
+
// */
|
|
1124
|
+
// const attrs = []
|
|
1125
|
+
// for (const attr of this.attrs) {
|
|
1126
|
+
// attrs.push([attr.key, $deleteAttrOp.check(attr) ? 'delete' : attr.type + ' ' + (attr.value?.toString() ?? attr.value)])
|
|
1127
|
+
// }
|
|
1128
|
+
// attrs.sort((a, b) => a[0].toString() < b[0].toString() ? -1 : 1)
|
|
1129
|
+
// const attrsString = attrs.map(attr => `${attr[0]} = ${attr[1]}`).join(', ')
|
|
1130
|
+
// if (this.childCnt === 0) return `<${this.name ?? ''} ${attrsString}/>`
|
|
1131
|
+
// this.children.toArray() drnt
|
|
1132
|
+
// return '<>'
|
|
1133
|
+
// }
|
|
1134
|
+
//
|
|
1088
1135
|
/**
|
|
1089
1136
|
* Mark this delta as done and perform some cleanup (e.g. remove appended retains without
|
|
1090
1137
|
* formats&attributions). In the future, there might be additional merge operations that can be
|
|
1091
1138
|
* performed to result in smaller deltas. Set `markAsDone=false` to only perform the cleanup.
|
|
1092
1139
|
*
|
|
1093
|
-
* @return {Delta<
|
|
1140
|
+
* @return {Delta<DConf>}
|
|
1094
1141
|
*/
|
|
1095
1142
|
done (markAsDone = true) {
|
|
1096
1143
|
if (!this.isDone) {
|
|
@@ -1105,17 +1152,66 @@ export class Delta {
|
|
|
1105
1152
|
}
|
|
1106
1153
|
}
|
|
1107
1154
|
|
|
1155
|
+
/**
|
|
1156
|
+
* @template {DeltaConf} DConf
|
|
1157
|
+
* @param {Delta<DConf>} d
|
|
1158
|
+
* @param {number} start
|
|
1159
|
+
* @param {number} end
|
|
1160
|
+
* @param {ChildrenOpAny?} currNode - start slicing at this node (instead of d.children.start)
|
|
1161
|
+
* @return {DeltaBuilder<DConf>}
|
|
1162
|
+
*/
|
|
1163
|
+
export const slice = (d, start = 0, end = d.childCnt, currNode = d.children.start) => {
|
|
1164
|
+
const cpy = /** @type {DeltaAny} */ (new DeltaBuilder(d.name, d.$schema))
|
|
1165
|
+
cpy.origin = d.origin
|
|
1166
|
+
// copy attrs
|
|
1167
|
+
for (const op of d.attrs) {
|
|
1168
|
+
// @ts-ignore
|
|
1169
|
+
cpy.attrs[op.key] = /** @type {any} */ (op.clone())
|
|
1170
|
+
}
|
|
1171
|
+
// copy children
|
|
1172
|
+
const slicedLen = end - start
|
|
1173
|
+
let remainingLen = slicedLen
|
|
1174
|
+
let currNodeOffset = 0
|
|
1175
|
+
while (start > 0 && currNode != null) {
|
|
1176
|
+
if (currNode.length <= start) {
|
|
1177
|
+
start -= currNode.length
|
|
1178
|
+
currNode = currNode.next
|
|
1179
|
+
} else {
|
|
1180
|
+
currNodeOffset = start
|
|
1181
|
+
start = 0
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
if (currNodeOffset > 0 && currNode) {
|
|
1185
|
+
const ncpy = currNode.clone(currNodeOffset, currNodeOffset + math.min(remainingLen, currNode.length - currNodeOffset))
|
|
1186
|
+
list.pushEnd(cpy.children, ncpy)
|
|
1187
|
+
remainingLen -= ncpy.length
|
|
1188
|
+
currNode = currNode.next
|
|
1189
|
+
}
|
|
1190
|
+
while (currNode != null && currNode.length <= remainingLen) {
|
|
1191
|
+
list.pushEnd(cpy.children, currNode.clone())
|
|
1192
|
+
remainingLen -= currNode.length
|
|
1193
|
+
currNode = currNode.next
|
|
1194
|
+
}
|
|
1195
|
+
if (currNode != null && remainingLen > 0) {
|
|
1196
|
+
list.pushEnd(cpy.children, currNode.clone(0, remainingLen))
|
|
1197
|
+
remainingLen -= math.min(currNode.length, remainingLen)
|
|
1198
|
+
}
|
|
1199
|
+
cpy.childCnt = slicedLen - remainingLen
|
|
1200
|
+
// @ts-ignore
|
|
1201
|
+
return cpy
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1108
1204
|
/**
|
|
1109
1205
|
* @template {DeltaAny} D
|
|
1110
1206
|
* @param {D} d
|
|
1111
|
-
* @return {D extends
|
|
1207
|
+
* @return {D extends Delta<infer DConf> ? DeltaBuilder<DConf> : never}
|
|
1112
1208
|
*/
|
|
1113
|
-
export const clone = d => /** @type {any} */ (
|
|
1209
|
+
export const clone = d => /** @type {any} */ (slice(d, 0, d.childCnt))
|
|
1114
1210
|
|
|
1115
1211
|
/**
|
|
1116
1212
|
* Try merging this op with the previous op
|
|
1117
1213
|
* @param {list.List<any>} parent
|
|
1118
|
-
* @param {InsertOp<any>|RetainOp|DeleteOp
|
|
1214
|
+
* @param {InsertOp<any>|RetainOp|DeleteOp<any>|TextOp|ModifyOp<any>} op
|
|
1119
1215
|
*/
|
|
1120
1216
|
const tryMergeWithPrev = (parent, op) => {
|
|
1121
1217
|
const prevOp = op.prev
|
|
@@ -1135,7 +1231,7 @@ const tryMergeWithPrev = (parent, op) => {
|
|
|
1135
1231
|
// @ts-ignore
|
|
1136
1232
|
/** @type {RetainOp} */ (prevOp).retain += op.retain
|
|
1137
1233
|
} else if ($deleteOp.check(op)) {
|
|
1138
|
-
/** @type {DeleteOp} */ (prevOp).delete += op.delete
|
|
1234
|
+
/** @type {DeleteOp<any>} */ (prevOp).delete += op.delete
|
|
1139
1235
|
} else if ($textOp.check(op)) {
|
|
1140
1236
|
/** @type {TextOp} */ (prevOp)._updateInsert(/** @type {TextOp} */ (prevOp).insert + op.insert)
|
|
1141
1237
|
} else {
|
|
@@ -1160,17 +1256,13 @@ const modDeltaCheck = d => {
|
|
|
1160
1256
|
}
|
|
1161
1257
|
|
|
1162
1258
|
/**
|
|
1163
|
-
* @template {
|
|
1164
|
-
* @
|
|
1165
|
-
* @template {fingerprintTrait.Fingerprintable} [Children=never]
|
|
1166
|
-
* @template {string} [Text=never]
|
|
1167
|
-
* @template {s.Schema<Delta<any,any,any,any,any>>|null} [Schema=any]
|
|
1168
|
-
* @extends {Delta<NodeName,Attrs,Children,Text,Schema>}
|
|
1259
|
+
* @template {DeltaConf} [DConf={}]
|
|
1260
|
+
* @extends {Delta<DConf>}
|
|
1169
1261
|
*/
|
|
1170
1262
|
export class DeltaBuilder extends Delta {
|
|
1171
1263
|
/**
|
|
1172
|
-
* @param {
|
|
1173
|
-
* @param {Schema}
|
|
1264
|
+
* @param {string?} name
|
|
1265
|
+
* @param {s.Schema<Delta<DConf>>?} $schema
|
|
1174
1266
|
*/
|
|
1175
1267
|
constructor (name, $schema) {
|
|
1176
1268
|
super(name, $schema)
|
|
@@ -1243,17 +1335,14 @@ export class DeltaBuilder extends Delta {
|
|
|
1243
1335
|
}
|
|
1244
1336
|
|
|
1245
1337
|
/**
|
|
1246
|
-
* @template {
|
|
1338
|
+
* @template {(DConf extends {fixed:true} ? never : (Array<any>|string)) | (DeltaConfGetChildren<DConf> extends infer Children ? (Children extends never ? never : Array<Children>) : never) | DeltaConfGetText<DConf>} NewContent
|
|
1247
1339
|
* @param {NewContent} insert
|
|
1248
1340
|
* @param {FormattingAttributes?} [formatting]
|
|
1249
1341
|
* @param {Attribution?} [attribution]
|
|
1250
|
-
* @return {DeltaBuilder<
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
* (Extract<NewContent,string>|Text) extends never ? never : string,
|
|
1255
|
-
* Schema
|
|
1256
|
-
* >}
|
|
1342
|
+
* @return {DeltaBuilder<DConf extends {fixed: true} ? DConf : DeltaConfOverwrite<DConf,
|
|
1343
|
+
* (Exclude<NewContent,string> extends never ? {} : {
|
|
1344
|
+
* children: Exclude<NewContent,string>[number]|DeltaConfGetChildren<DConf>
|
|
1345
|
+
* }) & (Extract<NewContent,string> extends never ? {} : { text: true })>>}
|
|
1257
1346
|
*/
|
|
1258
1347
|
insert (insert, formatting = null, attribution = null) {
|
|
1259
1348
|
modDeltaCheck(this)
|
|
@@ -1277,7 +1366,7 @@ export class DeltaBuilder extends Delta {
|
|
|
1277
1366
|
end.insert.push(...insert)
|
|
1278
1367
|
end._fingerprint = null
|
|
1279
1368
|
} else if (insert.length > 0) {
|
|
1280
|
-
list.pushEnd(this.children, new InsertOp(insert
|
|
1369
|
+
list.pushEnd(this.children, new InsertOp(insert.slice() /* ensures that we don't reuse an existing array */, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution))
|
|
1281
1370
|
}
|
|
1282
1371
|
this.childCnt += insert.length
|
|
1283
1372
|
}
|
|
@@ -1285,17 +1374,11 @@ export class DeltaBuilder extends Delta {
|
|
|
1285
1374
|
}
|
|
1286
1375
|
|
|
1287
1376
|
/**
|
|
1288
|
-
* @template {
|
|
1377
|
+
* @template {Extract<DeltaConfGetAllowedChildren<DConf>,Delta>} NewContent
|
|
1289
1378
|
* @param {NewContent} modify
|
|
1290
1379
|
* @param {FormattingAttributes?} formatting
|
|
1291
1380
|
* @param {Attribution?} attribution
|
|
1292
|
-
* @return {DeltaBuilder<
|
|
1293
|
-
* NodeName,
|
|
1294
|
-
* Attrs,
|
|
1295
|
-
* Exclude<NewContent,string>[number]|Children,
|
|
1296
|
-
* (Extract<NewContent,string>|Text) extends string ? string : never,
|
|
1297
|
-
* Schema
|
|
1298
|
-
* >}
|
|
1381
|
+
* @return {DeltaBuilder<DeltaConfOverwrite<DConf, {children: DeltaConfGetChildren<DConf>|NewContent}>>}
|
|
1299
1382
|
*/
|
|
1300
1383
|
modify (modify, formatting = null, attribution = null) {
|
|
1301
1384
|
modDeltaCheck(this)
|
|
@@ -1316,7 +1399,7 @@ export class DeltaBuilder extends Delta {
|
|
|
1316
1399
|
const mergedFormats = mergeAttrs(this.usedAttributes, format)
|
|
1317
1400
|
const mergedAttribution = mergeAttrs(this.usedAttribution, attribution)
|
|
1318
1401
|
const lastOp = /** @type {RetainOp|InsertOp<any>} */ (this.children.end)
|
|
1319
|
-
if (lastOp
|
|
1402
|
+
if ($retainOp.check(lastOp) && fun.equalityDeep(mergedFormats, lastOp.format) && fun.equalityDeep(mergedAttribution, lastOp.attribution)) {
|
|
1320
1403
|
// @ts-ignore
|
|
1321
1404
|
lastOp.retain += len
|
|
1322
1405
|
} else if (len > 0) {
|
|
@@ -1331,8 +1414,8 @@ export class DeltaBuilder extends Delta {
|
|
|
1331
1414
|
*/
|
|
1332
1415
|
delete (len) {
|
|
1333
1416
|
modDeltaCheck(this)
|
|
1334
|
-
const lastOp = /** @type {DeleteOp
|
|
1335
|
-
if (lastOp
|
|
1417
|
+
const lastOp = /** @type {DeleteOp<any>|InsertOp<any>} */ (this.children.end)
|
|
1418
|
+
if ($deleteOp.check(lastOp)) {
|
|
1336
1419
|
lastOp.delete += len
|
|
1337
1420
|
} else if (len > 0) {
|
|
1338
1421
|
list.pushEnd(this.children, new DeleteOp(len))
|
|
@@ -1342,94 +1425,81 @@ export class DeltaBuilder extends Delta {
|
|
|
1342
1425
|
}
|
|
1343
1426
|
|
|
1344
1427
|
/**
|
|
1345
|
-
* @template {
|
|
1346
|
-
* @template {
|
|
1428
|
+
* @template {keyof DeltaConfGetAllowedAttrs<DConf>} Key
|
|
1429
|
+
* @template {DeltaConfGetAllowedAttrs<DConf>[Key]} Val
|
|
1347
1430
|
* @param {Key} key
|
|
1348
1431
|
* @param {Val} val
|
|
1349
1432
|
* @param {Attribution?} attribution
|
|
1350
1433
|
* @param {Val|undefined} [prevValue]
|
|
1351
|
-
* @return {DeltaBuilder<
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
* Children,
|
|
1355
|
-
* Text,
|
|
1356
|
-
* Schema
|
|
1357
|
-
* >}
|
|
1358
|
-
*/
|
|
1359
|
-
set (key, val, attribution = null, prevValue) {
|
|
1434
|
+
* @return {DeltaBuilder<DeltaConfOverwrite<DConf,{attrs:AddToAttrs<DeltaConfGetAttrs<DConf>,Key,Val>}>>}
|
|
1435
|
+
*/
|
|
1436
|
+
setAttr (key, val, attribution = null, prevValue) {
|
|
1360
1437
|
modDeltaCheck(this)
|
|
1361
|
-
|
|
1438
|
+
// @ts-ignore
|
|
1439
|
+
this.attrs[key] /** @type {any} */ =
|
|
1440
|
+
(new SetAttrOp(/** @type {any} */ (key), val, prevValue, mergeAttrs(this.usedAttribution, attribution)))
|
|
1362
1441
|
return /** @type {any} */ (this)
|
|
1363
1442
|
}
|
|
1364
1443
|
|
|
1365
1444
|
/**
|
|
1366
|
-
* @template {
|
|
1445
|
+
* @template {DeltaConfGetAllowedAttrs<DConf>} NewAttrs
|
|
1367
1446
|
* @param {NewAttrs} attrs
|
|
1368
1447
|
* @param {Attribution?} attribution
|
|
1369
|
-
* @return {DeltaBuilder<
|
|
1370
|
-
*
|
|
1371
|
-
* {
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
*/
|
|
1377
|
-
setMany (attrs, attribution = null) {
|
|
1448
|
+
* @return {DeltaBuilder<DeltaConfOverwrite<
|
|
1449
|
+
* DConf,
|
|
1450
|
+
* { attrs: MergeAttrs<DeltaConfGetAttrs<DConf>,NewAttrs> }
|
|
1451
|
+
* >>
|
|
1452
|
+
* }
|
|
1453
|
+
*/
|
|
1454
|
+
setAttrs (attrs, attribution = null) {
|
|
1378
1455
|
modDeltaCheck(this)
|
|
1379
1456
|
for (const k in attrs) {
|
|
1380
|
-
this.
|
|
1457
|
+
this.setAttr(/** @type {any} */ (k), /** @type {any} */ (attrs)[/** @type {any} */ (k)], attribution)
|
|
1381
1458
|
}
|
|
1382
1459
|
return /** @type {any} */ (this)
|
|
1383
1460
|
}
|
|
1384
1461
|
|
|
1385
1462
|
/**
|
|
1386
|
-
* @template {
|
|
1463
|
+
* @template {keyof DeltaConfGetAllowedAttrs<DConf>} Key
|
|
1387
1464
|
* @param {Key} key
|
|
1388
1465
|
* @param {Attribution?} attribution
|
|
1389
1466
|
* @param {any} [prevValue]
|
|
1390
|
-
* @return {DeltaBuilder<
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
* Schema
|
|
1396
|
-
* >}
|
|
1397
|
-
*/
|
|
1398
|
-
unset (key, attribution = null, prevValue) {
|
|
1467
|
+
* @return {DeltaBuilder<DeltaConfOverwrite<DConf, {
|
|
1468
|
+
* attrs: AddToAttrs<DeltaConfGetAttrs<DConf>,Key,never>
|
|
1469
|
+
* }>>}
|
|
1470
|
+
*/
|
|
1471
|
+
deleteAttr (key, attribution = null, prevValue) {
|
|
1399
1472
|
modDeltaCheck(this)
|
|
1400
|
-
|
|
1473
|
+
// @ts-ignore
|
|
1474
|
+
this.attrs[key] /** @type {any} */ =
|
|
1475
|
+
(new DeleteAttrOp(/** @type {any} */ (key), prevValue, mergeAttrs(this.usedAttribution, attribution)))
|
|
1401
1476
|
return /** @type {any} */ (this)
|
|
1402
1477
|
}
|
|
1403
1478
|
|
|
1404
1479
|
/**
|
|
1405
|
-
* @template {
|
|
1406
|
-
* @template {
|
|
1480
|
+
* @template {DeltaConfGetAllowedAttrs<DConf> extends infer As ? { [K in keyof As]: Extract<As[K],DeltaAny> extends never ? never : K }[keyof As] : never} Key
|
|
1481
|
+
* @template {Extract<DeltaConfGetAllowedAttrs<DConf>[Key],DeltaAny>} D
|
|
1407
1482
|
* @param {Key} key
|
|
1408
1483
|
* @param {D} modify
|
|
1409
|
-
* @return {DeltaBuilder<
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
* Children,
|
|
1413
|
-
* Text,
|
|
1414
|
-
* Schema
|
|
1415
|
-
* >}
|
|
1416
|
-
*/
|
|
1417
|
-
update (key, modify) {
|
|
1484
|
+
* @return {DeltaBuilder<DeltaConfOverwrite<DConf,{attrs:AddToAttrs<DeltaConfGetAttrs<DConf>,Key,D>}>>}
|
|
1485
|
+
*/
|
|
1486
|
+
modifyAttr (key, modify) {
|
|
1418
1487
|
modDeltaCheck(this)
|
|
1419
|
-
this.attrs[key] = /** @type {any} */ (new
|
|
1488
|
+
this.attrs[key] = /** @type {any} */ (new ModifyAttrOp(key, modify))
|
|
1420
1489
|
return /** @type {any} */ (this)
|
|
1421
1490
|
}
|
|
1422
1491
|
|
|
1423
1492
|
/**
|
|
1424
|
-
* @param {Delta<
|
|
1493
|
+
* @param {Delta<DConf>} other
|
|
1425
1494
|
*/
|
|
1426
1495
|
apply (other) {
|
|
1427
1496
|
modDeltaCheck(this)
|
|
1428
1497
|
this.$schema?.expect(other)
|
|
1429
1498
|
// apply attrs
|
|
1430
1499
|
for (const op of other.attrs) {
|
|
1431
|
-
|
|
1432
|
-
|
|
1500
|
+
// @ts-ignore
|
|
1501
|
+
const c = /** @type {SetAttrOp<any,any>|DeleteAttrOp<any>|ModifyAttrOp<any,any>} */ (this.attrs[op.key])
|
|
1502
|
+
if ($modifyAttrOp.check(op)) {
|
|
1433
1503
|
if ($deltaAny.check(c?.value)) {
|
|
1434
1504
|
c._modValue.apply(op.value)
|
|
1435
1505
|
} else {
|
|
@@ -1437,13 +1507,14 @@ export class DeltaBuilder extends Delta {
|
|
|
1437
1507
|
// @ts-ignore
|
|
1438
1508
|
this.attrs[op.key] = op.clone()
|
|
1439
1509
|
}
|
|
1440
|
-
} else if ($
|
|
1510
|
+
} else if ($setAttrOp.check(op)) {
|
|
1441
1511
|
// @ts-ignore
|
|
1442
1512
|
op.prevValue = c?.value
|
|
1443
1513
|
// @ts-ignore
|
|
1444
1514
|
this.attrs[op.key] = op.clone()
|
|
1445
|
-
} else if ($
|
|
1515
|
+
} else if ($deleteAttrOp.check(op)) {
|
|
1446
1516
|
op.prevValue = c?.value
|
|
1517
|
+
// @ts-ignore
|
|
1447
1518
|
delete this.attrs[op.key]
|
|
1448
1519
|
}
|
|
1449
1520
|
}
|
|
@@ -1459,7 +1530,7 @@ export class DeltaBuilder extends Delta {
|
|
|
1459
1530
|
* Hence, anytime an op is cloned, deleted, or inserted (anytime list.* api is used) we must add
|
|
1460
1531
|
* an op to maybeMergeable.
|
|
1461
1532
|
*
|
|
1462
|
-
* @type {Array<InsertOp<any>|RetainOp|DeleteOp
|
|
1533
|
+
* @type {Array<InsertOp<any>|RetainOp|DeleteOp<any>|TextOp|ModifyOp<any>>}
|
|
1463
1534
|
*/
|
|
1464
1535
|
const maybeMergeable = []
|
|
1465
1536
|
/**
|
|
@@ -1528,7 +1599,7 @@ export class DeltaBuilder extends Delta {
|
|
|
1528
1599
|
list.pushEnd(this.children, scheduleForMerge(new DeleteOp(remainingLen)))
|
|
1529
1600
|
this.childCnt += remainingLen
|
|
1530
1601
|
break
|
|
1531
|
-
} else if (opsI
|
|
1602
|
+
} else if ($deleteOp.check(opsI)) {
|
|
1532
1603
|
const delLen = opsI.length - offset
|
|
1533
1604
|
// the same content can't be deleted twice, remove duplicated deletes
|
|
1534
1605
|
if (delLen >= remainingLen) {
|
|
@@ -1573,8 +1644,8 @@ export class DeltaBuilder extends Delta {
|
|
|
1573
1644
|
this.childCnt += 1
|
|
1574
1645
|
return
|
|
1575
1646
|
}
|
|
1576
|
-
if ($
|
|
1577
|
-
opsI._modValue.apply(op.value)
|
|
1647
|
+
if ($modifyAttrOp.check(opsI)) {
|
|
1648
|
+
opsI._modValue.apply(/** @type {any} */ (op.value))
|
|
1578
1649
|
} else if ($insertOp.check(opsI)) {
|
|
1579
1650
|
opsI._modValue(offset).apply(op.value)
|
|
1580
1651
|
} else if ($retainOp.check(opsI)) {
|
|
@@ -1627,24 +1698,30 @@ export class DeltaBuilder extends Delta {
|
|
|
1627
1698
|
* - modify vs modify ⇒ rebase using priority
|
|
1628
1699
|
*/
|
|
1629
1700
|
for (const op of this.attrs) {
|
|
1630
|
-
if ($
|
|
1631
|
-
if ($
|
|
1701
|
+
if ($setAttrOp.check(op)) {
|
|
1702
|
+
if ($setAttrOp.check(other.attrs[op.key]) && !priority) {
|
|
1703
|
+
// @ts-ignore
|
|
1632
1704
|
delete this.attrs[op.key]
|
|
1633
1705
|
}
|
|
1634
|
-
} else if ($
|
|
1706
|
+
} else if ($deleteAttrOp.check(op)) {
|
|
1707
|
+
// @ts-ignore
|
|
1635
1708
|
const otherOp = other.attrs[/** @type {any} */ (op.key)]
|
|
1636
|
-
if ($
|
|
1709
|
+
if ($setAttrOp.check(otherOp)) {
|
|
1710
|
+
// @ts-ignore
|
|
1637
1711
|
delete this.attrs[otherOp.key]
|
|
1638
1712
|
}
|
|
1639
|
-
} else if ($
|
|
1713
|
+
} else if ($modifyAttrOp.check(op)) {
|
|
1640
1714
|
const otherOp = other.attrs[/** @type {any} */ (op.key)]
|
|
1641
1715
|
if (otherOp == null) {
|
|
1642
1716
|
// nop
|
|
1643
|
-
} else if ($
|
|
1717
|
+
} else if ($modifyAttrOp.check(otherOp)) {
|
|
1644
1718
|
op._modValue.rebase(otherOp.value, priority)
|
|
1645
1719
|
} else {
|
|
1720
|
+
// @ts-ignore
|
|
1646
1721
|
delete this.attrs[otherOp.key]
|
|
1647
1722
|
}
|
|
1723
|
+
} else {
|
|
1724
|
+
error.unexpectedCase()
|
|
1648
1725
|
}
|
|
1649
1726
|
}
|
|
1650
1727
|
/**
|
|
@@ -1771,9 +1848,15 @@ export class DeltaBuilder extends Delta {
|
|
|
1771
1848
|
*
|
|
1772
1849
|
* delta.create().insert('a').append(delta.create().insert('b')) // => insert "ab"
|
|
1773
1850
|
*
|
|
1774
|
-
* @
|
|
1775
|
-
*
|
|
1776
|
-
* @
|
|
1851
|
+
* @todo on fixed deltas this should not extend
|
|
1852
|
+
*
|
|
1853
|
+
* @template {DeltaConf} OtherDeltaConf
|
|
1854
|
+
* @param {Delta<OtherDeltaConf>} other
|
|
1855
|
+
* @return {DeltaBuilder<DeltaConfOverwrite<
|
|
1856
|
+
* DConf,
|
|
1857
|
+
* (DeltaConfGetChildren<OtherDeltaConf> extends never ? {} : { children: DeltaConfGetChildren<DConf> | DeltaConfGetChildren<OtherDeltaConf> })
|
|
1858
|
+
* & (DeltaConfGetText<OtherDeltaConf> extends string ? { text: true } : never)
|
|
1859
|
+
* >>}
|
|
1777
1860
|
*/
|
|
1778
1861
|
append (other) {
|
|
1779
1862
|
const children = this.children
|
|
@@ -1811,70 +1894,52 @@ const updateOpFormat = (op, formatUpdate) => {
|
|
|
1811
1894
|
}
|
|
1812
1895
|
|
|
1813
1896
|
/**
|
|
1814
|
-
* @template {
|
|
1815
|
-
* @
|
|
1816
|
-
*/
|
|
1817
|
-
|
|
1818
|
-
/**
|
|
1819
|
-
* @template {string} NodeName
|
|
1820
|
-
* @template {{ [key: string|number]: any }} [Attrs={}]
|
|
1821
|
-
* @template {fingerprintTrait.Fingerprintable|never} [Children=never]
|
|
1822
|
-
* @template {string|never} [Text=never]
|
|
1823
|
-
* @typedef {Delta<NodeName,Attrs,Children|Delta<NodeName,Attrs,Children,Text>|RecursiveDelta<NodeName,Attrs,Children,Text>,Text>} RecursiveDelta
|
|
1824
|
-
*/
|
|
1825
|
-
|
|
1826
|
-
/**
|
|
1827
|
-
* @template {string} Name
|
|
1828
|
-
* @template {{[k:string|number]:any}} Attrs
|
|
1829
|
-
* @template {fingerprintTrait.Fingerprintable} Children
|
|
1830
|
-
* @template {boolean} HasText
|
|
1831
|
-
* @template {{ [k:string]:any }} Formats
|
|
1832
|
-
* @template {boolean} Recursive
|
|
1833
|
-
* @extends {s.Schema<Delta<
|
|
1834
|
-
* Name,
|
|
1835
|
-
* Attrs,
|
|
1836
|
-
* Children|(Recursive extends true ? RecursiveDelta<Name,Attrs,Children,HasText extends true ? string : never> : never),
|
|
1837
|
-
* HasText extends true ? string : never,
|
|
1838
|
-
* any>>}
|
|
1897
|
+
* @template {DeltaConf} DConf
|
|
1898
|
+
* @extends {s.Schema<Delta<DConf>>}
|
|
1839
1899
|
*/
|
|
1840
1900
|
export class $Delta extends s.Schema {
|
|
1841
1901
|
/**
|
|
1842
|
-
* @param {s.Schema<
|
|
1843
|
-
* @param {s.Schema<
|
|
1844
|
-
* @param {s.Schema<
|
|
1845
|
-
* @param {
|
|
1846
|
-
* @param {
|
|
1847
|
-
* @param {
|
|
1902
|
+
* @param {s.Schema<any>} $name
|
|
1903
|
+
* @param {s.Schema<any>} $attrs
|
|
1904
|
+
* @param {s.Schema<any>} $children
|
|
1905
|
+
* @param {any} hasText
|
|
1906
|
+
* @param {any} recursiveChildren
|
|
1907
|
+
* @param {s.Schema<{[K:string]:any}>} $formats
|
|
1848
1908
|
*/
|
|
1849
|
-
constructor ($name, $attrs, $children, hasText, $formats
|
|
1909
|
+
constructor ($name, $attrs, $children, hasText, recursiveChildren, $formats) {
|
|
1850
1910
|
super()
|
|
1851
1911
|
const $attrsPartial = s.$$object.check($attrs) ? $attrs.partial : $attrs
|
|
1852
|
-
if (
|
|
1912
|
+
if (recursiveChildren) {
|
|
1853
1913
|
// @ts-ignore
|
|
1854
1914
|
$children = s.$union($children, this)
|
|
1855
1915
|
}
|
|
1856
|
-
|
|
1916
|
+
/**
|
|
1917
|
+
* @type {{
|
|
1918
|
+
* $name: s.Schema<DeltaConfGetName<DConf>>,
|
|
1919
|
+
* $attrs: s.Schema<DeltaConfGetAttrs<DConf>>,
|
|
1920
|
+
* $children: s.Schema<DeltaConfGetChildren<DConf>>,
|
|
1921
|
+
* hasText: DeltaConfGetText<DConf>
|
|
1922
|
+
* recursiveChildren: DeltaConfGetRecursiveChildren<DConf>,
|
|
1923
|
+
* $formats: s.Schema<{[K:string]:any}>
|
|
1924
|
+
* }}
|
|
1925
|
+
*/
|
|
1926
|
+
this.shape = { $name, $attrs: $attrsPartial, $children, hasText, $formats, recursiveChildren }
|
|
1857
1927
|
}
|
|
1858
1928
|
|
|
1859
1929
|
/**
|
|
1860
1930
|
* @param {any} o
|
|
1861
1931
|
* @param {s.ValidationError} [err]
|
|
1862
|
-
* @return {o is Delta<
|
|
1863
|
-
* Name,
|
|
1864
|
-
* Attrs,
|
|
1865
|
-
* Children|(Recursive extends true ? RecursiveDelta<Name,Attrs,Children,HasText extends true ? string : never> : never),
|
|
1866
|
-
* HasText extends true ? string : never,
|
|
1867
|
-
* any>}
|
|
1932
|
+
* @return {o is Delta<DConf>}
|
|
1868
1933
|
*/
|
|
1869
1934
|
check (o, err = undefined) {
|
|
1870
1935
|
const { $name, $attrs, $children, hasText, $formats } = this.shape
|
|
1871
|
-
if (
|
|
1936
|
+
if (!$deltaAny.check(o, err)) {
|
|
1872
1937
|
err?.extend(null, 'Delta', o?.constructor.name, 'Constructor match failed')
|
|
1873
1938
|
} else if (o.name != null && !$name.check(o.name, err)) {
|
|
1874
1939
|
err?.extend('Delta.name', $name.toString(), o.name, 'Unexpected node name')
|
|
1875
1940
|
} else if (list.toArray(o.children).some(c => (!hasText && $textOp.check(c)) || (hasText && $textOp.check(c) && c.format != null && !$formats.check(c.format)) || ($insertOp.check(c) && !c.insert.every(ins => $children.check(ins))))) {
|
|
1876
1941
|
err?.extend('Delta.children', '', '', 'Children don\'t match the schema')
|
|
1877
|
-
} else if (object.some(o.attrs, (op, k) => $
|
|
1942
|
+
} else if (object.some(o.attrs, (op, k) => $setAttrOp.check(op) && !$attrs.check({ [k]: op.value }, err))) {
|
|
1878
1943
|
err?.extend('Delta.attrs', '', '', 'Attrs don\'t match the schema')
|
|
1879
1944
|
} else {
|
|
1880
1945
|
return true
|
|
@@ -1888,7 +1953,7 @@ export class $Delta extends s.Schema {
|
|
|
1888
1953
|
* @template {s.Schema<{ [key: string|number]: any }>|{ [key:string|number]:any }} [AttrsSchema=s.Schema<{}>]
|
|
1889
1954
|
* @template {any} [ChildrenSchema=s.Schema<never>]
|
|
1890
1955
|
* @template {boolean} [HasText=false]
|
|
1891
|
-
* @template {boolean} [
|
|
1956
|
+
* @template {boolean} [RecursiveChildren=false]
|
|
1892
1957
|
* @template {{ [k:string]:any }} [Formats={[k:string]:any}]
|
|
1893
1958
|
* @param {object} opts
|
|
1894
1959
|
* @param {NodeNameSchema?} [opts.name]
|
|
@@ -1896,24 +1961,25 @@ export class $Delta extends s.Schema {
|
|
|
1896
1961
|
* @param {ChildrenSchema?} [opts.children] The type of content in `insertOp`
|
|
1897
1962
|
* @param {HasText} [opts.text] Whether this delta contains text using `textOp`
|
|
1898
1963
|
* @param {Formats} [opts.formats]
|
|
1899
|
-
* @param {
|
|
1900
|
-
* @return {[s.Unwrap<s.ReadSchema<NodeNameSchema>>,s.Unwrap<s.ReadSchema<AttrsSchema>>,s.Unwrap<s.ReadSchema<ChildrenSchema>>] extends [infer NodeName, infer Attrs, infer Children] ? s.Schema<Delta<
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
*
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1964
|
+
* @param {RecursiveChildren} [opts.recursiveChildren]
|
|
1965
|
+
* @return {[s.Unwrap<s.ReadSchema<NodeNameSchema>>,s.Unwrap<s.ReadSchema<AttrsSchema>>,s.Unwrap<s.ReadSchema<ChildrenSchema>>] extends [infer NodeName, infer Attrs, infer Children] ? s.Schema<Delta<{
|
|
1966
|
+
* name: NodeName,
|
|
1967
|
+
* attrs: Attrs,
|
|
1968
|
+
* children: Children,
|
|
1969
|
+
* text: HasText,
|
|
1970
|
+
* recursiveChildren: RecursiveChildren
|
|
1971
|
+
* }>> : never}
|
|
1972
|
+
*/
|
|
1973
|
+
export const $delta = ({ name, attrs, children, text, formats, recursiveChildren: recursive }) => /** @type {any} */ (new $Delta(
|
|
1974
|
+
/** @type {any} */ (name == null ? s.$any : s.$(name)),
|
|
1909
1975
|
/** @type {any} */ (attrs == null ? s.$object({}) : s.$(attrs)),
|
|
1910
1976
|
/** @type {any} */ (children == null ? s.$never : s.$(children)),
|
|
1911
1977
|
text ?? false,
|
|
1912
|
-
|
|
1913
|
-
|
|
1978
|
+
recursive ?? false,
|
|
1979
|
+
formats == null ? s.$any : s.$(formats)
|
|
1914
1980
|
))
|
|
1915
1981
|
|
|
1916
|
-
export const $$delta = s.$constructedBy($Delta)
|
|
1982
|
+
export const $$delta = /* @__PURE__ */s.$constructedBy($Delta)
|
|
1917
1983
|
|
|
1918
1984
|
/**
|
|
1919
1985
|
* @todo remove this
|
|
@@ -1943,11 +2009,12 @@ export const _$delta = ({ name, attrs, children, text, recursive }) => {
|
|
|
1943
2009
|
let $arrContent = children == null ? s.$never : s.$array(s.$(children))
|
|
1944
2010
|
const $name = name == null ? s.$any : s.$(name)
|
|
1945
2011
|
const $attrsPartial = attrs == null ? s.$object({}) : (s.$$record.check(attrs) ? attrs : /** @type {any} */ (s.$(attrs)).partial)
|
|
1946
|
-
const $d = s.$
|
|
2012
|
+
const $d = s.$custom(d => {
|
|
1947
2013
|
if (
|
|
2014
|
+
!$deltaAny.check(d) ||
|
|
1948
2015
|
!$name.check(d.name) ||
|
|
1949
2016
|
object.some(d.attrs,
|
|
1950
|
-
(op, k) => $
|
|
2017
|
+
(op, k) => $setAttrOp.check(op) && !$attrsPartial.check({ [k]: op.value })
|
|
1951
2018
|
)
|
|
1952
2019
|
) return false
|
|
1953
2020
|
for (const op of d.children) {
|
|
@@ -1963,15 +2030,8 @@ export const _$delta = ({ name, attrs, children, text, recursive }) => {
|
|
|
1963
2030
|
return /** @type {any} */ ($d)
|
|
1964
2031
|
}
|
|
1965
2032
|
|
|
1966
|
-
/**
|
|
1967
|
-
|
|
1968
|
-
*/
|
|
1969
|
-
export const $deltaAny = /** @type {any} */ (s.$instanceOf(Delta))
|
|
1970
|
-
|
|
1971
|
-
/**
|
|
1972
|
-
* @type {s.Schema<DeltaBuilderAny>}
|
|
1973
|
-
*/
|
|
1974
|
-
export const $deltaBuilderAny = /** @type {any} */ (s.$instanceOf(DeltaBuilder))
|
|
2033
|
+
export const $deltaAny = /** @type {s.Schema<DeltaAny>} */ (/* @__PURE__ */s.$type('delta'))
|
|
2034
|
+
export const $deltaBuilderAny = /** @type {s.Schema<DeltaBuilderAny>} */ (/* @__PURE__ */s.$custom(o => $deltaAny.check(o) && !o.isDone))
|
|
1975
2035
|
|
|
1976
2036
|
/**
|
|
1977
2037
|
* Helper function to merge attribution and attributes. The latter input "wins".
|
|
@@ -2000,16 +2060,16 @@ export const mergeDeltas = (a, b) => {
|
|
|
2000
2060
|
}
|
|
2001
2061
|
|
|
2002
2062
|
/**
|
|
2003
|
-
* @template {
|
|
2063
|
+
* @template {DeltaConf} DConf
|
|
2004
2064
|
* @param {prng.PRNG} gen
|
|
2005
|
-
* @param {s.Schema<
|
|
2006
|
-
* @return {
|
|
2065
|
+
* @param {s.Schema<Delta<DConf>>} $d
|
|
2066
|
+
* @return {DeltaBuilder<DConf>}
|
|
2007
2067
|
*/
|
|
2008
2068
|
export const random = (gen, $d) => {
|
|
2009
|
-
const { $name, $attrs, $children, hasText, $formats: $formats_ } = /** @type {$Delta<any
|
|
2069
|
+
const { $name, $attrs, $children, hasText, $formats: $formats_ } = /** @type {$Delta<any>} */ (/** @type {any} */ ($d)).shape
|
|
2010
2070
|
const d = s.$$any.check($name) ? create($deltaAny) : create(s.random(gen, $name), $deltaAny)
|
|
2011
2071
|
const $formats = s.$$any.check($formats_) ? s.$null : $formats_
|
|
2012
|
-
prng.bool(gen) && d.
|
|
2072
|
+
prng.bool(gen) && d.setAttrs(s.random(gen, $attrs))
|
|
2013
2073
|
for (let i = prng.uint32(gen, 0, 5); i > 0; i--) {
|
|
2014
2074
|
if (hasText && prng.bool(gen)) {
|
|
2015
2075
|
d.insert(prng.word(gen), s.random(gen, $formats))
|
|
@@ -2030,13 +2090,13 @@ export const random = (gen, $d) => {
|
|
|
2030
2090
|
|
|
2031
2091
|
/**
|
|
2032
2092
|
* @overload
|
|
2033
|
-
* @return {DeltaBuilder<
|
|
2093
|
+
* @return {DeltaBuilder<{}>}
|
|
2034
2094
|
*/
|
|
2035
2095
|
/**
|
|
2036
|
-
* @template {string} NodeName
|
|
2096
|
+
* @template {string|null} NodeName
|
|
2037
2097
|
* @overload
|
|
2038
2098
|
* @param {NodeName} nodeName
|
|
2039
|
-
* @return {DeltaBuilder<NodeName
|
|
2099
|
+
* @return {DeltaBuilder<NodeName extends string ? { name: NodeName } : {}>}
|
|
2040
2100
|
*/
|
|
2041
2101
|
/**
|
|
2042
2102
|
* @template {string} NodeName
|
|
@@ -2044,13 +2104,13 @@ export const random = (gen, $d) => {
|
|
|
2044
2104
|
* @overload
|
|
2045
2105
|
* @param {NodeName} nodeName
|
|
2046
2106
|
* @param {Schema} schema
|
|
2047
|
-
* @return {Schema extends s.Schema<Delta<infer
|
|
2107
|
+
* @return {Schema extends s.Schema<Delta<infer DConf>> ? DeltaBuilder<DeltaConfOverwrite<DConf, {fixed:true}>> : never}
|
|
2048
2108
|
*/
|
|
2049
2109
|
/**
|
|
2050
2110
|
* @template {s.Schema<DeltaAny>} Schema
|
|
2051
2111
|
* @overload
|
|
2052
2112
|
* @param {Schema} schema
|
|
2053
|
-
* @return {Schema extends s.Schema<Delta<infer
|
|
2113
|
+
* @return {Schema extends s.Schema<Delta<infer DConf>> ? DeltaBuilder<DeltaConfOverwrite<DConf, {fixed:true}>> : never}
|
|
2054
2114
|
*/
|
|
2055
2115
|
/**
|
|
2056
2116
|
* @template {string|null} NodeName
|
|
@@ -2060,111 +2120,100 @@ export const random = (gen, $d) => {
|
|
|
2060
2120
|
* @param {NodeName} nodeName
|
|
2061
2121
|
* @param {Attrs} attrs
|
|
2062
2122
|
* @param {Children} [children]
|
|
2063
|
-
* @return {DeltaBuilder<
|
|
2064
|
-
*
|
|
2065
|
-
* Attrs extends null ? {} : Attrs,
|
|
2066
|
-
* Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
|
|
2067
|
-
* Extract<Children,string
|
|
2068
|
-
*
|
|
2069
|
-
* >}
|
|
2123
|
+
* @return {DeltaBuilder<{
|
|
2124
|
+
* name: NodeName,
|
|
2125
|
+
* attrs: Attrs extends null ? {} : Attrs,
|
|
2126
|
+
* children: Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
|
|
2127
|
+
* text: Extract<Children,string> extends never ? false : true
|
|
2128
|
+
* }>}
|
|
2070
2129
|
*/
|
|
2071
2130
|
/**
|
|
2072
|
-
* @param {string|s.Schema<DeltaAny
|
|
2131
|
+
* @param {string|s.Schema<DeltaAny>|null} [nodeNameOrSchema]
|
|
2073
2132
|
* @param {{[K:string|number]:any}|s.Schema<DeltaAny>} [attrsOrSchema]
|
|
2074
2133
|
* @param {(Array<any>|string)} [children]
|
|
2075
|
-
* @return {DeltaBuilder<
|
|
2134
|
+
* @return {DeltaBuilder<{}>}
|
|
2076
2135
|
*/
|
|
2077
2136
|
export const create = (nodeNameOrSchema, attrsOrSchema, children) => {
|
|
2078
2137
|
const nodeName = /** @type {any} */ (s.$string.check(nodeNameOrSchema) ? nodeNameOrSchema : null)
|
|
2079
2138
|
const schema = /** @type {any} */ (s.$$schema.check(nodeNameOrSchema) ? nodeNameOrSchema : (s.$$schema.check(attrsOrSchema) ? attrsOrSchema : null))
|
|
2080
|
-
const d = /** @type {DeltaBuilder<any
|
|
2139
|
+
const d = /** @type {DeltaBuilder<any>} */ (new DeltaBuilder(nodeName, schema))
|
|
2081
2140
|
if (s.$objectAny.check(attrsOrSchema)) {
|
|
2082
|
-
d.
|
|
2141
|
+
d.setAttrs(attrsOrSchema)
|
|
2083
2142
|
}
|
|
2084
2143
|
children && d.insert(children)
|
|
2085
2144
|
return d
|
|
2086
2145
|
}
|
|
2087
2146
|
|
|
2088
|
-
// DELTA TEXT
|
|
2089
|
-
|
|
2090
|
-
/**
|
|
2091
|
-
* @template {fingerprintTrait.Fingerprintable} [Embeds=never]
|
|
2092
|
-
* @typedef {Delta<any,{},Embeds,string>} TextDelta
|
|
2093
|
-
*/
|
|
2094
|
-
|
|
2095
2147
|
/**
|
|
2096
|
-
* @template {
|
|
2097
|
-
* @
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
* @
|
|
2102
|
-
*
|
|
2103
|
-
*
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
export const $textOnly = $text()
|
|
2107
|
-
|
|
2108
|
-
/**
|
|
2109
|
-
* @template {s.Schema<Delta<any,{},any,any,null>>} [Schema=s.Schema<Delta<any,{},never,string,null>>]
|
|
2110
|
-
* @param {Schema} [$schema]
|
|
2111
|
-
* @return {Schema extends s.Schema<Delta<infer N,infer Attrs,infer Children,infer Text,any>> ? DeltaBuilder<N,Attrs,Children,Text,Schema> : never}
|
|
2112
|
-
*/
|
|
2113
|
-
export const text = $schema => /** @type {any} */ (create($schema || $textOnly))
|
|
2114
|
-
|
|
2115
|
-
/**
|
|
2116
|
-
* @template {fingerprintTrait.Fingerprintable} Children
|
|
2117
|
-
* @typedef {Delta<any,{},Children,never>} ArrayDelta
|
|
2118
|
-
*/
|
|
2119
|
-
|
|
2120
|
-
/**
|
|
2121
|
-
* @template {fingerprintTrait.Fingerprintable} Children
|
|
2122
|
-
* @typedef {DeltaBuilder<any,{},Children,never>} ArrayDeltaBuilder
|
|
2123
|
-
*/
|
|
2124
|
-
|
|
2125
|
-
/**
|
|
2126
|
-
* @template {any|s.Schema<any>} $Children
|
|
2127
|
-
* @param {$Children} [$children]
|
|
2128
|
-
* @return {s.Schema<ArrayDelta<s.Unwrap<s.ReadSchema<$Children>>>>}
|
|
2129
|
-
*/
|
|
2130
|
-
export const $array = $children => /** @type {any} */ ($delta({ children: $children }))
|
|
2131
|
-
|
|
2132
|
-
/**
|
|
2133
|
-
* @template {s.Schema<ArrayDelta<any>>} [$Schema=never]
|
|
2134
|
-
* @param {$Schema} $schema
|
|
2135
|
-
* @return {$Schema extends never ? ArrayDeltaBuilder<never> : DeltaBuilder<any,{},never,never,$Schema>}
|
|
2148
|
+
* @template {string|null} NodeName
|
|
2149
|
+
* @template {Array<any>|string} [Children=never]
|
|
2150
|
+
* @overload
|
|
2151
|
+
* @param {NodeName} nodeName
|
|
2152
|
+
* @param {...Array<Children>} [children]
|
|
2153
|
+
* @return {DeltaBuilder<{
|
|
2154
|
+
* name: NodeName,
|
|
2155
|
+
* children: Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
|
|
2156
|
+
* text: Extract<Children,string> extends never ? false : true
|
|
2157
|
+
* }>}
|
|
2136
2158
|
*/
|
|
2137
|
-
export const array = $schema => /** @type {any} */ ($schema ? create($schema) : create())
|
|
2138
|
-
|
|
2139
2159
|
/**
|
|
2140
|
-
* @template {
|
|
2141
|
-
* @
|
|
2160
|
+
* @template {Array<any>|string} [Children=never]
|
|
2161
|
+
* @overload
|
|
2162
|
+
* @param {...Array<Children>} [children]
|
|
2163
|
+
* @return {DeltaBuilder<{
|
|
2164
|
+
* children: Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
|
|
2165
|
+
* text: Extract<Children,string> extends never ? false : true
|
|
2166
|
+
* }>}
|
|
2142
2167
|
*/
|
|
2143
|
-
|
|
2144
2168
|
/**
|
|
2145
|
-
* @template {{
|
|
2146
|
-
* @
|
|
2169
|
+
* @template {{[k:string|number]:any}|null} Attrs
|
|
2170
|
+
* @template {Array<any>|string} [Children=never]
|
|
2171
|
+
* @overload
|
|
2172
|
+
* @param {Attrs} attrs
|
|
2173
|
+
* @param {...Array<Children>} [children]
|
|
2174
|
+
* @return {DeltaBuilder<{
|
|
2175
|
+
* attrs: Attrs extends null ? {} : Attrs,
|
|
2176
|
+
* children: Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
|
|
2177
|
+
* text: Extract<Children,string> extends never ? false : true
|
|
2178
|
+
* }>}
|
|
2147
2179
|
*/
|
|
2148
|
-
|
|
2149
2180
|
/**
|
|
2150
|
-
* @template {
|
|
2151
|
-
* @
|
|
2152
|
-
* @
|
|
2181
|
+
* @template {string|null} NodeName
|
|
2182
|
+
* @template {{[k:string|number]:any}|null} Attrs
|
|
2183
|
+
* @template {Array<any>|string} [Children=never]
|
|
2184
|
+
* @overload
|
|
2185
|
+
* @param {NodeName} nodeName
|
|
2186
|
+
* @param {Attrs} attrs
|
|
2187
|
+
* @param {...Array<Children>} [children]
|
|
2188
|
+
* @return {DeltaBuilder<{
|
|
2189
|
+
* name: NodeName,
|
|
2190
|
+
* attrs: Attrs extends null ? {} : Attrs,
|
|
2191
|
+
* children: Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
|
|
2192
|
+
* text: Extract<Children,string> extends never ? false : true
|
|
2193
|
+
* }>}
|
|
2153
2194
|
*/
|
|
2154
|
-
export const $map = $attrs => /** @type {any} */ ($delta({ attrs: $attrs }))
|
|
2155
|
-
|
|
2156
2195
|
/**
|
|
2157
|
-
* @
|
|
2158
|
-
* @
|
|
2159
|
-
* @return {$Schema extends s.Schema<MapDelta<infer Attrs>> ? DeltaBuilder<any,Attrs,never,never,$Schema> : MapDeltaBuilder<{}>}
|
|
2196
|
+
* @param {Array<string|null|{[K:string|number]:any}|Array<any>>} args
|
|
2197
|
+
* @return {DeltaBuilder<{}>}
|
|
2160
2198
|
*/
|
|
2161
|
-
export const
|
|
2199
|
+
export const from = (...args) => {
|
|
2200
|
+
const hasName = s.$string.check(args[0])
|
|
2201
|
+
let i = hasName ? 1 : 0
|
|
2202
|
+
const d = create(hasName ? /** @type {string} */ (args[0]) : null)
|
|
2203
|
+
if (s.$objectAny.check(args[i])) {
|
|
2204
|
+
d.setAttrs(/** @type {any} */ (args[i++]))
|
|
2205
|
+
}
|
|
2206
|
+
for (; i < args.length; i++) {
|
|
2207
|
+
d.insert(/** @type {any} */ (args[i]))
|
|
2208
|
+
}
|
|
2209
|
+
return d
|
|
2210
|
+
}
|
|
2162
2211
|
|
|
2163
2212
|
/**
|
|
2164
|
-
* @template {
|
|
2165
|
-
* @param {
|
|
2166
|
-
* @param {NoInfer<
|
|
2167
|
-
* @return {
|
|
2213
|
+
* @template {DeltaConf} DConf
|
|
2214
|
+
* @param {Delta<DConf>} d1
|
|
2215
|
+
* @param {NoInfer<Delta<DConf>>} d2
|
|
2216
|
+
* @return {DeltaBuilder<DConf>}
|
|
2168
2217
|
*/
|
|
2169
2218
|
export const diff = (d1, d2) => {
|
|
2170
2219
|
/**
|
|
@@ -2172,9 +2221,21 @@ export const diff = (d1, d2) => {
|
|
|
2172
2221
|
*/
|
|
2173
2222
|
const d = create()
|
|
2174
2223
|
if (d1.fingerprint !== d2.fingerprint) {
|
|
2224
|
+
/**
|
|
2225
|
+
* @type {ChildrenOpAny?}
|
|
2226
|
+
*/
|
|
2175
2227
|
let left1 = d1.children.start
|
|
2228
|
+
/**
|
|
2229
|
+
* @type {ChildrenOpAny?}
|
|
2230
|
+
*/
|
|
2176
2231
|
let left2 = d2.children.start
|
|
2232
|
+
/**
|
|
2233
|
+
* @type {ChildrenOpAny?}
|
|
2234
|
+
*/
|
|
2177
2235
|
let right1 = d1.children.end
|
|
2236
|
+
/**
|
|
2237
|
+
* @type {ChildrenOpAny?}
|
|
2238
|
+
*/
|
|
2178
2239
|
let right2 = d2.children.end
|
|
2179
2240
|
let commonPrefixOffset = 0
|
|
2180
2241
|
// perform a patience sort
|
|
@@ -2222,7 +2283,7 @@ export const diff = (d1, d2) => {
|
|
|
2222
2283
|
* @param {ChildrenOpAny[]} opsShould
|
|
2223
2284
|
*/
|
|
2224
2285
|
const diffAndApply = (opsIs, opsShould) => {
|
|
2225
|
-
const d = create()
|
|
2286
|
+
const d = create($deltaAny)
|
|
2226
2287
|
// @todo unoptimized implementation. Convert content to array and diff that based on
|
|
2227
2288
|
// generated fingerprints. We probably could do better and cache more information.
|
|
2228
2289
|
// - benchmark
|
|
@@ -2247,11 +2308,12 @@ export const diff = (d1, d2) => {
|
|
|
2247
2308
|
const cd = cdiff[i]
|
|
2248
2309
|
cd.remove = isContent.slice(cd.index, cd.index + cd.remove.length)
|
|
2249
2310
|
cd.insert = shouldContent.slice(cd.index + adj, cd.index + adj + cd.insert.length)
|
|
2250
|
-
adj += cd.
|
|
2311
|
+
adj += cd.insert.length - cd.remove.length
|
|
2251
2312
|
}
|
|
2252
2313
|
for (let i = 0, lastIndex = 0; i < cdiff.length; i++) {
|
|
2253
2314
|
const cd = cdiff[i]
|
|
2254
2315
|
d.retain(cd.index - lastIndex)
|
|
2316
|
+
lastIndex = cd.index
|
|
2255
2317
|
let cdii = 0
|
|
2256
2318
|
let cdri = 0
|
|
2257
2319
|
// try to match as much content as possible, preferring to skip over non-deltas
|
|
@@ -2280,7 +2342,7 @@ export const diff = (d1, d2) => {
|
|
|
2280
2342
|
if (hasFormatting) {
|
|
2281
2343
|
const formattingDiff = create()
|
|
2282
2344
|
// update opsIs with content diff. then we can figure out the formatting diff.
|
|
2283
|
-
const isUpdated = create()
|
|
2345
|
+
const isUpdated = create($deltaAny)
|
|
2284
2346
|
// copy opsIs to fresh delta
|
|
2285
2347
|
opsIs.forEach(op => {
|
|
2286
2348
|
isUpdated.childCnt += op.length
|
|
@@ -2338,11 +2400,12 @@ export const diff = (d1, d2) => {
|
|
|
2338
2400
|
currIndexOffset2 += change.insert.length - change.remove.length
|
|
2339
2401
|
}
|
|
2340
2402
|
for (const attr2 of d2.attrs) {
|
|
2403
|
+
// @ts-ignore
|
|
2341
2404
|
const attr1 = d1.attrs[attr2.key]
|
|
2342
2405
|
if (attr1 == null || (attr1.fingerprint !== attr2.fingerprint)) {
|
|
2343
2406
|
/* c8 ignore else */
|
|
2344
|
-
if ($
|
|
2345
|
-
d.
|
|
2407
|
+
if ($setAttrOp.check(attr2)) {
|
|
2408
|
+
d.setAttr(attr2.key, attr2.value)
|
|
2346
2409
|
} else {
|
|
2347
2410
|
/* c8 ignore next 2 */
|
|
2348
2411
|
error.unexpectedCase()
|
|
@@ -2350,8 +2413,9 @@ export const diff = (d1, d2) => {
|
|
|
2350
2413
|
}
|
|
2351
2414
|
}
|
|
2352
2415
|
for (const attr1 of d1.attrs) {
|
|
2416
|
+
// @ts-ignore
|
|
2353
2417
|
if (d2.attrs[attr1.key] == null) {
|
|
2354
|
-
d.
|
|
2418
|
+
d.deleteAttr(attr1.key)
|
|
2355
2419
|
}
|
|
2356
2420
|
}
|
|
2357
2421
|
}
|