tinybase 4.0.0-beta.0 → 4.0.0-beta.2

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 (203) hide show
  1. package/bin/cli.js +1 -1
  2. package/lib/checkpoints.js +1 -1
  3. package/lib/checkpoints.js.gz +0 -0
  4. package/lib/cjs/checkpoints.cjs +1 -1
  5. package/lib/cjs/checkpoints.cjs.gz +0 -0
  6. package/lib/cjs/indexes.cjs +1 -1
  7. package/lib/cjs/indexes.cjs.gz +0 -0
  8. package/lib/cjs/metrics.cjs +1 -1
  9. package/lib/cjs/metrics.cjs.gz +0 -0
  10. package/lib/cjs/persister-browser.cjs +1 -0
  11. package/lib/cjs/persister-browser.cjs.gz +0 -0
  12. package/lib/cjs/persister-file.cjs +1 -0
  13. package/lib/cjs/persister-file.cjs.gz +0 -0
  14. package/lib/cjs/persister-remote.cjs +1 -0
  15. package/lib/cjs/persister-remote.cjs.gz +0 -0
  16. package/lib/cjs/persister-yjs.cjs +1 -1
  17. package/lib/cjs/persister-yjs.cjs.gz +0 -0
  18. package/lib/cjs/persisters.cjs +1 -1
  19. package/lib/cjs/persisters.cjs.gz +0 -0
  20. package/lib/cjs/queries.cjs +1 -1
  21. package/lib/cjs/queries.cjs.gz +0 -0
  22. package/lib/cjs/relationships.cjs +1 -1
  23. package/lib/cjs/relationships.cjs.gz +0 -0
  24. package/lib/cjs/store.cjs +1 -1
  25. package/lib/cjs/store.cjs.gz +0 -0
  26. package/lib/cjs/tinybase.cjs +1 -1
  27. package/lib/cjs/tinybase.cjs.gz +0 -0
  28. package/lib/cjs/tools.cjs +1 -1
  29. package/lib/cjs/tools.cjs.gz +0 -0
  30. package/lib/cjs/ui-react.cjs +1 -1
  31. package/lib/cjs/ui-react.cjs.gz +0 -0
  32. package/lib/cjs-es6/checkpoints.cjs +1 -1
  33. package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
  34. package/lib/cjs-es6/indexes.cjs +1 -1
  35. package/lib/cjs-es6/indexes.cjs.gz +0 -0
  36. package/lib/cjs-es6/metrics.cjs +1 -1
  37. package/lib/cjs-es6/metrics.cjs.gz +0 -0
  38. package/lib/cjs-es6/persister-browser.cjs +1 -0
  39. package/lib/cjs-es6/persister-browser.cjs.gz +0 -0
  40. package/lib/cjs-es6/persister-file.cjs +1 -0
  41. package/lib/cjs-es6/persister-file.cjs.gz +0 -0
  42. package/lib/cjs-es6/persister-remote.cjs +1 -0
  43. package/lib/cjs-es6/persister-remote.cjs.gz +0 -0
  44. package/lib/cjs-es6/persister-yjs.cjs +1 -1
  45. package/lib/cjs-es6/persister-yjs.cjs.gz +0 -0
  46. package/lib/cjs-es6/persisters.cjs +1 -1
  47. package/lib/cjs-es6/persisters.cjs.gz +0 -0
  48. package/lib/cjs-es6/queries.cjs +1 -1
  49. package/lib/cjs-es6/queries.cjs.gz +0 -0
  50. package/lib/cjs-es6/relationships.cjs +1 -1
  51. package/lib/cjs-es6/relationships.cjs.gz +0 -0
  52. package/lib/cjs-es6/store.cjs +1 -1
  53. package/lib/cjs-es6/store.cjs.gz +0 -0
  54. package/lib/cjs-es6/tinybase.cjs +1 -1
  55. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  56. package/lib/cjs-es6/tools.cjs +1 -1
  57. package/lib/cjs-es6/tools.cjs.gz +0 -0
  58. package/lib/cjs-es6/ui-react.cjs +1 -1
  59. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  60. package/lib/debug/checkpoints.js +3 -3
  61. package/lib/debug/indexes.js +3 -3
  62. package/lib/debug/metrics.js +3 -3
  63. package/lib/debug/persister-browser.js +147 -0
  64. package/lib/debug/persister-file.js +140 -0
  65. package/lib/debug/persister-remote.js +159 -0
  66. package/lib/debug/persister-yjs.js +234 -40
  67. package/lib/debug/persisters.js +43 -133
  68. package/lib/debug/queries.js +5 -5
  69. package/lib/debug/relationships.js +3 -3
  70. package/lib/debug/store.js +137 -87
  71. package/lib/debug/tinybase.js +179 -215
  72. package/lib/debug/tools.js +9 -9
  73. package/lib/es6/checkpoints.js +1 -1
  74. package/lib/es6/checkpoints.js.gz +0 -0
  75. package/lib/es6/indexes.js +1 -1
  76. package/lib/es6/indexes.js.gz +0 -0
  77. package/lib/es6/metrics.js +1 -1
  78. package/lib/es6/metrics.js.gz +0 -0
  79. package/lib/es6/persister-browser.js +1 -0
  80. package/lib/es6/persister-browser.js.gz +0 -0
  81. package/lib/es6/persister-file.js +1 -0
  82. package/lib/es6/persister-file.js.gz +0 -0
  83. package/lib/es6/persister-remote.js +1 -0
  84. package/lib/es6/persister-remote.js.gz +0 -0
  85. package/lib/es6/persister-yjs.js +1 -1
  86. package/lib/es6/persister-yjs.js.gz +0 -0
  87. package/lib/es6/persisters.js +1 -1
  88. package/lib/es6/persisters.js.gz +0 -0
  89. package/lib/es6/queries.js +1 -1
  90. package/lib/es6/queries.js.gz +0 -0
  91. package/lib/es6/relationships.js +1 -1
  92. package/lib/es6/relationships.js.gz +0 -0
  93. package/lib/es6/store.js +1 -1
  94. package/lib/es6/store.js.gz +0 -0
  95. package/lib/es6/tinybase.js +1 -1
  96. package/lib/es6/tinybase.js.gz +0 -0
  97. package/lib/es6/tools.js +1 -1
  98. package/lib/es6/tools.js.gz +0 -0
  99. package/lib/es6/ui-react.js +1 -1
  100. package/lib/es6/ui-react.js.gz +0 -0
  101. package/lib/indexes.js +1 -1
  102. package/lib/indexes.js.gz +0 -0
  103. package/lib/metrics.js +1 -1
  104. package/lib/metrics.js.gz +0 -0
  105. package/lib/persister-browser.js +1 -0
  106. package/lib/persister-browser.js.gz +0 -0
  107. package/lib/persister-file.js +1 -0
  108. package/lib/persister-file.js.gz +0 -0
  109. package/lib/persister-remote.js +1 -0
  110. package/lib/persister-remote.js.gz +0 -0
  111. package/lib/persister-yjs.js +1 -1
  112. package/lib/persister-yjs.js.gz +0 -0
  113. package/lib/persisters.js +1 -1
  114. package/lib/persisters.js.gz +0 -0
  115. package/lib/queries.js +1 -1
  116. package/lib/queries.js.gz +0 -0
  117. package/lib/relationships.js +1 -1
  118. package/lib/relationships.js.gz +0 -0
  119. package/lib/store.js +1 -1
  120. package/lib/store.js.gz +0 -0
  121. package/lib/tinybase.js +1 -1
  122. package/lib/tinybase.js.gz +0 -0
  123. package/lib/tools.js +1 -1
  124. package/lib/tools.js.gz +0 -0
  125. package/lib/types/persister-browser.d.ts +85 -0
  126. package/lib/types/persister-file.d.ts +41 -0
  127. package/lib/types/persister-remote.d.ts +60 -0
  128. package/lib/types/persister-yjs.d.ts +70 -8
  129. package/lib/types/persisters.d.ts +73 -181
  130. package/lib/types/queries.d.ts +52 -52
  131. package/lib/types/store.d.ts +499 -139
  132. package/lib/types/tools.d.ts +16 -16
  133. package/lib/types/ui-react.d.ts +56 -47
  134. package/lib/types/with-schemas/internal/ui-react.d.ts +2 -2
  135. package/lib/types/with-schemas/persister-browser.d.ts +103 -0
  136. package/lib/types/with-schemas/persister-file.d.ts +50 -0
  137. package/lib/types/with-schemas/persister-remote.d.ts +71 -0
  138. package/lib/types/with-schemas/persister-yjs.d.ts +72 -9
  139. package/lib/types/with-schemas/persisters.d.ts +99 -223
  140. package/lib/types/with-schemas/queries.d.ts +52 -52
  141. package/lib/types/with-schemas/store.d.ts +595 -153
  142. package/lib/types/with-schemas/tools.d.ts +16 -16
  143. package/lib/types/with-schemas/ui-react.d.ts +54 -45
  144. package/lib/ui-react.js +1 -1
  145. package/lib/ui-react.js.gz +0 -0
  146. package/lib/umd/checkpoints.js +1 -1
  147. package/lib/umd/checkpoints.js.gz +0 -0
  148. package/lib/umd/indexes.js +1 -1
  149. package/lib/umd/indexes.js.gz +0 -0
  150. package/lib/umd/metrics.js +1 -1
  151. package/lib/umd/metrics.js.gz +0 -0
  152. package/lib/umd/persister-browser.js +1 -0
  153. package/lib/umd/persister-browser.js.gz +0 -0
  154. package/lib/umd/persister-file.js +1 -0
  155. package/lib/umd/persister-file.js.gz +0 -0
  156. package/lib/umd/persister-remote.js +1 -0
  157. package/lib/umd/persister-remote.js.gz +0 -0
  158. package/lib/umd/persister-yjs.js +1 -1
  159. package/lib/umd/persister-yjs.js.gz +0 -0
  160. package/lib/umd/persisters.js +1 -1
  161. package/lib/umd/persisters.js.gz +0 -0
  162. package/lib/umd/queries.js +1 -1
  163. package/lib/umd/queries.js.gz +0 -0
  164. package/lib/umd/relationships.js +1 -1
  165. package/lib/umd/relationships.js.gz +0 -0
  166. package/lib/umd/store.js +1 -1
  167. package/lib/umd/store.js.gz +0 -0
  168. package/lib/umd/tinybase.js +1 -1
  169. package/lib/umd/tinybase.js.gz +0 -0
  170. package/lib/umd/tools.js +1 -1
  171. package/lib/umd/tools.js.gz +0 -0
  172. package/lib/umd/ui-react.js +1 -1
  173. package/lib/umd/ui-react.js.gz +0 -0
  174. package/lib/umd-es6/checkpoints.js +1 -1
  175. package/lib/umd-es6/checkpoints.js.gz +0 -0
  176. package/lib/umd-es6/indexes.js +1 -1
  177. package/lib/umd-es6/indexes.js.gz +0 -0
  178. package/lib/umd-es6/metrics.js +1 -1
  179. package/lib/umd-es6/metrics.js.gz +0 -0
  180. package/lib/umd-es6/persister-browser.js +1 -0
  181. package/lib/umd-es6/persister-browser.js.gz +0 -0
  182. package/lib/umd-es6/persister-file.js +1 -0
  183. package/lib/umd-es6/persister-file.js.gz +0 -0
  184. package/lib/umd-es6/persister-remote.js +1 -0
  185. package/lib/umd-es6/persister-remote.js.gz +0 -0
  186. package/lib/umd-es6/persister-yjs.js +1 -1
  187. package/lib/umd-es6/persister-yjs.js.gz +0 -0
  188. package/lib/umd-es6/persisters.js +1 -1
  189. package/lib/umd-es6/persisters.js.gz +0 -0
  190. package/lib/umd-es6/queries.js +1 -1
  191. package/lib/umd-es6/queries.js.gz +0 -0
  192. package/lib/umd-es6/relationships.js +1 -1
  193. package/lib/umd-es6/relationships.js.gz +0 -0
  194. package/lib/umd-es6/store.js +1 -1
  195. package/lib/umd-es6/store.js.gz +0 -0
  196. package/lib/umd-es6/tinybase.js +1 -1
  197. package/lib/umd-es6/tinybase.js.gz +0 -0
  198. package/lib/umd-es6/tools.js +1 -1
  199. package/lib/umd-es6/tools.js.gz +0 -0
  200. package/lib/umd-es6/ui-react.js +1 -1
  201. package/lib/umd-es6/ui-react.js.gz +0 -0
  202. package/package.json +15 -15
  203. package/readme.md +2 -2
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @packageDocumentation
9
9
  * @module tools
