tinybase 5.0.0 → 5.0.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 (43) hide show
  1. package/@types/ui-react/index.d.cts +62 -45
  2. package/@types/ui-react/index.d.ts +62 -45
  3. package/@types/ui-react/with-schemas/index.d.cts +83 -59
  4. package/@types/ui-react/with-schemas/index.d.ts +83 -59
  5. package/cjs/es6/min/ui-react/index.cjs +1 -1
  6. package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
  7. package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
  8. package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
  9. package/cjs/es6/ui-react/index.cjs +14 -34
  10. package/cjs/es6/ui-react/with-schemas/index.cjs +14 -34
  11. package/cjs/min/ui-react/index.cjs +1 -1
  12. package/cjs/min/ui-react/index.cjs.gz +0 -0
  13. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  14. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  15. package/cjs/ui-react/index.cjs +12 -12
  16. package/cjs/ui-react/with-schemas/index.cjs +12 -12
  17. package/es6/min/ui-react/index.js +1 -1
  18. package/es6/min/ui-react/index.js.gz +0 -0
  19. package/es6/min/ui-react/with-schemas/index.js +1 -1
  20. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  21. package/es6/ui-react/index.js +14 -34
  22. package/es6/ui-react/with-schemas/index.js +14 -34
  23. package/min/ui-react/index.js +1 -1
  24. package/min/ui-react/index.js.gz +0 -0
  25. package/min/ui-react/with-schemas/index.js +1 -1
  26. package/min/ui-react/with-schemas/index.js.gz +0 -0
  27. package/package.json +1 -1
  28. package/readme.md +40 -13
  29. package/releases.md +22 -22
  30. package/ui-react/index.js +12 -12
  31. package/ui-react/with-schemas/index.js +12 -12
  32. package/umd/es6/min/ui-react/index.js +1 -1
  33. package/umd/es6/min/ui-react/index.js.gz +0 -0
  34. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  35. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  36. package/umd/es6/ui-react/index.js +17 -34
  37. package/umd/es6/ui-react/with-schemas/index.js +17 -34
  38. package/umd/min/ui-react/index.js +1 -1
  39. package/umd/min/ui-react/index.js.gz +0 -0
  40. package/umd/min/ui-react/with-schemas/index.js +1 -1
  41. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  42. package/umd/ui-react/index.js +13 -12
  43. package/umd/ui-react/with-schemas/index.js +13 -12
@@ -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);
@@ -215,12 +216,7 @@
215
216
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
216
217
  [thing, returnType, listenable, ...args],
217
218
  );
218
- const result = useSyncExternalStore(subscribe, getResult);
219
- return returnType == 0 /* Object */
220
- ? {...result}
221
- : returnType < 3 /* CellOrValue */
222
- ? [...result]
223
- : result;
219
+ return useSyncExternalStore(subscribe, getResult);
224
220
  };
225
221
  const useListener = (
226
222
  listenable,
@@ -252,9 +248,7 @@
252
248
  ifNotUndefined(get(parameter, store2), (thing) =>
253
249
  then(
254
250
  store2['set' + settable](
255
- ...arrayMap(args, (arg) =>
256
- isFunction(arg) ? arg(parameter, store2) : arg,
257
- ),
251
+ ...argsOrGetArgs(args, store2, parameter),
258
252
  thing,
259
253
  ),
260
254
  thing,
@@ -262,9 +256,13 @@
262
256
  ),
263
257
  ),
264
258
  // eslint-disable-next-line react-hooks/exhaustive-deps
265
- [store, settable, ...getDeps, ...thenDeps, ...args],
259
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
266
260
  );
267
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));
268
266
  const useDel = (
269
267
  storeOrStoreId,
270
268
  deletable,
@@ -274,9 +272,12 @@
274
272
  ) => {
275
273
  const store = useStoreOrStoreById(storeOrStoreId);
276
274
  return useCallback$2(
277
- () => then(store?.['del' + deletable](...args)),
275
+ (parameter) =>
276
+ then(
277
+ store?.['del' + deletable](...argsOrGetArgs(args, store, parameter)),
278
+ ),
278
279
  // eslint-disable-next-line react-hooks/exhaustive-deps
279
- [store, deletable, ...thenDeps, ...args],
280
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
280
281
  );
281
282
  };
282
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);
@@ -215,12 +216,7 @@
215
216
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
216
217
  [thing, returnType, listenable, ...args],
217
218
  );
218
- const result = useSyncExternalStore(subscribe, getResult);
219
- return returnType == 0 /* Object */
220
- ? {...result}
221
- : returnType < 3 /* CellOrValue */
222
- ? [...result]
223
- : result;
219
+ return useSyncExternalStore(subscribe, getResult);
224
220
  };
225
221
  const useListener = (
226
222
  listenable,
@@ -252,9 +248,7 @@
252
248
  ifNotUndefined(get(parameter, store2), (thing) =>
253
249
  then(
254
250
  store2['set' + settable](
255
- ...arrayMap(args, (arg) =>
256
- isFunction(arg) ? arg(parameter, store2) : arg,
257
- ),
251
+ ...argsOrGetArgs(args, store2, parameter),
258
252
  thing,
259
253
  ),
260
254
  thing,
@@ -262,9 +256,13 @@
262
256
  ),
263
257
  ),
264
258
  // eslint-disable-next-line react-hooks/exhaustive-deps
265
- [store, settable, ...getDeps, ...thenDeps, ...args],
259
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
266
260
  );
267
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));
268
266
  const useDel = (
269
267
  storeOrStoreId,
270
268
  deletable,
@@ -274,9 +272,12 @@
274
272
  ) => {
275
273
  const store = useStoreOrStoreById(storeOrStoreId);
276
274
  return useCallback$2(
277
- () => then(store?.['del' + deletable](...args)),
275
+ (parameter) =>
276
+ then(
277
+ store?.['del' + deletable](...argsOrGetArgs(args, store, parameter)),
278
+ ),
278
279
  // eslint-disable-next-line react-hooks/exhaustive-deps
279
- [store, deletable, ...thenDeps, ...args],
280
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
280
281
  );
281
282
  };
282
283
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {