tinybase 3.2.0-beta.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) 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/persisters.cjs +1 -1
  11. package/lib/cjs/persisters.cjs.gz +0 -0
  12. package/lib/cjs/queries.cjs +1 -1
  13. package/lib/cjs/queries.cjs.gz +0 -0
  14. package/lib/cjs/relationships.cjs +1 -1
  15. package/lib/cjs/relationships.cjs.gz +0 -0
  16. package/lib/cjs/store.cjs +1 -1
  17. package/lib/cjs/store.cjs.gz +0 -0
  18. package/lib/cjs/tinybase.cjs +1 -1
  19. package/lib/cjs/tinybase.cjs.gz +0 -0
  20. package/lib/cjs/tools.cjs +1 -1
  21. package/lib/cjs/tools.cjs.gz +0 -0
  22. package/lib/cjs/ui-react.cjs +1 -1
  23. package/lib/cjs/ui-react.cjs.gz +0 -0
  24. package/lib/cjs-es6/checkpoints.cjs +1 -1
  25. package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
  26. package/lib/cjs-es6/indexes.cjs +1 -1
  27. package/lib/cjs-es6/indexes.cjs.gz +0 -0
  28. package/lib/cjs-es6/metrics.cjs +1 -1
  29. package/lib/cjs-es6/metrics.cjs.gz +0 -0
  30. package/lib/cjs-es6/persisters.cjs +1 -1
  31. package/lib/cjs-es6/persisters.cjs.gz +0 -0
  32. package/lib/cjs-es6/queries.cjs +1 -1
  33. package/lib/cjs-es6/queries.cjs.gz +0 -0
  34. package/lib/cjs-es6/relationships.cjs +1 -1
  35. package/lib/cjs-es6/relationships.cjs.gz +0 -0
  36. package/lib/cjs-es6/store.cjs +1 -1
  37. package/lib/cjs-es6/store.cjs.gz +0 -0
  38. package/lib/cjs-es6/tinybase.cjs +1 -1
  39. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  40. package/lib/cjs-es6/tools.cjs +1 -1
  41. package/lib/cjs-es6/tools.cjs.gz +0 -0
  42. package/lib/cjs-es6/ui-react.cjs +1 -1
  43. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  44. package/lib/debug/checkpoints.js +2 -2
  45. package/lib/debug/indexes.js +2 -2
  46. package/lib/debug/metrics.js +2 -2
  47. package/lib/debug/persisters.js +2 -2
  48. package/lib/debug/queries.js +1 -1
  49. package/lib/debug/relationships.js +2 -2
  50. package/lib/debug/store.js +36 -35
  51. package/lib/debug/tinybase.js +39 -38
  52. package/lib/debug/tools.js +13 -4
  53. package/lib/debug/ui-react.js +3 -2
  54. package/lib/es6/checkpoints.js +1 -1
  55. package/lib/es6/checkpoints.js.gz +0 -0
  56. package/lib/es6/indexes.js +1 -1
  57. package/lib/es6/indexes.js.gz +0 -0
  58. package/lib/es6/metrics.js +1 -1
  59. package/lib/es6/metrics.js.gz +0 -0
  60. package/lib/es6/persisters.js +1 -1
  61. package/lib/es6/persisters.js.gz +0 -0
  62. package/lib/es6/queries.js +1 -1
  63. package/lib/es6/queries.js.gz +0 -0
  64. package/lib/es6/relationships.js +1 -1
  65. package/lib/es6/relationships.js.gz +0 -0
  66. package/lib/es6/store.js +1 -1
  67. package/lib/es6/store.js.gz +0 -0
  68. package/lib/es6/tinybase.js +1 -1
  69. package/lib/es6/tinybase.js.gz +0 -0
  70. package/lib/es6/tools.js +1 -1
  71. package/lib/es6/tools.js.gz +0 -0
  72. package/lib/es6/ui-react.js +1 -1
  73. package/lib/es6/ui-react.js.gz +0 -0
  74. package/lib/indexes.js +1 -1
  75. package/lib/indexes.js.gz +0 -0
  76. package/lib/metrics.js +1 -1
  77. package/lib/metrics.js.gz +0 -0
  78. package/lib/persisters.js +1 -1
  79. package/lib/persisters.js.gz +0 -0
  80. package/lib/queries.js +1 -1
  81. package/lib/queries.js.gz +0 -0
  82. package/lib/relationships.js +1 -1
  83. package/lib/relationships.js.gz +0 -0
  84. package/lib/store.js +1 -1
  85. package/lib/store.js.gz +0 -0
  86. package/lib/tinybase.js +1 -1
  87. package/lib/tinybase.js.gz +0 -0
  88. package/lib/tools.js +1 -1
  89. package/lib/tools.js.gz +0 -0
  90. package/lib/types/store.d.ts +84 -21
  91. package/lib/types/ui-react.d.ts +11 -0
  92. package/lib/types/with-schemas/store.d.ts +91 -21
  93. package/lib/types/with-schemas/ui-react.d.ts +12 -0
  94. package/lib/ui-react.js +1 -1
  95. package/lib/ui-react.js.gz +0 -0
  96. package/lib/umd/checkpoints.js +1 -1
  97. package/lib/umd/checkpoints.js.gz +0 -0
  98. package/lib/umd/indexes.js +1 -1
  99. package/lib/umd/indexes.js.gz +0 -0
  100. package/lib/umd/metrics.js +1 -1
  101. package/lib/umd/metrics.js.gz +0 -0
  102. package/lib/umd/persisters.js +1 -1
  103. package/lib/umd/persisters.js.gz +0 -0
  104. package/lib/umd/queries.js +1 -1
  105. package/lib/umd/queries.js.gz +0 -0
  106. package/lib/umd/relationships.js +1 -1
  107. package/lib/umd/relationships.js.gz +0 -0
  108. package/lib/umd/store.js +1 -1
  109. package/lib/umd/store.js.gz +0 -0
  110. package/lib/umd/tinybase.js +1 -1
  111. package/lib/umd/tinybase.js.gz +0 -0
  112. package/lib/umd/tools.js +1 -1
  113. package/lib/umd/tools.js.gz +0 -0
  114. package/lib/umd/ui-react.js +1 -1
  115. package/lib/umd/ui-react.js.gz +0 -0
  116. package/lib/umd-es6/checkpoints.js +1 -1
  117. package/lib/umd-es6/checkpoints.js.gz +0 -0
  118. package/lib/umd-es6/indexes.js +1 -1
  119. package/lib/umd-es6/indexes.js.gz +0 -0
  120. package/lib/umd-es6/metrics.js +1 -1
  121. package/lib/umd-es6/metrics.js.gz +0 -0
  122. package/lib/umd-es6/persisters.js +1 -1
  123. package/lib/umd-es6/persisters.js.gz +0 -0
  124. package/lib/umd-es6/queries.js +1 -1
  125. package/lib/umd-es6/queries.js.gz +0 -0
  126. package/lib/umd-es6/relationships.js +1 -1
  127. package/lib/umd-es6/relationships.js.gz +0 -0
  128. package/lib/umd-es6/store.js +1 -1
  129. package/lib/umd-es6/store.js.gz +0 -0
  130. package/lib/umd-es6/tinybase.js +1 -1
  131. package/lib/umd-es6/tinybase.js.gz +0 -0
  132. package/lib/umd-es6/tools.js +1 -1
  133. package/lib/umd-es6/tools.js.gz +0 -0
  134. package/lib/umd-es6/ui-react.js +1 -1
  135. package/lib/umd-es6/ui-react.js.gz +0 -0
  136. package/package.json +50 -26
  137. package/readme.md +14 -14
