tinybase 5.3.0-beta.0 → 5.3.0-beta.1

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 (51) hide show
  1. package/@types/index.d.cts +0 -2
  2. package/@types/index.d.ts +0 -2
  3. package/@types/persisters/persister-partykit-client/index.d.cts +2 -2
  4. package/@types/persisters/persister-partykit-client/index.d.ts +2 -2
  5. package/@types/persisters/persister-partykit-client/with-schemas/index.d.cts +2 -2
  6. package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +2 -2
  7. package/@types/ui-react/index.d.cts +159 -0
  8. package/@types/ui-react/index.d.ts +159 -0
  9. package/@types/ui-react/with-schemas/index.d.cts +92 -0
  10. package/@types/ui-react/with-schemas/index.d.ts +92 -0
  11. package/@types/with-schemas/index.d.cts +0 -2
  12. package/@types/with-schemas/index.d.ts +0 -2
  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/ui-react/index.cjs +99 -30
  18. package/cjs/es6/ui-react/with-schemas/index.cjs +99 -30
  19. package/cjs/min/ui-react/index.cjs +1 -1
  20. package/cjs/min/ui-react/index.cjs.gz +0 -0
  21. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  22. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  23. package/cjs/ui-react/index.cjs +73 -31
  24. package/cjs/ui-react/with-schemas/index.cjs +73 -31
  25. package/es6/min/ui-react/index.js +1 -1
  26. package/es6/min/ui-react/index.js.gz +0 -0
  27. package/es6/min/ui-react/with-schemas/index.js +1 -1
  28. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  29. package/es6/ui-react/index.js +99 -30
  30. package/es6/ui-react/with-schemas/index.js +99 -30
  31. package/min/ui-react/index.js +1 -1
  32. package/min/ui-react/index.js.gz +0 -0
  33. package/min/ui-react/with-schemas/index.js +1 -1
  34. package/min/ui-react/with-schemas/index.js.gz +0 -0
  35. package/package.json +2 -2
  36. package/readme.md +14 -14
  37. package/releases.md +24 -24
  38. package/ui-react/index.js +73 -31
  39. package/ui-react/with-schemas/index.js +73 -31
  40. package/umd/es6/min/ui-react/index.js +1 -1
  41. package/umd/es6/min/ui-react/index.js.gz +0 -0
  42. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  43. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  44. package/umd/es6/ui-react/index.js +102 -34
  45. package/umd/es6/ui-react/with-schemas/index.js +102 -34
  46. package/umd/min/ui-react/index.js +1 -1
  47. package/umd/min/ui-react/index.js.gz +0 -0
  48. package/umd/min/ui-react/with-schemas/index.js +1 -1
  49. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  50. package/umd/ui-react/index.js +77 -31
  51. package/umd/ui-react/with-schemas/index.js +77 -31
@@ -11,8 +11,6 @@ export * from './checkpoints/index.d.cts';
11
11
  export * from './common/index.d.cts';
12
12
  export * from './indexes/index.d.cts';
13
13
  export * from './metrics/index.d.cts';
14
- export * from './persisters/index.d.cts';
15
- export * from './synchronizers/index.d.cts';
16
14
  export * from './queries/index.d.cts';
17
15
  export * from './relationships/index.d.cts';
18
16
  export * from './mergeable-store/index.d.cts';
package/@types/index.d.ts CHANGED
@@ -11,8 +11,6 @@ export * from './checkpoints/index.d.ts';
11
11
  export * from './common/index.d.ts';
12
12
  export * from './indexes/index.d.ts';
13
13
  export * from './metrics/index.d.ts';
14
- export * from './persisters/index.d.ts';
15
- export * from './synchronizers/index.d.ts';
16
14
  export * from './queries/index.d.ts';
17
15
  export * from './relationships/index.d.ts';
18
16
  export * from './mergeable-store/index.d.ts';
@@ -46,7 +46,7 @@ export interface PartyKitPersister extends Persister {
46
46
  * then gets the PartySocket back out again.
47
47
  *
48
48
  * ```js yolo
49
- * import PartySocket from 'partysocket';
49
+ * import {PartySocket} from 'partysocket';
50
50
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
51
51
  * import {createStore} from 'tinybase';
52
52
  *
@@ -166,7 +166,7 @@ export type PartyKitPersisterConfig = {
166
166
  * browser's IndexedDB storage.
167
167
  *
168
168
  * ```js yolo
169
- * import PartySocket from 'partysocket';
169
+ * import {PartySocket} from 'partysocket';
170
170
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
171
171
  * import {createStore} from 'tinybase';
172
172
  *
@@ -46,7 +46,7 @@ export interface PartyKitPersister extends Persister {
46
46
  * then gets the PartySocket back out again.
47
47
  *
48
48
  * ```js yolo
49
- * import PartySocket from 'partysocket';
49
+ * import {PartySocket} from 'partysocket';
50
50
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
51
51
  * import {createStore} from 'tinybase';
52
52
  *
@@ -166,7 +166,7 @@ export type PartyKitPersisterConfig = {
166
166
  * browser's IndexedDB storage.
167
167
  *
168
168
  * ```js yolo
169
- * import PartySocket from 'partysocket';
169
+ * import {PartySocket} from 'partysocket';
170
170
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
171
171
  * import {createStore} from 'tinybase';
172
172
  *
@@ -50,7 +50,7 @@ export interface PartyKitPersister<Schemas extends OptionalSchemas>
50
50
  * then gets the PartySocket back out again.
51
51
  *
52
52
  * ```js yolo
53
- * import PartySocket from 'partysocket';
53
+ * import {PartySocket} from 'partysocket';
54
54
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
55
55
  * import {createStore} from 'tinybase';
56
56
  *
@@ -181,7 +181,7 @@ export type PartyKitPersisterConfig = {
181
181
  * browser's IndexedDB storage.
182
182
  *
183
183
  * ```js yolo
184
- * import PartySocket from 'partysocket';
184
+ * import {PartySocket} from 'partysocket';
185
185
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
186
186
  * import {createStore} from 'tinybase';
187
187
  *
@@ -50,7 +50,7 @@ export interface PartyKitPersister<Schemas extends OptionalSchemas>
50
50
  * then gets the PartySocket back out again.
51
51
  *
52
52
  * ```js yolo
53
- * import PartySocket from 'partysocket';
53
+ * import {PartySocket} from 'partysocket';
54
54
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
55
55
  * import {createStore} from 'tinybase';
56
56
  *
@@ -181,7 +181,7 @@ export type PartyKitPersisterConfig = {
181
181
  * browser's IndexedDB storage.
182
182
  *
183
183
  * ```js yolo
184
- * import PartySocket from 'partysocket';
184
+ * import {PartySocket} from 'partysocket';
185
185
  * import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
186
186
  * import {createStore} from 'tinybase';
187
187
  *
@@ -5902,6 +5902,76 @@ export function useMetricsOrMetricsById(
5902
5902
  metricsOrMetricsId?: MetricsOrMetricsId,
5903
5903
  ): Metrics | undefined;
5904
5904
 
5905
+ /**
5906
+ * The useProvideMetrics hook is used to add a Metrics object by Id to a
5907
+ * Provider component, but imperatively from a component within it.
5908
+ *
5909
+ * Normally you will register a Metrics object by Id in a context by using the
5910
+ * `metricsById` prop of the top-level Provider component. This hook, however,
5911
+ * lets you dynamically add a new Metrics object to the context, from within a
5912
+ * descendent component. This is useful for applications where the set of
5913
+ * Metrics objects is not known at the time of the first render of the root
5914
+ * Provider.
5915
+ *
5916
+ * A Metrics object added to the Provider context in this way will be available
5917
+ * to other components within the context (using the useMetrics hook and so on).
5918
+ * If you use the same Id as an existing Metrics object registration, the new
5919
+ * one will take priority over one provided by the `metricsById` prop.
5920
+ *
5921
+ * Note that other components that consume a Metrics object registered like this
5922
+ * should defend against it being undefined at first. On the first render, the
5923
+ * other component will likely not yet have completed the registration. In the
5924
+ * example below, we use the null-safe `useMetrics('petMetrics')?` to do this.
5925
+ * @param metricsId The Id of the Metrics object to be registered with the
5926
+ * Provider.
5927
+ * @param metrics The Metrics object to be registered.
5928
+ * @example
5929
+ * This example creates a Provider context. A child component registers a
5930
+ * Metrics object into it which is then consumable by a peer child component.
5931
+ *
5932
+ * ```jsx
5933
+ * import {
5934
+ * Provider,
5935
+ * useCreateMetrics,
5936
+ * useCreateStore,
5937
+ * useMetrics,
5938
+ * useProvideMetrics,
5939
+ * } from 'tinybase/ui-react';
5940
+ * import {createMetrics, createStore} from 'tinybase';
5941
+ * import React from 'react';
5942
+ * import {createRoot} from 'react-dom/client';
5943
+ *
5944
+ * const App = () => (
5945
+ * <Provider>
5946
+ * <RegisterMetrics />
5947
+ * <ConsumeMetrics />
5948
+ * </Provider>
5949
+ * );
5950
+ * const RegisterMetrics = () => {
5951
+ * const store = useCreateStore(() =>
5952
+ * createStore().setCell('pets', 'fido', 'color', 'brown'),
5953
+ * );
5954
+ * const metrics = useCreateMetrics(store, (store) =>
5955
+ * createMetrics(store).setMetricDefinition('petCount', 'pets', 'count'),
5956
+ * );
5957
+ * useProvideMetrics('petMetrics', metrics);
5958
+ * return null;
5959
+ * };
5960
+ * const ConsumeMetrics = () => (
5961
+ * <span>{useMetrics('petMetrics')?.getMetric('petCount')}</span>
5962
+ * );
5963
+ *
5964
+ * const app = document.createElement('div');
5965
+ * const root = createRoot(app);
5966
+ * root.render(<App />); // !act
5967
+ * console.log(app.innerHTML);
5968
+ * // -> '<span>1</span>'
5969
+ * ```
5970
+ * @category Metrics hooks
5971
+ * @since v5.3.0
5972
+ */
5973
+ export function useProvideMetrics(metricsId: Id, metrics: Metrics): void;
5974
+
5905
5975
  /**
5906
5976
  * The useMetricIds hook gets an array of the Metric Ids registered with a
5907
5977
  * Metrics object, and registers a listener so that any changes to that result
@@ -6454,6 +6524,9 @@ export function useIndexesOrIndexesById(
6454
6524
  indexesOrIndexesId?: IndexesOrIndexesId,
6455
6525
  ): Indexes | undefined;
6456
6526
 
6527
+ // useProvideIndexes
6528
+ export function useProvideIndexes(indexesId: Id, indexes: Indexes): void;
6529
+
6457
6530
  /**
6458
6531
  * The useIndexIds hook gets an array of the Index Ids registered with an
6459
6532
  * Indexes object, and registers a listener so that any changes to that result
@@ -7258,6 +7331,12 @@ export function useRelationshipsOrRelationshipsById(
7258
7331
  relationshipsOrRelationshipsId?: RelationshipsOrRelationshipsId,
7259
7332
  ): Relationships | undefined;
7260
7333
 
7334
+ // useProvideRelationships
7335
+ export function useProvideRelationships(
7336
+ relationshipsId: Id,
7337
+ relationships: Relationships,
7338
+ ): void;
7339
+
7261
7340
  /**
7262
7341
  * The useRelationshipIds hook gets an array of the Relationship Ids registered
7263
7342
  * with a Relationships object, and registers a listener so that any changes to
@@ -8306,6 +8385,9 @@ export function useQueriesOrQueriesById(
8306
8385
  queriesOrQueriesId?: QueriesOrQueriesId,
8307
8386
  ): Queries | undefined;
8308
8387
 
8388
+ // useProvideQueries
8389
+ export function useProvideQueries(queriesId: Id, queries: Queries): void;
8390
+
8309
8391
  /**
8310
8392
  * The useQueryIds hook gets an array of the Query Ids registered with a Queries
8311
8393
  * object, and registers a listener so that any changes to that result will
@@ -10486,10 +10568,87 @@ export function useCheckpoints(id?: Id): Checkpoints | undefined;
10486
10568
  * @category Checkpoints hooks
10487
10569
  * @since v4.1.0
10488
10570
  */
10571
+ /**
10572
+ * The useProvideCheckpoints hook is used to add a Checkpoints object by Id to a
10573
+ * Provider component, but imperatively from a component within it.
10574
+ *
10575
+ * Normally you will register a Checkpoints object by Id in a context by using
10576
+ * the `checkpointsById` prop of the top-level Provider component. This hook,
10577
+ * however, lets you dynamically add a new Checkpoints object to the context,
10578
+ * from within a component. This is useful for applications where the set of
10579
+ * Checkpoints objects is not known at the time of the first render of the root
10580
+ * Provider.
10581
+ *
10582
+ * A Checkpoints object added to the Provider context in this way will be
10583
+ * available to other components within the context (using the useCheckpoints
10584
+ * hook and so on). If you use the same Id as an existing Checkpoints object
10585
+ * registration, the new one will take priority over one provided by the
10586
+ * `checkpointsById` prop.
10587
+ *
10588
+ * Note that other components that consume a Checkpoints object registered like
10589
+ * this should defend against it being undefined at first. On the first render,
10590
+ * the other component will likely not yet have completed the registration. In
10591
+ * the example below, we use the null-safe `useCheckpoints('petCheckpoints')?`
10592
+ * to do this.
10593
+ * @param checkpointsId The Id of the Checkpoints object to be registered with
10594
+ * the Provider.
10595
+ * @param checkpoints The Checkpoints object to be registered.
10596
+ * @example
10597
+ * This example creates a Provider context. A child component registers a
10598
+ * Checkpoints object into it which is then consumable by a peer child
10599
+ * component.
10600
+ *
10601
+ * ```jsx
10602
+ * import {
10603
+ * Provider,
10604
+ * useCheckpoints,
10605
+ * useCreateCheckpoints,
10606
+ * useCreateStore,
10607
+ * useProvideCheckpoints,
10608
+ * } from 'tinybase/ui-react';
10609
+ * import {createCheckpoints, createStore} from 'tinybase';
10610
+ * import React from 'react';
10611
+ * import {createRoot} from 'react-dom/client';
10612
+ *
10613
+ * const App = () => (
10614
+ * <Provider>
10615
+ * <RegisterCheckpoints />
10616
+ * <ConsumeCheckpoints />
10617
+ * </Provider>
10618
+ * );
10619
+ * const RegisterCheckpoints = () => {
10620
+ * const store = useCreateStore(() =>
10621
+ * createStore().setCell('pets', 'fido', 'color', 'brown'),
10622
+ * );
10623
+ * const checkpoints = useCreateCheckpoints(store, createCheckpoints);
10624
+ * useProvideCheckpoints('petCheckpoints', checkpoints);
10625
+ * return null;
10626
+ * };
10627
+ * const ConsumeCheckpoints = () => (
10628
+ * <span>
10629
+ * {JSON.stringify(useCheckpoints('petCheckpoints')?.getCheckpointIds())}
10630
+ * </span>
10631
+ * );
10632
+ *
10633
+ * const app = document.createElement('div');
10634
+ * const root = createRoot(app);
10635
+ * root.render(<App />); // !act
10636
+ * console.log(app.innerHTML);
10637
+ * // -> '<span>[[],"0",[]]</span>'
10638
+ * ```
10639
+ * @category Checkpoints hooks
10640
+ * @since v5.3.0
10641
+ */
10489
10642
  export function useCheckpointsOrCheckpointsById(
10490
10643
  checkpointsOrCheckpointsId?: CheckpointsOrCheckpointsId,
10491
10644
  ): Checkpoints | undefined;
10492
10645
 
10646
+ // useProvideCheckpoints
10647
+ export function useProvideCheckpoints(
10648
+ checkpointsId: Id,
10649
+ checkpoints: Checkpoints,
10650
+ ): void;
10651
+
10493
10652
  /**
10494
10653
  * The useCheckpointIds hook returns an array of the checkpoint Ids being
10495
10654
  * managed by this Checkpoints object, and registers a listener so that any
@@ -5902,6 +5902,76 @@ export function useMetricsOrMetricsById(
5902
5902
  metricsOrMetricsId?: MetricsOrMetricsId,
5903
5903
  ): Metrics | undefined;
5904
5904
 
5905
+ /**
5906
+ * The useProvideMetrics hook is used to add a Metrics object by Id to a
5907
+ * Provider component, but imperatively from a component within it.
5908
+ *
5909
+ * Normally you will register a Metrics object by Id in a context by using the
5910
+ * `metricsById` prop of the top-level Provider component. This hook, however,
5911
+ * lets you dynamically add a new Metrics object to the context, from within a
5912
+ * descendent component. This is useful for applications where the set of
5913
+ * Metrics objects is not known at the time of the first render of the root
5914
+ * Provider.
5915
+ *
5916
+ * A Metrics object added to the Provider context in this way will be available
5917
+ * to other components within the context (using the useMetrics hook and so on).
5918
+ * If you use the same Id as an existing Metrics object registration, the new
5919
+ * one will take priority over one provided by the `metricsById` prop.
5920
+ *
5921
+ * Note that other components that consume a Metrics object registered like this
5922
+ * should defend against it being undefined at first. On the first render, the
5923
+ * other component will likely not yet have completed the registration. In the
5924
+ * example below, we use the null-safe `useMetrics('petMetrics')?` to do this.
5925
+ * @param metricsId The Id of the Metrics object to be registered with the
5926
+ * Provider.
5927
+ * @param metrics The Metrics object to be registered.
5928
+ * @example
5929
+ * This example creates a Provider context. A child component registers a
5930
+ * Metrics object into it which is then consumable by a peer child component.
5931
+ *
5932
+ * ```jsx
5933
+ * import {
5934
+ * Provider,
5935
+ * useCreateMetrics,
5936
+ * useCreateStore,
5937
+ * useMetrics,
5938
+ * useProvideMetrics,
5939
+ * } from 'tinybase/ui-react';
5940
+ * import {createMetrics, createStore} from 'tinybase';
5941
+ * import React from 'react';
5942
+ * import {createRoot} from 'react-dom/client';
5943
+ *
5944
+ * const App = () => (
5945
+ * <Provider>
5946
+ * <RegisterMetrics />
5947
+ * <ConsumeMetrics />
5948
+ * </Provider>
5949
+ * );
5950
+ * const RegisterMetrics = () => {
5951
+ * const store = useCreateStore(() =>
5952
+ * createStore().setCell('pets', 'fido', 'color', 'brown'),
5953
+ * );
5954
+ * const metrics = useCreateMetrics(store, (store) =>
5955
+ * createMetrics(store).setMetricDefinition('petCount', 'pets', 'count'),
5956
+ * );
5957
+ * useProvideMetrics('petMetrics', metrics);
5958
+ * return null;
5959
+ * };
5960
+ * const ConsumeMetrics = () => (
5961
+ * <span>{useMetrics('petMetrics')?.getMetric('petCount')}</span>
5962
+ * );
5963
+ *
5964
+ * const app = document.createElement('div');
5965
+ * const root = createRoot(app);
5966
+ * root.render(<App />); // !act
5967
+ * console.log(app.innerHTML);
5968
+ * // -> '<span>1</span>'
5969
+ * ```
5970
+ * @category Metrics hooks
5971
+ * @since v5.3.0
5972
+ */
5973
+ export function useProvideMetrics(metricsId: Id, metrics: Metrics): void;
5974
+
5905
5975
  /**
5906
5976
  * The useMetricIds hook gets an array of the Metric Ids registered with a
5907
5977
  * Metrics object, and registers a listener so that any changes to that result
@@ -6454,6 +6524,9 @@ export function useIndexesOrIndexesById(
6454
6524
  indexesOrIndexesId?: IndexesOrIndexesId,
6455
6525
  ): Indexes | undefined;
6456
6526
 
6527
+ // useProvideIndexes
6528
+ export function useProvideIndexes(indexesId: Id, indexes: Indexes): void;
6529
+
6457
6530
  /**
6458
6531
  * The useIndexIds hook gets an array of the Index Ids registered with an
6459
6532
  * Indexes object, and registers a listener so that any changes to that result
@@ -7258,6 +7331,12 @@ export function useRelationshipsOrRelationshipsById(
7258
7331
  relationshipsOrRelationshipsId?: RelationshipsOrRelationshipsId,
7259
7332
  ): Relationships | undefined;
7260
7333
 
7334
+ // useProvideRelationships
7335
+ export function useProvideRelationships(
7336
+ relationshipsId: Id,
7337
+ relationships: Relationships,
7338
+ ): void;
7339
+
7261
7340
  /**
7262
7341
  * The useRelationshipIds hook gets an array of the Relationship Ids registered
7263
7342
  * with a Relationships object, and registers a listener so that any changes to
@@ -8306,6 +8385,9 @@ export function useQueriesOrQueriesById(
8306
8385
  queriesOrQueriesId?: QueriesOrQueriesId,
8307
8386
  ): Queries | undefined;
8308
8387
 
8388
+ // useProvideQueries
8389
+ export function useProvideQueries(queriesId: Id, queries: Queries): void;
8390
+
8309
8391
  /**
8310
8392
  * The useQueryIds hook gets an array of the Query Ids registered with a Queries
8311
8393
  * object, and registers a listener so that any changes to that result will
@@ -10486,10 +10568,87 @@ export function useCheckpoints(id?: Id): Checkpoints | undefined;
10486
10568
  * @category Checkpoints hooks
10487
10569
  * @since v4.1.0
10488
10570
  */
10571
+ /**
10572
+ * The useProvideCheckpoints hook is used to add a Checkpoints object by Id to a
10573
+ * Provider component, but imperatively from a component within it.
10574
+ *
10575
+ * Normally you will register a Checkpoints object by Id in a context by using
10576
+ * the `checkpointsById` prop of the top-level Provider component. This hook,
10577
+ * however, lets you dynamically add a new Checkpoints object to the context,
10578
+ * from within a component. This is useful for applications where the set of
10579
+ * Checkpoints objects is not known at the time of the first render of the root
10580
+ * Provider.
10581
+ *
10582
+ * A Checkpoints object added to the Provider context in this way will be
10583
+ * available to other components within the context (using the useCheckpoints
10584
+ * hook and so on). If you use the same Id as an existing Checkpoints object
10585
+ * registration, the new one will take priority over one provided by the
10586
+ * `checkpointsById` prop.
10587
+ *
10588
+ * Note that other components that consume a Checkpoints object registered like
10589
+ * this should defend against it being undefined at first. On the first render,
10590
+ * the other component will likely not yet have completed the registration. In
10591
+ * the example below, we use the null-safe `useCheckpoints('petCheckpoints')?`
10592
+ * to do this.
10593
+ * @param checkpointsId The Id of the Checkpoints object to be registered with
10594
+ * the Provider.
10595
+ * @param checkpoints The Checkpoints object to be registered.
10596
+ * @example
10597
+ * This example creates a Provider context. A child component registers a
10598
+ * Checkpoints object into it which is then consumable by a peer child
10599
+ * component.
10600
+ *
10601
+ * ```jsx
10602
+ * import {
10603
+ * Provider,
10604
+ * useCheckpoints,
10605
+ * useCreateCheckpoints,
10606
+ * useCreateStore,
10607
+ * useProvideCheckpoints,
10608
+ * } from 'tinybase/ui-react';
10609
+ * import {createCheckpoints, createStore} from 'tinybase';
10610
+ * import React from 'react';
10611
+ * import {createRoot} from 'react-dom/client';
10612
+ *
10613
+ * const App = () => (
10614
+ * <Provider>
10615
+ * <RegisterCheckpoints />
10616
+ * <ConsumeCheckpoints />
10617
+ * </Provider>
10618
+ * );
10619
+ * const RegisterCheckpoints = () => {
10620
+ * const store = useCreateStore(() =>
10621
+ * createStore().setCell('pets', 'fido', 'color', 'brown'),
10622
+ * );
10623
+ * const checkpoints = useCreateCheckpoints(store, createCheckpoints);
10624
+ * useProvideCheckpoints('petCheckpoints', checkpoints);
10625
+ * return null;
10626
+ * };
10627
+ * const ConsumeCheckpoints = () => (
10628
+ * <span>
10629
+ * {JSON.stringify(useCheckpoints('petCheckpoints')?.getCheckpointIds())}
10630
+ * </span>
10631
+ * );
10632
+ *
10633
+ * const app = document.createElement('div');
10634
+ * const root = createRoot(app);
10635
+ * root.render(<App />); // !act
10636
+ * console.log(app.innerHTML);
10637
+ * // -> '<span>[[],"0",[]]</span>'
10638
+ * ```
10639
+ * @category Checkpoints hooks
10640
+ * @since v5.3.0
10641
+ */
10489
10642
  export function useCheckpointsOrCheckpointsById(
10490
10643
  checkpointsOrCheckpointsId?: CheckpointsOrCheckpointsId,
10491
10644
  ): Checkpoints | undefined;
10492
10645
 
10646
+ // useProvideCheckpoints
10647
+ export function useProvideCheckpoints(
10648
+ checkpointsId: Id,
10649
+ checkpoints: Checkpoints,
10650
+ ): void;
10651
+
10493
10652
  /**
10494
10653
  * The useCheckpointIds hook returns an array of the checkpoint Ids being
10495
10654
  * managed by this Checkpoints object, and registers a listener so that any
@@ -6802,6 +6802,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
6802
6802
  metricsOrMetricsId?: MetricsOrMetricsId<Schemas>,
6803
6803
  ) => Metrics<Schemas> | undefined;
6804
6804
 
6805
+ // useProvideMetrics
6806
+ useProvideMetrics: (metricsId: Id, metrics: Metrics<Schemas>) => void;
6807
+
6805
6808
  /**
6806
6809
  * The useMetricIds hook gets an array of the Metric Ids registered with a
6807
6810
  * Metrics object, and registers a listener so that any changes to that result
@@ -7404,6 +7407,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
7404
7407
  indexesOrIndexesId?: IndexesOrIndexesId<Schemas>,
7405
7408
  ) => Indexes<Schemas> | undefined;
7406
7409
 
7410
+ // useProvideIndexes
7411
+ useProvideIndexes: (indexesId: Id, indexes: Indexes<Schemas>) => void;
7412
+
7407
7413
  /**
7408
7414
  * The useIndexIds hook gets an array of the Index Ids registered with an
7409
7415
  * Indexes object, and registers a listener so that any changes to that result
@@ -8280,6 +8286,12 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
8280
8286
  relationshipsOrRelationshipsId?: RelationshipsOrRelationshipsId<Schemas>,
8281
8287
  ) => Relationships<Schemas> | undefined;
8282
8288
 
8289
+ // useProvideRelationships
8290
+ useProvideRelationships: (
8291
+ relationshipsId: Id,
8292
+ relationships: Relationships<Schemas>,
8293
+ ) => void;
8294
+
8283
8295
  /**
8284
8296
  * The useRelationshipIds hook gets an array of the Relationship Ids registered
8285
8297
  * with a Relationships object, and registers a listener so that any changes to
@@ -9426,6 +9438,9 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
9426
9438
  queriesOrQueriesId?: QueriesOrQueriesId<Schemas>,
9427
9439
  ) => Queries<Schemas> | undefined;
9428
9440
 
9441
+ // useProvideQueries
9442
+ useProvideQueries: (queriesId: Id, queries: Queries<Schemas>) => void;
9443
+
9429
9444
  /**
9430
9445
  * The useQueryIds hook gets an array of the Query Ids registered with a Queries
9431
9446
  * object, and registers a listener so that any changes to that result will
@@ -11811,11 +11826,88 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
11811
11826
  * ```
11812
11827
  * @category Checkpoints hooks
11813
11828
  * @since v4.1.0
11829
+ */
11830
+ /**
11831
+ * The useProvideCheckpoints hook is used to add a Checkpoints object by Id to a
11832
+ * Provider component, but imperatively from a component within it.
11833
+ *
11834
+ * Normally you will register a Checkpoints object by Id in a context by using
11835
+ * the `checkpointsById` prop of the top-level Provider component. This hook,
11836
+ * however, lets you dynamically add a new Checkpoints object to the context,
11837
+ * from within a component. This is useful for applications where the set of
11838
+ * Checkpoints objects is not known at the time of the first render of the root
11839
+ * Provider.
11840
+ *
11841
+ * A Checkpoints object added to the Provider context in this way will be
11842
+ * available to other components within the context (using the useCheckpoints
11843
+ * hook and so on). If you use the same Id as an existing Checkpoints object
11844
+ * registration, the new one will take priority over one provided by the
11845
+ * `checkpointsById` prop.
11846
+ *
11847
+ * Note that other components that consume a Checkpoints object registered like
11848
+ * this should defend against it being undefined at first. On the first render,
11849
+ * the other component will likely not yet have completed the registration. In
11850
+ * the example below, we use the null-safe `useCheckpoints('petCheckpoints')?`
11851
+ * to do this.
11852
+ * @param checkpointsId The Id of the Checkpoints object to be registered with
11853
+ * the Provider.
11854
+ * @param checkpoints The Checkpoints object to be registered.
11855
+ * @example
11856
+ * This example creates a Provider context. A child component registers a
11857
+ * Checkpoints object into it which is then consumable by a peer child
11858
+ * component.
11859
+ *
11860
+ * ```jsx
11861
+ * import {
11862
+ * Provider,
11863
+ * useCheckpoints,
11864
+ * useCreateCheckpoints,
11865
+ * useCreateStore,
11866
+ * useProvideCheckpoints,
11867
+ * } from 'tinybase/ui-react';
11868
+ * import {createCheckpoints, createStore} from 'tinybase';
11869
+ * import React from 'react';
11870
+ * import {createRoot} from 'react-dom/client';
11871
+ *
11872
+ * const App = () => (
11873
+ * <Provider>
11874
+ * <RegisterCheckpoints />
11875
+ * <ConsumeCheckpoints />
11876
+ * </Provider>
11877
+ * );
11878
+ * const RegisterCheckpoints = () => {
11879
+ * const store = useCreateStore(() =>
11880
+ * createStore().setCell('pets', 'fido', 'color', 'brown'),
11881
+ * );
11882
+ * const checkpoints = useCreateCheckpoints(store, createCheckpoints);
11883
+ * useProvideCheckpoints('petCheckpoints', checkpoints);
11884
+ * return null;
11885
+ * };
11886
+ * const ConsumeCheckpoints = () => (
11887
+ * <span>
11888
+ * {JSON.stringify(useCheckpoints('petCheckpoints')?.getCheckpointIds())}
11889
+ * </span>
11890
+ * );
11891
+ *
11892
+ * const app = document.createElement('div');
11893
+ * const root = createRoot(app);
11894
+ * root.render(<App />); // !act
11895
+ * console.log(app.innerHTML);
11896
+ * // -> '<span>[[],"0",[]]</span>'
11897
+ * ```
11898
+ * @category Checkpoints hooks
11899
+ * @since v5.3.0
11814
11900
  */
11815
11901
  useCheckpointsOrCheckpointsById: (
11816
11902
  checkpointsOrCheckpointsId?: CheckpointsOrCheckpointsId<Schemas>,
11817
11903
  ) => Checkpoints<Schemas> | undefined;
11818
11904
 
11905
+ // useProvideCheckpoints
11906
+ useProvideCheckpoints: (
11907
+ checkpointsId: Id,
11908
+ checkpoints: Checkpoints<Schemas>,
11909
+ ) => void;
11910
+
11819
11911
  /**
11820
11912
  * The useCheckpointIds hook returns an array of the checkpoint Ids being
11821
11913
  * managed by this Checkpoints object, and registers a listener so that any