tinybase 5.0.0-beta.27 → 5.0.0-beta.28

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 (249) hide show
  1. package/@types/_internal/ui-react/with-schemas/index.d.cts +274 -0
  2. package/@types/_internal/ui-react/with-schemas/index.d.ts +274 -0
  3. package/@types/checkpoints/index.d.cts +30 -1
  4. package/@types/checkpoints/index.d.ts +30 -1
  5. package/@types/checkpoints/with-schemas/index.d.cts +30 -1
  6. package/@types/checkpoints/with-schemas/index.d.ts +30 -1
  7. package/@types/common/index.d.cts +9 -0
  8. package/@types/common/index.d.ts +9 -0
  9. package/@types/common/with-schemas/index.d.cts +9 -0
  10. package/@types/common/with-schemas/index.d.ts +9 -0
  11. package/@types/index.d.cts +1 -0
  12. package/@types/index.d.ts +1 -0
  13. package/@types/indexes/index.d.cts +32 -1
  14. package/@types/indexes/index.d.ts +32 -1
  15. package/@types/indexes/with-schemas/index.d.cts +32 -1
  16. package/@types/indexes/with-schemas/index.d.ts +32 -1
  17. package/@types/mergeable-store/index.d.cts +0 -2
  18. package/@types/mergeable-store/index.d.ts +0 -2
  19. package/@types/mergeable-store/with-schemas/index.d.cts +2 -2
  20. package/@types/mergeable-store/with-schemas/index.d.ts +2 -2
  21. package/@types/metrics/index.d.cts +30 -4
  22. package/@types/metrics/index.d.ts +30 -4
  23. package/@types/metrics/with-schemas/index.d.cts +30 -4
  24. package/@types/metrics/with-schemas/index.d.ts +30 -4
  25. package/@types/persisters/index.d.cts +87 -25
  26. package/@types/persisters/index.d.ts +87 -25
  27. package/@types/persisters/persister-automerge/index.d.cts +4 -4
  28. package/@types/persisters/persister-automerge/index.d.ts +4 -4
  29. package/@types/persisters/persister-automerge/with-schemas/index.d.cts +4 -4
  30. package/@types/persisters/persister-automerge/with-schemas/index.d.ts +4 -4
  31. package/@types/persisters/persister-browser/index.d.cts +7 -4
  32. package/@types/persisters/persister-browser/index.d.ts +7 -4
  33. package/@types/persisters/persister-browser/with-schemas/index.d.cts +7 -4
  34. package/@types/persisters/persister-browser/with-schemas/index.d.ts +7 -4
  35. package/@types/persisters/persister-cr-sqlite-wasm/index.d.cts +4 -4
  36. package/@types/persisters/persister-cr-sqlite-wasm/index.d.ts +4 -4
  37. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.cts +4 -4
  38. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts +4 -4
  39. package/@types/persisters/persister-electric-sql/index.d.cts +4 -4
  40. package/@types/persisters/persister-electric-sql/index.d.ts +4 -4
  41. package/@types/persisters/persister-electric-sql/with-schemas/index.d.cts +4 -4
  42. package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +4 -4
  43. package/@types/persisters/persister-expo-sqlite/index.d.cts +4 -4
  44. package/@types/persisters/persister-expo-sqlite/index.d.ts +4 -4
  45. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.cts +4 -4
  46. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +4 -4
  47. package/@types/persisters/persister-file/index.d.cts +6 -4
  48. package/@types/persisters/persister-file/index.d.ts +6 -4
  49. package/@types/persisters/persister-file/with-schemas/index.d.cts +6 -4
  50. package/@types/persisters/persister-file/with-schemas/index.d.ts +6 -4
  51. package/@types/persisters/persister-indexed-db/index.d.cts +5 -4
  52. package/@types/persisters/persister-indexed-db/index.d.ts +5 -4
  53. package/@types/persisters/persister-indexed-db/with-schemas/index.d.cts +5 -4
  54. package/@types/persisters/persister-indexed-db/with-schemas/index.d.ts +5 -4
  55. package/@types/persisters/persister-libsql/index.d.cts +5 -4
  56. package/@types/persisters/persister-libsql/index.d.ts +5 -4
  57. package/@types/persisters/persister-libsql/with-schemas/index.d.cts +5 -4
  58. package/@types/persisters/persister-libsql/with-schemas/index.d.ts +5 -4
  59. package/@types/persisters/persister-partykit-client/index.d.cts +12 -6
  60. package/@types/persisters/persister-partykit-client/index.d.ts +12 -6
  61. package/@types/persisters/persister-partykit-client/with-schemas/index.d.cts +12 -6
  62. package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +12 -6
  63. package/@types/persisters/persister-partykit-server/index.d.cts +11 -3
  64. package/@types/persisters/persister-partykit-server/index.d.ts +11 -3
  65. package/@types/persisters/persister-partykit-server/with-schemas/index.d.cts +11 -3
  66. package/@types/persisters/persister-partykit-server/with-schemas/index.d.ts +11 -3
  67. package/@types/persisters/persister-powersync/index.d.cts +5 -4
  68. package/@types/persisters/persister-powersync/index.d.ts +5 -4
  69. package/@types/persisters/persister-powersync/with-schemas/index.d.cts +5 -4
  70. package/@types/persisters/persister-powersync/with-schemas/index.d.ts +5 -4
  71. package/@types/persisters/persister-remote/index.d.cts +6 -4
  72. package/@types/persisters/persister-remote/index.d.ts +6 -4
  73. package/@types/persisters/persister-remote/with-schemas/index.d.cts +6 -4
  74. package/@types/persisters/persister-remote/with-schemas/index.d.ts +6 -4
  75. package/@types/persisters/persister-sqlite-wasm/index.d.cts +4 -4
  76. package/@types/persisters/persister-sqlite-wasm/index.d.ts +4 -4
  77. package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.cts +4 -4
  78. package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.ts +4 -4
  79. package/@types/persisters/persister-sqlite3/index.d.cts +4 -4
  80. package/@types/persisters/persister-sqlite3/index.d.ts +4 -4
  81. package/@types/persisters/persister-sqlite3/with-schemas/index.d.cts +4 -4
  82. package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +4 -4
  83. package/@types/persisters/persister-yjs/index.d.cts +4 -4
  84. package/@types/persisters/persister-yjs/index.d.ts +4 -4
  85. package/@types/persisters/persister-yjs/with-schemas/index.d.cts +4 -4
  86. package/@types/persisters/persister-yjs/with-schemas/index.d.ts +4 -4
  87. package/@types/persisters/with-schemas/index.d.cts +87 -25
  88. package/@types/persisters/with-schemas/index.d.ts +87 -25
  89. package/@types/queries/index.d.cts +64 -4
  90. package/@types/queries/index.d.ts +64 -4
  91. package/@types/queries/with-schemas/index.d.cts +64 -4
  92. package/@types/queries/with-schemas/index.d.ts +64 -4
  93. package/@types/relationships/index.d.cts +34 -1
  94. package/@types/relationships/index.d.ts +34 -1
  95. package/@types/relationships/with-schemas/index.d.cts +34 -1
  96. package/@types/relationships/with-schemas/index.d.ts +34 -1
  97. package/@types/store/index.d.cts +125 -0
  98. package/@types/store/index.d.ts +125 -0
  99. package/@types/store/with-schemas/index.d.cts +125 -0
  100. package/@types/store/with-schemas/index.d.ts +125 -0
  101. package/@types/synchronizers/index.d.cts +32 -10
  102. package/@types/synchronizers/index.d.ts +32 -10
  103. package/@types/synchronizers/synchronizer-broadcast-channel/index.d.cts +114 -0
  104. package/@types/synchronizers/synchronizer-broadcast-channel/index.d.ts +114 -0
  105. package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.cts +128 -0
  106. package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.ts +128 -0
  107. package/@types/synchronizers/synchronizer-local/index.d.cts +16 -17
  108. package/@types/synchronizers/synchronizer-local/index.d.ts +16 -17
  109. package/@types/synchronizers/synchronizer-local/with-schemas/index.d.cts +16 -17
  110. package/@types/synchronizers/synchronizer-local/with-schemas/index.d.ts +16 -17
  111. package/@types/synchronizers/synchronizer-ws-client/index.d.cts +66 -6
  112. package/@types/synchronizers/synchronizer-ws-client/index.d.ts +66 -6
  113. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.cts +77 -6
  114. package/@types/synchronizers/synchronizer-ws-client/with-schemas/index.d.ts +77 -6
  115. package/@types/synchronizers/synchronizer-ws-server/index.d.cts +486 -7
  116. package/@types/synchronizers/synchronizer-ws-server/index.d.ts +486 -7
  117. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +486 -7
  118. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +486 -7
  119. package/@types/synchronizers/with-schemas/index.d.cts +29 -11
  120. package/@types/synchronizers/with-schemas/index.d.ts +29 -11
  121. package/@types/tools/index.d.cts +22 -0
  122. package/@types/tools/index.d.ts +22 -0
  123. package/@types/tools/with-schemas/index.d.cts +22 -0
  124. package/@types/tools/with-schemas/index.d.ts +22 -0
  125. package/@types/ui-react/index.d.cts +375 -1
  126. package/@types/ui-react/index.d.ts +375 -1
  127. package/@types/ui-react/with-schemas/index.d.cts +100 -1
  128. package/@types/ui-react/with-schemas/index.d.ts +100 -1
  129. package/@types/ui-react-dom/index.d.cts +112 -0
  130. package/@types/ui-react-dom/index.d.ts +112 -0
  131. package/@types/ui-react-dom/with-schemas/index.d.cts +112 -0
  132. package/@types/ui-react-dom/with-schemas/index.d.ts +112 -0
  133. package/@types/ui-react-inspector/index.d.cts +6 -2
  134. package/@types/ui-react-inspector/index.d.ts +6 -2
  135. package/@types/ui-react-inspector/with-schemas/index.d.cts +118 -2
  136. package/@types/ui-react-inspector/with-schemas/index.d.ts +118 -2
  137. package/@types/with-schemas/index.d.cts +1 -0
  138. package/@types/with-schemas/index.d.ts +1 -0
  139. package/cjs/es6/index.cjs +2 -2
  140. package/cjs/es6/min/synchronizers/synchronizer-broadcast-channel/index.cjs +1 -0
  141. package/cjs/es6/min/synchronizers/synchronizer-broadcast-channel/index.cjs.gz +0 -0
  142. package/cjs/es6/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.cjs +1 -0
  143. package/cjs/es6/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.cjs.gz +0 -0
  144. package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
  145. package/cjs/es6/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
  146. package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
  147. package/cjs/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
  148. package/cjs/es6/synchronizers/index.cjs +2 -2
  149. package/cjs/es6/synchronizers/synchronizer-broadcast-channel/index.cjs +628 -0
  150. package/cjs/es6/synchronizers/synchronizer-broadcast-channel/with-schemas/index.cjs +628 -0
  151. package/cjs/es6/synchronizers/synchronizer-local/index.cjs +4 -4
  152. package/cjs/es6/synchronizers/synchronizer-local/with-schemas/index.cjs +4 -4
  153. package/cjs/es6/synchronizers/synchronizer-ws-client/index.cjs +15 -21
  154. package/cjs/es6/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +15 -21
  155. package/cjs/es6/synchronizers/with-schemas/index.cjs +2 -2
  156. package/cjs/es6/with-schemas/index.cjs +2 -2
  157. package/cjs/index.cjs +2 -2
  158. package/cjs/min/synchronizers/synchronizer-broadcast-channel/index.cjs +1 -0
  159. package/cjs/min/synchronizers/synchronizer-broadcast-channel/index.cjs.gz +0 -0
  160. package/cjs/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.cjs +1 -0
  161. package/cjs/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.cjs.gz +0 -0
  162. package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs +1 -1
  163. package/cjs/min/synchronizers/synchronizer-ws-client/index.cjs.gz +0 -0
  164. package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +1 -1
  165. package/cjs/min/synchronizers/synchronizer-ws-client/with-schemas/index.cjs.gz +0 -0
  166. package/cjs/synchronizers/index.cjs +2 -2
  167. package/cjs/synchronizers/synchronizer-broadcast-channel/index.cjs +500 -0
  168. package/cjs/synchronizers/synchronizer-broadcast-channel/with-schemas/index.cjs +500 -0
  169. package/cjs/synchronizers/synchronizer-local/index.cjs +4 -4
  170. package/cjs/synchronizers/synchronizer-local/with-schemas/index.cjs +4 -4
  171. package/cjs/synchronizers/synchronizer-ws-client/index.cjs +15 -21
  172. package/cjs/synchronizers/synchronizer-ws-client/with-schemas/index.cjs +15 -21
  173. package/cjs/synchronizers/with-schemas/index.cjs +2 -2
  174. package/cjs/with-schemas/index.cjs +2 -2
  175. package/es6/index.js +2 -2
  176. package/es6/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -0
  177. package/es6/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  178. package/es6/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -0
  179. package/es6/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  180. package/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  181. package/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  182. package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  183. package/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  184. package/es6/synchronizers/index.js +2 -2
  185. package/es6/synchronizers/synchronizer-broadcast-channel/index.js +626 -0
  186. package/es6/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +626 -0
  187. package/es6/synchronizers/synchronizer-local/index.js +4 -4
  188. package/es6/synchronizers/synchronizer-local/with-schemas/index.js +4 -4
  189. package/es6/synchronizers/synchronizer-ws-client/index.js +15 -21
  190. package/es6/synchronizers/synchronizer-ws-client/with-schemas/index.js +15 -21
  191. package/es6/synchronizers/with-schemas/index.js +2 -2
  192. package/es6/with-schemas/index.js +2 -2
  193. package/index.js +2 -2
  194. package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -0
  195. package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  196. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -0
  197. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  198. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  199. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  200. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  201. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  202. package/package.json +105 -1
  203. package/readme.md +9 -9
  204. package/releases.md +4 -4
  205. package/synchronizers/index.js +2 -2
  206. package/synchronizers/synchronizer-broadcast-channel/index.js +498 -0
  207. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +498 -0
  208. package/synchronizers/synchronizer-local/index.js +4 -4
  209. package/synchronizers/synchronizer-local/with-schemas/index.js +4 -4
  210. package/synchronizers/synchronizer-ws-client/index.js +15 -21
  211. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +15 -21
  212. package/synchronizers/with-schemas/index.js +2 -2
  213. package/umd/es6/index.js +2 -2
  214. package/umd/es6/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -0
  215. package/umd/es6/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  216. package/umd/es6/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -0
  217. package/umd/es6/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  218. package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  219. package/umd/es6/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  220. package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  221. package/umd/es6/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  222. package/umd/es6/synchronizers/index.js +2 -2
  223. package/umd/es6/synchronizers/synchronizer-broadcast-channel/index.js +654 -0
  224. package/umd/es6/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +654 -0
  225. package/umd/es6/synchronizers/synchronizer-local/index.js +4 -4
  226. package/umd/es6/synchronizers/synchronizer-local/with-schemas/index.js +4 -4
  227. package/umd/es6/synchronizers/synchronizer-ws-client/index.js +15 -21
  228. package/umd/es6/synchronizers/synchronizer-ws-client/with-schemas/index.js +15 -21
  229. package/umd/es6/synchronizers/with-schemas/index.js +2 -2
  230. package/umd/es6/with-schemas/index.js +2 -2
  231. package/umd/index.js +2 -2
  232. package/umd/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -0
  233. package/umd/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  234. package/umd/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -0
  235. package/umd/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  236. package/umd/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  237. package/umd/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  238. package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  239. package/umd/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  240. package/umd/synchronizers/index.js +2 -2
  241. package/umd/synchronizers/synchronizer-broadcast-channel/index.js +516 -0
  242. package/umd/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +516 -0
  243. package/umd/synchronizers/synchronizer-local/index.js +4 -4
  244. package/umd/synchronizers/synchronizer-local/with-schemas/index.js +4 -4
  245. package/umd/synchronizers/synchronizer-ws-client/index.js +15 -21
  246. package/umd/synchronizers/synchronizer-ws-client/with-schemas/index.js +15 -21
  247. package/umd/synchronizers/with-schemas/index.js +2 -2
  248. package/umd/with-schemas/index.js +2 -2
  249. package/with-schemas/index.js +2 -2
@@ -0,0 +1,128 @@
1
+ /**
2
+ * The synchronizer-broadcast-channel module of the TinyBase project lets you
3
+ * synchronize MergeableStore data to and from other MergeableStore instances
4
+ * via a browser's BroadcastChannel API.
5
+ * @see Synchronization guide
6
+ * @packageDocumentation
7
+ * @module synchronizer-broadcast-channel
8
+ * @since v5.0.0
9
+ */
10
+
11
+ import type {MergeableStore} from '../../../mergeable-store/with-schemas/index.d.ts';
12
+ import type {OptionalSchemas} from '../../../store/with-schemas/index.d.ts';
13
+ import type {Synchronizer} from '../../with-schemas/index.d.ts';
14
+
15
+ /**
16
+ * The BroadcastChannelSynchronizer interface represents a Synchronizer that
17
+ * lets you synchronize MergeableStore data to and from other MergeableStore
18
+ * instances via a browser's BroadcastChannel API.
19
+ *
20
+ * You should use the createBroadcastChannelSynchronizer function to create a
21
+ * BroadcastChannelSynchronizer object.
22
+ *
23
+ * It is a minor extension to the Synchronizer interface and simply provides an
24
+ * extra getChannelName method for accessing the name of the channel being used.
25
+ * @category Synchronizer
26
+ * @since v5.0.0
27
+ */
28
+ export interface BroadcastChannelSynchronizer<Schemas extends OptionalSchemas>
29
+ extends Synchronizer<Schemas> {
30
+ /**
31
+ * The getChannelName method returns the name of the channel being used for
32
+ * synchronization.
33
+ * @returns The channel name.
34
+ * @example
35
+ * This example creates a BroadcastChannelSynchronizer object for a
36
+ * newly-created MergeableStore and then gets the channel name back out again.
37
+ *
38
+ * ```js
39
+ * import {createBroadcastChannelSynchronizer} from 'tinybase/synchronizers/synchronizer-broadcast-channel';
40
+ * import {createMergeableStore} from 'tinybase';
41
+ *
42
+ * const store = createMergeableStore();
43
+ * const synchronizer = await createBroadcastChannelSynchronizer(
44
+ * store,
45
+ * 'channelA',
46
+ * );
47
+ *
48
+ * console.log(synchronizer.getChannelName());
49
+ * // -> 'channelA'
50
+ *
51
+ * synchronizer.destroy();
52
+ * ```
53
+ * @category Getter
54
+ * @since v5.0.0
55
+ */
56
+ getChannelName(): string;
57
+ }
58
+
59
+ /**
60
+ * The createBroadcastChannelSynchronizer function creates a
61
+ * BroadcastChannelSynchronizer object that can synchronize MergeableStore data
62
+ * to and from other MergeableStore instances via a browser's BroadcastChannel
63
+ * API.
64
+ *
65
+ * This has schema-based typing. The following is a simplified representation:
66
+ *
67
+ * ```ts override
68
+ * createBroadcastChannelSynchronizer(
69
+ * store: MergeableStore,
70
+ * channelName: string,
71
+ * onIgnoredError?: (error: any) => void,
72
+ * ): BroadcastChannelSynchronizer;
73
+ * ```
74
+ *
75
+ * As well as providing a reference to the MergeableStore to persist, you must
76
+ * provide a channel name, used by all the browser tabs, workers, or contexts
77
+ * that need to synchronize together.
78
+ * @param store The MergeableStore to synchronize.
79
+ * @param channelName The name of the channel to use.
80
+ * @param onIgnoredError An optional handler for the errors that the
81
+ * Synchronizer would otherwise ignore when trying to synchronize data. This is
82
+ * suitable for debugging synchronization issues in a development environment.
83
+ * @returns A reference to the new BroadcastChannelSynchronizer object.
84
+ * @example
85
+ * This example creates two BroadcastChannelSynchronizer objects to synchronize
86
+ * one MergeableStore to another.
87
+ *
88
+ * ```js
89
+ * import {createBroadcastChannelSynchronizer} from 'tinybase/synchronizers/synchronizer-broadcast-channel';
90
+ * import {createMergeableStore} from 'tinybase';
91
+ *
92
+ * const store1 = createMergeableStore();
93
+ * const store2 = createMergeableStore();
94
+ *
95
+ * const synchronizer1 = createBroadcastChannelSynchronizer(
96
+ * store1,
97
+ * 'channelA',
98
+ * );
99
+ * const synchronizer2 = createBroadcastChannelSynchronizer(
100
+ * store2,
101
+ * 'channelA',
102
+ * );
103
+ *
104
+ * await synchronizer1.startSync();
105
+ * await synchronizer2.startSync();
106
+ *
107
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
108
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
109
+ *
110
+ * // ...
111
+ * console.log(store1.getTables());
112
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
113
+ * console.log(store2.getTables());
114
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
115
+ *
116
+ * synchronizer1.destroy();
117
+ * synchronizer2.destroy();
118
+ * ```
119
+ * @category Creation
120
+ * @since v5.0.0
121
+ */
122
+ export function createBroadcastChannelSynchronizer<
123
+ Schemas extends OptionalSchemas,
124
+ >(
125
+ store: MergeableStore<Schemas>,
126
+ channelName: string,
127
+ onIgnoredError?: (error: any) => void,
128
+ ): BroadcastChannelSynchronizer<Schemas>;
@@ -2,7 +2,7 @@
2
2
  * The synchronizer-local module of the TinyBase project lets you synchronize
3
3
  * MergeableStore data to and from other MergeableStore instances on the same
4
4
  * local machine.
5
- * @see Synchronizing Data guide
5
+ * @see Synchronization guide
6
6
  * @packageDocumentation
7
7
  * @module synchronizer-local
8
8
  * @since v5.0.0
@@ -16,15 +16,15 @@ import type {Synchronizer} from '../index.d.cts';
16
16
  * synchronize MergeableStore data to and from other MergeableStore instances on
17
17
  * the same local machine.
18
18
  *
19
+ * You should use the createLocalSynchronizer function to create a
20
+ * LocalSynchronizer object.
21
+ *
19
22
  * Having no specialized methods, it is a synonym for the Synchronizer
20
23
  * interface. This is also something of a showcase Synchronizer, rather than
21
24
  * something you would use in a production environment. If you _do_ need to
22
25
  * synchronize two in-memory MergeableStore instances, you may prefer to use the
23
26
  * merge function on either one of them instead of going to the effort of
24
27
  * setting up this Synchronizer.
25
- *
26
- * You should use the createLocalSynchronizer function to create a
27
- * LocalSynchronizer object.
28
28
  * @category Synchronizer
29
29
  * @since v5.0.0
30
30
  */
@@ -49,31 +49,30 @@ export interface LocalSynchronizer extends Synchronizer {}
49
49
  * suitable for debugging synchronization issues in a development environment.
50
50
  * @returns A reference to the new LocalSynchronizer object.
51
51
  * @example
52
- * This example creates a LocalSynchronizer object and synchronizes one
52
+ * This example creates two LocalSynchronizer objects to synchronize one
53
53
  * MergeableStore to another.
54
54
  *
55
55
  * ```js
56
56
  * import {createLocalSynchronizer} from 'tinybase/synchronizers/synchronizer-local';
57
57
  * import {createMergeableStore} from 'tinybase';
58
58
  *
59
- * const store1 = createMergeableStore('store1').setTables({
60
- * pets: {fido: {species: 'dog'}},
61
- * });
62
- * const synchronizer1 = createLocalSynchronizer(store1);
59
+ * const store1 = createMergeableStore();
60
+ * const store2 = createMergeableStore();
63
61
  *
64
- * const store2 = createMergeableStore('store2');
62
+ * const synchronizer1 = createLocalSynchronizer(store1);
65
63
  * const synchronizer2 = createLocalSynchronizer(store2);
64
+ *
65
+ * await synchronizer1.startSync();
66
66
  * await synchronizer2.startSync();
67
67
  *
68
- * await synchronizer1.save();
69
- * // ...
70
- * // Store2 will be synced with Store1.
68
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
69
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
71
70
  *
71
+ * // ...
72
+ * console.log(store1.getTables());
73
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
72
74
  * console.log(store2.getTables());
73
- * // -> {pets: {fido: {species: 'dog'}}}
74
- *
75
- * await synchronizer1.load();
76
- * // Store1 will be synced with Store2.
75
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
77
76
  *
78
77
  * synchronizer1.destroy();
79
78
  * synchronizer2.destroy();
@@ -2,7 +2,7 @@
2
2
  * The synchronizer-local module of the TinyBase project lets you synchronize
3
3
  * MergeableStore data to and from other MergeableStore instances on the same
4
4
  * local machine.
5
- * @see Synchronizing Data guide
5
+ * @see Synchronization guide
6
6
  * @packageDocumentation
7
7
  * @module synchronizer-local
8
8
  * @since v5.0.0
@@ -16,15 +16,15 @@ import type {Synchronizer} from '../index.d.ts';
16
16
  * synchronize MergeableStore data to and from other MergeableStore instances on
17
17
  * the same local machine.
18
18
  *
19
+ * You should use the createLocalSynchronizer function to create a
20
+ * LocalSynchronizer object.
21
+ *
19
22
  * Having no specialized methods, it is a synonym for the Synchronizer
20
23
  * interface. This is also something of a showcase Synchronizer, rather than
21
24
  * something you would use in a production environment. If you _do_ need to
22
25
  * synchronize two in-memory MergeableStore instances, you may prefer to use the
23
26
  * merge function on either one of them instead of going to the effort of
24
27
  * setting up this Synchronizer.
25
- *
26
- * You should use the createLocalSynchronizer function to create a
27
- * LocalSynchronizer object.
28
28
  * @category Synchronizer
29
29
  * @since v5.0.0
30
30
  */
@@ -49,31 +49,30 @@ export interface LocalSynchronizer extends Synchronizer {}
49
49
  * suitable for debugging synchronization issues in a development environment.
50
50
  * @returns A reference to the new LocalSynchronizer object.
51
51
  * @example
52
- * This example creates a LocalSynchronizer object and synchronizes one
52
+ * This example creates two LocalSynchronizer objects to synchronize one
53
53
  * MergeableStore to another.
54
54
  *
55
55
  * ```js
56
56
  * import {createLocalSynchronizer} from 'tinybase/synchronizers/synchronizer-local';
57
57
  * import {createMergeableStore} from 'tinybase';
58
58
  *
59
- * const store1 = createMergeableStore('store1').setTables({
60
- * pets: {fido: {species: 'dog'}},
61
- * });
62
- * const synchronizer1 = createLocalSynchronizer(store1);
59
+ * const store1 = createMergeableStore();
60
+ * const store2 = createMergeableStore();
63
61
  *
64
- * const store2 = createMergeableStore('store2');
62
+ * const synchronizer1 = createLocalSynchronizer(store1);
65
63
  * const synchronizer2 = createLocalSynchronizer(store2);
64
+ *
65
+ * await synchronizer1.startSync();
66
66
  * await synchronizer2.startSync();
67
67
  *
68
- * await synchronizer1.save();
69
- * // ...
70
- * // Store2 will be synced with Store1.
68
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
69
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
71
70
  *
71
+ * // ...
72
+ * console.log(store1.getTables());
73
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
72
74
  * console.log(store2.getTables());
73
- * // -> {pets: {fido: {species: 'dog'}}}
74
- *
75
- * await synchronizer1.load();
76
- * // Store1 will be synced with Store2.
75
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
77
76
  *
78
77
  * synchronizer1.destroy();
79
78
  * synchronizer2.destroy();
@@ -2,7 +2,7 @@
2
2
  * The synchronizer-local module of the TinyBase project lets you synchronize
3
3
  * MergeableStore data to and from other MergeableStore instances on the same
4
4
  * local machine.
5
- * @see Synchronizing Data guide
5
+ * @see Synchronization guide
6
6
  * @packageDocumentation
7
7
  * @module synchronizer-local
8
8
  * @since v5.0.0
@@ -23,15 +23,15 @@ import type {Synchronizer} from '../../with-schemas/index.d.cts';
23
23
  * export interface LocalSynchronizer extends Synchronizer {}
24
24
  * ```
25
25
  *
26
+ * You should use the createLocalSynchronizer function to create a
27
+ * LocalSynchronizer object.
28
+ *
26
29
  * Having no specialized methods, it is a synonym for the Synchronizer
27
30
  * interface. This is also something of a showcase Synchronizer, rather than
28
31
  * something you would use in a production environment. If you _do_ need to
29
32
  * synchronize two in-memory MergeableStore instances, you may prefer to use the
30
33
  * merge function on either one of them instead of going to the effort of
31
34
  * setting up this Synchronizer.
32
- *
33
- * You should use the createLocalSynchronizer function to create a
34
- * LocalSynchronizer object.
35
35
  * @category Synchronizer
36
36
  * @since v5.0.0
37
37
  */
@@ -66,31 +66,30 @@ export interface LocalSynchronizer<Schemas extends OptionalSchemas>
66
66
  * suitable for debugging synchronization issues in a development environment.
67
67
  * @returns A reference to the new LocalSynchronizer object.
68
68
  * @example
69
- * This example creates a LocalSynchronizer object and synchronizes one
69
+ * This example creates two LocalSynchronizer objects to synchronize one
70
70
  * MergeableStore to another.
71
71
  *
72
72
  * ```js
73
73
  * import {createLocalSynchronizer} from 'tinybase/synchronizers/synchronizer-local';
74
74
  * import {createMergeableStore} from 'tinybase';
75
75
  *
76
- * const store1 = createMergeableStore('store1').setTables({
77
- * pets: {fido: {species: 'dog'}},
78
- * });
79
- * const synchronizer1 = createLocalSynchronizer(store1);
76
+ * const store1 = createMergeableStore();
77
+ * const store2 = createMergeableStore();
80
78
  *
81
- * const store2 = createMergeableStore('store2');
79
+ * const synchronizer1 = createLocalSynchronizer(store1);
82
80
  * const synchronizer2 = createLocalSynchronizer(store2);
81
+ *
82
+ * await synchronizer1.startSync();
83
83
  * await synchronizer2.startSync();
84
84
  *
85
- * await synchronizer1.save();
86
- * // ...
87
- * // Store2 will be synced with Store1.
85
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
86
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
88
87
  *
88
+ * // ...
89
+ * console.log(store1.getTables());
90
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
89
91
  * console.log(store2.getTables());
90
- * // -> {pets: {fido: {species: 'dog'}}}
91
- *
92
- * await synchronizer1.load();
93
- * // Store1 will be synced with Store2.
92
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
94
93
  *
95
94
  * synchronizer1.destroy();
96
95
  * synchronizer2.destroy();
@@ -2,7 +2,7 @@
2
2
  * The synchronizer-local module of the TinyBase project lets you synchronize
3
3
  * MergeableStore data to and from other MergeableStore instances on the same
4
4
  * local machine.
5
- * @see Synchronizing Data guide
5
+ * @see Synchronization guide
6
6
  * @packageDocumentation
7
7
  * @module synchronizer-local
8
8
  * @since v5.0.0
@@ -23,15 +23,15 @@ import type {Synchronizer} from '../../with-schemas/index.d.ts';
23
23
  * export interface LocalSynchronizer extends Synchronizer {}
24
24
  * ```
25
25
  *
26
+ * You should use the createLocalSynchronizer function to create a
27
+ * LocalSynchronizer object.
28
+ *
26
29
  * Having no specialized methods, it is a synonym for the Synchronizer
27
30
  * interface. This is also something of a showcase Synchronizer, rather than
28
31
  * something you would use in a production environment. If you _do_ need to
29
32
  * synchronize two in-memory MergeableStore instances, you may prefer to use the
30
33
  * merge function on either one of them instead of going to the effort of
31
34
  * setting up this Synchronizer.
32
- *
33
- * You should use the createLocalSynchronizer function to create a
34
- * LocalSynchronizer object.
35
35
  * @category Synchronizer
36
36
  * @since v5.0.0
37
37
  */
@@ -66,31 +66,30 @@ export interface LocalSynchronizer<Schemas extends OptionalSchemas>
66
66
  * suitable for debugging synchronization issues in a development environment.
67
67
  * @returns A reference to the new LocalSynchronizer object.
68
68
  * @example
69
- * This example creates a LocalSynchronizer object and synchronizes one
69
+ * This example creates two LocalSynchronizer objects to synchronize one
70
70
  * MergeableStore to another.
71
71
  *
72
72
  * ```js
73
73
  * import {createLocalSynchronizer} from 'tinybase/synchronizers/synchronizer-local';
74
74
  * import {createMergeableStore} from 'tinybase';
75
75
  *
76
- * const store1 = createMergeableStore('store1').setTables({
77
- * pets: {fido: {species: 'dog'}},
78
- * });
79
- * const synchronizer1 = createLocalSynchronizer(store1);
76
+ * const store1 = createMergeableStore();
77
+ * const store2 = createMergeableStore();
80
78
  *
81
- * const store2 = createMergeableStore('store2');
79
+ * const synchronizer1 = createLocalSynchronizer(store1);
82
80
  * const synchronizer2 = createLocalSynchronizer(store2);
81
+ *
82
+ * await synchronizer1.startSync();
83
83
  * await synchronizer2.startSync();
84
84
  *
85
- * await synchronizer1.save();
86
- * // ...
87
- * // Store2 will be synced with Store1.
85
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
86
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
88
87
  *
88
+ * // ...
89
+ * console.log(store1.getTables());
90
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
89
91
  * console.log(store2.getTables());
90
- * // -> {pets: {fido: {species: 'dog'}}}
91
- *
92
- * await synchronizer1.load();
93
- * // Store1 will be synced with Store2.
92
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
94
93
  *
95
94
  * synchronizer1.destroy();
96
95
  * synchronizer2.destroy();
@@ -2,7 +2,7 @@
2
2
  * The synchronizer-ws module of the TinyBase project lets you synchronize
3
3
  * MergeableStore data to and from other MergeableStore instances via WebSockets
4
4
  * facilitated by a server.
5
- * @see Synchronizing Data guide
5
+ * @see Synchronization guide
6
6
  * @see Todo App v6 (collaboration) demo
7
7
  * @packageDocumentation
8
8
  * @module synchronizer-ws-client
@@ -20,6 +20,8 @@ import type {WebSocket as WsWebSocket} from 'ws';
20
20
  * This includes the browser-native WebSocket type, as well as the WebSocket
21
21
  * type from the well-known `ws` package (such that the Synchronizer can be used
22
22
  * in a server environment).
23
+ * @category Creation
24
+ * @since v5.0.0
23
25
  */
24
26
  export type WebSocketTypes = WebSocket | WsWebSocket;
25
27
 
@@ -28,19 +30,19 @@ export type WebSocketTypes = WebSocket | WsWebSocket;
28
30
  * synchronize MergeableStore data to and from other MergeableStore instances
29
31
  * via WebSockets facilitated by a server.
30
32
  *
33
+ * You should use the createWsSynchronizer function to create a WsSynchronizer
34
+ * object.
35
+ *
31
36
  * It is a minor extension to the Synchronizer interface and simply provides an
32
37
  * extra getWebSocket method for accessing a reference to the WebSocket being
33
38
  * used.
34
- *
35
- * You should use the createWsSynchronizer function to create a WsSynchronizer
36
- * object.
37
39
  * @category Synchronizer
38
40
  * @since v5.0.0
39
41
  */
40
42
  export interface WsSynchronizer<WebSocketType extends WebSocketTypes>
41
43
  extends Synchronizer {
42
44
  /**
43
- * The getWebSocket method returns reference to the WebSocket being used for
45
+ * The getWebSocket method returns a reference to the WebSocket being used for
44
46
  * synchronization.
45
47
  * @returns The WebSocket reference.
46
48
  * @example
@@ -72,8 +74,66 @@ export interface WsSynchronizer<WebSocketType extends WebSocketTypes>
72
74
  }
73
75
 
74
76
  /**
75
- * The createWsSynchronizer function.
77
+ * The createWsSynchronizer function creates a WsSynchronizer object that can
78
+ * synchronize MergeableStore data to and from other MergeableStore instances
79
+ * via WebSockets facilitated by a WsServer.
80
+ *
81
+ * As well as providing a reference to the MergeableStore to persist, you must
82
+ * provide a configured WebSocket to send synchronization messages over.
83
+ *
84
+ * This method is asynchronous because it will await the websocket's connection
85
+ * to the server. You will need to `await` a call to this function or handle the
86
+ * return type natively as a Promise.
87
+ * @param store The MergeableStore to synchronize.
88
+ * @param webSocket The WebSocket to send synchronization messages over.
89
+ * @param requestTimeoutSeconds An optional time in seconds that the
90
+ * Synchronizer will wait for responses to request messages, defaulting to 1.
91
+ * @param onIgnoredError An optional handler for the errors that the
92
+ * Synchronizer would otherwise ignore when trying to synchronize data. This is
93
+ * suitable for debugging synchronization issues in a development environment.
94
+ * @returns A reference to the new WsSynchronizer object.
95
+ * @example
96
+ * This example creates two WsSynchronizer objects to synchronize one
97
+ * MergeableStore to another via a server.
98
+ *
99
+ * ```js
100
+ * import {WebSocket, WebSocketServer} from 'ws';
101
+ * import {createMergeableStore} from 'tinybase';
102
+ * import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server';
103
+ * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
104
+ *
105
+ * const server = createWsServer(new WebSocketServer({port: 8047}));
106
+ *
107
+ * const store1 = createMergeableStore();
108
+ * const store2 = createMergeableStore();
109
+ *
110
+ * const synchronizer1 = await createWsSynchronizer(
111
+ * store1,
112
+ * new WebSocket('ws://localhost:8047'),
113
+ * );
114
+ * const synchronizer2 = await createWsSynchronizer(
115
+ * store2,
116
+ * new WebSocket('ws://localhost:8047'),
117
+ * );
118
+ *
119
+ * await synchronizer1.startSync();
120
+ * await synchronizer2.startSync();
121
+ *
122
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
123
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
124
+ *
125
+ * // ...
126
+ * console.log(store1.getTables());
127
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
128
+ * console.log(store2.getTables());
129
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
130
+ *
131
+ * synchronizer1.destroy();
132
+ * synchronizer2.destroy();
133
+ * server.destroy();
134
+ * ```
76
135
  * @category Creation
136
+ * @since v5.0.0
77
137
  */
78
138
  export function createWsSynchronizer<WebSocketType extends WebSocketTypes>(
79
139
  store: MergeableStore,
@@ -2,7 +2,7 @@
2
2
  * The synchronizer-ws module of the TinyBase project lets you synchronize
3
3
  * MergeableStore data to and from other MergeableStore instances via WebSockets
4
4
  * facilitated by a server.
5
- * @see Synchronizing Data guide
5
+ * @see Synchronization guide
6
6
  * @see Todo App v6 (collaboration) demo
7
7
  * @packageDocumentation
8
8
  * @module synchronizer-ws-client
@@ -20,6 +20,8 @@ import type {WebSocket as WsWebSocket} from 'ws';
20
20
  * This includes the browser-native WebSocket type, as well as the WebSocket
21
21
  * type from the well-known `ws` package (such that the Synchronizer can be used
22
22
  * in a server environment).
23
+ * @category Creation
24
+ * @since v5.0.0
23
25
  */
24
26
  export type WebSocketTypes = WebSocket | WsWebSocket;
25
27
 
@@ -28,19 +30,19 @@ export type WebSocketTypes = WebSocket | WsWebSocket;
28
30
  * synchronize MergeableStore data to and from other MergeableStore instances
29
31
  * via WebSockets facilitated by a server.
30
32
  *
33
+ * You should use the createWsSynchronizer function to create a WsSynchronizer
34
+ * object.
35
+ *
31
36
  * It is a minor extension to the Synchronizer interface and simply provides an
32
37
  * extra getWebSocket method for accessing a reference to the WebSocket being
33
38
  * used.
34
- *
35
- * You should use the createWsSynchronizer function to create a WsSynchronizer
36
- * object.
37
39
  * @category Synchronizer
38
40
  * @since v5.0.0
39
41
  */
40
42
  export interface WsSynchronizer<WebSocketType extends WebSocketTypes>
41
43
  extends Synchronizer {
42
44
  /**
43
- * The getWebSocket method returns reference to the WebSocket being used for
45
+ * The getWebSocket method returns a reference to the WebSocket being used for
44
46
  * synchronization.
45
47
  * @returns The WebSocket reference.
46
48
  * @example
@@ -72,8 +74,66 @@ export interface WsSynchronizer<WebSocketType extends WebSocketTypes>
72
74
  }
73
75
 
74
76
  /**
75
- * The createWsSynchronizer function.
77
+ * The createWsSynchronizer function creates a WsSynchronizer object that can
78
+ * synchronize MergeableStore data to and from other MergeableStore instances
79
+ * via WebSockets facilitated by a WsServer.
80
+ *
81
+ * As well as providing a reference to the MergeableStore to persist, you must
82
+ * provide a configured WebSocket to send synchronization messages over.
83
+ *
84
+ * This method is asynchronous because it will await the websocket's connection
85
+ * to the server. You will need to `await` a call to this function or handle the
86
+ * return type natively as a Promise.
87
+ * @param store The MergeableStore to synchronize.
88
+ * @param webSocket The WebSocket to send synchronization messages over.
89
+ * @param requestTimeoutSeconds An optional time in seconds that the
90
+ * Synchronizer will wait for responses to request messages, defaulting to 1.
91
+ * @param onIgnoredError An optional handler for the errors that the
92
+ * Synchronizer would otherwise ignore when trying to synchronize data. This is
93
+ * suitable for debugging synchronization issues in a development environment.
94
+ * @returns A reference to the new WsSynchronizer object.
95
+ * @example
96
+ * This example creates two WsSynchronizer objects to synchronize one
97
+ * MergeableStore to another via a server.
98
+ *
99
+ * ```js
100
+ * import {WebSocket, WebSocketServer} from 'ws';
101
+ * import {createMergeableStore} from 'tinybase';
102
+ * import {createWsServer} from 'tinybase/synchronizers/synchronizer-ws-server';
103
+ * import {createWsSynchronizer} from 'tinybase/synchronizers/synchronizer-ws-client';
104
+ *
105
+ * const server = createWsServer(new WebSocketServer({port: 8047}));
106
+ *
107
+ * const store1 = createMergeableStore();
108
+ * const store2 = createMergeableStore();
109
+ *
110
+ * const synchronizer1 = await createWsSynchronizer(
111
+ * store1,
112
+ * new WebSocket('ws://localhost:8047'),
113
+ * );
114
+ * const synchronizer2 = await createWsSynchronizer(
115
+ * store2,
116
+ * new WebSocket('ws://localhost:8047'),
117
+ * );
118
+ *
119
+ * await synchronizer1.startSync();
120
+ * await synchronizer2.startSync();
121
+ *
122
+ * store1.setTables({pets: {fido: {species: 'dog'}}});
123
+ * store2.setTables({pets: {felix: {species: 'cat'}}});
124
+ *
125
+ * // ...
126
+ * console.log(store1.getTables());
127
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
128
+ * console.log(store2.getTables());
129
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
130
+ *
131
+ * synchronizer1.destroy();
132
+ * synchronizer2.destroy();
133
+ * server.destroy();
134
+ * ```
76
135
  * @category Creation
136
+ * @since v5.0.0
77
137
  */
78
138
  export function createWsSynchronizer<WebSocketType extends WebSocketTypes>(
79
139
  store: MergeableStore,