tinybase 1.3.5 → 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.
Files changed (53) hide show
  1. package/lib/checkpoints.js +1 -1
  2. package/lib/checkpoints.js.gz +0 -0
  3. package/lib/debug/checkpoints.js +67 -54
  4. package/lib/debug/indexes.js +104 -67
  5. package/lib/debug/metrics.js +185 -129
  6. package/lib/debug/persisters.js +2 -1
  7. package/lib/debug/queries.d.ts +3066 -0
  8. package/lib/debug/queries.js +883 -0
  9. package/lib/debug/relationships.d.ts +6 -5
  10. package/lib/debug/relationships.js +102 -66
  11. package/lib/debug/store.d.ts +128 -65
  12. package/lib/debug/store.js +215 -119
  13. package/lib/debug/tinybase.d.ts +1 -0
  14. package/lib/debug/tinybase.js +895 -175
  15. package/lib/debug/ui-react.d.ts +49 -2
  16. package/lib/debug/ui-react.js +85 -74
  17. package/lib/indexes.js +1 -1
  18. package/lib/indexes.js.gz +0 -0
  19. package/lib/metrics.js +1 -1
  20. package/lib/metrics.js.gz +0 -0
  21. package/lib/queries.d.ts +3066 -0
  22. package/lib/queries.js +1 -0
  23. package/lib/queries.js.gz +0 -0
  24. package/lib/relationships.d.ts +6 -5
  25. package/lib/relationships.js +1 -1
  26. package/lib/relationships.js.gz +0 -0
  27. package/lib/store.d.ts +128 -65
  28. package/lib/store.js +1 -1
  29. package/lib/store.js.gz +0 -0
  30. package/lib/tinybase.d.ts +1 -0
  31. package/lib/tinybase.js +1 -1
  32. package/lib/tinybase.js.gz +0 -0
  33. package/lib/ui-react.d.ts +49 -2
  34. package/lib/ui-react.js +1 -1
  35. package/lib/ui-react.js.gz +0 -0
  36. package/lib/umd/checkpoints.js +1 -1
  37. package/lib/umd/checkpoints.js.gz +0 -0
  38. package/lib/umd/indexes.js +1 -1
  39. package/lib/umd/indexes.js.gz +0 -0
  40. package/lib/umd/metrics.js +1 -1
  41. package/lib/umd/metrics.js.gz +0 -0
  42. package/lib/umd/queries.js +1 -0
  43. package/lib/umd/queries.js.gz +0 -0
  44. package/lib/umd/relationships.js +1 -1
  45. package/lib/umd/relationships.js.gz +0 -0
  46. package/lib/umd/store.js +1 -1
  47. package/lib/umd/store.js.gz +0 -0
  48. package/lib/umd/tinybase.js +1 -1
  49. package/lib/umd/tinybase.js.gz +0 -0
  50. package/lib/umd/ui-react.js +1 -1
  51. package/lib/umd/ui-react.js.gz +0 -0
  52. package/package.json +1 -1
  53. package/readme.md +2 -2
@@ -8,15 +8,17 @@ const FUNCTION = getTypeOf(getTypeOf);
8
8
  const TYPE = 'type';
9
9
  const DEFAULT = 'default';
10
10
 
11
- const arrayPair = (value) => [value, value];
12
11
  const arrayHas = (array, value) => array.includes(value);
12
+ const arrayEvery = (array, cb) => array.every(cb);
13
+ const arrayIsEqual = (array1, array2) =>
14
+ arrayLength(array1) === arrayLength(array2) &&
15
+ arrayEvery(array1, (value1, index) => array2[index] === value1);
13
16
  const arrayForEach = (array, cb) => array.forEach(cb);
14
17
  const arrayLength = (array) => array.length;
15
18
  const arrayIsEmpty = (array) => arrayLength(array) == 0;
16
19
  const arrayReduce = (array, cb, initial) => array.reduce(cb, initial);
17
20
  const arrayFilter = (array, cb) => array.filter(cb);
18
- const arrayFromSecond = (ids) => ids.slice(1);
19
- const arrayPush = (array, value) => array.push(value);
21
+ const arrayPush = (array, ...values) => array.push(...values);
20
22
  const arrayPop = (array) => array.pop();
