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.
Files changed (860) hide show
  1. package/package.json +160 -407
  2. package/{array.js → src/array.js} +6 -2
  3. package/{binary.js → src/binary.js} +29 -35
  4. package/{delta → src/delta}/delta.js +474 -410
  5. package/{environment.js → src/environment.js} +30 -16
  6. package/{hash → src/hash}/rabin.js +6 -6
  7. package/{schema.js → src/schema.js} +127 -58
  8. package/{string.js → src/string.js} +47 -26
  9. package/{testing.js → src/testing.js} +3 -1
  10. package/src/ts.js +46 -0
  11. package/{dist → types}/array.d.ts +1 -1
  12. package/types/array.d.ts.map +1 -0
  13. package/{dist → types}/binary.d.ts +31 -37
  14. package/types/binary.d.ts.map +1 -0
  15. package/types/broadcastchannel.d.ts.map +1 -0
  16. package/types/buffer.d.ts.map +1 -0
  17. package/types/cache.d.ts.map +1 -0
  18. package/types/component.d.ts.map +1 -0
  19. package/types/conditions.d.ts.map +1 -0
  20. package/types/decoding.d.ts.map +1 -0
  21. package/types/delta/delta.d.ts +87 -16
  22. package/types/delta/delta.d.ts.map +1 -1
  23. package/types/delta/t3.test.d.ts.map +1 -1
  24. package/types/diff.d.ts.map +1 -0
  25. package/types/dom.d.ts.map +1 -0
  26. package/types/encoding.d.ts.map +1 -0
  27. package/{environment.d.ts → types/environment.d.ts} +2 -0
  28. package/types/environment.d.ts.map +1 -0
  29. package/types/error.d.ts.map +1 -0
  30. package/types/eventloop.d.ts.map +1 -0
  31. package/{function.d.ts → types/function.d.ts} +1 -1
  32. package/types/function.d.ts.map +1 -0
  33. package/types/indexeddb.d.ts.map +1 -0
  34. package/types/indexeddbV2.d.ts.map +1 -0
  35. package/types/iterator.d.ts.map +1 -0
  36. package/types/json.d.ts.map +1 -0
  37. package/types/list.d.ts.map +1 -0
  38. package/types/logging.common.d.ts.map +1 -0
  39. package/types/logging.d.ts.map +1 -0
  40. package/types/logging.node.d.ts.map +1 -0
  41. package/types/map.d.ts.map +1 -0
  42. package/types/math.d.ts.map +1 -0
  43. package/types/metric.d.ts.map +1 -0
  44. package/types/mutex.d.ts.map +1 -0
  45. package/{number.d.ts → types/number.d.ts} +2 -2
  46. package/types/number.d.ts.map +1 -0
  47. package/types/object.d.ts.map +1 -0
  48. package/types/observable.d.ts.map +1 -0
  49. package/types/pair.d.ts.map +1 -0
  50. package/types/performance.d.ts.map +1 -0
  51. package/types/performance.node.d.ts.map +1 -0
  52. package/types/pledge.d.ts.map +1 -0
  53. package/types/prng.d.ts.map +1 -0
  54. package/types/promise.d.ts.map +1 -0
  55. package/types/queue.d.ts.map +1 -0
  56. package/types/random.d.ts.map +1 -0
  57. package/{schema.d.ts → types/schema.d.ts} +65 -59
  58. package/types/schema.d.ts.map +1 -0
  59. package/types/set.d.ts.map +1 -0
  60. package/types/sort.d.ts.map +1 -0
  61. package/types/statistics.d.ts.map +1 -0
  62. package/types/storage.d.ts.map +1 -0
  63. package/{string.d.ts → types/string.d.ts} +3 -8
  64. package/types/string.d.ts.map +1 -0
  65. package/types/symbol.d.ts.map +1 -0
  66. package/{testing.d.ts → types/testing.d.ts} +2 -1
  67. package/types/testing.d.ts.map +1 -0
  68. package/types/time.d.ts.map +1 -0
  69. package/types/trait/equality.d.ts.map +1 -1
  70. package/types/tree.d.ts.map +1 -0
  71. package/types/ts.d.ts +22 -0
  72. package/types/ts.d.ts.map +1 -0
  73. package/types/url.d.ts.map +1 -0
  74. package/types/webcrypto.d.ts.map +1 -0
  75. package/types/webcrypto.deno.d.ts.map +1 -0
  76. package/types/webcrypto.node.d.ts.map +1 -0
  77. package/types/webcrypto.react-native.d.ts.map +1 -0
  78. package/types/websocket.d.ts.map +1 -0
  79. package/.github/workflows/node.js.yml +0 -24
  80. package/.jsdoc.json +0 -18
  81. package/.vscode/launch.json +0 -17
  82. package/array.d.ts +0 -30
  83. package/array.d.ts.map +0 -1
  84. package/array.test.d.ts +0 -13
  85. package/array.test.d.ts.map +0 -1
  86. package/bin/0ecdsa-generate-keypair.d.ts +0 -3
  87. package/bin/0ecdsa-generate-keypair.d.ts.map +0 -1
  88. package/bin/0serve.d.ts +0 -3
  89. package/bin/0serve.d.ts.map +0 -1
  90. package/bin/gendocs.d.ts +0 -3
  91. package/bin/gendocs.d.ts.map +0 -1
  92. package/bin/gentesthtml.d.ts +0 -3
  93. package/bin/gentesthtml.d.ts.map +0 -1
  94. package/binary.d.ts +0 -87
  95. package/binary.d.ts.map +0 -1
  96. package/binary.test.d.ts +0 -4
  97. package/binary.test.d.ts.map +0 -1
  98. package/broadcastchannel.d.ts.map +0 -1
  99. package/broadcastchannel.test.d.ts +0 -3
  100. package/broadcastchannel.test.d.ts.map +0 -1
  101. package/buffer.d.ts.map +0 -1
  102. package/buffer.test.d.ts +0 -6
  103. package/buffer.test.d.ts.map +0 -1
  104. package/cache.d.ts.map +0 -1
  105. package/cache.test.d.ts +0 -3
  106. package/cache.test.d.ts.map +0 -1
  107. package/component.d.ts.map +0 -1
  108. package/conditions.d.ts.map +0 -1
  109. package/coverage/tmp/coverage-54474-1766470859038-0.json +0 -1
  110. package/crypto/aes-gcm.d.ts +0 -17
  111. package/crypto/aes-gcm.d.ts.map +0 -1
  112. package/crypto/common.d.ts +0 -3
  113. package/crypto/common.d.ts.map +0 -1
  114. package/crypto/ecdsa.d.ts +0 -17
  115. package/crypto/ecdsa.d.ts.map +0 -1
  116. package/crypto/jwt.d.ts +0 -10
  117. package/crypto/jwt.d.ts.map +0 -1
  118. package/crypto/rsa-oaep.d.ts +0 -13
  119. package/crypto/rsa-oaep.d.ts.map +0 -1
  120. package/crypto.test.d.ts +0 -9
  121. package/crypto.test.d.ts.map +0 -1
  122. package/decoding.d.ts.map +0 -1
  123. package/delta/binding.d.ts +0 -107
  124. package/delta/binding.d.ts.map +0 -1
  125. package/delta/binding.test.d.ts +0 -5
  126. package/delta/binding.test.d.ts.map +0 -1
  127. package/delta/delta-pitch.test.d.ts +0 -5
  128. package/delta/delta-pitch.test.d.ts.map +0 -1
  129. package/delta/delta.d.ts +0 -1008
  130. package/delta/delta.d.ts.map +0 -1
  131. package/delta/delta.test.d.ts +0 -28
  132. package/delta/delta.test.d.ts.map +0 -1
  133. package/delta/t3.test.d.ts +0 -19
  134. package/delta/t3.test.d.ts.map +0 -1
  135. package/deno.json +0 -12
  136. package/deno.lock +0 -122
  137. package/diff/patience.d.ts +0 -16
  138. package/diff/patience.d.ts.map +0 -1
  139. package/diff/patience.test.d.ts +0 -4
  140. package/diff/patience.test.d.ts.map +0 -1
  141. package/diff.d.ts.map +0 -1
  142. package/diff.test.d.ts +0 -6
  143. package/diff.test.d.ts.map +0 -1
  144. package/dist/aes-gcm.cjs +0 -171
  145. package/dist/aes-gcm.cjs.map +0 -1
  146. package/dist/array-78849c95.cjs +0 -260
  147. package/dist/array-78849c95.cjs.map +0 -1
  148. package/dist/array.cjs +0 -26
  149. package/dist/array.cjs.map +0 -1
  150. package/dist/array.d.ts.map +0 -1
  151. package/dist/array.test.d.ts +0 -13
  152. package/dist/array.test.d.ts.map +0 -1
  153. package/dist/bin/0ecdsa-generate-keypair.d.ts +0 -3
  154. package/dist/bin/0ecdsa-generate-keypair.d.ts.map +0 -1
  155. package/dist/bin/0serve.d.ts +0 -3
  156. package/dist/bin/0serve.d.ts.map +0 -1
  157. package/dist/bin/gendocs.d.ts +0 -3
  158. package/dist/bin/gendocs.d.ts.map +0 -1
  159. package/dist/bin/gentesthtml.d.ts +0 -3
  160. package/dist/bin/gentesthtml.d.ts.map +0 -1
  161. package/dist/binary-ac8e39e2.cjs +0 -229
  162. package/dist/binary-ac8e39e2.cjs.map +0 -1
  163. package/dist/binary.cjs +0 -74
  164. package/dist/binary.cjs.map +0 -1
  165. package/dist/binary.d.ts.map +0 -1
  166. package/dist/binary.test.d.ts +0 -4
  167. package/dist/binary.test.d.ts.map +0 -1
  168. package/dist/binding.cjs +0 -484
  169. package/dist/binding.cjs.map +0 -1
  170. package/dist/broadcastchannel-aca4f606.cjs +0 -128
  171. package/dist/broadcastchannel-aca4f606.cjs.map +0 -1
  172. package/dist/broadcastchannel.cjs +0 -29
  173. package/dist/broadcastchannel.cjs.map +0 -1
  174. package/dist/broadcastchannel.d.ts +0 -8
  175. package/dist/broadcastchannel.d.ts.map +0 -1
  176. package/dist/broadcastchannel.test.d.ts +0 -3
  177. package/dist/broadcastchannel.test.d.ts.map +0 -1
  178. package/dist/buffer-3e750729.cjs +0 -198
  179. package/dist/buffer-3e750729.cjs.map +0 -1
  180. package/dist/buffer.cjs +0 -38
  181. package/dist/buffer.cjs.map +0 -1
  182. package/dist/buffer.d.ts +0 -22
  183. package/dist/buffer.d.ts.map +0 -1
  184. package/dist/buffer.test.d.ts +0 -6
  185. package/dist/buffer.test.d.ts.map +0 -1
  186. package/dist/cache.cjs +0 -223
  187. package/dist/cache.cjs.map +0 -1
  188. package/dist/cache.d.ts +0 -52
  189. package/dist/cache.d.ts.map +0 -1
  190. package/dist/cache.test.d.ts +0 -3
  191. package/dist/cache.test.d.ts.map +0 -1
  192. package/dist/common.cjs +0 -47
  193. package/dist/common.cjs.map +0 -1
  194. package/dist/component.cjs +0 -437
  195. package/dist/component.cjs.map +0 -1
  196. package/dist/component.d.ts +0 -86
  197. package/dist/component.d.ts.map +0 -1
  198. package/dist/conditions-f5c0c102.cjs +0 -24
  199. package/dist/conditions-f5c0c102.cjs.map +0 -1
  200. package/dist/conditions.cjs +0 -10
  201. package/dist/conditions.cjs.map +0 -1
  202. package/dist/conditions.d.ts +0 -2
  203. package/dist/conditions.d.ts.map +0 -1
  204. package/dist/crypto/aes-gcm.d.ts +0 -17
  205. package/dist/crypto/aes-gcm.d.ts.map +0 -1
  206. package/dist/crypto/common.d.ts +0 -3
  207. package/dist/crypto/common.d.ts.map +0 -1
  208. package/dist/crypto/ecdsa.d.ts +0 -17
  209. package/dist/crypto/ecdsa.d.ts.map +0 -1
  210. package/dist/crypto/jwt.d.ts +0 -10
  211. package/dist/crypto/jwt.d.ts.map +0 -1
  212. package/dist/crypto/rsa-oaep.d.ts +0 -13
  213. package/dist/crypto/rsa-oaep.d.ts.map +0 -1
  214. package/dist/crypto.test.d.ts +0 -9
  215. package/dist/crypto.test.d.ts.map +0 -1
  216. package/dist/decoding-76e75827.cjs +0 -795
  217. package/dist/decoding-76e75827.cjs.map +0 -1
  218. package/dist/decoding.cjs +0 -55
  219. package/dist/decoding.cjs.map +0 -1
  220. package/dist/decoding.d.ts +0 -165
  221. package/dist/decoding.d.ts.map +0 -1
  222. package/dist/delta/binding.d.ts +0 -107
  223. package/dist/delta/binding.d.ts.map +0 -1
  224. package/dist/delta/binding.test.d.ts +0 -5
  225. package/dist/delta/binding.test.d.ts.map +0 -1
  226. package/dist/delta/delta-pitch.test.d.ts +0 -5
  227. package/dist/delta/delta-pitch.test.d.ts.map +0 -1
  228. package/dist/delta/delta.d.ts +0 -1008
  229. package/dist/delta/delta.d.ts.map +0 -1
  230. package/dist/delta/delta.test.d.ts +0 -28
  231. package/dist/delta/delta.test.d.ts.map +0 -1
  232. package/dist/delta/t3.test.d.ts +0 -19
  233. package/dist/delta/t3.test.d.ts.map +0 -1
  234. package/dist/delta.cjs +0 -2409
  235. package/dist/delta.cjs.map +0 -1
  236. package/dist/diff/patience.d.ts +0 -16
  237. package/dist/diff/patience.d.ts.map +0 -1
  238. package/dist/diff/patience.test.d.ts +0 -4
  239. package/dist/diff/patience.test.d.ts.map +0 -1
  240. package/dist/diff-9d236524.cjs +0 -162
  241. package/dist/diff-9d236524.cjs.map +0 -1
  242. package/dist/diff.cjs +0 -18
  243. package/dist/diff.cjs.map +0 -1
  244. package/dist/diff.d.ts +0 -36
  245. package/dist/diff.d.ts.map +0 -1
  246. package/dist/diff.test.d.ts +0 -6
  247. package/dist/diff.test.d.ts.map +0 -1
  248. package/dist/dom-7e625b09.cjs +0 -371
  249. package/dist/dom-7e625b09.cjs.map +0 -1
  250. package/dist/dom.cjs +0 -71
  251. package/dist/dom.cjs.map +0 -1
  252. package/dist/dom.d.ts.map +0 -1
  253. package/dist/ecdsa.cjs +0 -130
  254. package/dist/ecdsa.cjs.map +0 -1
  255. package/dist/encoding-1a745c43.cjs +0 -1025
  256. package/dist/encoding-1a745c43.cjs.map +0 -1
  257. package/dist/encoding.cjs +0 -54
  258. package/dist/encoding.cjs.map +0 -1
  259. package/dist/encoding.d.ts.map +0 -1
  260. package/dist/encoding.test.d.ts +0 -50
  261. package/dist/encoding.test.d.ts.map +0 -1
  262. package/dist/environment-1c97264d.cjs +0 -180
  263. package/dist/environment-1c97264d.cjs.map +0 -1
  264. package/dist/environment.cjs +0 -29
  265. package/dist/environment.cjs.map +0 -1
  266. package/dist/environment.d.ts +0 -19
  267. package/dist/environment.d.ts.map +0 -1
  268. package/dist/equality.cjs +0 -34
  269. package/dist/equality.cjs.map +0 -1
  270. package/dist/error-0c1f634f.cjs +0 -53
  271. package/dist/error-0c1f634f.cjs.map +0 -1
  272. package/dist/error.cjs +0 -13
  273. package/dist/error.cjs.map +0 -1
  274. package/dist/error.d.ts.map +0 -1
  275. package/dist/eventloop-a0168106.cjs +0 -151
  276. package/dist/eventloop-a0168106.cjs.map +0 -1
  277. package/dist/eventloop.cjs +0 -19
  278. package/dist/eventloop.cjs.map +0 -1
  279. package/dist/eventloop.d.ts.map +0 -1
  280. package/dist/eventloop.test.d.ts +0 -10
  281. package/dist/eventloop.test.d.ts.map +0 -1
  282. package/dist/fingerprint.cjs +0 -44
  283. package/dist/fingerprint.cjs.map +0 -1
  284. package/dist/function-314580f7.cjs +0 -223
  285. package/dist/function-314580f7.cjs.map +0 -1
  286. package/dist/function.cjs +0 -26
  287. package/dist/function.cjs.map +0 -1
  288. package/dist/function.d.ts +0 -19
  289. package/dist/function.d.ts.map +0 -1
  290. package/dist/function.test.d.ts +0 -5
  291. package/dist/function.test.d.ts.map +0 -1
  292. package/dist/hash/rabin-gf2-polynomial.d.ts +0 -45
  293. package/dist/hash/rabin-gf2-polynomial.d.ts.map +0 -1
  294. package/dist/hash/rabin-uncached.d.ts +0 -29
  295. package/dist/hash/rabin-uncached.d.ts.map +0 -1
  296. package/dist/hash/rabin.d.ts +0 -27
  297. package/dist/hash/rabin.d.ts.map +0 -1
  298. package/dist/hash/rabin.test.d.ts +0 -8
  299. package/dist/hash/rabin.test.d.ts.map +0 -1
  300. package/dist/hash/sha256.d.ts +0 -2
  301. package/dist/hash/sha256.d.ts.map +0 -1
  302. package/dist/hash/sha256.node.d.ts +0 -2
  303. package/dist/hash/sha256.node.d.ts.map +0 -1
  304. package/dist/hash/sha256.test.d.ts +0 -7
  305. package/dist/hash/sha256.test.d.ts.map +0 -1
  306. package/dist/index.cjs +0 -99
  307. package/dist/index.cjs.map +0 -1
  308. package/dist/index.d.ts +0 -35
  309. package/dist/index.d.ts.map +0 -1
  310. package/dist/indexeddb-46d1e737.cjs +0 -311
  311. package/dist/indexeddb-46d1e737.cjs.map +0 -1
  312. package/dist/indexeddb.cjs +0 -37
  313. package/dist/indexeddb.cjs.map +0 -1
  314. package/dist/indexeddb.d.ts.map +0 -1
  315. package/dist/indexeddb.test.d.ts +0 -3
  316. package/dist/indexeddb.test.d.ts.map +0 -1
  317. package/dist/indexeddbV2.cjs +0 -288
  318. package/dist/indexeddbV2.cjs.map +0 -1
  319. package/dist/indexeddbV2.d.ts.map +0 -1
  320. package/dist/indexeddbV2.test.d.ts +0 -3
  321. package/dist/indexeddbV2.test.d.ts.map +0 -1
  322. package/dist/isomorphic.cjs +0 -17
  323. package/dist/isomorphic.cjs.map +0 -1
  324. package/dist/iterator-9fc627c1.cjs +0 -78
  325. package/dist/iterator-9fc627c1.cjs.map +0 -1
  326. package/dist/iterator.cjs +0 -13
  327. package/dist/iterator.cjs.map +0 -1
  328. package/dist/iterator.d.ts.map +0 -1
  329. package/dist/json-092190a1.cjs +0 -34
  330. package/dist/json-092190a1.cjs.map +0 -1
  331. package/dist/json.cjs +0 -11
  332. package/dist/json.cjs.map +0 -1
  333. package/dist/json.d.ts.map +0 -1
  334. package/dist/jwt.cjs +0 -96
  335. package/dist/jwt.cjs.map +0 -1
  336. package/dist/list.cjs +0 -266
  337. package/dist/list.cjs.map +0 -1
  338. package/dist/list.d.ts.map +0 -1
  339. package/dist/list.test.d.ts +0 -6
  340. package/dist/list.test.d.ts.map +0 -1
  341. package/dist/logging.cjs +0 -428
  342. package/dist/logging.cjs.map +0 -1
  343. package/dist/logging.common.cjs +0 -132
  344. package/dist/logging.common.cjs.map +0 -1
  345. package/dist/logging.common.d.ts.map +0 -1
  346. package/dist/logging.d.ts.map +0 -1
  347. package/dist/logging.node.cjs +0 -203
  348. package/dist/logging.node.cjs.map +0 -1
  349. package/dist/logging.node.d.ts.map +0 -1
  350. package/dist/logging.test.d.ts +0 -3
  351. package/dist/logging.test.d.ts.map +0 -1
  352. package/dist/map-24d263c0.cjs +0 -139
  353. package/dist/map-24d263c0.cjs.map +0 -1
  354. package/dist/map.cjs +0 -15
  355. package/dist/map.cjs.map +0 -1
  356. package/dist/map.d.ts.map +0 -1
  357. package/dist/map.test.d.ts +0 -4
  358. package/dist/map.test.d.ts.map +0 -1
  359. package/dist/math-96d5e8c4.cjs +0 -103
  360. package/dist/math-96d5e8c4.cjs.map +0 -1
  361. package/dist/math.cjs +0 -26
  362. package/dist/math.cjs.map +0 -1
  363. package/dist/math.d.ts.map +0 -1
  364. package/dist/math.test.d.ts +0 -3
  365. package/dist/math.test.d.ts.map +0 -1
  366. package/dist/metric.cjs +0 -83
  367. package/dist/metric.cjs.map +0 -1
  368. package/dist/metric.d.ts.map +0 -1
  369. package/dist/metric.test.d.ts +0 -3
  370. package/dist/metric.test.d.ts.map +0 -1
  371. package/dist/mutex-63f09c81.cjs +0 -54
  372. package/dist/mutex-63f09c81.cjs.map +0 -1
  373. package/dist/mutex.cjs +0 -10
  374. package/dist/mutex.cjs.map +0 -1
  375. package/dist/mutex.d.ts.map +0 -1
  376. package/dist/mutex.test.d.ts +0 -3
  377. package/dist/mutex.test.d.ts.map +0 -1
  378. package/dist/number-1fb57bba.cjs +0 -64
  379. package/dist/number-1fb57bba.cjs.map +0 -1
  380. package/dist/number.cjs +0 -20
  381. package/dist/number.cjs.map +0 -1
  382. package/dist/number.d.ts +0 -10
  383. package/dist/number.d.ts.map +0 -1
  384. package/dist/number.test.d.ts +0 -4
  385. package/dist/number.test.d.ts.map +0 -1
  386. package/dist/object-c0c9435b.cjs +0 -212
  387. package/dist/object-c0c9435b.cjs.map +0 -1
  388. package/dist/object.cjs +0 -27
  389. package/dist/object.cjs.map +0 -1
  390. package/dist/object.d.ts.map +0 -1
  391. package/dist/object.test.d.ts +0 -6
  392. package/dist/object.test.d.ts.map +0 -1
  393. package/dist/observable.cjs +0 -169
  394. package/dist/observable.cjs.map +0 -1
  395. package/dist/observable.d.ts.map +0 -1
  396. package/dist/observable.test.d.ts +0 -3
  397. package/dist/observable.test.d.ts.map +0 -1
  398. package/dist/pair-ab022bc3.cjs +0 -69
  399. package/dist/pair-ab022bc3.cjs.map +0 -1
  400. package/dist/pair.cjs +0 -14
  401. package/dist/pair.cjs.map +0 -1
  402. package/dist/pair.d.ts.map +0 -1
  403. package/dist/pair.test.d.ts +0 -3
  404. package/dist/pair.test.d.ts.map +0 -1
  405. package/dist/patience.cjs +0 -236
  406. package/dist/patience.cjs.map +0 -1
  407. package/dist/performance.cjs +0 -14
  408. package/dist/performance.cjs.map +0 -1
  409. package/dist/performance.d.ts.map +0 -1
  410. package/dist/performance.node.cjs +0 -36
  411. package/dist/performance.node.cjs.map +0 -1
  412. package/dist/performance.node.d.ts.map +0 -1
  413. package/dist/pledge.cjs +0 -308
  414. package/dist/pledge.cjs.map +0 -1
  415. package/dist/pledge.d.ts.map +0 -1
  416. package/dist/pledge.test.d.ts +0 -6
  417. package/dist/pledge.test.d.ts.map +0 -1
  418. package/dist/prng/Mt19937.d.ts +0 -29
  419. package/dist/prng/Mt19937.d.ts.map +0 -1
  420. package/dist/prng/Xoroshiro128plus.d.ts +0 -27
  421. package/dist/prng/Xoroshiro128plus.d.ts.map +0 -1
  422. package/dist/prng/Xorshift32.d.ts +0 -21
  423. package/dist/prng/Xorshift32.d.ts.map +0 -1
  424. package/dist/prng-37d48618.cjs +0 -387
  425. package/dist/prng-37d48618.cjs.map +0 -1
  426. package/dist/prng.cjs +0 -44
  427. package/dist/prng.cjs.map +0 -1
  428. package/dist/prng.d.ts.map +0 -1
  429. package/dist/prng.test.d.ts +0 -6
  430. package/dist/prng.test.d.ts.map +0 -1
  431. package/dist/promise-cda7b9bb.cjs +0 -145
  432. package/dist/promise-cda7b9bb.cjs.map +0 -1
  433. package/dist/promise.cjs +0 -22
  434. package/dist/promise.cjs.map +0 -1
  435. package/dist/promise.d.ts.map +0 -1
  436. package/dist/promise.test.d.ts +0 -5
  437. package/dist/promise.test.d.ts.map +0 -1
  438. package/dist/queue.cjs +0 -97
  439. package/dist/queue.cjs.map +0 -1
  440. package/dist/queue.d.ts.map +0 -1
  441. package/dist/queue.test.d.ts +0 -3
  442. package/dist/queue.test.d.ts.map +0 -1
  443. package/dist/rabin-gf2-polynomial.cjs +0 -440
  444. package/dist/rabin-gf2-polynomial.cjs.map +0 -1
  445. package/dist/rabin-uncached.cjs +0 -90
  446. package/dist/rabin-uncached.cjs.map +0 -1
  447. package/dist/rabin.cjs +0 -128
  448. package/dist/rabin.cjs.map +0 -1
  449. package/dist/random.cjs +0 -48
  450. package/dist/random.cjs.map +0 -1
  451. package/dist/random.d.ts.map +0 -1
  452. package/dist/random.test.d.ts +0 -7
  453. package/dist/random.test.d.ts.map +0 -1
  454. package/dist/rollup.config.d.ts +0 -13
  455. package/dist/rollup.config.d.ts.map +0 -1
  456. package/dist/rsa-oaep.cjs +0 -112
  457. package/dist/rsa-oaep.cjs.map +0 -1
  458. package/dist/schema.cjs +0 -1223
  459. package/dist/schema.cjs.map +0 -1
  460. package/dist/schema.d.ts +0 -595
  461. package/dist/schema.d.ts.map +0 -1
  462. package/dist/schema.test.d.ts +0 -15
  463. package/dist/schema.test.d.ts.map +0 -1
  464. package/dist/set-5b47859e.cjs +0 -45
  465. package/dist/set-5b47859e.cjs.map +0 -1
  466. package/dist/set.cjs +0 -13
  467. package/dist/set.cjs.map +0 -1
  468. package/dist/set.d.ts.map +0 -1
  469. package/dist/set.test.d.ts +0 -3
  470. package/dist/set.test.d.ts.map +0 -1
  471. package/dist/sha256.cjs +0 -183
  472. package/dist/sha256.cjs.map +0 -1
  473. package/dist/sha256.node.cjs +0 -17
  474. package/dist/sha256.node.cjs.map +0 -1
  475. package/dist/sort-812cc211.cjs +0 -103
  476. package/dist/sort-812cc211.cjs.map +0 -1
  477. package/dist/sort.cjs +0 -13
  478. package/dist/sort.cjs.map +0 -1
  479. package/dist/sort.d.ts.map +0 -1
  480. package/dist/sort.test.d.ts +0 -7
  481. package/dist/sort.test.d.ts.map +0 -1
  482. package/dist/statistics-65f6114b.cjs +0 -32
  483. package/dist/statistics-65f6114b.cjs.map +0 -1
  484. package/dist/statistics.cjs +0 -12
  485. package/dist/statistics.cjs.map +0 -1
  486. package/dist/statistics.d.ts.map +0 -1
  487. package/dist/statistics.test.d.ts +0 -3
  488. package/dist/statistics.test.d.ts.map +0 -1
  489. package/dist/storage.cjs +0 -81
  490. package/dist/storage.cjs.map +0 -1
  491. package/dist/storage.d.ts.map +0 -1
  492. package/dist/storage.test.d.ts +0 -3
  493. package/dist/storage.test.d.ts.map +0 -1
  494. package/dist/string-fddc5f8b.cjs +0 -209
  495. package/dist/string-fddc5f8b.cjs.map +0 -1
  496. package/dist/string.cjs +0 -32
  497. package/dist/string.cjs.map +0 -1
  498. package/dist/string.d.ts +0 -28
  499. package/dist/string.d.ts.map +0 -1
  500. package/dist/string.test.d.ts +0 -9
  501. package/dist/string.test.d.ts.map +0 -1
  502. package/dist/symbol-9c439012.cjs +0 -29
  503. package/dist/symbol-9c439012.cjs.map +0 -1
  504. package/dist/symbol.cjs +0 -11
  505. package/dist/symbol.cjs.map +0 -1
  506. package/dist/symbol.d.ts.map +0 -1
  507. package/dist/symbol.test.d.ts +0 -3
  508. package/dist/symbol.test.d.ts.map +0 -1
  509. package/dist/testing.cjs +0 -709
  510. package/dist/testing.cjs.map +0 -1
  511. package/dist/testing.d.ts +0 -64
  512. package/dist/testing.d.ts.map +0 -1
  513. package/dist/testing.test.d.ts +0 -9
  514. package/dist/testing.test.d.ts.map +0 -1
  515. package/dist/time-d8438852.cjs +0 -63
  516. package/dist/time-d8438852.cjs.map +0 -1
  517. package/dist/time.cjs +0 -14
  518. package/dist/time.cjs.map +0 -1
  519. package/dist/time.d.ts.map +0 -1
  520. package/dist/time.test.d.ts +0 -4
  521. package/dist/time.test.d.ts.map +0 -1
  522. package/dist/trait/equality.d.ts +0 -6
  523. package/dist/trait/equality.d.ts.map +0 -1
  524. package/dist/trait/fingerprint.d.ts +0 -13
  525. package/dist/trait/fingerprint.d.ts.map +0 -1
  526. package/dist/trait/traits.d.ts +0 -3
  527. package/dist/trait/traits.d.ts.map +0 -1
  528. package/dist/trait/traits.test.d.ts +0 -5
  529. package/dist/trait/traits.test.d.ts.map +0 -1
  530. package/dist/traits.cjs +0 -31
  531. package/dist/traits.cjs.map +0 -1
  532. package/dist/tree-9f3c8837.cjs +0 -557
  533. package/dist/tree-9f3c8837.cjs.map +0 -1
  534. package/dist/tree.cjs +0 -10
  535. package/dist/tree.cjs.map +0 -1
  536. package/dist/tree.d.ts.map +0 -1
  537. package/dist/tree.test.d.ts +0 -2
  538. package/dist/tree.test.d.ts.map +0 -1
  539. package/dist/url.cjs +0 -46
  540. package/dist/url.cjs.map +0 -1
  541. package/dist/url.d.ts.map +0 -1
  542. package/dist/url.test.d.ts +0 -3
  543. package/dist/url.test.d.ts.map +0 -1
  544. package/dist/webcrypto.cjs +0 -12
  545. package/dist/webcrypto.cjs.map +0 -1
  546. package/dist/webcrypto.d.ts.map +0 -1
  547. package/dist/webcrypto.deno.cjs +0 -12
  548. package/dist/webcrypto.deno.cjs.map +0 -1
  549. package/dist/webcrypto.deno.d.ts.map +0 -1
  550. package/dist/webcrypto.node.cjs +0 -12
  551. package/dist/webcrypto.node.cjs.map +0 -1
  552. package/dist/webcrypto.node.d.ts.map +0 -1
  553. package/dist/webcrypto.react-native.cjs +0 -20
  554. package/dist/webcrypto.react-native.cjs.map +0 -1
  555. package/dist/webcrypto.react-native.d.ts.map +0 -1
  556. package/dist/websocket-b073d0fc.cjs +0 -157
  557. package/dist/websocket-b073d0fc.cjs.map +0 -1
  558. package/dist/websocket.cjs +0 -17
  559. package/dist/websocket.cjs.map +0 -1
  560. package/dist/websocket.d.ts.map +0 -1
  561. package/dom.d.ts +0 -60
  562. package/dom.d.ts.map +0 -1
  563. package/encoding.d.ts +0 -235
  564. package/encoding.d.ts.map +0 -1
  565. package/encoding.test.d.ts +0 -50
  566. package/encoding.test.d.ts.map +0 -1
  567. package/environment.d.ts.map +0 -1
  568. package/error.d.ts +0 -5
  569. package/error.d.ts.map +0 -1
  570. package/eventloop.d.ts +0 -16
  571. package/eventloop.d.ts.map +0 -1
  572. package/eventloop.test.d.ts +0 -10
  573. package/eventloop.test.d.ts.map +0 -1
  574. package/function.d.ts.map +0 -1
  575. package/function.test.d.ts +0 -5
  576. package/function.test.d.ts.map +0 -1
  577. package/hash/rabin-gf2-polynomial.d.ts +0 -45
  578. package/hash/rabin-gf2-polynomial.d.ts.map +0 -1
  579. package/hash/rabin-uncached.d.ts +0 -29
  580. package/hash/rabin-uncached.d.ts.map +0 -1
  581. package/hash/rabin.d.ts +0 -27
  582. package/hash/rabin.d.ts.map +0 -1
  583. package/hash/rabin.test.d.ts +0 -8
  584. package/hash/rabin.test.d.ts.map +0 -1
  585. package/hash/sha256.d.ts +0 -2
  586. package/hash/sha256.d.ts.map +0 -1
  587. package/hash/sha256.node.d.ts +0 -2
  588. package/hash/sha256.node.d.ts.map +0 -1
  589. package/hash/sha256.test.d.ts +0 -7
  590. package/hash/sha256.test.d.ts.map +0 -1
  591. package/index.d.ts +0 -35
  592. package/index.d.ts.map +0 -1
  593. package/index.js +0 -82
  594. package/indexeddb.d.ts +0 -34
  595. package/indexeddb.d.ts.map +0 -1
  596. package/indexeddb.test.d.ts +0 -3
  597. package/indexeddb.test.d.ts.map +0 -1
  598. package/indexeddbV2.d.ts +0 -35
  599. package/indexeddbV2.d.ts.map +0 -1
  600. package/indexeddbV2.test.d.ts +0 -3
  601. package/indexeddbV2.test.d.ts.map +0 -1
  602. package/isomorphic.js +0 -10
  603. package/iterator.d.ts +0 -5
  604. package/iterator.d.ts.map +0 -1
  605. package/json.d.ts +0 -23
  606. package/json.d.ts.map +0 -1
  607. package/list.d.ts +0 -55
  608. package/list.d.ts.map +0 -1
  609. package/list.test.d.ts +0 -6
  610. package/list.test.d.ts.map +0 -1
  611. package/logging.common.d.ts +0 -12
  612. package/logging.common.d.ts.map +0 -1
  613. package/logging.d.ts +0 -55
  614. package/logging.d.ts.map +0 -1
  615. package/logging.node.d.ts +0 -14
  616. package/logging.node.d.ts.map +0 -1
  617. package/logging.test.d.ts +0 -3
  618. package/logging.test.d.ts.map +0 -1
  619. package/map.d.ts +0 -8
  620. package/map.d.ts.map +0 -1
  621. package/map.test.d.ts +0 -4
  622. package/map.test.d.ts.map +0 -1
  623. package/math.d.ts +0 -23
  624. package/math.d.ts.map +0 -1
  625. package/math.test.d.ts +0 -3
  626. package/math.test.d.ts.map +0 -1
  627. package/metric.d.ts +0 -25
  628. package/metric.d.ts.map +0 -1
  629. package/metric.test.d.ts +0 -3
  630. package/metric.test.d.ts.map +0 -1
  631. package/mutex.d.ts +0 -3
  632. package/mutex.d.ts.map +0 -1
  633. package/mutex.test.d.ts +0 -3
  634. package/mutex.test.d.ts.map +0 -1
  635. package/number.d.ts.map +0 -1
  636. package/number.test.d.ts +0 -4
  637. package/number.test.d.ts.map +0 -1
  638. package/object.d.ts +0 -72
  639. package/object.d.ts.map +0 -1
  640. package/object.test.d.ts +0 -6
  641. package/object.test.d.ts.map +0 -1
  642. package/observable.d.ts +0 -86
  643. package/observable.d.ts.map +0 -1
  644. package/observable.test.d.ts +0 -3
  645. package/observable.test.d.ts.map +0 -1
  646. package/pair.d.ts +0 -22
  647. package/pair.d.ts.map +0 -1
  648. package/pair.test.d.ts +0 -3
  649. package/pair.test.d.ts.map +0 -1
  650. package/performance.d.ts +0 -4
  651. package/performance.d.ts.map +0 -1
  652. package/performance.node.d.ts +0 -14
  653. package/performance.node.d.ts.map +0 -1
  654. package/pledge.d.ts +0 -68
  655. package/pledge.d.ts.map +0 -1
  656. package/pledge.test.d.ts +0 -6
  657. package/pledge.test.d.ts.map +0 -1
  658. package/prng/Mt19937.d.ts +0 -29
  659. package/prng/Mt19937.d.ts.map +0 -1
  660. package/prng/Xoroshiro128plus.d.ts +0 -27
  661. package/prng/Xoroshiro128plus.d.ts.map +0 -1
  662. package/prng/Xorshift32.d.ts +0 -21
  663. package/prng/Xorshift32.d.ts.map +0 -1
  664. package/prng.d.ts +0 -44
  665. package/prng.d.ts.map +0 -1
  666. package/prng.test.d.ts +0 -6
  667. package/prng.test.d.ts.map +0 -1
  668. package/promise.d.ts +0 -22
  669. package/promise.d.ts.map +0 -1
  670. package/promise.test.d.ts +0 -5
  671. package/promise.test.d.ts.map +0 -1
  672. package/queue.d.ts +0 -34
  673. package/queue.d.ts.map +0 -1
  674. package/queue.test.d.ts +0 -3
  675. package/queue.test.d.ts.map +0 -1
  676. package/random.d.ts +0 -6
  677. package/random.d.ts.map +0 -1
  678. package/random.test.d.ts +0 -7
  679. package/random.test.d.ts.map +0 -1
  680. package/rollup.config.d.ts +0 -13
  681. package/rollup.config.d.ts.map +0 -1
  682. package/schema.d.ts.map +0 -1
  683. package/schema.test.d.ts +0 -15
  684. package/schema.test.d.ts.map +0 -1
  685. package/set.d.ts +0 -5
  686. package/set.d.ts.map +0 -1
  687. package/set.test.d.ts +0 -3
  688. package/set.test.d.ts.map +0 -1
  689. package/sort.d.ts +0 -4
  690. package/sort.d.ts.map +0 -1
  691. package/sort.test.d.ts +0 -7
  692. package/sort.test.d.ts.map +0 -1
  693. package/statistics.d.ts +0 -3
  694. package/statistics.d.ts.map +0 -1
  695. package/statistics.test.d.ts +0 -3
  696. package/statistics.test.d.ts.map +0 -1
  697. package/storage.d.ts +0 -15
  698. package/storage.d.ts.map +0 -1
  699. package/storage.test.d.ts +0 -3
  700. package/storage.test.d.ts.map +0 -1
  701. package/string.d.ts.map +0 -1
  702. package/string.test.d.ts +0 -9
  703. package/string.test.d.ts.map +0 -1
  704. package/symbol.d.ts +0 -11
  705. package/symbol.d.ts.map +0 -1
  706. package/symbol.test.d.ts +0 -3
  707. package/symbol.test.d.ts.map +0 -1
  708. package/test.d.ts +0 -2
  709. package/test.d.ts.map +0 -1
  710. package/test.html +0 -168
  711. package/test.js +0 -104
  712. package/testing.d.ts.map +0 -1
  713. package/testing.test.d.ts +0 -9
  714. package/testing.test.d.ts.map +0 -1
  715. package/time.d.ts +0 -9
  716. package/time.d.ts.map +0 -1
  717. package/time.test.d.ts +0 -4
  718. package/time.test.d.ts.map +0 -1
  719. package/trait/equality.d.ts +0 -6
  720. package/trait/equality.d.ts.map +0 -1
  721. package/trait/fingerprint.d.ts +0 -13
  722. package/trait/fingerprint.d.ts.map +0 -1
  723. package/trait/traits.d.ts +0 -3
  724. package/trait/traits.d.ts.map +0 -1
  725. package/trait/traits.test.d.ts +0 -5
  726. package/trait/traits.test.d.ts.map +0 -1
  727. package/tree.d.ts +0 -96
  728. package/tree.d.ts.map +0 -1
  729. package/tree.test.d.ts +0 -2
  730. package/tree.test.d.ts.map +0 -1
  731. package/url.d.ts +0 -7
  732. package/url.d.ts.map +0 -1
  733. package/url.test.d.ts +0 -3
  734. package/url.test.d.ts.map +0 -1
  735. package/webcrypto.d.ts +0 -3
  736. package/webcrypto.d.ts.map +0 -1
  737. package/webcrypto.deno.d.ts +0 -3
  738. package/webcrypto.deno.d.ts.map +0 -1
  739. package/webcrypto.node.d.ts +0 -3
  740. package/webcrypto.node.d.ts.map +0 -1
  741. package/webcrypto.react-native.d.ts +0 -3
  742. package/webcrypto.react-native.d.ts.map +0 -1
  743. package/websocket.d.ts +0 -38
  744. package/websocket.d.ts.map +0 -1
  745. /package/{bin → src/bin}/0ecdsa-generate-keypair.js +0 -0
  746. /package/{bin → src/bin}/0serve.js +0 -0
  747. /package/{bin → src/bin}/gendocs.js +0 -0
  748. /package/{bin → src/bin}/gentesthtml.js +0 -0
  749. /package/{broadcastchannel.js → src/broadcastchannel.js} +0 -0
  750. /package/{buffer.js → src/buffer.js} +0 -0
  751. /package/{cache.js → src/cache.js} +0 -0
  752. /package/{component.js → src/component.js} +0 -0
  753. /package/{conditions.js → src/conditions.js} +0 -0
  754. /package/{crypto → src/crypto}/aes-gcm.js +0 -0
  755. /package/{crypto → src/crypto}/common.js +0 -0
  756. /package/{crypto → src/crypto}/ecdsa.js +0 -0
  757. /package/{crypto → src/crypto}/jwt.js +0 -0
  758. /package/{crypto → src/crypto}/rsa-oaep.js +0 -0
  759. /package/{decoding.js → src/decoding.js} +0 -0
  760. /package/{delta → src/delta}/binding.js +0 -0
  761. /package/{delta → src/delta}/readme.md +0 -0
  762. /package/{diff → src/diff}/patience.js +0 -0
  763. /package/{diff.js → src/diff.js} +0 -0
  764. /package/{dom.js → src/dom.js} +0 -0
  765. /package/{encoding.js → src/encoding.js} +0 -0
  766. /package/{error.js → src/error.js} +0 -0
  767. /package/{eventloop.js → src/eventloop.js} +0 -0
  768. /package/{function.js → src/function.js} +0 -0
  769. /package/{hash → src/hash}/rabin-gf2-polynomial.js +0 -0
  770. /package/{hash → src/hash}/rabin-uncached.js +0 -0
  771. /package/{hash → src/hash}/sha256.js +0 -0
  772. /package/{hash → src/hash}/sha256.node.js +0 -0
  773. /package/{indexeddb.js → src/indexeddb.js} +0 -0
  774. /package/{indexeddbV2.js → src/indexeddbV2.js} +0 -0
  775. /package/{iterator.js → src/iterator.js} +0 -0
  776. /package/{json.js → src/json.js} +0 -0
  777. /package/{list.js → src/list.js} +0 -0
  778. /package/{logging.common.js → src/logging.common.js} +0 -0
  779. /package/{logging.js → src/logging.js} +0 -0
  780. /package/{logging.node.js → src/logging.node.js} +0 -0
  781. /package/{map.js → src/map.js} +0 -0
  782. /package/{math.js → src/math.js} +0 -0
  783. /package/{metric.js → src/metric.js} +0 -0
  784. /package/{mutex.js → src/mutex.js} +0 -0
  785. /package/{number.js → src/number.js} +0 -0
  786. /package/{object.js → src/object.js} +0 -0
  787. /package/{observable.js → src/observable.js} +0 -0
  788. /package/{pair.js → src/pair.js} +0 -0
  789. /package/{performance.js → src/performance.js} +0 -0
  790. /package/{performance.node.js → src/performance.node.js} +0 -0
  791. /package/{pledge.js → src/pledge.js} +0 -0
  792. /package/{prng → src/prng}/Mt19937.js +0 -0
  793. /package/{prng → src/prng}/Xoroshiro128plus.js +0 -0
  794. /package/{prng → src/prng}/Xorshift32.js +0 -0
  795. /package/{prng.js → src/prng.js} +0 -0
  796. /package/{promise.js → src/promise.js} +0 -0
  797. /package/{queue.js → src/queue.js} +0 -0
  798. /package/{random.js → src/random.js} +0 -0
  799. /package/{set.js → src/set.js} +0 -0
  800. /package/{sort.js → src/sort.js} +0 -0
  801. /package/{statistics.js → src/statistics.js} +0 -0
  802. /package/{storage.js → src/storage.js} +0 -0
  803. /package/{symbol.js → src/symbol.js} +0 -0
  804. /package/{time.js → src/time.js} +0 -0
  805. /package/{trait → src/trait}/equality.js +0 -0
  806. /package/{trait → src/trait}/fingerprint.js +0 -0
  807. /package/{trait → src/trait}/traits.js +0 -0
  808. /package/{tree.js → src/tree.js} +0 -0
  809. /package/{url.js → src/url.js} +0 -0
  810. /package/{webcrypto.deno.js → src/webcrypto.deno.js} +0 -0
  811. /package/{webcrypto.js → src/webcrypto.js} +0 -0
  812. /package/{webcrypto.node.js → src/webcrypto.node.js} +0 -0
  813. /package/{webcrypto.react-native.js → src/webcrypto.react-native.js} +0 -0
  814. /package/{websocket.js → src/websocket.js} +0 -0
  815. /package/{broadcastchannel.d.ts → types/broadcastchannel.d.ts} +0 -0
  816. /package/{buffer.d.ts → types/buffer.d.ts} +0 -0
  817. /package/{cache.d.ts → types/cache.d.ts} +0 -0
  818. /package/{component.d.ts → types/component.d.ts} +0 -0
  819. /package/{conditions.d.ts → types/conditions.d.ts} +0 -0
  820. /package/{decoding.d.ts → types/decoding.d.ts} +0 -0
  821. /package/{diff.d.ts → types/diff.d.ts} +0 -0
  822. /package/{dist → types}/dom.d.ts +0 -0
  823. /package/{dist → types}/encoding.d.ts +0 -0
  824. /package/{dist → types}/error.d.ts +0 -0
  825. /package/{dist → types}/eventloop.d.ts +0 -0
  826. /package/{dist → types}/indexeddb.d.ts +0 -0
  827. /package/{dist → types}/indexeddbV2.d.ts +0 -0
  828. /package/{dist → types}/iterator.d.ts +0 -0
  829. /package/{dist → types}/json.d.ts +0 -0
  830. /package/{dist → types}/list.d.ts +0 -0
  831. /package/{dist → types}/logging.common.d.ts +0 -0
  832. /package/{dist → types}/logging.d.ts +0 -0
  833. /package/{dist → types}/logging.node.d.ts +0 -0
  834. /package/{dist → types}/map.d.ts +0 -0
  835. /package/{dist → types}/math.d.ts +0 -0
  836. /package/{dist → types}/metric.d.ts +0 -0
  837. /package/{dist → types}/mutex.d.ts +0 -0
  838. /package/{dist → types}/object.d.ts +0 -0
  839. /package/{dist → types}/observable.d.ts +0 -0
  840. /package/{dist → types}/pair.d.ts +0 -0
  841. /package/{dist → types}/performance.d.ts +0 -0
  842. /package/{dist → types}/performance.node.d.ts +0 -0
  843. /package/{dist → types}/pledge.d.ts +0 -0
  844. /package/{dist → types}/prng.d.ts +0 -0
  845. /package/{dist → types}/promise.d.ts +0 -0
  846. /package/{dist → types}/queue.d.ts +0 -0
  847. /package/{dist → types}/random.d.ts +0 -0
  848. /package/{dist → types}/set.d.ts +0 -0
  849. /package/{dist → types}/sort.d.ts +0 -0
  850. /package/{dist → types}/statistics.d.ts +0 -0
  851. /package/{dist → types}/storage.d.ts +0 -0
  852. /package/{dist → types}/symbol.d.ts +0 -0
  853. /package/{dist → types}/time.d.ts +0 -0
  854. /package/{dist → types}/tree.d.ts +0 -0
  855. /package/{dist → types}/url.d.ts +0 -0
  856. /package/{dist → types}/webcrypto.d.ts +0 -0
  857. /package/{dist → types}/webcrypto.deno.d.ts +0 -0
  858. /package/{dist → types}/webcrypto.node.d.ts +0 -0
  859. /package/{dist → types}/webcrypto.react-native.d.ts +0 -0
  860. /package/{dist → types}/websocket.d.ts +0 -0
package/dist/delta.cjs DELETED
@@ -1,2409 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var list = require('./list.cjs');
6
- var object = require('./object-c0c9435b.cjs');
7
- var equality = require('./equality.cjs');
8
- var fingerprint = require('./fingerprint.cjs');
9
- var array$1 = require('./array-78849c95.cjs');
10
- var _function = require('./function-314580f7.cjs');
11
- var schema = require('./schema.cjs');
12
- var error = require('./error-0c1f634f.cjs');
13
- var math = require('./math-96d5e8c4.cjs');
14
- var rabin = require('./rabin.cjs');
15
- var encoding = require('./encoding-1a745c43.cjs');
16
- var buffer = require('./buffer-3e750729.cjs');
17
- var patience = require('./patience.cjs');
18
- var prng = require('./prng-37d48618.cjs');
19
- require('./set-5b47859e.cjs');
20
- require('./environment-1c97264d.cjs');
21
- require('./map-24d263c0.cjs');
22
- require('./string-fddc5f8b.cjs');
23
- require('./conditions-f5c0c102.cjs');
24
- require('./storage.cjs');
25
- require('./number-1fb57bba.cjs');
26
- require('./binary-ac8e39e2.cjs');
27
- require('./decoding-76e75827.cjs');
28
-
29
- /**
30
- * @beta this API is about to change
31
- *
32
- * ## Mutability
33
- *
34
- * Deltas are mutable by default. But references are often shared, by marking a Delta as "done". You
35
- * may only modify deltas by applying other deltas to them. Casting a Delta to a DeltaBuilder
36
- * manually, will likely modify "shared" state.
37
- */
38
-
39
- /**
40
- * @typedef {{
41
- * insert?: string[]
42
- * insertAt?: number
43
- * delete?: string[]
44
- * deleteAt?: number
45
- * format?: Record<string,string[]>
46
- * formatAt?: number
47
- * }} Attribution
48
- */
49
-
50
- /**
51
- * @type {s.Schema<Attribution>}
52
- */
53
- const $attribution = schema.$object({
54
- insert: schema.$array(schema.$string).optional,
55
- insertAt: schema.$number.optional,
56
- delete: schema.$array(schema.$string).optional,
57
- deleteAt: schema.$number.optional,
58
- format: schema.$record(schema.$string, schema.$array(schema.$string)).optional,
59
- formatAt: schema.$number.optional
60
- });
61
-
62
- /**
63
- * @typedef {s.Unwrap<$anyOp>} DeltaOps
64
- */
65
-
66
- /**
67
- * @typedef {{ [key: string]: any }} FormattingAttributes
68
- */
69
-
70
- /**
71
- * @typedef {{
72
- * type: 'delta',
73
- * name?: string,
74
- * attrs?: { [Key in string|number]: DeltaAttrOpJSON },
75
- * children?: Array<DeltaListOpJSON>
76
- * }} DeltaJSON
77
- */
78
-
79
- /**
80
- * @typedef {{ type: 'insert', insert: string|Array<any>, format?: { [key: string]: any }, attribution?: Attribution } | { delete: number } | { type: 'retain', retain: number, format?: { [key:string]: any }, attribution?: Attribution } | { type: 'modify', value: object }} DeltaListOpJSON
81
- */
82
-
83
- /**
84
- * @typedef {{ type: 'insert', value: any, prevValue?: any, attribution?: Attribution } | { type: 'delete', prevValue?: any, attribution?: Attribution } | { type: 'modify', value: DeltaJSON }} DeltaAttrOpJSON
85
- */
86
-
87
- /**
88
- * @typedef {TextOp|InsertOp<any>|DeleteOp|RetainOp|ModifyOp<any>} ChildrenOpAny
89
- */
90
-
91
- /**
92
- * @typedef {AttrInsertOp<any>|AttrDeleteOp<any>|AttrModifyOp} AttrOpAny
93
- */
94
-
95
- /**
96
- * @typedef {ChildrenOpAny|AttrOpAny} _OpAny
97
- */
98
-
99
- /**
100
- * @type {s.Schema<DeltaAttrOpJSON>}
101
- */
102
- const $deltaMapChangeJson = schema.$union(
103
- schema.$object({ type: schema.$literal('insert'), value: schema.$any, prevValue: schema.$any.optional, attribution: $attribution.optional }),
104
- schema.$object({ type: schema.$literal('modify'), value: schema.$any }),
105
- schema.$object({ type: schema.$literal('delete'), prevValue: schema.$any.optional, attribution: $attribution.optional })
106
- );
107
-
108
- /**
109
- * @template {{[key:string]: any} | null} Attrs
110
- * @param {Attrs} attrs
111
- * @return {Attrs}
112
- */
113
- const _cloneAttrs = attrs => attrs == null ? attrs : { ...attrs };
114
- /**
115
- * @template {any} MaybeDelta
116
- * @param {MaybeDelta} maybeDelta
117
- * @return {MaybeDelta}
118
- */
119
- const _markMaybeDeltaAsDone = maybeDelta => $deltaAny.check(maybeDelta) ? /** @type {MaybeDelta} */ (maybeDelta.done()) : maybeDelta;
120
-
121
- class TextOp extends list.ListNode {
122
- /**
123
- * @param {string} insert
124
- * @param {FormattingAttributes|null} format
125
- * @param {Attribution?} attribution
126
- */
127
- constructor (insert, format, attribution) {
128
- super();
129
- // Whenever this is modified, make sure to clear _fingerprint
130
- /**
131
- * @readonly
132
- * @type {string}
133
- */
134
- this.insert = insert;
135
- /**
136
- * @readonly
137
- * @type {FormattingAttributes|null}
138
- */
139
- this.format = format;
140
- this.attribution = attribution;
141
- /**
142
- * @type {string?}
143
- */
144
- this._fingerprint = null;
145
- }
146
-
147
- /**
148
- * @param {string} newVal
149
- */
150
- _updateInsert (newVal) {
151
- // @ts-ignore
152
- this.insert = newVal;
153
- this._fingerprint = null;
154
- }
155
-
156
- /**
157
- * @return {'insert'}
158
- */
159
- get type () {
160
- return 'insert'
161
- }
162
-
163
- get length () {
164
- return this.insert.length
165
- }
166
-
167
- get fingerprint () {
168
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
169
- encoding.writeVarUint(encoder, 0); // textOp type: 0
170
- encoding.writeVarString(encoder, this.insert);
171
- encoding.writeAny(encoder, this.format);
172
- })))
173
- }
174
-
175
- /**
176
- * Remove a part of the operation (similar to Array.splice)
177
- *
178
- * @param {number} offset
179
- * @param {number} len
180
- */
181
- _splice (offset, len) {
182
- this._fingerprint = null;
183
- // @ts-ignore
184
- this.insert = this.insert.slice(0, offset) + this.insert.slice(offset + len);
185
- return this
186
- }
187
-
188
- /**
189
- * @return {DeltaListOpJSON}
190
- */
191
- toJSON () {
192
- const { insert, format, attribution } = this;
193
- return object.assign(/** @type {{type: 'insert', insert: string}} */ ({ type: 'insert', insert }), format != null ? { format } : ({}), attribution != null ? { attribution } : ({}))
194
- }
195
-
196
- /**
197
- * @param {TextOp} other
198
- */
199
- [equality.EqualityTraitSymbol] (other) {
200
- return _function.equalityDeep(this.insert, other.insert) && _function.equalityDeep(this.format, other.format) && _function.equalityDeep(this.attribution, other.attribution)
201
- }
202
-
203
- /**
204
- * @return {TextOp}
205
- */
206
- clone (start = 0, end = this.length) {
207
- return new TextOp(this.insert.slice(start, end), _cloneAttrs(this.format), _cloneAttrs(this.attribution))
208
- }
209
- }
210
-
211
- /**
212
- * @template {fingerprintTrait.Fingerprintable} ArrayContent
213
- */
214
- class InsertOp extends list.ListNode {
215
- /**
216
- * @param {Array<ArrayContent>} insert
217
- * @param {FormattingAttributes|null} format
218
- * @param {Attribution?} attribution
219
- */
220
- constructor (insert, format, attribution) {
221
- super();
222
- /**
223
- * @readonly
224
- * @type {Array<ArrayContent>}
225
- */
226
- this.insert = insert;
227
- /**
228
- * @readonly
229
- * @type {FormattingAttributes?}
230
- */
231
- this.format = format;
232
- /**
233
- * @readonly
234
- * @type {Attribution?}
235
- */
236
- this.attribution = attribution;
237
- /**
238
- * @type {string?}
239
- */
240
- this._fingerprint = null;
241
- }
242
-
243
- /**
244
- * @param {ArrayContent} newVal
245
- */
246
- _updateInsert (newVal) {
247
- // @ts-ignore
248
- this.insert = newVal;
249
- this._fingerprint = null;
250
- }
251
-
252
- /**
253
- * @return {'insert'}
254
- */
255
- get type () {
256
- return 'insert'
257
- }
258
-
259
- get length () {
260
- return this.insert.length
261
- }
262
-
263
- /**
264
- * @param {number} i
265
- * @return {Extract<ArrayContent,DeltaAny>}
266
- */
267
- _modValue (i) {
268
- /**
269
- * @type {any}
270
- */
271
- let d = this.insert[i];
272
- this._fingerprint = null;
273
- $deltaAny.expect(d);
274
- if (d.isDone) {
275
- // @ts-ignore
276
- this.insert[i] = (d = clone(d));
277
- return d
278
- }
279
- return d
280
- }
281
-
282
- get fingerprint () {
283
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
284
- encoding.writeVarUint(encoder, 1); // insertOp type: 1
285
- encoding.writeVarUint(encoder, this.insert.length);
286
- this.insert.forEach(ins => {
287
- encoding.writeVarString(encoder, fingerprint.fingerprint(ins));
288
- });
289
- encoding.writeAny(encoder, this.format);
290
- })))
291
- }
292
-
293
- /**
294
- * Remove a part of the operation (similar to Array.splice)
295
- *
296
- * @param {number} offset
297
- * @param {number} len
298
- */
299
- _splice (offset, len) {
300
- this._fingerprint = null;
301
- this.insert.splice(offset, len);
302
- return this
303
- }
304
-
305
- /**
306
- * @return {DeltaListOpJSON}
307
- */
308
- toJSON () {
309
- const { insert, format, attribution } = this;
310
- return object.assign({ type: /** @type {'insert'} */ ('insert'), insert: insert.map(ins => $deltaAny.check(ins) ? ins.toJSON() : ins) }, format ? { format } : ({}), attribution != null ? { attribution } : ({}))
311
- }
312
-
313
- /**
314
- * @param {InsertOp<ArrayContent>} other
315
- */
316
- [equality.EqualityTraitSymbol] (other) {
317
- return _function.equalityDeep(this.insert, other.insert) && _function.equalityDeep(this.format, other.format) && _function.equalityDeep(this.attribution, other.attribution)
318
- }
319
-
320
- /**
321
- * @return {InsertOp<ArrayContent>}
322
- */
323
- clone (start = 0, end = this.length) {
324
- return new InsertOp(this.insert.slice(start, end).map(_markMaybeDeltaAsDone), _cloneAttrs(this.format), _cloneAttrs(this.attribution))
325
- }
326
- }
327
-
328
- /**
329
- * @template {fingerprintTrait.Fingerprintable} [Children=never]
330
- * @template {string} [Text=never]
331
- */
332
- class DeleteOp extends list.ListNode {
333
- /**
334
- * @param {number} len
335
- */
336
- constructor (len) {
337
- super();
338
- this.delete = len;
339
- /**
340
- * @type {(Children|Text) extends never ? null : (Delta<any,{},Children,Text>?)}
341
- */
342
- this.prevValue = null;
343
- /**
344
- * @type {string|null}
345
- */
346
- this._fingerprint = null;
347
- }
348
-
349
- /**
350
- * @return {'delete'}
351
- */
352
- get type () {
353
- return 'delete'
354
- }
355
-
356
- get length () {
357
- return 0
358
- }
359
-
360
- get fingerprint () {
361
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
362
- encoding.writeVarUint(encoder, 2); // deleteOp type: 2
363
- encoding.writeVarUint(encoder, this.delete);
364
- })))
365
- }
366
-
367
- /**
368
- * Remove a part of the operation (similar to Array.splice)
369
- *
370
- * @param {number} _offset
371
- * @param {number} len
372
- */
373
- _splice (_offset, len) {
374
- this.prevValue = /** @type {any} */ (this.prevValue?.slice(_offset, len) || null);
375
- this._fingerprint = null;
376
- this.delete -= len;
377
- return this
378
- }
379
-
380
- /**
381
- * @return {DeltaListOpJSON}
382
- */
383
- toJSON () {
384
- return { delete: this.delete }
385
- }
386
-
387
- /**
388
- * @param {DeleteOp} other
389
- */
390
- [equality.EqualityTraitSymbol] (other) {
391
- return this.delete === other.delete
392
- }
393
-
394
- clone (start = 0, end = this.delete) {
395
- return new DeleteOp(end - start)
396
- }
397
- }
398
-
399
- class RetainOp extends list.ListNode {
400
- /**
401
- * @param {number} retain
402
- * @param {FormattingAttributes|null} format
403
- * @param {Attribution?} attribution
404
- */
405
- constructor (retain, format, attribution) {
406
- super();
407
- /**
408
- * @readonly
409
- * @type {number}
410
- */
411
- this.retain = retain;
412
- /**
413
- * @readonly
414
- * @type {FormattingAttributes?}
415
- */
416
- this.format = format;
417
- /**
418
- * @readonly
419
- * @type {Attribution?}
420
- */
421
- this.attribution = attribution;
422
- /**
423
- * @type {string|null}
424
- */
425
- this._fingerprint = null;
426
- }
427
-
428
- /**
429
- * @return {'retain'}
430
- */
431
- get type () {
432
- return 'retain'
433
- }
434
-
435
- get length () {
436
- return this.retain
437
- }
438
-
439
- get fingerprint () {
440
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
441
- encoding.writeVarUint(encoder, 3); // retainOp type: 3
442
- encoding.writeVarUint(encoder, this.retain);
443
- encoding.writeAny(encoder, this.format);
444
- })))
445
- }
446
-
447
- /**
448
- * Remove a part of the operation (similar to Array.splice)
449
- *
450
- * @param {number} _offset
451
- * @param {number} len
452
- */
453
- _splice (_offset, len) {
454
- // @ts-ignore
455
- this.retain -= len;
456
- this._fingerprint = null;
457
- return this
458
- }
459
-
460
- /**
461
- * @return {DeltaListOpJSON}
462
- */
463
- toJSON () {
464
- const { retain, format, attribution } = this;
465
- return object.assign({ type: /** @type {'retain'} */ ('retain'), retain }, format ? { format } : {}, attribution != null ? { attribution } : {})
466
- }
467
-
468
- /**
469
- * @param {RetainOp} other
470
- */
471
- [equality.EqualityTraitSymbol] (other) {
472
- return this.retain === other.retain && _function.equalityDeep(this.format, other.format) && _function.equalityDeep(this.attribution, other.attribution)
473
- }
474
-
475
- clone (start = 0, end = this.retain) {
476
- return new RetainOp(end - start, _cloneAttrs(this.format), _cloneAttrs(this.attribution))
477
- }
478
- }
479
-
480
- /**
481
- * Delta that can be applied on a YType Embed
482
- *
483
- * @template {DeltaAny} [DTypes=DeltaAny]
484
- */
485
- class ModifyOp extends list.ListNode {
486
- /**
487
- * @param {DTypes} delta
488
- * @param {FormattingAttributes|null} format
489
- * @param {Attribution?} attribution
490
- */
491
- constructor (delta, format, attribution) {
492
- super();
493
- /**
494
- * @readonly
495
- * @type {DTypes}
496
- */
497
- this.value = delta;
498
- /**
499
- * @readonly
500
- * @type {FormattingAttributes?}
501
- */
502
- this.format = format;
503
- /**
504
- * @readonly
505
- * @type {Attribution?}
506
- */
507
- this.attribution = attribution;
508
- /**
509
- * @type {string|null}
510
- */
511
- this._fingerprint = null;
512
- }
513
-
514
- /**
515
- * @return {'modify'}
516
- */
517
- get type () {
518
- return 'modify'
519
- }
520
-
521
- get length () {
522
- return 1
523
- }
524
-
525
- /**
526
- * @type {DeltaBuilderAny}
527
- */
528
- get _modValue () {
529
- /**
530
- * @type {any}
531
- */
532
- const d = this.value;
533
- this._fingerprint = null;
534
- if (d.isDone) {
535
- // @ts-ignore
536
- return (this.value = clone(d))
537
- }
538
- return d
539
- }
540
-
541
- get fingerprint () {
542
- // don't cache fingerprint because we don't know when delta changes
543
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
544
- encoding.writeVarUint(encoder, 4); // modifyOp type: 4
545
- encoding.writeVarString(encoder, this.value.fingerprint);
546
- encoding.writeAny(encoder, this.format);
547
- })))
548
- }
549
-
550
- /**
551
- * Remove a part of the operation (similar to Array.splice)
552
- *
553
- * @param {number} _offset
554
- * @param {number} _len
555
- */
556
- _splice (_offset, _len) {
557
- return this
558
- }
559
-
560
- /**
561
- * @return {DeltaListOpJSON}
562
- */
563
- toJSON () {
564
- const { value, attribution, format } = this;
565
- return object.assign({ type: /** @type {'modify'} */ ('modify'), value: value.toJSON() }, format ? { format } : {}, attribution != null ? { attribution } : {})
566
- }
567
-
568
- /**
569
- * @param {ModifyOp<any>} other
570
- */
571
- [equality.EqualityTraitSymbol] (other) {
572
- return this.value[equality.EqualityTraitSymbol](other.value) && _function.equalityDeep(this.format, other.format) && _function.equalityDeep(this.attribution, other.attribution)
573
- }
574
-
575
- /**
576
- * @return {ModifyOp<DTypes>}
577
- */
578
- clone () {
579
- return new ModifyOp(/** @type {DTypes} */ (this.value.done()), _cloneAttrs(this.format), _cloneAttrs(this.attribution))
580
- }
581
- }
582
-
583
- /**
584
- * @template {fingerprintTrait.Fingerprintable} V
585
- * @template {string|number} [K=any]
586
- */
587
- class AttrInsertOp {
588
- /**
589
- * @param {K} key
590
- * @param {V} value
591
- * @param {V|undefined} prevValue
592
- * @param {Attribution?} attribution
593
- */
594
- constructor (key, value, prevValue, attribution) {
595
- /**
596
- * @readonly
597
- * @type {K}
598
- */
599
- this.key = key;
600
- /**
601
- * @readonly
602
- * @type {V}
603
- */
604
- this.value = value;
605
- /**
606
- * @readonly
607
- * @type {V|undefined}
608
- */
609
- this.prevValue = prevValue;
610
- /**
611
- * @readonly
612
- * @type {Attribution?}
613
- */
614
- this.attribution = attribution;
615
- /**
616
- * @type {string|null}
617
- */
618
- this._fingerprint = null;
619
- }
620
-
621
- /**
622
- * @return {'insert'}
623
- */
624
- get type () { return 'insert' }
625
-
626
- /**
627
- * @type {DeltaBuilderAny}
628
- */
629
- get _modValue () {
630
- /**
631
- * @type {any}
632
- */
633
- const v = this.value;
634
- this._fingerprint = null;
635
- if ($deltaAny.check(v) && v.isDone) {
636
- // @ts-ignore
637
- return (this.value = clone(v))
638
- }
639
- return v
640
- }
641
-
642
- get fingerprint () {
643
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
644
- encoding.writeVarUint(encoder, 5); // map insert type: 5
645
- encoding.writeAny(encoder, this.key);
646
- if ($deltaAny.check(this.value)) {
647
- encoding.writeUint8(encoder, 0);
648
- encoding.writeVarString(encoder, this.value.fingerprint);
649
- } else {
650
- encoding.writeUint8(encoder, 1);
651
- encoding.writeAny(encoder, this.value);
652
- }
653
- })))
654
- }
655
-
656
- toJSON () {
657
- const v = this.value;
658
- const prevValue = this.prevValue;
659
- const attribution = this.attribution;
660
- return object.assign({
661
- type: this.type,
662
- value: $deltaAny.check(v) ? v.toJSON() : v
663
- }, attribution != null ? { attribution } : {}, prevValue !== undefined ? { prevValue } : {})
664
- }
665
-
666
- /**
667
- * @param {AttrInsertOp<V>} other
668
- */
669
- [equality.EqualityTraitSymbol] (other) {
670
- return this.key === other.key && _function.equalityDeep(this.value, other.value) && _function.equalityDeep(this.attribution, other.attribution)
671
- }
672
-
673
- /**
674
- * @return {AttrInsertOp<V,K>}
675
- */
676
- clone () {
677
- return new AttrInsertOp(this.key, _markMaybeDeltaAsDone(this.value), _markMaybeDeltaAsDone(this.prevValue), _cloneAttrs(this.attribution))
678
- }
679
- }
680
-
681
- /**
682
- * @template V
683
- * @template {string|number} [K=string]
684
- */
685
- class AttrDeleteOp {
686
- /**
687
- * @param {K} key
688
- * @param {V|undefined} prevValue
689
- * @param {Attribution?} attribution
690
- */
691
- constructor (key, prevValue, attribution) {
692
- /**
693
- * @type {K}
694
- */
695
- this.key = key;
696
- /**
697
- * @type {V|undefined}
698
- */
699
- this.prevValue = prevValue;
700
- this.attribution = attribution;
701
- /**
702
- * @type {string|null}
703
- */
704
- this._fingerprint = null;
705
- }
706
-
707
- get value () { return undefined }
708
-
709
- /**
710
- * @type {'delete'}
711
- */
712
- get type () { return 'delete' }
713
-
714
- get fingerprint () {
715
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
716
- encoding.writeVarUint(encoder, 6); // map delete type: 6
717
- encoding.writeAny(encoder, this.key);
718
- })))
719
- }
720
-
721
- /**
722
- * @return {DeltaAttrOpJSON}
723
- */
724
- toJSON () {
725
- const {
726
- type, attribution, prevValue
727
- } = this;
728
- return object.assign({ type }, attribution != null ? { attribution } : {}, prevValue !== undefined ? { prevValue } : {})
729
- }
730
-
731
- /**
732
- * @param {AttrDeleteOp<V>} other
733
- */
734
- [equality.EqualityTraitSymbol] (other) {
735
- return this.key === other.key && _function.equalityDeep(this.attribution, other.attribution)
736
- }
737
-
738
- clone () {
739
- return new AttrDeleteOp(this.key, _markMaybeDeltaAsDone(this.prevValue), _cloneAttrs(this.attribution))
740
- }
741
- }
742
-
743
- /**
744
- * @template {DeltaAny} [Modifier=DeltaAny]
745
- * @template {string|number} [K=string]
746
- */
747
- class AttrModifyOp {
748
- /**
749
- * @param {K} key
750
- * @param {Modifier} delta
751
- */
752
- constructor (key, delta) {
753
- /**
754
- * @readonly
755
- * @type {K}
756
- */
757
- this.key = key;
758
- /**
759
- * @readonly
760
- * @type {Modifier}
761
- */
762
- this.value = delta;
763
- /**
764
- * @type {string|null}
765
- */
766
- this._fingerprint = null;
767
- }
768
-
769
- /**
770
- * @type {'modify'}
771
- */
772
- get type () { return 'modify' }
773
-
774
- get fingerprint () {
775
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
776
- encoding.writeVarUint(encoder, 7); // map modify type: 7
777
- encoding.writeAny(encoder, this.key);
778
- encoding.writeVarString(encoder, this.value.fingerprint);
779
- })))
780
- }
781
-
782
- /**
783
- * @return {DeltaBuilder}
784
- */
785
- get _modValue () {
786
- this._fingerprint = null;
787
- if (this.value.isDone) {
788
- // @ts-ignore
789
- this.value = /** @type {any} */ (clone(this.value));
790
- }
791
- // @ts-ignore
792
- return this.value
793
- }
794
-
795
- /**
796
- * @return {DeltaAttrOpJSON}
797
- */
798
- toJSON () {
799
- return {
800
- type: this.type,
801
- value: this.value.toJSON()
802
- }
803
- }
804
-
805
- /**
806
- * @param {AttrModifyOp<Modifier>} other
807
- */
808
- [equality.EqualityTraitSymbol] (other) {
809
- return this.key === other.key && this.value[equality.EqualityTraitSymbol](other.value)
810
- }
811
-
812
- /**
813
- * @return {AttrModifyOp<Modifier,K>}
814
- */
815
- clone () {
816
- return new AttrModifyOp(this.key, /** @type {Modifier} */ (this.value.done()))
817
- }
818
- }
819
-
820
- /**
821
- * @type {s.Schema<AttrDeleteOp<any> | DeleteOp>}
822
- */
823
- const $deleteOp = schema.$custom(o => o != null && (o.constructor === DeleteOp || o.constructor === AttrDeleteOp));
824
-
825
- /**
826
- * @type {s.Schema<AttrInsertOp<any> | InsertOp<any>>}
827
- */
828
- const $insertOp = schema.$custom(o => o != null && (o.constructor === AttrInsertOp || o.constructor === InsertOp));
829
-
830
- /**
831
- * @template {fingerprintTrait.Fingerprintable} Content
832
- * @param {s.Schema<Content>} $content
833
- * @return {s.Schema<AttrInsertOp<Content> | InsertOp<Content>>}
834
- */
835
- const $insertOpWith = $content => schema.$custom(o =>
836
- o != null && (
837
- (o.constructor === AttrInsertOp && $content.check(/** @type {AttrInsertOp<Content>} */ (o).value)) ||
838
- (o.constructor === InsertOp && /** @type {InsertOp<Content>} */ (o).insert.every(ins => $content.check(ins)))
839
- )
840
- );
841
-
842
- /**
843
- * @type {s.Schema<TextOp>}
844
- */
845
- const $textOp = schema.$constructedBy(TextOp);
846
-
847
- /**
848
- * @type {s.Schema<RetainOp>}
849
- */
850
- const $retainOp = schema.$constructedBy(RetainOp);
851
-
852
- /**
853
- * @type {s.Schema<AttrModifyOp | ModifyOp>}
854
- */
855
- const $modifyOp = schema.$custom(o => o != null && (o.constructor === AttrModifyOp || o.constructor === ModifyOp));
856
-
857
- /**
858
- * @template {DeltaAny} Modify
859
- * @param {s.Schema<Modify>} $content
860
- * @return {s.Schema<AttrModifyOp<Modify> | ModifyOp<Modify>>}
861
- */
862
- const $modifyOpWith = $content => schema.$custom(o =>
863
- o != null && (
864
- (o.constructor === AttrModifyOp && $content.check(/** @type {AttrModifyOp<Modify>} */ (o).value)) ||
865
- (o.constructor === ModifyOp && $content.check(/** @type {ModifyOp<Modify>} */ (o).value))
866
- )
867
- );
868
-
869
- const $anyOp = schema.$union($insertOp, $deleteOp, $textOp, $modifyOp);
870
-
871
- /**
872
- * @template {Array<any>|string} C1
873
- * @template {Array<any>|string} C2
874
- * @typedef {Extract<C1 | C2, Array<any>> extends never
875
- * ? never
876
- * : (Array<(Extract<C1 | C2,Array<any>> extends Array<infer AC1> ? (unknown extends AC1 ? never : AC1) : never)>)} MergeListArrays
877
- */
878
-
879
- /**
880
- * @template {{[Key in string|number]: any}} Attrs
881
- * @template {string|number} Key
882
- * @template {any} Val
883
- * @typedef {{ [K in (Key | keyof Attrs)]: (unknown extends Attrs[K] ? never : Attrs[K]) | (Key extends K ? Val : never) }} AddToAttrs
884
- */
885
-
886
- /**
887
- * @template {{[Key in string|number|symbol]: any}} Attrs
888
- * @template {{[Key in string|number|symbol]: any}} NewAttrs
889
- * @typedef {{ [K in (keyof NewAttrs | keyof Attrs)]: (unknown extends Attrs[K] ? never : Attrs[K]) | (unknown extends NewAttrs[K] ? never : NewAttrs[K]) }} MergeAttrs
890
- */
891
-
892
- /**
893
- * @template X
894
- * @typedef {0 extends (1 & X) ? null : X} _AnyToNull
895
- */
896
-
897
- /**
898
- * @template {s.Schema<Delta<any,any,any,any,any>>|null} Schema
899
- * @typedef {_AnyToNull<Schema> extends null ? Delta<any,{[key:string|number]:any},any,string> : (Schema extends s.Schema<infer D> ? D : never)} AllowedDeltaFromSchema
900
- */
901
-
902
- /**
903
- * @typedef {Delta<any,{ [k:string|number]: any },any,any,any>} DeltaAny
904
- */
905
- /**
906
- * @typedef {DeltaBuilder<any,{ [k:string|number]: any },any,any,any>} DeltaBuilderAny
907
- */
908
-
909
- /**
910
- * @template {string} [NodeName=any]
911
- * @template {{[k:string|number]:any}} [Attrs={}]
912
- * @template {fingerprintTrait.Fingerprintable} [Children=never]
913
- * @template {string} [Text=never]
914
- * @template {s.Schema<Delta<any,any,any,any,any>>|null} [Schema=any]
915
- */
916
- class Delta {
917
- /**
918
- * @param {NodeName} [name]
919
- * @param {Schema} [$schema]
920
- */
921
- constructor (name, $schema) {
922
- this.name = name || null;
923
- this.$schema = $schema || null;
924
- /**
925
- * @type {{ [K in keyof Attrs]?: K extends string|number ? (AttrInsertOp<Attrs[K],K>|AttrDeleteOp<Attrs[K],K>|(Delta extends Attrs[K] ? AttrModifyOp<Extract<Attrs[K],DeltaAny>,K> : never)) : never }
926
- * & { [Symbol.iterator]: () => Iterator<{ [K in keyof Attrs]: K extends string|number ? (AttrInsertOp<Attrs[K],K>|AttrDeleteOp<Attrs[K],K>|(Delta extends Attrs[K] ? AttrModifyOp<Extract<Attrs[K],DeltaAny>,K> : never)) : never }[keyof Attrs]> }
927
- * }
928
- */
929
- this.attrs = /** @type {any} */ ({
930
- * [Symbol.iterator] () {
931
- for (const k in this) {
932
- yield this[k];
933
- }
934
- }
935
- });
936
-
937
- /**
938
- * @type {list.List<
939
- * RetainOp
940
- * | DeleteOp
941
- * | (Text extends never ? never : TextOp)
942
- * | (Children extends never ? never : InsertOp<Children>)
943
- * | (Delta extends Children ? ModifyOp<Extract<Children,Delta<any,any,any,any,any>>> : never)
944
- * >}
945
- */
946
- this.children = /** @type {any} */ (list.create());
947
- this.childCnt = 0;
948
- /**
949
- * @type {any}
950
- */
951
- this.origin = null;
952
- /**
953
- * @type {string|null}
954
- */
955
- this._fingerprint = null;
956
- this.isDone = false;
957
- }
958
-
959
- /**
960
- * @type {string}
961
- */
962
- get fingerprint () {
963
- return this._fingerprint || (this._fingerprint = buffer.toBase64(encoding.encode(encoder => {
964
- encoding.writeUint32(encoder, 0xf2ae5680); // "magic number" that ensures that different types of content don't yield the same fingerprint
965
- encoding.writeAny(encoder, this.name);
966
- /**
967
- * @type {Array<number|string>}
968
- */
969
- const keys = [];
970
- for (const attr of this.attrs) {
971
- keys.push(attr.key);
972
- }
973
- keys.sort((a, b) => {
974
- const aIsString = schema.$string.check(a);
975
- const bIsString = schema.$string.check(b);
976
- // numbers first
977
- // in ascending order
978
- return (aIsString && bIsString)
979
- ? a.localeCompare(b)
980
- : (aIsString ? 1 : (bIsString ? -1 : (a - b)))
981
- });
982
- encoding.writeVarUint(encoder, keys.length);
983
- for (const key of keys) {
984
- encoding.writeVarString(encoder, /** @type {any} */ (this.attrs[/** @type {keyof Attrs} */ (key)]).fingerprint);
985
- }
986
- encoding.writeVarUint(encoder, this.children.len);
987
- for (const child of this.children) {
988
- encoding.writeVarString(encoder, child.fingerprint);
989
- }
990
- return buffer.toBase64(rabin.fingerprint(rabin.StandardIrreducible128, encoding.toUint8Array(encoder)))
991
- })))
992
- }
993
-
994
- [fingerprint.FingerprintTraitSymbol] () {
995
- return this.fingerprint
996
- }
997
-
998
- isEmpty () {
999
- return object.isEmpty(this.attrs) && list.isEmpty(this.children)
1000
- }
1001
-
1002
- /**
1003
- * @return {DeltaJSON}
1004
- */
1005
- toJSON () {
1006
- const name = this.name;
1007
- /**
1008
- * @type {any}
1009
- */
1010
- const attrs = {};
1011
- /**
1012
- * @type {any}
1013
- */
1014
- const children = [];
1015
- for (const attr of this.attrs) {
1016
- attrs[attr.key] = attr.toJSON();
1017
- }
1018
- this.children.forEach(val => {
1019
- children.push(val.toJSON());
1020
- });
1021
- return object.assign(
1022
- { type: /** @type {'delta'} */ ('delta') },
1023
- (name != null ? { name } : {}),
1024
- (object.isEmpty(attrs) ? {} : { attrs }),
1025
- (children.length > 0 ? { children } : {})
1026
- )
1027
- }
1028
-
1029
- /**
1030
- * @param {Delta<any,any,any,any,any>} other
1031
- * @return {boolean}
1032
- */
1033
- equals (other) {
1034
- return this[equality.EqualityTraitSymbol](other)
1035
- }
1036
-
1037
- /**
1038
- * @param {any} other
1039
- * @return {boolean}
1040
- */
1041
- [equality.EqualityTraitSymbol] (other) {
1042
- // @todo it is only necessary to compare finrerprints OR do a deep equality check (remove
1043
- // childCnt as well)
1044
- return this.name === other.name && _function.equalityDeep(this.attrs, other.attrs) && _function.equalityDeep(this.children, other.children) && this.childCnt === other.childCnt
1045
- }
1046
-
1047
- /**
1048
- * @return {DeltaBuilder<NodeName,Attrs,Children,Text,Schema>}
1049
- */
1050
- clone () {
1051
- return this.slice(0, this.childCnt)
1052
- }
1053
-
1054
- /**
1055
- * @param {number} start
1056
- * @param {number} end
1057
- * @return {DeltaBuilder<NodeName,Attrs,Children,Text,Schema>}
1058
- */
1059
- slice (start = 0, end = this.childCnt) {
1060
- const cpy = /** @type {DeltaAny} */ (new DeltaBuilder(/** @type {any} */ (this.name), this.$schema));
1061
- cpy.origin = this.origin;
1062
- // copy attrs
1063
- for (const op of this.attrs) {
1064
- cpy.attrs[op.key] = /** @type {any} */ (op.clone());
1065
- }
1066
- // copy children
1067
- const slicedLen = end - start;
1068
- let remainingLen = slicedLen;
1069
- /**
1070
- * @type {ChildrenOpAny?}
1071
- */
1072
- let currNode = this.children.start;
1073
- let currNodeOffset = 0;
1074
- while (start > 0 && currNode != null) {
1075
- if (currNode.length <= start) {
1076
- start -= currNode.length;
1077
- currNode = currNode.next;
1078
- } else {
1079
- currNodeOffset = start;
1080
- start = 0;
1081
- }
1082
- }
1083
- if (currNodeOffset > 0 && currNode) {
1084
- const ncpy = currNode.clone(currNodeOffset, currNodeOffset + math.min(remainingLen, currNode.length - currNodeOffset));
1085
- list.pushEnd(cpy.children, ncpy);
1086
- remainingLen -= ncpy.length;
1087
- currNode = currNode.next;
1088
- }
1089
- while (currNode != null && currNode.length <= remainingLen) {
1090
- list.pushEnd(cpy.children, currNode.clone());
1091
- currNode = currNode.next;
1092
- }
1093
- if (currNode != null && remainingLen > 0) {
1094
- list.pushEnd(cpy.children, currNode.clone(0, remainingLen));
1095
- }
1096
- cpy.childCnt = slicedLen - remainingLen;
1097
- // @ts-ignore
1098
- return cpy
1099
- }
1100
-
1101
- /**
1102
- * Mark this delta as done and perform some cleanup (e.g. remove appended retains without
1103
- * formats&attributions). In the future, there might be additional merge operations that can be
1104
- * performed to result in smaller deltas. Set `markAsDone=false` to only perform the cleanup.
1105
- *
1106
- * @return {Delta<NodeName,Attrs,Children,Text,Schema>}
1107
- */
1108
- done (markAsDone = true) {
1109
- if (!this.isDone) {
1110
- this.isDone = markAsDone;
1111
- const cs = this.children;
1112
- for (let end = cs.end; end !== null && $retainOp.check(end) && end.format == null && end.attribution == null; end = cs.end) {
1113
- this.childCnt -= end.length;
1114
- list.popEnd(cs);
1115
- }
1116
- }
1117
- return this
1118
- }
1119
- }
1120
-
1121
- /**
1122
- * @template {DeltaAny} D
1123
- * @param {D} d
1124
- * @return {D extends DeltaBuilder<infer NodeName,infer Attrs,infer Children,infer Text,infer Schema> ? DeltaBuilder<NodeName,Attrs,Children,Text,Schema> : never}
1125
- */
1126
- const clone = d => /** @type {any} */ (d.slice(0, d.childCnt));
1127
-
1128
- /**
1129
- * Try merging this op with the previous op
1130
- * @param {list.List<any>} parent
1131
- * @param {InsertOp<any>|RetainOp|DeleteOp|TextOp|ModifyOp<any>} op
1132
- */
1133
- const tryMergeWithPrev = (parent, op) => {
1134
- const prevOp = op.prev;
1135
- if (
1136
- prevOp?.constructor !== op.constructor ||
1137
- (
1138
- (!$deleteOp.check(op) && !$modifyOp.check(op)) && (!_function.equalityDeep(op.format, /** @type {InsertOp<any>} */ (prevOp).format) || !_function.equalityDeep(op.attribution, /** @type {InsertOp<any>} */ (prevOp).attribution))
1139
- )
1140
- ) {
1141
- // constructor mismatch or format/attribution mismatch
1142
- return
1143
- }
1144
- // can be merged
1145
- if ($insertOp.check(op)) {
1146
- /** @type {InsertOp<any>} */ (prevOp).insert.push(...op.insert);
1147
- } else if ($retainOp.check(op)) {
1148
- // @ts-ignore
1149
- /** @type {RetainOp} */ (prevOp).retain += op.retain;
1150
- } else if ($deleteOp.check(op)) {
1151
- /** @type {DeleteOp} */ (prevOp).delete += op.delete;
1152
- } else if ($textOp.check(op)) {
1153
- /** @type {TextOp} */ (prevOp)._updateInsert(/** @type {TextOp} */ (prevOp).insert + op.insert);
1154
- } else {
1155
- error.unexpectedCase();
1156
- }
1157
- list.remove(parent, op);
1158
- };
1159
-
1160
- /**
1161
- * Ensures that the delta can be edited. clears _fingerprint cache.
1162
- *
1163
- * @param {any} d
1164
- */
1165
- const modDeltaCheck = d => {
1166
- if (d.isDone) {
1167
- /**
1168
- * You tried to modify a delta after it has been marked as "done".
1169
- */
1170
- throw error.create("Readonly Delta can't be modified")
1171
- }
1172
- d._fingerprint = null;
1173
- };
1174
-
1175
- /**
1176
- * @template {string} [NodeName=any]
1177
- * @template {{[key:string|number]:any}} [Attrs={}]
1178
- * @template {fingerprintTrait.Fingerprintable} [Children=never]
1179
- * @template {string} [Text=never]
1180
- * @template {s.Schema<Delta<any,any,any,any,any>>|null} [Schema=any]
1181
- * @extends {Delta<NodeName,Attrs,Children,Text,Schema>}
1182
- */
1183
- class DeltaBuilder extends Delta {
1184
- /**
1185
- * @param {NodeName} [name]
1186
- * @param {Schema} [$schema]
1187
- */
1188
- constructor (name, $schema) {
1189
- super(name, $schema);
1190
- /**
1191
- * @type {FormattingAttributes?}
1192
- */
1193
- this.usedAttributes = null;
1194
- /**
1195
- * @type {Attribution?}
1196
- */
1197
- this.usedAttribution = null;
1198
- }
1199
-
1200
- /**
1201
- * @param {Attribution?} attribution
1202
- */
1203
- useAttribution (attribution) {
1204
- modDeltaCheck(this);
1205
- this.usedAttribution = attribution;
1206
- return this
1207
- }
1208
-
1209
- /**
1210
- * @param {FormattingAttributes?} attributes
1211
- * @return {this}
1212
- */
1213
- useAttributes (attributes) {
1214
- modDeltaCheck(this);
1215
- this.usedAttributes = attributes;
1216
- return this
1217
- }
1218
-
1219
- /**
1220
- * @param {string} name
1221
- * @param {any} value
1222
- */
1223
- updateUsedAttributes (name, value) {
1224
- modDeltaCheck(this);
1225
- if (value == null) {
1226
- this.usedAttributes = object.assign({}, this.usedAttributes);
1227
- delete this.usedAttributes?.[name];
1228
- if (object.isEmpty(this.usedAttributes)) {
1229
- this.usedAttributes = null;
1230
- }
1231
- } else if (!_function.equalityDeep(this.usedAttributes?.[name], value)) {
1232
- this.usedAttributes = object.assign({}, this.usedAttributes);
1233
- this.usedAttributes[name] = value;
1234
- }
1235
- return this
1236
- }
1237
-
1238
- /**
1239
- * @template {keyof Attribution} NAME
1240
- * @param {NAME} name
1241
- * @param {Attribution[NAME]?} value
1242
- */
1243
- updateUsedAttribution (name, value) {
1244
- modDeltaCheck(this);
1245
- if (value == null) {
1246
- this.usedAttribution = object.assign({}, this.usedAttribution);
1247
- delete this.usedAttribution?.[name];
1248
- if (object.isEmpty(this.usedAttribution)) {
1249
- this.usedAttribution = null;
1250
- }
1251
- } else if (!_function.equalityDeep(this.usedAttribution?.[name], value)) {
1252
- this.usedAttribution = object.assign({}, this.usedAttribution);
1253
- this.usedAttribution[name] = value;
1254
- }
1255
- return this
1256
- }
1257
-
1258
- /**
1259
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,any,infer Children,infer Text,infer Schema> ? ((Children extends never ? never : Array<Children>) | Text) : never} NewContent
1260
- * @param {NewContent} insert
1261
- * @param {FormattingAttributes?} [formatting]
1262
- * @param {Attribution?} [attribution]
1263
- * @return {DeltaBuilder<
1264
- * NodeName,
1265
- * Attrs,
1266
- * Exclude<NewContent,string>[number]|Children,
1267
- * (Extract<NewContent,string>|Text) extends never ? never : string,
1268
- * Schema
1269
- * >}
1270
- */
1271
- insert (insert, formatting = null, attribution = null) {
1272
- modDeltaCheck(this);
1273
- const mergedAttributes = mergeAttrs(this.usedAttributes, formatting);
1274
- const mergedAttribution = mergeAttrs(this.usedAttribution, attribution);
1275
- /**
1276
- * @param {TextOp | InsertOp<any>} lastOp
1277
- */
1278
- const checkMergedEquals = lastOp => (mergedAttributes === lastOp.format || _function.equalityDeep(mergedAttributes, lastOp.format)) && (mergedAttribution === lastOp.attribution || _function.equalityDeep(mergedAttribution, lastOp.attribution));
1279
- const end = this.children.end;
1280
- if (schema.$string.check(insert)) {
1281
- if ($textOp.check(end) && checkMergedEquals(end)) {
1282
- end._updateInsert(end.insert + insert);
1283
- } else if (insert.length > 0) {
1284
- list.pushEnd(this.children, new TextOp(insert, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution));
1285
- }
1286
- this.childCnt += insert.length;
1287
- } else if (array$1.isArray(insert)) {
1288
- if ($insertOp.check(end) && checkMergedEquals(end)) {
1289
- // @ts-ignore
1290
- end.insert.push(...insert);
1291
- end._fingerprint = null;
1292
- } else if (insert.length > 0) {
1293
- list.pushEnd(this.children, new InsertOp(insert, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution));
1294
- }
1295
- this.childCnt += insert.length;
1296
- }
1297
- return /** @type {any} */ (this)
1298
- }
1299
-
1300
- /**
1301
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,any,infer Children,any,any> ? Extract<Children,Delta<any,any,any,any,any>> : never} NewContent
1302
- * @param {NewContent} modify
1303
- * @param {FormattingAttributes?} formatting
1304
- * @param {Attribution?} attribution
1305
- * @return {DeltaBuilder<
1306
- * NodeName,
1307
- * Attrs,
1308
- * Exclude<NewContent,string>[number]|Children,
1309
- * (Extract<NewContent,string>|Text) extends string ? string : never,
1310
- * Schema
1311
- * >}
1312
- */
1313
- modify (modify, formatting = null, attribution = null) {
1314
- modDeltaCheck(this);
1315
- const mergedAttributes = mergeAttrs(this.usedAttributes, formatting);
1316
- const mergedAttribution = mergeAttrs(this.usedAttribution, attribution);
1317
- list.pushEnd(this.children, new ModifyOp(modify, object.isEmpty(mergedAttributes) ? null : mergedAttributes, object.isEmpty(mergedAttribution) ? null : mergedAttribution));
1318
- this.childCnt += 1;
1319
- return /** @type {any} */ (this)
1320
- }
1321
-
1322
- /**
1323
- * @param {number} len
1324
- * @param {FormattingAttributes?} [format]
1325
- * @param {Attribution?} [attribution]
1326
- */
1327
- retain (len, format = null, attribution = null) {
1328
- modDeltaCheck(this);
1329
- const mergedFormats = mergeAttrs(this.usedAttributes, format);
1330
- const mergedAttribution = mergeAttrs(this.usedAttribution, attribution);
1331
- const lastOp = /** @type {RetainOp|InsertOp<any>} */ (this.children.end);
1332
- if (lastOp instanceof RetainOp && _function.equalityDeep(mergedFormats, lastOp.format) && _function.equalityDeep(mergedAttribution, lastOp.attribution)) {
1333
- // @ts-ignore
1334
- lastOp.retain += len;
1335
- } else if (len > 0) {
1336
- list.pushEnd(this.children, new RetainOp(len, mergedFormats, mergedAttribution));
1337
- }
1338
- this.childCnt += len;
1339
- return this
1340
- }
1341
-
1342
- /**
1343
- * @param {number} len
1344
- */
1345
- delete (len) {
1346
- modDeltaCheck(this);
1347
- const lastOp = /** @type {DeleteOp|InsertOp<any>} */ (this.children.end);
1348
- if (lastOp instanceof DeleteOp) {
1349
- lastOp.delete += len;
1350
- } else if (len > 0) {
1351
- list.pushEnd(this.children, new DeleteOp(len));
1352
- }
1353
- this.childCnt += len;
1354
- return this
1355
- }
1356
-
1357
- /**
1358
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,infer Attrs,any,any,any> ? (keyof Attrs) : never} Key
1359
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,infer Attrs,any,any,any> ? (Attrs[Key]) : never} Val
1360
- * @param {Key} key
1361
- * @param {Val} val
1362
- * @param {Attribution?} attribution
1363
- * @param {Val|undefined} [prevValue]
1364
- * @return {DeltaBuilder<
1365
- * NodeName,
1366
- * { [K in keyof AddToAttrs<Attrs,Key,Val>]: AddToAttrs<Attrs,Key,Val>[K] },
1367
- * Children,
1368
- * Text,
1369
- * Schema
1370
- * >}
1371
- */
1372
- set (key, val, attribution = null, prevValue) {
1373
- modDeltaCheck(this);
1374
- this.attrs[key] = /** @type {any} */ (new AttrInsertOp(key, val, prevValue, mergeAttrs(this.usedAttribution, attribution)));
1375
- return /** @type {any} */ (this)
1376
- }
1377
-
1378
- /**
1379
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,infer Attrs,any,any,any> ? Attrs : never} NewAttrs
1380
- * @param {NewAttrs} attrs
1381
- * @param {Attribution?} attribution
1382
- * @return {DeltaBuilder<
1383
- * NodeName,
1384
- * { [K in keyof MergeAttrs<Attrs,NewAttrs>]: MergeAttrs<Attrs,NewAttrs>[K] },
1385
- * Children,
1386
- * Text,
1387
- * Schema
1388
- * >}
1389
- */
1390
- setMany (attrs, attribution = null) {
1391
- modDeltaCheck(this);
1392
- for (const k in attrs) {
1393
- this.set(/** @type {any} */ (k), attrs[k], attribution);
1394
- }
1395
- return /** @type {any} */ (this)
1396
- }
1397
-
1398
- /**
1399
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,infer As,any,any,any> ? keyof As : never} Key
1400
- * @param {Key} key
1401
- * @param {Attribution?} attribution
1402
- * @param {any} [prevValue]
1403
- * @return {DeltaBuilder<
1404
- * NodeName,
1405
- * { [K in keyof AddToAttrs<Attrs,Key,never>]: AddToAttrs<Attrs,Key,never>[K] },
1406
- * Children,
1407
- * Text,
1408
- * Schema
1409
- * >}
1410
- */
1411
- unset (key, attribution = null, prevValue) {
1412
- modDeltaCheck(this);
1413
- this.attrs[key] = /** @type {any} */ (new AttrDeleteOp(key, prevValue, mergeAttrs(this.usedAttribution, attribution)));
1414
- return /** @type {any} */ (this)
1415
- }
1416
-
1417
- /**
1418
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,infer As,any,any,any> ? { [K in keyof As]: Extract<As[K],Delta<any,any,any,any,any>> extends never ? never : K }[keyof As] : never} Key
1419
- * @template {AllowedDeltaFromSchema<Schema> extends Delta<any,infer As,any,any,any> ? Extract<As[Key],Delta<any,any,any,any,any>> : never} D
1420
- * @param {Key} key
1421
- * @param {D} modify
1422
- * @return {DeltaBuilder<
1423
- * NodeName,
1424
- * { [K in keyof AddToAttrs<Attrs,Key,D>]: AddToAttrs<Attrs,Key,D>[K] },
1425
- * Children,
1426
- * Text,
1427
- * Schema
1428
- * >}
1429
- */
1430
- update (key, modify) {
1431
- modDeltaCheck(this);
1432
- this.attrs[key] = /** @type {any} */ (new AttrModifyOp(key, modify));
1433
- return /** @type {any} */ (this)
1434
- }
1435
-
1436
- /**
1437
- * @param {Delta<NodeName,Attrs,Children,Text,any>} other
1438
- */
1439
- apply (other) {
1440
- modDeltaCheck(this);
1441
- this.$schema?.expect(other);
1442
- // apply attrs
1443
- for (const op of other.attrs) {
1444
- const c = /** @type {AttrInsertOp<any,any>|AttrDeleteOp<any>|AttrModifyOp<any,any>} */ (this.attrs[op.key]);
1445
- if ($modifyOp.check(op)) {
1446
- if ($deltaAny.check(c?.value)) {
1447
- c._modValue.apply(op.value);
1448
- } else {
1449
- // then this is a simple modify
1450
- // @ts-ignore
1451
- this.attrs[op.key] = op.clone();
1452
- }
1453
- } else if ($insertOp.check(op)) {
1454
- // @ts-ignore
1455
- op.prevValue = c?.value;
1456
- // @ts-ignore
1457
- this.attrs[op.key] = op.clone();
1458
- } else if ($deleteOp.check(op)) {
1459
- op.prevValue = c?.value;
1460
- delete this.attrs[op.key];
1461
- }
1462
- }
1463
- // apply children
1464
- /**
1465
- * @type {ChildrenOpAny?}
1466
- */
1467
- let opsI = this.children.start;
1468
- let offset = 0;
1469
- /**
1470
- * At the end, we will try to merge this op, and op.next op with their respective previous op.
1471
- *
1472
- * Hence, anytime an op is cloned, deleted, or inserted (anytime list.* api is used) we must add
1473
- * an op to maybeMergeable.
1474
- *
1475
- * @type {Array<InsertOp<any>|RetainOp|DeleteOp|TextOp|ModifyOp<any>>}
1476
- */
1477
- const maybeMergeable = [];
1478
- /**
1479
- * @template {InsertOp<any>|RetainOp|DeleteOp|TextOp|ModifyOp<any>|null} OP
1480
- * @param {OP} op
1481
- * @return {OP}
1482
- */
1483
- const scheduleForMerge = op => {
1484
- op && maybeMergeable.push(op);
1485
- return op
1486
- };
1487
- other.children.forEach(op => {
1488
- if ($textOp.check(op) || $insertOp.check(op)) {
1489
- if (offset === 0) {
1490
- list.insertBetween(this.children, opsI == null ? this.children.end : opsI.prev, opsI, scheduleForMerge(op.clone()));
1491
- } else {
1492
- // @todo inmplement "splitHelper" and "insertHelper" - I'm splitting all the time and
1493
- // forget to update opsI
1494
- if (opsI == null) error.unexpectedCase();
1495
- const cpy = scheduleForMerge(opsI.clone(offset));
1496
- opsI._splice(offset, opsI.length - offset);
1497
- list.insertBetween(this.children, opsI, opsI.next || null, cpy);
1498
- list.insertBetween(this.children, opsI, cpy || null, scheduleForMerge(op.clone()));
1499
- opsI = cpy;
1500
- offset = 0;
1501
- }
1502
- this.childCnt += op.insert.length;
1503
- } else if ($retainOp.check(op)) {
1504
- let retainLen = op.length;
1505
-
1506
- if (offset > 0 && opsI != null && op.format != null && !$deleteOp.check(opsI) && !object.every(op.format, (v, k) => _function.equalityDeep(v, /** @type {InsertOp<any>|RetainOp|ModifyOp} */ (opsI).format?.[k] || null))) {
1507
- // need to split current op
1508
- const cpy = scheduleForMerge(opsI.clone(offset));
1509
- opsI._splice(offset, opsI.length - offset);
1510
- list.insertBetween(this.children, opsI, opsI.next || null, cpy);
1511
- opsI = cpy;
1512
- offset = 0;
1513
- }
1514
-
1515
- while (opsI != null && opsI.length - offset <= retainLen) {
1516
- op.format != null && updateOpFormat(opsI, op.format);
1517
- retainLen -= opsI.length - offset;
1518
- opsI = opsI?.next || null;
1519
- offset = 0;
1520
- }
1521
-
1522
- if (opsI != null) {
1523
- if (op.format != null && retainLen > 0) {
1524
- // split current op and apply format
1525
- const cpy = scheduleForMerge(opsI.clone(retainLen));
1526
- opsI._splice(retainLen, opsI.length - retainLen);
1527
- list.insertBetween(this.children, opsI, opsI.next || null, cpy);
1528
- updateOpFormat(opsI, op.format);
1529
- opsI = cpy;
1530
- } else {
1531
- offset += retainLen;
1532
- }
1533
- } else if (retainLen > 0) {
1534
- list.pushEnd(this.children, scheduleForMerge(new RetainOp(retainLen, op.format, op.attribution)));
1535
- this.childCnt += retainLen;
1536
- }
1537
- } else if ($deleteOp.check(op)) {
1538
- let remainingLen = op.delete;
1539
- while (remainingLen > 0) {
1540
- if (opsI == null) {
1541
- list.pushEnd(this.children, scheduleForMerge(new DeleteOp(remainingLen)));
1542
- this.childCnt += remainingLen;
1543
- break
1544
- } else if (opsI instanceof DeleteOp) {
1545
- const delLen = opsI.length - offset;
1546
- // the same content can't be deleted twice, remove duplicated deletes
1547
- if (delLen >= remainingLen) {
1548
- offset = 0;
1549
- opsI = opsI.next;
1550
- } else {
1551
- offset += remainingLen;
1552
- }
1553
- remainingLen -= delLen;
1554
- } else { // insert / embed / retain / modify ⇒ replace
1555
- // case1: delete o fully
1556
- // case2: delete some part of beginning
1557
- // case3: delete some part of end
1558
- // case4: delete some part of center
1559
- const delLen = math.min(opsI.length - offset, remainingLen);
1560
- this.childCnt -= delLen;
1561
- if (opsI.length === delLen) {
1562
- // case 1
1563
- offset = 0;
1564
- scheduleForMerge(opsI.next);
1565
- list.remove(this.children, opsI);
1566
- opsI = opsI.next;
1567
- } else if (offset === 0) {
1568
- // case 2
1569
- offset = 0;
1570
- opsI._splice(0, delLen);
1571
- } else if (offset + delLen === opsI.length) {
1572
- // case 3
1573
- opsI._splice(offset, delLen);
1574
- offset = 0;
1575
- opsI = opsI.next;
1576
- } else {
1577
- // case 4
1578
- opsI._splice(offset, delLen);
1579
- }
1580
- remainingLen -= delLen;
1581
- }
1582
- }
1583
- } else if ($modifyOp.check(op)) {
1584
- if (opsI == null) {
1585
- list.pushEnd(this.children, op.clone());
1586
- this.childCnt += 1;
1587
- return
1588
- }
1589
- if ($modifyOp.check(opsI)) {
1590
- opsI._modValue.apply(op.value);
1591
- } else if ($insertOp.check(opsI)) {
1592
- opsI._modValue(offset).apply(op.value);
1593
- } else if ($retainOp.check(opsI)) {
1594
- if (offset > 0) {
1595
- const cpy = scheduleForMerge(opsI.clone(0, offset)); // skipped len
1596
- opsI._splice(0, offset); // new remainder
1597
- list.insertBetween(this.children, opsI.prev, opsI, cpy); // insert skipped len
1598
- offset = 0;
1599
- }
1600
- list.insertBetween(this.children, opsI.prev, opsI, scheduleForMerge(op.clone())); // insert skipped len
1601
- if (opsI.length === 1) {
1602
- list.remove(this.children, opsI);
1603
- } else {
1604
- opsI._splice(0, 1);
1605
- scheduleForMerge(opsI);
1606
- }
1607
- } else if ($deleteOp.check(opsI)) ; else {
1608
- error.unexpectedCase();
1609
- }
1610
- } else {
1611
- error.unexpectedCase();
1612
- }
1613
- });
1614
- maybeMergeable.forEach(op => {
1615
- // check if this is still integrated
1616
- if (op.prev?.next === op) {
1617
- tryMergeWithPrev(this.children, op);
1618
- op.next && tryMergeWithPrev(this.children, op.next);
1619
- }
1620
- });
1621
- return this
1622
- }
1623
-
1624
- /**
1625
- * @param {DeltaAny} other
1626
- * @param {boolean} priority
1627
- */
1628
- rebase (other, priority) {
1629
- modDeltaCheck(this);
1630
- /**
1631
- * Rebase attributes
1632
- *
1633
- * - insert vs delete ⇒ insert takes precedence
1634
- * - insert vs modify ⇒ insert takes precedence
1635
- * - insert vs insert ⇒ priority decides
1636
- * - delete vs modify ⇒ delete takes precedence
1637
- * - delete vs delete ⇒ current delete op is removed because item has already been deleted
1638
- * - modify vs modify ⇒ rebase using priority
1639
- */
1640
- for (const op of this.attrs) {
1641
- if ($insertOp.check(op)) {
1642
- if ($insertOp.check(other.attrs[op.key]) && !priority) {
1643
- delete this.attrs[op.key];
1644
- }
1645
- } else if ($deleteOp.check(op)) {
1646
- const otherOp = other.attrs[/** @type {any} */ (op.key)];
1647
- if ($insertOp.check(otherOp)) {
1648
- delete this.attrs[otherOp.key];
1649
- }
1650
- } else if ($modifyOp.check(op)) {
1651
- const otherOp = other.attrs[/** @type {any} */ (op.key)];
1652
- if (otherOp == null) ; else if ($modifyOp.check(otherOp)) {
1653
- op._modValue.rebase(otherOp.value, priority);
1654
- } else {
1655
- delete this.attrs[otherOp.key];
1656
- }
1657
- }
1658
- }
1659
- /**
1660
- * Rebase children.
1661
- *
1662
- * Precedence: insert with higher priority comes first. Op with less priority is transformed to
1663
- * be inserted later.
1664
- *
1665
- * @todo always check if inser OR text
1666
- */
1667
- /**
1668
- * @type {ChildrenOpAny?}
1669
- */
1670
- let currChild = this.children.start;
1671
- let currOffset = 0;
1672
- /**
1673
- * @type {ChildrenOpAny?}
1674
- */
1675
- let otherChild = other.children.start;
1676
- let otherOffset = 0;
1677
- while (currChild != null && otherChild != null) {
1678
- if ($insertOp.check(currChild) || $textOp.check(currChild)) {
1679
- /**
1680
- * Transforming *insert*. If other is..
1681
- * - insert: transform based on priority
1682
- * - retain/delete/modify: transform next op against other
1683
- */
1684
- if ($insertOp.check(otherChild) || $modifyOp.check(otherChild) || $textOp.check(otherChild)) {
1685
- if (!priority) {
1686
- list.insertBetween(this.children, currChild.prev, currChild, new RetainOp(otherChild.length, null, null));
1687
- this.childCnt += otherChild.length;
1688
- // curr is transformed against other, transform curr against next
1689
- otherOffset = otherChild.length;
1690
- } else {
1691
- // curr stays as is, transform next op
1692
- currOffset = currChild.length;
1693
- }
1694
- } else { // otherChild = delete | retain | modify - curr stays as is, transform next op
1695
- currOffset = currChild.length;
1696
- }
1697
- } else if ($modifyOp.check(currChild)) {
1698
- /**
1699
- * Transforming *modify*. If other is..
1700
- * - insert: adjust position
1701
- * - modify: rebase curr modify on other modify
1702
- * - delete: remove modify
1703
- * - retain: adjust offset
1704
- */
1705
- if ($insertOp.check(otherChild) || $textOp.check(otherChild)) {
1706
- // @todo: with all list changes (retain insertions, removal), try to merge the surrounding
1707
- // ops later
1708
- list.insertBetween(this.children, currChild.prev, currChild, new RetainOp(otherChild.length, null, null));
1709
- this.childCnt += otherChild.length;
1710
- // curr is transformed against other, transform curr against next
1711
- otherOffset = otherChild.length;
1712
- } else {
1713
- if ($modifyOp.check(otherChild)) {
1714
- /** @type {any} */ (currChild.value).rebase(otherChild, priority);
1715
- } else if ($deleteOp.check(otherChild)) {
1716
- list.remove(this.children, currChild);
1717
- this.childCnt -= 1;
1718
- }
1719
- currOffset += 1;
1720
- otherOffset += 1;
1721
- }
1722
- } else { // DeleteOp | RetainOp
1723
- const maxCommonLen = math.min(currChild.length - currOffset, otherChild.length - otherOffset);
1724
- /**
1725
- * Transforming *retain* OR *delete*. If other is..
1726
- * - retain / modify: adjust offsets
1727
- * - delete: shorten curr op
1728
- * - insert: split curr op and insert retain
1729
- */
1730
- if ($retainOp.check(otherChild) || $modifyOp.check(otherChild)) {
1731
- currOffset += maxCommonLen;
1732
- otherOffset += maxCommonLen;
1733
- } else if ($deleteOp.check(otherChild)) {
1734
- if ($retainOp.check(currChild)) {
1735
- // @ts-ignore
1736
- currChild.retain -= maxCommonLen;
1737
- } else if ($deleteOp.check(currChild)) {
1738
- currChild.delete -= maxCommonLen;
1739
- }
1740
- this.childCnt -= maxCommonLen;
1741
- } else { // insert/text.check(currOp)
1742
- if (currOffset > 0) {
1743
- const leftPart = currChild.clone(currOffset);
1744
- list.insertBetween(this.children, currChild.prev, currChild, leftPart);
1745
- currChild._splice(currOffset, currChild.length - currOffset);
1746
- currOffset = 0;
1747
- }
1748
- list.insertBetween(this.children, currChild.prev, currChild, new RetainOp(otherChild.length, null, null));
1749
- this.childCnt += otherChild.length;
1750
- otherOffset = otherChild.length;
1751
- }
1752
- }
1753
- if (currOffset >= currChild.length) {
1754
- currChild = currChild.next;
1755
- currOffset = 0;
1756
- }
1757
- if (otherOffset >= otherChild.length) {
1758
- otherChild = otherChild.next;
1759
- otherOffset = 0;
1760
- }
1761
- }
1762
- return this
1763
- }
1764
-
1765
- /**
1766
- * Same as doing `delta.rebase(other.inverse())`, without creating a temporary delta.
1767
- *
1768
- * @param {DeltaAny} other
1769
- * @param {boolean} priority
1770
- */
1771
- rebaseOnInverse (other, priority) {
1772
- modDeltaCheck(this);
1773
- // @todo
1774
- console.info('method rebaseOnInverse unimplemented');
1775
- return this
1776
- }
1777
-
1778
- /**
1779
- * Append child ops from one op to the other.
1780
- *
1781
- * delta.create().insert('a').append(delta.create().insert('b')) // => insert "ab"
1782
- *
1783
- * @template {DeltaAny} OtherDelta
1784
- * @param {OtherDelta} other
1785
- * @return {CastToDelta<OtherDelta> extends Delta<any,any,infer OtherChildren,infer OtherText,any> ? DeltaBuilder<NodeName,Attrs,Children|OtherChildren,Text|OtherText,Schema> : never}
1786
- */
1787
- append (other) {
1788
- const children = this.children;
1789
- const prevLast = children.end;
1790
- // @todo Investigate. Above is a typescript issue. It is necessary to cast OtherDelta to a Delta first before
1791
- // inferring type, otherwise Children will contain Text.
1792
- for (const child of other.children) {
1793
- list.pushEnd(children, child.clone());
1794
- }
1795
- this.childCnt += other.childCnt;
1796
- prevLast?.next && tryMergeWithPrev(children, prevLast.next);
1797
- // @ts-ignore
1798
- return this
1799
- }
1800
- }
1801
-
1802
- /**
1803
- * @param {ChildrenOpAny} op
1804
- * @param {{[k:string]:any}} formatUpdate
1805
- */
1806
- const updateOpFormat = (op, formatUpdate) => {
1807
- if (!$deleteOp.check(op)) {
1808
- // apply formatting attributes
1809
- for (const k in formatUpdate) {
1810
- const v = formatUpdate[k];
1811
- if (v != null || $retainOp.check(op)) {
1812
- // never modify formats
1813
- /** @type {any} */ (op).format = object.assign({}, op.format, { [k]: v });
1814
- } else if (op.format != null) {
1815
- const { [k]: _, ...rest } = op.format
1816
- ;/** @type {any} */ (op).format = rest;
1817
- }
1818
- }
1819
- }
1820
- };
1821
-
1822
- /**
1823
- * @template {DeltaAny} D
1824
- * @typedef {D extends DeltaBuilder<infer N,infer Attrs,infer Children,infer Text,infer Schema> ? Delta<N,Attrs,Children,Text,Schema> : D} CastToDelta
1825
- */
1826
-
1827
- /**
1828
- * @template {string} NodeName
1829
- * @template {{ [key: string|number]: any }} [Attrs={}]
1830
- * @template {fingerprintTrait.Fingerprintable|never} [Children=never]
1831
- * @template {string|never} [Text=never]
1832
- * @typedef {Delta<NodeName,Attrs,Children|Delta<NodeName,Attrs,Children,Text>|RecursiveDelta<NodeName,Attrs,Children,Text>,Text>} RecursiveDelta
1833
- */
1834
-
1835
- /**
1836
- * @template {string} Name
1837
- * @template {{[k:string|number]:any}} Attrs
1838
- * @template {fingerprintTrait.Fingerprintable} Children
1839
- * @template {boolean} HasText
1840
- * @template {{ [k:string]:any }} Formats
1841
- * @template {boolean} Recursive
1842
- * @extends {s.Schema<Delta<
1843
- * Name,
1844
- * Attrs,
1845
- * Children|(Recursive extends true ? RecursiveDelta<Name,Attrs,Children,HasText extends true ? string : never> : never),
1846
- * HasText extends true ? string : never,
1847
- * any>>}
1848
- */
1849
- class $Delta extends schema.Schema {
1850
- /**
1851
- * @param {s.Schema<Name>} $name
1852
- * @param {s.Schema<Attrs>} $attrs
1853
- * @param {s.Schema<Children>} $children
1854
- * @param {HasText} hasText
1855
- * @param {s.Schema<Formats>} $formats
1856
- * @param {Recursive} recursive
1857
- */
1858
- constructor ($name, $attrs, $children, hasText, $formats, recursive) {
1859
- super();
1860
- const $attrsPartial = schema.$$object.check($attrs) ? $attrs.partial : $attrs;
1861
- if (recursive) {
1862
- // @ts-ignore
1863
- $children = schema.$union($children, this);
1864
- }
1865
- this.shape = { $name, $attrs: $attrsPartial, $children, hasText, $formats };
1866
- }
1867
-
1868
- /**
1869
- * @param {any} o
1870
- * @param {s.ValidationError} [err]
1871
- * @return {o is Delta<
1872
- * Name,
1873
- * Attrs,
1874
- * Children|(Recursive extends true ? RecursiveDelta<Name,Attrs,Children,HasText extends true ? string : never> : never),
1875
- * HasText extends true ? string : never,
1876
- * any>}
1877
- */
1878
- check (o, err = undefined) {
1879
- const { $name, $attrs, $children, hasText, $formats } = this.shape;
1880
- if (!(o instanceof Delta)) {
1881
- err?.extend(null, 'Delta', o?.constructor.name, 'Constructor match failed');
1882
- } else if (o.name != null && !$name.check(o.name, err)) {
1883
- err?.extend('Delta.name', $name.toString(), o.name, 'Unexpected node name');
1884
- } 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))))) {
1885
- err?.extend('Delta.children', '', '', 'Children don\'t match the schema');
1886
- } else if (object.some(o.attrs, (op, k) => $insertOp.check(op) && !$attrs.check({ [k]: op.value }, err))) {
1887
- err?.extend('Delta.attrs', '', '', 'Attrs don\'t match the schema');
1888
- } else {
1889
- return true
1890
- }
1891
- return false
1892
- }
1893
- }
1894
-
1895
- /**
1896
- * @template {s.Schema<string>|string|Array<string>} [NodeNameSchema=s.Schema<any>]
1897
- * @template {s.Schema<{ [key: string|number]: any }>|{ [key:string|number]:any }} [AttrsSchema=s.Schema<{}>]
1898
- * @template {any} [ChildrenSchema=s.Schema<never>]
1899
- * @template {boolean} [HasText=false]
1900
- * @template {boolean} [Recursive=false]
1901
- * @template {{ [k:string]:any }} [Formats={[k:string]:any}]
1902
- * @param {object} opts
1903
- * @param {NodeNameSchema?} [opts.name]
1904
- * @param {AttrsSchema?} [opts.attrs] What key-value pairs are included.
1905
- * @param {ChildrenSchema?} [opts.children] The type of content in `insertOp`
1906
- * @param {HasText} [opts.text] Whether this delta contains text using `textOp`
1907
- * @param {Formats} [opts.formats]
1908
- * @param {Recursive} [opts.recursive]
1909
- * @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<
1910
- * NodeName,
1911
- * Attrs,
1912
- * Children|(Recursive extends true ? RecursiveDelta<NodeName,Attrs,Children,HasText extends true ? string : never> : never),
1913
- * HasText extends true ? string : never
1914
- * >> : never}
1915
- */
1916
- const $delta = ({ name, attrs, children, text, formats, recursive }) => /** @type {any} */ (new $Delta(
1917
- name == null ? schema.$any : schema.$(name),
1918
- /** @type {any} */ (attrs == null ? schema.$object({}) : schema.$(attrs)),
1919
- /** @type {any} */ (children == null ? schema.$never : schema.$(children)),
1920
- text ?? false,
1921
- formats == null ? schema.$any : schema.$(formats),
1922
- recursive ?? false
1923
- ));
1924
-
1925
- const $$delta = schema.$constructedBy($Delta);
1926
-
1927
- /**
1928
- * @todo remove this
1929
- *
1930
- * @template {s.Schema<string>|string|Array<string>} [NodeNameSchema=s.Schema<any>]
1931
- * @template {s.Schema<{ [key: string|number]: any }>|{ [key:string|number]:any }} [AttrsSchema=s.Schema<{}>]
1932
- * @template {any} [ChildrenSchema=s.Schema<never>]
1933
- * @template {boolean} [HasText=false]
1934
- * @template {boolean} [Recursive=false]
1935
- * @param {object} opts
1936
- * @param {NodeNameSchema?} [opts.name]
1937
- * @param {AttrsSchema?} [opts.attrs]
1938
- * @param {ChildrenSchema?} [opts.children]
1939
- * @param {HasText} [opts.text]
1940
- * @param {Recursive} [opts.recursive]
1941
- * @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<
1942
- * NodeName,
1943
- * Attrs,
1944
- * Children|(Recursive extends true ? RecursiveDelta<NodeName,Attrs,Children,HasText extends true ? string : never> : never),
1945
- * HasText extends true ? string : never
1946
- * >> : never}
1947
- */
1948
- const _$delta = ({ name, attrs, children, text, recursive }) => {
1949
- /**
1950
- * @type {s.Schema<Array<any>>}
1951
- */
1952
- let $arrContent = children == null ? schema.$never : schema.$array(schema.$(children));
1953
- const $name = name == null ? schema.$any : schema.$(name);
1954
- const $attrsPartial = attrs == null ? schema.$object({}) : (schema.$$record.check(attrs) ? attrs : /** @type {any} */ (schema.$(attrs)).partial);
1955
- const $d = schema.$instanceOf(Delta, /** @param {Delta<any,any,any,any,any>} d */ d => {
1956
- if (
1957
- !$name.check(d.name) ||
1958
- object.some(d.attrs,
1959
- (op, k) => $insertOp.check(op) && !$attrsPartial.check({ [k]: op.value })
1960
- )
1961
- ) return false
1962
- for (const op of d.children) {
1963
- if ((!text && $textOp.check(op)) || ($insertOp.check(op) && !$arrContent.check(op.insert))) {
1964
- return false
1965
- }
1966
- }
1967
- return true
1968
- });
1969
- if (recursive) {
1970
- $arrContent = children == null ? schema.$array($d) : schema.$array(schema.$(children), $d);
1971
- }
1972
- return /** @type {any} */ ($d)
1973
- };
1974
-
1975
- /**
1976
- * @type {s.Schema<DeltaAny>}
1977
- */
1978
- const $deltaAny = /** @type {any} */ (schema.$instanceOf(Delta));
1979
-
1980
- /**
1981
- * @type {s.Schema<DeltaBuilderAny>}
1982
- */
1983
- const $deltaBuilderAny = /** @type {any} */ (schema.$instanceOf(DeltaBuilder));
1984
-
1985
- /**
1986
- * Helper function to merge attribution and attributes. The latter input "wins".
1987
- *
1988
- * @template {{ [key: string]: any }} T
1989
- * @param {T | null} a
1990
- * @param {T | null} b
1991
- */
1992
- const mergeAttrs = (a, b) => object.isEmpty(a)
1993
- ? (object.isEmpty(b) ? null : b)
1994
- : (object.isEmpty(b) ? a : object.assign({}, a, b));
1995
-
1996
- /**
1997
- * @template {DeltaAny|null} D
1998
- * @param {D} a
1999
- * @param {D} b
2000
- * @return {D}
2001
- */
2002
- const mergeDeltas = (a, b) => {
2003
- if (a != null && b != null) {
2004
- const c = clone(a);
2005
- c.apply(b);
2006
- return /** @type {any} */ (c)
2007
- }
2008
- return a == null ? b : (a || null)
2009
- };
2010
-
2011
- /**
2012
- * @template {DeltaAny} D
2013
- * @param {prng.PRNG} gen
2014
- * @param {s.Schema<D>} $d
2015
- * @return {D extends Delta<infer NodeName,infer Attrs,infer Children,infer Text,infer Schema> ? DeltaBuilder<NodeName,Attrs,Children,Text,Schema> : never}
2016
- */
2017
- const random = (gen, $d) => {
2018
- const { $name, $attrs, $children, hasText, $formats: $formats_ } = /** @type {$Delta<any,any,any,boolean,any,any>} */ (/** @type {any} */ ($d)).shape;
2019
- const d = schema.$$any.check($name) ? create($deltaAny) : create(schema.random(gen, $name), $deltaAny);
2020
- const $formats = schema.$$any.check($formats_) ? schema.$null : $formats_;
2021
- prng.bool(gen) && d.setMany(schema.random(gen, $attrs));
2022
- for (let i = prng.uint32(gen, 0, 5); i > 0; i--) {
2023
- if (hasText && prng.bool(gen)) {
2024
- d.insert(prng.word(gen), schema.random(gen, $formats));
2025
- } else if (!schema.$$never.check($children)) {
2026
- /**
2027
- * @type {Array<any>}
2028
- */
2029
- const ins = [];
2030
- let insN = prng.int32(gen, 0, 5);
2031
- while (insN--) {
2032
- ins.push(schema.random(gen, $children));
2033
- }
2034
- d.insert(ins, schema.random(gen, $formats));
2035
- }
2036
- }
2037
- return /** @type {any} */ (d)
2038
- };
2039
-
2040
- /**
2041
- * @overload
2042
- * @return {DeltaBuilder<any,{},never,never,null>}
2043
- */
2044
- /**
2045
- * @template {string} NodeName
2046
- * @overload
2047
- * @param {NodeName} nodeName
2048
- * @return {DeltaBuilder<NodeName,{},never,never,null>}
2049
- */
2050
- /**
2051
- * @template {string} NodeName
2052
- * @template {s.Schema<DeltaAny>} Schema
2053
- * @overload
2054
- * @param {NodeName} nodeName
2055
- * @param {Schema} schema
2056
- * @return {Schema extends s.Schema<Delta<infer N,infer Attrs,infer Children,infer Text,any>> ? DeltaBuilder<NodeName,Attrs,Children,Text,Schema> : never}
2057
- */
2058
- /**
2059
- * @template {s.Schema<DeltaAny>} Schema
2060
- * @overload
2061
- * @param {Schema} schema
2062
- * @return {Schema extends s.Schema<Delta<infer N,infer Attrs,infer Children,infer Text,any>> ? DeltaBuilder<N,Attrs,Children,Text,Schema> : never}
2063
- */
2064
- /**
2065
- * @template {string|null} NodeName
2066
- * @template {{[k:string|number]:any}|null} Attrs
2067
- * @template {Array<any>|string} [Children=never]
2068
- * @overload
2069
- * @param {NodeName} nodeName
2070
- * @param {Attrs} attrs
2071
- * @param {Children} [children]
2072
- * @return {DeltaBuilder<
2073
- * NodeName extends null ? any : NodeName,
2074
- * Attrs extends null ? {} : Attrs,
2075
- * Extract<Children,Array<any>> extends Array<infer Ac> ? (unknown extends Ac ? never : Ac) : never,
2076
- * Extract<Children,string>,
2077
- * null
2078
- * >}
2079
- */
2080
- /**
2081
- * @param {string|s.Schema<DeltaAny>} [nodeNameOrSchema]
2082
- * @param {{[K:string|number]:any}|s.Schema<DeltaAny>} [attrsOrSchema]
2083
- * @param {(Array<any>|string)} [children]
2084
- * @return {DeltaBuilder<any,any,any,any,any>}
2085
- */
2086
- const create = (nodeNameOrSchema, attrsOrSchema, children) => {
2087
- const nodeName = /** @type {any} */ (schema.$string.check(nodeNameOrSchema) ? nodeNameOrSchema : null);
2088
- const schema$1 = /** @type {any} */ (schema.$$schema.check(nodeNameOrSchema) ? nodeNameOrSchema : (schema.$$schema.check(attrsOrSchema) ? attrsOrSchema : null));
2089
- const d = /** @type {DeltaBuilder<any,any,any,string,null>} */ (new DeltaBuilder(nodeName, schema$1));
2090
- if (schema.$objectAny.check(attrsOrSchema)) {
2091
- d.setMany(attrsOrSchema);
2092
- }
2093
- children && d.insert(children);
2094
- return d
2095
- };
2096
-
2097
- // DELTA TEXT
2098
-
2099
- /**
2100
- * @template {fingerprintTrait.Fingerprintable} [Embeds=never]
2101
- * @typedef {Delta<any,{},Embeds,string>} TextDelta
2102
- */
2103
-
2104
- /**
2105
- * @template {fingerprintTrait.Fingerprintable} [Embeds=never]
2106
- * @typedef {DeltaBuilder<any,{},Embeds,string>} TextDeltaBuilder
2107
- */
2108
-
2109
- /**
2110
- * @template {Array<s.Schema<any>>} [$Embeds=any]
2111
- * @param {$Embeds} $embeds
2112
- * @return {s.Schema<TextDelta<_AnyToNull<$Embeds> extends null ? never : ($Embeds extends Array<s.Schema<infer $C>> ? $C : never)>>}
2113
- */
2114
- const $text = (...$embeds) => /** @type {any} */ ($delta({ children: schema.$union(...$embeds), text: true }));
2115
- const $textOnly = $text();
2116
-
2117
- /**
2118
- * @template {s.Schema<Delta<any,{},any,any,null>>} [Schema=s.Schema<Delta<any,{},never,string,null>>]
2119
- * @param {Schema} [$schema]
2120
- * @return {Schema extends s.Schema<Delta<infer N,infer Attrs,infer Children,infer Text,any>> ? DeltaBuilder<N,Attrs,Children,Text,Schema> : never}
2121
- */
2122
- const text = $schema => /** @type {any} */ (create($schema || $textOnly));
2123
-
2124
- /**
2125
- * @template {fingerprintTrait.Fingerprintable} Children
2126
- * @typedef {Delta<any,{},Children,never>} ArrayDelta
2127
- */
2128
-
2129
- /**
2130
- * @template {fingerprintTrait.Fingerprintable} Children
2131
- * @typedef {DeltaBuilder<any,{},Children,never>} ArrayDeltaBuilder
2132
- */
2133
-
2134
- /**
2135
- * @template {any|s.Schema<any>} $Children
2136
- * @param {$Children} [$children]
2137
- * @return {s.Schema<ArrayDelta<s.Unwrap<s.ReadSchema<$Children>>>>}
2138
- */
2139
- const $array = $children => /** @type {any} */ ($delta({ children: $children }));
2140
-
2141
- /**
2142
- * @template {s.Schema<ArrayDelta<any>>} [$Schema=never]
2143
- * @param {$Schema} $schema
2144
- * @return {$Schema extends never ? ArrayDeltaBuilder<never> : DeltaBuilder<any,{},never,never,$Schema>}
2145
- */
2146
- const array = $schema => /** @type {any} */ ($schema ? create($schema) : create());
2147
-
2148
- /**
2149
- * @template {{ [K: string|number]: any }} Attrs
2150
- * @typedef {Delta<any,Attrs,never,never>} MapDelta
2151
- */
2152
-
2153
- /**
2154
- * @template {{ [K: string|number]: any }} Attrs
2155
- * @typedef {DeltaBuilder<any,Attrs,never,never>} MapDeltaBuilder
2156
- */
2157
-
2158
- /**
2159
- * @template {{ [K: string|number]: any }} $Attrs
2160
- * @param {s.Schema<$Attrs>} $attrs
2161
- * @return {s.Schema<MapDelta<$Attrs>>}
2162
- */
2163
- const $map = $attrs => /** @type {any} */ ($delta({ attrs: $attrs }));
2164
-
2165
- /**
2166
- * @template {s.Schema<MapDelta<any>>|undefined} [$Schema=undefined]
2167
- * @param {$Schema} [$schema]
2168
- * @return {$Schema extends s.Schema<MapDelta<infer Attrs>> ? DeltaBuilder<any,Attrs,never,never,$Schema> : MapDeltaBuilder<{}>}
2169
- */
2170
- const map = $schema => /** @type {any} */ (create(/** @type {any} */ ($schema)));
2171
-
2172
- /**
2173
- * @template {DeltaAny} D
2174
- * @param {D} d1
2175
- * @param {NoInfer<D>} d2
2176
- * @return {D extends Delta<infer N,infer Attrs,infer Children,infer Text,any> ? DeltaBuilder<N,Attrs,Children,Text,null> : never}
2177
- */
2178
- const diff = (d1, d2) => {
2179
- /**
2180
- * @type {DeltaBuilderAny}
2181
- */
2182
- const d = create();
2183
- if (d1.fingerprint !== d2.fingerprint) {
2184
- let left1 = d1.children.start;
2185
- let left2 = d2.children.start;
2186
- let right1 = d1.children.end;
2187
- let right2 = d2.children.end;
2188
- let commonPrefixOffset = 0;
2189
- // perform a patience sort
2190
- // 1) remove common prefix and suffix
2191
- while (left1 != null && left1.fingerprint === left2?.fingerprint) {
2192
- if (!$deleteOp.check(left1)) {
2193
- commonPrefixOffset += left1.length;
2194
- }
2195
- left1 = left1.next;
2196
- left2 = left2.next;
2197
- }
2198
- while (right1 !== null && right1 !== left1 && right1.fingerprint === right2?.fingerprint) {
2199
- right1 = right1.prev;
2200
- right2 = right2.prev;
2201
- }
2202
- /**
2203
- * @type {Array<ChildrenOpAny>}
2204
- */
2205
- const ops1 = [];
2206
- /**
2207
- * @type {Array<ChildrenOpAny>}
2208
- */
2209
- const ops2 = [];
2210
- while (left1 !== null && left1 !== right1?.next) {
2211
- ops1.push(left1);
2212
- left1 = left1.next;
2213
- }
2214
- while (left2 !== null && left2 !== right2?.next) {
2215
- ops2.push(left2);
2216
- left2 = left2.next;
2217
- }
2218
- const fprints1 = ops1.map(op => op.fingerprint);
2219
- const fprints2 = ops2.map(op => op.fingerprint);
2220
- const changeset = patience.diff(fprints1, fprints2);
2221
- d.retain(commonPrefixOffset);
2222
- for (let i = 0, lastIndex1 = 0, currIndexOffset2 = 0; i < changeset.length; i++) {
2223
- const change = changeset[i];
2224
- d.retain(change.index - lastIndex1);
2225
- // insert minimal diff at curred position in d
2226
- /**
2227
- *
2228
- * @todo it would be better if these would be slices of delta (an actual delta)
2229
- *
2230
- * @param {ChildrenOpAny[]} opsIs
2231
- * @param {ChildrenOpAny[]} opsShould
2232
- */
2233
- const diffAndApply = (opsIs, opsShould) => {
2234
- const d = create();
2235
- // @todo unoptimized implementation. Convert content to array and diff that based on
2236
- // generated fingerprints. We probably could do better and cache more information.
2237
- // - benchmark
2238
- // - cache fingerprints in ops
2239
- /**
2240
- * @type {Array<string|DeltaAny|fingerprintTrait.Fingerprintable>}
2241
- */
2242
- const isContent = opsIs.flatMap(op => $insertOp.check(op) ? op.insert : ($textOp.check(op) ? op.insert.split('') : error.unexpectedCase()));
2243
- /**
2244
- * @type {Array<string|DeltaAny|fingerprintTrait.Fingerprintable>}
2245
- */
2246
- const shouldContent = opsShould.flatMap(op => $insertOp.check(op) ? op.insert : ($textOp.check(op) ? op.insert.split('') : error.unexpectedCase()));
2247
- const isContentFingerprinted = isContent.map(c => schema.$string.check(c) ? c : fingerprint.fingerprint(c));
2248
- const shouldContentFingerprinted = shouldContent.map(c => schema.$string.check(c) ? c : fingerprint.fingerprint(c));
2249
- const hasFormatting = opsIs.some(op => !$deleteOp.check(op) && op.format != null) || opsShould.some(op => !$deleteOp.check(op) && op.format != null);
2250
- /**
2251
- * @type {{ index: number, insert: Array<string|DeltaAny|fingerprintTrait.Fingerprintable>, remove: Array<string|DeltaAny|fingerprintTrait.Fingerprintable> }[]}
2252
- */
2253
- const cdiff = patience.diff(isContentFingerprinted, shouldContentFingerprinted);
2254
- // overwrite fingerprinted content with actual content
2255
- for (let i = 0, adj = 0; i < cdiff.length; i++) {
2256
- const cd = cdiff[i];
2257
- cd.remove = isContent.slice(cd.index, cd.index + cd.remove.length);
2258
- cd.insert = shouldContent.slice(cd.index + adj, cd.index + adj + cd.insert.length);
2259
- adj += cd.remove.length - cd.insert.length;
2260
- }
2261
- for (let i = 0, lastIndex = 0; i < cdiff.length; i++) {
2262
- const cd = cdiff[i];
2263
- d.retain(cd.index - lastIndex);
2264
- let cdii = 0;
2265
- let cdri = 0;
2266
- // try to match as much content as possible, preferring to skip over non-deltas
2267
- for (; cdii < cd.insert.length && cdri < cd.remove.length;) {
2268
- const a = cd.insert[cdii];
2269
- const b = cd.remove[cdri];
2270
- if ($deltaAny.check(a) && $deltaAny.check(b) && a.name === b.name) {
2271
- d.modify(diff(b, a));
2272
- cdii++;
2273
- cdri++;
2274
- } else if ($deltaAny.check(b)) {
2275
- d.insert(schema.$string.check(a) ? a : [a]);
2276
- cdii++;
2277
- } else {
2278
- d.delete(1);
2279
- cdri++;
2280
- }
2281
- }
2282
- for (; cdii < cd.insert.length; cdii++) {
2283
- const a = cd.insert[cdii];
2284
- d.insert(schema.$string.check(a) ? a : [a]);
2285
- }
2286
- d.delete(cd.remove.length - cdri);
2287
- }
2288
- // create the diff for formatting
2289
- if (hasFormatting) {
2290
- const formattingDiff = create();
2291
- // update opsIs with content diff. then we can figure out the formatting diff.
2292
- const isUpdated = create();
2293
- // copy opsIs to fresh delta
2294
- opsIs.forEach(op => {
2295
- isUpdated.childCnt += op.length;
2296
- list.pushEnd(isUpdated.children, op.clone());
2297
- });
2298
- isUpdated.apply(d);
2299
- let shouldI = 0;
2300
- let shouldOffset = 0;
2301
- let isOp = isUpdated.children.start;
2302
- let isOffset = 0;
2303
- while (shouldI < opsShould.length && isOp != null) {
2304
- const shouldOp = opsShould[shouldI];
2305
- if (!$deleteOp.check(shouldOp) && !$deleteOp.check(isOp)) {
2306
- const isFormat = isOp.format;
2307
- const minForward = math.min(shouldOp.length - shouldOffset, isOp.length - isOffset);
2308
- shouldOffset += minForward;
2309
- isOffset += minForward;
2310
- if (_function.equalityDeep(shouldOp.format, isFormat)) {
2311
- formattingDiff.retain(minForward);
2312
- } else {
2313
- /**
2314
- * @type {FormattingAttributes}
2315
- */
2316
- const fupdate = {};
2317
- shouldOp.format != null && object.forEach(shouldOp.format, (v, k) => {
2318
- if (!_function.equalityDeep(v, isFormat?.[k] || null)) {
2319
- fupdate[k] = v;
2320
- }
2321
- });
2322
- isFormat && object.forEach(isFormat, (_, k) => {
2323
- if (shouldOp?.format?.[k] === undefined) {
2324
- fupdate[k] = null;
2325
- }
2326
- });
2327
- formattingDiff.retain(minForward, fupdate);
2328
- }
2329
- // update offset and iterators
2330
- if (shouldOffset >= shouldOp.length) {
2331
- shouldI++;
2332
- shouldOffset = 0;
2333
- }
2334
- if (isOffset >= isOp.length) {
2335
- isOp = isOp.next;
2336
- isOffset = 0;
2337
- }
2338
- }
2339
- }
2340
- d.apply(formattingDiff);
2341
- }
2342
- return d
2343
- };
2344
- const subd = diffAndApply(ops1.slice(change.index, change.index + change.remove.length), ops2.slice(change.index + currIndexOffset2, change.index + currIndexOffset2 + change.insert.length));
2345
- d.append(subd);
2346
- lastIndex1 = change.index + change.remove.length;
2347
- currIndexOffset2 += change.insert.length - change.remove.length;
2348
- }
2349
- for (const attr2 of d2.attrs) {
2350
- const attr1 = d1.attrs[attr2.key];
2351
- if (attr1 == null || (attr1.fingerprint !== attr2.fingerprint)) {
2352
- /* c8 ignore else */
2353
- if ($insertOp.check(attr2)) {
2354
- d.set(attr2.key, attr2.value);
2355
- } else {
2356
- /* c8 ignore next 2 */
2357
- error.unexpectedCase();
2358
- }
2359
- }
2360
- }
2361
- for (const attr1 of d1.attrs) {
2362
- if (d2.attrs[attr1.key] == null) {
2363
- d.unset(attr1.key);
2364
- }
2365
- }
2366
- }
2367
- return /** @type {any} */ (d.done(false))
2368
- };
2369
-
2370
- exports.$$delta = $$delta;
2371
- exports.$Delta = $Delta;
2372
- exports.$anyOp = $anyOp;
2373
- exports.$array = $array;
2374
- exports.$attribution = $attribution;
2375
- exports.$deleteOp = $deleteOp;
2376
- exports.$delta = $delta;
2377
- exports.$deltaAny = $deltaAny;
2378
- exports.$deltaBuilderAny = $deltaBuilderAny;
2379
- exports.$deltaMapChangeJson = $deltaMapChangeJson;
2380
- exports.$insertOp = $insertOp;
2381
- exports.$insertOpWith = $insertOpWith;
2382
- exports.$map = $map;
2383
- exports.$modifyOp = $modifyOp;
2384
- exports.$modifyOpWith = $modifyOpWith;
2385
- exports.$retainOp = $retainOp;
2386
- exports.$text = $text;
2387
- exports.$textOnly = $textOnly;
2388
- exports.$textOp = $textOp;
2389
- exports.AttrDeleteOp = AttrDeleteOp;
2390
- exports.AttrInsertOp = AttrInsertOp;
2391
- exports.AttrModifyOp = AttrModifyOp;
2392
- exports.DeleteOp = DeleteOp;
2393
- exports.Delta = Delta;
2394
- exports.DeltaBuilder = DeltaBuilder;
2395
- exports.InsertOp = InsertOp;
2396
- exports.ModifyOp = ModifyOp;
2397
- exports.RetainOp = RetainOp;
2398
- exports.TextOp = TextOp;
2399
- exports._$delta = _$delta;
2400
- exports.array = array;
2401
- exports.clone = clone;
2402
- exports.create = create;
2403
- exports.diff = diff;
2404
- exports.map = map;
2405
- exports.mergeAttrs = mergeAttrs;
2406
- exports.mergeDeltas = mergeDeltas;
2407
- exports.random = random;
2408
- exports.text = text;
2409
- //# sourceMappingURL=delta.cjs.map