tinybase 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
  2. package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
  3. package/lib/cjs/ui-react.cjs +1 -1
  4. package/lib/cjs/ui-react.cjs.gz +0 -0
  5. package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
  6. package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
  7. package/lib/cjs-es6/ui-react.cjs +1 -1
  8. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  9. package/lib/debug/checkpoints.js +8 -8
  10. package/lib/debug/indexes.js +8 -8
  11. package/lib/debug/metrics.js +8 -8
  12. package/lib/debug/persisters/persister-automerge.js +23 -23
  13. package/lib/debug/persisters/persister-partykit-server.js +35 -21
  14. package/lib/debug/persisters/persister-yjs.js +23 -23
  15. package/lib/debug/queries.js +10 -10
  16. package/lib/debug/relationships.js +6 -6
  17. package/lib/debug/store.js +10 -10
  18. package/lib/debug/tinybase.js +24 -24
  19. package/lib/debug/tools.js +2 -2
  20. package/lib/debug/ui-react-dom.js +12 -12
  21. package/lib/debug/ui-react.js +56 -22
  22. package/lib/es6/persisters/persister-partykit-server.js +1 -1
  23. package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
  24. package/lib/es6/ui-react.js +1 -1
  25. package/lib/es6/ui-react.js.gz +0 -0
  26. package/lib/persisters/persister-partykit-server.js +1 -1
  27. package/lib/persisters/persister-partykit-server.js.gz +0 -0
  28. package/lib/types/metrics.d.ts +2 -2
  29. package/lib/types/persisters/persister-partykit-server.d.ts +58 -2
  30. package/lib/types/persisters/persister-remote.d.ts +6 -1
  31. package/lib/types/queries.d.ts +2 -45
  32. package/lib/types/ui-react.d.ts +53 -0
  33. package/lib/types/with-schemas/metrics.d.ts +2 -2
  34. package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +61 -0
  35. package/lib/types/with-schemas/persisters/persister-remote.d.ts +6 -1
  36. package/lib/types/with-schemas/queries.d.ts +2 -45
  37. package/lib/types/with-schemas/store.d.ts +8 -8
  38. package/lib/types/with-schemas/ui-react.d.ts +59 -0
  39. package/lib/ui-react.js +1 -1
  40. package/lib/ui-react.js.gz +0 -0
  41. package/lib/umd/persisters/persister-partykit-server.js +1 -1
  42. package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
  43. package/lib/umd/ui-react.js +1 -1
  44. package/lib/umd/ui-react.js.gz +0 -0
  45. package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
  46. package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
  47. package/lib/umd-es6/ui-react.js +1 -1
  48. package/lib/umd-es6/ui-react.js.gz +0 -0
  49. package/package.json +19 -19
  50. package/readme.md +2 -2
@@ -268,8 +268,8 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
268
268
  p == size(path)
269
269
  ? arrayPush(leaves, node)
270
270
  : path[p] === null
271
- ? collForEach(node, (node2) => deep(node2, p + 1))
272
- : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
271
+ ? collForEach(node, (node2) => deep(node2, p + 1))
272
+ : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
273
273
  deep(deepIdSet, 0);
274
274
  return leaves;
275
275
  };
@@ -321,10 +321,10 @@ const getListenerFunctions = (getThing) => {
321
321
  index == size(path)
322
322
  ? listener(thing, ...ids, ...extraArgsGetter(ids))
323
323
  : isUndefined(path[index])
324
- ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
325
- callWithIds(...ids, id2),
326
- )
327
- : callWithIds(...ids, path[index]);
324
+ ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
325
+ callWithIds(...ids, id2),
326
+ )
327
+ : callWithIds(...ids, path[index]);
328
328
  };
329
329
  callWithIds();
330
330
  },
@@ -182,8 +182,8 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
182
182
  p == size(path)
183
183
  ? arrayPush(leaves, node)
184
184
  : path[p] === null
185
- ? collForEach(node, (node2) => deep(node2, p + 1))
186
- : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
185
+ ? collForEach(node, (node2) => deep(node2, p + 1))
186
+ : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
187
187
  deep(deepIdSet, 0);
188
188
  return leaves;
189
189
  };
@@ -235,10 +235,10 @@ const getListenerFunctions = (getThing) => {
235
235
  index == size(path)
236
236
  ? listener(thing, ...ids, ...extraArgsGetter(ids))
237
237
  : isUndefined(path[index])
238
- ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
239
- callWithIds(...ids, id2),
240
- )
241
- : callWithIds(...ids, path[index]);
238
+ ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
239
+ callWithIds(...ids, id2),
240
+ )
241
+ : callWithIds(...ids, path[index]);
242
242
  };
243
243
  callWithIds();
244
244
  },
@@ -400,8 +400,8 @@ const createStore = () => {
400
400
  () => cellInvalid(tableId, rowId, cellId, cell),
401
401
  )
402
402
  : isUndefined(getCellOrValueType(cell))
403
- ? cellInvalid(tableId, rowId, cellId, cell)
404
- : cell;
403
+ ? cellInvalid(tableId, rowId, cellId, cell)
404
+ : cell;
405
405
  const validateValues = (values, skipDefaults) =>
406
406
  validate(
407
407
  skipDefaults ? values : addDefaultsToValues(values),
@@ -427,8 +427,8 @@ const createStore = () => {
427
427
  () => valueInvalid(valueId, value),
428
428
  )
429
429
  : isUndefined(getCellOrValueType(value))
430
- ? valueInvalid(valueId, value)
431
- : value;
430
+ ? valueInvalid(valueId, value)
431
+ : value;
432
432
  const addDefaultsToRow = (row, tableId, rowId) => {
433
433
  ifNotUndefined(
434
434
  mapGet(tablesSchemaRowCache, tableId),
@@ -386,8 +386,8 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
386
386
  p == size(path)
387
387
  ? arrayPush(leaves, node)
388
388
  : path[p] === null
389
- ? collForEach(node, (node2) => deep(node2, p + 1))
390
- : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
389
+ ? collForEach(node, (node2) => deep(node2, p + 1))
390
+ : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
391
391
  deep(deepIdSet, 0);
392
392
  return leaves;
393
393
  };
@@ -439,10 +439,10 @@ const getListenerFunctions = (getThing) => {
439
439
  index == size(path)
440
440
  ? listener(thing, ...ids, ...extraArgsGetter(ids))
441
441
  : isUndefined(path[index])
442
- ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
443
- callWithIds(...ids, id2),
444
- )
445
- : callWithIds(...ids, path[index]);
442
+ ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
443
+ callWithIds(...ids, id2),
444
+ )
445
+ : callWithIds(...ids, path[index]);
446
446
  };
447
447
  callWithIds();
448
448
  },