21
23
 
22
24
  const jsonString = (obj) =>
@@ -47,7 +49,6 @@ const collSize = (coll) => coll.size;
47
49
  const collSize2 = collSizeN(collSize);
48
50
  const collSize3 = collSizeN(collSize2);
49
51
  const collSize4 = collSizeN(collSize3);
50
- const collPairSize = (pair, func = collSize) => func(pair[0]) + func(pair[1]);
51
52
  const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
52
53
  const collIsEmpty = (coll) => isUndefined(coll) || collSize(coll) == 0;
53
54
  const collValues = (coll) => [...(coll?.values() ?? [])];
@@ -56,7 +57,6 @@ const collForEach = (coll, cb) => coll?.forEach(cb);
56
57
  const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
57
58
 
58
59
  const mapNew = (entries) => new Map(entries);
59
- const mapNewPair = (newFunction = mapNew) => [newFunction(), newFunction()];
60
60
  const mapKeys = (map) => [...(map?.keys() ?? [])];
61
61
  const mapGet = (map, key) => map?.get(key);
62
62
  const mapForEach = (map, cb) =>
@@ -86,6 +86,27 @@ const mapClone = (map, childMapper) => {
86
86
  return map2;
87
87
  };
88
88
  const mapClone2 = (map) => mapClone(map, mapClone);
89
+ const visitTree = (node, path, ensureLeaf, pruneLeaf, p = 0) =>
90
+ ifNotUndefined(
91
+ (ensureLeaf ? mapEnsure : mapGet)(
92
+ node,
93
+ path[p],
94
+ p > arrayLength(path) - 2 ? ensureLeaf : mapNew,
95
+ ),
96
+ (nodeOrLeaf) => {
97
+ if (p > arrayLength(path) - 2) {
98
+ if (pruneLeaf?.(nodeOrLeaf)) {
99
+ mapSet(node, path[p]);
100
+ }
101
+ return nodeOrLeaf;
102
+ }
103
+ const leaf = visitTree(nodeOrLeaf, path, ensureLeaf, pruneLeaf, p + 1);
104
+ if (collIsEmpty(nodeOrLeaf)) {
105
+ mapSet(node, path[p]);
106
+ }
107
+ return leaf;
108
+ },
109
+ );
89
110
 
90
111
  const object = Object;
91
112
  const objIds = object.keys;
@@ -103,64 +124,51 @@ const objIsEmpty = (obj) => arrayIsEmpty(objIds(obj));
103
124
  const setNew = (entries) => new Set(entries);
104
125
  const setAdd = (set, value) => set?.add(value);
105
126
 
106
- const addDeepSet = (deepSet, value, ids) =>
107
- arrayLength(ids) < 2
108
- ? setAdd(
109
- arrayIsEmpty(ids) ? deepSet : mapEnsure(deepSet, ids[0], setNew),
110
- value,
111
- )
112
- : addDeepSet(
113
- mapEnsure(deepSet, ids[0], mapNew),
114
- value,
115
- arrayFromSecond(ids),
116
- );
117
- const forDeepSet = (valueDo) => {
118
- const deep = (deepIdSet, arg, ...ids) =>
119
- ifNotUndefined(deepIdSet, (deepIdSet2) =>
120
- arrayIsEmpty(ids)
121
- ? valueDo(deepIdSet2, arg)
122
- : arrayForEach([ids[0], null], (id) =>
123
- deep(mapGet(deepIdSet2, id), arg, ...arrayFromSecond(ids)),
124
- ),
125
- );
126
- return deep;
127
+ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
128
+ const sets = [];
129
+ const deep = (set, p) =>
130
+ p == arrayLength(path)
131
+ ? arrayPush(sets, set)
132
+ : arrayForEach([path[p], null], (id) => deep(mapGet(set, id), p + 1));
133
+ deep(deepIdSet, 0);
134
+ return sets;
127
135
  };
