tinybase 2.0.0-beta.2 → 2.0.0-beta.3

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 (48) hide show
  1. package/lib/checkpoints.js +1 -1
  2. package/lib/checkpoints.js.gz +0 -0
  3. package/lib/debug/checkpoints.js +1 -4
  4. package/lib/debug/indexes.js +1 -3
  5. package/lib/debug/metrics.js +1 -4
  6. package/lib/debug/queries.d.ts +61 -296
  7. package/lib/debug/queries.js +59 -201
  8. package/lib/debug/relationships.js +1 -4
  9. package/lib/debug/store.d.ts +112 -90
  10. package/lib/debug/store.js +90 -149
  11. package/lib/debug/tinybase.js +130 -333
  12. package/lib/debug/ui-react.d.ts +81 -81
  13. package/lib/debug/ui-react.js +138 -173
  14. package/lib/indexes.js +1 -1
  15. package/lib/indexes.js.gz +0 -0
  16. package/lib/metrics.js +1 -1
  17. package/lib/metrics.js.gz +0 -0
  18. package/lib/queries.d.ts +61 -296
  19. package/lib/queries.js +1 -1
  20. package/lib/queries.js.gz +0 -0
  21. package/lib/relationships.js +1 -1
  22. package/lib/relationships.js.gz +0 -0
  23. package/lib/store.d.ts +112 -90
  24. package/lib/store.js +1 -1
  25. package/lib/store.js.gz +0 -0
  26. package/lib/tinybase.js +1 -1
  27. package/lib/tinybase.js.gz +0 -0
  28. package/lib/ui-react.d.ts +81 -81
  29. package/lib/ui-react.js +1 -1
  30. package/lib/ui-react.js.gz +0 -0
  31. package/lib/umd/checkpoints.js +1 -1
  32. package/lib/umd/checkpoints.js.gz +0 -0
  33. package/lib/umd/indexes.js +1 -1
  34. package/lib/umd/indexes.js.gz +0 -0
  35. package/lib/umd/metrics.js +1 -1
  36. package/lib/umd/metrics.js.gz +0 -0
  37. package/lib/umd/queries.js +1 -1
  38. package/lib/umd/queries.js.gz +0 -0
  39. package/lib/umd/relationships.js +1 -1
  40. package/lib/umd/relationships.js.gz +0 -0
  41. package/lib/umd/store.js +1 -1
  42. package/lib/umd/store.js.gz +0 -0
  43. package/lib/umd/tinybase.js +1 -1
  44. package/lib/umd/tinybase.js.gz +0 -0
  45. package/lib/umd/ui-react.js +1 -1
  46. package/lib/umd/ui-react.js.gz +0 -0
  47. package/package.json +9 -9
  48. package/readme.md +2 -2
package/lib/ui-react.d.ts CHANGED
@@ -427,9 +427,6 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
427
427
  * @param storeOrStoreId The Store to be accessed: omit for the default context
428
428
  * Store, provide an Id for a named context Store, or provide an explicit
429
429
  * reference.
430
- * @param trackReorder Since v2.0.0, an optional boolean that indicates that the
431
- * listener should be called if the set of Ids remains the same but their order
432
- * changes. See the addTableIdsListener method for more details.
433
430
  * @returns An array of the Ids of every Table in the Store.
434
431
  * @example
435
432
  * This example creates a Store outside the application, which is used in the
@@ -487,10 +484,7 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
487
484
  * ```
488
485
  * @category Store hooks
489
486
  */
490
- export function useTableIds(
491
- storeOrStoreId?: StoreOrStoreId,
492
- trackReorder?: boolean,
493
- ): Ids;
487
+ export function useTableIds(storeOrStoreId?: StoreOrStoreId): Ids;
494
488
 
495
489
  /**
496
490
  * The useTable hook returns an object containing the entire data of a single
@@ -591,9 +585,6 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
591
585
  * @param storeOrStoreId The Store to be accessed: omit for the default context
592
586
  * Store, provide an Id for a named context Store, or provide an explicit
593
587
  * reference.
594
- * @param trackReorder Since v2.0.0, an optional boolean that indicates that the
595
- * listener should be called if the set of Ids remains the same but their order
596
- * changes. See the addRowIdsListener method for more details.
597
588
  * @returns An array of the Ids of every Row in the Table.
598
589
  * @example
599
590
  * This example creates a Store outside the application, which is used in the
@@ -653,16 +644,12 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
653
644
  * ```
654
645
  * @category Store hooks
655
646
  */
656
- export function useRowIds(
657
- tableId: Id,
658
- storeOrStoreId?: StoreOrStoreId,
659
- trackReorder?: boolean,
660
- ): Ids;
647
+ export function useRowIds(tableId: Id, storeOrStoreId?: StoreOrStoreId): Ids;
661
648
 
