tinybase 1.3.3 → 2.0.0-beta.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.
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/debug/checkpoints.js +67 -54
- package/lib/debug/indexes.js +104 -67
- package/lib/debug/metrics.js +185 -129
- package/lib/debug/persisters.js +2 -1
- package/lib/debug/queries.d.ts +3066 -0
- package/lib/debug/queries.js +883 -0
- package/lib/debug/relationships.d.ts +6 -5
- package/lib/debug/relationships.js +103 -67
- package/lib/debug/store.d.ts +137 -66
- package/lib/debug/store.js +215 -119
- package/lib/debug/tinybase.d.ts +1 -0
- package/lib/debug/tinybase.js +896 -176
- package/lib/debug/ui-react.d.ts +49 -2
- package/lib/debug/ui-react.js +85 -74
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/queries.d.ts +3066 -0
- package/lib/queries.js +1 -0
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.d.ts +6 -5
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.d.ts +137 -66
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.d.ts +1 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/ui-react.d.ts +49 -2
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/queries.js +1 -0
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/package.json +24 -24
- package/readme.md +2 -2
package/lib/debug/ui-react.d.ts
CHANGED
|
@@ -399,6 +399,9 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
399
399
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
400
400
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
401
401
|
* reference.
|
|
402
|
+
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
403
|
+
* listener should be called if the set of Ids remains the same but their order
|
|
404
|
+
* changes. See the addTableIdsListener method for more details.
|
|
402
405
|
* @returns An array of the Ids of every Table in the Store.
|
|
403
406
|
* @example
|
|
404
407
|
* This example creates a Store outside the application, which is used in the
|
|
@@ -456,7 +459,10 @@ export function useTables(storeOrStoreId?: StoreOrStoreId): Tables;
|
|
|
456
459
|
* ```
|
|
457
460
|
* @category Store hooks
|
|
458
461
|
*/
|
|
459
|
-
export function useTableIds(
|
|
462
|
+
export function useTableIds(
|
|
463
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
464
|
+
trackReorder?: boolean,
|
|
465
|
+
): Ids;
|
|
460
466
|
|
|
461
467
|
/**
|
|
462
468
|
* The useTable hook returns an object containing the entire data of a single
|
|
@@ -557,6 +563,9 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
557
563
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
558
564
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
559
565
|
* reference.
|
|
566
|
+
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
567
|
+
* listener should be called if the set of Ids remains the same but their order
|
|
568
|
+
* changes. See the addRowIdsListener method for more details.
|
|
560
569
|
* @returns An array of the Ids of every Row in the Table.
|
|
561
570
|
* @example
|
|
562
571
|
* This example creates a Store outside the application, which is used in the
|
|
@@ -616,7 +625,11 @@ export function useTable(tableId: Id, storeOrStoreId?: StoreOrStoreId): Table;
|
|
|
616
625
|
* ```
|
|
617
626
|
* @category Store hooks
|
|
618
627
|
*/
|
|
619
|
-
export function useRowIds(
|
|
628
|
+
export function useRowIds(
|
|
629
|
+
tableId: Id,
|
|
630
|
+
storeOrStoreId?: StoreOrStoreId,
|
|
631
|
+
trackReorder?: boolean,
|
|
632
|
+
): Ids;
|
|
620
633
|
|
|
621
634
|
/**
|
|
622
635
|
* The useRow hook returns an object containing the entire data of a single Row
|
|
@@ -725,6 +738,9 @@ export function useRow(
|
|
|
725
738
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
726
739
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
727
740
|
* reference.
|
|
741
|
+
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
742
|
+
* listener should be called if the set of Ids remains the same but their order
|
|
743
|
+
* changes. See the addCellIdsListener method for more details.
|
|
728
744
|
* @returns An array of the Ids of every Cell in the Row.
|
|
729
745
|
* @example
|
|
730
746
|
* This example creates a Store outside the application, which is used in the
|
|
@@ -792,6 +808,7 @@ export function useCellIds(
|
|
|
792
808
|
tableId: Id,
|
|
793
809
|
rowId: Id,
|
|
794
810
|
storeOrStoreId?: StoreOrStoreId,
|
|
811
|
+
trackReorder?: boolean,
|
|
795
812
|
): Ids;
|
|
796
813
|
|
|
797
814
|
/**
|
|
@@ -1798,6 +1815,9 @@ export function useTablesListener(
|
|
|
1798
1815
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
1799
1816
|
* function, which, if any change, result in the re-registration of the
|
|
1800
1817
|
* listener. This parameter defaults to an empty array.
|
|
1818
|
+
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
1819
|
+
* listener should be called if the set of Ids remains the same but their order
|
|
1820
|
+
* changes. See the addTableIdsListener method for more details.
|
|
1801
1821
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
1802
1822
|
* Store data.
|
|
1803
1823
|
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
@@ -1837,6 +1857,7 @@ export function useTablesListener(
|
|
|
1837
1857
|
export function useTableIdsListener(
|
|
1838
1858
|
listener: TableIdsListener,
|
|
1839
1859
|
listenerDeps?: React.DependencyList,
|
|
1860
|
+
trackReorder?: boolean,
|
|
1840
1861
|
mutator?: boolean,
|
|
1841
1862
|
storeOrStoreId?: StoreOrStoreId,
|
|
1842
1863
|
): void;
|
|
@@ -1929,6 +1950,9 @@ export function useTableListener(
|
|
|
1929
1950
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
1930
1951
|
* function, which, if any change, result in the re-registration of the
|
|
1931
1952
|
* listener. This parameter defaults to an empty array.
|
|
1953
|
+
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
1954
|
+
* listener should be called if the set of Ids remains the same but their order
|
|
1955
|
+
* changes. See the addRowIdsListener method for more details.
|
|
1932
1956
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
1933
1957
|
* Store data.
|
|
1934
1958
|
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
@@ -1969,6 +1993,7 @@ export function useRowIdsListener(
|
|
|
1969
1993
|
tableId: IdOrNull,
|
|
1970
1994
|
listener: RowIdsListener,
|
|
1971
1995
|
listenerDeps?: React.DependencyList,
|
|
1996
|
+
trackReorder?: boolean,
|
|
1972
1997
|
mutator?: boolean,
|
|
1973
1998
|
storeOrStoreId?: StoreOrStoreId,
|
|
1974
1999
|
): void;
|
|
@@ -2077,6 +2102,9 @@ export function useRowListener(
|
|
|
2077
2102
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
2078
2103
|
* function, which, if any change, result in the re-registration of the
|
|
2079
2104
|
* listener. This parameter defaults to an empty array.
|
|
2105
|
+
* @param trackReorder Since v2.0.0, an optional boolean that indicates that the
|
|
2106
|
+
* listener should be called if the set of Ids remains the same but their order
|
|
2107
|
+
* changes. See the addCellIdsListener method for more details.
|
|
2080
2108
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
2081
2109
|
* Store data.
|
|
2082
2110
|
* @param storeOrStoreId The Store to register the listener with: omit for the
|
|
@@ -2120,6 +2148,7 @@ export function useCellIdsListener(
|
|
|
2120
2148
|
rowId: IdOrNull,
|
|
2121
2149
|
listener: CellIdsListener,
|
|
2122
2150
|
listenerDeps?: React.DependencyList,
|
|
2151
|
+
trackReorder?: boolean,
|
|
2123
2152
|
mutator?: boolean,
|
|
2124
2153
|
storeOrStoreId?: StoreOrStoreId,
|
|
2125
2154
|
): void;
|
|
@@ -4898,6 +4927,12 @@ export type TablesProps = {
|
|
|
4898
4927
|
* for a named context Store, or provide an explicit reference.
|
|
4899
4928
|
*/
|
|
4900
4929
|
readonly store?: StoreOrStoreId;
|
|
4930
|
+
/**
|
|
4931
|
+
* An optional boolean that indicates that the component should re-render if
|
|
4932
|
+
* the set of Table Ids in the Store remains the same but their order changes.
|
|
4933
|
+
* See the addTableIdsListener method for more details.
|
|
4934
|
+
*/
|
|
4935
|
+
readonly trackReorder?: boolean;
|
|
4901
4936
|
/**
|
|
4902
4937
|
* A component for rendering each Table in the Store (to override the default
|
|
4903
4938
|
* TableView component).
|
|
@@ -4935,6 +4970,12 @@ export type TableProps = {
|
|
|
4935
4970
|
* for a named context Store, or provide an explicit reference.
|
|
4936
4971
|
*/
|
|
4937
4972
|
readonly store?: StoreOrStoreId;
|
|
4973
|
+
/**
|
|
4974
|
+
* An optional boolean that indicates that the component should re-render if
|
|
4975
|
+
* the set of Row Ids in the Table remains the same but their order changes.
|
|
4976
|
+
* See the addRowIdsListener method for more details.
|
|
4977
|
+
*/
|
|
4978
|
+
readonly trackReorder?: boolean;
|
|
4938
4979
|
/**
|
|
4939
4980
|
* A custom component for rendering each Row in the Table (to override the
|
|
4940
4981
|
* default RowView component).
|
|
@@ -4976,6 +5017,12 @@ export type RowProps = {
|
|
|
4976
5017
|
* for a named context Store, or provide an explicit reference.
|
|
4977
5018
|
*/
|
|
4978
5019
|
readonly store?: StoreOrStoreId;
|
|
5020
|
+
/**
|
|
5021
|
+
* An optional boolean that indicates that the component should re-render if
|
|
5022
|
+
* the set of Cell Ids remains the same but their order changes. See the
|
|
5023
|
+
* addCellIdsListener method for more details.
|
|
5024
|
+
*/
|
|
5025
|
+
readonly trackReorder?: boolean;
|
|
4979
5026
|
/**
|
|
4980
5027
|
* A custom component for rendering each Cell in the Row (to override the
|
|
4981
5028
|
* default CellView component).
|
package/lib/debug/ui-react.js
CHANGED
|
@@ -53,18 +53,24 @@ const useCreate = (store, create, createDeps = []) => {
|
|
|
53
53
|
useEffect(() => () => thing.destroy(), [thing]);
|
|
54
54
|
return thing;
|
|
55
55
|
};
|
|
56
|
-
const useListenable = (
|
|
56
|
+
const useListenable = (
|
|
57
|
+
listenable,
|
|
58
|
+
thing,
|
|
59
|
+
defaulted,
|
|
60
|
+
preArgs = [],
|
|
61
|
+
...postArgs
|
|
62
|
+
) => {
|
|
57
63
|
const getListenable = thing?.['get' + listenable] ?? (() => defaulted);
|
|
58
|
-
const immediateListenable = getListenable(...
|
|
64
|
+
const immediateListenable = getListenable(...preArgs);
|
|
59
65
|
const [, setListenable] = useState(immediateListenable);
|
|
60
66
|
useEffect(() => {
|
|
61
67
|
const listenerId = thing?.[`add${listenable}Listener`]?.(
|
|
62
|
-
...
|
|
63
|
-
() => setListenable(getListenable(...
|
|
64
|
-
|
|
68
|
+
...preArgs,
|
|
69
|
+
() => setListenable(getListenable(...preArgs)),
|
|
70
|
+
...postArgs,
|
|
65
71
|
);
|
|
66
72
|
return () => thing?.delListener(listenerId);
|
|
67
|
-
}, [thing, listenable, setListenable, getListenable, ...
|
|
73
|
+
}, [thing, listenable, setListenable, getListenable, ...preArgs]);
|
|
68
74
|
return immediateListenable;
|
|
69
75
|
};
|
|
70
76
|
const useListener = (
|
|
@@ -72,17 +78,17 @@ const useListener = (
|
|
|
72
78
|
thing,
|
|
73
79
|
listener,
|
|
74
80
|
listenerDeps = [],
|
|
75
|
-
|
|
76
|
-
...
|
|
81
|
+
preArgs = [],
|
|
82
|
+
...postArgs
|
|
77
83
|
) => {
|
|
78
84
|
useEffect(() => {
|
|
79
85
|
const listenerId = thing?.[`add${listenable}Listener`]?.(
|
|
80
|
-
...
|
|
86
|
+
...preArgs,
|
|
81
87
|
listener,
|
|
82
|
-
|
|
88
|
+
...postArgs,
|
|
83
89
|
);
|
|
84
90
|
return () => thing?.delListener(listenerId);
|
|
85
|
-
}, [thing, listenable, ...listenerDeps,
|
|
91
|
+
}, [thing, listenable, ...listenerDeps, ...preArgs, ...postArgs]);
|
|
86
92
|
};
|
|
87
93
|
const useSetCallback = (
|
|
88
94
|
storeOrStoreId,
|
|
@@ -128,31 +134,40 @@ const useCreateStore = (create, createDeps = []) =>
|
|
|
128
134
|
useMemo$1(create, createDeps);
|
|
129
135
|
const useTables = (storeOrStoreId) =>
|
|
130
136
|
useListenable('Tables', useStoreOrStoreId(storeOrStoreId), {});
|
|
131
|
-
const useTableIds = (storeOrStoreId) =>
|
|
132
|
-
useListenable(
|
|
137
|
+
const useTableIds = (storeOrStoreId, trackReorder) =>
|
|
138
|
+
useListenable(
|
|
139
|
+
'TableIds',
|
|
140
|
+
useStoreOrStoreId(storeOrStoreId),
|
|
141
|
+
[],
|
|
142
|
+
[],
|
|
143
|
+
trackReorder,
|
|
144
|
+
);
|
|
133
145
|
const useTable = (tableId, storeOrStoreId) =>
|
|
134
|
-
useListenable('Table', useStoreOrStoreId(storeOrStoreId), {}, tableId);
|
|
135
|
-
const useRowIds = (tableId, storeOrStoreId) =>
|
|
136
|
-
useListenable(
|
|
146
|
+
useListenable('Table', useStoreOrStoreId(storeOrStoreId), {}, [tableId]);
|
|
147
|
+
const useRowIds = (tableId, storeOrStoreId, trackReorder) =>
|
|
148
|
+
useListenable(
|
|
149
|
+
'RowIds',
|
|
150
|
+
useStoreOrStoreId(storeOrStoreId),
|
|
151
|
+
[],
|
|
152
|
+
[tableId],
|
|
153
|
+
trackReorder,
|
|
154
|
+
);
|
|
137
155
|
const useRow = (tableId, rowId, storeOrStoreId) =>
|
|
138
|
-
useListenable('Row', useStoreOrStoreId(storeOrStoreId), {}, tableId, rowId);
|
|
139
|
-
const useCellIds = (tableId, rowId, storeOrStoreId) =>
|
|
156
|
+
useListenable('Row', useStoreOrStoreId(storeOrStoreId), {}, [tableId, rowId]);
|
|
157
|
+
const useCellIds = (tableId, rowId, storeOrStoreId, trackReorder) =>
|
|
140
158
|
useListenable(
|
|
141
159
|
'CellIds',
|
|
142
160
|
useStoreOrStoreId(storeOrStoreId),
|
|
143
161
|
[],
|
|
144
|
-
tableId,
|
|
145
|
-
|
|
162
|
+
[tableId, rowId],
|
|
163
|
+
trackReorder,
|
|
146
164
|
);
|
|
147
165
|
const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
|
|
148
|
-
useListenable(
|
|
149
|
-
'Cell',
|
|
150
|
-
useStoreOrStoreId(storeOrStoreId),
|
|
151
|
-
void 0,
|
|
166
|
+
useListenable('Cell', useStoreOrStoreId(storeOrStoreId), void 0, [
|
|
152
167
|
tableId,
|
|
153
168
|
rowId,
|
|
154
169
|
cellId,
|
|
155
|
-
);
|
|
170
|
+
]);
|
|
156
171
|
const useSetTablesCallback = (
|
|
157
172
|
getTables,
|
|
158
173
|
getTablesDeps,
|
|
@@ -294,14 +309,23 @@ const useTablesListener = (listener, listenerDeps, mutator, storeOrStoreId) =>
|
|
|
294
309
|
useStoreOrStoreId(storeOrStoreId),
|
|
295
310
|
listener,
|
|
296
311
|
listenerDeps,
|
|
312
|
+
[],
|
|
297
313
|
mutator,
|
|
298
314
|
);
|
|
299
|
-
const useTableIdsListener = (
|
|
315
|
+
const useTableIdsListener = (
|
|
316
|
+
listener,
|
|
317
|
+
listenerDeps,
|
|
318
|
+
trackReorder,
|
|
319
|
+
mutator,
|
|
320
|
+
storeOrStoreId,
|
|
321
|
+
) =>
|
|
300
322
|
useListener(
|
|
301
323
|
'TableIds',
|
|
302
324
|
useStoreOrStoreId(storeOrStoreId),
|
|
303
325
|
listener,
|
|
304
326
|
listenerDeps,
|
|
327
|
+
[],
|
|
328
|
+
trackReorder,
|
|
305
329
|
mutator,
|
|
306
330
|
);
|
|
307
331
|
const useTableListener = (
|
|
@@ -316,13 +340,14 @@ const useTableListener = (
|
|
|
316
340
|
useStoreOrStoreId(storeOrStoreId),
|
|
317
341
|
listener,
|
|
318
342
|
listenerDeps,
|
|
343
|
+
[tableId],
|
|
319
344
|
mutator,
|
|
320
|
-
tableId,
|
|
321
345
|
);
|
|
322
346
|
const useRowIdsListener = (
|
|
323
347
|
tableId,
|
|
324
348
|
listener,
|
|
325
349
|
listenerDeps,
|
|
350
|
+
trackReorder,
|
|
326
351
|
mutator,
|
|
327
352
|
storeOrStoreId,
|
|
328
353
|
) =>
|
|
@@ -331,8 +356,9 @@ const useRowIdsListener = (
|
|
|
331
356
|
useStoreOrStoreId(storeOrStoreId),
|
|
332
357
|
listener,
|
|
333
358
|
listenerDeps,
|
|
359
|
+
[tableId],
|
|
360
|
+
trackReorder,
|
|
334
361
|
mutator,
|
|
335
|
-
tableId,
|
|
336
362
|
);
|
|
337
363
|
const useRowListener = (
|
|
338
364
|
tableId,
|
|
@@ -347,15 +373,15 @@ const useRowListener = (
|
|
|
347
373
|
useStoreOrStoreId(storeOrStoreId),
|
|
348
374
|
listener,
|
|
349
375
|
listenerDeps,
|
|
376
|
+
[tableId, rowId],
|
|
350
377
|
mutator,
|
|
351
|
-
tableId,
|
|
352
|
-
rowId,
|
|
353
378
|
);
|
|
354
379
|
const useCellIdsListener = (
|
|
355
380
|
tableId,
|
|
356
381
|
rowId,
|
|
357
382
|
listener,
|
|
358
383
|
listenerDeps,
|
|
384
|
+
trackReorder,
|
|
359
385
|
mutator,
|
|
360
386
|
storeOrStoreId,
|
|
361
387
|
) =>
|
|
@@ -364,9 +390,9 @@ const useCellIdsListener = (
|
|
|
364
390
|
useStoreOrStoreId(storeOrStoreId),
|
|
365
391
|
listener,
|
|
366
392
|
listenerDeps,
|
|
393
|
+
[tableId, rowId],
|
|
394
|
+
trackReorder,
|
|
367
395
|
mutator,
|
|
368
|
-
tableId,
|
|
369
|
-
rowId,
|
|
370
396
|
);
|
|
371
397
|
const useCellListener = (
|
|
372
398
|
tableId,
|
|
@@ -382,20 +408,15 @@ const useCellListener = (
|
|
|
382
408
|
useStoreOrStoreId(storeOrStoreId),
|
|
383
409
|
listener,
|
|
384
410
|
listenerDeps,
|
|
411
|
+
[tableId, rowId, cellId],
|
|
385
412
|
mutator,
|
|
386
|
-
tableId,
|
|
387
|
-
rowId,
|
|
388
|
-
cellId,
|
|
389
413
|
);
|
|
390
414
|
const useCreateMetrics = (store, create, createDeps) =>
|
|
391
415
|
useCreate(store, create, createDeps);
|
|
392
416
|
const useMetric = (metricId, metricsOrMetricsId) =>
|
|
393
|
-
useListenable(
|
|
394
|
-
'Metric',
|
|
395
|
-
useMetricsOrMetricsId(metricsOrMetricsId),
|
|
396
|
-
void 0,
|
|
417
|
+
useListenable('Metric', useMetricsOrMetricsId(metricsOrMetricsId), void 0, [
|
|
397
418
|
metricId,
|
|
398
|
-
);
|
|
419
|
+
]);
|
|
399
420
|
const useMetricListener = (
|
|
400
421
|
metricId,
|
|
401
422
|
listener,
|
|
@@ -407,8 +428,7 @@ const useMetricListener = (
|
|
|
407
428
|
useMetricsOrMetricsId(metricsOrMetricsId),
|
|
408
429
|
listener,
|
|
409
430
|
listenerDeps,
|
|
410
|
-
|
|
411
|
-
metricId,
|
|
431
|
+
[metricId],
|
|
412
432
|
);
|
|
413
433
|
const useCreateIndexes = (store, create, createDeps) =>
|
|
414
434
|
useCreate(store, create, createDeps);
|
|
@@ -417,15 +437,14 @@ const useSliceIds = (indexId, indexesOrIndexesId) =>
|
|
|
417
437
|
'SliceIds',
|
|
418
438
|
useIndexesOrIndexesId(indexesOrIndexesId),
|
|
419
439
|
[],
|
|
420
|
-
indexId,
|
|
440
|
+
[indexId],
|
|
421
441
|
);
|
|
422
442
|
const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
|
|
423
443
|
useListenable(
|
|
424
444
|
'SliceRowIds',
|
|
425
445
|
useIndexesOrIndexesId(indexesOrIndexesId),
|
|
426
446
|
[],
|
|
427
|
-
indexId,
|
|
428
|
-
sliceId,
|
|
447
|
+
[indexId, sliceId],
|
|
429
448
|
);
|
|
430
449
|
const useSliceIdsListener = (
|
|
431
450
|
indexId,
|
|
@@ -438,8 +457,7 @@ const useSliceIdsListener = (
|
|
|
438
457
|
useIndexesOrIndexesId(indexesOrIndexesId),
|
|
439
458
|
listener,
|
|
440
459
|
listenerDeps,
|
|
441
|
-
|
|
442
|
-
indexId,
|
|
460
|
+
[indexId],
|
|
443
461
|
);
|
|
444
462
|
const useSliceRowIdsListener = (
|
|
445
463
|
indexId,
|
|
@@ -453,9 +471,7 @@ const useSliceRowIdsListener = (
|
|
|
453
471
|
useIndexesOrIndexesId(indexesOrIndexesId),
|
|
454
472
|
listener,
|
|
455
473
|
listenerDeps,
|
|
456
|
-
|
|
457
|
-
indexId,
|
|
458
|
-
sliceId,
|
|
474
|
+
[indexId, sliceId],
|
|
459
475
|
);
|
|
460
476
|
const useCreateRelationships = (store, create, createDeps) =>
|
|
461
477
|
useCreate(store, create, createDeps);
|
|
@@ -468,8 +484,7 @@ const useRemoteRowId = (
|
|
|
468
484
|
'RemoteRowId',
|
|
469
485
|
useRelationshipsOrRelationshipsId(relationshipsOrRelationshipsId),
|
|
470
486
|
void 0,
|
|
471
|
-
relationshipId,
|
|
472
|
-
localRowId,
|
|
487
|
+
[relationshipId, localRowId],
|
|
473
488
|
);
|
|
474
489
|
const useLocalRowIds = (
|
|
475
490
|
relationshipId,
|
|
@@ -480,8 +495,7 @@ const useLocalRowIds = (
|
|
|
480
495
|
'LocalRowIds',
|
|
481
496
|
useRelationshipsOrRelationshipsId(relationshipsOrRelationshipsId),
|
|
482
497
|
[],
|
|
483
|
-
relationshipId,
|
|
484
|
-
remoteRowId,
|
|
498
|
+
[relationshipId, remoteRowId],
|
|
485
499
|
);
|
|
486
500
|
const useLinkedRowIds = (
|
|
487
501
|
relationshipId,
|
|
@@ -492,8 +506,7 @@ const useLinkedRowIds = (
|
|
|
492
506
|
'LinkedRowIds',
|
|
493
507
|
useRelationshipsOrRelationshipsId(relationshipsOrRelationshipsId),
|
|
494
508
|
[],
|
|
495
|
-
relationshipId,
|
|
496
|
-
firstRowId,
|
|
509
|
+
[relationshipId, firstRowId],
|
|
497
510
|
);
|
|
498
511
|
const useRemoteRowIdListener = (
|
|
499
512
|
relationshipId,
|
|
@@ -507,9 +520,7 @@ const useRemoteRowIdListener = (
|
|
|
507
520
|
useRelationshipsOrRelationshipsId(relationshipsOrRelationshipsId),
|
|
508
521
|
listener,
|
|
509
522
|
listenerDeps,
|
|
510
|
-
|
|
511
|
-
relationshipId,
|
|
512
|
-
localRowId,
|
|
523
|
+
[relationshipId, localRowId],
|
|
513
524
|
);
|
|
514
525
|
const useLocalRowIdsListener = (
|
|
515
526
|
relationshipId,
|
|
@@ -523,9 +534,7 @@ const useLocalRowIdsListener = (
|
|
|
523
534
|
useRelationshipsOrRelationshipsId(relationshipsOrRelationshipsId),
|
|
524
535
|
listener,
|
|
525
536
|
listenerDeps,
|
|
526
|
-
|
|
527
|
-
relationshipId,
|
|
528
|
-
remoteRowId,
|
|
537
|
+
[relationshipId, remoteRowId],
|
|
529
538
|
);
|
|
530
539
|
const useLinkedRowIdsListener = (
|
|
531
540
|
relationshipId,
|
|
@@ -539,9 +548,7 @@ const useLinkedRowIdsListener = (
|
|
|
539
548
|
useRelationshipsOrRelationshipsId(relationshipsOrRelationshipsId),
|
|
540
549
|
listener,
|
|
541
550
|
listenerDeps,
|
|
542
|
-
|
|
543
|
-
relationshipId,
|
|
544
|
-
firstRowId,
|
|
551
|
+
[relationshipId, firstRowId],
|
|
545
552
|
);
|
|
546
553
|
const useCreateCheckpoints = (store, create, createDeps) =>
|
|
547
554
|
useCreate(store, create, createDeps);
|
|
@@ -556,7 +563,7 @@ const useCheckpoint = (checkpointId, checkpointsOrCheckpointsId) =>
|
|
|
556
563
|
'Checkpoint',
|
|
557
564
|
useCheckpointsOrCheckpointsId(checkpointsOrCheckpointsId),
|
|
558
565
|
void 0,
|
|
559
|
-
checkpointId,
|
|
566
|
+
[checkpointId],
|
|
560
567
|
);
|
|
561
568
|
const useSetCheckpointCallback = (
|
|
562
569
|
getCheckpoint = getUndefined,
|
|
@@ -604,7 +611,8 @@ const useUndoInformation = (checkpointsOrCheckpointsId) => {
|
|
|
604
611
|
!arrayIsEmpty(backwardIds),
|
|
605
612
|
useGoBackwardCallback(checkpoints),
|
|
606
613
|
currentId,
|
|
607
|
-
ifNotUndefined(currentId, (id) => checkpoints?.getCheckpoint(id)) ??
|
|
614
|
+
ifNotUndefined(currentId, (id) => checkpoints?.getCheckpoint(id)) ??
|
|
615
|
+
EMPTY_STRING,
|
|
608
616
|
];
|
|
609
617
|
};
|
|
610
618
|
const useRedoInformation = (checkpointsOrCheckpointsId) => {
|
|
@@ -614,7 +622,8 @@ const useRedoInformation = (checkpointsOrCheckpointsId) => {
|
|
|
614
622
|
!isUndefined(forwardId),
|
|
615
623
|
useGoForwardCallback(checkpoints),
|
|
616
624
|
forwardId,
|
|
617
|
-
ifNotUndefined(forwardId, (id) => checkpoints?.getCheckpoint(id)) ??
|
|
625
|
+
ifNotUndefined(forwardId, (id) => checkpoints?.getCheckpoint(id)) ??
|
|
626
|
+
EMPTY_STRING,
|
|
618
627
|
];
|
|
619
628
|
};
|
|
620
629
|
const useCheckpointIdsListener = (
|
|
@@ -639,8 +648,7 @@ const useCheckpointListener = (
|
|
|
639
648
|
useCheckpointsOrCheckpointsId(checkpointsOrCheckpointsId),
|
|
640
649
|
listener,
|
|
641
650
|
listenerDeps,
|
|
642
|
-
|
|
643
|
-
checkpointId,
|
|
651
|
+
[checkpointId],
|
|
644
652
|
);
|
|
645
653
|
const useCreatePersister = (
|
|
646
654
|
store,
|
|
@@ -795,13 +803,14 @@ const RowView = ({
|
|
|
795
803
|
tableId,
|
|
796
804
|
rowId,
|
|
797
805
|
store,
|
|
806
|
+
trackReorder,
|
|
798
807
|
cellComponent: Cell = CellView,
|
|
799
808
|
getCellComponentProps,
|
|
800
809
|
separator,
|
|
801
810
|
debugIds,
|
|
802
811
|
}) =>
|
|
803
812
|
wrap(
|
|
804
|
-
arrayMap(useCellIds(tableId, rowId, store), (cellId) =>
|
|
813
|
+
arrayMap(useCellIds(tableId, rowId, store, trackReorder), (cellId) =>
|
|
805
814
|
/* @__PURE__ */ createElement(Cell, {
|
|
806
815
|
...getProps(getCellComponentProps, cellId),
|
|
807
816
|
key: cellId,
|
|
@@ -819,13 +828,14 @@ const RowView = ({
|
|
|
819
828
|
const TableView = ({
|
|
820
829
|
tableId,
|
|
821
830
|
store,
|
|
831
|
+
trackReorder,
|
|
822
832
|
rowComponent: Row = RowView,
|
|
823
833
|
getRowComponentProps,
|
|
824
834
|
separator,
|
|
825
835
|
debugIds,
|
|
826
836
|
}) =>
|
|
827
837
|
wrap(
|
|
828
|
-
arrayMap(useRowIds(tableId, store), (rowId) =>
|
|
838
|
+
arrayMap(useRowIds(tableId, store, trackReorder), (rowId) =>
|
|
829
839
|
/* @__PURE__ */ createElement(Row, {
|
|
830
840
|
...getProps(getRowComponentProps, rowId),
|
|
831
841
|
key: rowId,
|
|
@@ -841,13 +851,14 @@ const TableView = ({
|
|
|
841
851
|
);
|
|
842
852
|
const TablesView = ({
|
|
843
853
|
store,
|
|
854
|
+
trackReorder,
|
|
844
855
|
tableComponent: Table = TableView,
|
|
845
856
|
getTableComponentProps,
|
|
846
857
|
separator,
|
|
847
858
|
debugIds,
|
|
848
859
|
}) =>
|
|
849
860
|
wrap(
|
|
850
|
-
arrayMap(useTableIds(store), (tableId) =>
|
|
861
|
+
arrayMap(useTableIds(store, trackReorder), (tableId) =>
|
|
851
862
|
/* @__PURE__ */ createElement(Table, {
|
|
852
863
|
...getProps(getTableComponentProps, tableId),
|
|
853
864
|
key: tableId,
|
|
@@ -955,7 +966,7 @@ const LinkedRowsView = (props) =>
|
|
|
955
966
|
useComponentPerRow(props, useLinkedRowIds, props.firstRowId);
|
|
956
967
|
const CheckpointView = ({checkpoints, checkpointId, debugIds}) =>
|
|
957
968
|
wrap(
|
|
958
|
-
useCheckpoint(checkpointId, checkpoints) ??
|
|
969
|
+
useCheckpoint(checkpointId, checkpoints) ?? EMPTY_STRING,
|
|
959
970
|
void 0,
|
|
960
971
|
debugIds,
|
|
961
972
|
checkpointId,
|
package/lib/indexes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>typeof e,t=e(""),
|
|
1
|
+
const e=e=>typeof e,t=e(""),n=(e,t)=>e.every(t),s=(e,t)=>n(e,((n,s)=>0==s||t(e[s-1],n)<=0)),o=(e,t)=>e.sort(t),r=(e,t)=>e.forEach(t),c=e=>e.length,d=(e,...t)=>e.push(...t),l=e=>null==e,i=(e,t,n)=>l(e)?n?.():t(e),a=(e,t)=>e?.has(t)??!1,u=e=>l(e)||0==(e=>e.size)(e),h=e=>[...e?.values()??[]],f=e=>e.clear(),I=(e,t)=>e?.forEach(t),g=(e,t)=>e?.delete(t),S=e=>new Map(e),w=e=>[...e?.keys()??[]],L=(e,t)=>e?.get(t),p=(e,t)=>I(e,((e,n)=>t(n,e))),v=(e,t,n)=>l(n)?(g(e,t),e):e?.set(t,n),x=(e,t,n)=>(a(e,t)||e.set(t,n()),L(e,t)),E=(e,t,n,s,o=0)=>i((n?x:L)(e,t[o],o>c(t)-2?n:S),(r=>{if(o>c(t)-2)return s?.(r)&&v(e,t[o]),r;const d=E(r,t,n,s,o+1);return u(r)&&v(e,t[o]),d})),R=e=>new Set(e),b=(e,t)=>e?.add(t),y=(e,t,n)=>{const s=e.hasRow,o=S(),d=S(),E=S(),y=S(),T=S(),k=(t,n,...s)=>{const o=x(T,t,R);return r(s,(t=>b(o,t)&&n&&e.callListener(t))),s},z=(t,...n)=>i(L(T,t),(s=>{r(0==c(n)?h(s):n,(t=>{e.delListener(t),g(s,t)})),u(s)&&v(T,t)})),C=(e,n)=>{v(o,e,n),a(d,e)||(v(d,e,t()),v(E,e,S()),v(y,e,S()))},D=e=>{v(o,e),v(d,e),v(E,e),v(y,e),z(e)};return[()=>e,()=>w(o),e=>p(d,e),e=>a(d,e),e=>L(o,e),e=>L(d,e),(e,t)=>v(d,e,t),C,(t,o,c,d,i)=>{C(t,o);const u=S(),h=S(),g=L(E,t),w=L(y,t),x=t=>{const r=n=>e.getCell(o,t,n),c=L(g,t),a=s(o,t)?n(d(r,t)):void 0;if(c!=a&&v(u,t,[c,a]),!l(i)){const e=L(w,t),n=s(o,t)?i(r,t):void 0;e!=n&&v(h,t,n)}},R=e=>{c((()=>{I(u,(([,e],t)=>v(g,t,e))),I(h,((e,t)=>v(w,t,e)))}),u,h,g,w,e),f(u),f(h)};p(g,x),e.hasTable(o)&&r(e.getRowIds(o),(e=>{a(g,e)||x(e)})),R(!0),z(t),k(t,0,e.addRowListener(o,null,((e,t,n)=>x(n))),e.addTableListener(o,(()=>R())))},D,()=>p(T,D),k,z]},T=(n,s)=>e(n)==t?e=>e(n):n??(()=>s??""),k=(e,t)=>e<t?-1:1,z=(e,t=[""])=>{const n=[],s=(e,o)=>o==c(t)?d(n,e):r([t[o],null],(t=>s(L(e,t),o+1)));return s(e,0),n},C=Object.freeze,D=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((e=>{const t=S(),f=S(),[x,D,M,j,O,W,m,,q,A,B]=y(e,S,(e=>l(e)?"":e+"")),[F,G,H]=(e=>{let t,s=0;const o=[],a=S();return[(n,r,c)=>{t??=e();const d=o.pop()??""+s++;return v(a,d,[n,r,c]),b(E(r,c??[""],R),d),d},(e,n,...s)=>r(z(e,n),(e=>I(e,(e=>i(L(a,e),(([e])=>e(t,...n??[],...s))))))),e=>i(L(a,e),(([,t,n])=>(E(t,n??[""],void 0,(t=>(g(t,e),u(t)?1:0))),v(a,e),c(o)<1e3&&d(o,e),n))),(e,t)=>!n(z(e,t),l),(e,n,s)=>i(L(a,e),(([e,,o=[]])=>{const d=(...i)=>{const a=c(i);a==c(o)?e(t,...i,...s(i)):l(o[a])?r(n[a](...i),(e=>d(...i,e))):d(...i,o[a])};d()}))]})((()=>K)),J=(t,n,s)=>{const o=O(t);I(s,((t,s)=>n(s,(n=>I(t,(t=>n(t,(n=>e.forEachCell(o,t,n)))))))))},K={setIndexDefinition:(e,n,r,c,d,h=k)=>{const w=l(d)?void 0:([e],[t])=>d(e,t);return q(e,n,((n,r,d,x,E,y)=>{let T=0;const k=R(),z=R(),C=W(e);if(I(r,(([e,t],n)=>{l(e)||(b(k,e),i(L(C,e),(t=>{g(t,n),u(t)&&(v(C,e),T=1)}))),l(t)||(b(k,t),a(C,t)||(v(C,t,R()),T=1),b(L(C,t),n),l(c)||b(z,t))})),n(),u(E)||(y?p(C,(e=>b(z,e))):p(d,(e=>i(L(x,e),(e=>b(z,e))))),I(z,(e=>{const t=(t,n)=>h(L(E,t),L(E,n),e),n=[...L(C,e)];s(n,t)||(v(C,e,R(o(n,t))),b(k,e))}))),(T||y)&&!l(w)){const t=[...C];s(t,w)||(m(e,S(o(t,w))),T=1)}T&&G(t,[e]),I(k,(t=>G(f,[e,t])))}),T(r),i(c,T)),K},delIndexDefinition:e=>(A(e),K),getStore:x,getIndexIds:D,forEachIndex:e=>M(((t,n)=>e(t,(e=>J(t,e,n))))),forEachSlice:(e,t)=>J(e,t,W(e)),hasIndex:j,hasSlice:(e,t)=>a(W(e),t),getTableId:O,getSliceIds:e=>w(W(e)),getSliceRowIds:(e,t)=>h(L(W(e),t)),addSliceIdsListener:(e,n)=>F(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>F(n,f,[e,t]),delListener:e=>(H(e),K),destroy:B,getListenerStats:()=>({})};return C(K)}));export{D as createIndexes};
|
package/lib/indexes.js.gz
CHANGED
|
Binary file
|
package/lib/metrics.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=e=>typeof e,t=e(""),
|
|
1
|
+
const e=e=>typeof e,t=e(""),n=e(e),r=(e,t)=>e.forEach(t),s=e=>o(e,((e,t)=>e+t),0),i=e=>e.length,o=(e,t,n)=>e.reduce(t,n),c=(e,...t)=>e.push(...t),a=Math.max,d=Math.min,l=isFinite,u=e=>null==e,v=(e,t,n)=>u(e)?n?.():t(e),h=()=>{},g=e=>e.size,M=(e,t)=>e?.has(t)??!1,f=e=>u(e)||0==g(e),p=e=>[...e?.values()??[]],L=e=>e.clear(),m=(e,t)=>e?.forEach(t),w=(e,t)=>e?.delete(t),b=e=>new Map(e),y=(e,t)=>e?.get(t),x=(e,t)=>m(e,((e,n)=>t(n,e))),E=(e,t,n)=>u(n)?(w(e,t),e):e?.set(t,n),I=(e,t,n)=>(M(e,t)||e.set(t,n()),y(e,t)),R=(e,t,n,r,s=0)=>v((n?I:y)(e,t[s],s>i(t)-2?n:b),(o=>{if(s>i(t)-2)return r?.(o)&&E(e,t[s]),o;const c=R(o,t,n,r,s+1);return f(o)&&E(e,t[s]),c})),S=b([["avg",[(e,t)=>s(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=>a(...e),(e,t)=>a(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:a(t,e)]],["min",[e=>d(...e),(e,t)=>d(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:d(t,e)]],["sum",[e=>s(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),T=e=>new Set(e),k=(e,t)=>e?.add(t),z=(e,t,n)=>{const s=e.hasRow,o=b(),c=b(),a=b(),d=b(),l=b(),h=(t,n,...s)=>{const i=I(l,t,T);return r(s,(t=>k(i,t)&&n&&e.callListener(t))),s},g=(t,...n)=>v(y(l,t),(s=>{r(0==i(n)?p(s):n,(t=>{e.delListener(t),w(s,t)})),f(s)&&E(l,t)})),R=(e,n)=>{E(o,e,n),M(c,e)||(E(c,e,t()),E(a,e,b()),E(d,e,b()))},S=e=>{E(o,e),E(c,e),E(a,e),E(d,e),g(e)};return[()=>e,()=>[...o?.keys()??[]],e=>x(c,e),e=>M(c,e),e=>y(o,e),e=>y(c,e),(e,t)=>E(c,e,t),R,(t,i,o,c,l)=>{R(t,i);const v=b(),f=b(),p=y(a,t),w=y(d,t),I=t=>{const r=n=>e.getCell(i,t,n),o=y(p,t),a=s(i,t)?n(c(r,t)):void 0;if(o!=a&&E(v,t,[o,a]),!u(l)){const e=y(w,t),n=s(i,t)?l(r,t):void 0;e!=n&&E(f,t,n)}},S=e=>{o((()=>{m(v,(([,e],t)=>E(p,t,e))),m(f,((e,t)=>E(w,t,e)))}),v,f,p,w,e),L(v),L(f)};x(p,I),e.hasTable(i)&&r(e.getRowIds(i),(e=>{M(p,e)||I(e)})),S(!0),g(t),h(t,0,e.addRowListener(i,null,((e,t,n)=>I(n))),e.addTableListener(i,(()=>S())))},S,()=>x(l,S),h,g]},D=(n,r)=>e(n)==t?e=>e(n):n??(()=>r??""),N=(e,t=[""])=>{const n=[],s=(e,o)=>o==i(t)?c(n,e):r([t[o],null],(t=>s(y(e,t),o+1)));return s(e,0),n},j=Object.freeze,C=(e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))})((t=>{const s=b(),[o,a,d,M,L,x,I,,C,F,O]=z(t,h,(e=>isNaN(e)||u(e)||!0===e||!1===e||""===e?void 0:1*e)),[W,q,A]=(e=>{let t,n=0;const s=[],o=b();return[(r,i,c)=>{t??=e();const a=s.pop()??""+n++;return E(o,a,[r,i,c]),k(R(i,c??[""],T),a),a},(e,n,...s)=>r(N(e,n),(e=>m(e,(e=>v(y(o,e),(([e])=>e(t,...n??[],...s))))))),e=>v(y(o,e),(([,t,n])=>(R(t,n??[""],void 0,(t=>(w(t,e),f(t)?1:0))),E(o,e),i(s)<1e3&&c(s,e),n))),(e,t)=>{return n=N(e,t),r=u,!n.every(r);var n,r},(e,n,s)=>v(y(o,e),(([e,,o=[]])=>{const c=(...a)=>{const d=i(a);d==i(o)?e(t,...a,...s(a)):u(o[d])?r(n[d](...a),(e=>c(...a,e))):c(...a,o[d])};c()}))]})((()=>B)),B={setMetricDefinition:(t,r,i,o,c,a,d)=>{const v=e(i)==n?[i,c,a,d]:y(S,i)??y(S,"sum");return C(t,r,((e,n,r,i,o,c)=>{const a=x(t),d=g(i);c||=u(a),e();let h=((e,t,n,r,s,i=!1)=>{if(f(n))return;const[o,c,a,d]=s;return i||=u(e),m(r,(([n,r])=>{i||(e=u(n)?c?.(e,r,t++):u(r)?a?.(e,n,t--):d?.(e,r,n,t),i||=u(e))})),i?o(p(n),g(n)):e})(a,d,i,n,v,c);l(h)||(h=void 0),h!=a&&(I(t,h),q(s,[t],h,a))}),D(o,1)),B},delMetricDefinition:e=>(F(e),B),getStore:o,getMetricIds:a,forEachMetric:d,hasMetric:M,getTableId:L,getMetric:x,addMetricListener:(e,t)=>W(t,s,[e]),delListener:e=>(A(e),B),destroy:O,getListenerStats:()=>({})};return j(B)}));export{C as createMetrics};
|
package/lib/metrics.js.gz
CHANGED
|
Binary file
|