128
136
  const getListenerFunctions = (getThing) => {
129
137
  let thing;
130
138
  let nextId = 0;
131
139
  const listenerPool = [];
132
140
  const allListeners = mapNew();
133
- const addListener = (listener, deepSet, idOrNulls = []) => {
141
+ const addListener = (listener, idSetNode, idOrNulls) => {
134
142
  thing ??= getThing();
135
- const id = arrayPop(listenerPool) ?? '' + nextId++;
136
- mapSet(allListeners, id, [listener, deepSet, idOrNulls]);
137
- addDeepSet(deepSet, id, idOrNulls);
143
+ const id = arrayPop(listenerPool) ?? EMPTY_STRING + nextId++;
144
+ mapSet(allListeners, id, [listener, idSetNode, idOrNulls]);
145
+ setAdd(visitTree(idSetNode, idOrNulls ?? [EMPTY_STRING], setNew), id);
138
146
  return id;
139
147
  };
140
- const callListeners = (deepSet, ids = [], ...extraArgs) =>
141
- forDeepSet(collForEach)(
142
- deepSet,
143
- (id) =>
148
+ const callListeners = (idSetNode, ids, ...extraArgs) =>
149
+ arrayForEach(getWildcardedLeaves(idSetNode, ids), (set) =>
150
+ collForEach(set, (id) =>
144
151
  ifNotUndefined(mapGet(allListeners, id), ([listener]) =>
145
- listener(thing, ...ids, ...extraArgs),
152
+ listener(thing, ...(ids ?? []), ...extraArgs),
146
153
  ),
147
- ...ids,
154
+ ),
148
155
  );
149
156
  const delListener = (id) =>
150
- ifNotUndefined(
151
- mapGet(allListeners, id),
152
- ([, deepSet, idOrNulls]) => {
153
- forDeepSet(collDel)(deepSet, id, ...idOrNulls);
154
- mapSet(allListeners, id);
155
- if (arrayLength(listenerPool) < 1e3) {
156
- arrayPush(listenerPool, id);
157
- }
158
- return idOrNulls;
159
- },
160
- () => [],
161
- );
157
+ ifNotUndefined(mapGet(allListeners, id), ([, idSetNode, idOrNulls]) => {
158
+ visitTree(idSetNode, idOrNulls ?? [EMPTY_STRING], void 0, (idSet) => {
159
+ collDel(idSet, id);
160
+ return collIsEmpty(idSet) ? 1 : 0;
161
+ });
162
+ mapSet(allListeners, id);
163
+ if (arrayLength(listenerPool) < 1e3) {
164
+ arrayPush(listenerPool, id);
165
+ }
166
+ return idOrNulls;
167
+ });
168
+ const hasListeners = (idSetNode, ids) =>
169
+ !arrayEvery(getWildcardedLeaves(idSetNode, ids), isUndefined);
162
170
  const callListener = (id, idNullGetters, extraArgsGetter) =>
163
- ifNotUndefined(mapGet(allListeners, id), ([listener, , idOrNulls]) => {
171
+ ifNotUndefined(mapGet(allListeners, id), ([listener, , idOrNulls = []]) => {
164
172
  const callWithIds = (...ids) => {
165
173
  const index = arrayLength(ids);
166
174
  index == arrayLength(idOrNulls)
@@ -173,7 +181,22 @@ const getListenerFunctions = (getThing) => {
173
181
  };
174
182
  callWithIds();
175
183
  });
176
- return [addListener, callListeners, delListener, callListener];
184
+ return [addListener, callListeners, delListener, hasListeners, callListener];
185
+ };
186
+
187
+ const pairNew = (value) => [value, value];
188
+ const pairCollSize2 = (pair, func = collSize2) => func(pair[0]) + func(pair[1]);
189
+ const pairCollIsEmpty = (pair) => pairCollSize2(pair) == 0;
190
+ const pairNewMap = () => [mapNew(), mapNew()];
191
+ const pair2CollSize2 = (pair2, func = collSize2) =>
192
+ pairCollSize2(pair2[0], func) + pairCollSize2(pair2[1], func);
193
+ const pair2NewMap = () => [pairNewMap(), pairNewMap()];
194
+
195
+ const getCellType = (cell) => {
196
+ const type = getTypeOf(cell);
197
+ return isTypeStringOrBoolean(type) || (type == NUMBER && isFiniteNumber(cell))
198
+ ? type
199
+ : void 0;
177
200
  };
178
201
 
179
202
  const transformMap = (map, toBeLikeObject, setId, delId = mapSet) => {
@@ -187,12 +210,6 @@ const transformMap = (map, toBeLikeObject, setId, delId = mapSet) => {
187
210
  arrayForEach(idsToDelete, (id) => delId(map, id));
188
211
  return map;
189
212
  };
190
- const getCellType = (cell) => {
191
- const type = getTypeOf(cell);
192
- return isTypeStringOrBoolean(type) || (type == NUMBER && isFiniteNumber(cell))
193
- ? type
194
- : void 0;
195
- };
196
213
  const validate = (obj, validateChild, onInvalidObj) => {
197
214
  if (isUndefined(obj) || !isObject(obj) || objIsEmpty(obj) || objFrozen(obj)) {
198
215
  onInvalidObj?.();
@@ -205,8 +222,8 @@ const validate = (obj, validateChild, onInvalidObj) => {
205
222
  });
206
223
  return !objIsEmpty(obj);
207
224
  };
208
- const idsChanged = (ids, id, added) =>
209
- mapSet(ids, id, mapGet(ids, id) == -added ? void 0 : added);
225
+ const idsChanged = (changedIds, id, added) =>
226
+ mapSet(changedIds, id, mapGet(changedIds, id) == -added ? void 0 : added);
210
227
  const createStore = () => {
211
228
  let hasSchema;
212
229
  let cellsTouched;
@@ -220,17 +237,22 @@ const createStore = () => {
220
237
  const schemaMap = mapNew();
221
238
  const schemaRowCache = mapNew();
222
239
  const tablesMap = mapNew();
223
- const tablesListeners = mapNewPair(setNew);
224
- const tableIdsListeners = mapNewPair(setNew);
225
- const tableListeners = mapNewPair();
226
- const rowIdsListeners = mapNewPair();
227
- const rowListeners = mapNewPair();
228
- const cellIdsListeners = mapNewPair();
229
- const cellListeners = mapNewPair();
230
- const invalidCellListeners = mapNewPair();
231
- const finishTransactionListeners = mapNewPair(setNew);
232
- const [addListener, callListeners, delListenerImpl, callListenerImpl] =
233
- getListenerFunctions(() => store);
240
+ const tablesListeners = pairNewMap();
241
+ const tableIdsListeners = pair2NewMap();
242
+ const tableListeners = pairNewMap();
243
+ const rowIdsListeners = pair2NewMap();
244
+ const rowListeners = pairNewMap();
245
+ const cellIdsListeners = pair2NewMap();
246
+ const cellListeners = pairNewMap();
247
+ const invalidCellListeners = pairNewMap();
248
+ const finishTransactionListeners = pairNewMap();
249
+ const [
250
+ addListener,
251
+ callListeners,
252
+ delListenerImpl,
253
+ hasListeners,
254
+ callListenerImpl,
255
+ ] = getListenerFunctions(() => store);
234
256
  const validateSchema = (schema) =>
235
257
  validate(schema, (tableSchema) =>
236
258
  validate(tableSchema, (cellSchema) => {
@@ -381,7 +403,7 @@ const createStore = () => {
381
403
  ),
382
404
  );
383
405
  const getNewRowId = (tableMap) => {
384
- const rowId = '' + nextRowId++;
406
+ const rowId = EMPTY_STRING + nextRowId++;
385
407
  if (!collHas(tableMap, rowId)) {
386
408
  return rowId;
387
409
  }
@@ -412,12 +434,49 @@ const createStore = () => {
412
434
  }
413
435
  };
414
436
  const tableIdsChanged = (tableId, added) =>
415
- idsChanged(changedTableIds, tableId, added);
437
+ idsChanged(
438
+ collIsEmpty(changedTableIds)
439
+ ? mapSet(
440
+ changedTableIds,
441
+ null,
442
+ hasListeners(tableIdsListeners[0][1]) ||
443
+ hasListeners(tableIdsListeners[1][1])
444
+ ? getTableIds()
445
+ : 0,
446
+ )
447
+ : changedTableIds,
448
+ tableId,
449
+ added,
450
+ );
416
451
  const rowIdsChanged = (tableId, rowId, added) =>
417
- idsChanged(mapEnsure(changedRowIds, tableId, mapNew), rowId, added);
452
+ idsChanged(
453
+ mapEnsure(changedRowIds, tableId, () =>
454
+ mapNew([
455
+ [
456
+ null,
457
+ hasListeners(rowIdsListeners[0][1], [tableId]) ||
458
+ hasListeners(rowIdsListeners[1][1], [tableId])
459
+ ? getRowIds(tableId)
460
+ : 0,
461
+ ],
462
+ ]),
463
+ ),
464
+ rowId,
465
+ added,
466
+ );
418
467
  const cellIdsChanged = (tableId, rowId, cellId, added) =>
419
468
  idsChanged(
420
- mapEnsure(mapEnsure(changedCellIds, tableId, mapNew), rowId, mapNew),
469
+ mapEnsure(mapEnsure(changedCellIds, tableId, mapNew), rowId, () =>
470
+ mapNew([
471
+ [
472
+ null,
473
+ hasListeners(cellIdsListeners[0][1], [tableId, rowId]) ||
474
+ hasListeners(cellIdsListeners[1][1], [tableId, rowId])
475
+ ? getCellIds(tableId, rowId)
476
+ : 0,
477
+ ],
478
+ ]),
479
+ ),
421
480
  cellId,
422
481
  added,
423
482
  );
@@ -442,7 +501,7 @@ const createStore = () => {
442
501
  ifNotUndefined(
443
502
  mapGet(mapGet(mapGet(changedCells, tableId), rowId), cellId),
444
503
  ([oldCell, newCell]) => [true, oldCell, newCell],
445
- () => [false, ...arrayPair(getCell(tableId, rowId, cellId))],
504
+ () => [false, ...pairNew(getCell(tableId, rowId, cellId))],
446
505
  );
447
506
  const callInvalidCellListeners = (mutator) =>
448
507
  !collIsEmpty(invalidCells) && !collIsEmpty(invalidCellListeners[mutator])
@@ -460,17 +519,29 @@ const createStore = () => {
460
519
  ),
461
520
  )
462
521
  : 0;
522
+ const callIdsListenersIfChanged = (listeners, changedIds, getIds, ids) => {
523
+ if (collSize(changedIds) > 1) {
524
+ callListeners(listeners[0], ids);
525
+ callListeners(listeners[1], ids);
526
+ } else if (
527
+ !collIsEmpty(changedIds) &&
528
+ mapGet(changedIds, null) != 0 &&
529
+ !arrayIsEqual(mapGet(changedIds, null), getIds(...(ids ?? [])))
530
+ ) {
531
+ callListeners(listeners[1], ids);
532
+ }
533
+ };
463
534
  const callListenersForChanges = (mutator) => {
464
535
  const emptyIdListeners =
465
- collIsEmpty(cellIdsListeners[mutator]) &&
466
- collIsEmpty(rowIdsListeners[mutator]) &&
467
- collIsEmpty(tableIdsListeners[mutator]);
536
+ pairCollIsEmpty(cellIdsListeners[mutator]) &&
537
+ pairCollIsEmpty(rowIdsListeners[mutator]) &&
538
+ pairCollIsEmpty(tableIdsListeners[mutator]);
468
539
  const emptyOtherListeners =
469
540
  collIsEmpty(cellListeners[mutator]) &&
470
541
  collIsEmpty(rowListeners[mutator]) &&
471
542
  collIsEmpty(tableListeners[mutator]) &&
472
543
  collIsEmpty(tablesListeners[mutator]);
473
- if (!(emptyIdListeners && emptyOtherListeners)) {
544
+ if (!emptyIdListeners || !emptyOtherListeners) {
474
545
  const changes = mutator
475
546
  ? [
476
547
  mapClone(changedTableIds),
@@ -481,20 +552,28 @@ const createStore = () => {
481
552
  : [changedTableIds, changedRowIds, changedCellIds, changedCells];
482
553
  if (!emptyIdListeners) {
483
554
  collForEach(changes[2], (rowCellIds, tableId) =>
484
- collForEach(rowCellIds, (changedIds, rowId) => {
485
- if (!collIsEmpty(changedIds)) {
486
- callListeners(cellIdsListeners[mutator], [tableId, rowId]);
487
- }
488
- }),
555
+ collForEach(rowCellIds, (changedIds, rowId) =>
556
+ callIdsListenersIfChanged(
557
+ cellIdsListeners[mutator],
558
+ changedIds,
559
+ getCellIds,
560
+ [tableId, rowId],
561
+ ),
562
+ ),
563
+ );
564
+ collForEach(changes[1], (changedIds, tableId) =>
565
+ callIdsListenersIfChanged(
566
+ rowIdsListeners[mutator],
567
+ changedIds,
568
+ getRowIds,
569
+ [tableId],
570
+ ),
571
+ );
572
+ callIdsListenersIfChanged(
573
+ tableIdsListeners[mutator],
574
+ changes[0],
575
+ getTableIds,
489
576
  );
490
- collForEach(changes[1], (changedIds, tableId) => {
491
- if (!collIsEmpty(changedIds)) {
492
- callListeners(rowIdsListeners[mutator], [tableId]);
493
- }
494
- });
495
- if (!collIsEmpty(changes[0])) {
496
- callListeners(tableIdsListeners[mutator]);
497
- }
498
577
  }
499
578
  if (!emptyOtherListeners) {
500
579
  let tablesChanged;
@@ -527,7 +606,7 @@ const createStore = () => {
527
606
  }
528
607
  });
529
608
  if (tablesChanged) {
530
- callListeners(tablesListeners[mutator], [], getCellChange);
609
+ callListeners(tablesListeners[mutator], void 0, getCellChange);
531
610
  }
532
611
  }
533
612
  }
@@ -568,16 +647,15 @@ const createStore = () => {
568
647
  ? setValidRow(tableId, getOrCreateTable(tableId), rowId, row)
569
648
  : 0,
570
649
  );
571
- const addRow = (tableId, row) =>
650
+ const addRow = (tableId, row, forceId) =>
572
651
  transaction(() => {
573
- let rowId = void 0;
574
- if (validateRow(tableId, rowId, row)) {
575
- setValidRow(
576
- tableId,
577
- getOrCreateTable(tableId),
578
- (rowId = getNewRowId(mapGet(tablesMap, tableId))),
579
- row,
580
- );
652
+ const isValidRow = validateRow(tableId, void 0, row);
653
+ const rowId =
654
+ isValidRow || forceId
655
+ ? getNewRowId(mapGet(tablesMap, tableId))
656
+ : void 0;
657
+ if (isValidRow) {
658
+ setValidRow(tableId, getOrCreateTable(tableId), rowId, row);
581
659
  }
582
660
  return rowId;
583
661
  });
@@ -709,12 +787,12 @@ const createStore = () => {
709
787
  transactions = -1;
710
788
  cellsTouched = false;
711
789
  }
712
- callListeners(finishTransactionListeners[0], [], cellsTouched);
790
+ callListeners(finishTransactionListeners[0], void 0, cellsTouched);
713
791
  callInvalidCellListeners(0);
714
792
  if (cellsTouched) {
715
793
  callListenersForChanges(0);
716
794
  }
717
- callListeners(finishTransactionListeners[1], [], cellsTouched);
795
+ callListeners(finishTransactionListeners[1], void 0, cellsTouched);
718
796
  transactions = 0;
719
797
  arrayForEach(
720
798
  [
@@ -748,16 +826,33 @@ const createStore = () => {
748
826
  mapForEach(mapGet(mapGet(tablesMap, tableId), rowId), cellCallback);
749
827
  const addTablesListener = (listener, mutator) =>
750
828
  addListener(listener, tablesListeners[mutator ? 1 : 0]);
751
- const addTableIdsListener = (listener, mutator) =>
752
- addListener(listener, tableIdsListeners[mutator ? 1 : 0]);
829
+ const addTableIdsListener = (listener, trackReorder, mutator) =>
830
+ addListener(
831
+ listener,
832
+ tableIdsListeners[mutator ? 1 : 0][trackReorder ? 1 : 0],
833
+ );
753
834
  const addTableListener = (tableId, listener, mutator) =>
754
835
  addListener(listener, tableListeners[mutator ? 1 : 0], [tableId]);
755
- const addRowIdsListener = (tableId, listener, mutator) =>
756
- addListener(listener, rowIdsListeners[mutator ? 1 : 0], [tableId]);
836
+ const addRowIdsListener = (tableId, listener, trackReorder, mutator) =>
837
+ addListener(
838
+ listener,
839
+ rowIdsListeners[mutator ? 1 : 0][trackReorder ? 1 : 0],
840
+ [tableId],
841
+ );
757
842
  const addRowListener = (tableId, rowId, listener, mutator) =>
758
843
  addListener(listener, rowListeners[mutator ? 1 : 0], [tableId, rowId]);
759
- const addCellIdsListener = (tableId, rowId, listener, mutator) =>
760
- addListener(listener, cellIdsListeners[mutator ? 1 : 0], [tableId, rowId]);
844
+ const addCellIdsListener = (
845
+ tableId,
846
+ rowId,
847
+ listener,
848
+ trackReorder,
849
+ mutator,
850
+ ) =>
851
+ addListener(
852
+ listener,
853
+ cellIdsListeners[mutator ? 1 : 0][trackReorder ? 1 : 0],
854
+ [tableId, rowId],
855
+ );
761
856
  const addCellListener = (tableId, rowId, cellId, listener, mutator) =>
762
857
  addListener(listener, cellListeners[mutator ? 1 : 0], [
763
858
  tableId,
@@ -776,7 +871,7 @@ const createStore = () => {
776
871
  addListener(listener, finishTransactionListeners[1]);
777
872
  const callListener = (listenerId) => {
778
873
  callListenerImpl(listenerId, [getTableIds, getRowIds, getCellIds], (ids) =>
779
- isUndefined(ids[2]) ? [] : arrayPair(getCell(...ids)),
874
+ isUndefined(ids[2]) ? [] : pairNew(getCell(...ids)),
780
875
  );
781
876
  return store;
782
877
  };
@@ -785,15 +880,15 @@ const createStore = () => {
785
880
  return store;
786
881
  };
787
882
  const getListenerStats = () => ({
788
- tables: collPairSize(tablesListeners),
789
- tableIds: collPairSize(tableIdsListeners),
790
- table: collPairSize(tableListeners, collSize2),
791
- rowIds: collPairSize(rowIdsListeners, collSize2),
792
- row: collPairSize(rowListeners, collSize3),
793
- cellIds: collPairSize(cellIdsListeners, collSize3),
794
- cell: collPairSize(cellListeners, collSize4),
795
- invalidCell: collPairSize(invalidCellListeners, collSize4),
796
- transaction: collPairSize(finishTransactionListeners),
883
+ tables: pairCollSize2(tablesListeners),
884
+ tableIds: pair2CollSize2(tableIdsListeners),
885
+ table: pairCollSize2(tableListeners),
886
+ rowIds: pair2CollSize2(rowIdsListeners),
887
+ row: pairCollSize2(rowListeners, collSize3),
888
+ cellIds: pair2CollSize2(cellIdsListeners, collSize3),
889
+ cell: pairCollSize2(cellListeners, collSize4),
890
+ invalidCell: pairCollSize2(invalidCellListeners, collSize4),
891
+ transaction: pairCollSize2(finishTransactionListeners),
797
892
  });
798
893
  const store = {
799
894
  getTables,
@@ -841,6 +936,7 @@ const createStore = () => {
841
936
  callListener,
842
937
  delListener,
843
938
  getListenerStats,
939
+ createStore,
844
940
  };
845
941
  return objFreeze(store);
846
942
  };
@@ -9,5 +9,6 @@ export * from './common';
9
9
  export * from './indexes';
10
10
  export * from './metrics';
11
11
  export * from './persisters';
12
+ export * from './queries';
12
13
  export * from './relationships';
13
14
  export * from './store';