@@ -742,10 +742,10 @@ export type ValueListener = (
742
742
  * The InvalidCellListener type describes a function that is used to listen to
743
743
  * attempts to set invalid data to a Cell.
744
744
  *
745
- * A InvalidCellListener is provided when using the addInvalidCellListener
745
+ * An InvalidCellListener is provided when using the addInvalidCellListener
746
746
  * method. See that method for specific examples.
747
747
  *
748
- * When called, a InvalidCellListener is given a reference to the Store, the Id
748
+ * When called, an InvalidCellListener is given a reference to the Store, the Id
749
749
  * of the Table, the Id of the Row, and the Id of Cell that was being attempted
750
750
  * to be changed. It is also given the invalid value of the Cell, which could
751
751
  * have been of absolutely any type. Since there could have been multiple failed
@@ -772,11 +772,11 @@ export type InvalidCellListener = (
772
772
  * The InvalidValueListener type describes a function that is used to listen to
773
773
  * attempts to set invalid data to a Value.
774
774
  *
775
- * A InvalidValueListener is provided when using the addInvalidValueListener
775
+ * An InvalidValueListener is provided when using the addInvalidValueListener
776
776
  * method. See that method for specific examples.
777
777
  *
778
- * When called, a InvalidValueListener is given a reference to the Store and the
779
- * Id of Value that was being attempted to be changed. It is also given the
778
+ * When called, an InvalidValueListener is given a reference to the Store and
779
+ * the Id of Value that was being attempted to be changed. It is also given the
780
780
  * invalid value of the Value, which could have been of absolutely any type.
781
781
  * Since there could have been multiple failed attempts to set the Value within
782
782
  * a single transaction, this is an array containing each attempt,
@@ -1221,16 +1221,16 @@ export type StoreListenerStats = {
1221
1221
  export interface Store {
1222
1222
  //
1223
1223
  /**
1224
- * The getTables method returns a Tables object containing the entire data of
1225
- * the Store.
1224
+ * The getTables method returns a Tables object containing the entire tabular
1225
+ * data of the Store.
1226
1226
  *
1227
1227
  * Note that this returns a copy of, rather than a reference to the underlying
1228
1228
  * data, so changes made to the returned object are not made to the Store
1229
1229
  * itself.
1230
1230
  *
1231
- * @returns A Tables object containing the entire data of the Store.
1231
+ * @returns A Tables object containing the tabular data of the Store.
1232
1232
  * @example
1233
- * This example retrieves the data in a Store.
1233
+ * This example retrieves the tabular data in a Store.
1234
1234
  *
1235
1235
  * ```js
1236
1236
  * const store = createStore().setTables({
@@ -1371,7 +1371,7 @@ export interface Store {
1371
1371
  *
1372
1372
  * @param tableId The Id of the Table in the Store.
1373
1373
  * @param cellId The Id of the Cell whose values are used for the sorting, or
1374
- * `undefined` to by sort the Row Id itself.
1374
+ * `undefined` to sort by the Row Id itself.
1375
1375
  * @param descending Whether the sorting should be in descending order.
1376
1376
  * @param offset The number of Row Ids to skip for pagination purposes, if
1377
1377
  * any.
@@ -1569,9 +1569,9 @@ export interface Store {
1569
1569
  * data, so changes made to the returned object are not made to the Store
1570
1570
  * itself.
1571
1571
  *
1572
- * @returns An object containing the entire data of the Values.
1572
+ * @returns An object containing the set of keyed Values in the Store.
1573
1573
  * @example
1574
- * This example retrieves the keyed Values data in a Store.
1574
+ * This example retrieves the set of keyed Values in the Store.
1575
1575
  *
1576
1576
  * ```js
1577
1577
  * const store = createStore().setValues({open: true, employees: 3});
@@ -1579,7 +1579,7 @@ export interface Store {
1579
1579
  * // -> {open: true, employees: 3}
1580
1580
  * ```
1581
1581
  * @example
1582
- * This example retrieves a Values from a Store that has none, returning an
1582
+ * This example retrieves Values from a Store that has none, returning an
1583
1583
  * empty object.
1584
1584
  *
1585
1585
  * ```js
@@ -1964,7 +1964,8 @@ export interface Store {
1964
1964
  getSchemaJson(): Json;
1965
1965
 
1966
1966
  /**
1967
- * The setTables method takes an object and sets the entire data of the Store.
1967
+ * The setTables method takes an object and sets the entire tabular data of
1968
+ * the Store.
1968
1969
  *
1969
1970
  * This method will cause listeners to be called for any Table, Row, Cell, or
1970
1971
  * Id changes resulting from it.
@@ -1982,7 +1983,7 @@ export interface Store {
1982
1983
  *
1983
1984
  * @param tables The data of the Store to be set.
1984
1985
  * @example
1985
- * This example sets the data of a Store.
1986
+ * This example sets the tabular data of a Store.
1986
1987
  *
1987
1988
  * ```js
1988
1989
  * const store = createStore().setTables({
@@ -1993,8 +1994,8 @@ export interface Store {
1993
1994
  * // -> {pets: {fido: {species: 'dog'}}, species: {dog: {price: 5}}}
1994
1995
  * ```
1995
1996
  * @example
1996
- * This example attempts to set the data of an existing Store with partly
1997
- * invalid, and then completely invalid, Tables objects.
1997
+ * This example attempts to set the tabular data of an existing Store with
1998
+ * partly invalid, and then completely invalid, Tables objects.
1998
1999
  *
1999
2000
  * ```js
2000
2001
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
@@ -2131,8 +2132,17 @@ export interface Store {
2131
2132
  * Row is added to the Table. However it is likely to be a string
2132
2133
  * representation of an increasing integer.
2133
2134
  *
2135
+ * The `reuseRowIds` parameter defaults to `true`, which means that if you
2136
+ * delete a Row and then add another, the Id will be re-used - unless you
2137
+ * delete the entire Table, in which case all Row Ids will reset. Otherwise,
2138
+ * if you specify `reuseRowIds` to be `false`, then the Id will be a
2139
+ * monotonically increasing string representation of an increasing integer,
2140
+ * regardless of any you may have previously deleted.
2141
+ *
2134
2142
  * @param tableId The Id of the Table in the Store.
2135
2143
  * @param row The data of a single Row to be added.
2144
+ * @param reuseRowIds Whether Ids should be recycled from previously deleted
2145
+ * Row objects, defaulting to `true`.
2136
2146
  * @returns A reference to the Store.
2137
2147
  * @example
2138
2148
  * This example adds a single Row.
@@ -2163,7 +2173,7 @@ export interface Store {
2163
2173
  * ```
2164
2174
  * @category Setter
2165
2175
  */
2166
- addRow(tableId: Id, row: Row): Id | undefined;
2176
+ addRow(tableId: Id, row: Row, reuseRowIds?: boolean): Id | undefined;
2167
2177
 
2168
2178
  /**
2169
2179
  * The setPartialRow method takes an object and sets partial data of a single
@@ -2541,7 +2551,7 @@ export interface Store {
2541
2551
  * // -> {}
2542
2552
  * ```
2543
2553
  * @example
2544
- * This example attempts to set the the tabular and keyed value contents of a
2554
+ * This example attempts to set both the tabular and keyed value contents of a
2545
2555
  * Store from an invalid serialization.
2546
2556
  *
2547
2557
  * ```js
@@ -3721,7 +3731,7 @@ export interface Store {
3721
3731
  *
3722
3732
  * @param tableId The Id of the Table to listen to.
3723
3733
  * @param cellId The Id of the Cell whose values are used for the sorting, or
3724
- * `undefined` to by sort the Row Id itself.
3734
+ * `undefined` to sort by the Row Id itself.
3725
3735
  * @param descending Whether the sorting should be in descending order.
3726
3736
  * @param offset The number of Row Ids to skip for pagination purposes, if
3727
3737
  * any.
@@ -4872,6 +4882,51 @@ export interface Store {
4872
4882
  mutator?: boolean,
4873
4883
  ): Id;
4874
4884
 
4885
+ /**
4886
+ * The addStartTransactionListener method registers a listener function with
4887
+ * the Store that will be called at the start of a transaction.
4888
+ *
4889
+ * The provided TransactionListener will receive a reference to the Store and
4890
+ * two booleans to indicate whether Cell or Value data has been touched during
4891
+ * the transaction. Since this is called at the start, they will both be
4892
+ * `false`!
4893
+ *
4894
+ * Note that a TransactionListener added to the Store with this method can
4895
+ * mutate the Store, and its changes will be treated as part of the
4896
+ * transaction that is starting.
4897
+ *
4898
+ * @returns A unique Id for the listener that can later be used to remove it.
4899
+ * @example
4900
+ * This example registers a listener that is called at start end of the
4901
+ * transaction, just before its listeners will be called.
4902
+ *
4903
+ * ```js
4904
+ * const store = createStore()
4905
+ * .setTables({
4906
+ * pets: {fido: {species: 'dog', color: 'brown'}},
4907
+ * })
4908
+ * .setValues({open: true, employees: 3});
4909
+ * const listenerId = store.addStartTransactionListener(
4910
+ * (store, cellsTouched, valuesTouched) => {
4911
+ * console.log('Transaction started');
4912
+ * },
4913
+ * );
4914
+ *
4915
+ * store.transaction(() =>
4916
+ * store.setCell('pets', 'fido', 'color', 'brown').setValue('employees', 3),
4917
+ * );
4918
+ * // -> 'Transaction started'
4919
+ *
4920
+ * store.callListener(listenerId);
4921
+ * // -> 'Transaction started'
4922
+ *
4923
+ * store.delListener(listenerId);
4924
+ * ```
4925
+ * @category Listener
4926
+ * @since v3.2.0
4927
+ */
4928
+ addStartTransactionListener(listener: TransactionListener): Id;
4929
+
4875
4930
  /**
4876
4931
  * The addWillFinishTransactionListener method registers a listener function
4877
4932
  * with the Store that will be called just before other non-mutating listeners
@@ -4892,6 +4947,11 @@ export interface Store {
4892
4947
  * value of `cellsTouched` and `valuesTouched` in the listener will be `false`
4893
4948
  * because all changes have been reverted.
4894
4949
  *
4950
+ * Note that a TransactionListener added to the Store with this method can
4951
+ * mutate the Store itself, and its changes will be treated as part of the
4952
+ * transaction that is starting (and may fire non-mutating listeners after
4953
+ * this).
4954
+ *
4895
4955
  * @returns A unique Id for the listener that can later be used to remove it.
4896
4956
  * @example
4897
4957
  * This example registers a listener that is called at the end of the
@@ -4985,6 +5045,9 @@ export interface Store {
4985
5045
  * value of `cellsTouched` and `valuesTouched` in the listener will be `false`
4986
5046
  * because all changes have been reverted.
4987
5047
  *
5048
+ * Note that a TransactionListener added to the Store with this method
5049
+ * _cannot_ mutate the Store itself, and attempts to do so will fail silently.
5050
+ *
4988
5051
  * @returns A unique Id for the listener that can later be used to remove it.
4989
5052
  * @example
4990
5053
  * This example registers a listener that is called at the end of the
@@ -5143,7 +5206,7 @@ export interface Store {
5143
5206
  * ```
5144
5207
  * @example
5145
5208
  * This example registers listeners for the end of transactions, and for
5146
- * invalid Cells. The are explicitly called, meaninglessly. The former
5209
+ * invalid Cells. They are explicitly called, meaninglessly. The former
5147
5210
  * receives empty arguments. The latter is not called at all.
5148
5211
  *
5149
5212
  * ```js
@@ -1563,6 +1563,13 @@ export function useSetRowCallback<Parameter>(
1563
1563
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
1564
1564
  * dependency for the callback.
1565
1565
  *
1566
+ * The `reuseRowIds` parameter defaults to `true`, which means that if you
1567
+ * delete a Row and then add another, the Id will be re-used - unless you delete
1568
+ * the entire Table, in which case all Row Ids will reset. Otherwise, if you
1569
+ * specify `reuseRowIds` to be `false`, then the Id will be a monotonically
1570
+ * increasing string representation of an increasing integer, regardless of any
1571
+ * you may have previously deleted.
1572
+ *
1566
1573
  * @param tableId The Id of the Table in the Store.
1567
1574
  * @param getRow A function which returns the Row object that will be used to
1568
1575
  * update the Store, based on the parameter the callback will receive (and which
@@ -1578,6 +1585,9 @@ export function useSetRowCallback<Parameter>(
1578
1585
  * @param thenDeps An optional array of dependencies for the `then` function,
1579
1586
  * which, if any change, result in the regeneration of the callback. This
1580
1587
  * parameter defaults to an empty array.
1588
+ * @param reuseRowIds Whether Ids should be recycled from previously deleted Row
1589
+ * objects, defaulting to `true`.
1590
+ *
1581
1591
  * @returns A parameterized callback for subsequent use.
1582
1592
  * @example
1583
1593
  * This example uses the useAddRowCallback hook to create an event handler which
@@ -1622,6 +1632,7 @@ export function useAddRowCallback<Parameter>(
1622
1632
  storeOrStoreId?: StoreOrStoreId,
1623
1633
  then?: (rowId: Id | undefined, store: Store, row: Row) => void,
1624
1634
  thenDeps?: React.DependencyList,
1635
+ reuseRowIds?: boolean,
1625
1636
  ): ParameterizedCallback<Parameter>;
1626
1637
 
1627
1638
  /**
@@ -1253,10 +1253,10 @@ export type ValueListener<
1253
1253
  * ) => void;
1254
1254
  * ```
1255
1255
  *
1256
- * A InvalidCellListener is provided when using the addInvalidCellListener
1256
+ * An InvalidCellListener is provided when using the addInvalidCellListener
1257
1257
  * method. See that method for specific examples.
1258
1258
  *
1259
- * When called, a InvalidCellListener is given a reference to the Store, the Id
1259
+ * When called, an InvalidCellListener is given a reference to the Store, the Id
1260
1260
  * of the Table, the Id of the Row, and the Id of Cell that was being attempted
1261
1261
  * to be changed. It is also given the invalid value of the Cell, which could
1262
1262
  * have been of absolutely any type. Since there could have been multiple failed
@@ -1293,11 +1293,11 @@ export type InvalidCellListener<Schemas extends OptionalSchemas> = (
1293
1293
  * ) => void;
1294
1294
  * ```
1295
1295
  *
1296
- * A InvalidValueListener is provided when using the addInvalidValueListener
1296
+ * An InvalidValueListener is provided when using the addInvalidValueListener
1297
1297
  * method. See that method for specific examples.
1298
1298
  *
1299
- * When called, a InvalidValueListener is given a reference to the Store and the
1300
- * Id of Value that was being attempted to be changed. It is also given the
1299
+ * When called, an InvalidValueListener is given a reference to the Store and
1300
+ * the Id of Value that was being attempted to be changed. It is also given the
1301
1301
  * invalid value of the Value, which could have been of absolutely any type.
1302
1302
  * Since there could have been multiple failed attempts to set the Value within
1303
1303
  * a single transaction, this is an array containing each attempt,
@@ -1811,8 +1811,8 @@ export type StoreListenerStats = {
1811
1811
  */
1812
1812
  export interface Store<in out Schemas extends OptionalSchemas> {
1813
1813
  /**
1814
- * The getTables method returns a Tables object containing the entire data of
1815
- * the Store.
1814
+ * The getTables method returns a Tables object containing the entire tabular
1815
+ * data of the Store.
1816
1816
  *
1817
1817
  * This has schema-based typing. The following is a simplified representation:
1818
1818
  *
@@ -1824,9 +1824,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
1824
1824
  * data, so changes made to the returned object are not made to the Store
1825
1825
  * itself.
1826
1826
  *
1827
- * @returns A Tables object containing the entire data of the Store.
1827
+ * @returns A Tables object containing the tabular data of the Store.
1828
1828
  * @example
1829
- * This example retrieves the data in a Store.
1829
+ * This example retrieves the tabular data in a Store.
1830
1830
  *
1831
1831
  * ```js
1832
1832
  * const store = createStore().setTables({
@@ -1999,7 +1999,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
1999
1999
  *
2000
2000
  * @param tableId The Id of the Table in the Store.
2001
2001
  * @param cellId The Id of the Cell whose values are used for the sorting, or
2002
- * `undefined` to by sort the Row Id itself.
2002
+ * `undefined` to sort by the Row Id itself.
2003
2003
  * @param descending Whether the sorting should be in descending order.
2004
2004
  * @param offset The number of Row Ids to skip for pagination purposes, if
2005
2005
  * any.
@@ -2234,9 +2234,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2234
2234
  * data, so changes made to the returned object are not made to the Store
2235
2235
  * itself.
2236
2236
  *
2237
- * @returns An object containing the entire data of the Values.
2237
+ * @returns An object containing the set of keyed Values in the Store.
2238
2238
  * @example
2239
- * This example retrieves the keyed Values data in a Store.
2239
+ * This example retrieves the set of keyed Values in the Store.
2240
2240
  *
2241
2241
  * ```js
2242
2242
  * const store = createStore().setValues({open: true, employees: 3});
@@ -2244,7 +2244,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2244
2244
  * // -> {open: true, employees: 3}
2245
2245
  * ```
2246
2246
  * @example
2247
- * This example retrieves a Values from a Store that has none, returning an
2247
+ * This example retrieves Values from a Store that has none, returning an
2248
2248
  * empty object.
2249
2249
  *
2250
2250
  * ```js
@@ -2671,7 +2671,8 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2671
2671
  getSchemaJson(): Json;
2672
2672
 
2673
2673
  /**
2674
- * The setTables method takes an object and sets the entire data of the Store.
2674
+ * The setTables method takes an object and sets the entire tabular data of
2675
+ * the Store.
2675
2676
  *
2676
2677
  * This has schema-based typing. The following is a simplified representation:
2677
2678
  *
@@ -2695,7 +2696,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2695
2696
  *
2696
2697
  * @param tables The data of the Store to be set.
2697
2698
  * @example
2698
- * This example sets the data of a Store.
2699
+ * This example sets the tabular data of a Store.
2699
2700
  *
2700
2701
  * ```js
2701
2702
  * const store = createStore().setTables({
@@ -2706,8 +2707,8 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2706
2707
  * // -> {pets: {fido: {species: 'dog'}}, species: {dog: {price: 5}}}
2707
2708
  * ```
2708
2709
  * @example
2709
- * This example attempts to set the data of an existing Store with partly
2710
- * invalid, and then completely invalid, Tables objects.
2710
+ * This example attempts to set the tabular data of an existing Store with
2711
+ * partly invalid, and then completely invalid, Tables objects.
2711
2712
  *
2712
2713
  * ```js
2713
2714
  * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
@@ -2851,7 +2852,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2851
2852
  * This has schema-based typing. The following is a simplified representation:
2852
2853
  *
2853
2854
  * ```ts override
2854
- * addRow(tableId: Id, row: Row): Id | undefined;
2855
+ * addRow(tableId: Id, row: Row, reuseRowIds?: boolean): Id | undefined;
2855
2856
  * ```
2856
2857
  *
2857
2858
  * This method will cause listeners to be called for any Table, Row, Cell, or
@@ -2869,8 +2870,17 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2869
2870
  * Row is added to the Table. However it is likely to be a string
2870
2871
  * representation of an increasing integer.
2871
2872
  *
2873
+ * The `reuseRowIds` parameter defaults to `true`, which means that if you
2874
+ * delete a Row and then add another, the Id will be re-used - unless you
2875
+ * delete the entire Table, in which case all Row Ids will reset. Otherwise,
2876
+ * if you specify `reuseRowIds` to be `false`, then the Id will be a
2877
+ * monotonically increasing string representation of an increasing integer,
2878
+ * regardless of any you may have previously deleted.
2879
+ *
2872
2880
  * @param tableId The Id of the Table in the Store.
2873
2881
  * @param row The data of a single Row to be added.
2882
+ * @param reuseRowIds Whether Ids should be recycled from previously deleted
2883
+ * Row objects, defaulting to `true`.
2874
2884
  * @returns A reference to the Store.
2875
2885
  * @example
2876
2886
  * This example adds a single Row.
@@ -2904,6 +2914,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
2904
2914
  addRow<TableId extends TableIdFromSchema<Schemas[0]>>(
2905
2915
  tableId: TableId,
2906
2916
  row: Row<Schemas[0], TableId, true>,
2917
+ reuseRowIds?: boolean,
2907
2918
  ): Id | undefined;
2908
2919
 
2909
2920
  /**
@@ -3347,7 +3358,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
3347
3358
  * // -> {}
3348
3359
  * ```
3349
3360
  * @example
3350
- * This example attempts to set the the tabular and keyed value contents of a
3361
+ * This example attempts to set both the tabular and keyed value contents of a
3351
3362
  * Store from an invalid serialization.
3352
3363
  *
3353
3364
  * ```js
@@ -4723,7 +4734,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
4723
4734
  *
4724
4735
  * @param tableId The Id of the Table to listen to.
4725
4736
  * @param cellId The Id of the Cell whose values are used for the sorting, or
4726
- * `undefined` to by sort the Row Id itself.
4737
+ * `undefined` to sort by the Row Id itself.
4727
4738
  * @param descending Whether the sorting should be in descending order.
4728
4739
  * @param offset The number of Row Ids to skip for pagination purposes, if
4729
4740
  * any.
@@ -5982,6 +5993,57 @@ export interface Store<in out Schemas extends OptionalSchemas> {
5982
5993
  mutator?: boolean,
5983
5994
  ): Id;
5984
5995
 
5996
+ /**
5997
+ * The addStartTransactionListener method registers a listener function with
5998
+ * the Store that will be called at the start of a transaction.
5999
+ *
6000
+ * This has schema-based typing. The following is a simplified representation:
6001
+ *
6002
+ * ```ts override
6003
+ * addStartTransactionListener(listener: TransactionListener): Id;
6004
+ * ```
6005
+ *
6006
+ * The provided TransactionListener will receive a reference to the Store and
6007
+ * two booleans to indicate whether Cell or Value data has been touched during
6008
+ * the transaction. Since this is called at the start, they will both be
6009
+ * `false`!
6010
+ *
6011
+ * Note that a TransactionListener added to the Store with this method can
6012
+ * mutate the Store, and its changes will be treated as part of the
6013
+ * transaction that is starting.
6014
+ *
6015
+ * @returns A unique Id for the listener that can later be used to remove it.
6016
+ * @example
6017
+ * This example registers a listener that is called at start end of the
6018
+ * transaction, just before its listeners will be called.
6019
+ *
6020
+ * ```js
6021
+ * const store = createStore()
6022
+ * .setTables({
6023
+ * pets: {fido: {species: 'dog', color: 'brown'}},
6024
+ * })
6025
+ * .setValues({open: true, employees: 3});
6026
+ * const listenerId = store.addStartTransactionListener(
6027
+ * (store, cellsTouched, valuesTouched) => {
6028
+ * console.log('Transaction started');
6029
+ * },
6030
+ * );
6031
+ *
6032
+ * store.transaction(() =>
6033
+ * store.setCell('pets', 'fido', 'color', 'brown').setValue('employees', 3),
6034
+ * );
6035
+ * // -> 'Transaction started'
6036
+ *
6037
+ * store.callListener(listenerId);
6038
+ * // -> 'Transaction started'
6039
+ *
6040
+ * store.delListener(listenerId);
6041
+ * ```
6042
+ * @category Listener
6043
+ * @since v3.2.0
6044
+ */
6045
+ addStartTransactionListener(listener: TransactionListener<Schemas>): Id;
6046
+
5985
6047
  /**
5986
6048
  * The addWillFinishTransactionListener method registers a listener function
5987
6049
  * with the Store that will be called just before other non-mutating listeners
@@ -6008,6 +6070,11 @@ export interface Store<in out Schemas extends OptionalSchemas> {
6008
6070
  * value of `cellsTouched` and `valuesTouched` in the listener will be `false`
6009
6071
  * because all changes have been reverted.
6010
6072
  *
6073
+ * Note that a TransactionListener added to the Store with this method can
6074
+ * mutate the Store itself, and its changes will be treated as part of the
6075
+ * transaction that is starting (and may fire non-mutating listeners after
6076
+ * this).
6077
+ *
6011
6078
  * @returns A unique Id for the listener that can later be used to remove it.
6012
6079
  * @example
6013
6080
  * This example registers a listener that is called at the end of the
@@ -6107,6 +6174,9 @@ export interface Store<in out Schemas extends OptionalSchemas> {
6107
6174
  * value of `cellsTouched` and `valuesTouched` in the listener will be `false`
6108
6175
  * because all changes have been reverted.
6109
6176
  *
6177
+ * Note that a TransactionListener added to the Store with this method
6178
+ * _cannot_ mutate the Store itself, and attempts to do so will fail silently.
6179
+ *
6110
6180
  * @returns A unique Id for the listener that can later be used to remove it.
6111
6181
  * @example
6112
6182
  * This example registers a listener that is called at the end of the
@@ -6271,7 +6341,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
6271
6341
  * ```
6272
6342
  * @example
6273
6343
  * This example registers listeners for the end of transactions, and for
6274
- * invalid Cells. The are explicitly called, meaninglessly. The former
6344
+ * invalid Cells. They are explicitly called, meaninglessly. The former
6275
6345
  * receives empty arguments. The latter is not called at all.
6276
6346
  *
6277
6347
  * ```js
@@ -1809,6 +1809,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
1809
1809
  * storeOrStoreId?: StoreOrStoreId,
1810
1810
  * then?: (rowId: Id | undefined, store: Store, row: Row) => void,
1811
1811
  * thenDeps?: React.DependencyList,
1812
+ * reuseRowIds?: boolean,
1812
1813
  * ): ParameterizedCallback<Parameter>;
1813
1814
  * ```
1814
1815
  *
@@ -1833,6 +1834,13 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
1833
1834
  * hook's `storeOrStoreId` parameter) is always automatically used as a hook
1834
1835
  * dependency for the callback.
1835
1836
  *
1837
+ * The `reuseRowIds` parameter defaults to `true`, which means that if you
1838
+ * delete a Row and then add another, the Id will be re-used - unless you delete
1839
+ * the entire Table, in which case all Row Ids will reset. Otherwise, if you
1840
+ * specify `reuseRowIds` to be `false`, then the Id will be a monotonically
1841
+ * increasing string representation of an increasing integer, regardless of any
1842
+ * you may have previously deleted.
1843
+ *
1836
1844
  * @param tableId The Id of the Table in the Store.
1837
1845
  * @param getRow A function which returns the Row object that will be used to
1838
1846
  * update the Store, based on the parameter the callback will receive (and which
@@ -1848,6 +1856,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
1848
1856
  * @param thenDeps An optional array of dependencies for the `then` function,
1849
1857
  * which, if any change, result in the regeneration of the callback. This
1850
1858
  * parameter defaults to an empty array.
1859
+ * @param reuseRowIds Whether Ids should be recycled from previously deleted Row
1860
+ * objects, defaulting to `true`.
1861
+ *
1851
1862
  * @returns A parameterized callback for subsequent use.
1852
1863
  * @example
1853
1864
  * This example uses the useAddRowCallback hook to create an event handler which
@@ -1896,6 +1907,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
1896
1907
  storeOrStoreId?: StoreOrStoreId<Schemas>,
1897
1908
  then?: (rowId: Id | undefined, store: Store<Schemas>, row: AddRow) => void,
1898
1909
  thenDeps?: React.DependencyList,
1910
+ reuseRowIds?: boolean,
1899
1911
  ) => ParameterizedCallback<Parameter>;
1900
1912
 
1901
1913
  /**
package/lib/ui-react.js CHANGED
@@ -1 +1 @@
1
- import e,{useContext as o}from"react";const t=e=>typeof e,s=t(""),d=(e,o)=>e.map(o),r=e=>null==e,n=(e,o,t)=>r(e)?t?.():o(e),l=e=>t(e)==s,I=()=>{},{createContext:u,useContext:a}=e,i=u([]),c=(e,o)=>{const t=a(i);return r(e)?t[o]:l(e)?((e,o)=>n(e,(e=>e[o])))(t[o+1],e):e},p=(e,o)=>{const t=c(e,o);return r(e)||l(e)?t:e},b=e=>c(e,0),g=e=>c(e,2),w=e=>c(e,4),R=e=>c(e,6),C=e=>c(e,8),m=e=>c(e,10),k=e=>p(e,0),y=e=>p(e,2),h=e=>p(e,4),v=e=>p(e,6),T=e=>p(e,8),q=e=>p(e,10),{useCallback:P,useEffect:x,useMemo:S,useRef:V,useState:f}=e,B=(e,o,t=[])=>{const s=S((()=>o(e)),[e,...t]);return x((()=>()=>s.destroy()),[s]),s},L=(e,o,t,s=[],d)=>{const[,n]=f(),l=P((()=>o?.["get"+e]?.(...s)??t),[o,...s]),[I]=f(l),u=V(I);return S((()=>u.current=l()),[l]),M(e,o,((...e)=>{u.current=r(d)?l():e[d],n([])}),[],s),u.current},M=(e,o,t,s=[],d=[],...r)=>x((()=>{const s=o?.["add"+e+"Listener"]?.(...d,t,...r);return()=>o?.delListener(s)}),[o,...d,...s,...r]),A=(e,o,t,s=[],d=I,r=[],...l)=>{const u=k(e);return P((e=>n(u,(s=>n(t(e,s),(e=>d(s["set"+o](...l,e),e)))))),[u,o,...s,...r,...l])},E=(e,o,t=I,s=[],...d)=>{const r=k(e);return P((()=>t(r?.["del"+o](...d))),[r,o,...s,...d])},F=(e,o,t)=>{const s=q(e);return P((()=>s?.[o](t)),[s,o,t])},j=(e,o=[])=>S(e,o),z=e=>L("Tables",k(e),{}),D=e=>L("TableIds",k(e),[],[]),G=(e,o)=>L("Table",k(o),{},[e]),H=(e,o)=>L("RowIds",k(o),[],[e]),J=(e,o,t,s=0,d,r)=>L("SortedRowIds",k(r),[],[e,o,t,s,d],6),K=(e,o,t)=>L("Row",k(t),{},[e,o]),N=(e,o,t)=>L("CellIds",k(t),[],[e,o]),O=(e,o,t,s)=>L("Cell",k(s),void 0,[e,o,t],4),Q=e=>L("Values",k(e),{}),U=e=>L("ValueIds",k(e),[],[]),W=(e,o)=>L("Value",k(o),void 0,[e]),X=(e,o,t,s,d)=>A(t,"Tables",e,o,s,d),Y=(e,o,t,s,d,r)=>A(s,"Table",o,t,d,r,e),Z=(e,o,t,s,d,r,n)=>A(d,"Row",t,s,r,n,e,o),$=(e,o,t=[],s,d=I,r=[])=>{const l=k(s);return P((t=>n(l,(s=>n(o(t,s),(o=>d(s.addRow(e,o),s,o)))))),[l,e,...t,...r])},_=(e,o,t,s,d,r,n)=>A(d,"PartialRow",t,s,r,n,e,o),ee=(e,o,t,s,d,r,n,l)=>A(r,"Cell",s,d,n,l,e,o,t),oe=(e,o,t,s,d)=>A(t,"Values",e,o,s,d),te=(e,o,t,s,d)=>A(t,"PartialValues",e,o,s,d),se=(e,o,t,s,d,r)=>A(s,"Value",o,t,d,r,e),de=(e,o,t)=>E(e,"Tables",o,t),re=(e,o,t,s)=>E(o,"Table",t,s,e),ne=(e,o,t,s,d)=>E(t,"Row",s,d,e,o),le=(e,o,t,s,d,r,n)=>E(d,"Cell",r,n,e,o,t,s),Ie=(e,o,t)=>E(e,"Values",o,t),ue=(e,o,t,s)=>E(o,"Value",t,s,e),ae=(e,o,t,s)=>M("Tables",k(s),e,o,[],t),ie=(e,o,t,s)=>M("TableIds",k(s),e,o,[],t),ce=(e,o,t,s,d)=>M("Table",k(d),o,t,[e],s),pe=(e,o,t,s,d)=>M("RowIds",k(d),o,t,[e],s),be=(e,o,t,s,d,r,n,l,I)=>M("SortedRowIds",k(I),r,n,[e,o,t,s,d],l),ge=(e,o,t,s,d,r)=>M("Row",k(r),t,s,[e,o],d),we=(e,o,t,s,d,r)=>M("CellIds",k(r),t,s,[e,o],d),Re=(e,o,t,s,d,r,n)=>M("Cell",k(n),s,d,[e,o,t],r),Ce=(e,o,t,s)=>M("Values",k(s),e,o,[],t),me=(e,o,t,s)=>M("ValueIds",k(s),e,o,[],t),ke=(e,o,t,s,d)=>M("Value",k(d),o,t,[e],s),ye=(e,o,t)=>B(e,o,t),he=(e,o)=>L("Metric",y(o),void 0,[e]),ve=(e,o,t,s)=>M("Metric",y(s),o,t,[e]),Te=(e,o,t)=>B(e,o,t),qe=(e,o)=>L("SliceIds",h(o),[],[e]),Pe=(e,o,t)=>L("SliceRowIds",h(t),[],[e,o]),xe=(e,o,t,s)=>M("SliceIds",h(s),o,t,[e]),Se=(e,o,t,s,d)=>M("SliceRowIds",h(d),t,s,[e,o]),Ve=(e,o,t)=>B(e,o,t),fe=(e,o,t)=>L("RemoteRowId",v(t),void 0,[e,o]),Be=(e,o,t)=>L("LocalRowIds",v(t),[],[e,o]),Le=(e,o,t)=>L("LinkedRowIds",v(t),[],[e,o]),Me=(e,o,t,s,d)=>M("RemoteRowId",v(d),t,s,[e,o]),Ae=(e,o,t,s,d)=>M("LocalRowIds",v(d),t,s,[e,o]),Ee=(e,o,t,s,d)=>M("LinkedRowIds",v(d),t,s,[e,o]),Fe=(e,o,t)=>B(e,o,t),je=(e,o)=>L("ResultTable",T(o),{},[e]),ze=(e,o)=>L("ResultRowIds",T(o),[],[e]),De=(e,o,t,s=0,d,r)=>L("ResultSortedRowIds",T(r),[],[e,o,t,s,d],6),Ge=(e,o,t)=>L("ResultRow",T(t),{},[e,o]),He=(e,o,t)=>L("ResultCellIds",T(t),[],[e,o]),Je=(e,o,t,s)=>L("ResultCell",T(s),void 0,[e,o,t]),Ke=(e,o,t,s)=>M("ResultTable",T(s),o,t,[e]),Ne=(e,o,t,s)=>M("ResultRowIds",T(s),o,t,[e]),Oe=(e,o,t,s,d,r,n,l)=>M("ResultSortedRowIds",T(l),r,n,[e,o,t,s,d]),Qe=(e,o,t,s,d)=>M("ResultRow",T(d),t,s,[e,o]),Ue=(e,o,t,s,d)=>M("ResultCellIds",T(d),t,s,[e,o]),We=(e,o,t,s,d,r)=>M("ResultCell",T(r),s,d,[e,o,t]),Xe=(e,o,t)=>B(e,o,t),Ye=e=>L("CheckpointIds",q(e),[[],void 0,[]]),Ze=(e,o)=>L("Checkpoint",q(o),void 0,[e]),$e=(e=I,o=[],t,s=I,d=[])=>{const r=q(t);return P((o=>n(r,(t=>{const d=e(o);s(t.addCheckpoint(d),t,d)}))),[r,...o,...d])},_e=e=>F(e,"goBackward"),eo=e=>F(e,"goForward"),oo=(e,o=[],t,s=I,d=[])=>{const r=q(t);return P((o=>n(r,(t=>n(e(o),(e=>s(t.goTo(e),e)))))),[r,...o,...d])},to=e=>{const o=q(e),[t,s]=Ye(o);return[(d=t,!(0==(e=>e.length)(d))),_e(o),s,n(s,(e=>o?.getCheckpoint(e)))??""];var d},so=e=>{const o=q(e),[,,[t]]=Ye(o);return[!r(t),eo(o),t,n(t,(e=>o?.getCheckpoint(e)))??""]},ro=(e,o,t)=>M("CheckpointIds",q(t),e,o),no=(e,o,t,s)=>M("Checkpoint",q(s),o,t,[e]),lo=(e,o,t=[],s,d=[])=>{const[,r]=f(),n=S((()=>o(e)),[e,...t]);return x((()=>((async()=>{await(s?.(n)),r(1)})(),()=>{n.destroy()})),[n,...d]),n},{createElement:Io,useMemo:uo}=e,ao=({tableId:e,store:o,rowComponent:t=mo,getRowComponentProps:s,separator:r,debugIds:n},l)=>Ro(d(l,(d=>Io(t,{...go(s,d),key:d,tableId:e,rowId:d,store:o,debugIds:n}))),r,n,e),io=({queryId:e,queries:o,resultRowComponent:t=Lo,getResultRowComponentProps:s,separator:r,debugIds:n},l)=>Ro(d(l,(d=>Io(t,{...go(s,d),key:d,queryId:e,rowId:d,queries:o,debugIds:n}))),r,n,e),co=e=>{const o=v(e);return[o,o?.getStore()]},po=({relationshipId:e,relationships:o,rowComponent:t=mo,getRowComponentProps:s,separator:r,debugIds:n},l,I)=>{const[u,a]=co(o),i=u?.getLocalTableId(e),c=l(e,I,u);return Ro(d(c,(e=>Io(t,{...go(s,e),key:e,tableId:i,rowId:e,store:a,debugIds:n}))),r,n,I)},bo=e=>({checkpoints:o,checkpointComponent:t=Eo,getCheckpointComponentProps:s,separator:r,debugIds:n})=>{const l=q(o);return Ro(d(e(Ye(l)),(e=>Io(t,{...go(s,e),key:e,checkpoints:l,checkpointId:e,debugIds:n}))),r)},go=(e,o)=>r(e)?{}:e(o),wo=({store:e,storesById:t,metrics:s,metricsById:d,indexes:r,indexesById:n,relationships:l,relationshipsById:I,queries:u,queriesById:a,checkpoints:c,checkpointsById:p,children:b})=>{const g=o(i);return Io(i.Provider,{value:uo((()=>[e??g[0],{...g[1],...t},s??g[2],{...g[3],...d},r??g[4],{...g[5],...n},l??g[6],{...g[7],...I},u??g[8],{...g[9],...a},c??g[10],{...g[11],...p}]),[e,t,s,d,r,n,l,I,u,a,c,p,g])},b)},Ro=(e,o,t,s)=>{const n=r(o)||!Array.isArray(e)?e:d(e,((e,t)=>t>0?[o,e]:e));return t?[s,":{",n,"}"]:n},Co=({tableId:e,rowId:o,cellId:t,store:s,debugIds:d})=>Ro(""+(O(e,o,t,s)??""),void 0,d,t),mo=({tableId:e,rowId:o,store:t,cellComponent:s=Co,getCellComponentProps:r,separator:n,debugIds:l})=>Ro(d(N(e,o,t),(d=>Io(s,{...go(r,d),key:d,tableId:e,rowId:o,cellId:d,store:t,debugIds:l}))),n,l,o),ko=e=>ao(e,H(e.tableId,e.store)),yo=({cellId:e,descending:o,offset:t,limit:s,...d})=>ao(d,J(d.tableId,e,o,t,s,d.store)),ho=({store:e,tableComponent:o=ko,getTableComponentProps:t,separator:s,debugIds:r})=>Ro(d(D(e),(s=>Io(o,{...go(t,s),key:s,tableId:s,store:e,debugIds:r}))),s),vo=({valueId:e,store:o,debugIds:t})=>Ro(""+(W(e,o)??""),void 0,t,e),To=({store:e,valueComponent:o=vo,getValueComponentProps:t,separator:s,debugIds:r})=>Ro(d(U(e),(s=>Io(o,{...go(t,s),key:s,valueId:s,store:e,debugIds:r}))),s),qo=({metricId:e,metrics:o,debugIds:t})=>Ro(he(e,o)??"",void 0,t,e),Po=({indexId:e,sliceId:o,indexes:t,rowComponent:s=mo,getRowComponentProps:r,separator:n,debugIds:l})=>{const I=h(t),u=I?.getStore(),a=I?.getTableId(e),i=Pe(e,o,I);return Ro(d(i,(e=>Io(s,{...go(r,e),key:e,tableId:a,rowId:e,store:u,debugIds:l}))),n,l,o)},xo=({indexId:e,indexes:o,sliceComponent:t=Po,getSliceComponentProps:s,separator:r,debugIds:n})=>Ro(d(qe(e,o),(d=>Io(t,{...go(s,d),key:d,indexId:e,sliceId:d,indexes:o,debugIds:n}))),r,n,e),So=({relationshipId:e,localRowId:o,relationships:t,rowComponent:s=mo,getRowComponentProps:d,debugIds:n})=>{const[l,I]=co(t),u=l?.getRemoteTableId(e),a=fe(e,o,l);return Ro(r(u)||r(a)?null:Io(s,{...go(d,a),key:a,tableId:u,rowId:a,store:I,debugIds:n}),void 0,n,o)},Vo=e=>po(e,Be,e.remoteRowId),fo=e=>po(e,Le,e.firstRowId),Bo=({queryId:e,rowId:o,cellId:t,queries:s,debugIds:d})=>Ro(""+(Je(e,o,t,s)??""),void 0,d,t),Lo=({queryId:e,rowId:o,queries:t,resultCellComponent:s=Bo,getResultCellComponentProps:r,separator:n,debugIds:l})=>Ro(d(He(e,o,t),(d=>Io(s,{...go(r,d),key:d,queryId:e,rowId:o,cellId:d,queries:t,debugIds:l}))),n,l,o),Mo=e=>io(e,ze(e.queryId,e.queries)),Ao=({cellId:e,descending:o,offset:t,limit:s,...d})=>io(d,De(d.queryId,e,o,t,s,d.queries)),Eo=({checkpoints:e,checkpointId:o,debugIds:t})=>Ro(Ze(o,e)??"",void 0,t,o),Fo=bo((e=>e[0])),jo=bo((e=>r(e[1])?[]:[e[1]])),zo=bo((e=>e[2]));export{Fo as BackwardCheckpointsView,Co as CellView,Eo as CheckpointView,jo as CurrentCheckpointView,zo as ForwardCheckpointsView,xo as IndexView,fo as LinkedRowsView,Vo as LocalRowsView,qo as MetricView,wo as Provider,So as RemoteRowView,Bo as ResultCellView,Lo as ResultRowView,Ao as ResultSortedTableView,Mo as ResultTableView,mo as RowView,Po as SliceView,yo as SortedTableView,ko as TableView,ho as TablesView,vo as ValueView,To as ValuesView,ao as tableView,$ as useAddRowCallback,O as useCell,N as useCellIds,we as useCellIdsListener,Re as useCellListener,Ze as useCheckpoint,Ye as useCheckpointIds,ro as useCheckpointIdsListener,no as useCheckpointListener,m as useCheckpoints,Xe as useCreateCheckpoints,Te as useCreateIndexes,ye as useCreateMetrics,lo as useCreatePersister,Fe as useCreateQueries,Ve as useCreateRelationships,j as useCreateStore,le as useDelCellCallback,ne as useDelRowCallback,re as useDelTableCallback,de as useDelTablesCallback,ue as useDelValueCallback,Ie as useDelValuesCallback,_e as useGoBackwardCallback,eo as useGoForwardCallback,oo as useGoToCallback,w as useIndexes,Le as useLinkedRowIds,Ee as useLinkedRowIdsListener,Be as useLocalRowIds,Ae as useLocalRowIdsListener,he as useMetric,ve as useMetricListener,g as useMetrics,C as useQueries,so as useRedoInformation,R as useRelationships,fe as useRemoteRowId,Me as useRemoteRowIdListener,Je as useResultCell,He as useResultCellIds,Ue as useResultCellIdsListener,We as useResultCellListener,Ge as useResultRow,ze as useResultRowIds,Ne as useResultRowIdsListener,Qe as useResultRowListener,De as useResultSortedRowIds,Oe as useResultSortedRowIdsListener,je as useResultTable,Ke as useResultTableListener,K as useRow,H as useRowIds,pe as useRowIdsListener,ge as useRowListener,ee as useSetCellCallback,$e as useSetCheckpointCallback,_ as useSetPartialRowCallback,te as useSetPartialValuesCallback,Z as useSetRowCallback,Y as useSetTableCallback,X as useSetTablesCallback,se as useSetValueCallback,oe as useSetValuesCallback,qe as useSliceIds,xe as useSliceIdsListener,Pe as useSliceRowIds,Se as useSliceRowIdsListener,J as useSortedRowIds,be as useSortedRowIdsListener,b as useStore,G as useTable,D as useTableIds,ie as useTableIdsListener,ce as useTableListener,z as useTables,ae as useTablesListener,to as useUndoInformation,W as useValue,U as useValueIds,me as useValueIdsListener,ke as useValueListener,Q as useValues,Ce as useValuesListener};
1
+ import e,{useContext as o}from"react";const t=e=>typeof e,s="",d=t(s),r="Ids",n="Table",l=n+"s",I=n+r,u="Row",i=u+r,c="Sorted"+u+r,a="Cell",p=a+r,g="Value",b=g+"s",w=g+r,R=(e,o)=>e.map(o),C=e=>null==e,m=(e,o,t)=>C(e)?t?.():o(e),k=e=>t(e)==d,y=()=>{},{createContext:h,useContext:v}=e,q=h([]),P=(e,o)=>{const t=v(q);return C(e)?t[o]:k(e)?((e,o)=>m(e,(e=>e[o])))(t[o+1],e):e},x=(e,o)=>{const t=P(e,o);return C(e)||k(e)?t:e},S=e=>P(e,0),f=e=>P(e,2),T=e=>P(e,4),B=e=>P(e,6),L=e=>P(e,8),M=e=>P(e,10),V=e=>x(e,0),A=e=>x(e,2),E=e=>x(e,4),F=e=>x(e,6),j=e=>x(e,8),z=e=>x(e,10),{useCallback:D,useEffect:G,useMemo:H,useRef:J,useState:K}=e,N=(e,o,t=[])=>{const s=H((()=>o(e)),[e,...t]);return G((()=>()=>s.destroy()),[s]),s},O=(e,o,t,s=[],d)=>{const[,r]=K(),n=D((()=>o?.["get"+e]?.(...s)??t),[o,...s]),[l]=K(n),I=J(l);return H((()=>I.current=n()),[n]),Q(e,o,((...e)=>{I.current=C(d)?n():e[d],r([])}),[],s),I.current},Q=(e,o,t,s=[],d=[],...r)=>G((()=>{const s=o?.["add"+e+"Listener"]?.(...d,t,...r);return()=>o?.delListener(s)}),[o,...d,...s,...r]),U=(e,o,t,s=[],d=y,r=[],...n)=>{const l=V(e);return D((e=>m(l,(s=>m(t(e,s),(e=>d(s["set"+o](...n,e),e)))))),[l,o,...s,...r,...n])},W=(e,o,t=y,s=[],...d)=>{const r=V(e);return D((()=>t(r?.["del"+o](...d))),[r,o,...s,...d])},X=(e,o,t)=>{const s=z(e);return D((()=>s?.[o](t)),[s,o,t])},Y=(e,o=[])=>H(e,o),Z=e=>O(l,V(e),{}),$=e=>O(I,V(e),[],[]),_=(e,o)=>O(n,V(o),{},[e]),ee=(e,o)=>O(i,V(o),[],[e]),oe=(e,o,t,s=0,d,r)=>O(c,V(r),[],[e,o,t,s,d],6),te=(e,o,t)=>O(u,V(t),{},[e,o]),se=(e,o,t)=>O(p,V(t),[],[e,o]),de=(e,o,t,s)=>O(a,V(s),void 0,[e,o,t],4),re=e=>O(b,V(e),{}),ne=e=>O(w,V(e),[],[]),le=(e,o)=>O(g,V(o),void 0,[e]),Ie=(e,o,t,s,d)=>U(t,l,e,o,s,d),ue=(e,o,t,s,d,r)=>U(s,n,o,t,d,r,e),ie=(e,o,t,s,d,r,n)=>U(d,u,t,s,r,n,e,o),ce=(e,o,t=[],s,d=y,r=[],n=!0)=>{const l=V(s);return D((t=>m(l,(s=>m(o(t,s),(o=>d(s.addRow(e,o,n),s,o)))))),[l,e,...t,...r,n])},ae=(e,o,t,s,d,r,n)=>U(d,"PartialRow",t,s,r,n,e,o),pe=(e,o,t,s,d,r,n,l)=>U(r,a,s,d,n,l,e,o,t),ge=(e,o,t,s,d)=>U(t,b,e,o,s,d),be=(e,o,t,s,d)=>U(t,"PartialValues",e,o,s,d),we=(e,o,t,s,d,r)=>U(s,g,o,t,d,r,e),Re=(e,o,t)=>W(e,l,o,t),Ce=(e,o,t,s)=>W(o,n,t,s,e),me=(e,o,t,s,d)=>W(t,u,s,d,e,o),ke=(e,o,t,s,d,r,n)=>W(d,a,r,n,e,o,t,s),ye=(e,o,t)=>W(e,b,o,t),he=(e,o,t,s)=>W(o,g,t,s,e),ve=(e,o,t,s)=>Q(l,V(s),e,o,[],t),qe=(e,o,t,s)=>Q(I,V(s),e,o,[],t),Pe=(e,o,t,s,d)=>Q(n,V(d),o,t,[e],s),xe=(e,o,t,s,d)=>Q(i,V(d),o,t,[e],s),Se=(e,o,t,s,d,r,n,l,I)=>Q(c,V(I),r,n,[e,o,t,s,d],l),fe=(e,o,t,s,d,r)=>Q(u,V(r),t,s,[e,o],d),Te=(e,o,t,s,d,r)=>Q(p,V(r),t,s,[e,o],d),Be=(e,o,t,s,d,r,n)=>Q(a,V(n),s,d,[e,o,t],r),Le=(e,o,t,s)=>Q(b,V(s),e,o,[],t),Me=(e,o,t,s)=>Q(w,V(s),e,o,[],t),Ve=(e,o,t,s,d)=>Q(g,V(d),o,t,[e],s),Ae=(e,o,t)=>N(e,o,t),Ee=(e,o)=>O("Metric",A(o),void 0,[e]),Fe=(e,o,t,s)=>Q("Metric",A(s),o,t,[e]),je=(e,o,t)=>N(e,o,t),ze=(e,o)=>O("SliceIds",E(o),[],[e]),De=(e,o,t)=>O("SliceRowIds",E(t),[],[e,o]),Ge=(e,o,t,s)=>Q("SliceIds",E(s),o,t,[e]),He=(e,o,t,s,d)=>Q("SliceRowIds",E(d),t,s,[e,o]),Je=(e,o,t)=>N(e,o,t),Ke=(e,o,t)=>O("RemoteRowId",F(t),void 0,[e,o]),Ne=(e,o,t)=>O("LocalRowIds",F(t),[],[e,o]),Oe=(e,o,t)=>O("LinkedRowIds",F(t),[],[e,o]),Qe=(e,o,t,s,d)=>Q("RemoteRowId",F(d),t,s,[e,o]),Ue=(e,o,t,s,d)=>Q("LocalRowIds",F(d),t,s,[e,o]),We=(e,o,t,s,d)=>Q("LinkedRowIds",F(d),t,s,[e,o]),Xe=(e,o,t)=>N(e,o,t),Ye=(e,o)=>O("ResultTable",j(o),{},[e]),Ze=(e,o)=>O("ResultRowIds",j(o),[],[e]),$e=(e,o,t,s=0,d,r)=>O("ResultSortedRowIds",j(r),[],[e,o,t,s,d],6),_e=(e,o,t)=>O("ResultRow",j(t),{},[e,o]),eo=(e,o,t)=>O("ResultCellIds",j(t),[],[e,o]),oo=(e,o,t,s)=>O("ResultCell",j(s),void 0,[e,o,t]),to=(e,o,t,s)=>Q("ResultTable",j(s),o,t,[e]),so=(e,o,t,s)=>Q("ResultRowIds",j(s),o,t,[e]),ro=(e,o,t,s,d,r,n,l)=>Q("ResultSortedRowIds",j(l),r,n,[e,o,t,s,d]),no=(e,o,t,s,d)=>Q("ResultRow",j(d),t,s,[e,o]),lo=(e,o,t,s,d)=>Q("ResultCellIds",j(d),t,s,[e,o]),Io=(e,o,t,s,d,r)=>Q("ResultCell",j(r),s,d,[e,o,t]),uo=(e,o,t)=>N(e,o,t),io=e=>O("CheckpointIds",z(e),[[],void 0,[]]),co=(e,o)=>O("Checkpoint",z(o),void 0,[e]),ao=(e=y,o=[],t,s=y,d=[])=>{const r=z(t);return D((o=>m(r,(t=>{const d=e(o);s(t.addCheckpoint(d),t,d)}))),[r,...o,...d])},po=e=>X(e,"goBackward"),go=e=>X(e,"goForward"),bo=(e,o=[],t,s=y,d=[])=>{const r=z(t);return D((o=>m(r,(t=>m(e(o),(e=>s(t.goTo(e),e)))))),[r,...o,...d])},wo=e=>{const o=z(e),[t,d]=io(o);return[(r=t,!(0==(e=>e.length)(r))),po(o),d,m(d,(e=>o?.getCheckpoint(e)))??s];var r},Ro=e=>{const o=z(e),[,,[t]]=io(o);return[!C(t),go(o),t,m(t,(e=>o?.getCheckpoint(e)))??s]},Co=(e,o,t)=>Q("CheckpointIds",z(t),e,o),mo=(e,o,t,s)=>Q("Checkpoint",z(s),o,t,[e]),ko=(e,o,t=[],s,d=[])=>{const[,r]=K(),n=H((()=>o(e)),[e,...t]);return G((()=>((async()=>{await(s?.(n)),r(1)})(),()=>{n.destroy()})),[n,...d]),n},{createElement:yo,useMemo:ho}=e,vo=({tableId:e,store:o,rowComponent:t=Mo,getRowComponentProps:s,separator:d,debugIds:r},n)=>Bo(R(n,(d=>yo(t,{...fo(s,d),key:d,tableId:e,rowId:d,store:o,debugIds:r}))),d,r,e),qo=({queryId:e,queries:o,resultRowComponent:t=Oo,getResultRowComponentProps:s,separator:d,debugIds:r},n)=>Bo(R(n,(d=>yo(t,{...fo(s,d),key:d,queryId:e,rowId:d,queries:o,debugIds:r}))),d,r,e),Po=e=>{const o=F(e);return[o,o?.getStore()]},xo=({relationshipId:e,relationships:o,rowComponent:t=Mo,getRowComponentProps:s,separator:d,debugIds:r},n,l)=>{const[I,u]=Po(o),i=I?.getLocalTableId(e),c=n(e,l,I);return Bo(R(c,(e=>yo(t,{...fo(s,e),key:e,tableId:i,rowId:e,store:u,debugIds:r}))),d,r,l)},So=e=>({checkpoints:o,checkpointComponent:t=Wo,getCheckpointComponentProps:s,separator:d,debugIds:r})=>{const n=z(o);return Bo(R(e(io(n)),(e=>yo(t,{...fo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:r}))),d)},fo=(e,o)=>C(e)?{}:e(o),To=({store:e,storesById:t,metrics:s,metricsById:d,indexes:r,indexesById:n,relationships:l,relationshipsById:I,queries:u,queriesById:i,checkpoints:c,checkpointsById:a,children:p})=>{const g=o(q);return yo(q.Provider,{value:ho((()=>[e??g[0],{...g[1],...t},s??g[2],{...g[3],...d},r??g[4],{...g[5],...n},l??g[6],{...g[7],...I},u??g[8],{...g[9],...i},c??g[10],{...g[11],...a}]),[e,t,s,d,r,n,l,I,u,i,c,a,g])},p)},Bo=(e,o,t,s)=>{const d=C(o)||!Array.isArray(e)?e:R(e,((e,t)=>t>0?[o,e]:e));return t?[s,":{",d,"}"]:d},Lo=({tableId:e,rowId:o,cellId:t,store:d,debugIds:r})=>Bo(s+(de(e,o,t,d)??s),void 0,r,t),Mo=({tableId:e,rowId:o,store:t,cellComponent:s=Lo,getCellComponentProps:d,separator:r,debugIds:n})=>Bo(R(se(e,o,t),(r=>yo(s,{...fo(d,r),key:r,tableId:e,rowId:o,cellId:r,store:t,debugIds:n}))),r,n,o),Vo=e=>vo(e,ee(e.tableId,e.store)),Ao=({cellId:e,descending:o,offset:t,limit:s,...d})=>vo(d,oe(d.tableId,e,o,t,s,d.store)),Eo=({store:e,tableComponent:o=Vo,getTableComponentProps:t,separator:s,debugIds:d})=>Bo(R($(e),(s=>yo(o,{...fo(t,s),key:s,tableId:s,store:e,debugIds:d}))),s),Fo=({valueId:e,store:o,debugIds:t})=>Bo(s+(le(e,o)??s),void 0,t,e),jo=({store:e,valueComponent:o=Fo,getValueComponentProps:t,separator:s,debugIds:d})=>Bo(R(ne(e),(s=>yo(o,{...fo(t,s),key:s,valueId:s,store:e,debugIds:d}))),s),zo=({metricId:e,metrics:o,debugIds:t})=>Bo(Ee(e,o)??s,void 0,t,e),Do=({indexId:e,sliceId:o,indexes:t,rowComponent:s=Mo,getRowComponentProps:d,separator:r,debugIds:n})=>{const l=E(t),I=l?.getStore(),u=l?.getTableId(e),i=De(e,o,l);return Bo(R(i,(e=>yo(s,{...fo(d,e),key:e,tableId:u,rowId:e,store:I,debugIds:n}))),r,n,o)},Go=({indexId:e,indexes:o,sliceComponent:t=Do,getSliceComponentProps:s,separator:d,debugIds:r})=>Bo(R(ze(e,o),(d=>yo(t,{...fo(s,d),key:d,indexId:e,sliceId:d,indexes:o,debugIds:r}))),d,r,e),Ho=({relationshipId:e,localRowId:o,relationships:t,rowComponent:s=Mo,getRowComponentProps:d,debugIds:r})=>{const[n,l]=Po(t),I=n?.getRemoteTableId(e),u=Ke(e,o,n);return Bo(C(I)||C(u)?null:yo(s,{...fo(d,u),key:u,tableId:I,rowId:u,store:l,debugIds:r}),void 0,r,o)},Jo=e=>xo(e,Ne,e.remoteRowId),Ko=e=>xo(e,Oe,e.firstRowId),No=({queryId:e,rowId:o,cellId:t,queries:d,debugIds:r})=>Bo(s+(oo(e,o,t,d)??s),void 0,r,t),Oo=({queryId:e,rowId:o,queries:t,resultCellComponent:s=No,getResultCellComponentProps:d,separator:r,debugIds:n})=>Bo(R(eo(e,o,t),(r=>yo(s,{...fo(d,r),key:r,queryId:e,rowId:o,cellId:r,queries:t,debugIds:n}))),r,n,o),Qo=e=>qo(e,Ze(e.queryId,e.queries)),Uo=({cellId:e,descending:o,offset:t,limit:s,...d})=>qo(d,$e(d.queryId,e,o,t,s,d.queries)),Wo=({checkpoints:e,checkpointId:o,debugIds:t})=>Bo(co(o,e)??s,void 0,t,o),Xo=So((e=>e[0])),Yo=So((e=>C(e[1])?[]:[e[1]])),Zo=So((e=>e[2]));export{Xo as BackwardCheckpointsView,Lo as CellView,Wo as CheckpointView,Yo as CurrentCheckpointView,Zo as ForwardCheckpointsView,Go as IndexView,Ko as LinkedRowsView,Jo as LocalRowsView,zo as MetricView,To as Provider,Ho as RemoteRowView,No as ResultCellView,Oo as ResultRowView,Uo as ResultSortedTableView,Qo as ResultTableView,Mo as RowView,Do as SliceView,Ao as SortedTableView,Vo as TableView,Eo as TablesView,Fo as ValueView,jo as ValuesView,vo as tableView,ce as useAddRowCallback,de as useCell,se as useCellIds,Te as useCellIdsListener,Be as useCellListener,co as useCheckpoint,io as useCheckpointIds,Co as useCheckpointIdsListener,mo as useCheckpointListener,M as useCheckpoints,uo as useCreateCheckpoints,je as useCreateIndexes,Ae as useCreateMetrics,ko as useCreatePersister,Xe as useCreateQueries,Je as useCreateRelationships,Y as useCreateStore,ke as useDelCellCallback,me as useDelRowCallback,Ce as useDelTableCallback,Re as useDelTablesCallback,he as useDelValueCallback,ye as useDelValuesCallback,po as useGoBackwardCallback,go as useGoForwardCallback,bo as useGoToCallback,T as useIndexes,Oe as useLinkedRowIds,We as useLinkedRowIdsListener,Ne as useLocalRowIds,Ue as useLocalRowIdsListener,Ee as useMetric,Fe as useMetricListener,f as useMetrics,L as useQueries,Ro as useRedoInformation,B as useRelationships,Ke as useRemoteRowId,Qe as useRemoteRowIdListener,oo as useResultCell,eo as useResultCellIds,lo as useResultCellIdsListener,Io as useResultCellListener,_e as useResultRow,Ze as useResultRowIds,so as useResultRowIdsListener,no as useResultRowListener,$e as useResultSortedRowIds,ro as useResultSortedRowIdsListener,Ye as useResultTable,to as useResultTableListener,te as useRow,ee as useRowIds,xe as useRowIdsListener,fe as useRowListener,pe as useSetCellCallback,ao as useSetCheckpointCallback,ae as useSetPartialRowCallback,be as useSetPartialValuesCallback,ie as useSetRowCallback,ue as useSetTableCallback,Ie as useSetTablesCallback,we as useSetValueCallback,ge as useSetValuesCallback,ze as useSliceIds,Ge as useSliceIdsListener,De as useSliceRowIds,He as useSliceRowIdsListener,oe as useSortedRowIds,Se as useSortedRowIdsListener,S as useStore,_ as useTable,$ as useTableIds,qe as useTableIdsListener,Pe as useTableListener,Z as useTables,ve as useTablesListener,wo as useUndoInformation,le as useValue,ne as useValueIds,Me as useValueIdsListener,Ve as useValueListener,re as useValues,Le as useValuesListener};
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=(e,t)=>e.includes(t),n=(e,t)=>e.forEach(t),s=e=>e.length,o=e=>0==s(e),r=(e,...t)=>e.push(...t),i=e=>e.pop(),l=e=>e.shift(),c=e=>null==e,d=(e,t,n)=>c(e)?n?.():t(e),a=(e,t)=>e?.has(t)??!1,u=e=>c(e)||0==(e=>e.size)(e),h=(e,t)=>e?.forEach(t),p=(e,t)=>e?.delete(t),f=e=>new Map(e),C=(e,t)=>e?.get(t),g=(e,t,n)=>c(n)?(p(e,t),e):e?.set(t,n),k=(e,t,n)=>(a(e,t)||g(e,t,n()),C(e,t)),v=(e,t,n,o,r=0)=>d((n?k:C)(e,t[r],r>s(t)-2?n:f),(i=>{if(r>s(t)-2)return o?.(i)&&g(e,t[r]),i;const l=v(i,t,n,o,r+1);return u(i)&&g(e,t[r]),l})),y=e=>new Set(Array.isArray(e)||c(e)?e:[e]),L=/^\d+$/,w=Object.freeze,b=(e=>{const b=new WeakMap;return e=>(b.has(e)||b.set(e,(e=>{let b,S,T,x=100,z=f(),E=f(),V=1;const j=f(),m=f(),[A,B,I]=(e=>{let t;const[o,i]=(()=>{const e=[];let t=0;return[()=>l(e)??""+t++,t=>{L.test(t)&&s(e)<1e3&&r(e,t)}]})(),a=f();return[(e,n,s,r=[],i=(()=>[]))=>{t??=_;const l=o();var c;return g(a,l,[e,n,s,r,i]),c=l,v(n,s??[""],y)?.add(c),l},(e,o,...i)=>n(((e,t=[""])=>{const o=[],i=(e,l)=>l==s(t)?r(o,e):null===t[l]?h(e,(e=>i(e,l+1))):n([t[l],null],(t=>i(C(e,t),l+1)));return i(e,0),o})(e,o),(e=>h(e,(e=>C(a,e)[0](t,...o??[],...i))))),e=>d(C(a,e),(([,t,n])=>(v(t,n??[""],void 0,(t=>(p(t,e),u(t)?1:0))),g(a,e),i(e),n))),e=>d(C(a,e),(([e,,o=[],r,i])=>{const l=(...d)=>{const a=s(d);a==s(o)?e(t,...d,...i(d)):c(o[a])?n(r[a]?.(...d)??[],(e=>l(...d,e))):l(...d,o[a])};l()}))]})(),M=f(),F=f(),O=[],W=[],$=(t,n)=>{V=0,e.transaction((()=>{const[s,o]=C(M,n);h(s,((n,s)=>h(n,((n,o)=>h(n,((n,r)=>((e,t,n,s,o)=>c(o)?e.delCell(t,n,s,!0):e.setCell(t,n,s,o))(e,s,o,r,n[t]))))))),h(o,((n,s)=>((e,t,n)=>c(n)?e.delValue(t):e.setValue(t,n))(e,s,n[t])))})),V=1},q=e=>{g(M,e),g(F,e),B(m,[e])},D=(e,t)=>n(((e,t)=>e.splice(0,t))(e,t??s(e)),q),G=()=>D(O,s(O)-x),H=()=>d(b,(()=>{r(O,b),G(),D(W),b=void 0,T=1})),J=()=>{b=i(O),T=1},K=e.addCellListener(null,null,null,((e,t,n,s,o,r)=>{if(V){H();const e=k(z,t,f),i=k(e,n,f),l=k(i,s,(()=>[r,void 0]));l[1]=o,l[0]===o&&u(g(i,s))&&u(g(e,n))&&u(g(z,t))&&J(),U()}})),N=e.addValueListener(null,((e,t,n,s)=>{if(V){H();const e=k(E,t,(()=>[s,void 0]));e[1]=n,e[0]===n&&u(g(E,t))&&J(),U()}})),P=(e="")=>(c(b)&&(b=""+S++,g(M,b,[z,E]),Y(b,e),z=f(),E=f(),T=1),b),Q=()=>{o(O)||(((e,...t)=>{e.unshift(...t)})(W,P()),$(0,b),b=i(O),T=1)},R=()=>{o(W)||(r(O,b),b=l(W),$(1,b),T=1)},U=()=>{T&&(B(j),T=0)},X=e=>{const t=P(e);return U(),t},Y=(e,t)=>(Z(e)&&C(F,e)!==t&&(g(F,e,t),B(m,[e])),_),Z=e=>a(M,e),_={setSize:e=>(x=e,G(),_),addCheckpoint:X,setCheckpoint:Y,getStore:()=>e,getCheckpointIds:()=>[[...O],b,[...W]],forEachCheckpoint:e=>{return t=e,h(F,((e,n)=>t(n,e)));var t},hasCheckpoint:Z,getCheckpoint:e=>C(F,e),goBackward:()=>(Q(),U(),_),goForward:()=>(R(),U(),_),goTo:e=>{const n=t(O,e)?Q:t(W,e)?R:null;for(;!c(n)&&e!=b;)n();return U(),_},addCheckpointIdsListener:e=>A(e,j),addCheckpointListener:(e,t)=>A(t,m,[e]),delListener:e=>(I(e),_),clear:()=>(D(O),D(W),c(b)||q(b),b=void 0,S=0,X(),_),destroy:()=>{e.delListener(K),e.delListener(N)},getListenerStats:()=>({})};return w(_.clear())})(e)),b.get(e))})();e.createCheckpoints=b},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseCheckpoints={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=(e,t)=>e.includes(t),n=(e,t)=>e.forEach(t),s=e=>e.length,o=e=>0==s(e),r=(e,...t)=>e.push(...t),l=e=>e.pop(),i=e=>e.shift(),c=e=>null==e,d=(e,t,n)=>c(e)?n?.():t(e),a=(e,t)=>e?.has(t)??!1,u=e=>c(e)||0==(e=>e.size)(e),h=(e,t)=>e?.forEach(t),p=(e,t)=>e?.delete(t),f=e=>new Map(e),C=(e,t)=>e?.get(t),g=(e,t,n)=>c(n)?(p(e,t),e):e?.set(t,n),k=(e,t,n)=>(a(e,t)||g(e,t,n()),C(e,t)),v=(e,t,n,o,r=0)=>d((n?k:C)(e,t[r],r>s(t)-2?n:f),(l=>{if(r>s(t)-2)return o?.(l)&&g(e,t[r]),l;const i=v(l,t,n,o,r+1);return u(l)&&g(e,t[r]),i})),y=e=>new Set(Array.isArray(e)||c(e)?e:[e]),L=/^\d+$/,w=Object.freeze,b=(e=>{const b=new WeakMap;return e=>(b.has(e)||b.set(e,(e=>{let b,S,T,x=100,z=f(),E=f(),V=1;const j=f(),m=f(),[A,B,I]=(e=>{let t;const[o,l]=(()=>{const e=[];let t=0;return[n=>(n?i(e):null)??""+t++,t=>{L.test(t)&&s(e)<1e3&&r(e,t)}]})(),a=f();return[(e,n,s,r=[],l=(()=>[]))=>{t??=_;const i=o(1);var c,d;return g(a,i,[e,n,s,r,l]),c=v(n,s??[""],y),d=i,c?.add(d),i},(e,o,...l)=>n(((e,t=[""])=>{const o=[],l=(e,i)=>i==s(t)?r(o,e):null===t[i]?h(e,(e=>l(e,i+1))):n([t[i],null],(t=>l(C(e,t),i+1)));return l(e,0),o})(e,o),(e=>h(e,(e=>C(a,e)[0](t,...o??[],...l))))),e=>d(C(a,e),(([,t,n])=>(v(t,n??[""],void 0,(t=>(p(t,e),u(t)?1:0))),g(a,e),l(e),n))),e=>d(C(a,e),(([e,,o=[],r,l])=>{const i=(...d)=>{const a=s(d);a==s(o)?e(t,...d,...l(d)):c(o[a])?n(r[a]?.(...d)??[],(e=>i(...d,e))):i(...d,o[a])};i()}))]})(),M=f(),F=f(),O=[],W=[],$=(t,n)=>{V=0,e.transaction((()=>{const[s,o]=C(M,n);h(s,((n,s)=>h(n,((n,o)=>h(n,((n,r)=>((e,t,n,s,o)=>c(o)?e.delCell(t,n,s,!0):e.setCell(t,n,s,o))(e,s,o,r,n[t]))))))),h(o,((n,s)=>((e,t,n)=>c(n)?e.delValue(t):e.setValue(t,n))(e,s,n[t])))})),V=1},q=e=>{g(M,e),g(F,e),B(m,[e])},D=(e,t)=>n(((e,t)=>e.splice(0,t))(e,t??s(e)),q),G=()=>D(O,s(O)-x),H=()=>d(b,(()=>{r(O,b),G(),D(W),b=void 0,T=1})),J=()=>{b=l(O),T=1},K=e.addCellListener(null,null,null,((e,t,n,s,o,r)=>{if(V){H();const e=k(z,t,f),l=k(e,n,f),i=k(l,s,(()=>[r,void 0]));i[1]=o,i[0]===o&&u(g(l,s))&&u(g(e,n))&&u(g(z,t))&&J(),U()}})),N=e.addValueListener(null,((e,t,n,s)=>{if(V){H();const e=k(E,t,(()=>[s,void 0]));e[1]=n,e[0]===n&&u(g(E,t))&&J(),U()}})),P=(e="")=>(c(b)&&(b=""+S++,g(M,b,[z,E]),Y(b,e),z=f(),E=f(),T=1),b),Q=()=>{o(O)||(((e,...t)=>{e.unshift(...t)})(W,P()),$(0,b),b=l(O),T=1)},R=()=>{o(W)||(r(O,b),b=i(W),$(1,b),T=1)},U=()=>{T&&(B(j),T=0)},X=e=>{const t=P(e);return U(),t},Y=(e,t)=>(Z(e)&&C(F,e)!==t&&(g(F,e,t),B(m,[e])),_),Z=e=>a(M,e),_={setSize:e=>(x=e,G(),_),addCheckpoint:X,setCheckpoint:Y,getStore:()=>e,getCheckpointIds:()=>[[...O],b,[...W]],forEachCheckpoint:e=>{return t=e,h(F,((e,n)=>t(n,e)));var t},hasCheckpoint:Z,getCheckpoint:e=>C(F,e),goBackward:()=>(Q(),U(),_),goForward:()=>(R(),U(),_),goTo:e=>{const n=t(O,e)?Q:t(W,e)?R:null;for(;!c(n)&&e!=b;)n();return U(),_},addCheckpointIdsListener:e=>A(e,j),addCheckpointListener:(e,t)=>A(t,m,[e]),delListener:e=>(I(e),_),clear:()=>(D(O),D(W),c(b)||q(b),b=void 0,S=0,X(),_),destroy:()=>{e.delListener(K),e.delListener(N)},getListenerStats:()=>({})};return w(_.clear())})(e)),b.get(e))})();e.createCheckpoints=b},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseCheckpoints={});
Binary file