@@ -621,8 +621,8 @@ const createCheckpoints = getCreateFunction((store) => {
621
621
  const action = arrayHas(backwardIds, checkpointId)
622
622
  ? goBackwardImpl
623
623
  : arrayHas(forwardIds, checkpointId)
624
- ? goForwardImpl
625
- : null;
624
+ ? goForwardImpl
625
+ : null;
626
626
  while (!isUndefined(action) && checkpointId != currentId) {
627
627
  action();
628
628
  }
@@ -707,8 +707,8 @@ const createIndexes = getCreateFunction((store) => {
707
707
  isUndefined(value)
708
708
  ? EMPTY_STRING
709
709
  : isArray(value)
710
- ? arrayMap(value, id)
711
- : id(value),
710
+ ? arrayMap(value, id)
711
+ : id(value),
712
712
  addListener,
713
713
  callListeners,
714
714
  );
@@ -938,8 +938,8 @@ const getAggregateValue = (
938
938
  aggregateValue = isUndefined(oldValue)
939
939
  ? aggregateAdd?.(aggregateValue, newValue, oldLength++)
940
940
  : isUndefined(newValue)
941
- ? aggregateRemove?.(aggregateValue, oldValue, oldLength--)
942
- : aggregateReplace?.(aggregateValue, newValue, oldValue, oldLength);
941
+ ? aggregateRemove?.(aggregateValue, oldValue, oldLength--)
942
+ : aggregateReplace?.(aggregateValue, newValue, oldValue, oldLength);
943
943
  force ||= isUndefined(aggregateValue);
944
944
  }
945
945
  });
@@ -1301,8 +1301,8 @@ const createQueries = getCreateFunction((store) => {
1301
1301
  isFunction(arg1)
1302
1302
  ? arg1
1303
1303
  : isUndefined(arg3)
1304
- ? (getTableCell) => getTableCell(arg1) === arg2
1305
- : (getTableCell) => getTableCell(arg1, arg2) === arg3,
1304
+ ? (getTableCell) => getTableCell(arg1) === arg2
1305
+ : (getTableCell) => getTableCell(arg1, arg2) === arg3,
1306
1306
  );
1307
1307
  const group = (
1308
1308
  selectedCellId,
@@ -1505,12 +1505,12 @@ const createQueries = getCreateFunction((store) => {
1505
1505
  ...(isUndefined(arg2)
1506
1506
  ? [tableId, rootRowId, arg1]
1507
1507
  : arg1 === tableId
1508
- ? [tableId, rootRowId, arg2]
1509
- : [
1510
- mapGet(joins, arg1)?.[0],
1511
- mapGet(mapGet(joins, arg1)?.[4], rootRowId)?.[0],
1512
- arg2,
1513
- ]),
1508
+ ? [tableId, rootRowId, arg2]
1509
+ : [
1510
+ mapGet(joins, arg1)?.[0],
1511
+ mapGet(mapGet(joins, arg1)?.[4], rootRowId)?.[0],
1512
+ arg2,
1513
+ ]),
1514
1514
  );
1515
1515
  selectJoinWhereStore.transaction(() =>
1516
1516
  arrayEvery(wheres, (where2) => where2(getTableCell))
@@ -1980,8 +1980,8 @@ const createStore = () => {
1980
1980
  () => cellInvalid(tableId, rowId, cellId, cell),
1981
1981
  )
1982
1982
  : isUndefined(getCellOrValueType(cell))
1983
- ? cellInvalid(tableId, rowId, cellId, cell)
1984
- : cell;
1983
+ ? cellInvalid(tableId, rowId, cellId, cell)
1984
+ : cell;
1985
1985
  const validateValues = (values, skipDefaults) =>
1986
1986
  validate(
1987
1987
  skipDefaults ? values : addDefaultsToValues(values),
@@ -2007,8 +2007,8 @@ const createStore = () => {
2007
2007
  () => valueInvalid(valueId, value),
2008
2008
  )
2009
2009
  : isUndefined(getCellOrValueType(value))
2010
- ? valueInvalid(valueId, value)
2011
- : value;
2010
+ ? valueInvalid(valueId, value)
2011
+ : value;
2012
2012
  const addDefaultsToRow = (row, tableId, rowId) => {
2013
2013
  ifNotUndefined(
2014
2014
  mapGet(tablesSchemaRowCache, tableId),
@@ -361,8 +361,8 @@ const getCodeFunctions = () => {
361
361
  ? -1
362
362
  : 1
363
363
  : import1 > import2
364
- ? 1
365
- : -1,
364
+ ? 1
365
+ : -1,
366
366
  ),
367
367
  EMPTY_STRING,
368
368
  ],
@@ -575,8 +575,8 @@ const RelationshipInHtmlRow = ({
575
575
  tableId === localTableId
576
576
  ? localRowId
577
577
  : tableId === remoteTableId
578
- ? remoteRowId
579
- : null;
578
+ ? remoteRowId
579
+ : null;
580
580
  return isUndefined(rowId)
581
581
  ? null
582
582
  : /* @__PURE__ */ createElement(
@@ -1796,8 +1796,8 @@ const getWildcardedLeaves = (deepIdSet, path = [EMPTY_STRING]) => {
1796
1796
  p == size(path)
1797
1797
  ? arrayPush(leaves, node)
1798
1798
  : path[p] === null
1799
- ? collForEach(node, (node2) => deep(node2, p + 1))
1800
- : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
1799
+ ? collForEach(node, (node2) => deep(node2, p + 1))
1800
+ : arrayForEach([path[p], null], (id) => deep(mapGet(node, id), p + 1));
1801
1801
  deep(deepIdSet, 0);
1802
1802
  return leaves;
1803
1803
  };
@@ -1849,10 +1849,10 @@ const getListenerFunctions = (getThing) => {
1849
1849
  index == size(path)
1850
1850
  ? listener(thing, ...ids, ...extraArgsGetter(ids))
1851
1851
  : isUndefined(path[index])
1852
- ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
1853
- callWithIds(...ids, id2),
1854
- )
1855
- : callWithIds(...ids, path[index]);
1852
+ ? arrayForEach(pathGetters[index]?.(...ids) ?? [], (id2) =>
1853
+ callWithIds(...ids, id2),
1854
+ )
1855
+ : callWithIds(...ids, path[index]);
1856
1856
  };
1857
1857
  callWithIds();
1858
1858
  },
@@ -1995,8 +1995,8 @@ const createStore = () => {
1995
1995
  () => cellInvalid(tableId, rowId, cellId, cell),
1996
1996
  )
1997
1997
  : isUndefined(getCellOrValueType(cell))
1998
- ? cellInvalid(tableId, rowId, cellId, cell)
1999
- : cell;
1998
+ ? cellInvalid(tableId, rowId, cellId, cell)
1999
+ : cell;
2000
2000
  const validateValues = (values, skipDefaults) =>
2001
2001
  validate(
2002
2002
  skipDefaults ? values : addDefaultsToValues(values),
@@ -2022,8 +2022,8 @@ const createStore = () => {
2022
2022
  () => valueInvalid(valueId, value),
2023
2023
  )
2024
2024
  : isUndefined(getCellOrValueType(value))
2025
- ? valueInvalid(valueId, value)
2026
- : value;
2025
+ ? valueInvalid(valueId, value)
2026
+ : value;
2027
2027
  const addDefaultsToRow = (row, tableId, rowId) => {
2028
2028
  ifNotUndefined(
2029
2029
  mapGet(tablesSchemaRowCache, tableId),
@@ -1,4 +1,4 @@
1
- import React, {useContext as useContext$1} from 'react';
1
+ import React from 'react';
2
2
 
3
3
  const getTypeOf = (thing) => typeof thing;
4
4
  const EMPTY_STRING = '';
@@ -37,16 +37,20 @@ const arrayIsEmpty = (array) => size(array) == 0;
37
37
  const object = Object;
38
38
  const objIds = object.keys;
39
39
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
40
+ const objDel = (obj, id) => {
41
+ delete obj[id];
42
+ return obj;
43
+ };
40
44
 
41
- const {createContext, useContext} = React;
45
+ const {createContext, useContext: useContext$1, useEffect: useEffect$1} = React;
42
46
  const Context = createContext([]);
43
47
  const useThing = (id, offset) => {
44
- const contextValue = useContext(Context);
48
+ const contextValue = useContext$1(Context);
45
49
  return isUndefined(id)
46
50
  ? contextValue[offset]
47
51
  : isString(id)
48
- ? objGet(contextValue[offset + 1] ?? {}, id)
49
- : id;
52
+ ? objGet(contextValue[offset + 1] ?? {}, id)
53
+ : id;
50
54
  };
51
55
  const useThingOrThingById = (thingOrThingId, offset) => {
52
56
  const thing = useThing(thingOrThingId, offset);
@@ -54,10 +58,17 @@ const useThingOrThingById = (thingOrThingId, offset) => {
54
58
  ? thing
55
59
  : thingOrThingId;
56
60
  };
57
- const useThingIds = (offset) => objIds(useContext(Context)[offset] ?? {});
61
+ const useThingIds = (offset) => objIds(useContext$1(Context)[offset] ?? {});
58
62
  const useStore = (id) => useThing(id, 0);
59
63
  const useStoreOrStoreById = (storeOrStoreId) =>
60
64
  useThingOrThingById(storeOrStoreId, 0);
65
+ const useProvideStore = (storeId, store) => {
66
+ const {12: addExtraStore, 13: delExtraStore} = useContext$1(Context);
67
+ useEffect$1(() => {
68
+ addExtraStore?.(storeId, store);
69
+ return () => delExtraStore?.(storeId);
70
+ }, [addExtraStore, storeId, store, delExtraStore]);
71
+ };
61
72
  const useMetrics = (id) => useThing(id, 2);
62
73
  const useMetricsOrMetricsById = (metricsOrMetricsId) =>
63
74
  useThingOrThingById(metricsOrMetricsId, 2);
@@ -80,12 +91,12 @@ const TRANSACTION = 'Transaction';
80
91
  lower(TRANSACTION);
81
92
 
82
93
  const {
83
- useCallback: useCallback$1,
94
+ useCallback: useCallback$2,
84
95
  useEffect,
85
96
  useMemo: useMemo$1,
86
97
  useLayoutEffect: useLayoutEffect$1,
87
98
  useRef: useRef$1,
88
- useState: useState$1,
99
+ useState: useState$2,
89
100
  } = React;
90
101
  const EMPTY_ARRAY = [];
91
102
  const EMPTY_OBJECT = {};
@@ -108,8 +119,8 @@ const useListenable = (
108
119
  getterPrefix = GET,
109
120
  listenerPrefix = EMPTY_STRING,
110
121
  ) => {
111
- const [, rerender] = useState$1();
112
- const getResult = useCallback$1(
122
+ const [, rerender] = useState$2();
123
+ const getResult = useCallback$2(
113
124
  () => thing?.[getterPrefix + listenable]?.(...args) ?? defaulted,
114
125
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
115
126
  [thing, listenable, ...args, defaulted],
@@ -156,7 +167,7 @@ const useSetCallback = (
156
167
  ...args
157
168
  ) => {
158
169
  const store = useStoreOrStoreById(storeOrStoreId);
159
- return useCallback$1(
170
+ return useCallback$2(
160
171
  (parameter) =>
161
172
  ifNotUndefined(store, (store2) =>
162
173
  ifNotUndefined(get(parameter, store2), (thing) =>
@@ -175,7 +186,7 @@ const useDel = (
175
186
  ...args
176
187
  ) => {
177
188
  const store = useStoreOrStoreById(storeOrStoreId);
178
- return useCallback$1(
189
+ return useCallback$2(
179
190
  () => then(store?.['del' + deletable](...args)),
180
191
  // eslint-disable-next-line react-hooks/exhaustive-deps
181
192
  [store, deletable, ...thenDeps, ...args],
@@ -185,7 +196,7 @@ const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
185
196
  const checkpoints = useCheckpointsOrCheckpointsById(
186
197
  checkpointsOrCheckpointsId,
187
198
  );
188
- return useCallback$1(
199
+ return useCallback$2(
189
200
  () => checkpoints?.[action](arg),
190
201
  // eslint-disable-next-line react-hooks/exhaustive-deps
191
202
  [checkpoints, action, arg],
@@ -385,7 +396,7 @@ const useAddRowCallback = (
385
396
  reuseRowIds = true,
386
397
  ) => {
387
398
  const store = useStoreOrStoreById(storeOrStoreId);
388
- return useCallback$1(
399
+ return useCallback$2(
389
400
  (parameter) =>
390
401
  ifNotUndefined(store, (store2) =>
391
402
  ifNotUndefined(getRow(parameter, store2), (row) =>
@@ -1198,7 +1209,7 @@ const useSetCheckpointCallback = (
1198
1209
  const checkpoints = useCheckpointsOrCheckpointsById(
1199
1210
  checkpointsOrCheckpointsId,
1200
1211
  );
1201
- return useCallback$1(
1212
+ return useCallback$2(
1202
1213
  (parameter) =>
1203
1214
  ifNotUndefined(checkpoints, (checkpoints2) => {
1204
1215
  const label = getCheckpoint(parameter);
@@ -1222,7 +1233,7 @@ const useGoToCallback = (
1222
1233
  const checkpoints = useCheckpointsOrCheckpointsById(
1223
1234
  checkpointsOrCheckpointsId,
1224
1235
  );
1225
- return useCallback$1(
1236
+ return useCallback$2(
1226
1237
  (parameter) =>
1227
1238
  ifNotUndefined(checkpoints, (checkpoints2) =>
1228
1239
  ifNotUndefined(getCheckpointId(parameter), (checkpointId) =>
@@ -1292,7 +1303,7 @@ const useCreatePersister = (
1292
1303
  destroy,
1293
1304
  destroyDeps = EMPTY_ARRAY,
1294
1305
  ) => {
1295
- const [, rerender] = useState$1();
1306
+ const [, rerender] = useState$2();
1296
1307
  const persister = useMemo$1(
1297
1308
  () => create(store),
1298
1309
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1321,10 +1332,10 @@ const {
1321
1332
  PureComponent,
1322
1333
  Fragment,
1323
1334
  createElement,
1324
- useCallback,
1335
+ useCallback: useCallback$1,
1325
1336
  useLayoutEffect,
1326
1337
  useRef,
1327
- useState,
1338
+ useState: useState$1,
1328
1339
  } = React;
1329
1340
  const getProps = (getProps2, ...ids) =>
1330
1341
  isUndefined(getProps2) ? {} : getProps2(...ids);
@@ -1340,7 +1351,7 @@ const getIndexStoreTableId = (indexes, indexId) => [
1340
1351
  indexes?.getTableId(indexId),
1341
1352
  ];
1342
1353
 
1343
- const {useMemo} = React;
1354
+ const {useCallback, useContext, useMemo, useState} = React;
1344
1355
  const tableView = (
1345
1356
  {
1346
1357
  tableId,
@@ -1469,14 +1480,31 @@ const Provider = ({
1469
1480
  checkpointsById,
1470
1481
  children,
1471
1482
  }) => {
1472
- const parentValue = useContext$1(Context);
1483
+ const parentValue = useContext(Context);
1484
+ const [extraStoresById, setExtraStoresById] = useState({});
1485
+ const addExtraStore = useCallback(
1486
+ (id, store2) =>
1487
+ setExtraStoresById((extraStoresById2) =>
1488
+ objGet(extraStoresById2, id) == store2
1489
+ ? extraStoresById2
1490
+ : {...extraStoresById2, [id]: store2},
1491
+ ),
1492
+ [],
1493
+ );
1494
+ const delExtraStore = useCallback(
1495
+ (id) =>
1496
+ setExtraStoresById((extraStoresById2) => ({
1497
+ ...objDel(extraStoresById2, id),
1498
+ })),
1499
+ [],
1500
+ );
1473
1501
  return /* @__PURE__ */ createElement(
1474
1502
  Context.Provider,
1475
1503
  {
1476
1504
  value: useMemo(
1477
1505
  () => [
1478
1506
  store ?? parentValue[0],
1479
- {...parentValue[1], ...storesById},
1507
+ {...parentValue[1], ...storesById, ...extraStoresById},
1480
1508
  metrics ?? parentValue[2],
1481
1509
  {...parentValue[3], ...metricsById},
1482
1510
  indexes ?? parentValue[4],
@@ -1487,10 +1515,13 @@ const Provider = ({
1487
1515
  {...parentValue[9], ...queriesById},
1488
1516
  checkpoints ?? parentValue[10],
1489
1517
  {...parentValue[11], ...checkpointsById},
1518
+ addExtraStore,
1519
+ delExtraStore,
1490
1520
  ],
1491
1521
  [
1492
1522
  store,
1493
1523
  storesById,
1524
+ extraStoresById,
1494
1525
  metrics,
1495
1526
  metricsById,
1496
1527
  indexes,
@@ -1502,6 +1533,8 @@ const Provider = ({
1502
1533
  checkpoints,
1503
1534
  checkpointsById,
1504
1535
  parentValue,
1536
+ addExtraStore,
1537
+ delExtraStore,
1505
1538
  ],
1506
1539
  ),
1507
1540
  },
@@ -1855,6 +1888,7 @@ export {
1855
1888
  useMetrics,
1856
1889
  useMetricsIds,
1857
1890
  useMetricsOrMetricsById,
1891
+ useProvideStore,
1858
1892
  useQueries,
1859
1893
  useQueriesIds,
1860
1894
  useQueriesOrQueriesById,
@@ -1 +1 @@
1
- const e=e=>typeof e,t="",n=e(t),l="t",r=(e,t)=>e.startsWith(t),i=Promise,o=e=>null==e,s=(e,t,n)=>o(e)?null==n?void 0:n():t(e),a=(e,t,n)=>e.slice(t,n),u=e=>e.length,c=e=>{return t=function*(){return i.all(e)},new Promise(((e,n)=>{var l=e=>{try{i(t.next(e))}catch(e){n(e)}},r=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(l,r);i((t=t.apply(void 0,null)).next())}));var t},d=(e,t)=>e.map(t),h=(e,...t)=>e.push(...t),f=Object,v=(e=[])=>f.fromEntries(e),y=(e,t)=>d(f.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!o(((e,t)=>s(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?f.fromEntries([...t]):t)),S=JSON.parse,m=(t,l,r)=>t+l+(e(r)==n?r:p(r)),w=(e,t,n)=>{const l=u(e);return r(t,e)?[t[l],(n?S:String)(a(t,l+1))]:void 0},P=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var x=(e,t,n)=>new Promise(((l,r)=>{var i=e=>{try{s(n.next(e))}catch(e){r(e)}},o=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,o);s((n=n.apply(e,t)).next())}));const D="hasStore",R=v(d(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),b=e=>x(void 0,null,(function*(){var n;return yield e.party.storage.get((null!=(n=e.config.storagePrefix)?n:t)+D)})),C=(e,n,i,s)=>x(void 0,null,(function*(){var a;const d=e.party.storage,f=null!=(a=e.config.storagePrefix)?a:t,v={[f+D]:1},g=[],p=[];yield c(y(n[0],((t,n)=>x(void 0,null,(function*(){return o(t)?!i&&e.canDelTable(n,s)&&((e,...t)=>e.unshift(...t))(p,T(f,l,n)):e.canSetTable(n,i,s)&&(yield c(y(t,((t,r)=>x(void 0,null,(function*(){return o(t)?!i&&e.canDelRow(n,r,s)&&h(p,T(f,l,n,r)):e.canSetRow(n,r,i,s)&&(yield c(y(t,((t,a)=>x(void 0,null,(function*(){const u=[n,r,a],c=T(f,l,...u);o(t)?!i&&e.canDelCell(...u,s)&&h(g,c):e.canSetCell(...u,t,i,s,yield d.get(c))&&(v[c]=t)}))))))}))))))}))))),yield c(y(n[1],((t,n)=>x(void 0,null,(function*(){const l=f+"v"+n;o(t)?!i&&e.canDelValue(n,s)&&h(g,l):e.canSetValue(n,t,i,s,yield d.get(l))&&(v[l]=t)}))))),0!=u(p)&&P(yield d.list(),(e=>p.every((t=>!r(e,t)||h(g,e)&&0)))),yield d.delete(g),yield d.put(v)})),T=(e,t,...n)=>m(e,t,a(p(n),1,-1)),O=(e,t,n=null)=>x(void 0,null,(function*(){var l;return new Response(n,{status:t,headers:null!=(l=e.config.responseHeaders)?l:R})}));class V{constructor(e){this.party=e,this.config={}}onRequest(e){return x(this,null,(function*(){var n;const r=null!=(n=this.config.storePath)?n:"/store";if(new URL(e.url).pathname.endsWith(r)){const n=yield b(this),r=yield e.text();return"PUT"==e.method?n?O(this,205):(yield C(this,S(r),!0,e),O(this,201)):O(this,200,n?p(yield(i=this,x(void 0,null,(function*(){var e;const n={},r={},o=null!=(e=i.config.storagePrefix)?e:t;return P(yield i.party.storage.list(),((e,t)=>s(w(o,e),(([e,i])=>{if(e==l){const[e,l,r]=S("["+i+"]");g(g(n,e,v),l,v)[r]=t}else"v"==e&&(r[i]=t)})))),[n,r]})))):t)}var i;return O(this,404)}))}onMessage(e,n){return x(this,null,(function*(){var l;const r=null!=(l=this.config.messagePrefix)?l:t;yield s(w(r,e,1),(e=>x(this,[e],(function*([e,t]){"s"==e&&(yield b(this))&&(yield C(this,t,!1,n),this.party.broadcast(m(r,"s",t)))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,l){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,l,r,i,o){return!0}canDelCell(e,t,n,l){return!0}canSetValue(e,t,n,l,r){return!0}canDelValue(e,t){return!0}}export{V as TinyBasePartyKitServer};
1
+ const e=e=>typeof e,t=e(""),n="t",r=(e,t)=>e.startsWith(t),i=Promise,l=e=>null==e,s=(e,t,n)=>l(e)?null==n?void 0:n():t(e),o=(e,t,n)=>e.slice(t,n),a=e=>e.length,c=e=>{return t=function*(){return i.all(e)},new Promise(((e,n)=>{var r=e=>{try{l(t.next(e))}catch(e){n(e)}},i=e=>{try{l(t.throw(e))}catch(e){n(e)}},l=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,i);l((t=t.apply(void 0,null)).next())}));var t},u=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),h=Object,f=(e=[])=>h.fromEntries(e),y=(e,t)=>u(h.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!l(((e,t)=>s(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),v=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),p=JSON.parse,P=(n,r,i)=>n+r+(e(i)==t?i:v(i)),x=(e,t,n)=>{const i=a(e);return r(t,e)?[t[i],(n?p:String)(o(t,i+1))]:void 0},m=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var S=(e,t,n)=>new Promise(((r,i)=>{var l=e=>{try{o(n.next(e))}catch(e){i(e)}},s=e=>{try{o(n.throw(e))}catch(e){i(e)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(l,s);o((n=n.apply(e,t)).next())}));const w="hasStore",D=f(u(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),R=(e,...t)=>S(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+w))})),b=(e,...t)=>S(void 0,[e,...t],(function*(e,t=""){const r={},i={};return m(yield e.list(),((e,l)=>s(x(t,e),(([e,t])=>{if(e==n){const[e,n,i]=p("["+t+"]");g(g(r,e,f),n,f)[i]=l}else"v"==e&&(i[t]=l)})))),[r,i]})),C=(e,t,i,s)=>S(void 0,null,(function*(){const o=e.party.storage,u=e.config.storagePrefix,h={[u+w]:1},f=[],g=[];yield c(y(t[0],((t,r)=>S(void 0,null,(function*(){return l(t)?!i&&e.canDelTable(r,s)&&((e,...t)=>e.unshift(...t))(g,T(u,n,r)):e.canSetTable(r,i,s)&&(yield c(y(t,((t,a)=>S(void 0,null,(function*(){return l(t)?!i&&e.canDelRow(r,a,s)&&d(g,T(u,n,r,a)):e.canSetRow(r,a,i,s)&&(yield c(y(t,((t,c)=>S(void 0,null,(function*(){const y=[r,a,c],g=T(u,n,...y);l(t)?!i&&e.canDelCell(...y,s)&&d(f,g):e.canSetCell(...y,t,i,s,yield o.get(g))&&(h[g]=t)}))))))}))))))}))))),yield c(y(t[1],((t,n)=>S(void 0,null,(function*(){const r=u+"v"+n;l(t)?!i&&e.canDelValue(n,s)&&d(f,r):e.canSetValue(n,t,i,s,yield o.get(r))&&(h[r]=t)}))))),0!=a(g)&&m(yield o.list(),(e=>g.every((t=>!r(e,t)||d(f,e)&&0)))),yield o.delete(f),yield o.put(h)})),T=(e,t,...n)=>P(e,t,o(v(n),1,-1)),H=(e,t,n=null)=>S(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));class O{constructor(e){var t,n,r,i;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(i=this.config).responseHeaders||(i.responseHeaders=D)}onRequest(e){return S(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield R(t,r),i=yield e.text();return"PUT"==e.method?n?H(this,205):(yield C(this,p(i),!0,e),H(this,201)):H(this,200,n?v(yield b(t,r)):"")}return H(this,404)}))}onMessage(e,t){return S(this,null,(function*(){const{party:{storage:n,broadcast:r},config:{messagePrefix:i,storagePrefix:l}}=this;yield s(x(i,e,1),(e=>S(this,[e],(function*([e,s]){"s"==e&&(yield R(n,l))&&(yield C(this,s,!1,t),r(P(i,"s",s),[t.id]))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,i,l,s){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r,i){return!0}canDelValue(e,t){return!0}}export{O as TinyBasePartyKitServer,R as hasStoreInStorage,b as loadStoreFromStorage};
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";const o=e=>typeof e,r="",n=o(r),d="Listener",l="Result",s="Has",u="has",i="Ids",a="Table",c=a+"s",I=a+i,p="Row",v=p+"Count",b=p+i,g="Sorted"+p+i,m="Cell",y=m+i,C="Value",w=C+"s",f=C+i,h=e=>null==e,k=(e,t,o)=>h(e)?null==o?void 0:o():t(e),R=e=>o(e)==n,P=()=>{},x=(e,t)=>e.map(t),q=Object.keys,{createContext:O,useContext:S}=e,L=O([]),j=(e,t)=>{var o;const r=S(L);return h(e)?r[t]:R(e)?((e,t)=>k(e,(e=>e[t])))(null!=(o=r[t+1])?o:{},e):e},B=(e,t)=>{const o=j(e,t);return h(e)||R(e)?o:e},T=e=>{var t;return q(null!=(t=S(L)[e])?t:{})},E=e=>j(e,0),M=e=>B(e,0),F=e=>j(e,2),V=e=>B(e,2),A=e=>j(e,4),D=e=>B(e,4),H=e=>j(e,6),Q=e=>B(e,6),W=e=>j(e,8),z=e=>B(e,8),G=e=>j(e,10),J=e=>B(e,10),K=e=>e.toLowerCase();K(d);const N="Transaction";K(N);const{useCallback:U,useEffect:X,useMemo:Y,useLayoutEffect:Z,useRef:$,useState:_}=e,ee=[],te={},oe=[[],void 0,[]],re=(e,t,o=ee)=>{const r=Y((()=>t(e)),[e,...o]);return X((()=>()=>r.destroy()),[r]),r},ne=(e,t,o,r=ee,n,d="get",l="")=>{const[,s]=_(),u=U((()=>{var n,l;return null!=(l=null==(n=null==t?void 0:t[d+e])?void 0:n.call(t,...r))?l:o}),[t,e,...r,o]),i=$();return Y((()=>i.current=u()),[u]),de(l+e,t,((...e)=>{i.current=h(n)?u():e[n],s([])}),[u,n],r),i.current},de=(e,t,o,r=ee,n=ee,...l)=>Z((()=>{var r;const s=null==(r=null==t?void 0:t["add"+e+d])?void 0:r.call(t,...n,o,...l);return()=>null==t?void 0:t.delListener(s)}),[t,e,...n,...r,...l]),le=(e,t,o,r=ee,n=P,d=ee,...l)=>{const s=M(e);return U((e=>k(s,(r=>k(o(e,r),(e=>n(r["set"+t](...l,e),e)))))),[s,t,...r,...d,...l])},se=(e,t,o=P,r=ee,...n)=>{const d=M(e);return U((()=>o(null==d?void 0:d["del"+t](...n))),[d,t,...r,...n])},ue=(e,t,o)=>{const r=J(e);return U((()=>null==r?void 0:r[t](o)),[r,t,o])},ie=(e,t=ee)=>Y(e,t),ae=()=>T(1),ce=e=>ne(c,M(e),!1,[],1,u,s),Ie=e=>ne(c,M(e),te),pe=e=>ne(I,M(e),ee),ve=(e,t)=>ne(a,M(t),!1,[e],2,u,s),be=(e,t)=>ne(a,M(t),te,[e]),ge=(e,t)=>ne(a+y,M(t),ee,[e]),me=(e,t,o)=>ne(a+m,M(o),!1,[e,t],3,u,s),ye=(e,t)=>ne(v,M(t),0,[e]),Ce=(e,t)=>ne(b,M(t),ee,[e]),we=(e,t,o,r=0,n,d)=>ne(g,M(d),ee,[e,t,o,r,n],6),fe=(e,t,o)=>ne(p,M(o),!1,[e,t],3,u,s),he=(e,t,o)=>ne(p,M(o),te,[e,t]),ke=(e,t,o)=>ne(y,M(o),ee,[e,t]),Re=(e,t,o,r)=>ne(m,M(r),!1,[e,t,o],4,u,s),Pe=(e,t,o,r)=>ne(m,M(r),void 0,[e,t,o],4),xe=e=>ne(w,M(e),!1,[],1,u,s),qe=e=>ne(w,M(e),te),Oe=e=>ne(f,M(e),ee),Se=(e,t)=>ne(C,M(t),!1,[e],2,u,s),Le=(e,t)=>ne(C,M(t),void 0,[e]),je=(e,t,o,r,n)=>le(o,c,e,t,r,n),Be=(e,t,o,r,n,d)=>le(r,a,t,o,n,d,e),Te=(e,t,o,r,n,d,l)=>le(n,p,o,r,d,l,e,t),Ee=(e,t,o=ee,r,n=P,d=ee,l=!0)=>{const s=M(r);return U((o=>k(s,(r=>k(t(o,r),(t=>n(r.addRow(e,t,l),r,t)))))),[s,e,...o,...d,l])},Me=(e,t,o,r,n,d,l)=>le(n,"PartialRow",o,r,d,l,e,t),Fe=(e,t,o,r,n,d,l,s)=>le(d,m,r,n,l,s,e,t,o),Ve=(e,t,o,r,n)=>le(o,w,e,t,r,n),Ae=(e,t,o,r,n)=>le(o,"PartialValues",e,t,r,n),De=(e,t,o,r,n,d)=>le(r,C,t,o,n,d,e),He=(e,t,o)=>se(e,c,t,o),Qe=(e,t,o,r)=>se(t,a,o,r,e),We=(e,t,o,r,n)=>se(o,p,r,n,e,t),ze=(e,t,o,r,n,d,l)=>se(n,m,d,l,e,t,o,r),Ge=(e,t,o)=>se(e,w,t,o),Je=(e,t,o,r)=>se(t,C,o,r,e),Ke=(e,t,o,r)=>de(s+c,M(r),e,t,[],o),Ne=(e,t,o,r)=>de(c,M(r),e,t,ee,o),Ue=(e,t,o,r)=>de(I,M(r),e,t,ee,o),Xe=(e,t,o,r,n)=>de(s+a,M(n),t,o,[e],r),Ye=(e,t,o,r,n)=>de(a,M(n),t,o,[e],r),Ze=(e,t,o,r,n)=>de(a+y,M(n),t,o,[e],r),$e=(e,t,o,r,n,d)=>de(s+a+m,M(d),o,r,[e,t],n),_e=(e,t,o,r,n)=>de(v,M(n),t,o,[e],r),et=(e,t,o,r,n)=>de(b,M(n),t,o,[e],r),tt=(e,t,o,r,n,d,l,s,u)=>de(g,M(u),d,l,[e,t,o,r,n],s),ot=(e,t,o,r,n,d)=>de(s+p,M(d),o,r,[e,t],n),rt=(e,t,o,r,n,d)=>de(p,M(d),o,r,[e,t],n),nt=(e,t,o,r,n,d)=>de(y,M(d),o,r,[e,t],n),dt=(e,t,o,r,n,d,l)=>de(s+m,M(l),r,n,[e,t,o],d),lt=(e,t,o,r,n,d,l)=>de(m,M(l),r,n,[e,t,o],d),st=(e,t,o,r)=>de(s+w,M(r),e,t,[],o),ut=(e,t,o,r)=>de(w,M(r),e,t,ee,o),it=(e,t,o,r)=>de(f,M(r),e,t,ee,o),at=(e,t,o,r,n)=>de(s+C,M(n),t,o,[e],r),ct=(e,t,o,r,n)=>de(C,M(n),t,o,[e],r),It=(e,t,o)=>de("Start"+N,M(o),e,t),pt=(e,t,o)=>de("WillFinish"+N,M(o),e,t),vt=(e,t,o)=>de("DidFinish"+N,M(o),e,t),bt=(e,t,o)=>re(e,t,o),gt=()=>T(3),mt=e=>ne("MetricIds",V(e),ee),yt=(e,t)=>ne("Metric",V(t),void 0,[e]),Ct=(e,t,o,r)=>de("Metric",V(r),t,o,[e]),wt=(e,t,o)=>re(e,t,o),ft=()=>T(5),ht=(e,t)=>ne("SliceIds",D(t),ee,[e]),kt=e=>ne("IndexIds",D(e),ee),Rt=(e,t,o)=>ne("Slice"+b,D(o),ee,[e,t]),Pt=(e,t,o,r)=>de("SliceIds",D(r),t,o,[e]),xt=(e,t,o,r,n)=>de("Slice"+b,D(n),o,r,[e,t]),qt=(e,t,o)=>re(e,t,o),Ot=()=>T(7),St=e=>ne("RelationshipIds",Q(e),ee),Lt=(e,t,o)=>ne("RemoteRowId",Q(o),void 0,[e,t]),jt=(e,t,o)=>ne("Local"+b,Q(o),ee,[e,t]),Bt=(e,t,o)=>ne("Linked"+b,Q(o),ee,[e,t]),Tt=(e,t,o,r,n)=>de("RemoteRowId",Q(n),o,r,[e,t]),Et=(e,t,o,r,n)=>de("Local"+b,Q(n),o,r,[e,t]),Mt=(e,t,o,r,n)=>de("Linked"+b,Q(n),o,r,[e,t]),Ft=(e,t,o)=>re(e,t,o),Vt=()=>T(9),At=e=>ne("QueryIds",z(e),ee),Dt=(e,t)=>ne(l+a,z(t),te,[e]),Ht=(e,t)=>ne(l+a+y,z(t),ee,[e]),Qt=(e,t)=>ne(l+v,z(t),0,[e]),Wt=(e,t)=>ne(l+b,z(t),ee,[e]),zt=(e,t,o,r=0,n,d)=>ne(l+g,z(d),ee,[e,t,o,r,n],6),Gt=(e,t,o)=>ne(l+p,z(o),te,[e,t]),Jt=(e,t,o)=>ne(l+y,z(o),ee,[e,t]),Kt=(e,t,o,r)=>ne(l+m,z(r),void 0,[e,t,o]),Nt=(e,t,o,r)=>de(l+a,z(r),t,o,[e]),Ut=(e,t,o,r)=>de(l+a+y,z(r),t,o,[e]),Xt=(e,t,o,r)=>de(l+v,z(r),t,o,[e]),Yt=(e,t,o,r)=>de(l+b,z(r),t,o,[e]),Zt=(e,t,o,r,n,d,s,u)=>de(l+g,z(u),d,s,[e,t,o,r,n]),$t=(e,t,o,r,n)=>de(l+p,z(n),o,r,[e,t]),_t=(e,t,o,r,n)=>de(l+y,z(n),o,r,[e,t]),eo=(e,t,o,r,n,d)=>de(l+m,z(d),r,n,[e,t,o]),to=(e,t,o)=>re(e,t,o),oo=()=>T(11),ro=e=>ne("CheckpointIds",J(e),oe),no=(e,t)=>ne("Checkpoint",J(t),void 0,[e]),lo=(e=P,t=ee,o,r=P,n=ee)=>{const d=J(o);return U((t=>k(d,(o=>{const n=e(t);r(o.addCheckpoint(n),o,n)}))),[d,...t,...n])},so=e=>ue(e,"goBackward"),uo=e=>ue(e,"goForward"),io=(e,t=ee,o,r=P,n=ee)=>{const d=J(o);return U((t=>k(d,(o=>k(e(t),(e=>r(o.goTo(e),e)))))),[d,...t,...n])},ao=e=>{var t;const o=J(e),[n,d]=ro(o);return[(l=n,!(0==l.length)),so(o),d,null!=(t=k(d,(e=>null==o?void 0:o.getCheckpoint(e))))?t:r];var l},co=e=>{var t;const o=J(e),[,,[n]]=ro(o);return[!h(n),uo(o),n,null!=(t=k(n,(e=>null==o?void 0:o.getCheckpoint(e))))?t:r]},Io=(e,t,o)=>de("CheckpointIds",J(o),e,t),po=(e,t,o,r)=>de("Checkpoint",J(r),t,o,[e]),vo=(e,t,o=ee,r,n=ee,d,l=ee)=>{const[,s]=_(),u=Y((()=>t(e)),[e,...o]);return X((()=>{var e;return e=function*(){r&&(yield r(u),s([]))},new Promise(((t,o)=>{var r=t=>{try{d(e.next(t))}catch(e){o(e)}},n=t=>{try{d(e.throw(t))}catch(e){o(e)}},d=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,n);d((e=e.apply(void 0,null)).next())})),()=>{null==u||u.destroy(),null==d||d(u)}}),[u,...n,...l]),u},{PureComponent:bo,Fragment:go,createElement:mo,useCallback:yo,useLayoutEffect:Co,useRef:wo,useState:fo}=e,ho=(e,...t)=>h(e)?{}:e(...t),ko=(e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)];var Ro=Object.defineProperty,Po=Object.defineProperties,xo=Object.getOwnPropertyDescriptors,qo=Object.getOwnPropertySymbols,Oo=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable,Lo=(e,t,o)=>t in e?Ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,jo=(e,t)=>{for(var o in t||(t={}))Oo.call(t,o)&&Lo(e,o,t[o]);if(qo)for(var o of qo(t))So.call(t,o)&&Lo(e,o,t[o]);return e},Bo=(e,t)=>Po(e,xo(t)),To=(e,t)=>{var o={};for(var r in e)Oo.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&qo)for(var r of qo(e))t.indexOf(r)<0&&So.call(e,r)&&(o[r]=e[r]);return o};const{useMemo:Eo}=e,Mo=({tableId:e,store:t,rowComponent:o=Wo,getRowComponentProps:r,customCellIds:n,separator:d,debugIds:l},s)=>Ho(x(s,(d=>mo(o,Bo(jo({},ho(r,d)),{key:d,tableId:e,rowId:d,customCellIds:n,store:t,debugIds:l})))),d,l,e),Fo=({queryId:e,queries:t,resultRowComponent:o=tr,getResultRowComponentProps:r,separator:n,debugIds:d},l)=>Ho(x(l,(n=>mo(o,Bo(jo({},ho(r,n)),{key:n,queryId:e,rowId:n,queries:t,debugIds:d})))),n,d,e),Vo=({relationshipId:e,relationships:t,rowComponent:o=Wo,getRowComponentProps:r,separator:n,debugIds:d},l,s)=>{const[u,i,a]=ko(Q(t),e),c=l(e,s,u);return Ho(x(c,(e=>mo(o,Bo(jo({},ho(r,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:d})))),n,d,s)},Ao=e=>({checkpoints:t,checkpointComponent:o=nr,getCheckpointComponentProps:r,separator:n,debugIds:d})=>{const l=J(t);return Ho(x(e(ro(l)),(e=>mo(o,Bo(jo({},ho(r,e)),{key:e,checkpoints:l,checkpointId:e,debugIds:d})))),n)},Do=({store:e,storesById:o,metrics:r,metricsById:n,indexes:d,indexesById:l,relationships:s,relationshipsById:u,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:p})=>{const v=t(L);return mo(L.Provider,{value:Eo((()=>[null!=e?e:v[0],jo(jo({},v[1]),o),null!=r?r:v[2],jo(jo({},v[3]),n),null!=d?d:v[4],jo(jo({},v[5]),l),null!=s?s:v[6],jo(jo({},v[7]),u),null!=i?i:v[8],jo(jo({},v[9]),a),null!=c?c:v[10],jo(jo({},v[11]),I)]),[e,o,r,n,d,l,s,u,i,a,c,I,v])},p)},Ho=(e,t,o,r)=>{const n=h(t)||!Array.isArray(e)?e:x(e,((e,o)=>o>0?[t,e]:e));return o?[r,":{",n,"}"]:n},Qo=({tableId:e,rowId:t,cellId:o,store:n,debugIds:d})=>{var l;return Ho(r+(null!=(l=Pe(e,t,o,n))?l:r),void 0,d,o)},Wo=({tableId:e,rowId:t,store:o,cellComponent:r=Qo,getCellComponentProps:n,customCellIds:d,separator:l,debugIds:s})=>Ho(x(((e,t,o,r)=>{const n=ke(t,o,r);return null!=e?e:n})(d,e,t,o),(d=>mo(r,Bo(jo({},ho(n,d)),{key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:s})))),l,s,t),zo=e=>Mo(e,Ce(e.tableId,e.store)),Go=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:d}=t,l=To(t,["cellId","descending","offset","limit"]);return Mo(l,we(l.tableId,o,r,n,d,l.store))},Jo=({store:e,tableComponent:t=zo,getTableComponentProps:o,separator:r,debugIds:n})=>Ho(x(pe(e),(r=>mo(t,Bo(jo({},ho(o,r)),{key:r,tableId:r,store:e,debugIds:n})))),r),Ko=({valueId:e,store:t,debugIds:o})=>{var n;return Ho(r+(null!=(n=Le(e,t))?n:r),void 0,o,e)},No=({store:e,valueComponent:t=Ko,getValueComponentProps:o,separator:r,debugIds:n})=>Ho(x(Oe(e),(r=>mo(t,Bo(jo({},ho(o,r)),{key:r,valueId:r,store:e,debugIds:n})))),r),Uo=({metricId:e,metrics:t,debugIds:o})=>{var n;return Ho(null!=(n=yt(e,t))?n:r,void 0,o,e)},Xo=({indexId:e,sliceId:t,indexes:o,rowComponent:r=Wo,getRowComponentProps:n,separator:d,debugIds:l})=>{const[s,u,i]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(D(o),e),a=Rt(e,t,s);return Ho(x(a,(e=>mo(r,Bo(jo({},ho(n,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:l})))),d,l,t)},Yo=({indexId:e,indexes:t,sliceComponent:o=Xo,getSliceComponentProps:r,separator:n,debugIds:d})=>Ho(x(ht(e,t),(n=>mo(o,Bo(jo({},ho(r,n)),{key:n,indexId:e,sliceId:n,indexes:t,debugIds:d})))),n,d,e),Zo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:r=Wo,getRowComponentProps:n,debugIds:d})=>{const[l,s,,u]=ko(Q(o),e),i=Lt(e,t,l);return Ho(h(u)||h(i)?null:mo(r,Bo(jo({},ho(n,i)),{key:i,tableId:u,rowId:i,store:s,debugIds:d})),void 0,d,t)},$o=e=>Vo(e,jt,e.remoteRowId),_o=e=>Vo(e,Bt,e.firstRowId),er=({queryId:e,rowId:t,cellId:o,queries:n,debugIds:d})=>{var l;return Ho(r+(null!=(l=Kt(e,t,o,n))?l:r),void 0,d,o)},tr=({queryId:e,rowId:t,queries:o,resultCellComponent:r=er,getResultCellComponentProps:n,separator:d,debugIds:l})=>Ho(x(Jt(e,t,o),(d=>mo(r,Bo(jo({},ho(n,d)),{key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:l})))),d,l,t),or=e=>Fo(e,Wt(e.queryId,e.queries)),rr=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:d}=t,l=To(t,["cellId","descending","offset","limit"]);return Fo(l,zt(l.queryId,o,r,n,d,l.queries))},nr=({checkpoints:e,checkpointId:t,debugIds:o})=>{var n;return Ho(null!=(n=no(t,e))?n:r,void 0,o,t)},dr=Ao((e=>e[0])),lr=Ao((e=>h(e[1])?[]:[e[1]])),sr=Ao((e=>e[2]));export{dr as BackwardCheckpointsView,Qo as CellView,nr as CheckpointView,lr as CurrentCheckpointView,sr as ForwardCheckpointsView,Yo as IndexView,_o as LinkedRowsView,$o as LocalRowsView,Uo as MetricView,Do as Provider,Zo as RemoteRowView,er as ResultCellView,tr as ResultRowView,rr as ResultSortedTableView,or as ResultTableView,Wo as RowView,Xo as SliceView,Go as SortedTableView,zo as TableView,Jo as TablesView,Ko as ValueView,No as ValuesView,Ee as useAddRowCallback,Pe as useCell,ke as useCellIds,nt as useCellIdsListener,lt as useCellListener,no as useCheckpoint,ro as useCheckpointIds,Io as useCheckpointIdsListener,po as useCheckpointListener,G as useCheckpoints,oo as useCheckpointsIds,J as useCheckpointsOrCheckpointsById,to as useCreateCheckpoints,wt as useCreateIndexes,bt as useCreateMetrics,vo as useCreatePersister,Ft as useCreateQueries,qt as useCreateRelationships,ie as useCreateStore,ze as useDelCellCallback,We as useDelRowCallback,Qe as useDelTableCallback,He as useDelTablesCallback,Je as useDelValueCallback,Ge as useDelValuesCallback,vt as useDidFinishTransactionListener,so as useGoBackwardCallback,uo as useGoForwardCallback,io as useGoToCallback,Re as useHasCell,dt as useHasCellListener,fe as useHasRow,ot as useHasRowListener,ve as useHasTable,me as useHasTableCell,$e as useHasTableCellListener,Xe as useHasTableListener,ce as useHasTables,Ke as useHasTablesListener,Se as useHasValue,at as useHasValueListener,xe as useHasValues,st as useHasValuesListener,kt as useIndexIds,A as useIndexes,ft as useIndexesIds,D as useIndexesOrIndexesById,Bt as useLinkedRowIds,Mt as useLinkedRowIdsListener,jt as useLocalRowIds,Et as useLocalRowIdsListener,yt as useMetric,mt as useMetricIds,Ct as useMetricListener,F as useMetrics,gt as useMetricsIds,V as useMetricsOrMetricsById,W as useQueries,Vt as useQueriesIds,z as useQueriesOrQueriesById,At as useQueryIds,co as useRedoInformation,St as useRelationshipIds,H as useRelationships,Ot as useRelationshipsIds,Q as useRelationshipsOrRelationshipsById,Lt as useRemoteRowId,Tt as useRemoteRowIdListener,Kt as useResultCell,Jt as useResultCellIds,_t as useResultCellIdsListener,eo as useResultCellListener,Gt as useResultRow,Qt as useResultRowCount,Xt as useResultRowCountListener,Wt as useResultRowIds,Yt as useResultRowIdsListener,$t as useResultRowListener,zt as useResultSortedRowIds,Zt as useResultSortedRowIdsListener,Dt as useResultTable,Ht as useResultTableCellIds,Ut as useResultTableCellIdsListener,Nt as useResultTableListener,he as useRow,ye as useRowCount,_e as useRowCountListener,Ce as useRowIds,et as useRowIdsListener,rt as useRowListener,Fe as useSetCellCallback,lo as useSetCheckpointCallback,Me as useSetPartialRowCallback,Ae as useSetPartialValuesCallback,Te as useSetRowCallback,Be as useSetTableCallback,je as useSetTablesCallback,De as useSetValueCallback,Ve as useSetValuesCallback,ht as useSliceIds,Pt as useSliceIdsListener,Rt as useSliceRowIds,xt as useSliceRowIdsListener,we as useSortedRowIds,tt as useSortedRowIdsListener,It as useStartTransactionListener,E as useStore,ae as useStoreIds,M as useStoreOrStoreById,be as useTable,ge as useTableCellIds,Ze as useTableCellIdsListener,pe as useTableIds,Ue as useTableIdsListener,Ye as useTableListener,Ie as useTables,Ne as useTablesListener,ao as useUndoInformation,Le as useValue,Oe as useValueIds,it as useValueIdsListener,ct as useValueListener,qe as useValues,ut as useValuesListener,pt as useWillFinishTransactionListener};
1
+ import e from"react";const t=e=>typeof e,o="",r=t(o),n="Listener",l="Result",d="Has",s="has",u="Ids",i="Table",a=i+"s",c=i+u,I="Row",p=I+"Count",v=I+u,b="Sorted"+I+u,g="Cell",m=g+u,C="Value",y=C+"s",w=C+u,f=e=>null==e,k=(e,t,o)=>f(e)?null==o?void 0:o():t(e),h=e=>t(e)==r,R=()=>{},P=(e,t)=>e.map(t),x=Object.keys,q=(e,t)=>k(e,(e=>e[t])),{createContext:S,useContext:O,useEffect:L}=e,j=S([]),B=(e,t)=>{var o;const r=O(j);return f(e)?r[t]:h(e)?q(null!=(o=r[t+1])?o:{},e):e},T=(e,t)=>{const o=B(e,t);return f(e)||h(e)?o:e},E=e=>{var t;return x(null!=(t=O(j)[e])?t:{})},M=e=>B(e,0),F=e=>T(e,0),V=(e,t)=>{const{12:o,13:r}=O(j);L((()=>(null==o||o(e,t),()=>null==r?void 0:r(e))),[o,e,t,r])},A=e=>B(e,2),D=e=>T(e,2),H=e=>B(e,4),Q=e=>T(e,4),W=e=>B(e,6),z=e=>T(e,6),G=e=>B(e,8),J=e=>T(e,8),K=e=>B(e,10),N=e=>T(e,10),U=e=>e.toLowerCase();U(n);const X="Transaction";U(X);const{useCallback:Y,useEffect:Z,useMemo:$,useLayoutEffect:_,useRef:ee,useState:te}=e,oe=[],re={},ne=[[],void 0,[]],le=(e,t,o=oe)=>{const r=$((()=>t(e)),[e,...o]);return Z((()=>()=>r.destroy()),[r]),r},de=(e,t,o,r=oe,n,l="get",d="")=>{const[,s]=te(),u=Y((()=>{var n,d;return null!=(d=null==(n=null==t?void 0:t[l+e])?void 0:n.call(t,...r))?d:o}),[t,e,...r,o]),i=ee();return $((()=>i.current=u()),[u]),se(d+e,t,((...e)=>{i.current=f(n)?u():e[n],s([])}),[u,n],r),i.current},se=(e,t,o,r=oe,l=oe,...d)=>_((()=>{var r;const s=null==(r=null==t?void 0:t["add"+e+n])?void 0:r.call(t,...l,o,...d);return()=>null==t?void 0:t.delListener(s)}),[t,e,...l,...r,...d]),ue=(e,t,o,r=oe,n=R,l=oe,...d)=>{const s=F(e);return Y((e=>k(s,(r=>k(o(e,r),(e=>n(r["set"+t](...d,e),e)))))),[s,t,...r,...l,...d])},ie=(e,t,o=R,r=oe,...n)=>{const l=F(e);return Y((()=>o(null==l?void 0:l["del"+t](...n))),[l,t,...r,...n])},ae=(e,t,o)=>{const r=N(e);return Y((()=>null==r?void 0:r[t](o)),[r,t,o])},ce=(e,t=oe)=>$(e,t),Ie=()=>E(1),pe=e=>de(a,F(e),!1,[],1,s,d),ve=e=>de(a,F(e),re),be=e=>de(c,F(e),oe),ge=(e,t)=>de(i,F(t),!1,[e],2,s,d),me=(e,t)=>de(i,F(t),re,[e]),Ce=(e,t)=>de(i+m,F(t),oe,[e]),ye=(e,t,o)=>de(i+g,F(o),!1,[e,t],3,s,d),we=(e,t)=>de(p,F(t),0,[e]),fe=(e,t)=>de(v,F(t),oe,[e]),ke=(e,t,o,r=0,n,l)=>de(b,F(l),oe,[e,t,o,r,n],6),he=(e,t,o)=>de(I,F(o),!1,[e,t],3,s,d),Re=(e,t,o)=>de(I,F(o),re,[e,t]),Pe=(e,t,o)=>de(m,F(o),oe,[e,t]),xe=(e,t,o,r)=>de(g,F(r),!1,[e,t,o],4,s,d),qe=(e,t,o,r)=>de(g,F(r),void 0,[e,t,o],4),Se=e=>de(y,F(e),!1,[],1,s,d),Oe=e=>de(y,F(e),re),Le=e=>de(w,F(e),oe),je=(e,t)=>de(C,F(t),!1,[e],2,s,d),Be=(e,t)=>de(C,F(t),void 0,[e]),Te=(e,t,o,r,n)=>ue(o,a,e,t,r,n),Ee=(e,t,o,r,n,l)=>ue(r,i,t,o,n,l,e),Me=(e,t,o,r,n,l,d)=>ue(n,I,o,r,l,d,e,t),Fe=(e,t,o=oe,r,n=R,l=oe,d=!0)=>{const s=F(r);return Y((o=>k(s,(r=>k(t(o,r),(t=>n(r.addRow(e,t,d),r,t)))))),[s,e,...o,...l,d])},Ve=(e,t,o,r,n,l,d)=>ue(n,"PartialRow",o,r,l,d,e,t),Ae=(e,t,o,r,n,l,d,s)=>ue(l,g,r,n,d,s,e,t,o),De=(e,t,o,r,n)=>ue(o,y,e,t,r,n),He=(e,t,o,r,n)=>ue(o,"PartialValues",e,t,r,n),Qe=(e,t,o,r,n,l)=>ue(r,C,t,o,n,l,e),We=(e,t,o)=>ie(e,a,t,o),ze=(e,t,o,r)=>ie(t,i,o,r,e),Ge=(e,t,o,r,n)=>ie(o,I,r,n,e,t),Je=(e,t,o,r,n,l,d)=>ie(n,g,l,d,e,t,o,r),Ke=(e,t,o)=>ie(e,y,t,o),Ne=(e,t,o,r)=>ie(t,C,o,r,e),Ue=(e,t,o,r)=>se(d+a,F(r),e,t,[],o),Xe=(e,t,o,r)=>se(a,F(r),e,t,oe,o),Ye=(e,t,o,r)=>se(c,F(r),e,t,oe,o),Ze=(e,t,o,r,n)=>se(d+i,F(n),t,o,[e],r),$e=(e,t,o,r,n)=>se(i,F(n),t,o,[e],r),_e=(e,t,o,r,n)=>se(i+m,F(n),t,o,[e],r),et=(e,t,o,r,n,l)=>se(d+i+g,F(l),o,r,[e,t],n),tt=(e,t,o,r,n)=>se(p,F(n),t,o,[e],r),ot=(e,t,o,r,n)=>se(v,F(n),t,o,[e],r),rt=(e,t,o,r,n,l,d,s,u)=>se(b,F(u),l,d,[e,t,o,r,n],s),nt=(e,t,o,r,n,l)=>se(d+I,F(l),o,r,[e,t],n),lt=(e,t,o,r,n,l)=>se(I,F(l),o,r,[e,t],n),dt=(e,t,o,r,n,l)=>se(m,F(l),o,r,[e,t],n),st=(e,t,o,r,n,l,s)=>se(d+g,F(s),r,n,[e,t,o],l),ut=(e,t,o,r,n,l,d)=>se(g,F(d),r,n,[e,t,o],l),it=(e,t,o,r)=>se(d+y,F(r),e,t,[],o),at=(e,t,o,r)=>se(y,F(r),e,t,oe,o),ct=(e,t,o,r)=>se(w,F(r),e,t,oe,o),It=(e,t,o,r,n)=>se(d+C,F(n),t,o,[e],r),pt=(e,t,o,r,n)=>se(C,F(n),t,o,[e],r),vt=(e,t,o)=>se("Start"+X,F(o),e,t),bt=(e,t,o)=>se("WillFinish"+X,F(o),e,t),gt=(e,t,o)=>se("DidFinish"+X,F(o),e,t),mt=(e,t,o)=>le(e,t,o),Ct=()=>E(3),yt=e=>de("MetricIds",D(e),oe),wt=(e,t)=>de("Metric",D(t),void 0,[e]),ft=(e,t,o,r)=>se("Metric",D(r),t,o,[e]),kt=(e,t,o)=>le(e,t,o),ht=()=>E(5),Rt=(e,t)=>de("SliceIds",Q(t),oe,[e]),Pt=e=>de("IndexIds",Q(e),oe),xt=(e,t,o)=>de("Slice"+v,Q(o),oe,[e,t]),qt=(e,t,o,r)=>se("SliceIds",Q(r),t,o,[e]),St=(e,t,o,r,n)=>se("Slice"+v,Q(n),o,r,[e,t]),Ot=(e,t,o)=>le(e,t,o),Lt=()=>E(7),jt=e=>de("RelationshipIds",z(e),oe),Bt=(e,t,o)=>de("RemoteRowId",z(o),void 0,[e,t]),Tt=(e,t,o)=>de("Local"+v,z(o),oe,[e,t]),Et=(e,t,o)=>de("Linked"+v,z(o),oe,[e,t]),Mt=(e,t,o,r,n)=>se("RemoteRowId",z(n),o,r,[e,t]),Ft=(e,t,o,r,n)=>se("Local"+v,z(n),o,r,[e,t]),Vt=(e,t,o,r,n)=>se("Linked"+v,z(n),o,r,[e,t]),At=(e,t,o)=>le(e,t,o),Dt=()=>E(9),Ht=e=>de("QueryIds",J(e),oe),Qt=(e,t)=>de(l+i,J(t),re,[e]),Wt=(e,t)=>de(l+i+m,J(t),oe,[e]),zt=(e,t)=>de(l+p,J(t),0,[e]),Gt=(e,t)=>de(l+v,J(t),oe,[e]),Jt=(e,t,o,r=0,n,d)=>de(l+b,J(d),oe,[e,t,o,r,n],6),Kt=(e,t,o)=>de(l+I,J(o),re,[e,t]),Nt=(e,t,o)=>de(l+m,J(o),oe,[e,t]),Ut=(e,t,o,r)=>de(l+g,J(r),void 0,[e,t,o]),Xt=(e,t,o,r)=>se(l+i,J(r),t,o,[e]),Yt=(e,t,o,r)=>se(l+i+m,J(r),t,o,[e]),Zt=(e,t,o,r)=>se(l+p,J(r),t,o,[e]),$t=(e,t,o,r)=>se(l+v,J(r),t,o,[e]),_t=(e,t,o,r,n,d,s,u)=>se(l+b,J(u),d,s,[e,t,o,r,n]),eo=(e,t,o,r,n)=>se(l+I,J(n),o,r,[e,t]),to=(e,t,o,r,n)=>se(l+m,J(n),o,r,[e,t]),oo=(e,t,o,r,n,d)=>se(l+g,J(d),r,n,[e,t,o]),ro=(e,t,o)=>le(e,t,o),no=()=>E(11),lo=e=>de("CheckpointIds",N(e),ne),so=(e,t)=>de("Checkpoint",N(t),void 0,[e]),uo=(e=R,t=oe,o,r=R,n=oe)=>{const l=N(o);return Y((t=>k(l,(o=>{const n=e(t);r(o.addCheckpoint(n),o,n)}))),[l,...t,...n])},io=e=>ae(e,"goBackward"),ao=e=>ae(e,"goForward"),co=(e,t=oe,o,r=R,n=oe)=>{const l=N(o);return Y((t=>k(l,(o=>k(e(t),(e=>r(o.goTo(e),e)))))),[l,...t,...n])},Io=e=>{var t;const r=N(e),[n,l]=lo(r);return[(d=n,!(0==d.length)),io(r),l,null!=(t=k(l,(e=>null==r?void 0:r.getCheckpoint(e))))?t:o];var d},po=e=>{var t;const r=N(e),[,,[n]]=lo(r);return[!f(n),ao(r),n,null!=(t=k(n,(e=>null==r?void 0:r.getCheckpoint(e))))?t:o]},vo=(e,t,o)=>se("CheckpointIds",N(o),e,t),bo=(e,t,o,r)=>se("Checkpoint",N(r),t,o,[e]),go=(e,t,o=oe,r,n=oe,l,d=oe)=>{const[,s]=te(),u=$((()=>t(e)),[e,...o]);return Z((()=>{var e;return e=function*(){r&&(yield r(u),s([]))},new Promise(((t,o)=>{var r=t=>{try{l(e.next(t))}catch(e){o(e)}},n=t=>{try{l(e.throw(t))}catch(e){o(e)}},l=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,n);l((e=e.apply(void 0,null)).next())})),()=>{null==u||u.destroy(),null==l||l(u)}}),[u,...n,...d]),u},{PureComponent:mo,Fragment:Co,createElement:yo,useCallback:wo,useLayoutEffect:fo,useRef:ko,useState:ho}=e,Ro=(e,...t)=>f(e)?{}:e(...t),Po=(e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)];var xo=Object.defineProperty,qo=Object.defineProperties,So=Object.getOwnPropertyDescriptors,Oo=Object.getOwnPropertySymbols,Lo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Bo=(e,t,o)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,To=(e,t)=>{for(var o in t||(t={}))Lo.call(t,o)&&Bo(e,o,t[o]);if(Oo)for(var o of Oo(t))jo.call(t,o)&&Bo(e,o,t[o]);return e},Eo=(e,t)=>qo(e,So(t)),Mo=(e,t)=>{var o={};for(var r in e)Lo.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&Oo)for(var r of Oo(e))t.indexOf(r)<0&&jo.call(e,r)&&(o[r]=e[r]);return o};const{useCallback:Fo,useContext:Vo,useMemo:Ao,useState:Do}=e,Ho=({tableId:e,store:t,rowComponent:o=No,getRowComponentProps:r,customCellIds:n,separator:l,debugIds:d},s)=>Jo(P(s,(l=>yo(o,Eo(To({},Ro(r,l)),{key:l,tableId:e,rowId:l,customCellIds:n,store:t,debugIds:d})))),l,d,e),Qo=({queryId:e,queries:t,resultRowComponent:o=dr,getResultRowComponentProps:r,separator:n,debugIds:l},d)=>Jo(P(d,(n=>yo(o,Eo(To({},Ro(r,n)),{key:n,queryId:e,rowId:n,queries:t,debugIds:l})))),n,l,e),Wo=({relationshipId:e,relationships:t,rowComponent:o=No,getRowComponentProps:r,separator:n,debugIds:l},d,s)=>{const[u,i,a]=Po(z(t),e),c=d(e,s,u);return Jo(P(c,(e=>yo(o,Eo(To({},Ro(r,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:l})))),n,l,s)},zo=e=>({checkpoints:t,checkpointComponent:o=ir,getCheckpointComponentProps:r,separator:n,debugIds:l})=>{const d=N(t);return Jo(P(e(lo(d)),(e=>yo(o,Eo(To({},Ro(r,e)),{key:e,checkpoints:d,checkpointId:e,debugIds:l})))),n)},Go=({store:e,storesById:t,metrics:o,metricsById:r,indexes:n,indexesById:l,relationships:d,relationshipsById:s,queries:u,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const p=Vo(j),[v,b]=Do({}),g=Fo(((e,t)=>b((o=>q(o,e)==t?o:Eo(To({},o),{[e]:t})))),[]),m=Fo((e=>b((t=>To({},((e,t)=>(delete e[t],e))(t,e))))),[]);return yo(j.Provider,{value:Ao((()=>[null!=e?e:p[0],To(To(To({},p[1]),t),v),null!=o?o:p[2],To(To({},p[3]),r),null!=n?n:p[4],To(To({},p[5]),l),null!=d?d:p[6],To(To({},p[7]),s),null!=u?u:p[8],To(To({},p[9]),i),null!=a?a:p[10],To(To({},p[11]),c),g,m]),[e,t,v,o,r,n,l,d,s,u,i,a,c,p,g,m])},I)},Jo=(e,t,o,r)=>{const n=f(t)||!Array.isArray(e)?e:P(e,((e,o)=>o>0?[t,e]:e));return o?[r,":{",n,"}"]:n},Ko=({tableId:e,rowId:t,cellId:r,store:n,debugIds:l})=>{var d;return Jo(o+(null!=(d=qe(e,t,r,n))?d:o),void 0,l,r)},No=({tableId:e,rowId:t,store:o,cellComponent:r=Ko,getCellComponentProps:n,customCellIds:l,separator:d,debugIds:s})=>Jo(P(((e,t,o,r)=>{const n=Pe(t,o,r);return null!=e?e:n})(l,e,t,o),(l=>yo(r,Eo(To({},Ro(n,l)),{key:l,tableId:e,rowId:t,cellId:l,store:o,debugIds:s})))),d,s,t),Uo=e=>Ho(e,fe(e.tableId,e.store)),Xo=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:l}=t,d=Mo(t,["cellId","descending","offset","limit"]);return Ho(d,ke(d.tableId,o,r,n,l,d.store))},Yo=({store:e,tableComponent:t=Uo,getTableComponentProps:o,separator:r,debugIds:n})=>Jo(P(be(e),(r=>yo(t,Eo(To({},Ro(o,r)),{key:r,tableId:r,store:e,debugIds:n})))),r),Zo=({valueId:e,store:t,debugIds:r})=>{var n;return Jo(o+(null!=(n=Be(e,t))?n:o),void 0,r,e)},$o=({store:e,valueComponent:t=Zo,getValueComponentProps:o,separator:r,debugIds:n})=>Jo(P(Le(e),(r=>yo(t,Eo(To({},Ro(o,r)),{key:r,valueId:r,store:e,debugIds:n})))),r),_o=({metricId:e,metrics:t,debugIds:r})=>{var n;return Jo(null!=(n=wt(e,t))?n:o,void 0,r,e)},er=({indexId:e,sliceId:t,indexes:o,rowComponent:r=No,getRowComponentProps:n,separator:l,debugIds:d})=>{const[s,u,i]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(Q(o),e),a=xt(e,t,s);return Jo(P(a,(e=>yo(r,Eo(To({},Ro(n,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:d})))),l,d,t)},tr=({indexId:e,indexes:t,sliceComponent:o=er,getSliceComponentProps:r,separator:n,debugIds:l})=>Jo(P(Rt(e,t),(n=>yo(o,Eo(To({},Ro(r,n)),{key:n,indexId:e,sliceId:n,indexes:t,debugIds:l})))),n,l,e),or=({relationshipId:e,localRowId:t,relationships:o,rowComponent:r=No,getRowComponentProps:n,debugIds:l})=>{const[d,s,,u]=Po(z(o),e),i=Bt(e,t,d);return Jo(f(u)||f(i)?null:yo(r,Eo(To({},Ro(n,i)),{key:i,tableId:u,rowId:i,store:s,debugIds:l})),void 0,l,t)},rr=e=>Wo(e,Tt,e.remoteRowId),nr=e=>Wo(e,Et,e.firstRowId),lr=({queryId:e,rowId:t,cellId:r,queries:n,debugIds:l})=>{var d;return Jo(o+(null!=(d=Ut(e,t,r,n))?d:o),void 0,l,r)},dr=({queryId:e,rowId:t,queries:o,resultCellComponent:r=lr,getResultCellComponentProps:n,separator:l,debugIds:d})=>Jo(P(Nt(e,t,o),(l=>yo(r,Eo(To({},Ro(n,l)),{key:l,queryId:e,rowId:t,cellId:l,queries:o,debugIds:d})))),l,d,t),sr=e=>Qo(e,Gt(e.queryId,e.queries)),ur=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:l}=t,d=Mo(t,["cellId","descending","offset","limit"]);return Qo(d,Jt(d.queryId,o,r,n,l,d.queries))},ir=({checkpoints:e,checkpointId:t,debugIds:r})=>{var n;return Jo(null!=(n=so(t,e))?n:o,void 0,r,t)},ar=zo((e=>e[0])),cr=zo((e=>f(e[1])?[]:[e[1]])),Ir=zo((e=>e[2]));export{ar as BackwardCheckpointsView,Ko as CellView,ir as CheckpointView,cr as CurrentCheckpointView,Ir as ForwardCheckpointsView,tr as IndexView,nr as LinkedRowsView,rr as LocalRowsView,_o as MetricView,Go as Provider,or as RemoteRowView,lr as ResultCellView,dr as ResultRowView,ur as ResultSortedTableView,sr as ResultTableView,No as RowView,er as SliceView,Xo as SortedTableView,Uo as TableView,Yo as TablesView,Zo as ValueView,$o as ValuesView,Fe as useAddRowCallback,qe as useCell,Pe as useCellIds,dt as useCellIdsListener,ut as useCellListener,so as useCheckpoint,lo as useCheckpointIds,vo as useCheckpointIdsListener,bo as useCheckpointListener,K as useCheckpoints,no as useCheckpointsIds,N as useCheckpointsOrCheckpointsById,ro as useCreateCheckpoints,kt as useCreateIndexes,mt as useCreateMetrics,go as useCreatePersister,At as useCreateQueries,Ot as useCreateRelationships,ce as useCreateStore,Je as useDelCellCallback,Ge as useDelRowCallback,ze as useDelTableCallback,We as useDelTablesCallback,Ne as useDelValueCallback,Ke as useDelValuesCallback,gt as useDidFinishTransactionListener,io as useGoBackwardCallback,ao as useGoForwardCallback,co as useGoToCallback,xe as useHasCell,st as useHasCellListener,he as useHasRow,nt as useHasRowListener,ge as useHasTable,ye as useHasTableCell,et as useHasTableCellListener,Ze as useHasTableListener,pe as useHasTables,Ue as useHasTablesListener,je as useHasValue,It as useHasValueListener,Se as useHasValues,it as useHasValuesListener,Pt as useIndexIds,H as useIndexes,ht as useIndexesIds,Q as useIndexesOrIndexesById,Et as useLinkedRowIds,Vt as useLinkedRowIdsListener,Tt as useLocalRowIds,Ft as useLocalRowIdsListener,wt as useMetric,yt as useMetricIds,ft as useMetricListener,A as useMetrics,Ct as useMetricsIds,D as useMetricsOrMetricsById,V as useProvideStore,G as useQueries,Dt as useQueriesIds,J as useQueriesOrQueriesById,Ht as useQueryIds,po as useRedoInformation,jt as useRelationshipIds,W as useRelationships,Lt as useRelationshipsIds,z as useRelationshipsOrRelationshipsById,Bt as useRemoteRowId,Mt as useRemoteRowIdListener,Ut as useResultCell,Nt as useResultCellIds,to as useResultCellIdsListener,oo as useResultCellListener,Kt as useResultRow,zt as useResultRowCount,Zt as useResultRowCountListener,Gt as useResultRowIds,$t as useResultRowIdsListener,eo as useResultRowListener,Jt as useResultSortedRowIds,_t as useResultSortedRowIdsListener,Qt as useResultTable,Wt as useResultTableCellIds,Yt as useResultTableCellIdsListener,Xt as useResultTableListener,Re as useRow,we as useRowCount,tt as useRowCountListener,fe as useRowIds,ot as useRowIdsListener,lt as useRowListener,Ae as useSetCellCallback,uo as useSetCheckpointCallback,Ve as useSetPartialRowCallback,He as useSetPartialValuesCallback,Me as useSetRowCallback,Ee as useSetTableCallback,Te as useSetTablesCallback,Qe as useSetValueCallback,De as useSetValuesCallback,Rt as useSliceIds,qt as useSliceIdsListener,xt as useSliceRowIds,St as useSliceRowIdsListener,ke as useSortedRowIds,rt as useSortedRowIdsListener,vt as useStartTransactionListener,M as useStore,Ie as useStoreIds,F as useStoreOrStoreById,me as useTable,Ce as useTableCellIds,_e as useTableCellIdsListener,be as useTableIds,Ye as useTableIdsListener,$e as useTableListener,ve as useTables,Xe as useTablesListener,Io as useUndoInformation,Be as useValue,Le as useValueIds,ct as useValueIdsListener,pt as useValueListener,Oe as useValues,at as useValuesListener,bt as useWillFinishTransactionListener};
Binary file
@@ -1 +1 @@
1
- const t=t=>typeof t,a="",e=t(a),s="t",n=(t,a)=>t.startsWith(a),r=Promise,i=t=>null==t,c=(t,a,e)=>i(t)?e?.():a(t),o=(t,a,e)=>t.slice(a,e),l=t=>t.length,h=async t=>r.all(t),u=(t,a)=>t.map(a),w=(t,...a)=>t.push(...a),g=Object,f=(t=[])=>g.fromEntries(t),y=(t,a)=>u(g.entries(t),(([t,e])=>a(e,t))),p=(t,a,e)=>(((t,a)=>!i(((t,a)=>c(t,(t=>t[a])))(t,a)))(t,a)||(t[a]=e()),t[a]),S=t=>JSON.stringify(t,((t,a)=>a instanceof Map?g.fromEntries([...a]):a)),d=JSON.parse,D=(a,s,n)=>a+s+(t(n)==e?n:S(n)),m=(t,a,e)=>{const s=l(t);return n(a,t)?[a[s],(e?d:String)(o(a,s+1))]:void 0},P=(t,a)=>((t,a)=>t?.forEach(a))(t,((t,e)=>a(e,t))),R="hasStore",b=f(u(["Origin","Methods","Headers"],(t=>["Access-Control-Allow-"+t,"*"]))),x=async t=>await t.party.storage.get((t.config.storagePrefix??a)+R),C=async(t,e,r,c)=>{const o=t.party.storage,u=t.config.storagePrefix??a,g={[u+R]:1},f=[],p=[];await h(y(e[0],(async(a,e)=>i(a)?!r&&t.canDelTable(e,c)&&((t,...a)=>t.unshift(...a))(p,T(u,s,e)):t.canSetTable(e,r,c)&&await h(y(a,(async(a,n)=>i(a)?!r&&t.canDelRow(e,n,c)&&w(p,T(u,s,e,n)):t.canSetRow(e,n,r,c)&&await h(y(a,(async(a,l)=>{const h=[e,n,l],y=T(u,s,...h);i(a)?!r&&t.canDelCell(...h,c)&&w(f,y):t.canSetCell(...h,a,r,c,await o.get(y))&&(g[y]=a)}))))))))),await h(y(e[1],(async(a,e)=>{const s=u+"v"+e;i(a)?!r&&t.canDelValue(e,c)&&w(f,s):t.canSetValue(e,a,r,c,await o.get(s))&&(g[s]=a)}))),0!=l(p)&&P(await o.list(),(t=>p.every((a=>!n(t,a)||w(f,t)&&0)))),await o.delete(f),await o.put(g)},T=(t,a,...e)=>D(t,a,o(S(e),1,-1)),v=async(t,a,e=null)=>new Response(e,{status:a,headers:t.config.responseHeaders??b});class O{constructor(t){this.party=t,this.config={}}async onRequest(t){const e=this.config.storePath??"/store";if(new URL(t.url).pathname.endsWith(e)){const e=await x(this),n=await t.text();return"PUT"==t.method?e?v(this,205):(await C(this,d(n),!0,t),v(this,201)):v(this,200,e?S(await(async t=>{const e={},n={},r=t.config.storagePrefix??a;return P(await t.party.storage.list(),((t,a)=>c(m(r,t),(([t,r])=>{if(t==s){const[t,s,n]=d("["+r+"]");p(p(e,t,f),s,f)[n]=a}else"v"==t&&(n[r]=a)})))),[e,n]})(this)):a)}return v(this,404)}async onMessage(t,e){const s=this.config.messagePrefix??a;await c(m(s,t,1),(async([t,a])=>{"s"==t&&await x(this)&&(await C(this,a,!1,e),this.party.broadcast(D(s,"s",a)))}))}canSetTable(t,a,e){return!0}canDelTable(t,a){return!0}canSetRow(t,a,e,s){return!0}canDelRow(t,a,e){return!0}canSetCell(t,a,e,s,n,r,i){return!0}canDelCell(t,a,e,s){return!0}canSetValue(t,a,e,s,n){return!0}canDelValue(t,a){return!0}}export{O as TinyBasePartyKitServer};
1
+ const t=t=>typeof t,e=t(""),a="t",s=(t,e)=>t.startsWith(e),n=Promise,r=t=>null==t,i=(t,e,a)=>r(t)?a?.():e(t),c=(t,e,a)=>t.slice(e,a),o=t=>t.length,l=async t=>n.all(t),h=(t,e)=>t.map(e),g=(t,...e)=>t.push(...e),u=Object,w=(t=[])=>u.fromEntries(t),f=(t,e)=>h(u.entries(t),(([t,a])=>e(a,t))),y=(t,e,a)=>(((t,e)=>!r(((t,e)=>i(t,(t=>t[e])))(t,e)))(t,e)||(t[e]=a()),t[e]),p=t=>JSON.stringify(t,((t,e)=>e instanceof Map?u.fromEntries([...e]):e)),S=JSON.parse,d=(a,s,n)=>a+s+(t(n)==e?n:p(n)),P=(t,e,a)=>{const n=o(t);return s(e,t)?[e[n],(a?S:String)(c(e,n+1))]:void 0},m=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,a)=>e(a,t))),x="hasStore",D=w(h(["Origin","Methods","Headers"],(t=>["Access-Control-Allow-"+t,"*"]))),R=async(t,e="")=>!!await t.get(e+x),b=async(t,e="")=>{const s={},n={};return m(await t.list(),((t,r)=>i(P(e,t),(([t,e])=>{if(t==a){const[t,a,n]=S("["+e+"]");y(y(s,t,w),a,w)[n]=r}else"v"==t&&(n[e]=r)})))),[s,n]},C=async(t,e,n,i)=>{const c=t.party.storage,h=t.config.storagePrefix,u={[h+x]:1},w=[],y=[];await l(f(e[0],(async(e,s)=>r(e)?!n&&t.canDelTable(s,i)&&((t,...e)=>t.unshift(...e))(y,T(h,a,s)):t.canSetTable(s,n,i)&&await l(f(e,(async(e,o)=>r(e)?!n&&t.canDelRow(s,o,i)&&g(y,T(h,a,s,o)):t.canSetRow(s,o,n,i)&&await l(f(e,(async(e,l)=>{const f=[s,o,l],y=T(h,a,...f);r(e)?!n&&t.canDelCell(...f,i)&&g(w,y):t.canSetCell(...f,e,n,i,await c.get(y))&&(u[y]=e)}))))))))),await l(f(e[1],(async(e,a)=>{const s=h+"v"+a;r(e)?!n&&t.canDelValue(a,i)&&g(w,s):t.canSetValue(a,e,n,i,await c.get(s))&&(u[s]=e)}))),0!=o(y)&&m(await c.list(),(t=>y.every((e=>!s(t,e)||g(w,t)&&0)))),await c.delete(w),await c.put(u)},T=(t,e,...a)=>d(t,e,c(p(a),1,-1)),v=async(t,e,a=null)=>new Response(a,{status:e,headers:t.config.responseHeaders});class O{constructor(t){this.party=t,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=D}async onRequest(t){const{party:{storage:e},config:{storePath:a,storagePrefix:s}}=this;if(new URL(t.url).pathname.endsWith(a)){const a=await R(e,s),n=await t.text();return"PUT"==t.method?a?v(this,205):(await C(this,S(n),!0,t),v(this,201)):v(this,200,a?p(await b(e,s)):"")}return v(this,404)}async onMessage(t,e){const{party:{storage:a,broadcast:s},config:{messagePrefix:n,storagePrefix:r}}=this;await i(P(n,t,1),(async([t,i])=>{"s"==t&&await R(a,r)&&(await C(this,i,!1,e),s(d(n,"s",i),[e.id]))}))}canSetTable(t,e,a){return!0}canDelTable(t,e){return!0}canSetRow(t,e,a,s){return!0}canDelRow(t,e,a){return!0}canSetCell(t,e,a,s,n,r,i){return!0}canDelCell(t,e,a,s){return!0}canSetValue(t,e,a,s,n){return!0}canDelValue(t,e){return!0}}export{O as TinyBasePartyKitServer,R as hasStoreInStorage,b as loadStoreFromStorage};
@@ -380,8 +380,8 @@ export interface Metrics {
380
380
  * remove == metric
381
381
  * ? undefined
382
382
  * : add > 2
383
- * ? Math.min(metric, add)
384
- * : metric,
383
+ * ? Math.min(metric, add)
384
+ * : metric,
385
385
  * );
386
386
  *
387
387
  * console.log(metrics.getMetric('lowestPriceOver2'));