tinybase 5.1.0 → 5.1.1

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 (382) hide show
  1. package/@types/synchronizers/synchronizer-ws-client/index.d.cts +6 -0
  2. package/@types/synchronizers/synchronizer-ws-client/index.d.ts +6 -0
  3. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.cts +6 -0
  4. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +6 -0
  5. package/@types/synchronizers/synchronizer-ws-server/index.d.cts +59 -3
  6. package/@types/synchronizers/synchronizer-ws-server/index.d.ts +59 -3
  7. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +65 -4
  8. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +65 -4
  9. package/cjs/es6/min/checkpoints/index.cjs +1 -1
  10. package/cjs/es6/min/checkpoints/index.cjs.gz +0 -0
  11. package/cjs/es6/min/checkpoints/with-schemas/index.cjs +1 -1
  12. package/cjs/es6/min/checkpoints/with-schemas/index.cjs.gz +0 -0
  13. package/cjs/es6/min/index.cjs +1 -1
  14. package/cjs/es6/min/index.cjs.gz +0 -0
  15. package/cjs/es6/min/indexes/index.cjs +1 -1
  16. package/cjs/es6/min/indexes/index.cjs.gz +0 -0
  17. package/cjs/es6/min/indexes/with-schemas/index.cjs +1 -1
  18. package/cjs/es6/min/indexes/with-schemas/index.cjs.gz +0 -0
  19. package/cjs/es6/min/mergeable-store/index.cjs +1 -1
  20. package/cjs/es6/min/mergeable-store/index.cjs.gz +0 -0
  21. package/cjs/es6/min/mergeable-store/with-schemas/index.cjs +1 -1
  22. package/cjs/es6/min/mergeable-store/with-schemas/index.cjs.gz +0 -0
  23. package/cjs/es6/min/metrics/index.cjs +1 -1
  24. package/cjs/es6/min/metrics/index.cjs.gz +0 -0
  25. package/cjs/es6/min/metrics/with-schemas/index.cjs +1 -1
  26. package/cjs/es6/min/metrics/with-schemas/index.cjs.gz +0 -0
  27. package/cjs/es6/min/persisters/persister-automerge/index.cjs +1 -1
  28. package/cjs/es6/min/persisters/persister-automerge/index.cjs.gz +0 -0
  29. package/cjs/es6/min/persisters/persister-automerge/with-schemas/index.cjs +1 -1
  30. package/cjs/es6/min/persisters/persister-automerge/with-schemas/index.cjs.gz +0 -0
  31. package/cjs/es6/min/persisters/persister-indexed-db/index.cjs +1 -1
  32. package/cjs/es6/min/persisters/persister-indexed-db/index.cjs.gz +0 -0
  33. package/cjs/es6/min/persisters/persister-indexed-db/with-schemas/index.cjs +1 -1
  34. package/cjs/es6/min/persisters/persister-indexed-db/with-schemas/index.cjs.gz +0 -0
  35. package/cjs/es6/min/persisters/persister-partykit-client/index.cjs +1 -1
  36. package/cjs/es6/min/persisters/persister-partykit-client/index.cjs.gz +0 -0
  37. package/cjs/es6/min/persisters/persister-partykit-client/with-schemas/index.cjs +1 -1
  38. package/cjs/es6/min/persisters/persister-partykit-client/with-schemas/index.cjs.gz +0 -0
  39. package/cjs/es6/min/persisters/persister-yjs/index.cjs +1 -1
  40. package/cjs/es6/min/persisters/persister-yjs/index.cjs.gz +0 -0
  41. package/cjs/es6/min/persisters/persister-yjs/with-schemas/index.cjs +1 -1
  42. package/cjs/es6/min/persisters/persister-yjs/with-schemas/index.cjs.gz +0 -0
  43. package/cjs/es6/min/queries/index.cjs +1 -1
  44. package/cjs/es6/min/queries/index.cjs.gz +0 -0
  45. package/cjs/es6/min/queries/with-schemas/index.cjs +1 -1
  46. package/cjs/es6/min/queries/with-schemas/index.cjs.gz +0 -0
  47. package/cjs/es6/min/relationships/index.cjs +1 -1
  48. package/cjs/es6/min/relationships/index.cjs.gz +0 -0
  49. package/cjs/es6/min/relationships/with-schemas/index.cjs +1 -1
  50. package/cjs/es6/min/relationships/with-schemas/index.cjs.gz +0 -0
  51. package/cjs/es6/min/store/index.cjs +1 -1
  52. package/cjs/es6/min/store/index.cjs.gz +0 -0
  53. package/cjs/es6/min/store/with-schemas/index.cjs +1 -1
  54. package/cjs/es6/min/store/with-schemas/index.cjs.gz +0 -0
  55. package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
  56. package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
  57. package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
  58. package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
  59. package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
  60. package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
  61. package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
  62. package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
  63. package/cjs/es6/min/ui-react-inspector/index.cjs +1 -1
  64. package/cjs/es6/min/ui-react-inspector/index.cjs.gz +0 -0
  65. package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs +1 -1
  66. package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
  67. package/cjs/es6/min/with-schemas/index.cjs +1 -1
  68. package/cjs/es6/min/with-schemas/index.cjs.gz +0 -0
  69. package/cjs/es6/synchronizers/synchronizer-ws-server/index.cjs +11 -4
  70. package/cjs/es6/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +11 -4
  71. package/cjs/min/checkpoints/index.cjs +1 -1
  72. package/cjs/min/checkpoints/index.cjs.gz +0 -0
  73. package/cjs/min/checkpoints/with-schemas/index.cjs +1 -1
  74. package/cjs/min/checkpoints/with-schemas/index.cjs.gz +0 -0
  75. package/cjs/min/index.cjs +1 -1
  76. package/cjs/min/index.cjs.gz +0 -0
  77. package/cjs/min/indexes/index.cjs +1 -1
  78. package/cjs/min/indexes/index.cjs.gz +0 -0
  79. package/cjs/min/indexes/with-schemas/index.cjs +1 -1
  80. package/cjs/min/indexes/with-schemas/index.cjs.gz +0 -0
  81. package/cjs/min/mergeable-store/index.cjs +1 -1
  82. package/cjs/min/mergeable-store/index.cjs.gz +0 -0
  83. package/cjs/min/mergeable-store/with-schemas/index.cjs +1 -1
  84. package/cjs/min/mergeable-store/with-schemas/index.cjs.gz +0 -0
  85. package/cjs/min/metrics/index.cjs +1 -1
  86. package/cjs/min/metrics/index.cjs.gz +0 -0
  87. package/cjs/min/metrics/with-schemas/index.cjs +1 -1
  88. package/cjs/min/metrics/with-schemas/index.cjs.gz +0 -0
  89. package/cjs/min/persisters/persister-automerge/index.cjs +1 -1
  90. package/cjs/min/persisters/persister-automerge/index.cjs.gz +0 -0
  91. package/cjs/min/persisters/persister-automerge/with-schemas/index.cjs +1 -1
  92. package/cjs/min/persisters/persister-automerge/with-schemas/index.cjs.gz +0 -0
  93. package/cjs/min/persisters/persister-indexed-db/index.cjs +1 -1
  94. package/cjs/min/persisters/persister-indexed-db/index.cjs.gz +0 -0
  95. package/cjs/min/persisters/persister-indexed-db/with-schemas/index.cjs +1 -1
  96. package/cjs/min/persisters/persister-indexed-db/with-schemas/index.cjs.gz +0 -0
  97. package/cjs/min/persisters/persister-partykit-client/index.cjs +1 -1
  98. package/cjs/min/persisters/persister-partykit-client/index.cjs.gz +0 -0
  99. package/cjs/min/persisters/persister-partykit-client/with-schemas/index.cjs +1 -1
  100. package/cjs/min/persisters/persister-partykit-client/with-schemas/index.cjs.gz +0 -0
  101. package/cjs/min/persisters/persister-yjs/index.cjs +1 -1
  102. package/cjs/min/persisters/persister-yjs/index.cjs.gz +0 -0
  103. package/cjs/min/persisters/persister-yjs/with-schemas/index.cjs +1 -1
  104. package/cjs/min/persisters/persister-yjs/with-schemas/index.cjs.gz +0 -0
  105. package/cjs/min/queries/index.cjs +1 -1
  106. package/cjs/min/queries/index.cjs.gz +0 -0
  107. package/cjs/min/queries/with-schemas/index.cjs +1 -1
  108. package/cjs/min/queries/with-schemas/index.cjs.gz +0 -0
  109. package/cjs/min/relationships/index.cjs +1 -1
  110. package/cjs/min/relationships/index.cjs.gz +0 -0
  111. package/cjs/min/relationships/with-schemas/index.cjs +1 -1
  112. package/cjs/min/relationships/with-schemas/index.cjs.gz +0 -0
  113. package/cjs/min/store/index.cjs +1 -1
  114. package/cjs/min/store/index.cjs.gz +0 -0
  115. package/cjs/min/store/with-schemas/index.cjs +1 -1
  116. package/cjs/min/store/with-schemas/index.cjs.gz +0 -0
  117. package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
  118. package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
  119. package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
  120. package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
  121. package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
  122. package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
  123. package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
  124. package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
  125. package/cjs/min/ui-react-inspector/index.cjs +1 -1
  126. package/cjs/min/ui-react-inspector/index.cjs.gz +0 -0
  127. package/cjs/min/ui-react-inspector/with-schemas/index.cjs +1 -1
  128. package/cjs/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
  129. package/cjs/min/with-schemas/index.cjs +1 -1
  130. package/cjs/min/with-schemas/index.cjs.gz +0 -0
  131. package/cjs/synchronizers/synchronizer-ws-server/index.cjs +11 -4
  132. package/cjs/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +11 -4
  133. package/es6/min/checkpoints/index.js +1 -1
  134. package/es6/min/checkpoints/index.js.gz +0 -0
  135. package/es6/min/checkpoints/with-schemas/index.js +1 -1
  136. package/es6/min/checkpoints/with-schemas/index.js.gz +0 -0
  137. package/es6/min/index.js +1 -1
  138. package/es6/min/index.js.gz +0 -0
  139. package/es6/min/indexes/index.js +1 -1
  140. package/es6/min/indexes/index.js.gz +0 -0
  141. package/es6/min/indexes/with-schemas/index.js +1 -1
  142. package/es6/min/indexes/with-schemas/index.js.gz +0 -0
  143. package/es6/min/mergeable-store/index.js +1 -1
  144. package/es6/min/mergeable-store/index.js.gz +0 -0
  145. package/es6/min/mergeable-store/with-schemas/index.js +1 -1
  146. package/es6/min/mergeable-store/with-schemas/index.js.gz +0 -0
  147. package/es6/min/metrics/index.js +1 -1
  148. package/es6/min/metrics/index.js.gz +0 -0
  149. package/es6/min/metrics/with-schemas/index.js +1 -1
  150. package/es6/min/metrics/with-schemas/index.js.gz +0 -0
  151. package/es6/min/persisters/persister-automerge/index.js +1 -1
  152. package/es6/min/persisters/persister-automerge/index.js.gz +0 -0
  153. package/es6/min/persisters/persister-automerge/with-schemas/index.js +1 -1
  154. package/es6/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
  155. package/es6/min/persisters/persister-indexed-db/index.js +1 -1
  156. package/es6/min/persisters/persister-indexed-db/index.js.gz +0 -0
  157. package/es6/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
  158. package/es6/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
  159. package/es6/min/persisters/persister-partykit-client/index.js +1 -1
  160. package/es6/min/persisters/persister-partykit-client/index.js.gz +0 -0
  161. package/es6/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
  162. package/es6/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
  163. package/es6/min/persisters/persister-yjs/index.js +1 -1
  164. package/es6/min/persisters/persister-yjs/index.js.gz +0 -0
  165. package/es6/min/persisters/persister-yjs/with-schemas/index.js +1 -1
  166. package/es6/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
  167. package/es6/min/queries/index.js +1 -1
  168. package/es6/min/queries/index.js.gz +0 -0
  169. package/es6/min/queries/with-schemas/index.js +1 -1
  170. package/es6/min/queries/with-schemas/index.js.gz +0 -0
  171. package/es6/min/relationships/index.js +1 -1
  172. package/es6/min/relationships/index.js.gz +0 -0
  173. package/es6/min/relationships/with-schemas/index.js +1 -1
  174. package/es6/min/relationships/with-schemas/index.js.gz +0 -0
  175. package/es6/min/store/index.js +1 -1
  176. package/es6/min/store/index.js.gz +0 -0
  177. package/es6/min/store/with-schemas/index.js +1 -1
  178. package/es6/min/store/with-schemas/index.js.gz +0 -0
  179. package/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  180. package/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  181. package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  182. package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  183. package/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  184. package/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  185. package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  186. package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  187. package/es6/min/ui-react-inspector/index.js +1 -1
  188. package/es6/min/ui-react-inspector/index.js.gz +0 -0
  189. package/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
  190. package/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  191. package/es6/min/with-schemas/index.js +1 -1
  192. package/es6/min/with-schemas/index.js.gz +0 -0
  193. package/es6/synchronizers/synchronizer-ws-server/index.js +11 -4
  194. package/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +11 -4
  195. package/min/checkpoints/index.js +1 -1
  196. package/min/checkpoints/index.js.gz +0 -0
  197. package/min/checkpoints/with-schemas/index.js +1 -1
  198. package/min/checkpoints/with-schemas/index.js.gz +0 -0
  199. package/min/index.js +1 -1
  200. package/min/index.js.gz +0 -0
  201. package/min/indexes/index.js +1 -1
  202. package/min/indexes/index.js.gz +0 -0
  203. package/min/indexes/with-schemas/index.js +1 -1
  204. package/min/indexes/with-schemas/index.js.gz +0 -0
  205. package/min/mergeable-store/index.js +1 -1
  206. package/min/mergeable-store/index.js.gz +0 -0
  207. package/min/mergeable-store/with-schemas/index.js +1 -1
  208. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  209. package/min/metrics/index.js +1 -1
  210. package/min/metrics/index.js.gz +0 -0
  211. package/min/metrics/with-schemas/index.js +1 -1
  212. package/min/metrics/with-schemas/index.js.gz +0 -0
  213. package/min/persisters/persister-automerge/index.js +1 -1
  214. package/min/persisters/persister-automerge/index.js.gz +0 -0
  215. package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
  216. package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
  217. package/min/persisters/persister-indexed-db/index.js +1 -1
  218. package/min/persisters/persister-indexed-db/index.js.gz +0 -0
  219. package/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
  220. package/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
  221. package/min/persisters/persister-partykit-client/index.js +1 -1
  222. package/min/persisters/persister-partykit-client/index.js.gz +0 -0
  223. package/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
  224. package/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
  225. package/min/persisters/persister-yjs/index.js +1 -1
  226. package/min/persisters/persister-yjs/index.js.gz +0 -0
  227. package/min/persisters/persister-yjs/with-schemas/index.js +1 -1
  228. package/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
  229. package/min/queries/index.js +1 -1
  230. package/min/queries/index.js.gz +0 -0
  231. package/min/queries/with-schemas/index.js +1 -1
  232. package/min/queries/with-schemas/index.js.gz +0 -0
  233. package/min/relationships/index.js +1 -1
  234. package/min/relationships/index.js.gz +0 -0
  235. package/min/relationships/with-schemas/index.js +1 -1
  236. package/min/relationships/with-schemas/index.js.gz +0 -0
  237. package/min/store/index.js +1 -1
  238. package/min/store/index.js.gz +0 -0
  239. package/min/store/with-schemas/index.js +1 -1
  240. package/min/store/with-schemas/index.js.gz +0 -0
  241. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  242. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  243. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  244. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  245. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  246. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  247. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  248. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  249. package/min/ui-react-inspector/index.js +1 -1
  250. package/min/ui-react-inspector/index.js.gz +0 -0
  251. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  252. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  253. package/min/with-schemas/index.js +1 -1
  254. package/min/with-schemas/index.js.gz +0 -0
  255. package/package.json +4 -4
  256. package/readme.md +1 -1
  257. package/synchronizers/synchronizer-ws-server/index.js +11 -4
  258. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +11 -4
  259. package/umd/es6/min/checkpoints/index.js +1 -1
  260. package/umd/es6/min/checkpoints/index.js.gz +0 -0
  261. package/umd/es6/min/checkpoints/with-schemas/index.js +1 -1
  262. package/umd/es6/min/checkpoints/with-schemas/index.js.gz +0 -0
  263. package/umd/es6/min/index.js +1 -1
  264. package/umd/es6/min/index.js.gz +0 -0
  265. package/umd/es6/min/indexes/index.js +1 -1
  266. package/umd/es6/min/indexes/index.js.gz +0 -0
  267. package/umd/es6/min/indexes/with-schemas/index.js +1 -1
  268. package/umd/es6/min/indexes/with-schemas/index.js.gz +0 -0
  269. package/umd/es6/min/mergeable-store/index.js +1 -1
  270. package/umd/es6/min/mergeable-store/index.js.gz +0 -0
  271. package/umd/es6/min/mergeable-store/with-schemas/index.js +1 -1
  272. package/umd/es6/min/mergeable-store/with-schemas/index.js.gz +0 -0
  273. package/umd/es6/min/metrics/index.js +1 -1
  274. package/umd/es6/min/metrics/index.js.gz +0 -0
  275. package/umd/es6/min/metrics/with-schemas/index.js +1 -1
  276. package/umd/es6/min/metrics/with-schemas/index.js.gz +0 -0
  277. package/umd/es6/min/persisters/persister-automerge/index.js +1 -1
  278. package/umd/es6/min/persisters/persister-automerge/index.js.gz +0 -0
  279. package/umd/es6/min/persisters/persister-automerge/with-schemas/index.js +1 -1
  280. package/umd/es6/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
  281. package/umd/es6/min/persisters/persister-indexed-db/index.js +1 -1
  282. package/umd/es6/min/persisters/persister-indexed-db/index.js.gz +0 -0
  283. package/umd/es6/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
  284. package/umd/es6/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
  285. package/umd/es6/min/persisters/persister-partykit-client/index.js +1 -1
  286. package/umd/es6/min/persisters/persister-partykit-client/index.js.gz +0 -0
  287. package/umd/es6/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
  288. package/umd/es6/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
  289. package/umd/es6/min/persisters/persister-yjs/index.js +1 -1
  290. package/umd/es6/min/persisters/persister-yjs/index.js.gz +0 -0
  291. package/umd/es6/min/persisters/persister-yjs/with-schemas/index.js +1 -1
  292. package/umd/es6/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
  293. package/umd/es6/min/queries/index.js +1 -1
  294. package/umd/es6/min/queries/index.js.gz +0 -0
  295. package/umd/es6/min/queries/with-schemas/index.js +1 -1
  296. package/umd/es6/min/queries/with-schemas/index.js.gz +0 -0
  297. package/umd/es6/min/relationships/index.js +1 -1
  298. package/umd/es6/min/relationships/index.js.gz +0 -0
  299. package/umd/es6/min/relationships/with-schemas/index.js +1 -1
  300. package/umd/es6/min/relationships/with-schemas/index.js.gz +0 -0
  301. package/umd/es6/min/store/index.js +1 -1
  302. package/umd/es6/min/store/index.js.gz +0 -0
  303. package/umd/es6/min/store/with-schemas/index.js +1 -1
  304. package/umd/es6/min/store/with-schemas/index.js.gz +0 -0
  305. package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  306. package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  307. package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  308. package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  309. package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  310. package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  311. package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  312. package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  313. package/umd/es6/min/ui-react-inspector/index.js +1 -1
  314. package/umd/es6/min/ui-react-inspector/index.js.gz +0 -0
  315. package/umd/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
  316. package/umd/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  317. package/umd/es6/min/with-schemas/index.js +1 -1
  318. package/umd/es6/min/with-schemas/index.js.gz +0 -0
  319. package/umd/es6/synchronizers/synchronizer-ws-server/index.js +11 -4
  320. package/umd/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +11 -4
  321. package/umd/min/checkpoints/index.js +1 -1
  322. package/umd/min/checkpoints/index.js.gz +0 -0
  323. package/umd/min/checkpoints/with-schemas/index.js +1 -1
  324. package/umd/min/checkpoints/with-schemas/index.js.gz +0 -0
  325. package/umd/min/index.js +1 -1
  326. package/umd/min/index.js.gz +0 -0
  327. package/umd/min/indexes/index.js +1 -1
  328. package/umd/min/indexes/index.js.gz +0 -0
  329. package/umd/min/indexes/with-schemas/index.js +1 -1
  330. package/umd/min/indexes/with-schemas/index.js.gz +0 -0
  331. package/umd/min/mergeable-store/index.js +1 -1
  332. package/umd/min/mergeable-store/index.js.gz +0 -0
  333. package/umd/min/mergeable-store/with-schemas/index.js +1 -1
  334. package/umd/min/mergeable-store/with-schemas/index.js.gz +0 -0
  335. package/umd/min/metrics/index.js +1 -1
  336. package/umd/min/metrics/index.js.gz +0 -0
  337. package/umd/min/metrics/with-schemas/index.js +1 -1
  338. package/umd/min/metrics/with-schemas/index.js.gz +0 -0
  339. package/umd/min/persisters/persister-automerge/index.js +1 -1
  340. package/umd/min/persisters/persister-automerge/index.js.gz +0 -0
  341. package/umd/min/persisters/persister-automerge/with-schemas/index.js +1 -1
  342. package/umd/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
  343. package/umd/min/persisters/persister-indexed-db/index.js +1 -1
  344. package/umd/min/persisters/persister-indexed-db/index.js.gz +0 -0
  345. package/umd/min/persisters/persister-indexed-db/with-schemas/index.js +1 -1
  346. package/umd/min/persisters/persister-indexed-db/with-schemas/index.js.gz +0 -0
  347. package/umd/min/persisters/persister-partykit-client/index.js +1 -1
  348. package/umd/min/persisters/persister-partykit-client/index.js.gz +0 -0
  349. package/umd/min/persisters/persister-partykit-client/with-schemas/index.js +1 -1
  350. package/umd/min/persisters/persister-partykit-client/with-schemas/index.js.gz +0 -0
  351. package/umd/min/persisters/persister-yjs/index.js +1 -1
  352. package/umd/min/persisters/persister-yjs/index.js.gz +0 -0
  353. package/umd/min/persisters/persister-yjs/with-schemas/index.js +1 -1
  354. package/umd/min/persisters/persister-yjs/with-schemas/index.js.gz +0 -0
  355. package/umd/min/queries/index.js +1 -1
  356. package/umd/min/queries/index.js.gz +0 -0
  357. package/umd/min/queries/with-schemas/index.js +1 -1
  358. package/umd/min/queries/with-schemas/index.js.gz +0 -0
  359. package/umd/min/relationships/index.js +1 -1
  360. package/umd/min/relationships/index.js.gz +0 -0
  361. package/umd/min/relationships/with-schemas/index.js +1 -1
  362. package/umd/min/relationships/with-schemas/index.js.gz +0 -0
  363. package/umd/min/store/index.js +1 -1
  364. package/umd/min/store/index.js.gz +0 -0
  365. package/umd/min/store/with-schemas/index.js +1 -1
  366. package/umd/min/store/with-schemas/index.js.gz +0 -0
  367. package/umd/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  368. package/umd/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  369. package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  370. package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  371. package/umd/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  372. package/umd/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  373. package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  374. package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  375. package/umd/min/ui-react-inspector/index.js +1 -1
  376. package/umd/min/ui-react-inspector/index.js.gz +0 -0
  377. package/umd/min/ui-react-inspector/with-schemas/index.js +1 -1
  378. package/umd/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  379. package/umd/min/with-schemas/index.js +1 -1
  380. package/umd/min/with-schemas/index.js.gz +0 -0
  381. package/umd/synchronizers/synchronizer-ws-server/index.js +11 -4
  382. package/umd/synchronizers/synchronizer-ws-server/with-schemas/index.js +11 -4
@@ -81,6 +81,12 @@ export interface WsSynchronizer<WebSocketType extends WebSocketTypes>
81
81
  * As well as providing a reference to the MergeableStore to persist, you must
82
82
  * provide a configured WebSocket to send synchronization messages over.
83
83
  *
84
+ * Instead of the raw browser implementation of WebSocket You may prefer to use
85
+ * the [Reconnecting
86
+ * WebSocket](https://github.com/pladaria/reconnecting-websocket) wrapper so
87
+ * that if a client goes offline, it can easily re-establish a connection when
88
+ * it comes back online. Its API is compatible with this Synchronizer.
89
+ *
84
90
  * You can indicate how long the Synchronizer will wait for responses to message
85
91
  * requests before timing out. A final set of optional handlers can be provided
86
92
  * to help debug sends, receives, and errors respectively.
@@ -81,6 +81,12 @@ export interface WsSynchronizer<WebSocketType extends WebSocketTypes>
81
81
  * As well as providing a reference to the MergeableStore to persist, you must
82
82
  * provide a configured WebSocket to send synchronization messages over.
83
83
  *
84
+ * Instead of the raw browser implementation of WebSocket You may prefer to use
85
+ * the [Reconnecting
86
+ * WebSocket](https://github.com/pladaria/reconnecting-websocket) wrapper so
87
+ * that if a client goes offline, it can easily re-establish a connection when
88
+ * it comes back online. Its API is compatible with this Synchronizer.
89
+ *
84
90
  * You can indicate how long the Synchronizer will wait for responses to message
85
91
  * requests before timing out. A final set of optional handlers can be provided
86
92
  * to help debug sends, receives, and errors respectively.
@@ -97,6 +97,12 @@ export interface WsSynchronizer<
97
97
  * As well as providing a reference to the MergeableStore to persist, you must
98
98
  * provide a configured WebSocket to send synchronization messages over.
99
99
  *
100
+ * Instead of the raw browser implementation of WebSocket You may prefer to use
101
+ * the [Reconnecting
102
+ * WebSocket](https://github.com/pladaria/reconnecting-websocket) wrapper so
103
+ * that if a client goes offline, it can easily re-establish a connection when
104
+ * it comes back online. Its API is compatible with this Synchronizer.
105
+ *
100
106
  * You can indicate how long the Synchronizer will wait for responses to message
101
107
  * requests before timing out. A final set of optional handlers can be provided
102
108
  * to help debug sends, receives, and errors respectively.
@@ -97,6 +97,12 @@ export interface WsSynchronizer<
97
97
  * As well as providing a reference to the MergeableStore to persist, you must
98
98
  * provide a configured WebSocket to send synchronization messages over.
99
99
  *
100
+ * Instead of the raw browser implementation of WebSocket You may prefer to use
101
+ * the [Reconnecting
102
+ * WebSocket](https://github.com/pladaria/reconnecting-websocket) wrapper so
103
+ * that if a client goes offline, it can easily re-establish a connection when
104
+ * it comes back online. Its API is compatible with this Synchronizer.
105
+ *
100
106
  * You can indicate how long the Synchronizer will wait for responses to message
101
107
  * requests before timing out. A final set of optional handlers can be provided
102
108
  * to help debug sends, receives, and errors respectively.
@@ -11,6 +11,7 @@
11
11
  import type {Id, IdOrNull, Ids} from '../../common/index.d.cts';
12
12
  import type {Persister, Persists} from '../../persisters/index.d.cts';
13
13
  import type {IdAddedOrRemoved} from '../../store/index.d.cts';
14
+ import type {MergeableStore} from '../../mergeable-store/index.d.cts';
14
15
  import type {WebSocketServer} from 'ws';
15
16
 
16
17
  /**
@@ -509,10 +510,20 @@ export interface WsServer {
509
510
  * by the WsServer. As a result, the server MergeableStore will be kept in sync
510
511
  * with the clients on that path, and in turn with whatever persistence layer
511
512
  * you have configured. See the example below.
513
+ *
514
+ * It is not safe to add or manipulate data in the MergeableStore during the
515
+ * `createPersisterForPath` function, since changes will probably be overwritten
516
+ * when the Persister starts. If you wish to modify data - or upgrade a schema,
517
+ * for example - you can have that function instead return an array containing
518
+ * the Persister _and_ a callback that takes the MergeableStore. That callback
519
+ * will get called after the Persister has started, and is an appropriate place
520
+ * to manipulate data in a way that will be transmitted to clients. Again, see
521
+ * the example below.
512
522
  * @param webSocketServer A WebSocketServer object from your server environment.
513
523
  * @param createPersisterForPath An optional function that will create a
514
- * Persister (with a MergeableStore) to synchronize with the clients on a given
515
- * path.
524
+ * Persister to synchronize with the clients on a given path (or a two-item
525
+ * array of Persister and callback that lets you handle data after persistence
526
+ * has started).
516
527
  * @returns A reference to the new WsServer object.
517
528
  * @example
518
529
  * This example creates a WsServer that synchronizes two clients on a shared
@@ -626,6 +637,46 @@ export interface WsServer {
626
637
  * rmSync('petShop.json');
627
638
  * ```
628
639
  * @example
640
+ * This example creates a WsServer that persists a MergeableStore to file that
641
+ * is synchronized with two clients on a shared path, but also which updates its
642
+ * data once synchronization has started.
643
+ *
644
+ * ```js
645
+ * import {WebSocketServer} from 'ws';
646
+ * import {createFilePersister} from 'tinybase/persisters/persister-file';
647
+ * import {createMergeableStore} from 'tinybase';
648
+ * import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server';
649
+ * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
650
+ * import {rmSync} from 'fs';
651
+ *
652
+ * // Server
653
+ * const server = createWsServer(
654
+ * new WebSocketServer({port: 8047}),
655
+ * (pathId) => [
656
+ * createFilePersister(createMergeableStore(), pathId + '.json'),
657
+ * (store) => store.setValue('pathId', pathId),
658
+ * ],
659
+ * );
660
+ *
661
+ * const clientStore = createMergeableStore();
662
+ * clientStore.setCell('pets', 'fido', 'species', 'dog');
663
+ * const synchronizer = await createWsSynchronizer(
664
+ * clientStore,
665
+ * new WebSocket('ws://localhost:8047/petShop'),
666
+ * );
667
+ * await synchronizer.startSync();
668
+ * // ...
669
+ *
670
+ * console.log(clientStore.getContent());
671
+ * // -> [{pets: {fido: {species: 'dog'}}}, {"pathId": "petShop"}]
672
+ *
673
+ * synchronizer.destroy();
674
+ * server.destroy();
675
+ *
676
+ * // Remove file for the purposes of this demo.
677
+ * rmSync('petShop.json');
678
+ * ```
679
+ * @example
629
680
  * This example creates a WsServer with a custom listener that displays
630
681
  * information about the address of the client that connects to it.
631
682
  *
@@ -661,5 +712,10 @@ export function createWsServer<
661
712
  >,
662
713
  >(
663
714
  webSocketServer: WebSocketServer,
664
- createPersisterForPath?: (pathId: Id) => PathPersister | undefined,
715
+ createPersisterForPath?: (
716
+ pathId: Id,
717
+ ) =>
718
+ | PathPersister
719
+ | [PathPersister, (store: MergeableStore) => void]
720
+ | undefined,
665
721
  ): WsServer;
@@ -11,6 +11,7 @@
11
11
  import type {Id, IdOrNull, Ids} from '../../common/index.d.ts';
12
12
  import type {Persister, Persists} from '../../persisters/index.d.ts';
13
13
  import type {IdAddedOrRemoved} from '../../store/index.d.ts';
14
+ import type {MergeableStore} from '../../mergeable-store/index.d.ts';
14
15
  import type {WebSocketServer} from 'ws';
15
16
 
16
17
  /**
@@ -509,10 +510,20 @@ export interface WsServer {
509
510
  * by the WsServer. As a result, the server MergeableStore will be kept in sync
510
511
  * with the clients on that path, and in turn with whatever persistence layer
511
512
  * you have configured. See the example below.
513
+ *
514
+ * It is not safe to add or manipulate data in the MergeableStore during the
515
+ * `createPersisterForPath` function, since changes will probably be overwritten
516
+ * when the Persister starts. If you wish to modify data - or upgrade a schema,
517
+ * for example - you can have that function instead return an array containing
518
+ * the Persister _and_ a callback that takes the MergeableStore. That callback
519
+ * will get called after the Persister has started, and is an appropriate place
520
+ * to manipulate data in a way that will be transmitted to clients. Again, see
521
+ * the example below.
512
522
  * @param webSocketServer A WebSocketServer object from your server environment.
513
523
  * @param createPersisterForPath An optional function that will create a
514
- * Persister (with a MergeableStore) to synchronize with the clients on a given
515
- * path.
524
+ * Persister to synchronize with the clients on a given path (or a two-item
525
+ * array of Persister and callback that lets you handle data after persistence
526
+ * has started).
516
527
  * @returns A reference to the new WsServer object.
517
528
  * @example
518
529
  * This example creates a WsServer that synchronizes two clients on a shared
@@ -626,6 +637,46 @@ export interface WsServer {
626
637
  * rmSync('petShop.json');
627
638
  * ```
628
639
  * @example
640
+ * This example creates a WsServer that persists a MergeableStore to file that
641
+ * is synchronized with two clients on a shared path, but also which updates its
642
+ * data once synchronization has started.
643
+ *
644
+ * ```js
645
+ * import {WebSocketServer} from 'ws';
646
+ * import {createFilePersister} from 'tinybase/persisters/persister-file';
647
+ * import {createMergeableStore} from 'tinybase';
648
+ * import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server';
649
+ * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
650
+ * import {rmSync} from 'fs';
651
+ *
652
+ * // Server
653
+ * const server = createWsServer(
654
+ * new WebSocketServer({port: 8047}),
655
+ * (pathId) => [
656
+ * createFilePersister(createMergeableStore(), pathId + '.json'),
657
+ * (store) => store.setValue('pathId', pathId),
658
+ * ],
659
+ * );
660
+ *
661
+ * const clientStore = createMergeableStore();
662
+ * clientStore.setCell('pets', 'fido', 'species', 'dog');
663
+ * const synchronizer = await createWsSynchronizer(
664
+ * clientStore,
665
+ * new WebSocket('ws://localhost:8047/petShop'),
666
+ * );
667
+ * await synchronizer.startSync();
668
+ * // ...
669
+ *
670
+ * console.log(clientStore.getContent());
671
+ * // -> [{pets: {fido: {species: 'dog'}}}, {"pathId": "petShop"}]
672
+ *
673
+ * synchronizer.destroy();
674
+ * server.destroy();
675
+ *
676
+ * // Remove file for the purposes of this demo.
677
+ * rmSync('petShop.json');
678
+ * ```
679
+ * @example
629
680
  * This example creates a WsServer with a custom listener that displays
630
681
  * information about the address of the client that connects to it.
631
682
  *
@@ -661,5 +712,10 @@ export function createWsServer<
661
712
  >,
662
713
  >(
663
714
  webSocketServer: WebSocketServer,
664
- createPersisterForPath?: (pathId: Id) => PathPersister | undefined,
715
+ createPersisterForPath?: (
716
+ pathId: Id,
717
+ ) =>
718
+ | PathPersister
719
+ | [PathPersister, (store: MergeableStore) => void]
720
+ | undefined,
665
721
  ): WsServer;
@@ -17,6 +17,7 @@ import type {
17
17
  Persister,
18
18
  Persists,
19
19
  } from '../../../persisters/with-schemas/index.d.cts';
20
+ import type {MergeableStore} from '../../../mergeable-store/with-schemas/index.d.cts';
20
21
  import type {WebSocketServer} from 'ws';
21
22
 
22
23
  /**
@@ -511,7 +512,12 @@ export interface WsServer {
511
512
  * >,
512
513
  * >(
513
514
  * webSocketServer: WebSocketServer,
514
- * createPersisterForPath?: (pathId: Id) => PathPersister | undefined,
515
+ * createPersisterForPath?: (
516
+ * pathId: Id,
517
+ * ) =>
518
+ * | PathPersister
519
+ * | [PathPersister, (store: MergeableStore) => void]
520
+ * | undefined,
515
521
  * ): WsServer;
516
522
  * ```
517
523
  *
@@ -528,10 +534,20 @@ export interface WsServer {
528
534
  * by the WsServer. As a result, the server MergeableStore will be kept in sync
529
535
  * with the clients on that path, and in turn with whatever persistence layer
530
536
  * you have configured. See the example below.
537
+ *
538
+ * It is not safe to add or manipulate data in the MergeableStore during the
539
+ * `createPersisterForPath` function, since changes will probably be overwritten
540
+ * when the Persister starts. If you wish to modify data - or upgrade a schema,
541
+ * for example - you can have that function instead return an array containing
542
+ * the Persister _and_ a callback that takes the MergeableStore. That callback
543
+ * will get called after the Persister has started, and is an appropriate place
544
+ * to manipulate data in a way that will be transmitted to clients. Again, see
545
+ * the example below.
531
546
  * @param webSocketServer A WebSocketServer object from your server environment.
532
547
  * @param createPersisterForPath An optional function that will create a
533
- * Persister (with a MergeableStore) to synchronize with the clients on a given
534
- * path.
548
+ * Persister to synchronize with the clients on a given path (or a two-item
549
+ * array of Persister and callback that lets you handle data after persistence
550
+ * has started).
535
551
  * @returns A reference to the new WsServer object.
536
552
  * @example
537
553
  * This example creates a WsServer that synchronizes two clients on a shared
@@ -645,6 +661,46 @@ export interface WsServer {
645
661
  * rmSync('petShop.json');
646
662
  * ```
647
663
  * @example
664
+ * This example creates a WsServer that persists a MergeableStore to file that
665
+ * is synchronized with two clients on a shared path, but also which updates its
666
+ * data once synchronization has started.
667
+ *
668
+ * ```js
669
+ * import {WebSocketServer} from 'ws';
670
+ * import {createFilePersister} from 'tinybase/persisters/persister-file';
671
+ * import {createMergeableStore} from 'tinybase';
672
+ * import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server';
673
+ * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
674
+ * import {rmSync} from 'fs';
675
+ *
676
+ * // Server
677
+ * const server = createWsServer(
678
+ * new WebSocketServer({port: 8047}),
679
+ * (pathId) => [
680
+ * createFilePersister(createMergeableStore(), pathId + '.json'),
681
+ * (store) => store.setValue('pathId', pathId),
682
+ * ],
683
+ * );
684
+ *
685
+ * const clientStore = createMergeableStore();
686
+ * clientStore.setCell('pets', 'fido', 'species', 'dog');
687
+ * const synchronizer = await createWsSynchronizer(
688
+ * clientStore,
689
+ * new WebSocket('ws://localhost:8047/petShop'),
690
+ * );
691
+ * await synchronizer.startSync();
692
+ * // ...
693
+ *
694
+ * console.log(clientStore.getContent());
695
+ * // -> [{pets: {fido: {species: 'dog'}}}, {"pathId": "petShop"}]
696
+ *
697
+ * synchronizer.destroy();
698
+ * server.destroy();
699
+ *
700
+ * // Remove file for the purposes of this demo.
701
+ * rmSync('petShop.json');
702
+ * ```
703
+ * @example
648
704
  * This example creates a WsServer with a custom listener that displays
649
705
  * information about the address of the client that connects to it.
650
706
  *
@@ -682,5 +738,10 @@ export function createWsServer<
682
738
  >,
683
739
  >(
684
740
  webSocketServer: WebSocketServer,
685
- createPersisterForPath?: (pathId: Id) => PathPersister | undefined,
741
+ createPersisterForPath?: (
742
+ pathId: Id,
743
+ ) =>
744
+ | PathPersister
745
+ | [PathPersister, (store: MergeableStore<Schemas>) => void]
746
+ | undefined,
686
747
  ): WsServer;
@@ -17,6 +17,7 @@ import type {
17
17
  Persister,
18
18
  Persists,
19
19
  } from '../../../persisters/with-schemas/index.d.ts';
20
+ import type {MergeableStore} from '../../../mergeable-store/with-schemas/index.d.ts';
20
21
  import type {WebSocketServer} from 'ws';
21
22
 
22
23
  /**
@@ -511,7 +512,12 @@ export interface WsServer {
511
512
  * >,
512
513
  * >(
513
514
  * webSocketServer: WebSocketServer,
514
- * createPersisterForPath?: (pathId: Id) => PathPersister | undefined,
515
+ * createPersisterForPath?: (
516
+ * pathId: Id,
517
+ * ) =>
518
+ * | PathPersister
519
+ * | [PathPersister, (store: MergeableStore) => void]
520
+ * | undefined,
515
521
  * ): WsServer;
516
522
  * ```
517
523
  *
@@ -528,10 +534,20 @@ export interface WsServer {
528
534
  * by the WsServer. As a result, the server MergeableStore will be kept in sync
529
535
  * with the clients on that path, and in turn with whatever persistence layer
530
536
  * you have configured. See the example below.
537
+ *
538
+ * It is not safe to add or manipulate data in the MergeableStore during the
539
+ * `createPersisterForPath` function, since changes will probably be overwritten
540
+ * when the Persister starts. If you wish to modify data - or upgrade a schema,
541
+ * for example - you can have that function instead return an array containing
542
+ * the Persister _and_ a callback that takes the MergeableStore. That callback
543
+ * will get called after the Persister has started, and is an appropriate place
544
+ * to manipulate data in a way that will be transmitted to clients. Again, see
545
+ * the example below.
531
546
  * @param webSocketServer A WebSocketServer object from your server environment.
532
547
  * @param createPersisterForPath An optional function that will create a
533
- * Persister (with a MergeableStore) to synchronize with the clients on a given
534
- * path.
548
+ * Persister to synchronize with the clients on a given path (or a two-item
549
+ * array of Persister and callback that lets you handle data after persistence
550
+ * has started).
535
551
  * @returns A reference to the new WsServer object.
536
552
  * @example
537
553
  * This example creates a WsServer that synchronizes two clients on a shared
@@ -645,6 +661,46 @@ export interface WsServer {
645
661
  * rmSync('petShop.json');
646
662
  * ```
647
663
  * @example
664
+ * This example creates a WsServer that persists a MergeableStore to file that
665
+ * is synchronized with two clients on a shared path, but also which updates its
666
+ * data once synchronization has started.
667
+ *
668
+ * ```js
669
+ * import {WebSocketServer} from 'ws';
670
+ * import {createFilePersister} from 'tinybase/persisters/persister-file';
671
+ * import {createMergeableStore} from 'tinybase';
672
+ * import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server';
673
+ * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
674
+ * import {rmSync} from 'fs';
675
+ *
676
+ * // Server
677
+ * const server = createWsServer(
678
+ * new WebSocketServer({port: 8047}),
679
+ * (pathId) => [
680
+ * createFilePersister(createMergeableStore(), pathId + '.json'),
681
+ * (store) => store.setValue('pathId', pathId),
682
+ * ],
683
+ * );
684
+ *
685
+ * const clientStore = createMergeableStore();
686
+ * clientStore.setCell('pets', 'fido', 'species', 'dog');
687
+ * const synchronizer = await createWsSynchronizer(
688
+ * clientStore,
689
+ * new WebSocket('ws://localhost:8047/petShop'),
690
+ * );
691
+ * await synchronizer.startSync();
692
+ * // ...
693
+ *
694
+ * console.log(clientStore.getContent());
695
+ * // -> [{pets: {fido: {species: 'dog'}}}, {"pathId": "petShop"}]
696
+ *
697
+ * synchronizer.destroy();
698
+ * server.destroy();
699
+ *
700
+ * // Remove file for the purposes of this demo.
701
+ * rmSync('petShop.json');
702
+ * ```
703
+ * @example
648
704
  * This example creates a WsServer with a custom listener that displays
649
705
  * information about the address of the client that connects to it.
650
706
  *
@@ -682,5 +738,10 @@ export function createWsServer<
682
738
  >,
683
739
  >(
684
740
  webSocketServer: WebSocketServer,
685
- createPersisterForPath?: (pathId: Id) => PathPersister | undefined,
741
+ createPersisterForPath?: (
742
+ pathId: Id,
743
+ ) =>
744
+ | PathPersister
745
+ | [PathPersister, (store: MergeableStore<Schemas>) => void]
746
+ | undefined,
686
747
  ): WsServer;
@@ -1 +1 @@
1
- "use strict";const e=e=>null==e,n=(n,t,l)=>e(n)?void 0:t(n),t=e=>e.length,l=(e,n)=>e.includes(n),r=(e,n)=>e.forEach(n),s=e=>0==t(e),o=(e,...n)=>e.push(...n),u=e=>e.pop(),i=e=>e.shift(),c=Object.freeze,d=e=>{var n;return null!=(n=null==e?void 0:e.size)?n:0},a=(v=d,e=>{return n=(e,n)=>e+v(n),k(e).reduce(n,0);var n});var v;const h=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},p=n=>e(n)||0==d(n),k=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},g=(e,n)=>null==e?void 0:e.forEach(n),C=(e,n)=>null==e?void 0:e.delete(n),f=e=>new Map(e),L=(e,n)=>null==e?void 0:e.get(n),w=(n,t,l)=>e(l)?(C(n,t),n):null==n?void 0:n.set(t,l),S=(e,n,t,l)=>(h(e,n)?null==l||l(L(e,n)):w(e,n,t()),L(e,n)),y=(e,l,r,s,o=0)=>n((r?S:L)(e,l[o],o>t(l)-2?r:f),(n=>{if(o>t(l)-2)return(null==s?void 0:s(n))&&w(e,l[o]),n;const u=y(n,l,r,s,o+1);return p(n)&&w(e,l[o]),u})),z=n=>new Set(Array.isArray(n)||e(n)?n:[n]),E=/^\d+$/,I=((d,v)=>{const k=new WeakMap;return d=>{k.has(d)||k.set(d,(d=>{let v,k,I,V=100,A=f(),F=f(),M=1;const _=f(),b=f(),[j,x,B]=(l=>{let s;const[u,c]=(()=>{const e=[];let n=0;return[t=>{var l;return null!=(l=t?i(e):null)?l:""+n++},n=>{E.test(n)&&t(e)<1e3&&o(e,n)}]})(),d=f();return[(e,n,t,l=[],r=(()=>[]))=>{null!=s||(s=ee);const o=u(1);var i,c;return w(d,o,[e,n,t,l,r]),c=o,null==(i=y(n,null!=t?t:[""],z))||i.add(c),o},(e,n,...l)=>r(((e,n=[""])=>{const l=[],s=(e,u)=>u==t(n)?o(l,e):null===n[u]?g(e,(e=>s(e,u+1))):r([n[u],null],(n=>s(L(e,n),u+1)));return s(e,0),l})(e,n),(e=>g(e,(e=>L(d,e)[0](s,...null!=n?n:[],...l))))),e=>n(L(d,e),(([,n,t])=>(y(n,null!=t?t:[""],void 0,(n=>(C(n,e),p(n)?1:0))),w(d,e),c(e),t))),l=>n(L(d,l),(([n,,l=[],o,u])=>{const i=(...c)=>{var d,a;const v=t(c);v==t(l)?n(s,...c,...u(c)):e(l[v])?r(null!=(a=null==(d=o[v])?void 0:d.call(o,...c))?a:[],(e=>i(...c,e))):i(...c,l[v])};i()}))]})(),O=f(),T=f(),W=[],$=[],m=(n,t)=>{M=0,d.transaction((()=>{const[l,r]=L(O,t);g(l,((t,l)=>g(t,((t,r)=>g(t,((t,s)=>((n,t,l,r,s)=>e(s)?n.delCell(t,l,r,!0):n.setCell(t,l,r,s))(d,l,r,s,t[n]))))))),g(r,((t,l)=>((n,t,l)=>e(l)?n.delValue(t):n.setValue(t,l))(d,l,t[n])))})),M=1},q=e=>{w(O,e),w(T,e),x(b,[e])},D=(e,n)=>r(((e,n)=>e.splice(0,n))(e,null!=n?n:t(e)),q),G=()=>D(W,t(W)-V),H=()=>n(v,(()=>{o(W,v),G(),D($),v=void 0,I=1})),J=()=>{v=u(W),I=1};let K,N;const P=(n="")=>(e(v)&&(v=""+k++,w(O,v,[A,F]),Y(v,n),A=f(),F=f(),I=1),v),Q=()=>{s(W)||(((e,...n)=>{e.unshift(...n)})($,P()),m(0,v),v=u(W),I=1)},R=()=>{s($)||(o(W,v),v=i($),m(1,v),I=1)},U=()=>{I&&(x(_),I=0)},X=e=>{const n=P(e);return U(),n},Y=(e,n)=>(Z(e)&&L(T,e)!==n&&(w(T,e,n),x(b,[e])),ee),Z=e=>h(O,e),ee={setSize:e=>(V=e,G(),ee),addCheckpoint:X,setCheckpoint:Y,getStore:()=>d,getCheckpointIds:()=>[[...W],v,[...$]],forEachCheckpoint:e=>{return n=e,g(T,((e,t)=>n(t,e)));var n},hasCheckpoint:Z,getCheckpoint:e=>L(T,e),goBackward:()=>(Q(),U(),ee),goForward:()=>(R(),U(),ee),goTo:n=>{const t=l(W,n)?Q:l($,n)?R:null;for(;!e(t)&&n!=v;)t();return U(),ee},addCheckpointIdsListener:e=>j(e,_),addCheckpointListener:(e,n)=>j(n,b,[e]),delListener:e=>(B(e),ee),clear:()=>(D(W),D($),e(v)||q(v),v=void 0,k=0,X(),ee),clearForward:()=>(s($)||(D($),x(_)),ee),destroy:()=>{d.delListener(K),d.delListener(N)},getListenerStats:()=>({checkpointIds:a(_),checkpoint:a(b)}),_registerListeners:()=>{K=d.addCellListener(null,null,null,((e,n,t,l,r,s)=>{if(M){H();const e=S(A,n,f),o=S(e,t,f),u=S(o,l,(()=>[s,void 0]));u[1]=r,u[0]===r&&p(w(o,l))&&p(w(e,t))&&p(w(A,n))&&J(),U()}})),N=d.addValueListener(null,((e,n,t,l)=>{if(M){H();const e=S(F,n,(()=>[l,void 0]));e[1]=t,e[0]===t&&p(w(F,n))&&J(),U()}}))}};return c(ee.clear())})(d));const I=k.get(d);return null==v||v(I),I}})(0,(e=>e._registerListeners()));exports.createCheckpoints=I;
1
+ "use strict";const e=e=>null==e,n=(n,t,l)=>e(n)?void 0:t(n),t=e=>e.length,l=(e,n)=>e.includes(n),r=(e,n)=>e.forEach(n),s=e=>0==t(e),o=(e,...n)=>e.push(...n),u=e=>e.pop(),i=e=>e.shift(),c=Object.freeze,d=e=>{var n;return null!=(n=null==e?void 0:e.size)?n:0},a=(v=d,e=>{return n=(e,n)=>e+v(n),k(e).reduce(n,0);var n});var v;const h=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},p=n=>e(n)||0==d(n),k=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},g=(e,n)=>null==e?void 0:e.forEach(n),C=(e,n)=>null==e?void 0:e.delete(n),f=e=>new Map(e),L=(e,n)=>null==e?void 0:e.get(n),w=(n,t,l)=>e(l)?(C(n,t),n):null==n?void 0:n.set(t,l),S=(e,n,t,l)=>(h(e,n)?null==l||l(L(e,n)):w(e,n,t()),L(e,n)),y=(e,l,r,s,o=0)=>n((r?S:L)(e,l[o],o>t(l)-2?r:f),(n=>{if(o>t(l)-2)return(null==s?void 0:s(n))&&w(e,l[o]),n;const u=y(n,l,r,s,o+1);return p(n)&&w(e,l[o]),u})),z=n=>new Set(Array.isArray(n)||e(n)?n:[n]),E=/^\d+$/,I=((d,v)=>{const k=new WeakMap;return d=>{k.has(d)||k.set(d,(d=>{let v,k,I,V=100,A=f(),F=f(),M=1;const _=f(),b=f(),[j,x,B]=(()=>{let l;const[s,u]=(()=>{const e=[];let n=0;return[t=>{var l;return null!=(l=t?i(e):null)?l:""+n++},n=>{E.test(n)&&t(e)<1e3&&o(e,n)}]})(),c=f();return[(e,n,t,r=[],o=()=>[])=>{null!=l||(l=ee);const u=s(1);var i,d;return w(c,u,[e,n,t,r,o]),d=u,null==(i=y(n,null!=t?t:[""],z))||i.add(d),u},(e,n,...s)=>r(((e,n=[""])=>{const l=[],s=(e,u)=>u==t(n)?o(l,e):null===n[u]?g(e,(e=>s(e,u+1))):r([n[u],null],(n=>s(L(e,n),u+1)));return s(e,0),l})(e,n),(e=>g(e,(e=>L(c,e)[0](l,...null!=n?n:[],...s))))),e=>n(L(c,e),(([,n,t])=>(y(n,null!=t?t:[""],void 0,(n=>(C(n,e),p(n)?1:0))),w(c,e),u(e),t))),s=>n(L(c,s),(([n,,s=[],o,u])=>{const i=(...c)=>{var d,a;const v=t(c);v==t(s)?n(l,...c,...u(c)):e(s[v])?r(null!=(a=null==(d=o[v])?void 0:d.call(o,...c))?a:[],(e=>i(...c,e))):i(...c,s[v])};i()}))]})(),O=f(),T=f(),W=[],$=[],m=(n,t)=>{M=0,d.transaction((()=>{const[l,r]=L(O,t);g(l,((t,l)=>g(t,((t,r)=>g(t,((t,s)=>((n,t,l,r,s)=>e(s)?n.delCell(t,l,r,!0):n.setCell(t,l,r,s))(d,l,r,s,t[n]))))))),g(r,((t,l)=>((n,t,l)=>e(l)?n.delValue(t):n.setValue(t,l))(d,l,t[n])))})),M=1},q=e=>{w(O,e),w(T,e),x(b,[e])},D=(e,n)=>r(((e,n)=>e.splice(0,n))(e,null!=n?n:t(e)),q),G=()=>D(W,t(W)-V),H=()=>n(v,(()=>{o(W,v),G(),D($),v=void 0,I=1})),J=()=>{v=u(W),I=1};let K,N;const P=(n="")=>(e(v)&&(v=""+k++,w(O,v,[A,F]),Y(v,n),A=f(),F=f(),I=1),v),Q=()=>{s(W)||(((e,...n)=>{e.unshift(...n)})($,P()),m(0,v),v=u(W),I=1)},R=()=>{s($)||(o(W,v),v=i($),m(1,v),I=1)},U=()=>{I&&(x(_),I=0)},X=e=>{const n=P(e);return U(),n},Y=(e,n)=>(Z(e)&&L(T,e)!==n&&(w(T,e,n),x(b,[e])),ee),Z=e=>h(O,e),ee={setSize:e=>(V=e,G(),ee),addCheckpoint:X,setCheckpoint:Y,getStore:()=>d,getCheckpointIds:()=>[[...W],v,[...$]],forEachCheckpoint:e=>{return n=e,g(T,((e,t)=>n(t,e)));var n},hasCheckpoint:Z,getCheckpoint:e=>L(T,e),goBackward:()=>(Q(),U(),ee),goForward:()=>(R(),U(),ee),goTo:n=>{const t=l(W,n)?Q:l($,n)?R:null;for(;!e(t)&&n!=v;)t();return U(),ee},addCheckpointIdsListener:e=>j(e,_),addCheckpointListener:(e,n)=>j(n,b,[e]),delListener:e=>(B(e),ee),clear:()=>(D(W),D($),e(v)||q(v),v=void 0,k=0,X(),ee),clearForward:()=>(s($)||(D($),x(_)),ee),destroy:()=>{d.delListener(K),d.delListener(N)},getListenerStats:()=>({checkpointIds:a(_),checkpoint:a(b)}),_registerListeners:()=>{K=d.addCellListener(null,null,null,((e,n,t,l,r,s)=>{if(M){H();const e=S(A,n,f),o=S(e,t,f),u=S(o,l,(()=>[s,void 0]));u[1]=r,u[0]===r&&p(w(o,l))&&p(w(e,t))&&p(w(A,n))&&J(),U()}})),N=d.addValueListener(null,((e,n,t,l)=>{if(M){H();const e=S(F,n,(()=>[l,void 0]));e[1]=t,e[0]===t&&p(w(F,n))&&J(),U()}}))}};return c(ee.clear())})(d));const I=k.get(d);return null==v||v(I),I}})(0,(e=>e._registerListeners()));exports.createCheckpoints=I;
@@ -1 +1 @@
1
- "use strict";const e=e=>null==e,n=(n,t,l)=>e(n)?void 0:t(n),t=e=>e.length,l=(e,n)=>e.includes(n),r=(e,n)=>e.forEach(n),s=e=>0==t(e),o=(e,...n)=>e.push(...n),u=e=>e.pop(),i=e=>e.shift(),c=Object.freeze,d=e=>{var n;return null!=(n=null==e?void 0:e.size)?n:0},a=(v=d,e=>{return n=(e,n)=>e+v(n),k(e).reduce(n,0);var n});var v;const h=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},p=n=>e(n)||0==d(n),k=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},g=(e,n)=>null==e?void 0:e.forEach(n),C=(e,n)=>null==e?void 0:e.delete(n),f=e=>new Map(e),L=(e,n)=>null==e?void 0:e.get(n),w=(n,t,l)=>e(l)?(C(n,t),n):null==n?void 0:n.set(t,l),S=(e,n,t,l)=>(h(e,n)?null==l||l(L(e,n)):w(e,n,t()),L(e,n)),y=(e,l,r,s,o=0)=>n((r?S:L)(e,l[o],o>t(l)-2?r:f),(n=>{if(o>t(l)-2)return(null==s?void 0:s(n))&&w(e,l[o]),n;const u=y(n,l,r,s,o+1);return p(n)&&w(e,l[o]),u})),z=n=>new Set(Array.isArray(n)||e(n)?n:[n]),E=/^\d+$/,I=((d,v)=>{const k=new WeakMap;return d=>{k.has(d)||k.set(d,(d=>{let v,k,I,V=100,A=f(),F=f(),M=1;const _=f(),b=f(),[j,x,B]=(l=>{let s;const[u,c]=(()=>{const e=[];let n=0;return[t=>{var l;return null!=(l=t?i(e):null)?l:""+n++},n=>{E.test(n)&&t(e)<1e3&&o(e,n)}]})(),d=f();return[(e,n,t,l=[],r=(()=>[]))=>{null!=s||(s=ee);const o=u(1);var i,c;return w(d,o,[e,n,t,l,r]),c=o,null==(i=y(n,null!=t?t:[""],z))||i.add(c),o},(e,n,...l)=>r(((e,n=[""])=>{const l=[],s=(e,u)=>u==t(n)?o(l,e):null===n[u]?g(e,(e=>s(e,u+1))):r([n[u],null],(n=>s(L(e,n),u+1)));return s(e,0),l})(e,n),(e=>g(e,(e=>L(d,e)[0](s,...null!=n?n:[],...l))))),e=>n(L(d,e),(([,n,t])=>(y(n,null!=t?t:[""],void 0,(n=>(C(n,e),p(n)?1:0))),w(d,e),c(e),t))),l=>n(L(d,l),(([n,,l=[],o,u])=>{const i=(...c)=>{var d,a;const v=t(c);v==t(l)?n(s,...c,...u(c)):e(l[v])?r(null!=(a=null==(d=o[v])?void 0:d.call(o,...c))?a:[],(e=>i(...c,e))):i(...c,l[v])};i()}))]})(),O=f(),T=f(),W=[],$=[],m=(n,t)=>{M=0,d.transaction((()=>{const[l,r]=L(O,t);g(l,((t,l)=>g(t,((t,r)=>g(t,((t,s)=>((n,t,l,r,s)=>e(s)?n.delCell(t,l,r,!0):n.setCell(t,l,r,s))(d,l,r,s,t[n]))))))),g(r,((t,l)=>((n,t,l)=>e(l)?n.delValue(t):n.setValue(t,l))(d,l,t[n])))})),M=1},q=e=>{w(O,e),w(T,e),x(b,[e])},D=(e,n)=>r(((e,n)=>e.splice(0,n))(e,null!=n?n:t(e)),q),G=()=>D(W,t(W)-V),H=()=>n(v,(()=>{o(W,v),G(),D($),v=void 0,I=1})),J=()=>{v=u(W),I=1};let K,N;const P=(n="")=>(e(v)&&(v=""+k++,w(O,v,[A,F]),Y(v,n),A=f(),F=f(),I=1),v),Q=()=>{s(W)||(((e,...n)=>{e.unshift(...n)})($,P()),m(0,v),v=u(W),I=1)},R=()=>{s($)||(o(W,v),v=i($),m(1,v),I=1)},U=()=>{I&&(x(_),I=0)},X=e=>{const n=P(e);return U(),n},Y=(e,n)=>(Z(e)&&L(T,e)!==n&&(w(T,e,n),x(b,[e])),ee),Z=e=>h(O,e),ee={setSize:e=>(V=e,G(),ee),addCheckpoint:X,setCheckpoint:Y,getStore:()=>d,getCheckpointIds:()=>[[...W],v,[...$]],forEachCheckpoint:e=>{return n=e,g(T,((e,t)=>n(t,e)));var n},hasCheckpoint:Z,getCheckpoint:e=>L(T,e),goBackward:()=>(Q(),U(),ee),goForward:()=>(R(),U(),ee),goTo:n=>{const t=l(W,n)?Q:l($,n)?R:null;for(;!e(t)&&n!=v;)t();return U(),ee},addCheckpointIdsListener:e=>j(e,_),addCheckpointListener:(e,n)=>j(n,b,[e]),delListener:e=>(B(e),ee),clear:()=>(D(W),D($),e(v)||q(v),v=void 0,k=0,X(),ee),clearForward:()=>(s($)||(D($),x(_)),ee),destroy:()=>{d.delListener(K),d.delListener(N)},getListenerStats:()=>({checkpointIds:a(_),checkpoint:a(b)}),_registerListeners:()=>{K=d.addCellListener(null,null,null,((e,n,t,l,r,s)=>{if(M){H();const e=S(A,n,f),o=S(e,t,f),u=S(o,l,(()=>[s,void 0]));u[1]=r,u[0]===r&&p(w(o,l))&&p(w(e,t))&&p(w(A,n))&&J(),U()}})),N=d.addValueListener(null,((e,n,t,l)=>{if(M){H();const e=S(F,n,(()=>[l,void 0]));e[1]=t,e[0]===t&&p(w(F,n))&&J(),U()}}))}};return c(ee.clear())})(d));const I=k.get(d);return null==v||v(I),I}})(0,(e=>e._registerListeners()));exports.createCheckpoints=I;
1
+ "use strict";const e=e=>null==e,n=(n,t,l)=>e(n)?void 0:t(n),t=e=>e.length,l=(e,n)=>e.includes(n),r=(e,n)=>e.forEach(n),s=e=>0==t(e),o=(e,...n)=>e.push(...n),u=e=>e.pop(),i=e=>e.shift(),c=Object.freeze,d=e=>{var n;return null!=(n=null==e?void 0:e.size)?n:0},a=(v=d,e=>{return n=(e,n)=>e+v(n),k(e).reduce(n,0);var n});var v;const h=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},p=n=>e(n)||0==d(n),k=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},g=(e,n)=>null==e?void 0:e.forEach(n),C=(e,n)=>null==e?void 0:e.delete(n),f=e=>new Map(e),L=(e,n)=>null==e?void 0:e.get(n),w=(n,t,l)=>e(l)?(C(n,t),n):null==n?void 0:n.set(t,l),S=(e,n,t,l)=>(h(e,n)?null==l||l(L(e,n)):w(e,n,t()),L(e,n)),y=(e,l,r,s,o=0)=>n((r?S:L)(e,l[o],o>t(l)-2?r:f),(n=>{if(o>t(l)-2)return(null==s?void 0:s(n))&&w(e,l[o]),n;const u=y(n,l,r,s,o+1);return p(n)&&w(e,l[o]),u})),z=n=>new Set(Array.isArray(n)||e(n)?n:[n]),E=/^\d+$/,I=((d,v)=>{const k=new WeakMap;return d=>{k.has(d)||k.set(d,(d=>{let v,k,I,V=100,A=f(),F=f(),M=1;const _=f(),b=f(),[j,x,B]=(()=>{let l;const[s,u]=(()=>{const e=[];let n=0;return[t=>{var l;return null!=(l=t?i(e):null)?l:""+n++},n=>{E.test(n)&&t(e)<1e3&&o(e,n)}]})(),c=f();return[(e,n,t,r=[],o=()=>[])=>{null!=l||(l=ee);const u=s(1);var i,d;return w(c,u,[e,n,t,r,o]),d=u,null==(i=y(n,null!=t?t:[""],z))||i.add(d),u},(e,n,...s)=>r(((e,n=[""])=>{const l=[],s=(e,u)=>u==t(n)?o(l,e):null===n[u]?g(e,(e=>s(e,u+1))):r([n[u],null],(n=>s(L(e,n),u+1)));return s(e,0),l})(e,n),(e=>g(e,(e=>L(c,e)[0](l,...null!=n?n:[],...s))))),e=>n(L(c,e),(([,n,t])=>(y(n,null!=t?t:[""],void 0,(n=>(C(n,e),p(n)?1:0))),w(c,e),u(e),t))),s=>n(L(c,s),(([n,,s=[],o,u])=>{const i=(...c)=>{var d,a;const v=t(c);v==t(s)?n(l,...c,...u(c)):e(s[v])?r(null!=(a=null==(d=o[v])?void 0:d.call(o,...c))?a:[],(e=>i(...c,e))):i(...c,s[v])};i()}))]})(),O=f(),T=f(),W=[],$=[],m=(n,t)=>{M=0,d.transaction((()=>{const[l,r]=L(O,t);g(l,((t,l)=>g(t,((t,r)=>g(t,((t,s)=>((n,t,l,r,s)=>e(s)?n.delCell(t,l,r,!0):n.setCell(t,l,r,s))(d,l,r,s,t[n]))))))),g(r,((t,l)=>((n,t,l)=>e(l)?n.delValue(t):n.setValue(t,l))(d,l,t[n])))})),M=1},q=e=>{w(O,e),w(T,e),x(b,[e])},D=(e,n)=>r(((e,n)=>e.splice(0,n))(e,null!=n?n:t(e)),q),G=()=>D(W,t(W)-V),H=()=>n(v,(()=>{o(W,v),G(),D($),v=void 0,I=1})),J=()=>{v=u(W),I=1};let K,N;const P=(n="")=>(e(v)&&(v=""+k++,w(O,v,[A,F]),Y(v,n),A=f(),F=f(),I=1),v),Q=()=>{s(W)||(((e,...n)=>{e.unshift(...n)})($,P()),m(0,v),v=u(W),I=1)},R=()=>{s($)||(o(W,v),v=i($),m(1,v),I=1)},U=()=>{I&&(x(_),I=0)},X=e=>{const n=P(e);return U(),n},Y=(e,n)=>(Z(e)&&L(T,e)!==n&&(w(T,e,n),x(b,[e])),ee),Z=e=>h(O,e),ee={setSize:e=>(V=e,G(),ee),addCheckpoint:X,setCheckpoint:Y,getStore:()=>d,getCheckpointIds:()=>[[...W],v,[...$]],forEachCheckpoint:e=>{return n=e,g(T,((e,t)=>n(t,e)));var n},hasCheckpoint:Z,getCheckpoint:e=>L(T,e),goBackward:()=>(Q(),U(),ee),goForward:()=>(R(),U(),ee),goTo:n=>{const t=l(W,n)?Q:l($,n)?R:null;for(;!e(t)&&n!=v;)t();return U(),ee},addCheckpointIdsListener:e=>j(e,_),addCheckpointListener:(e,n)=>j(n,b,[e]),delListener:e=>(B(e),ee),clear:()=>(D(W),D($),e(v)||q(v),v=void 0,k=0,X(),ee),clearForward:()=>(s($)||(D($),x(_)),ee),destroy:()=>{d.delListener(K),d.delListener(N)},getListenerStats:()=>({checkpointIds:a(_),checkpoint:a(b)}),_registerListeners:()=>{K=d.addCellListener(null,null,null,((e,n,t,l,r,s)=>{if(M){H();const e=S(A,n,f),o=S(e,t,f),u=S(o,l,(()=>[s,void 0]));u[1]=r,u[0]===r&&p(w(o,l))&&p(w(e,t))&&p(w(A,n))&&J(),U()}})),N=d.addValueListener(null,((e,n,t,l)=>{if(M){H();const e=S(F,n,(()=>[l,void 0]));e[1]=t,e[0]===t&&p(w(F,n))&&J(),U()}}))}};return c(ee.clear())})(d));const I=k.get(d);return null==v||v(I),I}})(0,(e=>e._registerListeners()));exports.createCheckpoints=I;