662
649
  /**
663
- * The useSortedRowIds hook returns the sorted Ids of every Row in a given
664
- * Table, and registers a listener so that any changes to that result will cause
665
- * a re-render.
650
+ * The useSortedRowIds hook returns the sorted (and optionally, paginated) Ids
651
+ * of every Row in a given Table, and registers a listener so that any changes
652
+ * to that result will cause a re-render.
666
653
  *
667
654
  * A Provider component is used to wrap part of an application in a context, and
668
655
  * it can contain a default Store or a set of Store objects named by Id. The
@@ -678,6 +665,8 @@ export function useRowIds(
678
665
  * @param cellId The Id of the Cell whose values are used for the sorting, or
679
666
  * `undefined` to by sort the Row Id itself.
680
667
  * @param descending Whether the sorting should be in descending order.
668
+ * @param offset The number of Row Ids to skip for pagination purposes, if any.
669
+ * @param limit The maximum number of Row Ids to return, or `undefined` for all.
681
670
  * @param storeOrStoreId The Store to be accessed: omit for the default context
682
671
  * Store, provide an Id for a named context Store, or provide an explicit
683
672
  * reference.
@@ -696,7 +685,9 @@ export function useRowIds(
696
685
  * });
697
686
  * const App = () => (
698
687
  * <span>
699
- * {JSON.stringify(useSortedRowIds('pets', 'species', false, store))}
688
+ * {JSON.stringify(
689
+ * useSortedRowIds('pets', 'species', false, 0, undefined, store),
690
+ * )}
700
691
  * </span>
701
692
  * );
702
693
  *
@@ -744,7 +735,9 @@ export function useRowIds(
744
735
  * );
745
736
  * const Pane = () => (
746
737
  * <span>
747
- * {JSON.stringify(useSortedRowIds('pets', 'species', false, 'petStore'))}
738
+ * {JSON.stringify(
739
+ * useSortedRowIds('pets', 'species', false, 0, undefined, 'petStore'),
740
+ * )}
748
741
  * </span>
749
742
  * );
750
743
  *
@@ -766,6 +759,8 @@ export function useSortedRowIds(
766
759
  tableId: Id,
767
760
  cellId?: Id,
768
761
  descending?: boolean,
762
+ offset?: number,
763
+ limit?: number,
769
764
  storeOrStoreId?: StoreOrStoreId,
770
765
  ): Ids;
771
766
 
@@ -876,9 +871,6 @@ export function useRow(
876
871
  * @param storeOrStoreId The Store to be accessed: omit for the default context
877
872
  * Store, provide an Id for a named context Store, or provide an explicit
878
873
  * reference.
879
- * @param trackReorder Since v2.0.0, an optional boolean that indicates that the
880
- * listener should be called if the set of Ids remains the same but their order
881
- * changes. See the addCellIdsListener method for more details.
882
874
  * @returns An array of the Ids of every Cell in the Row.
883
875
  * @example
884
876
  * This example creates a Store outside the application, which is used in the
@@ -946,7 +938,6 @@ export function useCellIds(
946
938
  tableId: Id,
947
939
  rowId: Id,
948
940
  storeOrStoreId?: StoreOrStoreId,
949
- trackReorder?: boolean,
950
941
  ): Ids;
951
942
 
952
943
  /**
@@ -1953,9 +1944,6 @@ export function useTablesListener(
1953
1944
  * @param listenerDeps An optional array of dependencies for the `listener`
1954
1945
  * function, which, if any change, result in the re-registration of the
1955
1946
  * listener. This parameter defaults to an empty array.
1956
- * @param trackReorder Since v2.0.0, an optional boolean that indicates that the
1957
- * listener should be called if the set of Ids remains the same but their order
1958
- * changes. See the addTableIdsListener method for more details.
1959
1947
  * @param mutator An optional boolean that indicates that the listener mutates
1960
1948
  * Store data.
1961
1949
  * @param storeOrStoreId The Store to register the listener with: omit for the
@@ -1995,7 +1983,6 @@ export function useTablesListener(
1995
1983
  export function useTableIdsListener(
1996
1984
  listener: TableIdsListener,
1997
1985
  listenerDeps?: React.DependencyList,
1998
- trackReorder?: boolean,
1999
1986
  mutator?: boolean,
2000
1987
  storeOrStoreId?: StoreOrStoreId,
2001
1988
  ): void;
@@ -2088,9 +2075,6 @@ export function useTableListener(
2088
2075
  * @param listenerDeps An optional array of dependencies for the `listener`
2089
2076
  * function, which, if any change, result in the re-registration of the
2090
2077
  * listener. This parameter defaults to an empty array.
2091
- * @param trackReorder Since v2.0.0, an optional boolean that indicates that the
2092
- * listener should be called if the set of Ids remains the same but their order
2093
- * changes. See the addRowIdsListener method for more details.
2094
2078
  * @param mutator An optional boolean that indicates that the listener mutates
2095
2079
  * Store data.
2096
2080
  * @param storeOrStoreId The Store to register the listener with: omit for the
@@ -2131,14 +2115,14 @@ export function useRowIdsListener(
2131
2115
  tableId: IdOrNull,
2132
2116
  listener: RowIdsListener,
2133
2117
  listenerDeps?: React.DependencyList,
2134
- trackReorder?: boolean,
2135
2118
  mutator?: boolean,
2136
2119
  storeOrStoreId?: StoreOrStoreId,
2137
2120
  ): void;
2138
2121
 
2139
2122
  /**
2140
2123
  * The useSortedRowIdsListener hook registers a listener function with a Store
2141
- * that will be called whenever the sorted Row Ids in a Table change.
2124
+ * that will be called whenever sorted (and optionally, paginated) Row Ids in a
2125
+ * Table change.
2142
2126
  *
2143
2127
  * This hook is useful for situations where a component needs to register its
2144
2128
  * own specific listener to do more than simply tracking the value (which is
@@ -2154,6 +2138,8 @@ export function useRowIdsListener(
2154
2138
  * @param cellId The Id of the Cell whose values are used for the sorting, or
2155
2139
  * `undefined` to by sort the Row Id itself.
2156
2140
  * @param descending Whether the sorting should be in descending order.
2141
+ * @param offset The number of Row Ids to skip for pagination purposes, if any.
2142
+ * @param limit The maximum number of Row Ids to return, or `undefined` for all.
2157
2143
  * @param listener The function that will be called whenever the sorted Row Ids
2158
2144
  * in the Table change.
2159
2145
  * @param listenerDeps An optional array of dependencies for the `listener`
@@ -2176,7 +2162,7 @@ export function useRowIdsListener(
2176
2162
  * </Provider>
2177
2163
  * );
2178
2164
  * const Pane = () => {
2179
- * useSortedRowIdsListener('pets', 'species', false, () =>
2165
+ * useSortedRowIdsListener('pets', 'species', false, 0, undefined, () =>
2180
2166
  * console.log('Sorted Row Ids changed'),
2181
2167
  * );
2182
2168
  * return <span>App</span>;
@@ -2206,6 +2192,8 @@ export function useSortedRowIdsListener(
2206
2192
  tableId: Id,
2207
2193
  cellId: Id | undefined,
2208
2194
  descending: boolean,
2195
+ offset: number,
2196
+ limit: number | undefined,
2209
2197
  listener: SortedRowIdsListener,
2210
2198
  listenerDeps?: React.DependencyList,
2211
2199
  mutator?: boolean,
@@ -2316,9 +2304,6 @@ export function useRowListener(
2316
2304
  * @param listenerDeps An optional array of dependencies for the `listener`
2317
2305
  * function, which, if any change, result in the re-registration of the
2318
2306
  * listener. This parameter defaults to an empty array.
2319
- * @param trackReorder Since v2.0.0, an optional boolean that indicates that the
2320
- * listener should be called if the set of Ids remains the same but their order
2321
- * changes. See the addCellIdsListener method for more details.
2322
2307
  * @param mutator An optional boolean that indicates that the listener mutates
2323
2308
  * Store data.
2324
2309
  * @param storeOrStoreId The Store to register the listener with: omit for the
@@ -2362,7 +2347,6 @@ export function useCellIdsListener(
2362
2347
  rowId: IdOrNull,
2363
2348
  listener: CellIdsListener,
2364
2349
  listenerDeps?: React.DependencyList,
2365
- trackReorder?: boolean,
2366
2350
  mutator?: boolean,
2367
2351
  storeOrStoreId?: StoreOrStoreId,
2368
2352
  ): void;
@@ -4462,8 +4446,6 @@ export function useResultTable(
4462
4446
  * @param queriesOrQueriesId The Queries object to be accessed: omit for the
4463
4447
  * default context Queries object, provide an Id for a named context Queries
4464
4448
  * object, or provide an explicit reference.
4465
- * @param trackReorder An optional boolean that indicates that the listener
4466
- * should be called if the set of Ids remains the same but their order changes.
4467
4449
  * See the addResultRowIdsListener method for more details.
4468
4450
  * @returns An array of the Ids of every Row in the result of the query.
4469
4451
  * @example
@@ -4562,13 +4544,12 @@ export function useResultTable(
4562
4544
  export function useResultRowIds(
4563
4545
  queryId: Id,
4564
4546
  queriesOrQueriesId?: QueriesOrQueriesId,
4565
- trackReorder?: boolean,
4566
4547
  ): Ids;
4567
4548
 
4568
4549
  /**
4569
- * The useResultSortedRowIds hook returns the sorted Ids of every Row in the
4570
- * result Table of the given query, and registers a listener so that any changes
4571
- * to those Ids will cause a re-render.
4550
+ * The useResultSortedRowIds hook returns the sorted (and optionally, paginated)
4551
+ * Ids of every Row in the result Table of the given query, and registers a
4552
+ * listener so that any changes to those Ids will cause a re-render.
4572
4553
  *
4573
4554
  * A Provider component is used to wrap part of an application in a context, and
4574
4555
  * it can contain a default Queries object or a set of Queries objects named by
@@ -4585,6 +4566,8 @@ export function useResultRowIds(
4585
4566
  * @param cellId The Id of the result Cell whose values are used for the
4586
4567
  * sorting, or `undefined` to by sort the result Row Id itself.
4587
4568
  * @param descending Whether the sorting should be in descending order.
4569
+ * @param offset The number of Row Ids to skip for pagination purposes, if any.
4570
+ * @param limit The maximum number of Row Ids to return, or `undefined` for all.
4588
4571
  * @param queriesOrQueriesId The Queries object to be accessed: omit for the
4589
4572
  * default context Queries object, provide an Id for a named context Queries
4590
4573
  * object, or provide an explicit reference.
@@ -4611,7 +4594,14 @@ export function useResultRowIds(
4611
4594
  * const App = () => (
4612
4595
  * <span>
4613
4596
  * {JSON.stringify(
4614
- * useResultSortedRowIds('dogColors', 'color', false, queries),
4597
+ * useResultSortedRowIds(
4598
+ * 'dogColors',
4599
+ * 'color',
4600
+ * false,
4601
+ * 0,
4602
+ * undefined,
4603
+ * queries,
4604
+ * ),
4615
4605
  * )}
4616
4606
  * </span>
4617
4607
  * );
@@ -4637,7 +4627,7 @@ export function useResultRowIds(
4637
4627
  * );
4638
4628
  * const Pane = () => (
4639
4629
  * <span>
4640
- * {JSON.stringify(useResultSortedRowIds('dogColors', 'color', false))}
4630
+ * {JSON.stringify(useResultSortedRowIds('dogColors', 'color'))}
4641
4631
  * </span>
4642
4632
  * );
4643
4633
  *
@@ -4670,7 +4660,14 @@ export function useResultRowIds(
4670
4660
  * const Pane = () => (
4671
4661
  * <span>
4672
4662
  * {JSON.stringify(
4673
- * useResultSortedRowIds('dogColors', 'color', false, 'petQueries'),
4663
+ * useResultSortedRowIds(
4664
+ * 'dogColors',
4665
+ * 'color',
4666
+ * false,
4667
+ * 0,
4668
+ * undefined,
4669
+ * 'petQueries',
4670
+ * ),
4674
4671
  * )}
4675
4672
  * </span>
4676
4673
  * );
@@ -4696,6 +4693,8 @@ export function useResultSortedRowIds(
4696
4693
  queryId: Id,
4697
4694
  cellId?: Id,
4698
4695
  descending?: boolean,
4696
+ offset?: number,
4697
+ limit?: number,
4699
4698
  queriesOrQueriesId?: QueriesOrQueriesId,
4700
4699
  ): Ids;
4701
4700
 
@@ -5180,9 +5179,6 @@ export function useResultTableListener(
5180
5179
  * @param listenerDeps An optional array of dependencies for the `listener`
5181
5180
  * function, which, if any change, result in the re-registration of the
5182
5181
  * listener. This parameter defaults to an empty array.
5183
- * @param trackReorder An optional boolean that indicates that the listener
5184
- * should be called if the set of Ids remains the same but their order changes.
5185
- * See the addResultRowIdsListener method for more details.
5186
5182
  * @param queriesOrQueriesId The Queries object to register the listener with:
5187
5183
  * omit for the default context Queries object, provide an Id for a named
5188
5184
  * context Queries object, or provide an explicit reference.
@@ -5232,14 +5228,13 @@ export function useResultRowIdsListener(
5232
5228
  queryId: IdOrNull,
5233
5229
  listener: ResultRowIdsListener,
5234
5230
  listenerDeps?: React.DependencyList,
5235
- trackReorder?: boolean,
5236
5231
  queriesOrQueriesId?: QueriesOrQueriesId,
5237
5232
  ): void;
5238
5233
 
5239
5234
  /**
5240
5235
  * The useResultSortedRowIdsListener hook registers a listener function with a
5241
- * Queries object that will be called whenever the sorted Row Ids in a result
5242
- * Table change.
5236
+ * Queries object that will be called whenever the sorted (and optionally,
5237
+ * paginated) Row Ids in a result Table change.
5243
5238
  *
5244
5239
  * This hook is useful for situations where a component needs to register its
5245
5240
  * own specific listener to do more than simply tracking the value (which is
@@ -5255,6 +5250,8 @@ export function useResultRowIdsListener(
5255
5250
  * @param cellId The Id of the Cell whose values are used for the sorting, or
5256
5251
  * `undefined` to by sort the Row Id itself.
5257
5252
  * @param descending Whether the sorting should be in descending order.
5253
+ * @param offset The number of Row Ids to skip for pagination purposes, if any.
5254
+ * @param limit The maximum number of Row Ids to return, or `undefined` for all.
5258
5255
  * @param listener The function that will be called whenever the Row Ids in the
5259
5256
  * matching result Table change.
5260
5257
  * @param listenerDeps An optional array of dependencies for the `listener`
@@ -5275,8 +5272,13 @@ export function useResultRowIdsListener(
5275
5272
  * </Provider>
5276
5273
  * );
5277
5274
  * const Pane = () => {
5278
- * useResultSortedRowIdsListener('petColors', 'color', false, () =>
5279
- * console.log('Sorted result Row Ids changed'),
5275
+ * useResultSortedRowIdsListener(
5276
+ * 'petColors',
5277
+ * 'color',
5278
+ * false,
5279
+ * 0,
5280
+ * undefined,
5281
+ * () => console.log('Sorted result Row Ids changed'),
5280
5282
  * );
5281
5283
  * return <span>App</span>;
5282
5284
  * };
@@ -5309,6 +5311,8 @@ export function useResultSortedRowIdsListener(
5309
5311
  queryId: Id,
5310
5312
  cellId: Id | undefined,
5311
5313
  descending: boolean,
5314
+ offset: number,
5315
+ limit: number | undefined,
5312
5316
  listener: ResultRowIdsListener,
5313
5317
  listenerDeps?: React.DependencyList,
5314
5318
  queriesOrQueriesId?: QueriesOrQueriesId,
@@ -6567,12 +6571,6 @@ export type TablesProps = {
6567
6571
  * for a named context Store, or provide an explicit reference.
6568
6572
  */
6569
6573
  readonly store?: StoreOrStoreId;
6570
- /**
6571
- * An optional boolean that indicates that the component should re-render if
6572
- * the set of Table Ids in the Store remains the same but their order changes.
6573
- * See the addTableIdsListener method for more details.
6574
- */
6575
- readonly trackReorder?: boolean;
6576
6574
  /**
6577
6575
  * A component for rendering each Table in the Store (to override the default
6578
6576
  * TableView component).
@@ -6610,12 +6608,6 @@ export type TableProps = {
6610
6608
  * for a named context Store, or provide an explicit reference.
6611
6609
  */
6612
6610
  readonly store?: StoreOrStoreId;
6613
- /**
6614
- * An optional boolean that indicates that the component should re-render if
6615
- * the set of Row Ids in the Table remains the same but their order changes.
6616
- * See the addRowIdsListener method for more details.
6617
- */
6618
- readonly trackReorder?: boolean;
6619
6611
  /**
6620
6612
  * A custom component for rendering each Row in the Table (to override the
6621
6613
  * default RowView component).
@@ -6658,6 +6650,14 @@ export type SortedTableProps = {
6658
6650
  * Whether the sorting should be in descending order.
6659
6651
  */
6660
6652
  readonly descending?: boolean;
6653
+ /**
6654
+ * The number of Row Ids to skip for pagination purposes.
6655
+ */
6656
+ readonly offset?: number;
6657
+ /**
6658
+ * The maximum number of Row Ids to return.
6659
+ */
6660
+ readonly limit?: number;
6661
6661
  /**
6662
6662
  * The Store to be accessed: omit for the default context Store, provide an Id
6663
6663
  * for a named context Store, or provide an explicit reference.
@@ -6704,12 +6704,6 @@ export type RowProps = {
6704
6704
  * for a named context Store, or provide an explicit reference.
6705
6705
  */
