tinybase 5.0.1 → 5.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/@types/synchronizers/synchronizer-ws-server/index.d.cts +32 -27
  2. package/@types/synchronizers/synchronizer-ws-server/index.d.ts +32 -27
  3. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.cts +32 -27
  4. package/@types/synchronizers/synchronizer-ws-server/with-schemas/index.d.ts +32 -27
  5. package/@types/ui-react/index.d.cts +62 -45
  6. package/@types/ui-react/index.d.ts +62 -45
  7. package/@types/ui-react/with-schemas/index.d.cts +83 -59
  8. package/@types/ui-react/with-schemas/index.d.ts +83 -59
  9. package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
  10. package/cjs/es6/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
  11. package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
  12. package/cjs/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
  13. package/cjs/es6/min/ui-react/index.cjs +1 -1
  14. package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
  15. package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
  16. package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
  17. package/cjs/es6/synchronizers/synchronizer-ws-server/index.cjs +4 -6
  18. package/cjs/es6/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +4 -6
  19. package/cjs/es6/ui-react/index.cjs +13 -6
  20. package/cjs/es6/ui-react/with-schemas/index.cjs +13 -6
  21. package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs +1 -1
  22. package/cjs/min/synchronizers/synchronizer-ws-server/index.cjs.gz +0 -0
  23. package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +1 -1
  24. package/cjs/min/synchronizers/synchronizer-ws-server/with-schemas/index.cjs.gz +0 -0
  25. package/cjs/min/ui-react/index.cjs +1 -1
  26. package/cjs/min/ui-react/index.cjs.gz +0 -0
  27. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  28. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  29. package/cjs/synchronizers/synchronizer-ws-server/index.cjs +4 -4
  30. package/cjs/synchronizers/synchronizer-ws-server/with-schemas/index.cjs +4 -4
  31. package/cjs/ui-react/index.cjs +11 -6
  32. package/cjs/ui-react/with-schemas/index.cjs +11 -6
  33. package/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  34. package/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  35. package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  36. package/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  37. package/es6/min/ui-react/index.js +1 -1
  38. package/es6/min/ui-react/index.js.gz +0 -0
  39. package/es6/min/ui-react/with-schemas/index.js +1 -1
  40. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  41. package/es6/synchronizers/synchronizer-ws-server/index.js +4 -6
  42. package/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
  43. package/es6/ui-react/index.js +13 -6
  44. package/es6/ui-react/with-schemas/index.js +13 -6
  45. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  46. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  47. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  48. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  49. package/min/ui-react/index.js +1 -1
  50. package/min/ui-react/index.js.gz +0 -0
  51. package/min/ui-react/with-schemas/index.js +1 -1
  52. package/min/ui-react/with-schemas/index.js.gz +0 -0
  53. package/package.json +1 -1
  54. package/readme.md +2 -2
  55. package/synchronizers/synchronizer-ws-server/index.js +4 -4
  56. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -4
  57. package/ui-react/index.js +11 -6
  58. package/ui-react/with-schemas/index.js +11 -6
  59. package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  60. package/umd/es6/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  61. package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  62. package/umd/es6/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  63. package/umd/es6/min/ui-react/index.js +1 -1
  64. package/umd/es6/min/ui-react/index.js.gz +0 -0
  65. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  66. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  67. package/umd/es6/synchronizers/synchronizer-ws-server/index.js +4 -6
  68. package/umd/es6/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
  69. package/umd/es6/ui-react/index.js +16 -6
  70. package/umd/es6/ui-react/with-schemas/index.js +16 -6
  71. package/umd/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  72. package/umd/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  73. package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  74. package/umd/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  75. package/umd/min/ui-react/index.js +1 -1
  76. package/umd/min/ui-react/index.js.gz +0 -0
  77. package/umd/min/ui-react/with-schemas/index.js +1 -1
  78. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  79. package/umd/synchronizers/synchronizer-ws-server/index.js +4 -6
  80. package/umd/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -6
  81. package/umd/ui-react/index.js +12 -6
  82. package/umd/ui-react/with-schemas/index.js +12 -6
@@ -242,9 +242,9 @@
242
242
  const clients = mapEnsure(clientsByPath, pathId, mapNew);
243
243
  mapSet(clients, clientId, webSocket);
244
244
  if (clients.size == 1) {
245
- callListeners(pathIdListeners, void 0, () => ({[pathId]: 1}));
245
+ callListeners(pathIdListeners, void 0, pathId, 1);
246
246
  }
247
- callListeners(clientIdListeners, [pathId], () => ({[clientId]: 1}));
247
+ callListeners(clientIdListeners, [pathId], clientId, 1);
248
248
  webSocket.on('message', (data) => {
249
249
  var _a2;
250
250
  const payload = data.toString(UTF8);
@@ -267,12 +267,10 @@
267
267
  });
268
268
  webSocket.on('close', () => {
269
269
  collDel(clients, clientId);
270
- callListeners(clientIdListeners, [pathId], () => ({
271
- [clientId]: -1,
272
- }));
270
+ callListeners(clientIdListeners, [pathId], clientId, -1);
273
271
  if (collIsEmpty(clients)) {
274
272
  collDel(clientsByPath, pathId);
275
- callListeners(pathIdListeners, void 0, () => ({[pathId]: -1}));
273
+ callListeners(pathIdListeners, void 0, pathId, -1);
276
274
  }
277
275
  });
278
276
  }),
@@ -242,9 +242,9 @@
242
242
  const clients = mapEnsure(clientsByPath, pathId, mapNew);
243
243
  mapSet(clients, clientId, webSocket);
244
244
  if (clients.size == 1) {
245
- callListeners(pathIdListeners, void 0, () => ({[pathId]: 1}));
245
+ callListeners(pathIdListeners, void 0, pathId, 1);
246
246
  }
247
- callListeners(clientIdListeners, [pathId], () => ({[clientId]: 1}));
247
+ callListeners(clientIdListeners, [pathId], clientId, 1);
248
248
  webSocket.on('message', (data) => {
249
249
  var _a2;
250
250
  const payload = data.toString(UTF8);
@@ -267,12 +267,10 @@
267
267
  });
268
268
  webSocket.on('close', () => {
269
269
  collDel(clients, clientId);
270
- callListeners(clientIdListeners, [pathId], () => ({
271
- [clientId]: -1,
272
- }));
270
+ callListeners(clientIdListeners, [pathId], clientId, -1);
273
271
  if (collIsEmpty(clients)) {
274
272
  collDel(clientsByPath, pathId);
275
- callListeners(pathIdListeners, void 0, () => ({[pathId]: -1}));
273
+ callListeners(pathIdListeners, void 0, pathId, -1);
276
274
  }
277
275
  });
278
276
  }),
@@ -52,6 +52,7 @@
52
52
  arrayEvery(array1, (value1, index) => array2[index] === value1);
53
53
  const arrayMap = (array, cb) => array.map(cb);
54
54
  const arrayIsEmpty = (array) => size(array) == 0;
55
+ const arrayFilter = (array, cb) => array.filter(cb);
55
56
 
56
57
  const object = Object;
57
58
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -291,9 +292,7 @@
291
292
  ifNotUndefined(get(parameter, store2), (thing) =>
292
293
  then(
293
294
  store2['set' + settable](
294
- ...arrayMap(args, (arg) =>
295
- isFunction(arg) ? arg(parameter, store2) : arg,
296
- ),
295
+ ...argsOrGetArgs(args, store2, parameter),
297
296
  thing,
298
297
  ),
299
298
  thing,
@@ -301,9 +300,13 @@
301
300
  ),
302
301
  ),
303
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
304
- [store, settable, ...getDeps, ...thenDeps, ...args],
303
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
305
304
  );
306
305
  };
306
+ const argsOrGetArgs = (args, store, parameter) =>
307
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
308
+ const nonFunctionDeps = (args) =>
309
+ arrayFilter(args, (arg) => !isFunction(arg));
307
310
  const useDel = (
308
311
  storeOrStoreId,
309
312
  deletable,
@@ -313,9 +316,16 @@
313
316
  ) => {
314
317
  const store = useStoreOrStoreById(storeOrStoreId);
315
318
  return useCallback$2(
316
- () => then(store == null ? void 0 : store['del' + deletable](...args)),
319
+ (parameter) =>
320
+ then(
321
+ store == null
322
+ ? void 0
323
+ : store['del' + deletable](
324
+ ...argsOrGetArgs(args, store, parameter),
325
+ ),
326
+ ),
317
327
  // eslint-disable-next-line react-hooks/exhaustive-deps
318
- [store, deletable, ...thenDeps, ...args],
328
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
319
329
  );
320
330
  };
321
331
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
@@ -52,6 +52,7 @@
52
52
  arrayEvery(array1, (value1, index) => array2[index] === value1);
53
53
  const arrayMap = (array, cb) => array.map(cb);
54
54
  const arrayIsEmpty = (array) => size(array) == 0;
55
+ const arrayFilter = (array, cb) => array.filter(cb);
55
56
 
56
57
  const object = Object;
57
58
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -291,9 +292,7 @@
291
292
  ifNotUndefined(get(parameter, store2), (thing) =>
292
293
  then(
293
294
  store2['set' + settable](
294
- ...arrayMap(args, (arg) =>
295
- isFunction(arg) ? arg(parameter, store2) : arg,
296
- ),
295
+ ...argsOrGetArgs(args, store2, parameter),
297
296
  thing,
298
297
  ),
299
298
  thing,
@@ -301,9 +300,13 @@
301
300
  ),
302
301
  ),
303
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
304
- [store, settable, ...getDeps, ...thenDeps, ...args],
303
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
305
304
  );
306
305
  };