10
- * @since v2.2.0
10
+ * @since v2.2
11
11
  */
12
12
 
13
13
  import {Store, TablesSchema, ValuesSchema} from './store.d';
@@ -20,7 +20,7 @@ import {Id} from './common.d';
20
20
  * A StoreStats object is returned from the getStoreStats method.
21
21
  *
22
22
  * @category Statistics
23
- * @since v2.2.0
23
+ * @since v2.2
24
24
  */
25
25
  export type StoreStats = {
26
26
  /**
@@ -37,7 +37,7 @@ export type StoreStats = {
37
37
  */
38
38
  totalCells: number;
39
39
  /**
40
- * The number of Value objects in the Store, since v3.0.0.
40
+ * The number of Value objects in the Store, since v3.0.
41
41
  */
42
42
  totalValues: number;
43
43
  /**
@@ -59,7 +59,7 @@ export type StoreStats = {
59
59
  * the getStoreStats method) when the `detail` flag is specified.
60
60
  *
61
61
  * @category Statistics
62
- * @since v2.2.0
62
+ * @since v2.2
63
63
  */
64
64
  export type StoreStatsDetail = {
65
65
  /**
@@ -73,7 +73,7 @@ export type StoreStatsDetail = {
73
73
  * single Table in the Store, and is used for debugging purposes.
74
74
  *
75
75
  * @category Statistics
76
- * @since v2.2.0
76
+ * @since v2.2
77
77
  */
78
78
  export type StoreStatsTableDetail = {
79
79
  /**
@@ -95,7 +95,7 @@ export type StoreStatsTableDetail = {
95
95
  * Store, and is used for debugging purposes.
96
96
  *
97
97
  * @category Statistics
98
- * @since v2.2.0
98
+ * @since v2.2
99
99
  */
100
100
  export type StoreStatsRowDetail = {
101
101
  /**
@@ -110,7 +110,7 @@ export type StoreStatsRowDetail = {
110
110
  *
111
111
  * @see Developer Tools guides
112
112
  * @category Tools
113
- * @since v2.2.0
113
+ * @since v2.2
114
114
  */
115
115
  export interface Tools {
116
116
  //
@@ -169,7 +169,7 @@ export interface Tools {
169
169
  * // -> {fido: {rowCells: 2}, felix: {rowCells: 2}, cujo: {rowCells: 2}}
170
170
  * ```
171
171
  * @category Statistics
172
- * @since v2.2.0
172
+ * @since v2.2
173
173
  */
174
174
  getStoreStats(detail?: boolean): StoreStats;
175
175
 
@@ -233,7 +233,7 @@ export interface Tools {
233
233
  * // -> {type: 'boolean'}
234
234
  * ```
235
235
  * @category Modelling
236
- * @since v3.0.0
236
+ * @since v3.0
237
237
  */
238
238
  getStoreTablesSchema(): TablesSchema;
239
239
 
@@ -272,13 +272,13 @@ export interface Tools {
272
272
  * // -> {open: {type: 'boolean'}, employees: {type: 'number'}}
273
273
  * ```
274
274
  * @category Modelling
275
- * @since v3.0.0
275
+ * @since v3.0
276
276
  */
277
277
  getStoreValuesSchema(): ValuesSchema;
278
278
 
279
279
  /**
280
280
  * The getStoreApi method returns code-generated `.d.ts` and `.ts(x)` files
281
- * that describe the schema of a Store and React bindings (since v3.1.0) in an
281
+ * that describe the schema of a Store and React bindings (since v3.1) in an
282
282
  * ORM style.
283
283
  *
284
284
  * If the Store does not already have an explicit TablesSchema or ValuesSchema
@@ -378,14 +378,14 @@ export interface Tools {
378
378
  * // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
379
379
  * ```
380
380
  * @category Modelling
381
- * @since v2.2.0
381
+ * @since v2.2
382
382
  */
383
383
  getStoreApi(storeName: string): [string, string, string, string];
384
384
 
385
385
  /**
386
386
  * The getPrettyStoreApi method attempts to return prettified code-generated
387
387
  * `.d.ts` and `.ts(x)` files that describe the schema of a Store and React
388
- * bindings (since v3.1.0) in an ORM style.
388
+ * bindings (since v3.1) in an ORM style.
389
389
  *
390
390
  * This is simply a wrapper around the getStoreApi method that attempts to
391
391
  * invoke the `prettier` module (which it hopes you have installed) to format
@@ -458,7 +458,7 @@ export interface Tools {
458
458
  * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
459
459
  * ```
460
460
  * @category Modelling
461
- * @since v2.2.0
461
+ * @since v2.2
462
462
  */
463
463
  getPrettyStoreApi(
464
464
  storeName: string,
@@ -480,7 +480,7 @@ export interface Tools {
480
480
  * // -> 1
481
481
  * ```
482
482
  * @category Getter
483
- * @since v3.0.0
483
+ * @since v3.0
484
484
  */
485
485
  getStore(): Store;
486
486
  //
@@ -528,7 +528,7 @@ export interface Tools {
528
528
  * // -> true
529
529
  * ```
530
530
  * @category Creation
531
- * @since v2.2.0
531
+ * @since v2.2
532
532
  */
533
533
  export function createTools(store: Store): Tools;
534
534
  //
@@ -163,7 +163,7 @@ export type RelationshipsOrRelationshipsId = Relationships | Id;
163
163
  * parameter or a prop, allowing you to pass in either the Store or its Id.
164
164
  *
165
165
  * @category Identity
166
- * @since v2.0.0
166
+ * @since v2.0
167
167
  */
168
168
  export type QueriesOrQueriesId = Queries | Id;
169
169
 
@@ -767,7 +767,7 @@ export function useRowIds(tableId: Id, storeOrStoreId?: StoreOrStoreId): Ids;
767
767
  * // -> '<span>["felix","fido"]</span>'
768
768
  * ```
769
769
  * @category Store hooks
770
- * @since v2.0.0
770
+ * @since v2.0
771
771
  */
772
772
  export function useSortedRowIds(
773
773
  tableId: Id,
@@ -1115,7 +1115,7 @@ export function useCell(
1115
1115
  * // -> '<span>{"open":true}</span>'
1116
1116
  * ```
1117
1117
  * @category Store hooks
1118
- * @since v3.0.0
1118
+ * @since v3.0
1119
1119
  */
1120
1120
  export function useValues(storeOrStoreId?: StoreOrStoreId): Values;
1121
1121
 
@@ -1192,7 +1192,7 @@ export function useValues(storeOrStoreId?: StoreOrStoreId): Values;
1192
1192
  * // -> '<span>["open"]</span>'
1193
1193
  * ```
1194
1194
  * @category Store hooks
1195
- * @since v3.0.0
1195
+ * @since v3.0
1196
1196
  */
1197
1197
  export function useValueIds(storeOrStoreId?: StoreOrStoreId): Ids;
1198
1198
 
@@ -1273,7 +1273,7 @@ export function useValueIds(storeOrStoreId?: StoreOrStoreId): Ids;
1273
1273
  * // -> '<span>true</span>'
1274
1274
  * ```
1275
1275
  * @category Store hooks
1276
- * @since v3.0.0
1276
+ * @since v3.0
1277
1277
  */
1278
1278
  export function useValue(
1279
1279
  valueId: Id,
@@ -1929,7 +1929,7 @@ export function useSetCellCallback<Parameter>(
1929
1929
  * // -> '{"bubbles":true}'
1930
1930
  * ```
1931
1931
  * @category Store hooks
1932
- * @since v3.0.0
1932
+ * @since v3.0
1933
1933
  */
1934
1934
  export function useSetValuesCallback<Parameter>(
1935
1935
  getValues: (parameter: Parameter, store: Store) => Values,
@@ -2015,7 +2015,7 @@ export function useSetValuesCallback<Parameter>(
2015
2015
  * // -> '{"open":true,"bubbles":true}'
2016
2016
  * ```
2017
2017
  * @category Store hooks
2018
- * @since v3.0.0
2018
+ * @since v3.0
2019
2019
  */
2020
2020
  export function useSetPartialValuesCallback<Parameter>(
2021
2021
  getPartialValues: (parameter: Parameter, store: Store) => Values,
@@ -2101,7 +2101,7 @@ export function useSetPartialValuesCallback<Parameter>(
2101
2101
  * // -> '{"open":true,"bubbles":true}'
2102
2102
  * ```
2103
2103
  * @category Store hooks
2104
- * @since v3.0.0
2104
+ * @since v3.0
2105
2105
  */
2106
2106
  export function useSetValueCallback<Parameter>(
2107
2107
  valueId: Id,
@@ -2441,7 +2441,7 @@ export function useDelCellCallback(
2441
2441
  * // -> '{}'
2442
2442
  * ```
2443
2443
  * @category Store hooks
2444
- * @since v3.0.0
2444
+ * @since v3.0
2445
2445
  */
2446
2446
  export function useDelValuesCallback(
2447
2447
  storeOrStoreId?: StoreOrStoreId,
@@ -2506,7 +2506,7 @@ export function useDelValuesCallback(
2506
2506
  * // -> '{"employees":3}'
2507
2507
  * ```
2508
2508
  * @category Store hooks
2509
- * @since v3.0.0
2509
+ * @since v3.0
2510
2510
  */
2511
2511
  export function useDelValueCallback(
2512
2512
  valueId: Id,
@@ -2843,7 +2843,7 @@ export function useRowIdsListener(
2843
2843
  * // -> 0
2844
2844
  * ```
2845
2845
  * @category Store hooks
2846
- * @since v2.0.0
2846
+ * @since v2.0
2847
2847
  */
2848
2848
  export function useSortedRowIdsListener(
2849
2849
  tableId: Id,
@@ -3143,7 +3143,7 @@ export function useCellListener(
3143
3143
  * // -> 0
3144
3144
  * ```
3145
3145
  * @category Store hooks
3146
- * @since v3.0.0
3146
+ * @since v3.0
3147
3147
  */
3148
3148
  export function useValuesListener(
3149
3149
  listener: ValuesListener,
@@ -3207,7 +3207,7 @@ export function useValuesListener(
3207
3207
  * // -> 0
3208
3208
  * ```
3209
3209
  * @category Store hooks
3210
- * @since v3.0.0
3210
+ * @since v3.0
3211
3211
  */
3212
3212
  export function useValueIdsListener(
3213
3213
  listener: ValueIdsListener,
@@ -3274,7 +3274,7 @@ export function useValueIdsListener(
3274
3274
  * // -> 0
3275
3275
  * ```
3276
3276
  * @category Store hooks
3277
- * @since v3.0.0
3277
+ * @since v3.0
3278
3278
  */
3279
3279
  export function useValueListener(
3280
3280
  valueId: IdOrNull,
@@ -5113,7 +5113,7 @@ export function useLinkedRowIdsListener(
5113
5113
  * // -> '<span>brown</span>'
5114
5114
  * ```
5115
5115
  * @category Queries hooks
5116
- * @since v2.0.0
5116
+ * @since v2.0
5117
5117
  */
5118
5118
  export function useCreateQueries(
5119
5119
  store: Store,
@@ -5181,7 +5181,7 @@ export function useCreateQueries(
5181
5181
  * // -> '<span>0</span>'
5182
5182
  * ```
5183
5183
  * @category Queries hooks
5184
- * @since v2.0.0
5184
+ * @since v2.0
5185
5185
  */
5186
5186
  export function useQueries(id?: Id): Queries | undefined;
5187
5187
 
@@ -5298,7 +5298,7 @@ export function useQueries(id?: Id): Queries | undefined;
5298
5298
  * // -> '<span>{"fido":{"color":"brown"},"cujo":{"color":"black"}}</span>'
5299
5299
  * ```
5300
5300
  * @category Queries hooks
5301
- * @since v2.0.0
5301
+ * @since v2.0
5302
5302
  */
5303
5303
  export function useResultTable(
5304
5304
  queryId: Id,
@@ -5419,7 +5419,7 @@ export function useResultTable(
5419
5419
  * // -> '<span>["fido","cujo"]</span>'
5420
5420
  * ```
5421
5421
  * @category Queries hooks
5422
- * @since v2.0.0
5422
+ * @since v2.0
5423
5423
  */
5424
5424
  export function useResultRowIds(
5425
5425
  queryId: Id,
@@ -5568,7 +5568,7 @@ export function useResultRowIds(
5568
5568
  * // -> '<span>["cujo","fido"]</span>'
5569
5569
  * ```
5570
5570
  * @category Queries hooks
5571
- * @since v2.0.0
5571
+ * @since v2.0
5572
5572
  */
5573
5573
  export function useResultSortedRowIds(
5574
5574
  queryId: Id,
@@ -5696,7 +5696,7 @@ export function useResultSortedRowIds(
5696
5696
  * // -> '<span>{"color":"brown"}</span>'
5697
5697
  * ```
5698
5698
  * @category Queries hooks
5699
- * @since v2.0.0
5699
+ * @since v2.0
5700
5700
  */
5701
5701
  export function useResultRow(
5702
5702
  queryId: Id,
@@ -5827,7 +5827,7 @@ export function useResultRow(
5827
5827
  * // -> '<span>["species","color"]</span>'
5828
5828
  * ```
5829
5829
  * @category Queries hooks
5830
- * @since v2.0.0
5830
+ * @since v2.0
5831
5831
  */
5832
5832
  export function useResultCellIds(
5833
5833
  queryId: Id,
@@ -5954,7 +5954,7 @@ export function useResultCellIds(
5954
5954
  * // -> '<span>brown</span>'
5955
5955
  * ```
5956
5956
  * @category Queries hooks
5957
- * @since v2.0.0
5957
+ * @since v2.0
5958
5958
  */
5959
5959
  export function useResultCell(
5960
5960
  queryId: Id,
@@ -6032,7 +6032,7 @@ export function useResultCell(
6032
6032
  * // -> 0
6033
6033
  * ```
6034
6034
  * @category Queries hooks
6035
- * @since v2.0.0
6035
+ * @since v2.0
6036
6036
  */
6037
6037
  export function useResultTableListener(
6038
6038
  queryId: IdOrNull,
@@ -6110,7 +6110,7 @@ export function useResultTableListener(
6110
6110
  * // -> 0
6111
6111
  * ```
6112
6112
  * @category Queries hooks
6113
- * @since v2.0.0
6113
+ * @since v2.0
6114
6114
  */
6115
6115
  export function useResultRowIdsListener(
6116
6116
  queryId: IdOrNull,
@@ -6195,7 +6195,7 @@ export function useResultRowIdsListener(
6195
6195
  * // -> 0
6196
6196
  * ```
6197
6197
  * @category Queries hooks
6198
- * @since v2.0.0
6198
+ * @since v2.0
6199
6199
  */
6200
6200
  export function useResultSortedRowIdsListener(
6201
6201
  queryId: Id,
@@ -6283,7 +6283,7 @@ export function useResultSortedRowIdsListener(
6283
6283
  * // -> 0
6284
6284
  * ```
6285
6285
  * @category Queries hooks
6286
- * @since v2.0.0
6286
+ * @since v2.0
6287
6287
  */
6288
6288
  export function useResultRowListener(
6289
6289
  queryId: IdOrNull,
@@ -6368,7 +6368,7 @@ export function useResultRowListener(
6368
6368
  * // -> 0
6369
6369
  * ```
6370
6370
  * @category Queries hooks
6371
- * @since v2.0.0
6371
+ * @since v2.0
6372
6372
  */
6373
6373
  export function useResultCellIdsListener(
6374
6374
  queryId: IdOrNull,
@@ -6455,7 +6455,7 @@ export function useResultCellIdsListener(
6455
6455
  * // -> 0
6456
6456
  * ```
6457
6457
  * @category Queries hooks
6458
- * @since v2.0.0
6458
+ * @since v2.0
6459
6459
  */
6460
6460
  export function useResultCellListener(
6461
6461
  queryId: IdOrNull,
@@ -7389,7 +7389,10 @@ export function useCheckpointListener(
7389
7389
  * return <span>{JSON.stringify(useTables(store))}</span>;
7390
7390
  * };
7391
7391
  *
7392
- * sessionStorage.setItem('pets', '{"pets":{"fido":{"species":"dog"}}}');
7392
+ * sessionStorage.setItem(
7393
+ * 'pets',
7394
+ * '[{"pets":{"fido":{"species":"dog"}}}, {}]',
7395
+ * );
7393
7396
  *
7394
7397
  * const app = document.createElement('div');
7395
7398
  * const root = ReactDOMClient.createRoot(app);
@@ -7429,8 +7432,14 @@ export function useCheckpointListener(
7429
7432
  * return <span>{JSON.stringify(useTables(store))}</span>;
7430
7433
  * };
7431
7434
  *
7432
- * sessionStorage.setItem('fidoStore', '{"pets":{"fido":{"species":"dog"}}}');
7433
- * sessionStorage.setItem('cujoStore', '{"pets":{"cujo":{"species":"dog"}}}');
7435
+ * sessionStorage.setItem(
7436
+ * 'fidoStore',
7437
+ * '[{"pets":{"fido":{"species":"dog"}}}, {}]',
7438
+ * );
7439
+ * sessionStorage.setItem(
7440
+ * 'cujoStore',
7441
+ * '[{"pets":{"cujo":{"species":"dog"}}}, {}]',
7442
+ * );
7434
7443
  *
7435
7444
  * const app = document.createElement('div');
7436
7445
  * const root = ReactDOMClient.createRoot(app);
@@ -7542,7 +7551,7 @@ export type TableProps = {
7542
7551
  * Table in a Store, such as the SortedTableView component.
7543
7552
  *
7544
7553
  * @category Props
7545
- * @since v2.0.0
7554
+ * @since v2.0
7546
7555
  */
7547
7556
  export type SortedTableProps = {
7548
7557
  /**
@@ -7669,7 +7678,7 @@ export type CellProps = {
7669
7678
  * Store, such as the ValuesView component.
7670
7679
  *
7671
7680
  * @category Props
7672
- * @since v3.0.0
7681
+ * @since v3.0
7673
7682
  */
7674
7683
  export type ValuesProps = {
7675
7684
  /**
@@ -7703,7 +7712,7 @@ export type ValuesProps = {
7703
7712
  * Row, such as the ValueView component.
7704
7713
  *
7705
7714
  * @category Props
7706
- * @since v3.0.0
7715
+ * @since v3.0
7707
7716
  */
7708
7717
  export type ValueProps = {
7709
7718
  /**
@@ -7954,7 +7963,7 @@ export type LinkedRowsProps = {
7954
7963
  * result Table, such as the ResultTableView component.
7955
7964
  *
7956
7965
  * @category Props
7957
- * @since v2.0.0
7966
+ * @since v2.0
7958
7967
  */
7959
7968
  export type ResultTableProps = {
7960
7969
  /**
@@ -7994,7 +8003,7 @@ export type ResultTableProps = {
7994
8003
  * sorted query result Table, such as the ResultSortedTableView component.
7995
8004
  *
7996
8005
  * @category Props
7997
- * @since v2.0.0
8006
+ * @since v2.0
7998
8007
  */
7999
8008
  export type ResultSortedTableProps = {
8000
8009
  /**
@@ -8051,7 +8060,7 @@ export type ResultSortedTableProps = {
8051
8060
  * query result Table, such as the ResultRowView component.
8052
8061
  *
8053
8062
  * @category Props
8054
- * @since v2.0.0
8063
+ * @since v2.0
8055
8064
  */
8056
8065
  export type ResultRowProps = {
8057
8066
  /**
@@ -8095,7 +8104,7 @@ export type ResultRowProps = {
8095
8104
  * Row of a result Table, such as the ResultCellView component.
8096
8105
  *
8097
8106
  * @category Props
8098
- * @since v2.0.0
8107
+ * @since v2.0
8099
8108
  */
8100
8109
  export type ResultCellProps = {
8101
8110
  /**
@@ -8300,12 +8309,12 @@ export type ProviderProps = {
8300
8309
  readonly relationshipsById?: {[relationshipsId: Id]: Relationships};
8301
8310
  /**
8302
8311
  * A default single Queries object that will be available within the Provider
8303
- * context, since v2.0.0.
8312
+ * context, since v2.0.
8304
8313
  */
8305
8314
  readonly queries?: Queries;
8306
8315
  /**
8307
8316
  * An object containing multiple Queries objects that will be available within
8308
- * the Provider context by their Id, since v2.0.0.
8317
+ * the Provider context by their Id, since v2.0.
8309
8318
  */
8310
8319
  readonly queriesById?: {[queriesId: Id]: Queries};
8311
8320
  /**
@@ -8759,7 +8768,7 @@ export function RowView(props: RowProps): ComponentReturnType;
8759
8768
  * // -> '<div><span>felix: cat</span><span><b>fido</b>: dog</span></div>'
8760
8769
  * ```
8761
8770
  * @category Store components
8762
- * @since v2.0.0
8771
+ * @since v2.0
8763
8772
  */
8764
8773
  export function SortedTableView(props: SortedTableProps): ComponentReturnType;
8765
8774
 
@@ -9070,7 +9079,7 @@ export function TablesView(props: TablesProps): ComponentReturnType;
9070
9079
  * // -> '<span></span>'
9071
9080
  * ```
9072
9081
  * @category Store components
9073
- * @since v3.0.0
9082
+ * @since v3.0
9074
9083
  */
9075
9084
  export function ValueView(props: ValueProps): ComponentReturnType;
9076
9085
 
@@ -9176,7 +9185,7 @@ export function ValueView(props: ValueProps): ComponentReturnType;
9176
9185
  * // -> '<div><span><b>open</b>: true</span><span>employees: 3</span></div>'
9177
9186
  * ```
9178
9187
  * @category Store components
9179
- * @since v3.0.0
9188
+ * @since v3.0
9180
9189
  */
9181
9190
  export function ValuesView(props: ValuesProps): ComponentReturnType;
9182
9191
 
@@ -10060,7 +10069,7 @@ export function LinkedRowsView(props: LinkedRowsProps): ComponentReturnType;
10060
10069
  * // -> '<span></span>'
10061
10070
  * ```
10062
10071
  * @category Queries components
10063
- * @since v2.0.0
10072
+ * @since v2.0
10064
10073
  */
10065
10074
  export function ResultCellView(props: ResultCellProps): ComponentReturnType;
10066
10075
 
@@ -10207,7 +10216,7 @@ export function ResultCellView(props: ResultCellProps): ComponentReturnType;
10207
10216
  * // -> '<div><span><b>species</b>: dog</span><span>color: brown</span></div>'
10208
10217
  * ```
10209
10218
  * @category Queries components
10210
- * @since v2.0.0
10219
+ * @since v2.0
10211
10220
  */
10212
10221
  export function ResultRowView(props: ResultRowProps): ComponentReturnType;
10213
10222
 
@@ -10345,7 +10354,7 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
10345
10354
  * // -> '<div><span>felix: black</span><span><b>fido</b>: brown</span></div>'
10346
10355
  * ```
10347
10356
  * @category Queries components
10348
- * @since v2.0.0
10357
+ * @since v2.0
10349
10358
  */
10350
10359
  export function ResultSortedTableView(
10351
10360
  props: ResultSortedTableProps,
@@ -10470,7 +10479,7 @@ export function ResultSortedTableView(
10470
10479
  * // -> '<div><span><b>fido</b>: brown</span><span>felix: black</span></div>'
10471
10480
  * ```
10472
10481
  * @category Queries components
10473
- * @since v2.0.0
10482
+ * @since v2.0
10474
10483
  */
10475
10484
  export function ResultTableView(props: ResultTableProps): ComponentReturnType;
10476
10485
 
@@ -753,12 +753,12 @@ export type ProviderProps<Schemas extends OptionalSchemas> = {
753
753
  readonly relationshipsById?: {[relationshipsId: Id]: Relationships<Schemas>};
754
754
  /**
755
755
  * A default single Queries object that will be available within the Provider
756
- * context, since v2.0.0.
756
+ * context, since v2.0.
757
757
  */
758
758
  readonly queries?: Queries<Schemas>;
759
759
  /**
760
760
  * An object containing multiple Queries objects that will be available within
761
- * the Provider context by their Id, since v2.0.0.
761
+ * the Provider context by their Id, since v2.0.
762
762
  */
763
763
  readonly queriesById?: {[queriesId: Id]: Queries<Schemas>};
764
764
  /**
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The persister-browser module of the TinyBase project lets you save and load
3
+ * Store data to and from browser storage.
4
+ *
5
+ * Two entry points are provided, each of which returns a new Persister object
6
+ * that can load and save a Store:
7
+ *
8
+ * - The createSessionPersister function returns a Persister that uses the
9
+ * browser's session storage.
10
+ * - The createLocalPersister function returns a Persister that uses the
11
+ * browser's local storage.
12
+ *
13
+ * @see Persisting Data guide
14
+ * @packageDocumentation
15
+ * @module persister-browser
16
+ */
17
+
18
+ import {OptionalSchemas, Store} from './store';
19
+ import {Persister} from './persisters';
20
+
21
+ /**
22
+ * The createSessionPersister function creates a Persister object that can
23
+ * persist the Store to the browser's session storage.
24
+ *
25
+ * This has schema-based typing. The following is a simplified representation:
26
+ *
27
+ * ```ts override
28
+ * createSessionPersister(
29
+ * store: Store,
30
+ * storageName: string,
31
+ * ): Persister;
32
+ * ```
33
+ *
34
+ * As well as providing a reference to the Store to persist, you must provide a
35
+ * `storageName` parameter which is unique to your application. This is the key
36
+ * that the browser uses to identify the storage location.
37
+ *
38
+ * @param store The Store to persist.
39
+ * @param storageName The unique key to identify the storage location.
40
+ * @returns A reference to the new Persister object.
41
+ * @example
42
+ * This example creates a Persister object and persists the Store to the
43
+ * browser's session storage.
44
+ *
45
+ * ```js
46
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
47
+ * const persister = createSessionPersister(store, 'pets');
48
+ *
49
+ * await persister.save();
50
+ * console.log(sessionStorage.getItem('pets'));
51
+ * // -> '[{"pets":{"fido":{"species":"dog"}}},{}]'
52
+ *
53
+ * persister.destroy();
54
+ * sessionStorage.clear();
55
+ * ```
56
+ * @category Creation
57
+ */
58
+ export function createSessionPersister<Schemas extends OptionalSchemas>(
59
+ store: Store<Schemas>,
60
+ storageName: string,
61
+ ): Persister<Schemas>;
62
+
63
+ /**
64
+ * The createLocalPersister function creates a Persister object that can
65
+ * persist the Store to the browser's local storage.
66
+ *
67
+ * This has schema-based typing. The following is a simplified representation:
68
+ *
69
+ * ```ts override
70
+ * createLocalPersister(
71
+ * store: Store,
72
+ * storageName: string,
73
+ * ): Persister;
74
+ * ```
75
+ *
76
+ * As well as providing a reference to the Store to persist, you must provide a
77
+ * `storageName` parameter which is unique to your application. This is the key
78
+ * that the browser uses to identify the storage location.
79
+ *
80
+ * @param store The Store to persist.
81
+ * @param storageName The unique key to identify the storage location.
82
+ * @returns A reference to the new Persister object.
83
+ * @example
84
+ * This example creates a Persister object and persists the Store to the
85
+ * browser's local storage.
86
+ *
87
+ * ```js
88
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
89
+ * const persister = createLocalPersister(store, 'pets');
90
+ *
91
+ * await persister.save();
92
+ * console.log(localStorage.getItem('pets'));
93
+ * // -> '[{"pets":{"fido":{"species":"dog"}}},{}]'
94
+ *
95
+ * persister.destroy();
96
+ * localStorage.clear();
97
+ * ```
98
+ * @category Creation
99
+ */
100
+ export function createLocalPersister<Schemas extends OptionalSchemas>(
101
+ store: Store<Schemas>,
102
+ storageName: string,
103
+ ): Persister<Schemas>;