6706
6706
  readonly store?: StoreOrStoreId;
6707
- /**
6708
- * An optional boolean that indicates that the component should re-render if
6709
- * the set of Cell Ids remains the same but their order changes. See the
6710
- * addCellIdsListener method for more details.
6711
- */
6712
- readonly trackReorder?: boolean;
6713
6707
  /**
6714
6708
  * A custom component for rendering each Cell in the Row (to override the
6715
6709
  * default CellView component).
@@ -7009,12 +7003,6 @@ export type ResultTableProps = {
7009
7003
  * explicit reference.
7010
7004
  */
7011
7005
  readonly queries?: QueriesOrQueriesId;
7012
- /**
7013
- * An optional boolean that indicates that the component should re-render if
7014
- * the set of Row Ids in the result Table remains the same but their order
7015
- * changes. See the addResultRowIdsListener method for more details.
7016
- */
7017
- readonly trackReorder?: boolean;
7018
7006
  /**
7019
7007
  * A custom component for rendering each Row in the Table (to override the
7020
7008
  * default ResultRowView component).
@@ -7058,6 +7046,14 @@ export type ResultSortedTableProps = {
7058
7046
  * Whether the sorting should be in descending order.
7059
7047
  */
7060
7048
  readonly descending?: boolean;
7049
+ /**
7050
+ * The number of Row Ids to skip for pagination purposes.
7051
+ */
7052
+ readonly offset?: number;
7053
+ /**
7054
+ * The maximum number of Row Ids to return.
7055
+ */
7056
+ readonly limit?: number;
7061
7057
  /**
7062
7058
  * The Queries object to be accessed: omit for the default context Queries
7063
7059
  * object, provide an Id for a named context Queries object, or provide an
@@ -7678,7 +7674,9 @@ export function RowView(props: RowProps): ComponentReturnType;
7678
7674
  * The component's props identify which Table to render based on Table Id, and
7679
7675
  * Store (which is either the default context Store, a named context Store, or
7680
7676
  * by explicit reference). It also takes a Cell Id to sort by and a boolean to
7681
- * indicate that the sorting should be in descending order.
7677
+ * indicate that the sorting should be in descending order. The `offset` and
7678
+ * `limit` props are used to paginate results, but default to `0` and
7679
+ * `undefined` to return all available Row Ids if not specified.
7682
7680
  *
7683
7681
  * This component renders a Table by iterating over its Row objects, in the
7684
7682
  * order dictated by the sort parameters. By default these are in turn rendered
@@ -9048,7 +9046,9 @@ export function ResultRowView(props: ResultRowProps): ComponentReturnType;
9048
9046
  * Queries object (which is either the default context Queries object, a named
9049
9047
  * context Queries object, or by explicit reference). It also takes a Cell Id to
9050
9048
  * sort by and a boolean to indicate that the sorting should be in descending
9051
- * order.
9049
+ * order. The `offset` and `limit` props are used to paginate results, but
9050
+ * default to `0` and `undefined` to return all available Row Ids if not
9051
+ * specified.
9052
9052
  *
9053
9053
  * This component renders a result Table by iterating over its Row objects, in
9054
9054
  * the order dictated by the sort parameters. By default these are in turn
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=()=>{},{createContext:I,useContext:u}=e,c=I([]),a=(e,o)=>{const t=u(c);return r(e)?t[o]:((e,o)=>n(e,(e=>e[o])))(t[o+1],e)},i=(e,o)=>{const d=a(e,o);return r(e)||(e=>t(e)==s)(e)?d:e},p=e=>a(e,0),R=e=>a(e,2),b=e=>a(e,4),w=e=>a(e,6),g=e=>a(e,8),C=e=>a(e,10),m=e=>i(e,0),k=e=>i(e,2),y=e=>i(e,4),h=e=>i(e,6),T=e=>i(e,8),q=e=>i(e,10),{useCallback:v,useEffect:P,useMemo:x,useRef:S,useState:B}=e,L=(e,o,t=[])=>{const s=x((()=>o(e)),[e,...t]);return P((()=>()=>s.destroy()),[s]),s},f=(e,o,t,s=[],d=[],n)=>{const[,l]=B(),I=v((()=>o?.["get"+e]?.(...s)??t),[o,...s]),[u]=B(I),c=S(u);return x((()=>c.current=I()),[I]),M(e,o,((...e)=>{c.current=r(n)?I():e[n],l([])}),[],s,...d),c.current},M=(e,o,t,s=[],d=[],...r)=>P((()=>{const s=o?.[`add${e}Listener`]?.(...d,t,...r);return()=>o?.delListener(s)}),[o,...d,...s,...r]),A=(e,o,t,s=[],d=l,r=[],...I)=>{const u=m(e);return v((e=>n(u,(s=>n(t(e,s),(e=>d(s["set"+o](...I,e),e)))))),[u,o,...s,...r,...I])},E=(e,o,t=l,s=[],...d)=>{const r=m(e);return v((()=>t(r?.["del"+o](...d))),[r,o,...s,...d])},F=(e,o,t)=>{const s=q(e);return v((()=>s?.[o](t)),[s,o,t])},$=(e,o=[])=>x(e,o),j=e=>f("Tables",m(e),{}),z=(e,o)=>f("TableIds",m(e),[],[],[o]),D=(e,o)=>f("Table",m(o),{},[e]),G=(e,o,t)=>f("RowIds",m(o),[],[e],[t]),H=(e,o,t,s,d)=>f("SortedRowIds",m(s),[],[e,o,t],[d],4),J=(e,o,t)=>f("Row",m(t),{},[e,o]),K=(e,o,t,s)=>f("CellIds",m(t),[],[e,o],[s]),N=(e,o,t,s)=>f("Cell",m(s),void 0,[e,o,t],[],4),O=(e,o,t,s,d)=>A(t,"Tables",e,o,s,d),Q=(e,o,t,s,d,r)=>A(s,"Table",o,t,d,r,e),U=(e,o,t,s,d,r,n)=>A(d,"Row",t,s,r,n,e,o),V=(e,o,t=[],s,d=l,r=[])=>{const I=m(s);return v((t=>n(I,(s=>n(o(t,s),(o=>d(s.addRow(e,o),s,o)))))),[I,e,...t,...r])},W=(e,o,t,s,d,r,n)=>A(d,"PartialRow",t,s,r,n,e,o),X=(e,o,t,s,d,r,n,l)=>A(r,"Cell",s,d,n,l,e,o,t),Y=(e,o,t)=>E(e,"Tables",o,t),Z=(e,o,t,s)=>E(o,"Table",t,s,e),_=(e,o,t,s,d)=>E(t,"Row",s,d,e,o),ee=(e,o,t,s,d,r,n)=>E(d,"Cell",r,n,e,o,t,s),oe=(e,o,t,s)=>M("Tables",m(s),e,o,[],t),te=(e,o,t,s,d)=>M("TableIds",m(d),e,o,[],t,s),se=(e,o,t,s,d)=>M("Table",m(d),o,t,[e],s),de=(e,o,t,s,d,r)=>M("RowIds",m(r),o,t,[e],s,d),re=(e,o,t,s,d,r,n)=>M("SortedRowIds",m(n),s,d,[e,o,t],r),ne=(e,o,t,s,d,r)=>M("Row",m(r),t,s,[e,o],d),le=(e,o,t,s,d,r,n)=>M("CellIds",m(n),t,s,[e,o],d,r),Ie=(e,o,t,s,d,r,n)=>M("Cell",m(n),s,d,[e,o,t],r),ue=(e,o,t)=>L(e,o,t),ce=(e,o)=>f("Metric",k(o),void 0,[e]),ae=(e,o,t,s)=>M("Metric",k(s),o,t,[e]),ie=(e,o,t)=>L(e,o,t),pe=(e,o)=>f("SliceIds",y(o),[],[e]),Re=(e,o,t)=>f("SliceRowIds",y(t),[],[e,o]),be=(e,o,t,s)=>M("SliceIds",y(s),o,t,[e]),we=(e,o,t,s,d)=>M("SliceRowIds",y(d),t,s,[e,o]),ge=(e,o,t)=>L(e,o,t),Ce=(e,o,t)=>f("RemoteRowId",h(t),void 0,[e,o]),me=(e,o,t)=>f("LocalRowIds",h(t),[],[e,o]),ke=(e,o,t)=>f("LinkedRowIds",h(t),[],[e,o]),ye=(e,o,t,s,d)=>M("RemoteRowId",h(d),t,s,[e,o]),he=(e,o,t,s,d)=>M("LocalRowIds",h(d),t,s,[e,o]),Te=(e,o,t,s,d)=>M("LinkedRowIds",h(d),t,s,[e,o]),qe=(e,o,t)=>L(e,o,t),ve=(e,o)=>f("ResultTable",T(o),{},[e]),Pe=(e,o,t)=>f("ResultRowIds",T(o),[],[e],[t]),xe=(e,o,t,s)=>f("ResultSortedRowIds",T(s),[],[e,o,t],[],4),Se=(e,o,t)=>f("ResultRow",T(t),{},[e,o]),Be=(e,o,t)=>f("ResultCellIds",T(t),[],[e,o]),Le=(e,o,t,s)=>f("ResultCell",T(s),void 0,[e,o,t]),fe=(e,o,t,s)=>M("ResultTable",T(s),o,t,[e]),Me=(e,o,t,s,d)=>M("ResultRowIds",T(d),o,t,[e],s),Ae=(e,o,t,s,d,r)=>M("ResultSortedRowIds",T(r),s,d,[e,o,t]),Ee=(e,o,t,s,d)=>M("ResultRow",T(d),t,s,[e,o]),Fe=(e,o,t,s,d)=>M("ResultCellIds",T(d),t,s,[e,o]),$e=(e,o,t,s,d,r)=>M("ResultCell",T(r),s,d,[e,o,t]),je=(e,o,t)=>L(e,o,t),ze=e=>f("CheckpointIds",q(e),[[],void 0,[]]),De=(e,o)=>f("Checkpoint",q(o),void 0,[e]),Ge=(e=l,o=[],t,s=l,d=[])=>{const r=q(t);return v((o=>n(r,(t=>{const d=e(o);s(t.addCheckpoint(d),t,d)}))),[r,...o,...d])},He=e=>F(e,"goBackward"),Je=e=>F(e,"goForward"),Ke=(e,o=[],t,s=l,d=[])=>{const r=q(t);return v((o=>n(r,(t=>n(e(o),(e=>s(t.goTo(e),e)))))),[r,...o,...d])},Ne=e=>{const o=q(e),[t,s]=ze(o);return[(d=t,!(0==(e=>e.length)(d))),He(o),s,n(s,(e=>o?.getCheckpoint(e)))??""];var d},Oe=e=>{const o=q(e),[,,[t]]=ze(o);return[!r(t),Je(o),t,n(t,(e=>o?.getCheckpoint(e)))??""]},Qe=(e,o,t)=>M("CheckpointIds",q(t),e,o),Ue=(e,o,t,s)=>M("Checkpoint",q(s),o,t,[e]),Ve=(e,o,t=[],s,d=[])=>{const[,r]=B(),n=x((()=>o(e)),[e,...t]);return P((()=>((async()=>{await(s?.(n)),r(1)})(),()=>{n.destroy()})),[n,...d]),n},{createElement:We,useMemo:Xe}=e,Ye=e=>{const o=h(e);return[o,o?.getStore()]},Ze=({relationshipId:e,relationships:o,rowComponent:t=ro,getRowComponentProps:s,separator:r,debugIds:n},l,I)=>{const[u,c]=Ye(o),a=u?.getLocalTableId(e),i=l(e,I,u);return to(d(i,(e=>We(t,{...eo(s,e),key:e,tableId:a,rowId:e,store:c,debugIds:n}))),r,n,I)},_e=e=>({checkpoints:o,checkpointComponent:t=mo,getCheckpointComponentProps:s,separator:r,debugIds:n})=>{const l=q(o);return to(d(e(ze(l)),(e=>We(t,{...eo(s,e),key:e,checkpoints:l,checkpointId:e,debugIds:n}))),r)},eo=(e,o)=>r(e)?{}:e(o),oo=({store:e,storesById:t,metrics:s,metricsById:d,indexes:r,indexesById:n,relationships:l,relationshipsById:I,queries:u,queriesById:a,checkpoints:i,checkpointsById:p,children:R})=>{const b=o(c);return We(c.Provider,{value:Xe((()=>[e??b[0],{...b[1],...t},s??b[2],{...b[3],...d},r??b[4],{...b[5],...n},l??b[6],{...b[7],...I},u??b[8],{...b[9],...a},i??b[10],{...b[11],...p}]),[e,t,s,d,r,n,l,I,u,a,i,p,b])},R)},to=(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},so=({tableId:e,rowId:o,cellId:t,store:s,debugIds:d})=>to(""+(N(e,o,t,s)??""),void 0,d,t),ro=({tableId:e,rowId:o,store:t,trackReorder:s,cellComponent:r=so,getCellComponentProps:n,separator:l,debugIds:I})=>to(d(K(e,o,t,s),(s=>We(r,{...eo(n,s),key:s,tableId:e,rowId:o,cellId:s,store:t,debugIds:I}))),l,I,o),no=({tableId:e,cellId:o,descending:t,store:s,rowComponent:r=ro,getRowComponentProps:n,separator:l,debugIds:I})=>to(d(H(e,o,t,s),(o=>We(r,{...eo(n,o),key:o,tableId:e,rowId:o,store:s,debugIds:I}))),l,I,e),lo=({tableId:e,store:o,trackReorder:t,rowComponent:s=ro,getRowComponentProps:r,separator:n,debugIds:l})=>to(d(G(e,o,t),(t=>We(s,{...eo(r,t),key:t,tableId:e,rowId:t,store:o,debugIds:l}))),n,l,e),Io=({store:e,trackReorder:o,tableComponent:t=lo,getTableComponentProps:s,separator:r,debugIds:n})=>to(d(z(e,o),(o=>We(t,{...eo(s,o),key:o,tableId:o,store:e,debugIds:n}))),r),uo=({metricId:e,metrics:o,debugIds:t})=>to(ce(e,o)??"",void 0,t,e),co=({indexId:e,sliceId:o,indexes:t,rowComponent:s=ro,getRowComponentProps:r,separator:n,debugIds:l})=>{const I=y(t),u=I?.getStore(),c=I?.getTableId(e),a=Re(e,o,I);return to(d(a,(e=>We(s,{...eo(r,e),key:e,tableId:c,rowId:e,store:u,debugIds:l}))),n,l,o)},ao=({indexId:e,indexes:o,sliceComponent:t=co,getSliceComponentProps:s,separator:r,debugIds:n})=>to(d(pe(e,o),(d=>We(t,{...eo(s,d),key:d,indexId:e,sliceId:d,indexes:o,debugIds:n}))),r,n,e),io=({relationshipId:e,localRowId:o,relationships:t,rowComponent:s=ro,getRowComponentProps:d,debugIds:n})=>{const[l,I]=Ye(t),u=l?.getRemoteTableId(e),c=Ce(e,o,l);return to(r(u)||r(c)?null:We(s,{...eo(d,c),key:c,tableId:u,rowId:c,store:I,debugIds:n}),void 0,n,o)},po=e=>Ze(e,me,e.remoteRowId),Ro=e=>Ze(e,ke,e.firstRowId),bo=({queryId:e,rowId:o,cellId:t,queries:s,debugIds:d})=>to(""+(Le(e,o,t,s)??""),void 0,d,t),wo=({queryId:e,rowId:o,queries:t,resultCellComponent:s=bo,getResultCellComponentProps:r,separator:n,debugIds:l})=>to(d(Be(e,o,t),(d=>We(s,{...eo(r,d),key:d,queryId:e,rowId:o,cellId:d,queries:t,debugIds:l}))),n,l,o),go=({queryId:e,queries:o,trackReorder:t,resultRowComponent:s=wo,getResultRowComponentProps:r,separator:n,debugIds:l})=>to(d(Pe(e,o,t),(t=>We(s,{...eo(r,t),key:t,queryId:e,rowId:t,queries:o,debugIds:l}))),n,l,e),Co=({queryId:e,cellId:o,descending:t,queries:s,resultRowComponent:r=wo,getResultRowComponentProps:n,separator:l,debugIds:I})=>to(d(xe(e,o,t,s),(o=>We(r,{...eo(n,o),key:o,queryId:e,rowId:o,queries:s,debugIds:I}))),l,I,e),mo=({checkpoints:e,checkpointId:o,debugIds:t})=>to(De(o,e)??"",void 0,t,o),ko=_e((e=>e[0])),yo=_e((e=>r(e[1])?[]:[e[1]])),ho=_e((e=>e[2]));export{ko as BackwardCheckpointsView,so as CellView,mo as CheckpointView,yo as CurrentCheckpointView,ho as ForwardCheckpointsView,ao as IndexView,Ro as LinkedRowsView,po as LocalRowsView,uo as MetricView,oo as Provider,io as RemoteRowView,bo as ResultCellView,wo as ResultRowView,Co as ResultSortedTableView,go as ResultTableView,ro as RowView,co as SliceView,no as SortedTableView,lo as TableView,Io as TablesView,V as useAddRowCallback,N as useCell,K as useCellIds,le as useCellIdsListener,Ie as useCellListener,De as useCheckpoint,ze as useCheckpointIds,Qe as useCheckpointIdsListener,Ue as useCheckpointListener,C as useCheckpoints,je as useCreateCheckpoints,ie as useCreateIndexes,ue as useCreateMetrics,Ve as useCreatePersister,qe as useCreateQueries,ge as useCreateRelationships,$ as useCreateStore,ee as useDelCellCallback,_ as useDelRowCallback,Z as useDelTableCallback,Y as useDelTablesCallback,He as useGoBackwardCallback,Je as useGoForwardCallback,Ke as useGoToCallback,b as useIndexes,ke as useLinkedRowIds,Te as useLinkedRowIdsListener,me as useLocalRowIds,he as useLocalRowIdsListener,ce as useMetric,ae as useMetricListener,R as useMetrics,g as useQueries,Oe as useRedoInformation,w as useRelationships,Ce as useRemoteRowId,ye as useRemoteRowIdListener,Le as useResultCell,Be as useResultCellIds,Fe as useResultCellIdsListener,$e as useResultCellListener,Se as useResultRow,Pe as useResultRowIds,Me as useResultRowIdsListener,Ee as useResultRowListener,xe as useResultSortedRowIds,Ae as useResultSortedRowIdsListener,ve as useResultTable,fe as useResultTableListener,J as useRow,G as useRowIds,de as useRowIdsListener,ne as useRowListener,X as useSetCellCallback,Ge as useSetCheckpointCallback,W as useSetPartialRowCallback,U as useSetRowCallback,Q as useSetTableCallback,O as useSetTablesCallback,pe as useSliceIds,be as useSliceIdsListener,Re as useSliceRowIds,we as useSliceRowIdsListener,H as useSortedRowIds,re as useSortedRowIdsListener,p as useStore,D as useTable,z as useTableIds,te as useTableIdsListener,se as useTableListener,j as useTables,oe as useTablesListener,Ne as useUndoInformation};
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=()=>{},{createContext:I,useContext:u}=e,i=I([]),c=(e,o)=>{const t=u(i);return r(e)?t[o]:((e,o)=>n(e,(e=>e[o])))(t[o+1],e)},a=(e,o)=>{const d=c(e,o);return r(e)||(e=>t(e)==s)(e)?d:e},p=e=>c(e,0),b=e=>c(e,2),w=e=>c(e,4),R=e=>c(e,6),g=e=>c(e,8),C=e=>c(e,10),m=e=>a(e,0),k=e=>a(e,2),y=e=>a(e,4),h=e=>a(e,6),T=e=>a(e,8),q=e=>a(e,10),{useCallback:v,useEffect:x,useMemo:P,useRef:S,useState:f}=e,B=(e,o,t=[])=>{const s=P((()=>o(e)),[e,...t]);return x((()=>()=>s.destroy()),[s]),s},L=(e,o,t,s=[],d)=>{const[,n]=f(),l=v((()=>o?.["get"+e]?.(...s)??t),[o,...s]),[I]=f(l),u=S(I);return P((()=>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=l,r=[],...I)=>{const u=m(e);return v((e=>n(u,(s=>n(t(e,s),(e=>d(s["set"+o](...I,e),e)))))),[u,o,...s,...r,...I])},E=(e,o,t=l,s=[],...d)=>{const r=m(e);return v((()=>t(r?.["del"+o](...d))),[r,o,...s,...d])},F=(e,o,t)=>{const s=q(e);return v((()=>s?.[o](t)),[s,o,t])},j=(e,o=[])=>P(e,o),z=e=>L("Tables",m(e),{}),D=e=>L("TableIds",m(e),[],[]),G=(e,o)=>L("Table",m(o),{},[e]),H=(e,o)=>L("RowIds",m(o),[],[e]),J=(e,o,t,s=0,d,r)=>L("SortedRowIds",m(r),[],[e,o,t,s,d],6),K=(e,o,t)=>L("Row",m(t),{},[e,o]),N=(e,o,t)=>L("CellIds",m(t),[],[e,o]),O=(e,o,t,s)=>L("Cell",m(s),void 0,[e,o,t],4),Q=(e,o,t,s,d)=>A(t,"Tables",e,o,s,d),U=(e,o,t,s,d,r)=>A(s,"Table",o,t,d,r,e),V=(e,o,t,s,d,r,n)=>A(d,"Row",t,s,r,n,e,o),W=(e,o,t=[],s,d=l,r=[])=>{const I=m(s);return v((t=>n(I,(s=>n(o(t,s),(o=>d(s.addRow(e,o),s,o)))))),[I,e,...t,...r])},X=(e,o,t,s,d,r,n)=>A(d,"PartialRow",t,s,r,n,e,o),Y=(e,o,t,s,d,r,n,l)=>A(r,"Cell",s,d,n,l,e,o,t),Z=(e,o,t)=>E(e,"Tables",o,t),$=(e,o,t,s)=>E(o,"Table",t,s,e),_=(e,o,t,s,d)=>E(t,"Row",s,d,e,o),ee=(e,o,t,s,d,r,n)=>E(d,"Cell",r,n,e,o,t,s),oe=(e,o,t,s)=>M("Tables",m(s),e,o,[],t),te=(e,o,t,s)=>M("TableIds",m(s),e,o,[],t),se=(e,o,t,s,d)=>M("Table",m(d),o,t,[e],s),de=(e,o,t,s,d)=>M("RowIds",m(d),o,t,[e],s),re=(e,o,t,s,d,r,n,l,I)=>M("SortedRowIds",m(I),r,n,[e,o,t,s,d],l),ne=(e,o,t,s,d,r)=>M("Row",m(r),t,s,[e,o],d),le=(e,o,t,s,d,r)=>M("CellIds",m(r),t,s,[e,o],d),Ie=(e,o,t,s,d,r,n)=>M("Cell",m(n),s,d,[e,o,t],r),ue=(e,o,t)=>B(e,o,t),ie=(e,o)=>L("Metric",k(o),void 0,[e]),ce=(e,o,t,s)=>M("Metric",k(s),o,t,[e]),ae=(e,o,t)=>B(e,o,t),pe=(e,o)=>L("SliceIds",y(o),[],[e]),be=(e,o,t)=>L("SliceRowIds",y(t),[],[e,o]),we=(e,o,t,s)=>M("SliceIds",y(s),o,t,[e]),Re=(e,o,t,s,d)=>M("SliceRowIds",y(d),t,s,[e,o]),ge=(e,o,t)=>B(e,o,t),Ce=(e,o,t)=>L("RemoteRowId",h(t),void 0,[e,o]),me=(e,o,t)=>L("LocalRowIds",h(t),[],[e,o]),ke=(e,o,t)=>L("LinkedRowIds",h(t),[],[e,o]),ye=(e,o,t,s,d)=>M("RemoteRowId",h(d),t,s,[e,o]),he=(e,o,t,s,d)=>M("LocalRowIds",h(d),t,s,[e,o]),Te=(e,o,t,s,d)=>M("LinkedRowIds",h(d),t,s,[e,o]),qe=(e,o,t)=>B(e,o,t),ve=(e,o)=>L("ResultTable",T(o),{},[e]),xe=(e,o)=>L("ResultRowIds",T(o),[],[e]),Pe=(e,o,t,s=0,d,r)=>L("ResultSortedRowIds",T(r),[],[e,o,t,s,d],6),Se=(e,o,t)=>L("ResultRow",T(t),{},[e,o]),fe=(e,o,t)=>L("ResultCellIds",T(t),[],[e,o]),Be=(e,o,t,s)=>L("ResultCell",T(s),void 0,[e,o,t]),Le=(e,o,t,s)=>M("ResultTable",T(s),o,t,[e]),Me=(e,o,t,s)=>M("ResultRowIds",T(s),o,t,[e]),Ae=(e,o,t,s,d,r,n,l)=>M("ResultSortedRowIds",T(l),r,n,[e,o,t,s,d]),Ee=(e,o,t,s,d)=>M("ResultRow",T(d),t,s,[e,o]),Fe=(e,o,t,s,d)=>M("ResultCellIds",T(d),t,s,[e,o]),je=(e,o,t,s,d,r)=>M("ResultCell",T(r),s,d,[e,o,t]),ze=(e,o,t)=>B(e,o,t),De=e=>L("CheckpointIds",q(e),[[],void 0,[]]),Ge=(e,o)=>L("Checkpoint",q(o),void 0,[e]),He=(e=l,o=[],t,s=l,d=[])=>{const r=q(t);return v((o=>n(r,(t=>{const d=e(o);s(t.addCheckpoint(d),t,d)}))),[r,...o,...d])},Je=e=>F(e,"goBackward"),Ke=e=>F(e,"goForward"),Ne=(e,o=[],t,s=l,d=[])=>{const r=q(t);return v((o=>n(r,(t=>n(e(o),(e=>s(t.goTo(e),e)))))),[r,...o,...d])},Oe=e=>{const o=q(e),[t,s]=De(o);return[(d=t,!(0==(e=>e.length)(d))),Je(o),s,n(s,(e=>o?.getCheckpoint(e)))??""];var d},Qe=e=>{const o=q(e),[,,[t]]=De(o);return[!r(t),Ke(o),t,n(t,(e=>o?.getCheckpoint(e)))??""]},Ue=(e,o,t)=>M("CheckpointIds",q(t),e,o),Ve=(e,o,t,s)=>M("Checkpoint",q(s),o,t,[e]),We=(e,o,t=[],s,d=[])=>{const[,r]=f(),n=P((()=>o(e)),[e,...t]);return x((()=>((async()=>{await(s?.(n)),r(1)})(),()=>{n.destroy()})),[n,...d]),n},{createElement:Xe,useMemo:Ye}=e,Ze=({tableId:e,store:o,rowComponent:t=lo,getRowComponentProps:s,separator:r,debugIds:n},l)=>ro(d(l,(d=>Xe(t,{...to(s,d),key:d,tableId:e,rowId:d,store:o,debugIds:n}))),r,n,e),$e=({queryId:e,queries:o,resultRowComponent:t=Co,getResultRowComponentProps:s,separator:r,debugIds:n},l)=>ro(d(l,(d=>Xe(t,{...to(s,d),key:d,queryId:e,rowId:d,queries:o,debugIds:n}))),r,n,e),_e=e=>{const o=h(e);return[o,o?.getStore()]},eo=({relationshipId:e,relationships:o,rowComponent:t=lo,getRowComponentProps:s,separator:r,debugIds:n},l,I)=>{const[u,i]=_e(o),c=u?.getLocalTableId(e),a=l(e,I,u);return ro(d(a,(e=>Xe(t,{...to(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:n}))),r,n,I)},oo=e=>({checkpoints:o,checkpointComponent:t=yo,getCheckpointComponentProps:s,separator:r,debugIds:n})=>{const l=q(o);return ro(d(e(De(l)),(e=>Xe(t,{...to(s,e),key:e,checkpoints:l,checkpointId:e,debugIds:n}))),r)},to=(e,o)=>r(e)?{}:e(o),so=({store:e,storesById:t,metrics:s,metricsById:d,indexes:r,indexesById:n,relationships:l,relationshipsById:I,queries:u,queriesById:c,checkpoints:a,checkpointsById:p,children:b})=>{const w=o(i);return Xe(i.Provider,{value:Ye((()=>[e??w[0],{...w[1],...t},s??w[2],{...w[3],...d},r??w[4],{...w[5],...n},l??w[6],{...w[7],...I},u??w[8],{...w[9],...c},a??w[10],{...w[11],...p}]),[e,t,s,d,r,n,l,I,u,c,a,p,w])},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},no=({tableId:e,rowId:o,cellId:t,store:s,debugIds:d})=>ro(""+(O(e,o,t,s)??""),void 0,d,t),lo=({tableId:e,rowId:o,store:t,cellComponent:s=no,getCellComponentProps:r,separator:n,debugIds:l})=>ro(d(N(e,o,t),(d=>Xe(s,{...to(r,d),key:d,tableId:e,rowId:o,cellId:d,store:t,debugIds:l}))),n,l,o),Io=e=>Ze(e,H(e.tableId,e.store)),uo=({cellId:e,descending:o,offset:t,limit:s,...d})=>Ze(d,J(d.tableId,e,o,t,s,d.store)),io=({store:e,tableComponent:o=Io,getTableComponentProps:t,separator:s,debugIds:r})=>ro(d(D(e),(s=>Xe(o,{...to(t,s),key:s,tableId:s,store:e,debugIds:r}))),s),co=({metricId:e,metrics:o,debugIds:t})=>ro(ie(e,o)??"",void 0,t,e),ao=({indexId:e,sliceId:o,indexes:t,rowComponent:s=lo,getRowComponentProps:r,separator:n,debugIds:l})=>{const I=y(t),u=I?.getStore(),i=I?.getTableId(e),c=be(e,o,I);return ro(d(c,(e=>Xe(s,{...to(r,e),key:e,tableId:i,rowId:e,store:u,debugIds:l}))),n,l,o)},po=({indexId:e,indexes:o,sliceComponent:t=ao,getSliceComponentProps:s,separator:r,debugIds:n})=>ro(d(pe(e,o),(d=>Xe(t,{...to(s,d),key:d,indexId:e,sliceId:d,indexes:o,debugIds:n}))),r,n,e),bo=({relationshipId:e,localRowId:o,relationships:t,rowComponent:s=lo,getRowComponentProps:d,debugIds:n})=>{const[l,I]=_e(t),u=l?.getRemoteTableId(e),i=Ce(e,o,l);return ro(r(u)||r(i)?null:Xe(s,{...to(d,i),key:i,tableId:u,rowId:i,store:I,debugIds:n}),void 0,n,o)},wo=e=>eo(e,me,e.remoteRowId),Ro=e=>eo(e,ke,e.firstRowId),go=({queryId:e,rowId:o,cellId:t,queries:s,debugIds:d})=>ro(""+(Be(e,o,t,s)??""),void 0,d,t),Co=({queryId:e,rowId:o,queries:t,resultCellComponent:s=go,getResultCellComponentProps:r,separator:n,debugIds:l})=>ro(d(fe(e,o,t),(d=>Xe(s,{...to(r,d),key:d,queryId:e,rowId:o,cellId:d,queries:t,debugIds:l}))),n,l,o),mo=e=>$e(e,xe(e.queryId,e.queries)),ko=({cellId:e,descending:o,offset:t,limit:s,...d})=>$e(d,Pe(d.queryId,e,o,t,s,d.queries)),yo=({checkpoints:e,checkpointId:o,debugIds:t})=>ro(Ge(o,e)??"",void 0,t,o),ho=oo((e=>e[0])),To=oo((e=>r(e[1])?[]:[e[1]])),qo=oo((e=>e[2]));export{ho as BackwardCheckpointsView,no as CellView,yo as CheckpointView,To as CurrentCheckpointView,qo as ForwardCheckpointsView,po as IndexView,Ro as LinkedRowsView,wo as LocalRowsView,co as MetricView,so as Provider,bo as RemoteRowView,go as ResultCellView,Co as ResultRowView,ko as ResultSortedTableView,mo as ResultTableView,lo as RowView,ao as SliceView,uo as SortedTableView,Io as TableView,io as TablesView,Ze as tableView,W as useAddRowCallback,O as useCell,N as useCellIds,le as useCellIdsListener,Ie as useCellListener,Ge as useCheckpoint,De as useCheckpointIds,Ue as useCheckpointIdsListener,Ve as useCheckpointListener,C as useCheckpoints,ze as useCreateCheckpoints,ae as useCreateIndexes,ue as useCreateMetrics,We as useCreatePersister,qe as useCreateQueries,ge as useCreateRelationships,j as useCreateStore,ee as useDelCellCallback,_ as useDelRowCallback,$ as useDelTableCallback,Z as useDelTablesCallback,Je as useGoBackwardCallback,Ke as useGoForwardCallback,Ne as useGoToCallback,w as useIndexes,ke as useLinkedRowIds,Te as useLinkedRowIdsListener,me as useLocalRowIds,he as useLocalRowIdsListener,ie as useMetric,ce as useMetricListener,b as useMetrics,g as useQueries,Qe as useRedoInformation,R as useRelationships,Ce as useRemoteRowId,ye as useRemoteRowIdListener,Be as useResultCell,fe as useResultCellIds,Fe as useResultCellIdsListener,je as useResultCellListener,Se as useResultRow,xe as useResultRowIds,Me as useResultRowIdsListener,Ee as useResultRowListener,Pe as useResultSortedRowIds,Ae as useResultSortedRowIdsListener,ve as useResultTable,Le as useResultTableListener,K as useRow,H as useRowIds,de as useRowIdsListener,ne as useRowListener,Y as useSetCellCallback,He as useSetCheckpointCallback,X as useSetPartialRowCallback,V as useSetRowCallback,U as useSetTableCallback,Q as useSetTablesCallback,pe as useSliceIds,we as useSliceIdsListener,be as useSliceRowIds,Re as useSliceRowIdsListener,J as useSortedRowIds,re as useSortedRowIdsListener,p as useStore,G as useTable,D as useTableIds,te as useTableIdsListener,se as useTableListener,z as useTables,oe as useTablesListener,Oe as useUndoInformation};
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t="",n=(e,t)=>e.includes(t),o=(e,t)=>e.forEach(t),r=e=>e.length,s=e=>0==r(e),i=(e,...t)=>e.push(...t),l=e=>e.pop(),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),p=(e,t)=>e?.forEach(t),h=(e,t)=>e?.delete(t),f=e=>new Map(e),C=(e,t)=>e?.get(t),g=(e,t,n)=>c(n)?(h(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,s=0)=>d((n?k:C)(e,t[s],s>r(t)-2?n:f),(i=>{if(s>r(t)-2)return o?.(i)&&g(e,t[s]),i;const l=v(i,t,n,o,s+1);return u(i)&&g(e,t[s]),l})),y=e=>new Set(e),L=(e,n=[t])=>{const s=[],l=(e,t)=>t==r(n)?i(s,e):null===n[t]?p(e,(e=>l(e,t+1))):o([n[t],null],(n=>l(C(e,n),t+1)));return l(e,0),s},b=Object.freeze,w=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{let w,S,T,j=100,x=f(),z=1;const E=f(),M=f(),[m,B,I]=(e=>{let n,s=0;const a=[],k=f();return[(o,r,i)=>{n??=e();const c=l(a)??t+s++;var d;return g(k,c,[o,r,i]),d=c,v(r,i??[t],y)?.add(d),c},(e,t,...r)=>o(L(e,t),(e=>p(e,(e=>C(k,e)[0](n,...t??[],...r))))),e=>d(C(k,e),(([,n,o])=>(v(n,o??[t],void 0,(t=>(h(t,e),u(t)?1:0))),g(k,e),r(a)<1e3&&i(a,e),o))),(e,t)=>{return n=L(e,t),o=c,!n.every(o);var n,o},(e,t,s)=>d(C(k,e),(([e,,i=[]])=>{const l=(...d)=>{const a=r(d);a==r(i)?e(n,...d,...s(d)):c(i[a])?o(t[a](...d),(e=>l(...d,e))):l(...d,i[a])};l()}))]})((()=>V)),O=f(),_=f(),F=[],P=[],W=(t,n)=>{z=0,e.transaction((()=>p(C(O,n),((n,o)=>p(n,((n,r)=>p(n,((n,s)=>((e,t,n,o,r)=>c(r)?e.delCell(t,n,o,!0):e.setCell(t,n,o,r))(e,o,r,s,n[t]))))))))),z=1},q=e=>{g(O,e),g(_,e),B(M,[e])},A=(e,t)=>o(((e,t)=>e.splice(0,t))(e,t??r(e)),q),D=()=>A(F,r(F)-j),G=e.addCellListener(null,null,null,((e,t,n,o,r,s)=>{if(z){d(w,(()=>{i(F,w),D(),A(P),w=void 0,T=1}));const e=k(x,t,f),c=k(e,n,f),a=k(c,o,(()=>[s,void 0]));a[1]=r,a[0]===r&&u(g(c,o))&&u(g(e,n))&&u(g(x,t))&&(w=l(F),T=1),N()}})),H=(e="")=>(c(w)&&(w=t+S++,g(O,w,x),R(w,e),x=f(),T=1),w),J=()=>{s(F)||(P.unshift(H()),W(0,w),w=l(F),T=1)},K=()=>{s(P)||(i(F,w),w=P.shift(),W(1,w),T=1)},N=()=>{T&&(B(E),T=0)},Q=e=>{const t=H(e);return N(),t},R=(e,t)=>(U(e)&&C(_,e)!==t&&(g(_,e,t),B(M,[e])),V),U=e=>a(O,e),V={setSize:e=>(j=e,D(),V),addCheckpoint:Q,setCheckpoint:R,getStore:()=>e,getCheckpointIds:()=>[[...F],w,[...P]],forEachCheckpoint:e=>{return t=e,p(_,((e,n)=>t(n,e)));var t},hasCheckpoint:U,getCheckpoint:e=>C(_,e),goBackward:()=>(J(),N(),V),goForward:()=>(K(),N(),V),goTo:e=>{const t=n(F,e)?J:n(P,e)?K:null;for(;!c(t)&&e!=w;)t();return N(),V},addCheckpointIdsListener:e=>m(e,E),addCheckpointListener:(e,t)=>m(t,M,[e]),delListener:e=>(I(e),V),clear:()=>(A(F),A(P),c(w)||q(w),w=void 0,S=0,Q(),V),destroy:()=>{e.delListener(G)},getListenerStats:()=>({})};return b(V.clear())}));e.createCheckpoints=w,Object.defineProperty(e,"__esModule",{value:!0})},"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="",n=(e,t)=>e.includes(t),o=(e,t)=>e.forEach(t),s=e=>e.length,r=e=>0==s(e),i=(e,...t)=>e.push(...t),l=e=>e.pop(),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),p=(e,t)=>e?.forEach(t),h=(e,t)=>e?.delete(t),f=e=>new Map(e),C=(e,t)=>e?.get(t),g=(e,t,n)=>c(n)?(h(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(e),L=e=>{let n,r=0;const a=[],k=f();return[(o,s,i)=>{n??=e();const c=l(a)??t+r++;var d,u;return g(k,c,[o,s,i]),d=v(s,i??[t],y),u=c,d?.add(u),c},(e,r,...l)=>o(((e,n=[t])=>{const r=[],l=(e,t)=>t==s(n)?i(r,e):null===n[t]?p(e,(e=>l(e,t+1))):o([n[t],null],(n=>l(C(e,n),t+1)));return l(e,0),r})(e,r),(e=>p(e,(e=>C(k,e)[0](n,...r??[],...l))))),e=>d(C(k,e),(([,n,o])=>(v(n,o??[t],void 0,(t=>(h(t,e),u(t)?1:0))),g(k,e),s(a)<1e3&&i(a,e),o))),(e,t,r)=>d(C(k,e),(([e,,i=[]])=>{const l=(...d)=>{const a=s(d);a==s(i)?e(n,...d,...r(d)):c(i[a])?o(t[a](...d),(e=>l(...d,e))):l(...d,i[a])};l()}))]},b=Object.freeze,w=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{let h,v,y,w=100,S=f(),T=1;const j=f(),x=f(),[z,E,M]=L((()=>Q)),m=f(),B=f(),I=[],O=[],_=(t,n)=>{T=0,e.transaction((()=>p(C(m,n),((n,o)=>p(n,((n,s)=>p(n,((n,r)=>((e,t,n,o,s)=>c(s)?e.delCell(t,n,o,!0):e.setCell(t,n,o,s))(e,o,s,r,n[t]))))))))),T=1},F=e=>{g(m,e),g(B,e),E(x,[e])},P=(e,t)=>o(((e,t)=>e.splice(0,t))(e,t??s(e)),F),W=()=>P(I,s(I)-w),q=e.addCellListener(null,null,null,((e,t,n,o,s,r)=>{if(T){d(h,(()=>{i(I,h),W(),P(O),h=void 0,y=1}));const e=k(S,t,f),c=k(e,n,f),a=k(c,o,(()=>[r,void 0]));a[1]=s,a[0]===s&&u(g(c,o))&&u(g(e,n))&&u(g(S,t))&&(h=l(I),y=1),H()}})),A=(e="")=>(c(h)&&(h=t+v++,g(m,h,S),K(h,e),S=f(),y=1),h),D=()=>{r(I)||(O.unshift(A()),_(0,h),h=l(I),y=1)},G=()=>{r(O)||(i(I,h),h=O.shift(),_(1,h),y=1)},H=()=>{y&&(E(j),y=0)},J=e=>{const t=A(e);return H(),t},K=(e,t)=>(N(e)&&C(B,e)!==t&&(g(B,e,t),E(x,[e])),Q),N=e=>a(m,e),Q={setSize:e=>(w=e,W(),Q),addCheckpoint:J,setCheckpoint:K,getStore:()=>e,getCheckpointIds:()=>[[...I],h,[...O]],forEachCheckpoint:e=>{return t=e,p(B,((e,n)=>t(n,e)));var t},hasCheckpoint:N,getCheckpoint:e=>C(B,e),goBackward:()=>(D(),H(),Q),goForward:()=>(G(),H(),Q),goTo:e=>{const t=n(I,e)?D:n(O,e)?G:null;for(;!c(t)&&e!=h;)t();return H(),Q},addCheckpointIdsListener:e=>z(e,j),addCheckpointListener:(e,t)=>z(t,x,[e]),delListener:e=>(M(e),Q),clear:()=>(P(I),P(O),c(h)||F(h),h=void 0,v=0,J(),Q),destroy:()=>{e.delListener(q)},getListenerStats:()=>({})};return b(Q.clear())}));e.createCheckpoints=w,Object.defineProperty(e,"__esModule",{value:!0})},"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
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",s=t(n),o=(e,t)=>e.every(t),r=(e,t)=>o(e,((n,s)=>0==s||t(e[s-1],n)<=0)),d=(e,t)=>e.sort(t),i=(e,t)=>e.forEach(t),l=e=>e.length,c=(e,...t)=>e.push(...t),a=e=>null==e,f=(e,t,n)=>a(e)?n?.():t(e),u=(e,t)=>e?.has(t)??!1,h=e=>a(e)||0==(e=>e.size)(e),p=e=>[...e?.values()??[]],I=e=>e.clear(),g=(e,t)=>e?.forEach(t),x=(e,t)=>e?.delete(t),y=e=>new Map(e),S=e=>[...e?.keys()??[]],b=(e,t)=>e?.get(t),v=(e,t)=>g(e,((e,n)=>t(n,e))),w=(e,t,n)=>a(n)?(x(e,t),e):e?.set(t,n),L=(e,t,n)=>(u(e,t)||w(e,t,n()),b(e,t)),T=(e,t,n,s,o=0)=>f((n?L:b)(e,t[o],o>l(t)-2?n:y),(r=>{if(o>l(t)-2)return s?.(r)&&w(e,t[o]),r;const d=T(r,t,n,s,o+1);return h(r)&&w(e,t[o]),d})),E=e=>new Set(e),R=(e,t)=>e?.add(t),j=(e,t,n)=>{const s=e.hasRow,o=y(),r=y(),d=y(),c=y(),T=y(),j=(t,n,...s)=>{const o=L(T,t,E);return i(s,(t=>R(o,t)&&n&&e.callListener(t))),s},M=(t,...n)=>f(b(T,t),(s=>{i(0==l(n)?p(s):n,(t=>{e.delListener(t),x(s,t)})),h(s)&&w(T,t)})),k=(e,n)=>{w(o,e,n),u(r,e)||(w(r,e,t()),w(d,e,y()),w(c,e,y()))},m=e=>{w(o,e),w(r,e),w(d,e),w(c,e),M(e)};return[()=>e,()=>S(o),e=>v(r,e),e=>u(r,e),e=>b(o,e),e=>b(r,e),(e,t)=>w(r,e,t),k,(t,o,r,l,f)=>{k(t,o);const h=y(),p=y(),x=b(d,t),S=b(c,t),L=t=>{const r=n=>e.getCell(o,t,n),d=b(x,t),i=s(o,t)?n(l(r,t)):void 0;if(d!=i&&w(h,t,[d,i]),!a(f)){const e=b(S,t),n=s(o,t)?f(r,t):void 0;e!=n&&w(p,t,n)}},T=e=>{r((()=>{g(h,(([,e],t)=>w(x,t,e))),g(p,((e,t)=>w(S,t,e)))}),h,p,x,S,e),I(h),I(p)};v(x,L),e.hasTable(o)&&i(e.getRowIds(o),(e=>{u(x,e)||L(e)})),T(!0),M(t),j(t,0,e.addRowListener(o,null,((e,t,n)=>L(n))),e.addTableListener(o,(()=>T())))},m,()=>v(T,m),j,M]},M=(e,o)=>t(e)==s?t=>t(e):e??(()=>o??n),k=(e,t)=>e<t?-1:1,m=(e,t=[n])=>{const s=[],o=(e,n)=>n==l(t)?c(s,e):null===t[n]?g(e,(e=>o(e,n+1))):i([t[n],null],(t=>o(b(e,t),n+1)));return o(e,0),s},z=Object.freeze,C=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=y(),s=y(),[I,L,C,D,O,_,B,,P,W,q]=j(e,y,(e=>a(e)?n:e+n)),[A,F,G]=(e=>{let t,s=0;const r=[],d=y();return[(o,i,l)=>{t??=e();const c=r.pop()??n+s++;return w(d,c,[o,i,l]),R(T(i,l??[n],E),c),c},(e,n,...s)=>i(m(e,n),(e=>g(e,(e=>b(d,e)[0](t,...n??[],...s))))),e=>f(b(d,e),(([,t,s])=>(T(t,s??[n],void 0,(t=>(x(t,e),h(t)?1:0))),w(d,e),l(r)<1e3&&c(r,e),s))),(e,t)=>!o(m(e,t),a),(e,n,s)=>f(b(d,e),(([e,,o=[]])=>{const r=(...d)=>{const c=l(d);c==l(o)?e(t,...d,...s(d)):a(o[c])?i(n[c](...d),(e=>r(...d,e))):r(...d,o[c])};r()}))]})((()=>J)),H=(t,n,s)=>{const o=O(t);g(s,((t,s)=>n(s,(n=>g(t,(t=>n(t,(n=>e.forEachCell(o,t,n)))))))))},J={setIndexDefinition:(e,n,o,i,l,c=k)=>{const p=a(l)?void 0:([e],[t])=>l(e,t);return P(e,n,((n,o,l,I,S,L)=>{let T=0;const j=E(),M=E(),k=_(e);if(g(o,(([e,t],n)=>{a(e)||(R(j,e),f(b(k,e),(t=>{x(t,n),h(t)&&(w(k,e),T=1)}))),a(t)||(R(j,t),u(k,t)||(w(k,t,E()),T=1),R(b(k,t),n),a(i)||R(M,t))})),n(),h(S)||(L?v(k,(e=>R(M,e))):v(l,(e=>f(b(I,e),(e=>R(M,e))))),g(M,(e=>{const t=(t,n)=>c(b(S,t),b(S,n),e),n=[...b(k,e)];r(n,t)||(w(k,e,E(d(n,t))),R(j,e))}))),(T||L)&&!a(p)){const t=[...k];r(t,p)||(B(e,y(d(t,p))),T=1)}T&&F(t,[e]),g(j,(t=>F(s,[e,t])))}),M(o),f(i,M)),J},delIndexDefinition:e=>(W(e),J),getStore:I,getIndexIds:L,forEachIndex:e=>C(((t,n)=>e(t,(e=>H(t,e,n))))),forEachSlice:(e,t)=>H(e,t,_(e)),hasIndex:D,hasSlice:(e,t)=>u(_(e),t),getTableId:O,getSliceIds:e=>S(_(e)),getSliceRowIds:(e,t)=>p(b(_(e),t)),addSliceIdsListener:(e,n)=>A(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>A(n,s,[e,t]),delListener:e=>(G(e),J),destroy:q,getListenerStats:()=>({})};return z(J)}));e.createIndexes=C,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseIndexes={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",s=t(n),o=(e,t)=>((e,t)=>e.every(t))(e,((n,s)=>0==s||t(e[s-1],n)<=0)),r=(e,t)=>e.sort(t),d=(e,t)=>e.forEach(t),i=e=>e.length,l=(e,...t)=>e.push(...t),c=e=>null==e,a=(e,t,n)=>c(e)?n?.():t(e),f=(e,t)=>e?.has(t)??!1,u=e=>c(e)||0==(e=>e.size)(e),h=e=>[...e?.values()??[]],p=e=>e.clear(),I=(e,t)=>e?.forEach(t),g=(e,t)=>e?.delete(t),x=e=>new Map(e),y=e=>[...e?.keys()??[]],S=(e,t)=>e?.get(t),b=(e,t)=>I(e,((e,n)=>t(n,e))),v=(e,t,n)=>c(n)?(g(e,t),e):e?.set(t,n),w=(e,t,n)=>(f(e,t)||v(e,t,n()),S(e,t)),L=(e,t,n,s,o=0)=>a((n?w:S)(e,t[o],o>i(t)-2?n:x),(r=>{if(o>i(t)-2)return s?.(r)&&v(e,t[o]),r;const d=L(r,t,n,s,o+1);return u(r)&&v(e,t[o]),d})),T=e=>new Set(e),E=(e,t)=>e?.add(t),R=(e,t,n)=>{const s=e.hasRow,o=x(),r=x(),l=x(),L=x(),R=x(),j=(t,n,...s)=>{const o=w(R,t,T);return d(s,(t=>E(o,t)&&n&&e.callListener(t))),s},M=(t,...n)=>a(S(R,t),(s=>{d(0==i(n)?h(s):n,(t=>{e.delListener(t),g(s,t)})),u(s)&&v(R,t)})),k=(e,n)=>{v(o,e,n),f(r,e)||(v(r,e,t()),v(l,e,x()),v(L,e,x()))},m=e=>{v(o,e),v(r,e),v(l,e),v(L,e),M(e)};return[()=>e,()=>y(o),e=>b(r,e),e=>f(r,e),e=>S(o,e),e=>S(r,e),(e,t)=>v(r,e,t),k,(t,o,r,i,a)=>{k(t,o);const u=x(),h=x(),g=S(l,t),y=S(L,t),w=t=>{const r=n=>e.getCell(o,t,n),d=S(g,t),l=s(o,t)?n(i(r,t)):void 0;if(d!=l&&v(u,t,[d,l]),!c(a)){const e=S(y,t),n=s(o,t)?a(r,t):void 0;e!=n&&v(h,t,n)}},T=e=>{r((()=>{I(u,(([,e],t)=>v(g,t,e))),I(h,((e,t)=>v(y,t,e)))}),u,h,g,y,e),p(u),p(h)};b(g,w),e.hasTable(o)&&d(e.getRowIds(o),(e=>{f(g,e)||w(e)})),T(!0),M(t),j(t,0,e.addRowListener(o,null,((e,t,n)=>w(n))),e.addTableListener(o,(()=>T())))},m,()=>b(R,m),j,M]},j=(e,o)=>t(e)==s?t=>t(e):e??(()=>o??n),M=(e,t)=>e<t?-1:1,k=e=>{let t,s=0;const o=[],r=x();return[(d,i,l)=>{t??=e();const c=o.pop()??n+s++;return v(r,c,[d,i,l]),E(L(i,l??[n],T),c),c},(e,s,...o)=>d(((e,t=[n])=>{const s=[],o=(e,n)=>n==i(t)?l(s,e):null===t[n]?I(e,(e=>o(e,n+1))):d([t[n],null],(t=>o(S(e,t),n+1)));return o(e,0),s})(e,s),(e=>I(e,(e=>S(r,e)[0](t,...s??[],...o))))),e=>a(S(r,e),(([,t,s])=>(L(t,s??[n],void 0,(t=>(g(t,e),u(t)?1:0))),v(r,e),i(o)<1e3&&l(o,e),s))),(e,n,s)=>a(S(r,e),(([e,,o=[]])=>{const r=(...l)=>{const a=i(l);a==i(o)?e(t,...l,...s(l)):c(o[a])?d(n[a](...l),(e=>r(...l,e))):r(...l,o[a])};r()}))]},m=Object.freeze,z=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=x(),s=x(),[d,i,l,p,w,L,z,,C,D,O]=R(e,x,(e=>c(e)?n:e+n)),[_,B,P]=k((()=>q)),W=(t,n,s)=>{const o=w(t);I(s,((t,s)=>n(s,(n=>I(t,(t=>n(t,(n=>e.forEachCell(o,t,n)))))))))},q={setIndexDefinition:(e,n,d,i,l,h=M)=>{const p=c(l)?void 0:([e],[t])=>l(e,t);return C(e,n,((n,d,l,y,w,R)=>{let j=0;const M=T(),k=T(),m=L(e);if(I(d,(([e,t],n)=>{c(e)||(E(M,e),a(S(m,e),(t=>{g(t,n),u(t)&&(v(m,e),j=1)}))),c(t)||(E(M,t),f(m,t)||(v(m,t,T()),j=1),E(S(m,t),n),c(i)||E(k,t))})),n(),u(w)||(R?b(m,(e=>E(k,e))):b(l,(e=>a(S(y,e),(e=>E(k,e))))),I(k,(e=>{const t=(t,n)=>h(S(w,t),S(w,n),e),n=[...S(m,e)];o(n,t)||(v(m,e,T(r(n,t))),E(M,e))}))),(j||R)&&!c(p)){const t=[...m];o(t,p)||(z(e,x(r(t,p))),j=1)}j&&B(t,[e]),I(M,(t=>B(s,[e,t])))}),j(d),a(i,j)),q},delIndexDefinition:e=>(D(e),q),getStore:d,getIndexIds:i,forEachIndex:e=>l(((t,n)=>e(t,(e=>W(t,e,n))))),forEachSlice:(e,t)=>W(e,t,L(e)),hasIndex:p,hasSlice:(e,t)=>f(L(e),t),getTableId:w,getSliceIds:e=>y(L(e)),getSliceRowIds:(e,t)=>h(S(L(e),t)),addSliceIdsListener:(e,n)=>_(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>_(n,s,[e,t]),delListener:e=>(P(e),q),destroy:O,getListenerStats:()=>({})};return m(q)}));e.createIndexes=z,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseIndexes={});
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",r=t(n),s=t(t),i=(e,t)=>e.forEach(t),o=e=>d(e,((e,t)=>e+t),0),c=e=>e.length,d=(e,t,n)=>e.reduce(t,n),a=(e,...t)=>e.push(...t),l=Math.max,u=Math.min,f=isFinite,h=e=>null==e,v=(e,t,n)=>h(e)?n?.():t(e),p=()=>{},M=e=>e.size,g=(e,t)=>e?.has(t)??!1,y=e=>h(e)||0==M(e),b=e=>[...e?.values()??[]],m=e=>e.clear(),L=(e,t)=>e?.forEach(t),w=(e,t)=>e?.delete(t),T=e=>new Map(e),x=(e,t)=>e?.get(t),j=(e,t)=>L(e,((e,n)=>t(n,e))),E=(e,t,n)=>h(n)?(w(e,t),e):e?.set(t,n),I=(e,t,n)=>(g(e,t)||E(e,t,n()),x(e,t)),R=(e,t,n,r,s=0)=>v((n?I:x)(e,t[s],s>c(t)-2?n:T),(i=>{if(s>c(t)-2)return r?.(i)&&E(e,t[s]),i;const o=R(i,t,n,r,s+1);return y(i)&&E(e,t[s]),o})),S=T([["avg",[(e,t)=>o(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,r)=>e+(t-n)/r]],["max",[e=>l(...e),(e,t)=>l(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:l(t,e)]],["min",[e=>u(...e),(e,t)=>u(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:u(t,e)]],["sum",[e=>o(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),k=e=>new Set(e),z=(e,t)=>e?.add(t),D=(e,t,n)=>{const r=e.hasRow,s=T(),o=T(),d=T(),a=T(),l=T(),u=(t,n,...r)=>{const s=I(l,t,k);return i(r,(t=>z(s,t)&&n&&e.callListener(t))),r},f=(t,...n)=>v(x(l,t),(r=>{i(0==c(n)?b(r):n,(t=>{e.delListener(t),w(r,t)})),y(r)&&E(l,t)})),p=(e,n)=>{E(s,e,n),g(o,e)||(E(o,e,t()),E(d,e,T()),E(a,e,T()))},M=e=>{E(s,e),E(o,e),E(d,e),E(a,e),f(e)};return[()=>e,()=>[...s?.keys()??[]],e=>j(o,e),e=>g(o,e),e=>x(s,e),e=>x(o,e),(e,t)=>E(o,e,t),p,(t,s,o,c,l)=>{p(t,s);const v=T(),M=T(),y=x(d,t),b=x(a,t),w=t=>{const i=n=>e.getCell(s,t,n),o=x(y,t),d=r(s,t)?n(c(i,t)):void 0;if(o!=d&&E(v,t,[o,d]),!h(l)){const e=x(b,t),n=r(s,t)?l(i,t):void 0;e!=n&&E(M,t,n)}},I=e=>{o((()=>{L(v,(([,e],t)=>E(y,t,e))),L(M,((e,t)=>E(b,t,e)))}),v,M,y,b,e),m(v),m(M)};j(y,w),e.hasTable(s)&&i(e.getRowIds(s),(e=>{g(y,e)||w(e)})),I(!0),f(t),u(t,0,e.addRowListener(s,null,((e,t,n)=>w(n))),e.addTableListener(s,(()=>I())))},M,()=>j(l,M),u,f]},N=(e,s)=>t(e)==r?t=>t(e):e??(()=>s??n),O=(e,t=[n])=>{const r=[],s=(e,n)=>n==c(t)?a(r,e):null===t[n]?L(e,(e=>s(e,n+1))):i([t[n],null],(t=>s(x(e,t),n+1)));return s(e,0),r},_=Object.freeze,B=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const r=T(),[o,d,l,u,g,m,j,,I,B,C]=D(e,p,(e=>isNaN(e)||h(e)||!0===e||!1===e||e===n?void 0:1*e)),[F,P,W]=(e=>{let t,r=0;const s=[],o=T();return[(i,c,d)=>{t??=e();const a=s.pop()??n+r++;return E(o,a,[i,c,d]),z(R(c,d??[n],k),a),a},(e,n,...r)=>i(O(e,n),(e=>L(e,(e=>x(o,e)[0](t,...n??[],...r))))),e=>v(x(o,e),(([,t,r])=>(R(t,r??[n],void 0,(t=>(w(t,e),y(t)?1:0))),E(o,e),c(s)<1e3&&a(s,e),r))),(e,t)=>{return n=O(e,t),r=h,!n.every(r);var n,r},(e,n,r)=>v(x(o,e),(([e,,s=[]])=>{const o=(...d)=>{const a=c(d);a==c(s)?e(t,...d,...r(d)):h(s[a])?i(n[a](...d),(e=>o(...d,e))):o(...d,s[a])};o()}))]})((()=>q)),q={setMetricDefinition:(e,n,i,o,c,d,a)=>{const l=t(i)==s?[i,c,d,a]:x(S,i)??x(S,"sum");return I(e,n,((t,n,s,i,o,c)=>{const d=m(e),a=M(i);c||=h(d),t();let u=((e,t,n,r,s,i=!1)=>{if(y(n))return;const[o,c,d,a]=s;return i||=h(e),L(r,(([n,r])=>{i||(e=h(n)?c?.(e,r,t++):h(r)?d?.(e,n,t--):a?.(e,r,n,t),i||=h(e))})),i?o(b(n),M(n)):e})(d,a,i,n,l,c);f(u)||(u=void 0),u!=d&&(j(e,u),P(r,[e],u,d))}),N(o,1)),q},delMetricDefinition:e=>(B(e),q),getStore:o,getMetricIds:d,forEachMetric:l,hasMetric:u,getTableId:g,getMetric:m,addMetricListener:(e,t)=>F(t,r,[e]),delListener:e=>(W(e),q),destroy:C,getListenerStats:()=>({})};return _(q)}));e.createMetrics=B,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseMetrics={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",s=t(n),r=t(t),i=(e,t)=>e.forEach(t),o=e=>d(e,((e,t)=>e+t),0),c=e=>e.length,d=(e,t,n)=>e.reduce(t,n),a=(e,...t)=>e.push(...t),l=Math.max,u=Math.min,f=isFinite,h=e=>null==e,p=(e,t,n)=>h(e)?n?.():t(e),M=()=>{},g=e=>e.size,v=(e,t)=>e?.has(t)??!1,y=e=>h(e)||0==g(e),b=e=>[...e?.values()??[]],m=e=>e.clear(),L=(e,t)=>e?.forEach(t),w=(e,t)=>e?.delete(t),T=e=>new Map(e),x=(e,t)=>e?.get(t),j=(e,t)=>L(e,((e,n)=>t(n,e))),E=(e,t,n)=>h(n)?(w(e,t),e):e?.set(t,n),I=(e,t,n)=>(v(e,t)||E(e,t,n()),x(e,t)),R=(e,t,n,s,r=0)=>p((n?I:x)(e,t[r],r>c(t)-2?n:T),(i=>{if(r>c(t)-2)return s?.(i)&&E(e,t[r]),i;const o=R(i,t,n,s,r+1);return y(i)&&E(e,t[r]),o})),S=T([["avg",[(e,t)=>o(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,s)=>e+(t-n)/s]],["max",[e=>l(...e),(e,t)=>l(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:l(t,e)]],["min",[e=>u(...e),(e,t)=>u(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:u(t,e)]],["sum",[e=>o(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),k=e=>new Set(e),z=(e,t)=>e?.add(t),D=(e,t,n)=>{const s=e.hasRow,r=T(),o=T(),d=T(),a=T(),l=T(),u=(t,n,...s)=>{const r=I(l,t,k);return i(s,(t=>z(r,t)&&n&&e.callListener(t))),s},f=(t,...n)=>p(x(l,t),(s=>{i(0==c(n)?b(s):n,(t=>{e.delListener(t),w(s,t)})),y(s)&&E(l,t)})),M=(e,n)=>{E(r,e,n),v(o,e)||(E(o,e,t()),E(d,e,T()),E(a,e,T()))},g=e=>{E(r,e),E(o,e),E(d,e),E(a,e),f(e)};return[()=>e,()=>[...r?.keys()??[]],e=>j(o,e),e=>v(o,e),e=>x(r,e),e=>x(o,e),(e,t)=>E(o,e,t),M,(t,r,o,c,l)=>{M(t,r);const p=T(),g=T(),y=x(d,t),b=x(a,t),w=t=>{const i=n=>e.getCell(r,t,n),o=x(y,t),d=s(r,t)?n(c(i,t)):void 0;if(o!=d&&E(p,t,[o,d]),!h(l)){const e=x(b,t),n=s(r,t)?l(i,t):void 0;e!=n&&E(g,t,n)}},I=e=>{o((()=>{L(p,(([,e],t)=>E(y,t,e))),L(g,((e,t)=>E(b,t,e)))}),p,g,y,b,e),m(p),m(g)};j(y,w),e.hasTable(r)&&i(e.getRowIds(r),(e=>{v(y,e)||w(e)})),I(!0),f(t),u(t,0,e.addRowListener(r,null,((e,t,n)=>w(n))),e.addTableListener(r,(()=>I())))},g,()=>j(l,g),u,f]},N=(e,r)=>t(e)==s?t=>t(e):e??(()=>r??n),O=e=>{let t,s=0;const r=[],o=T();return[(i,c,d)=>{t??=e();const a=r.pop()??n+s++;return E(o,a,[i,c,d]),z(R(c,d??[n],k),a),a},(e,s,...r)=>i(((e,t=[n])=>{const s=[],r=(e,n)=>n==c(t)?a(s,e):null===t[n]?L(e,(e=>r(e,n+1))):i([t[n],null],(t=>r(x(e,t),n+1)));return r(e,0),s})(e,s),(e=>L(e,(e=>x(o,e)[0](t,...s??[],...r))))),e=>p(x(o,e),(([,t,s])=>(R(t,s??[n],void 0,(t=>(w(t,e),y(t)?1:0))),E(o,e),c(r)<1e3&&a(r,e),s))),(e,n,s)=>p(x(o,e),(([e,,r=[]])=>{const o=(...d)=>{const a=c(d);a==c(r)?e(t,...d,...s(d)):h(r[a])?i(n[a](...d),(e=>o(...d,e))):o(...d,r[a])};o()}))]},_=Object.freeze,B=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const s=T(),[i,o,c,d,a,l,u,,p,v,m]=D(e,M,(e=>isNaN(e)||h(e)||!0===e||!1===e||e===n?void 0:1*e)),[w,j,E]=O((()=>I)),I={setMetricDefinition:(e,n,i,o,c,d,a)=>{const M=t(i)==r?[i,c,d,a]:x(S,i)??x(S,"sum");return p(e,n,((t,n,r,i,o,c)=>{const d=l(e),a=g(i);c||=h(d),t();let p=((e,t,n,s,r,i=!1)=>{if(y(n))return;const[o,c,d,a]=r;return i||=h(e),L(s,(([n,s])=>{i||(e=h(n)?c?.(e,s,t++):h(s)?d?.(e,n,t--):a?.(e,s,n,t),i||=h(e))})),i?o(b(n),g(n)):e})(d,a,i,n,M,c);f(p)||(p=void 0),p!=d&&(u(e,p),j(s,[e],p,d))}),N(o,1)),I},delMetricDefinition:e=>(v(e),I),getStore:i,getMetricIds:o,forEachMetric:c,hasMetric:d,getTableId:a,getMetric:l,addMetricListener:(e,t)=>w(t,s,[e]),delListener:e=>(E(e),I),destroy:m,getListenerStats:()=>({})};return _(I)}));e.createMetrics=B,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseMetrics={});
Binary file