306
+ const argsOrGetArgs = (args, store, parameter) =>
307
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
308
+ const nonFunctionDeps = (args) =>
309
+ arrayFilter(args, (arg) => !isFunction(arg));
307
310
  const useDel = (
308
311
  storeOrStoreId,
309
312
  deletable,
@@ -313,9 +316,16 @@
313
316
  ) => {
314
317
  const store = useStoreOrStoreById(storeOrStoreId);
315
318
  return useCallback$2(
316
- () => then(store == null ? void 0 : store['del' + deletable](...args)),
319
+ (parameter) =>
320
+ then(
321
+ store == null
322
+ ? void 0
323
+ : store['del' + deletable](
324
+ ...argsOrGetArgs(args, store, parameter),
325
+ ),
326
+ ),
317
327
  // eslint-disable-next-line react-hooks/exhaustive-deps
318
- [store, deletable, ...thenDeps, ...args],
328
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
319
329
  );
320
330
  };
321
331
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,s)=>t(e)?s?.():n(e),s=(e,t,n)=>e.slice(t,n),r=e=>e.length,o=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),i=Object.freeze,d=e=>e?.size??0,a=(l=d,e=>{return t=(e,t)=>e+l(t),f(e).reduce(t,0);var t});var l;const u=e=>t(e)||0==d(e),f=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),y=e=>new Map(e),g=e=>[...e?.keys()??[]],p=(e,t)=>e?.get(t),S=(e,n,s)=>t(s)?(v(e,n),e):e?.set(n,s),b=(e,t,n,s)=>{var r,o;return r=e,o=t,r?.has(o)?s?.(p(e,t)):S(e,t,n()),p(e,t)},k=(e,t,s,o,c=0)=>n((s?b:p)(e,t[c],c>r(t)-2?s:y),(n=>{if(c>r(t)-2)return o?.(n)&&S(e,t[c]),n;const i=k(n,t,s,o,c+1);return u(n)&&S(e,t[c]),i})),m=e=>new Set(Array.isArray(e)||t(e)?e:[e]),x=/^\d+$/,z=/\/([^?]*)/;e.createWsServer=e=>{const l=y(),f=y(),I=y(),[w,L,T]=(e=>{let s;const[i,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{x.test(t)&&r(e)<1e3&&c(e,t)}]})(),a=y();return[(e,t,n,r=[],o=(()=>[]))=>{s??=W;const c=i(1);var d,l;return S(a,c,[e,t,n,r,o]),d=k(t,n??[""],m),l=c,d?.add(l),c},(e,t,...n)=>o(((e,t=[""])=>{const n=[],s=(e,i)=>i==r(t)?c(n,e):null===t[i]?h(e,(e=>s(e,i+1))):o([t[i],null],(t=>s(p(e,t),i+1)));return s(e,0),n})(e,t),(e=>h(e,(e=>p(a,e)[0](s,...t??[],...n))))),e=>n(p(a,e),(([,t,n])=>(k(t,n??[""],void 0,(t=>(v(t,e),u(t)?1:0))),S(a,e),d(e),n))),e=>n(p(a,e),(([e,,n=[],c,i])=>{const d=(...a)=>{const l=r(a);l==r(n)?e(s,...a,...i(a)):t(n[l])?o(c[l]?.(...a)??[],(e=>d(...a,e))):d(...a,n[l])};d()}))]})();e.on("connection",((e,t)=>n(t.url?.match(z),(([,r])=>n(t.headers["sec-websocket-key"],(t=>{const n=b(I,r,y);S(n,t,e),1==n.size&&L(l,void 0,(()=>({[r]:1}))),L(f,[r],(()=>({[t]:1}))),e.on("message",(e=>{const r=e.toString("utf8"),o=r.indexOf("\n");if(-1!==o){const e=s(r,0,o),i=s(r,o+1);""===e?(c=(e,n)=>e!=t?n.send(t+"\n"+i):0,h(n,((e,t)=>c(t,e)))):p(n,e)?.send(t+"\n"+i)}var c})),e.on("close",(()=>{v(n,t),L(f,[r],(()=>({[t]:-1}))),u(n)&&(v(I,r),L(l,void 0,(()=>({[r]:-1}))))}))}))))));const W={getWebSocketServer:()=>e,getPathIds:()=>g(I),getClientIds:e=>g(p(I,e)),addPathIdsListener:e=>w(e,l),addClientIdsListener:(e,t)=>w(t,f,[e]),delListener:e=>(T(e),W),getStats:()=>({paths:d(I),clients:a(I)}),destroy:()=>{e.close(),I.clear()}};return i(W)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseSynchronizerWsServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,s)=>t(e)?s?.():n(e),s=(e,t,n)=>e.slice(t,n),r=e=>e.length,o=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),i=Object.freeze,d=e=>e?.size??0,a=(l=d,e=>{return t=(e,t)=>e+l(t),f(e).reduce(t,0);var t});var l;const u=e=>t(e)||0==d(e),f=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),y=e=>new Map(e),g=e=>[...e?.keys()??[]],p=(e,t)=>e?.get(t),S=(e,n,s)=>t(s)?(v(e,n),e):e?.set(n,s),b=(e,t,n,s)=>{var r,o;return r=e,o=t,r?.has(o)?s?.(p(e,t)):S(e,t,n()),p(e,t)},k=(e,t,s,o,c=0)=>n((s?b:p)(e,t[c],c>r(t)-2?s:y),(n=>{if(c>r(t)-2)return o?.(n)&&S(e,t[c]),n;const i=k(n,t,s,o,c+1);return u(n)&&S(e,t[c]),i})),m=e=>new Set(Array.isArray(e)||t(e)?e:[e]),x=/^\d+$/,z=/\/([^?]*)/;e.createWsServer=e=>{const l=y(),f=y(),I=y(),[w,L,T]=(e=>{let s;const[i,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{x.test(t)&&r(e)<1e3&&c(e,t)}]})(),a=y();return[(e,t,n,r=[],o=(()=>[]))=>{s??=W;const c=i(1);var d,l;return S(a,c,[e,t,n,r,o]),d=k(t,n??[""],m),l=c,d?.add(l),c},(e,t,...n)=>o(((e,t=[""])=>{const n=[],s=(e,i)=>i==r(t)?c(n,e):null===t[i]?h(e,(e=>s(e,i+1))):o([t[i],null],(t=>s(p(e,t),i+1)));return s(e,0),n})(e,t),(e=>h(e,(e=>p(a,e)[0](s,...t??[],...n))))),e=>n(p(a,e),(([,t,n])=>(k(t,n??[""],void 0,(t=>(v(t,e),u(t)?1:0))),S(a,e),d(e),n))),e=>n(p(a,e),(([e,,n=[],c,i])=>{const d=(...a)=>{const l=r(a);l==r(n)?e(s,...a,...i(a)):t(n[l])?o(c[l]?.(...a)??[],(e=>d(...a,e))):d(...a,n[l])};d()}))]})();e.on("connection",((e,t)=>n(t.url?.match(z),(([,r])=>n(t.headers["sec-websocket-key"],(t=>{const n=b(I,r,y);S(n,t,e),1==n.size&&L(l,void 0,r,1),L(f,[r],t,1),e.on("message",(e=>{const r=e.toString("utf8"),o=r.indexOf("\n");if(-1!==o){const e=s(r,0,o),i=s(r,o+1);""===e?(c=(e,n)=>e!=t?n.send(t+"\n"+i):0,h(n,((e,t)=>c(t,e)))):p(n,e)?.send(t+"\n"+i)}var c})),e.on("close",(()=>{v(n,t),L(f,[r],t,-1),u(n)&&(v(I,r),L(l,void 0,r,-1))}))}))))));const W={getWebSocketServer:()=>e,getPathIds:()=>g(I),getClientIds:e=>g(p(I,e)),addPathIdsListener:e=>w(e,l),addClientIdsListener:(e,t)=>w(t,f,[e]),delListener:e=>(T(e),W),getStats:()=>({paths:d(I),clients:a(I)}),destroy:()=>{e.close(),I.clear()}};return i(W)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseSynchronizerWsServer={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,s)=>t(e)?s?.():n(e),s=(e,t,n)=>e.slice(t,n),r=e=>e.length,o=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),i=Object.freeze,d=e=>e?.size??0,a=(l=d,e=>{return t=(e,t)=>e+l(t),f(e).reduce(t,0);var t});var l;const u=e=>t(e)||0==d(e),f=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),y=e=>new Map(e),g=e=>[...e?.keys()??[]],p=(e,t)=>e?.get(t),S=(e,n,s)=>t(s)?(v(e,n),e):e?.set(n,s),b=(e,t,n,s)=>{var r,o;return r=e,o=t,r?.has(o)?s?.(p(e,t)):S(e,t,n()),p(e,t)},k=(e,t,s,o,c=0)=>n((s?b:p)(e,t[c],c>r(t)-2?s:y),(n=>{if(c>r(t)-2)return o?.(n)&&S(e,t[c]),n;const i=k(n,t,s,o,c+1);return u(n)&&S(e,t[c]),i})),m=e=>new Set(Array.isArray(e)||t(e)?e:[e]),x=/^\d+$/,z=/\/([^?]*)/;e.createWsServer=e=>{const l=y(),f=y(),I=y(),[w,L,T]=(e=>{let s;const[i,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{x.test(t)&&r(e)<1e3&&c(e,t)}]})(),a=y();return[(e,t,n,r=[],o=(()=>[]))=>{s??=W;const c=i(1);var d,l;return S(a,c,[e,t,n,r,o]),d=k(t,n??[""],m),l=c,d?.add(l),c},(e,t,...n)=>o(((e,t=[""])=>{const n=[],s=(e,i)=>i==r(t)?c(n,e):null===t[i]?h(e,(e=>s(e,i+1))):o([t[i],null],(t=>s(p(e,t),i+1)));return s(e,0),n})(e,t),(e=>h(e,(e=>p(a,e)[0](s,...t??[],...n))))),e=>n(p(a,e),(([,t,n])=>(k(t,n??[""],void 0,(t=>(v(t,e),u(t)?1:0))),S(a,e),d(e),n))),e=>n(p(a,e),(([e,,n=[],c,i])=>{const d=(...a)=>{const l=r(a);l==r(n)?e(s,...a,...i(a)):t(n[l])?o(c[l]?.(...a)??[],(e=>d(...a,e))):d(...a,n[l])};d()}))]})();e.on("connection",((e,t)=>n(t.url?.match(z),(([,r])=>n(t.headers["sec-websocket-key"],(t=>{const n=b(I,r,y);S(n,t,e),1==n.size&&L(l,void 0,(()=>({[r]:1}))),L(f,[r],(()=>({[t]:1}))),e.on("message",(e=>{const r=e.toString("utf8"),o=r.indexOf("\n");if(-1!==o){const e=s(r,0,o),i=s(r,o+1);""===e?(c=(e,n)=>e!=t?n.send(t+"\n"+i):0,h(n,((e,t)=>c(t,e)))):p(n,e)?.send(t+"\n"+i)}var c})),e.on("close",(()=>{v(n,t),L(f,[r],(()=>({[t]:-1}))),u(n)&&(v(I,r),L(l,void 0,(()=>({[r]:-1}))))}))}))))));const W={getWebSocketServer:()=>e,getPathIds:()=>g(I),getClientIds:e=>g(p(I,e)),addPathIdsListener:e=>w(e,l),addClientIdsListener:(e,t)=>w(t,f,[e]),delListener:e=>(T(e),W),getStats:()=>({paths:d(I),clients:a(I)}),destroy:()=>{e.close(),I.clear()}};return i(W)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseSynchronizerWsServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,s)=>t(e)?s?.():n(e),s=(e,t,n)=>e.slice(t,n),r=e=>e.length,o=(e,t)=>e.forEach(t),c=(e,...t)=>e.push(...t),i=Object.freeze,d=e=>e?.size??0,a=(l=d,e=>{return t=(e,t)=>e+l(t),f(e).reduce(t,0);var t});var l;const u=e=>t(e)||0==d(e),f=e=>[...e?.values()??[]],h=(e,t)=>e?.forEach(t),v=(e,t)=>e?.delete(t),y=e=>new Map(e),g=e=>[...e?.keys()??[]],p=(e,t)=>e?.get(t),S=(e,n,s)=>t(s)?(v(e,n),e):e?.set(n,s),b=(e,t,n,s)=>{var r,o;return r=e,o=t,r?.has(o)?s?.(p(e,t)):S(e,t,n()),p(e,t)},k=(e,t,s,o,c=0)=>n((s?b:p)(e,t[c],c>r(t)-2?s:y),(n=>{if(c>r(t)-2)return o?.(n)&&S(e,t[c]),n;const i=k(n,t,s,o,c+1);return u(n)&&S(e,t[c]),i})),m=e=>new Set(Array.isArray(e)||t(e)?e:[e]),x=/^\d+$/,z=/\/([^?]*)/;e.createWsServer=e=>{const l=y(),f=y(),I=y(),[w,L,T]=(e=>{let s;const[i,d]=(()=>{const e=[];let t=0;return[n=>(n?e.shift():null)??""+t++,t=>{x.test(t)&&r(e)<1e3&&c(e,t)}]})(),a=y();return[(e,t,n,r=[],o=(()=>[]))=>{s??=W;const c=i(1);var d,l;return S(a,c,[e,t,n,r,o]),d=k(t,n??[""],m),l=c,d?.add(l),c},(e,t,...n)=>o(((e,t=[""])=>{const n=[],s=(e,i)=>i==r(t)?c(n,e):null===t[i]?h(e,(e=>s(e,i+1))):o([t[i],null],(t=>s(p(e,t),i+1)));return s(e,0),n})(e,t),(e=>h(e,(e=>p(a,e)[0](s,...t??[],...n))))),e=>n(p(a,e),(([,t,n])=>(k(t,n??[""],void 0,(t=>(v(t,e),u(t)?1:0))),S(a,e),d(e),n))),e=>n(p(a,e),(([e,,n=[],c,i])=>{const d=(...a)=>{const l=r(a);l==r(n)?e(s,...a,...i(a)):t(n[l])?o(c[l]?.(...a)??[],(e=>d(...a,e))):d(...a,n[l])};d()}))]})();e.on("connection",((e,t)=>n(t.url?.match(z),(([,r])=>n(t.headers["sec-websocket-key"],(t=>{const n=b(I,r,y);S(n,t,e),1==n.size&&L(l,void 0,r,1),L(f,[r],t,1),e.on("message",(e=>{const r=e.toString("utf8"),o=r.indexOf("\n");if(-1!==o){const e=s(r,0,o),i=s(r,o+1);""===e?(c=(e,n)=>e!=t?n.send(t+"\n"+i):0,h(n,((e,t)=>c(t,e)))):p(n,e)?.send(t+"\n"+i)}var c})),e.on("close",(()=>{v(n,t),L(f,[r],t,-1),u(n)&&(v(I,r),L(l,void 0,r,-1))}))}))))));const W={getWebSocketServer:()=>e,getPathIds:()=>g(I),getClientIds:e=>g(p(I,e)),addPathIdsListener:e=>w(e,l),addClientIdsListener:(e,t)=>w(t,f,[e]),delListener:e=>(T(e),W),getStats:()=>({paths:d(I),clients:a(I)}),destroy:()=>{e.close(),I.clear()}};return i(W)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseSynchronizerWsServer={});
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",p=C+"Count",b=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",L=g+"s",h=g+a,y=e=>null==e,m=(e,s,t)=>y(e)?t?.():s(e),S=e=>t(e)==r,T=e=>t(e)==u,V=e=>e.length,f=()=>{},x=(e,s)=>e.every(s),v=(e,s)=>V(e)===V(s)&&x(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!y(e)&&m(B(e),(e=>e==q.prototype||y(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>m(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&x(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=s,j=E([]),U=(e,s)=>{const t=A(j);return y(e)?t[s]:S(e)?F(t[s+1]??{},e):e},W=(e,s)=>{const t=U(e,s);return y(e)||S(e)?t:e},z=e=>D(A(j)[e]??{}),J=e=>W(e,0),K=e=>W(e,2),N=e=>W(e,4),X=e=>W(e,6),Y=e=>W(e,8),Z=e=>W(e,10),$=e=>e.toLowerCase();$(l);const _="Transaction";$(_);const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:oe,useRef:re,useState:ue,useSyncExternalStore:le}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ae=[Q,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],ie=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,o]=ue(),[r,u]=ue();return se((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ie=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Ce=(e,s,t,r=ne)=>{const u=re(de[t]),l=ee((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??de[t];return(ae[t]??ie)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=ee((u=>Ie(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return le(n,l)},pe=(e,s,t,o=ne,r=ne,...u)=>oe((()=>Ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),be=(e,s,t,o=ne,r=f,u=ne,...l)=>{const n=J(e);return ee((e=>m(n,(o=>m(t(e,o),(t=>r(o["set"+s](...P(l,(s=>T(s)?s(e,o):s)),t),t)))))),[n,s,...o,...u,...l])},we=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},Re=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},ke=e=>Ce(I,J(e),1),ge=(e,s)=>Ce(b,J(s),1,[e]),Le=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),he=(e,s,t)=>Ce(k,J(t),1,[e,s]),ye=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),me=e=>Ce(h,J(e),1),Se=(e,s)=>Ce(g,J(s),3,[e]),Te=(e,s)=>Ce("Metric",K(s),3,[e]),Ve=(e,s)=>Ce("SliceIds",N(s),1,[e]),fe=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),xe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),ve=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Pe=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),qe=(e,s)=>Ce(n+b,Y(s),1,[e]),Be=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),He=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Me=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),De=e=>Ce("CheckpointIds",Z(e),2),Fe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Oe=e=>Re(e,"goBackward"),Qe=e=>Re(e,"goForward"),{PureComponent:Ee,Fragment:Ae,createElement:Ge,useCallback:je,useLayoutEffect:Ue,useRef:We,useState:ze}=s,Je=(e,...s)=>y(e)?{}:e(...s),Ke=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ne,useContext:Xe,useMemo:Ye,useState:Ze}=s,$e=({tableId:e,store:s,rowComponent:t=rs,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ts(P(n,(u=>Ge(t,{...Je(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),_e=({queryId:e,queries:s,resultRowComponent:t=as,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ts(P(l,(r=>Ge(t,{...Je(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),es=({relationshipId:e,relationships:s,rowComponent:t=rs,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Ke(X(s),e),c=l(e,n,d);return ts(P(c,(e=>Ge(t,{...Je(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ss=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return ts(P(e(De(l)),(e=>Ge(t,{...Je(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ts=(e,s,t,o)=>{const r=y(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},os=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ts(o+(ye(e,s,t,r)??o),void 0,u,t),rs=({tableId:e,rowId:s,store:t,cellComponent:o=os,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ts(P(((e,s,t,o)=>{const r=he(s,t,o);return e??r})(u,e,s,t),(u=>Ge(o,{...Je(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),us=e=>$e(e,ge(e.tableId,e.store)),ls=({valueId:e,store:s,debugIds:t})=>ts(o+(Se(e,s)??o),void 0,t,e),ns=({indexId:e,sliceId:s,indexes:t,rowComponent:o=rs,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=fe(e,s,n);return ts(P(i,(e=>Ge(o,{...Je(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},ds=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ts(o+(Me(e,s,t,r)??o),void 0,u,t),as=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ds,getResultCellComponentProps:r,separator:u,debugIds:l})=>ts(P(He(e,s,t),(u=>Ge(o,{...Je(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),is=({checkpoints:e,checkpointId:s,debugIds:t})=>ts(Fe(s,e)??o,void 0,t,s),cs=ss((e=>e[0])),Is=ss((e=>y(e[1])?[]:[e[1]])),Cs=ss((e=>e[2]));e.BackwardCheckpointsView=cs,e.CellView=os,e.CheckpointView=is,e.CurrentCheckpointView=Is,e.ForwardCheckpointsView=Cs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=ns,getSliceComponentProps:o,separator:r,debugIds:u})=>ts(P(Ve(e,s),(r=>Ge(t,{...Je(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>es(e,Pe,e.firstRowId),e.LocalRowsView=e=>es(e,ve,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ts(Te(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=Xe(j),[p,b]=Ze({}),w=Ne(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ne((e=>b((s=>({...O(s,e)})))),[]);return Ge(j.Provider,{value:Ye((()=>[e??C[0],{...C[1],...s,...p},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,p,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=rs,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ke(X(t),e),a=xe(e,s,l);return ts(y(d)||y(a)?null:Ge(o,{...Je(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=ds,e.ResultRowView=as,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>_e(r,Be(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>_e(e,qe(e.queryId,e.queries)),e.RowView=rs,e.SliceView=ns,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>$e(r,Le(r.tableId,e,s,t,o,r.store)),e.TableView=us,e.TablesView=({store:e,tableComponent:s=us,getTableComponentProps:t,separator:o,debugIds:r})=>ts(P(ke(e),(o=>Ge(s,{...Je(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ls,e.ValuesView=({store:e,valueComponent:s=ls,getValueComponentProps:t,separator:o,debugIds:r})=>ts(P(me(e),(o=>Ge(s,{...Je(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ne,o,r=f,u=ne,l=!0)=>{const n=J(o);return ee((t=>m(n,(o=>m(s(t,o),(s=>r(o.addRow(T(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=ye,e.useCellIds=he,e.useCellIdsListener=(e,s,t,o,r,u)=>pe(k,J(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>pe(R,J(l),o,r,[e,s,t],u),e.useCheckpoint=Fe,e.useCheckpointIds=De,e.useCheckpointIdsListener=(e,s,t)=>pe("CheckpointIds",Z(t),e,s),e.useCheckpointListener=(e,s,t,o)=>pe("Checkpoint",Z(o),s,t,[e]),e.useCheckpoints=e=>U(e,10),e.useCheckpointsIds=()=>z(11),e.useCheckpointsOrCheckpointsById=Z,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,o,r=ne,u,l=ne)=>{const[,n]=ue(),[d,a]=ue();return se((()=>{const t=e?s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()}),[e,...t,...r]),se((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,o,r=ne)=>{const[u,l]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),se((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>we(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>we(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>we(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>we(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>we(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>we(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Oe,e.useGoForwardCallback=Qe,e.useGoToCallback=(e,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Ce(R,J(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>pe(d+R,J(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Ce(C,J(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>pe(d+C,J(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Ce(i,J(s),4,[e]),e.useHasTableCell=(e,s,t)=>Ce(i+R,J(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>pe(d+i+R,J(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>pe(d+i,J(r),s,t,[e],o),e.useHasTables=e=>Ce(c,J(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>pe(d+c,J(o),e,s,[],t),e.useHasValue=(e,s)=>Ce(g,J(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>pe(d+g,J(r),s,t,[e],o),e.useHasValues=e=>Ce(L,J(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>pe(d+L,J(o),e,s,[],t),e.useIndexIds=e=>Ce("IndexIds",N(e),1),e.useIndexes=e=>U(e,4),e.useIndexesIds=()=>z(5),e.useIndexesOrIndexesById=N,e.useLinkedRowIds=Pe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=ve,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=Te,e.useMetricIds=e=>Ce("MetricIds",K(e),1),e.useMetricListener=(e,s,t,o)=>pe("Metric",K(o),s,t,[e]),e.useMetrics=e=>U(e,2),e.useMetricsIds=()=>z(3),e.useMetricsOrMetricsById=K,e.useProvideStore=(e,s)=>{const{12:t,13:o}=A(j);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>U(e,8),e.useQueriesIds=()=>z(9),e.useQueriesOrQueriesById=Y,e.useQueryIds=e=>Ce("QueryIds",Y(e),1),e.useRedoInformation=e=>{const s=Z(e),[,,[t]]=De(s);return[!y(t),Qe(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Ce("RelationshipIds",X(e),1),e.useRelationships=e=>U(e,6),e.useRelationshipsIds=()=>z(7),e.useRelationshipsOrRelationshipsById=X,e.useRemoteRowId=xe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Me,e.useResultCellIds=He,e.useResultCellIdsListener=(e,s,t,o,r)=>pe(n+k,Y(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>pe(n+R,Y(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Ce(n+C,Y(t),0,[e,s]),e.useResultRowCount=(e,s)=>Ce(n+p,Y(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>pe(n+p,Y(o),s,t,[e]),e.useResultRowIds=qe,e.useResultRowIdsListener=(e,s,t,o)=>pe(n+b,Y(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>pe(n+C,Y(r),t,o,[e,s]),e.useResultSortedRowIds=Be,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>pe(n+w,Y(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Ce(n+i,Y(s),0,[e]),e.useResultTableCellIds=(e,s)=>Ce(n+i+k,Y(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>pe(n+i+k,Y(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>pe(n+i,Y(o),s,t,[e]),e.useRow=(e,s,t)=>Ce(C,J(t),0,[e,s]),e.useRowCount=(e,s)=>Ce(p,J(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>pe(p,J(r),s,t,[e],o),e.useRowIds=ge,e.useRowIdsListener=(e,s,t,o,r)=>pe(b,J(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>pe(C,J(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>be(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>be(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>be(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>be(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>be(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>be(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>be(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>be(t,L,e,s,o,r),e.useSliceIds=Ve,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=fe,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=Le,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>pe(w,J(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>pe("Start"+_,J(t),e,s),e.useStore=e=>U(e,0),e.useStoreIds=()=>z(1),e.useStoreOrStoreById=J,e.useTable=(e,s)=>Ce(i,J(s),0,[e]),e.useTableCellIds=(e,s)=>Ce(i+k,J(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>pe(i+k,J(r),s,t,[e],o),e.useTableIds=ke,e.useTableIdsListener=(e,s,t,o)=>pe(I,J(o),e,s,ne,t),e.useTableListener=(e,s,t,o,r)=>pe(i,J(r),s,t,[e],o),e.useTables=e=>Ce(c,J(e),0),e.useTablesListener=(e,s,t,o)=>pe(c,J(o),e,s,ne,t),e.useUndoInformation=e=>{const s=Z(e),[t,r]=De(s);return[(u=t,!(0==V(u))),Oe(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Se,e.useValueIds=me,e.useValueIdsListener=(e,s,t,o)=>pe(h,J(o),e,s,ne,t),e.useValueListener=(e,s,t,o,r)=>pe(g,J(r),s,t,[e],o),e.useValues=e=>Ce(L,J(e),0),e.useValuesListener=(e,s,t,o)=>pe(L,J(o),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>pe("WillFinish"+_,J(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",p=C+"Count",b=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",L=g+"s",h=g+a,y=e=>null==e,m=(e,s,t)=>y(e)?t?.():s(e),S=e=>t(e)==r,T=e=>t(e)==u,V=e=>e.length,f=()=>{},x=(e,s)=>e.every(s),v=(e,s)=>V(e)===V(s)&&x(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!y(e)&&m(B(e),(e=>e==q.prototype||y(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>m(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&x(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=s,j=E([]),U=(e,s)=>{const t=A(j);return y(e)?t[s]:S(e)?F(t[s+1]??{},e):e},W=(e,s)=>{const t=U(e,s);return y(e)||S(e)?t:e},z=e=>D(A(j)[e]??{}),J=e=>W(e,0),K=e=>W(e,2),N=e=>W(e,4),X=e=>W(e,6),Y=e=>W(e,8),Z=e=>W(e,10),$=e=>e.toLowerCase();$(l);const _="Transaction";$(_);const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:oe,useRef:re,useState:ue,useSyncExternalStore:le}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ae=[Q,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],ie=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,o]=ue(),[r,u]=ue();return se((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ie=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Ce=(e,s,t,r=ne)=>{const u=re(de[t]),l=ee((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??de[t];return(ae[t]??ie)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=ee((u=>Ie(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return le(n,l)},pe=(e,s,t,o=ne,r=ne,...u)=>oe((()=>Ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),be=(e,s,t,o=ne,r=f,u=ne,...l)=>{const n=J(e);return ee((e=>m(n,(o=>m(t(e,o),(t=>r(o["set"+s](...we(l,o,e),t),t)))))),[n,s,...o,...u,...Re(l)])},we=(e,s,t)=>P(e,(e=>T(e)?e(t,s):e)),Re=e=>{return s=e=>!T(e),e.filter(s);var s},ke=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((e=>t(u?.["del"+s](...we(r,u,e)))),[u,s,...o,...Re(r)])},ge=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},Le=e=>Ce(I,J(e),1),he=(e,s)=>Ce(b,J(s),1,[e]),ye=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),me=(e,s,t)=>Ce(k,J(t),1,[e,s]),Se=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),Te=e=>Ce(h,J(e),1),Ve=(e,s)=>Ce(g,J(s),3,[e]),fe=(e,s)=>Ce("Metric",K(s),3,[e]),xe=(e,s)=>Ce("SliceIds",N(s),1,[e]),ve=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),Pe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),qe=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Be=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),He=(e,s)=>Ce(n+b,Y(s),1,[e]),Me=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),De=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Fe=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),Oe=e=>Ce("CheckpointIds",Z(e),2),Qe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Ee=e=>ge(e,"goBackward"),Ae=e=>ge(e,"goForward"),{PureComponent:Ge,Fragment:je,createElement:Ue,useCallback:We,useLayoutEffect:ze,useRef:Je,useState:Ke}=s,Ne=(e,...s)=>y(e)?{}:e(...s),Xe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ye,useContext:Ze,useMemo:$e,useState:_e}=s,es=({tableId:e,store:s,rowComponent:t=ls,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>rs(P(n,(u=>Ue(t,{...Ne(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),ss=({queryId:e,queries:s,resultRowComponent:t=cs,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>rs(P(l,(r=>Ue(t,{...Ne(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ts=({relationshipId:e,relationships:s,rowComponent:t=ls,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Xe(X(s),e),c=l(e,n,d);return rs(P(c,(e=>Ue(t,{...Ne(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},os=e=>({checkpoints:s,checkpointComponent:t=Is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return rs(P(e(Oe(l)),(e=>Ue(t,{...Ne(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},rs=(e,s,t,o)=>{const r=y(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},us=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>rs(o+(Se(e,s,t,r)??o),void 0,u,t),ls=({tableId:e,rowId:s,store:t,cellComponent:o=us,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>rs(P(((e,s,t,o)=>{const r=me(s,t,o);return e??r})(u,e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),ns=e=>es(e,he(e.tableId,e.store)),ds=({valueId:e,store:s,debugIds:t})=>rs(o+(Ve(e,s)??o),void 0,t,e),as=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ls,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=ve(e,s,n);return rs(P(i,(e=>Ue(o,{...Ne(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},is=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>rs(o+(Fe(e,s,t,r)??o),void 0,u,t),cs=({queryId:e,rowId:s,queries:t,resultCellComponent:o=is,getResultCellComponentProps:r,separator:u,debugIds:l})=>rs(P(De(e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),Is=({checkpoints:e,checkpointId:s,debugIds:t})=>rs(Qe(s,e)??o,void 0,t,s),Cs=os((e=>e[0])),ps=os((e=>y(e[1])?[]:[e[1]])),bs=os((e=>e[2]));e.BackwardCheckpointsView=Cs,e.CellView=us,e.CheckpointView=Is,e.CurrentCheckpointView=ps,e.ForwardCheckpointsView=bs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=as,getSliceComponentProps:o,separator:r,debugIds:u})=>rs(P(xe(e,s),(r=>Ue(t,{...Ne(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ts(e,Be,e.firstRowId),e.LocalRowsView=e=>ts(e,qe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>rs(fe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=Ze(j),[p,b]=_e({}),w=Ye(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ye((e=>b((s=>({...O(s,e)})))),[]);return Ue(j.Provider,{value:$e((()=>[e??C[0],{...C[1],...s,...p},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,p,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ls,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Xe(X(t),e),a=Pe(e,s,l);return rs(y(d)||y(a)?null:Ue(o,{...Ne(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=is,e.ResultRowView=cs,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ss(r,Me(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ss(e,He(e.queryId,e.queries)),e.RowView=ls,e.SliceView=as,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>es(r,ye(r.tableId,e,s,t,o,r.store)),e.TableView=ns,e.TablesView=({store:e,tableComponent:s=ns,getTableComponentProps:t,separator:o,debugIds:r})=>rs(P(Le(e),(o=>Ue(s,{...Ne(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ds,e.ValuesView=({store:e,valueComponent:s=ds,getValueComponentProps:t,separator:o,debugIds:r})=>rs(P(Te(e),(o=>Ue(s,{...Ne(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ne,o,r=f,u=ne,l=!0)=>{const n=J(o);return ee((t=>m(n,(o=>m(s(t,o),(s=>r(o.addRow(T(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=Se,e.useCellIds=me,e.useCellIdsListener=(e,s,t,o,r,u)=>pe(k,J(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>pe(R,J(l),o,r,[e,s,t],u),e.useCheckpoint=Qe,e.useCheckpointIds=Oe,e.useCheckpointIdsListener=(e,s,t)=>pe("CheckpointIds",Z(t),e,s),e.useCheckpointListener=(e,s,t,o)=>pe("Checkpoint",Z(o),s,t,[e]),e.useCheckpoints=e=>U(e,10),e.useCheckpointsIds=()=>z(11),e.useCheckpointsOrCheckpointsById=Z,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,o,r=ne,u,l=ne)=>{const[,n]=ue(),[d,a]=ue();return se((()=>{const t=e?s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()}),[e,...t,...r]),se((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,o,r=ne)=>{const[u,l]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),se((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>ke(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>ke(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>ke(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>ke(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>ke(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>ke(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Ee,e.useGoForwardCallback=Ae,e.useGoToCallback=(e,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Ce(R,J(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>pe(d+R,J(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Ce(C,J(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>pe(d+C,J(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Ce(i,J(s),4,[e]),e.useHasTableCell=(e,s,t)=>Ce(i+R,J(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>pe(d+i+R,J(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>pe(d+i,J(r),s,t,[e],o),e.useHasTables=e=>Ce(c,J(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>pe(d+c,J(o),e,s,[],t),e.useHasValue=(e,s)=>Ce(g,J(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>pe(d+g,J(r),s,t,[e],o),e.useHasValues=e=>Ce(L,J(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>pe(d+L,J(o),e,s,[],t),e.useIndexIds=e=>Ce("IndexIds",N(e),1),e.useIndexes=e=>U(e,4),e.useIndexesIds=()=>z(5),e.useIndexesOrIndexesById=N,e.useLinkedRowIds=Be,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=qe,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=fe,e.useMetricIds=e=>Ce("MetricIds",K(e),1),e.useMetricListener=(e,s,t,o)=>pe("Metric",K(o),s,t,[e]),e.useMetrics=e=>U(e,2),e.useMetricsIds=()=>z(3),e.useMetricsOrMetricsById=K,e.useProvideStore=(e,s)=>{const{12:t,13:o}=A(j);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>U(e,8),e.useQueriesIds=()=>z(9),e.useQueriesOrQueriesById=Y,e.useQueryIds=e=>Ce("QueryIds",Y(e),1),e.useRedoInformation=e=>{const s=Z(e),[,,[t]]=Oe(s);return[!y(t),Ae(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Ce("RelationshipIds",X(e),1),e.useRelationships=e=>U(e,6),e.useRelationshipsIds=()=>z(7),e.useRelationshipsOrRelationshipsById=X,e.useRemoteRowId=Pe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Fe,e.useResultCellIds=De,e.useResultCellIdsListener=(e,s,t,o,r)=>pe(n+k,Y(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>pe(n+R,Y(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Ce(n+C,Y(t),0,[e,s]),e.useResultRowCount=(e,s)=>Ce(n+p,Y(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>pe(n+p,Y(o),s,t,[e]),e.useResultRowIds=He,e.useResultRowIdsListener=(e,s,t,o)=>pe(n+b,Y(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>pe(n+C,Y(r),t,o,[e,s]),e.useResultSortedRowIds=Me,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>pe(n+w,Y(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Ce(n+i,Y(s),0,[e]),e.useResultTableCellIds=(e,s)=>Ce(n+i+k,Y(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>pe(n+i+k,Y(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>pe(n+i,Y(o),s,t,[e]),e.useRow=(e,s,t)=>Ce(C,J(t),0,[e,s]),e.useRowCount=(e,s)=>Ce(p,J(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>pe(p,J(r),s,t,[e],o),e.useRowIds=he,e.useRowIdsListener=(e,s,t,o,r)=>pe(b,J(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>pe(C,J(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>be(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>be(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>be(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>be(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>be(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>be(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>be(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>be(t,L,e,s,o,r),e.useSliceIds=xe,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=ve,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=ye,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>pe(w,J(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>pe("Start"+_,J(t),e,s),e.useStore=e=>U(e,0),e.useStoreIds=()=>z(1),e.useStoreOrStoreById=J,e.useTable=(e,s)=>Ce(i,J(s),0,[e]),e.useTableCellIds=(e,s)=>Ce(i+k,J(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>pe(i+k,J(r),s,t,[e],o),e.useTableIds=Le,e.useTableIdsListener=(e,s,t,o)=>pe(I,J(o),e,s,ne,t),e.useTableListener=(e,s,t,o,r)=>pe(i,J(r),s,t,[e],o),e.useTables=e=>Ce(c,J(e),0),e.useTablesListener=(e,s,t,o)=>pe(c,J(o),e,s,ne,t),e.useUndoInformation=e=>{const s=Z(e),[t,r]=Oe(s);return[(u=t,!(0==V(u))),Ee(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Ve,e.useValueIds=Te,e.useValueIdsListener=(e,s,t,o)=>pe(h,J(o),e,s,ne,t),e.useValueListener=(e,s,t,o,r)=>pe(g,J(r),s,t,[e],o),e.useValues=e=>Ce(L,J(e),0),e.useValuesListener=(e,s,t,o)=>pe(L,J(o),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>pe("WillFinish"+_,J(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",p=C+"Count",b=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",L=g+"s",h=g+a,y=e=>null==e,m=(e,s,t)=>y(e)?t?.():s(e),S=e=>t(e)==r,T=e=>t(e)==u,V=e=>e.length,f=()=>{},x=(e,s)=>e.every(s),v=(e,s)=>V(e)===V(s)&&x(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!y(e)&&m(B(e),(e=>e==q.prototype||y(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>m(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&x(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=s,j=E([]),U=(e,s)=>{const t=A(j);return y(e)?t[s]:S(e)?F(t[s+1]??{},e):e},W=(e,s)=>{const t=U(e,s);return y(e)||S(e)?t:e},z=e=>D(A(j)[e]??{}),J=e=>W(e,0),K=e=>W(e,2),N=e=>W(e,4),X=e=>W(e,6),Y=e=>W(e,8),Z=e=>W(e,10),$=e=>e.toLowerCase();$(l);const _="Transaction";$(_);const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:oe,useRef:re,useState:ue,useSyncExternalStore:le}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ae=[Q,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],ie=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,o]=ue(),[r,u]=ue();return se((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ie=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Ce=(e,s,t,r=ne)=>{const u=re(de[t]),l=ee((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??de[t];return(ae[t]??ie)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=ee((u=>Ie(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return le(n,l)},pe=(e,s,t,o=ne,r=ne,...u)=>oe((()=>Ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),be=(e,s,t,o=ne,r=f,u=ne,...l)=>{const n=J(e);return ee((e=>m(n,(o=>m(t(e,o),(t=>r(o["set"+s](...P(l,(s=>T(s)?s(e,o):s)),t),t)))))),[n,s,...o,...u,...l])},we=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},Re=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},ke=e=>Ce(I,J(e),1),ge=(e,s)=>Ce(b,J(s),1,[e]),Le=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),he=(e,s,t)=>Ce(k,J(t),1,[e,s]),ye=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),me=e=>Ce(h,J(e),1),Se=(e,s)=>Ce(g,J(s),3,[e]),Te=(e,s)=>Ce("Metric",K(s),3,[e]),Ve=(e,s)=>Ce("SliceIds",N(s),1,[e]),fe=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),xe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),ve=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Pe=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),qe=(e,s)=>Ce(n+b,Y(s),1,[e]),Be=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),He=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Me=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),De=e=>Ce("CheckpointIds",Z(e),2),Fe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Oe=e=>Re(e,"goBackward"),Qe=e=>Re(e,"goForward"),{PureComponent:Ee,Fragment:Ae,createElement:Ge,useCallback:je,useLayoutEffect:Ue,useRef:We,useState:ze}=s,Je=(e,...s)=>y(e)?{}:e(...s),Ke=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ne,useContext:Xe,useMemo:Ye,useState:Ze}=s,$e=({tableId:e,store:s,rowComponent:t=rs,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ts(P(n,(u=>Ge(t,{...Je(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),_e=({queryId:e,queries:s,resultRowComponent:t=as,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ts(P(l,(r=>Ge(t,{...Je(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),es=({relationshipId:e,relationships:s,rowComponent:t=rs,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Ke(X(s),e),c=l(e,n,d);return ts(P(c,(e=>Ge(t,{...Je(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ss=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return ts(P(e(De(l)),(e=>Ge(t,{...Je(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ts=(e,s,t,o)=>{const r=y(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},os=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ts(o+(ye(e,s,t,r)??o),void 0,u,t),rs=({tableId:e,rowId:s,store:t,cellComponent:o=os,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ts(P(((e,s,t,o)=>{const r=he(s,t,o);return e??r})(u,e,s,t),(u=>Ge(o,{...Je(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),us=e=>$e(e,ge(e.tableId,e.store)),ls=({valueId:e,store:s,debugIds:t})=>ts(o+(Se(e,s)??o),void 0,t,e),ns=({indexId:e,sliceId:s,indexes:t,rowComponent:o=rs,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=fe(e,s,n);return ts(P(i,(e=>Ge(o,{...Je(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},ds=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ts(o+(Me(e,s,t,r)??o),void 0,u,t),as=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ds,getResultCellComponentProps:r,separator:u,debugIds:l})=>ts(P(He(e,s,t),(u=>Ge(o,{...Je(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),is=({checkpoints:e,checkpointId:s,debugIds:t})=>ts(Fe(s,e)??o,void 0,t,s),cs=ss((e=>e[0])),Is=ss((e=>y(e[1])?[]:[e[1]])),Cs=ss((e=>e[2]));e.BackwardCheckpointsView=cs,e.CellView=os,e.CheckpointView=is,e.CurrentCheckpointView=Is,e.ForwardCheckpointsView=Cs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=ns,getSliceComponentProps:o,separator:r,debugIds:u})=>ts(P(Ve(e,s),(r=>Ge(t,{...Je(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>es(e,Pe,e.firstRowId),e.LocalRowsView=e=>es(e,ve,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ts(Te(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=Xe(j),[p,b]=Ze({}),w=Ne(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ne((e=>b((s=>({...O(s,e)})))),[]);return Ge(j.Provider,{value:Ye((()=>[e??C[0],{...C[1],...s,...p},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,p,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=rs,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ke(X(t),e),a=xe(e,s,l);return ts(y(d)||y(a)?null:Ge(o,{...Je(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=ds,e.ResultRowView=as,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>_e(r,Be(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>_e(e,qe(e.queryId,e.queries)),e.RowView=rs,e.SliceView=ns,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>$e(r,Le(r.tableId,e,s,t,o,r.store)),e.TableView=us,e.TablesView=({store:e,tableComponent:s=us,getTableComponentProps:t,separator:o,debugIds:r})=>ts(P(ke(e),(o=>Ge(s,{...Je(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ls,e.ValuesView=({store:e,valueComponent:s=ls,getValueComponentProps:t,separator:o,debugIds:r})=>ts(P(me(e),(o=>Ge(s,{...Je(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ne,o,r=f,u=ne,l=!0)=>{const n=J(o);return ee((t=>m(n,(o=>m(s(t,o),(s=>r(o.addRow(T(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=ye,e.useCellIds=he,e.useCellIdsListener=(e,s,t,o,r,u)=>pe(k,J(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>pe(R,J(l),o,r,[e,s,t],u),e.useCheckpoint=Fe,e.useCheckpointIds=De,e.useCheckpointIdsListener=(e,s,t)=>pe("CheckpointIds",Z(t),e,s),e.useCheckpointListener=(e,s,t,o)=>pe("Checkpoint",Z(o),s,t,[e]),e.useCheckpoints=e=>U(e,10),e.useCheckpointsIds=()=>z(11),e.useCheckpointsOrCheckpointsById=Z,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,o,r=ne,u,l=ne)=>{const[,n]=ue(),[d,a]=ue();return se((()=>{const t=e?s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()}),[e,...t,...r]),se((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,o,r=ne)=>{const[u,l]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),se((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>we(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>we(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>we(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>we(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>we(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>we(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Oe,e.useGoForwardCallback=Qe,e.useGoToCallback=(e,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Ce(R,J(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>pe(d+R,J(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Ce(C,J(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>pe(d+C,J(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Ce(i,J(s),4,[e]),e.useHasTableCell=(e,s,t)=>Ce(i+R,J(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>pe(d+i+R,J(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>pe(d+i,J(r),s,t,[e],o),e.useHasTables=e=>Ce(c,J(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>pe(d+c,J(o),e,s,[],t),e.useHasValue=(e,s)=>Ce(g,J(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>pe(d+g,J(r),s,t,[e],o),e.useHasValues=e=>Ce(L,J(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>pe(d+L,J(o),e,s,[],t),e.useIndexIds=e=>Ce("IndexIds",N(e),1),e.useIndexes=e=>U(e,4),e.useIndexesIds=()=>z(5),e.useIndexesOrIndexesById=N,e.useLinkedRowIds=Pe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=ve,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=Te,e.useMetricIds=e=>Ce("MetricIds",K(e),1),e.useMetricListener=(e,s,t,o)=>pe("Metric",K(o),s,t,[e]),e.useMetrics=e=>U(e,2),e.useMetricsIds=()=>z(3),e.useMetricsOrMetricsById=K,e.useProvideStore=(e,s)=>{const{12:t,13:o}=A(j);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>U(e,8),e.useQueriesIds=()=>z(9),e.useQueriesOrQueriesById=Y,e.useQueryIds=e=>Ce("QueryIds",Y(e),1),e.useRedoInformation=e=>{const s=Z(e),[,,[t]]=De(s);return[!y(t),Qe(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Ce("RelationshipIds",X(e),1),e.useRelationships=e=>U(e,6),e.useRelationshipsIds=()=>z(7),e.useRelationshipsOrRelationshipsById=X,e.useRemoteRowId=xe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Me,e.useResultCellIds=He,e.useResultCellIdsListener=(e,s,t,o,r)=>pe(n+k,Y(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>pe(n+R,Y(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Ce(n+C,Y(t),0,[e,s]),e.useResultRowCount=(e,s)=>Ce(n+p,Y(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>pe(n+p,Y(o),s,t,[e]),e.useResultRowIds=qe,e.useResultRowIdsListener=(e,s,t,o)=>pe(n+b,Y(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>pe(n+C,Y(r),t,o,[e,s]),e.useResultSortedRowIds=Be,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>pe(n+w,Y(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Ce(n+i,Y(s),0,[e]),e.useResultTableCellIds=(e,s)=>Ce(n+i+k,Y(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>pe(n+i+k,Y(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>pe(n+i,Y(o),s,t,[e]),e.useRow=(e,s,t)=>Ce(C,J(t),0,[e,s]),e.useRowCount=(e,s)=>Ce(p,J(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>pe(p,J(r),s,t,[e],o),e.useRowIds=ge,e.useRowIdsListener=(e,s,t,o,r)=>pe(b,J(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>pe(C,J(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>be(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>be(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>be(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>be(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>be(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>be(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>be(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>be(t,L,e,s,o,r),e.useSliceIds=Ve,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=fe,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=Le,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>pe(w,J(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>pe("Start"+_,J(t),e,s),e.useStore=e=>U(e,0),e.useStoreIds=()=>z(1),e.useStoreOrStoreById=J,e.useTable=(e,s)=>Ce(i,J(s),0,[e]),e.useTableCellIds=(e,s)=>Ce(i+k,J(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>pe(i+k,J(r),s,t,[e],o),e.useTableIds=ke,e.useTableIdsListener=(e,s,t,o)=>pe(I,J(o),e,s,ne,t),e.useTableListener=(e,s,t,o,r)=>pe(i,J(r),s,t,[e],o),e.useTables=e=>Ce(c,J(e),0),e.useTablesListener=(e,s,t,o)=>pe(c,J(o),e,s,ne,t),e.useUndoInformation=e=>{const s=Z(e),[t,r]=De(s);return[(u=t,!(0==V(u))),Oe(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Se,e.useValueIds=me,e.useValueIdsListener=(e,s,t,o)=>pe(h,J(o),e,s,ne,t),e.useValueListener=(e,s,t,o,r)=>pe(g,J(r),s,t,[e],o),e.useValues=e=>Ce(L,J(e),0),e.useValuesListener=(e,s,t,o)=>pe(L,J(o),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>pe("WillFinish"+_,J(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",p=C+"Count",b=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",L=g+"s",h=g+a,y=e=>null==e,m=(e,s,t)=>y(e)?t?.():s(e),S=e=>t(e)==r,T=e=>t(e)==u,V=e=>e.length,f=()=>{},x=(e,s)=>e.every(s),v=(e,s)=>V(e)===V(s)&&x(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!y(e)&&m(B(e),(e=>e==q.prototype||y(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>m(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&x(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=s,j=E([]),U=(e,s)=>{const t=A(j);return y(e)?t[s]:S(e)?F(t[s+1]??{},e):e},W=(e,s)=>{const t=U(e,s);return y(e)||S(e)?t:e},z=e=>D(A(j)[e]??{}),J=e=>W(e,0),K=e=>W(e,2),N=e=>W(e,4),X=e=>W(e,6),Y=e=>W(e,8),Z=e=>W(e,10),$=e=>e.toLowerCase();$(l);const _="Transaction";$(_);const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:oe,useRef:re,useState:ue,useSyncExternalStore:le}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ae=[Q,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],ie=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,o]=ue(),[r,u]=ue();return se((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ie=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Ce=(e,s,t,r=ne)=>{const u=re(de[t]),l=ee((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??de[t];return(ae[t]??ie)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=ee((u=>Ie(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return le(n,l)},pe=(e,s,t,o=ne,r=ne,...u)=>oe((()=>Ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),be=(e,s,t,o=ne,r=f,u=ne,...l)=>{const n=J(e);return ee((e=>m(n,(o=>m(t(e,o),(t=>r(o["set"+s](...we(l,o,e),t),t)))))),[n,s,...o,...u,...Re(l)])},we=(e,s,t)=>P(e,(e=>T(e)?e(t,s):e)),Re=e=>{return s=e=>!T(e),e.filter(s);var s},ke=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((e=>t(u?.["del"+s](...we(r,u,e)))),[u,s,...o,...Re(r)])},ge=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},Le=e=>Ce(I,J(e),1),he=(e,s)=>Ce(b,J(s),1,[e]),ye=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),me=(e,s,t)=>Ce(k,J(t),1,[e,s]),Se=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),Te=e=>Ce(h,J(e),1),Ve=(e,s)=>Ce(g,J(s),3,[e]),fe=(e,s)=>Ce("Metric",K(s),3,[e]),xe=(e,s)=>Ce("SliceIds",N(s),1,[e]),ve=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),Pe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),qe=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Be=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),He=(e,s)=>Ce(n+b,Y(s),1,[e]),Me=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),De=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Fe=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),Oe=e=>Ce("CheckpointIds",Z(e),2),Qe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Ee=e=>ge(e,"goBackward"),Ae=e=>ge(e,"goForward"),{PureComponent:Ge,Fragment:je,createElement:Ue,useCallback:We,useLayoutEffect:ze,useRef:Je,useState:Ke}=s,Ne=(e,...s)=>y(e)?{}:e(...s),Xe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ye,useContext:Ze,useMemo:$e,useState:_e}=s,es=({tableId:e,store:s,rowComponent:t=ls,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>rs(P(n,(u=>Ue(t,{...Ne(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),ss=({queryId:e,queries:s,resultRowComponent:t=cs,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>rs(P(l,(r=>Ue(t,{...Ne(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ts=({relationshipId:e,relationships:s,rowComponent:t=ls,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Xe(X(s),e),c=l(e,n,d);return rs(P(c,(e=>Ue(t,{...Ne(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},os=e=>({checkpoints:s,checkpointComponent:t=Is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return rs(P(e(Oe(l)),(e=>Ue(t,{...Ne(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},rs=(e,s,t,o)=>{const r=y(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},us=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>rs(o+(Se(e,s,t,r)??o),void 0,u,t),ls=({tableId:e,rowId:s,store:t,cellComponent:o=us,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>rs(P(((e,s,t,o)=>{const r=me(s,t,o);return e??r})(u,e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),ns=e=>es(e,he(e.tableId,e.store)),ds=({valueId:e,store:s,debugIds:t})=>rs(o+(Ve(e,s)??o),void 0,t,e),as=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ls,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=ve(e,s,n);return rs(P(i,(e=>Ue(o,{...Ne(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},is=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>rs(o+(Fe(e,s,t,r)??o),void 0,u,t),cs=({queryId:e,rowId:s,queries:t,resultCellComponent:o=is,getResultCellComponentProps:r,separator:u,debugIds:l})=>rs(P(De(e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),Is=({checkpoints:e,checkpointId:s,debugIds:t})=>rs(Qe(s,e)??o,void 0,t,s),Cs=os((e=>e[0])),ps=os((e=>y(e[1])?[]:[e[1]])),bs=os((e=>e[2]));e.BackwardCheckpointsView=Cs,e.CellView=us,e.CheckpointView=Is,e.CurrentCheckpointView=ps,e.ForwardCheckpointsView=bs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=as,getSliceComponentProps:o,separator:r,debugIds:u})=>rs(P(xe(e,s),(r=>Ue(t,{...Ne(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ts(e,Be,e.firstRowId),e.LocalRowsView=e=>ts(e,qe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>rs(fe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=Ze(j),[p,b]=_e({}),w=Ye(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ye((e=>b((s=>({...O(s,e)})))),[]);return Ue(j.Provider,{value:$e((()=>[e??C[0],{...C[1],...s,...p},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,p,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ls,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Xe(X(t),e),a=Pe(e,s,l);return rs(y(d)||y(a)?null:Ue(o,{...Ne(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=is,e.ResultRowView=cs,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ss(r,Me(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ss(e,He(e.queryId,e.queries)),e.RowView=ls,e.SliceView=as,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>es(r,ye(r.tableId,e,s,t,o,r.store)),e.TableView=ns,e.TablesView=({store:e,tableComponent:s=ns,getTableComponentProps:t,separator:o,debugIds:r})=>rs(P(Le(e),(o=>Ue(s,{...Ne(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ds,e.ValuesView=({store:e,valueComponent:s=ds,getValueComponentProps:t,separator:o,debugIds:r})=>rs(P(Te(e),(o=>Ue(s,{...Ne(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ne,o,r=f,u=ne,l=!0)=>{const n=J(o);return ee((t=>m(n,(o=>m(s(t,o),(s=>r(o.addRow(T(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=Se,e.useCellIds=me,e.useCellIdsListener=(e,s,t,o,r,u)=>pe(k,J(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>pe(R,J(l),o,r,[e,s,t],u),e.useCheckpoint=Qe,e.useCheckpointIds=Oe,e.useCheckpointIdsListener=(e,s,t)=>pe("CheckpointIds",Z(t),e,s),e.useCheckpointListener=(e,s,t,o)=>pe("Checkpoint",Z(o),s,t,[e]),e.useCheckpoints=e=>U(e,10),e.useCheckpointsIds=()=>z(11),e.useCheckpointsOrCheckpointsById=Z,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,o,r=ne,u,l=ne)=>{const[,n]=ue(),[d,a]=ue();return se((()=>{const t=e?s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()}),[e,...t,...r]),se((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,o,r=ne)=>{const[u,l]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),se((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>ke(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>ke(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>ke(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>ke(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>ke(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>ke(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Ee,e.useGoForwardCallback=Ae,e.useGoToCallback=(e,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Ce(R,J(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>pe(d+R,J(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Ce(C,J(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>pe(d+C,J(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Ce(i,J(s),4,[e]),e.useHasTableCell=(e,s,t)=>Ce(i+R,J(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>pe(d+i+R,J(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>pe(d+i,J(r),s,t,[e],o),e.useHasTables=e=>Ce(c,J(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>pe(d+c,J(o),e,s,[],t),e.useHasValue=(e,s)=>Ce(g,J(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>pe(d+g,J(r),s,t,[e],o),e.useHasValues=e=>Ce(L,J(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>pe(d+L,J(o),e,s,[],t),e.useIndexIds=e=>Ce("IndexIds",N(e),1),e.useIndexes=e=>U(e,4),e.useIndexesIds=()=>z(5),e.useIndexesOrIndexesById=N,e.useLinkedRowIds=Be,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=qe,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=fe,e.useMetricIds=e=>Ce("MetricIds",K(e),1),e.useMetricListener=(e,s,t,o)=>pe("Metric",K(o),s,t,[e]),e.useMetrics=e=>U(e,2),e.useMetricsIds=()=>z(3),e.useMetricsOrMetricsById=K,e.useProvideStore=(e,s)=>{const{12:t,13:o}=A(j);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>U(e,8),e.useQueriesIds=()=>z(9),e.useQueriesOrQueriesById=Y,e.useQueryIds=e=>Ce("QueryIds",Y(e),1),e.useRedoInformation=e=>{const s=Z(e),[,,[t]]=Oe(s);return[!y(t),Ae(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Ce("RelationshipIds",X(e),1),e.useRelationships=e=>U(e,6),e.useRelationshipsIds=()=>z(7),e.useRelationshipsOrRelationshipsById=X,e.useRemoteRowId=Pe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Fe,e.useResultCellIds=De,e.useResultCellIdsListener=(e,s,t,o,r)=>pe(n+k,Y(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>pe(n+R,Y(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Ce(n+C,Y(t),0,[e,s]),e.useResultRowCount=(e,s)=>Ce(n+p,Y(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>pe(n+p,Y(o),s,t,[e]),e.useResultRowIds=He,e.useResultRowIdsListener=(e,s,t,o)=>pe(n+b,Y(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>pe(n+C,Y(r),t,o,[e,s]),e.useResultSortedRowIds=Me,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>pe(n+w,Y(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Ce(n+i,Y(s),0,[e]),e.useResultTableCellIds=(e,s)=>Ce(n+i+k,Y(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>pe(n+i+k,Y(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>pe(n+i,Y(o),s,t,[e]),e.useRow=(e,s,t)=>Ce(C,J(t),0,[e,s]),e.useRowCount=(e,s)=>Ce(p,J(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>pe(p,J(r),s,t,[e],o),e.useRowIds=he,e.useRowIdsListener=(e,s,t,o,r)=>pe(b,J(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>pe(C,J(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>be(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>be(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>be(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>be(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>be(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>be(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>be(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>be(t,L,e,s,o,r),e.useSliceIds=xe,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=ve,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=ye,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>pe(w,J(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>pe("Start"+_,J(t),e,s),e.useStore=e=>U(e,0),e.useStoreIds=()=>z(1),e.useStoreOrStoreById=J,e.useTable=(e,s)=>Ce(i,J(s),0,[e]),e.useTableCellIds=(e,s)=>Ce(i+k,J(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>pe(i+k,J(r),s,t,[e],o),e.useTableIds=Le,e.useTableIdsListener=(e,s,t,o)=>pe(I,J(o),e,s,ne,t),e.useTableListener=(e,s,t,o,r)=>pe(i,J(r),s,t,[e],o),e.useTables=e=>Ce(c,J(e),0),e.useTablesListener=(e,s,t,o)=>pe(c,J(o),e,s,ne,t),e.useUndoInformation=e=>{const s=Z(e),[t,r]=Oe(s);return[(u=t,!(0==V(u))),Ee(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Ve,e.useValueIds=Te,e.useValueIdsListener=(e,s,t,o)=>pe(h,J(o),e,s,ne,t),e.useValueListener=(e,s,t,o,r)=>pe(g,J(r),s,t,[e],o),e.useValues=e=>Ce(L,J(e),0),e.useValuesListener=(e,s,t,o)=>pe(L,J(o),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>pe("WillFinish"+_,J(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
@@ -190,9 +190,9 @@
190
190
  const clients = mapEnsure(clientsByPath, pathId, mapNew);
191
191
  mapSet(clients, clientId, webSocket);
192
192
  if (clients.size == 1) {
193
- callListeners(pathIdListeners, void 0, () => ({[pathId]: 1}));
193
+ callListeners(pathIdListeners, void 0, pathId, 1);
194
194
  }
195
- callListeners(clientIdListeners, [pathId], () => ({[clientId]: 1}));
195
+ callListeners(clientIdListeners, [pathId], clientId, 1);
196
196
  webSocket.on('message', (data) => {
197
197
  const payload = data.toString(UTF8);
198
198
  const splitAt = payload.indexOf(MESSAGE_SEPARATOR);
@@ -214,12 +214,10 @@
214
214
  });
215
215
  webSocket.on('close', () => {
216
216
  collDel(clients, clientId);
217
- callListeners(clientIdListeners, [pathId], () => ({
218
- [clientId]: -1,
219
- }));
217
+ callListeners(clientIdListeners, [pathId], clientId, -1);
220
218
  if (collIsEmpty(clients)) {
221
219
  collDel(clientsByPath, pathId);
222
- callListeners(pathIdListeners, void 0, () => ({[pathId]: -1}));
220
+ callListeners(pathIdListeners, void 0, pathId, -1);
223
221
  }
224
222
  });
225
223
  }),
@@ -190,9 +190,9 @@
190
190
  const clients = mapEnsure(clientsByPath, pathId, mapNew);
191
191
  mapSet(clients, clientId, webSocket);
192
192
  if (clients.size == 1) {
193
- callListeners(pathIdListeners, void 0, () => ({[pathId]: 1}));
193
+ callListeners(pathIdListeners, void 0, pathId, 1);
194
194
  }
195
- callListeners(clientIdListeners, [pathId], () => ({[clientId]: 1}));
195
+ callListeners(clientIdListeners, [pathId], clientId, 1);
196
196
  webSocket.on('message', (data) => {
197
197
  const payload = data.toString(UTF8);
198
198
  const splitAt = payload.indexOf(MESSAGE_SEPARATOR);
@@ -214,12 +214,10 @@
214
214
  });
215
215
  webSocket.on('close', () => {
216
216
  collDel(clients, clientId);
217
- callListeners(clientIdListeners, [pathId], () => ({
218
- [clientId]: -1,
219
- }));
217
+ callListeners(clientIdListeners, [pathId], clientId, -1);
220
218
  if (collIsEmpty(clients)) {
221
219
  collDel(clientsByPath, pathId);
222
- callListeners(pathIdListeners, void 0, () => ({[pathId]: -1}));
220
+ callListeners(pathIdListeners, void 0, pathId, -1);
223
221
  }
224
222
  });
225
223
  }),
@@ -48,6 +48,7 @@
48
48
  arrayEvery(array1, (value1, index) => array2[index] === value1);
49
49
  const arrayMap = (array, cb) => array.map(cb);
50
50
  const arrayIsEmpty = (array) => size(array) == 0;
51
+ const arrayFilter = (array, cb) => array.filter(cb);
51
52
 
52
53
  const object = Object;
53
54
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -247,9 +248,7 @@
247
248
  ifNotUndefined(get(parameter, store2), (thing) =>
248
249
  then(
249
250
  store2['set' + settable](
250
- ...arrayMap(args, (arg) =>
251
- isFunction(arg) ? arg(parameter, store2) : arg,
252
- ),
251
+ ...argsOrGetArgs(args, store2, parameter),
253
252
  thing,
254
253
  ),
255
254
  thing,
@@ -257,9 +256,13 @@
257
256
  ),
258
257
  ),
259
258
  // eslint-disable-next-line react-hooks/exhaustive-deps
260
- [store, settable, ...getDeps, ...thenDeps, ...args],
259
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
261
260
  );
262
261
  };
262
+ const argsOrGetArgs = (args, store, parameter) =>
263
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
264
+ const nonFunctionDeps = (args) =>
265
+ arrayFilter(args, (arg) => !isFunction(arg));
263
266
  const useDel = (
264
267
  storeOrStoreId,
265
268
  deletable,
@@ -269,9 +272,12 @@
269
272
  ) => {
270
273
  const store = useStoreOrStoreById(storeOrStoreId);
271
274
  return useCallback$2(
272
- () => then(store?.['del' + deletable](...args)),
275
+ (parameter) =>
276
+ then(
277
+ store?.['del' + deletable](...argsOrGetArgs(args, store, parameter)),
278
+ ),
273
279
  // eslint-disable-next-line react-hooks/exhaustive-deps
274
- [store, deletable, ...thenDeps, ...args],
280
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
275
281
  );
276
282
  };
277
283
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
@@ -48,6 +48,7 @@
48
48
  arrayEvery(array1, (value1, index) => array2[index] === value1);
49
49
  const arrayMap = (array, cb) => array.map(cb);
50
50
  const arrayIsEmpty = (array) => size(array) == 0;
51
+ const arrayFilter = (array, cb) => array.filter(cb);
51
52
 
52
53
  const object = Object;
53
54
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -247,9 +248,7 @@
247
248
  ifNotUndefined(get(parameter, store2), (thing) =>
248
249
  then(
249
250
  store2['set' + settable](
250
- ...arrayMap(args, (arg) =>
251
- isFunction(arg) ? arg(parameter, store2) : arg,
252
- ),
251
+ ...argsOrGetArgs(args, store2, parameter),
253
252
  thing,
254
253
  ),
255
254
  thing,
@@ -257,9 +256,13 @@
257
256
  ),
258
257
  ),
259
258
  // eslint-disable-next-line react-hooks/exhaustive-deps
260
- [store, settable, ...getDeps, ...thenDeps, ...args],
259
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
261
260
  );
262
261
  };
262
+ const argsOrGetArgs = (args, store, parameter) =>
263
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
264
+ const nonFunctionDeps = (args) =>
265
+ arrayFilter(args, (arg) => !isFunction(arg));
263
266
  const useDel = (
264
267
  storeOrStoreId,
265
268
  deletable,
@@ -269,9 +272,12 @@
269
272
  ) => {
270
273
  const store = useStoreOrStoreById(storeOrStoreId);
271
274
  return useCallback$2(
272
- () => then(store?.['del' + deletable](...args)),
275
+ (parameter) =>
276
+ then(
277
+ store?.['del' + deletable](...argsOrGetArgs(args, store, parameter)),
278
+ ),
273
279
  // eslint-disable-next-line react-hooks/exhaustive-deps
274
- [store, deletable, ...thenDeps, ...args],
280
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
275
281
  );
276
282
  };
277
283
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {