tinybase 5.2.2 → 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 (43) hide show
  1. package/@types/ui-react/index.d.cts +159 -0
  2. package/@types/ui-react/index.d.ts +159 -0
  3. package/@types/ui-react/with-schemas/index.d.cts +92 -0
  4. package/@types/ui-react/with-schemas/index.d.ts +92 -0
  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 +89 -29
  10. package/cjs/es6/ui-react/with-schemas/index.cjs +89 -29
  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 +63 -30
  16. package/cjs/ui-react/with-schemas/index.cjs +63 -30
  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 +89 -29
  22. package/es6/ui-react/with-schemas/index.js +89 -29
  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 +14 -14
  29. package/releases.md +24 -24
  30. package/ui-react/index.js +63 -30
  31. package/ui-react/with-schemas/index.js +63 -30
  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 +90 -33
  37. package/umd/es6/ui-react/with-schemas/index.js +90 -33
  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 +65 -30
  43. package/umd/ui-react/with-schemas/index.js +65 -30
@@ -42,6 +42,7 @@ const arrayIsEqual = (array1, array2) =>
42
42
  const arrayMap = (array, cb) => array.map(cb);
43
43
  const arrayIsEmpty = (array) => size(array) == 0;
44
44
  const arrayFilter = (array, cb) => array.filter(cb);
45
+ const arrayWith = (array, index, value) => array.with(index, value);
45
46
 
46
47
  const object = Object;
47
48
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -102,6 +103,16 @@ const useThingOrThingById = (thingOrThingId, offset) => {
102
103
  ? thing
103
104
  : thingOrThingId;
104
105
  };
106
+ const useProvideThing = (thingId, thing, offset) => {
107
+ const {12: addExtraThingById, 13: delExtraThingById} = useContext$1(Context);
108
+ useEffect$1(() => {
109
+ addExtraThingById == null
110
+ ? void 0
111
+ : addExtraThingById(offset, thingId, thing);
112
+ return () =>
113
+ delExtraThingById == null ? void 0 : delExtraThingById(offset, thingId);
114
+ }, [addExtraThingById, thingId, thing, offset, delExtraThingById]);
115
+ };
105
116
  const useThingIds = (offset) => {
106
117
  var _a;
107
118
  return objIds((_a = useContext$1(Context)[offset]) != null ? _a : {});
@@ -109,28 +120,32 @@ const useThingIds = (offset) => {
109
120
  const useStore = (id) => useThing(id, 0);
110
121
  const useStoreOrStoreById = (storeOrStoreId) =>
111
122
  useThingOrThingById(storeOrStoreId, 0);
112
- const useProvideStore = (storeId, store) => {
113
- const {12: addExtraStore, 13: delExtraStore} = useContext$1(Context);
114
- useEffect$1(() => {
115
- addExtraStore == null ? void 0 : addExtraStore(storeId, store);
116
- return () => (delExtraStore == null ? void 0 : delExtraStore(storeId));
117
- }, [addExtraStore, storeId, store, delExtraStore]);
118
- };
123
+ const useProvideStore = (storeId, store) => useProvideThing(storeId, store, 0);
119
124
  const useMetrics = (id) => useThing(id, 2);
120
125
  const useMetricsOrMetricsById = (metricsOrMetricsId) =>
121
126
  useThingOrThingById(metricsOrMetricsId, 2);
127
+ const useProvideMetrics = (metricsId, metrics) =>
128
+ useProvideThing(metricsId, metrics, 1);
122
129
  const useIndexes = (id) => useThing(id, 4);
123
130
  const useIndexesOrIndexesById = (indexesOrIndexesId) =>
124
131
  useThingOrThingById(indexesOrIndexesId, 4);
132
+ const useProvideIndexes = (indexesId, indexes) =>
133
+ useProvideThing(indexesId, indexes, 2);
125
134
  const useRelationships = (id) => useThing(id, 6);
126
135
  const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
127
136
  useThingOrThingById(relationshipsOrRelationshipsId, 6);
137
+ const useProvideRelationships = (relationshipsId, relationships) =>
138
+ useProvideThing(relationshipsId, relationships, 3);
128
139
  const useQueries = (id) => useThing(id, 8);
129
140
  const useQueriesOrQueriesById = (queriesOrQueriesId) =>
130
141
  useThingOrThingById(queriesOrQueriesId, 8);
142
+ const useProvideQueries = (queriesId, queries) =>
143
+ useProvideThing(queriesId, queries, 4);
131
144
  const useCheckpoints = (id) => useThing(id, 10);
132
145
  const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
133
146
  useThingOrThingById(checkpointsOrCheckpointsId, 10);
147
+ const useProvideCheckpoints = (checkpointsId, checkpoints) =>
148
+ useProvideThing(checkpointsId, checkpoints, 5);
134
149
 
135
150
  const lower = (str) => str.toLowerCase();
136
151
  lower(LISTENER);
@@ -1699,20 +1714,39 @@ const Provider = ({
1699
1714
  children,
1700
1715
  }) => {
1701
1716
  const parentValue = useContext(Context);
1702
- const [extraStoresById, setExtraStoresById] = useState({});
1703
- const addExtraStore = useCallback(
1704
- (id, store2) =>
1705
- setExtraStoresById((extraStoresById2) =>
1706
- objGet(extraStoresById2, id) == store2
1707
- ? extraStoresById2
1708
- : __spreadProps(__spreadValues({}, extraStoresById2), {[id]: store2}),
1717
+ const [extraThingsById, setExtraThingsById] = useState([
1718
+ {},
1719
+ {},
1720
+ {},
1721
+ {},
1722
+ {},
1723
+ {},
1724
+ ]);
1725
+ const addExtraThingById = useCallback(
1726
+ (thingOffset, id, thing) =>
1727
+ setExtraThingsById((extraThingsById2) =>
1728
+ objGet(extraThingsById2[thingOffset], id) == thing
1729
+ ? extraThingsById2
1730
+ : arrayWith(
1731
+ extraThingsById2,
1732
+ thingOffset,
1733
+ __spreadProps(__spreadValues({}, extraThingsById2[thingOffset]), {
1734
+ [id]: thing,
1735
+ }),
1736
+ ),
1709
1737
  ),
1710
1738
  [],
1711
1739
  );
1712
- const delExtraStore = useCallback(
1713
- (id) =>
1714
- setExtraStoresById((extraStoresById2) =>
1715
- __spreadValues({}, objDel(extraStoresById2, id)),
1740
+ const delExtraThingById = useCallback(
1741
+ (thingOffset, id) =>
1742
+ setExtraThingsById((extraThingsById2) =>
1743
+ !objHas(extraThingsById2[thingOffset], id)
1744
+ ? extraThingsById2
1745
+ : arrayWith(
1746
+ extraThingsById2,
1747
+ thingOffset,
1748
+ objDel(extraThingsById2[thingOffset], id),
1749
+ ),
1716
1750
  ),
1717
1751
  [],
1718
1752
  );
@@ -1724,25 +1758,46 @@ const Provider = ({
1724
1758
  store != null ? store : parentValue[0],
1725
1759
  __spreadValues(
1726
1760
  __spreadValues(__spreadValues({}, parentValue[1]), storesById),
1727
- extraStoresById,
1761
+ extraThingsById[0],
1728
1762
  ),
1729
1763
  metrics != null ? metrics : parentValue[2],
1730
- __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1764
+ __spreadValues(
1765
+ __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1766
+ extraThingsById[1],
1767
+ ),
1731
1768
  indexes != null ? indexes : parentValue[4],
1732
- __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1769
+ __spreadValues(
1770
+ __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1771
+ extraThingsById[2],
1772
+ ),
1733
1773
  relationships != null ? relationships : parentValue[6],
1734
- __spreadValues(__spreadValues({}, parentValue[7]), relationshipsById),
1774
+ __spreadValues(
1775
+ __spreadValues(
1776
+ __spreadValues({}, parentValue[7]),
1777
+ relationshipsById,
1778
+ ),
1779
+ extraThingsById[3],
1780
+ ),
1735
1781
  queries != null ? queries : parentValue[8],
1736
- __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1782
+ __spreadValues(
1783
+ __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1784
+ extraThingsById[4],
1785
+ ),
1737
1786
  checkpoints != null ? checkpoints : parentValue[10],
1738
- __spreadValues(__spreadValues({}, parentValue[11]), checkpointsById),
1739
- addExtraStore,
1740
- delExtraStore,
1787
+ __spreadValues(
1788
+ __spreadValues(
1789
+ __spreadValues({}, parentValue[11]),
1790
+ checkpointsById,
1791
+ ),
1792
+ extraThingsById[5],
1793
+ ),
1794
+ addExtraThingById,
1795
+ delExtraThingById,
1741
1796
  ],
1742
1797
  [
1743
1798
  store,
1744
1799
  storesById,
1745
- extraStoresById,
1800
+ extraThingsById,
1746
1801
  metrics,
1747
1802
  metricsById,
1748
1803
  indexes,
@@ -1754,8 +1809,8 @@ const Provider = ({
1754
1809
  checkpoints,
1755
1810
  checkpointsById,
1756
1811
  parentValue,
1757
- addExtraStore,
1758
- delExtraStore,
1812
+ addExtraThingById,
1813
+ delExtraThingById,
1759
1814
  ],
1760
1815
  ),
1761
1816
  },
@@ -2170,6 +2225,11 @@ export {
2170
2225
  useMetrics,
2171
2226
  useMetricsIds,
2172
2227
  useMetricsOrMetricsById,
2228
+ useProvideCheckpoints,
2229
+ useProvideIndexes,
2230
+ useProvideMetrics,
2231
+ useProvideQueries,
2232
+ useProvideRelationships,
2173
2233
  useProvideStore,
2174
2234
  useQueries,
2175
2235
  useQueriesIds,
@@ -42,6 +42,7 @@ const arrayIsEqual = (array1, array2) =>
42
42
  const arrayMap = (array, cb) => array.map(cb);
43
43
  const arrayIsEmpty = (array) => size(array) == 0;
44
44
  const arrayFilter = (array, cb) => array.filter(cb);
45
+ const arrayWith = (array, index, value) => array.with(index, value);
45
46
 
46
47
  const object = Object;
47
48
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -102,6 +103,16 @@ const useThingOrThingById = (thingOrThingId, offset) => {
102
103
  ? thing
103
104
  : thingOrThingId;
104
105
  };
106
+ const useProvideThing = (thingId, thing, offset) => {
107
+ const {12: addExtraThingById, 13: delExtraThingById} = useContext$1(Context);
108
+ useEffect$1(() => {
109
+ addExtraThingById == null
110
+ ? void 0
111
+ : addExtraThingById(offset, thingId, thing);
112
+ return () =>
113
+ delExtraThingById == null ? void 0 : delExtraThingById(offset, thingId);
114
+ }, [addExtraThingById, thingId, thing, offset, delExtraThingById]);
115
+ };
105
116
  const useThingIds = (offset) => {
106
117
  var _a;
107
118
  return objIds((_a = useContext$1(Context)[offset]) != null ? _a : {});
@@ -109,28 +120,32 @@ const useThingIds = (offset) => {
109
120
  const useStore = (id) => useThing(id, 0);
110
121
  const useStoreOrStoreById = (storeOrStoreId) =>
111
122
  useThingOrThingById(storeOrStoreId, 0);
112
- const useProvideStore = (storeId, store) => {
113
- const {12: addExtraStore, 13: delExtraStore} = useContext$1(Context);
114
- useEffect$1(() => {
115
- addExtraStore == null ? void 0 : addExtraStore(storeId, store);
116
- return () => (delExtraStore == null ? void 0 : delExtraStore(storeId));
117
- }, [addExtraStore, storeId, store, delExtraStore]);
118
- };
123
+ const useProvideStore = (storeId, store) => useProvideThing(storeId, store, 0);
119
124
  const useMetrics = (id) => useThing(id, 2);
120
125
  const useMetricsOrMetricsById = (metricsOrMetricsId) =>
121
126
  useThingOrThingById(metricsOrMetricsId, 2);
127
+ const useProvideMetrics = (metricsId, metrics) =>
128
+ useProvideThing(metricsId, metrics, 1);
122
129
  const useIndexes = (id) => useThing(id, 4);
123
130
  const useIndexesOrIndexesById = (indexesOrIndexesId) =>
124
131
  useThingOrThingById(indexesOrIndexesId, 4);
132
+ const useProvideIndexes = (indexesId, indexes) =>
133
+ useProvideThing(indexesId, indexes, 2);
125
134
  const useRelationships = (id) => useThing(id, 6);
126
135
  const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
127
136
  useThingOrThingById(relationshipsOrRelationshipsId, 6);
137
+ const useProvideRelationships = (relationshipsId, relationships) =>
138
+ useProvideThing(relationshipsId, relationships, 3);
128
139
  const useQueries = (id) => useThing(id, 8);
129
140
  const useQueriesOrQueriesById = (queriesOrQueriesId) =>
130
141
  useThingOrThingById(queriesOrQueriesId, 8);
142
+ const useProvideQueries = (queriesId, queries) =>
143
+ useProvideThing(queriesId, queries, 4);
131
144
  const useCheckpoints = (id) => useThing(id, 10);
132
145
  const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
133
146
  useThingOrThingById(checkpointsOrCheckpointsId, 10);
147
+ const useProvideCheckpoints = (checkpointsId, checkpoints) =>
148
+ useProvideThing(checkpointsId, checkpoints, 5);
134
149
 
135
150
  const lower = (str) => str.toLowerCase();
136
151
  lower(LISTENER);
@@ -1699,20 +1714,39 @@ const Provider = ({
1699
1714
  children,
1700
1715
  }) => {
1701
1716
  const parentValue = useContext(Context);
1702
- const [extraStoresById, setExtraStoresById] = useState({});
1703
- const addExtraStore = useCallback(
1704
- (id, store2) =>
1705
- setExtraStoresById((extraStoresById2) =>
1706
- objGet(extraStoresById2, id) == store2
1707
- ? extraStoresById2
1708
- : __spreadProps(__spreadValues({}, extraStoresById2), {[id]: store2}),
1717
+ const [extraThingsById, setExtraThingsById] = useState([
1718
+ {},
1719
+ {},
1720
+ {},
1721
+ {},
1722
+ {},
1723
+ {},
1724
+ ]);
1725
+ const addExtraThingById = useCallback(
1726
+ (thingOffset, id, thing) =>
1727
+ setExtraThingsById((extraThingsById2) =>
1728
+ objGet(extraThingsById2[thingOffset], id) == thing
1729
+ ? extraThingsById2
1730
+ : arrayWith(
1731
+ extraThingsById2,
1732
+ thingOffset,
1733
+ __spreadProps(__spreadValues({}, extraThingsById2[thingOffset]), {
1734
+ [id]: thing,
1735
+ }),
1736
+ ),
1709
1737
  ),
1710
1738
  [],
1711
1739
  );
1712
- const delExtraStore = useCallback(
1713
- (id) =>
1714
- setExtraStoresById((extraStoresById2) =>
1715
- __spreadValues({}, objDel(extraStoresById2, id)),
1740
+ const delExtraThingById = useCallback(
1741
+ (thingOffset, id) =>
1742
+ setExtraThingsById((extraThingsById2) =>
1743
+ !objHas(extraThingsById2[thingOffset], id)
1744
+ ? extraThingsById2
1745
+ : arrayWith(
1746
+ extraThingsById2,
1747
+ thingOffset,
1748
+ objDel(extraThingsById2[thingOffset], id),
1749
+ ),
1716
1750
  ),
1717
1751
  [],
1718
1752
  );
@@ -1724,25 +1758,46 @@ const Provider = ({
1724
1758
  store != null ? store : parentValue[0],
1725
1759
  __spreadValues(
1726
1760
  __spreadValues(__spreadValues({}, parentValue[1]), storesById),
1727
- extraStoresById,
1761
+ extraThingsById[0],
1728
1762
  ),
1729
1763
  metrics != null ? metrics : parentValue[2],
1730
- __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1764
+ __spreadValues(
1765
+ __spreadValues(__spreadValues({}, parentValue[3]), metricsById),
1766
+ extraThingsById[1],
1767
+ ),
1731
1768
  indexes != null ? indexes : parentValue[4],
1732
- __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1769
+ __spreadValues(
1770
+ __spreadValues(__spreadValues({}, parentValue[5]), indexesById),
1771
+ extraThingsById[2],
1772
+ ),
1733
1773
  relationships != null ? relationships : parentValue[6],
1734
- __spreadValues(__spreadValues({}, parentValue[7]), relationshipsById),
1774
+ __spreadValues(
1775
+ __spreadValues(
1776
+ __spreadValues({}, parentValue[7]),
1777
+ relationshipsById,
1778
+ ),
1779
+ extraThingsById[3],
1780
+ ),
1735
1781
  queries != null ? queries : parentValue[8],
1736
- __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1782
+ __spreadValues(
1783
+ __spreadValues(__spreadValues({}, parentValue[9]), queriesById),
1784
+ extraThingsById[4],
1785
+ ),
1737
1786
  checkpoints != null ? checkpoints : parentValue[10],
1738
- __spreadValues(__spreadValues({}, parentValue[11]), checkpointsById),
1739
- addExtraStore,
1740
- delExtraStore,
1787
+ __spreadValues(
1788
+ __spreadValues(
1789
+ __spreadValues({}, parentValue[11]),
1790
+ checkpointsById,
1791
+ ),
1792
+ extraThingsById[5],
1793
+ ),
1794
+ addExtraThingById,
1795
+ delExtraThingById,
1741
1796
  ],
1742
1797
  [
1743
1798
  store,
1744
1799
  storesById,
1745
- extraStoresById,
1800
+ extraThingsById,
1746
1801
  metrics,
1747
1802
  metricsById,
1748
1803
  indexes,
@@ -1754,8 +1809,8 @@ const Provider = ({
1754
1809
  checkpoints,
1755
1810
  checkpointsById,
1756
1811
  parentValue,
1757
- addExtraStore,
1758
- delExtraStore,
1812
+ addExtraThingById,
1813
+ delExtraThingById,
1759
1814
  ],
1760
1815
  ),
1761
1816
  },
@@ -2170,6 +2225,11 @@ export {
2170
2225
  useMetrics,
2171
2226
  useMetricsIds,
2172
2227
  useMetricsOrMetricsById,
2228
+ useProvideCheckpoints,
2229
+ useProvideIndexes,
2230
+ useProvideMetrics,
2231
+ useProvideQueries,
2232
+ useProvideRelationships,
2173
2233
  useProvideStore,
2174
2234
  useQueries,
2175
2235
  useQueriesIds,
@@ -1 +1 @@
1
- import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",c="Ids",i="Table",a=i+"s",l=i+c,I="Row",p=I+"Count",g=I+c,b="Sorted"+I+c,C="Cell",m=C+c,y="Value",w=y+"s",k=y+c,h=globalThis,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=e=>e.length,x=()=>{},S=(e,t)=>e.every(t),L=(e,t)=>P(e)===P(t)&&S(e,((e,o)=>t[o]===e)),T=(e,t)=>e.map(t),B=Object,E=e=>B.getPrototypeOf(e),M=B.entries,F=e=>!R(e)&&v(E(e),(e=>e==B.prototype||R(E(e))),(()=>!0)),V=B.keys,A=(e,t)=>v(e,(e=>e[t])),O=(e,t)=>(delete e[t],e),j=(e,t)=>{const o=M(e);return P(o)===P(V(t))&&S(o,(([e,o])=>F(o)?!!F(t[e])&&j(t[e],o):t[e]===o))},{createContext:D,useContext:H,useEffect:Q}=e,W=(G=()=>D([]),((e,t)=>t in e)(_=h,z="tinybase_uirc")||(_[z]=G()),_[z]);var _,z,G;const J=(e,t)=>{const o=H(W);return R(e)?o[t]:f(e)?A(o[t+1]??{},e):e},K=(e,t)=>{const o=J(e,t);return R(e)||f(e)?o:e},N=e=>V(H(W)[e]??{}),U=e=>J(e,0),X=e=>K(e,0),Y=(e,t)=>{const{12:o,13:s}=H(W);Q((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},Z=e=>J(e,2),$=e=>K(e,2),ee=e=>J(e,4),te=e=>K(e,4),oe=e=>J(e,6),se=e=>K(e,6),re=e=>J(e,8),de=e=>K(e,8),ne=e=>J(e,10),ue=e=>K(e,10),ce=e=>e.toLowerCase();ce(d);const ie="Transaction";ce(ie);const{useCallback:ae,useEffect:le,useMemo:Ie,useLayoutEffect:pe,useRef:ge,useState:be,useSyncExternalStore:Ce}=e,me=[],ye=[{},[],[me,void 0,me],void 0,!1,0],we=[j,L,([e,t,o],[s,r,d])=>t===r&&L(e,s)&&L(o,d)],ke=(e,t)=>e===t,he=(e,t,o=me)=>{const[,s]=be(),[r,d]=be();return le((()=>{const o=e?t(e):void 0;return d(o),s([]),o?.destroy}),[e,...o]),r},Re=(e,t,...o)=>{const s=e?.["add"+t+d]?.(...o);return()=>e?.delListener(s)},ve=(e,t,s,r=me)=>{const d=ge(ye[s]),n=ae((()=>{const o=t?.[(4==s?"has":"get")+e]?.(...r)??ye[s];return(we[s]??ke)(o,d.current)?d.current:d.current=o}),[t,s,e,...r]),c=ae((d=>Re(t,(4==s?u:o)+e,...r,d)),[t,s,e,...r]);return Ce(c,n)},fe=(e,t,o,s=me,r=me,...d)=>pe((()=>Re(t,e,...r,o,...d)),[t,e,...r,...s,...d]),qe=(e,t,o,s=me,r=x,d=me,...n)=>{const u=X(e);return ae((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...Pe(n,s,e),o),o)))))),[u,t,...s,...d,...xe(n)])},Pe=(e,t,o)=>T(e,(e=>q(e)?e(o,t):e)),xe=e=>{return t=e=>!q(e),e.filter(t);var t},Se=(e,t,o=x,s=me,...r)=>{const d=X(e);return ae((e=>o(d?.["del"+t](...Pe(r,d,e)))),[d,t,...s,...xe(r)])},Le=(e,t,o)=>{const s=ue(e);return ae((()=>s?.[t](o)),[s,t,o])},Te=(e,t=me)=>Ie(e,t),Be=(e,t=me)=>Ie(e,t),Ee=()=>N(1),Me=e=>ve(a,X(e),4,[]),Fe=e=>ve(a,X(e),0),Ve=e=>ve(l,X(e),1),Ae=(e,t)=>ve(i,X(t),4,[e]),Oe=(e,t)=>ve(i,X(t),0,[e]),je=(e,t)=>ve(i+m,X(t),1,[e]),De=(e,t,o)=>ve(i+C,X(o),4,[e,t]),He=(e,t)=>ve(p,X(t),5,[e]),Qe=(e,t)=>ve(g,X(t),1,[e]),We=(e,t,o,s=0,r,d)=>ve(b,X(d),1,[e,t,o,s,r]),_e=(e,t,o)=>ve(I,X(o),4,[e,t]),ze=(e,t,o)=>ve(I,X(o),0,[e,t]),Ge=(e,t,o)=>ve(m,X(o),1,[e,t]),Je=(e,t,o,s)=>ve(C,X(s),4,[e,t,o]),Ke=(e,t,o,s)=>ve(C,X(s),3,[e,t,o]),Ne=e=>ve(w,X(e),4,[]),Ue=e=>ve(w,X(e),0),Xe=e=>ve(k,X(e),1),Ye=(e,t)=>ve(y,X(t),4,[e]),Ze=(e,t)=>ve(y,X(t),3,[e]),$e=(e,t,o,s,r)=>qe(o,a,e,t,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=(e,t,o,s,r,d,n)=>fe(u+C,X(n),s,r,[e,t,o],d),St=(e,t,o,s,r,d,n)=>fe(C,X(n),s,r,[e,t,o],d),Lt=(e,t,o,s)=>fe(u+w,X(s),e,t,[],o),Tt=(e,t,o,s)=>fe(w,X(s),e,t,me,o),Bt=(e,t,o,s)=>fe(k,X(s),e,t,me,o),Et=(e,t,o,s,r)=>fe(u+y,X(r),t,o,[e],s),Mt=(e,t,o,s,r)=>fe(y,X(r),t,o,[e],s),Ft=(e,t,o)=>fe("Start"+ie,X(o),e,t),Vt=(e,t,o)=>fe("WillFinish"+ie,X(o),e,t),At=(e,t,o)=>fe("DidFinish"+ie,X(o),e,t),Ot=(e,t,o)=>he(e,t,o),jt=()=>N(3),Dt=e=>ve("MetricIds",$(e),1),Ht=(e,t)=>ve("Metric",$(t),3,[e]),Qt=(e,t,o,s)=>fe("Metric",$(s),t,o,[e]),Wt=(e,t,o)=>he(e,t,o),_t=()=>N(5),zt=(e,t)=>ve("SliceIds",te(t),1,[e]),Gt=e=>ve("IndexIds",te(e),1),Jt=(e,t,o)=>ve("Slice"+g,te(o),1,[e,t]),Kt=(e,t,o,s)=>fe("SliceIds",te(s),t,o,[e]),Nt=(e,t,o,s,r)=>fe("Slice"+g,te(r),o,s,[e,t]),Ut=(e,t,o)=>he(e,t,o),Xt=()=>N(7),Yt=e=>ve("RelationshipIds",se(e),1),Zt=(e,t,o)=>ve("RemoteRowId",se(o),3,[e,t]),$t=(e,t,o)=>ve("Local"+g,se(o),1,[e,t]),eo=(e,t,o)=>ve("Linked"+g,se(o),1,[e,t]),to=(e,t,o,s,r)=>fe("RemoteRowId",se(r),o,s,[e,t]),oo=(e,t,o,s,r)=>fe("Local"+g,se(r),o,s,[e,t]),so=(e,t,o,s,r)=>fe("Linked"+g,se(r),o,s,[e,t]),ro=(e,t,o)=>he(e,t,o),no=()=>N(9),uo=e=>ve("QueryIds",de(e),1),co=(e,t)=>ve(n+i,de(t),0,[e]),io=(e,t)=>ve(n+i+m,de(t),1,[e]),ao=(e,t)=>ve(n+p,de(t),5,[e]),lo=(e,t)=>ve(n+g,de(t),1,[e]),Io=(e,t,o,s=0,r,d)=>ve(n+b,de(d),1,[e,t,o,s,r]),po=(e,t,o)=>ve(n+I,de(o),0,[e,t]),go=(e,t,o)=>ve(n+m,de(o),1,[e,t]),bo=(e,t,o,s)=>ve(n+C,de(s),3,[e,t,o]),Co=(e,t,o,s)=>fe(n+i,de(s),t,o,[e]),mo=(e,t,o,s)=>fe(n+i+m,de(s),t,o,[e]),yo=(e,t,o,s)=>fe(n+p,de(s),t,o,[e]),wo=(e,t,o,s)=>fe(n+g,de(s),t,o,[e]),ko=(e,t,o,s,r,d,u,c)=>fe(n+b,de(c),d,u,[e,t,o,s,r]),ho=(e,t,o,s,r)=>fe(n+I,de(r),o,s,[e,t]),Ro=(e,t,o,s,r)=>fe(n+m,de(r),o,s,[e,t]),vo=(e,t,o,s,r,d)=>fe(n+C,de(d),s,r,[e,t,o]),fo=(e,t,o)=>he(e,t,o),qo=()=>N(11),Po=e=>ve("CheckpointIds",ue(e),2),xo=(e,t)=>ve("Checkpoint",ue(t),3,[e]),So=(e=x,t=me,o,s=x,r=me)=>{const d=ue(o);return ae((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Lo=e=>Le(e,"goBackward"),To=e=>Le(e,"goForward"),Bo=(e,t=me,o,s=x,r=me)=>{const d=ue(o);return ae((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Eo=e=>{const t=ue(e),[s,r]=Po(t);return[(d=s,!(0==P(d))),Lo(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Mo=e=>{const t=ue(e),[,,[s]]=Po(t);return[!R(s),To(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},Fo=(e,t,o)=>fe("CheckpointIds",ue(o),e,t),Vo=(e,t,o,s)=>fe("Checkpoint",ue(s),t,o,[e]),Ao=(e,t,o=me,s,r=me,d,n=me)=>{const[,u]=be(),[c,i]=be();return le((()=>{(async()=>{const o=e?await t(e):void 0;i(o),o&&s&&(async()=>{await s(o),u([])})()})()}),[e,...o,...r]),le((()=>()=>{c&&(c.destroy(),d?.(c))}),[c,...n]),c},Oo=(e,t,o=me,s,r=me)=>{const[d,n]=be();return le((()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()}),[e,...o]),le((()=>()=>{d&&(d.destroy(),s?.(d))}),[d,...r]),d},{PureComponent:jo,Fragment:Do,createElement:Ho,useCallback:Qo,useLayoutEffect:Wo,useRef:_o,useState:zo}=e,Go=(e,...t)=>R(e)?{}:e(...t),Jo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:Ko,useContext:No,useMemo:Uo,useState:Xo}=e,Yo=({tableId:e,store:t,rowComponent:o=rs,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>os(T(u,(d=>Ho(o,{...Go(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Zo=({queryId:e,queries:t,resultRowComponent:o=ms,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>os(T(n,(r=>Ho(o,{...Go(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),$o=({relationshipId:e,relationships:t,rowComponent:o=rs,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[c,i,a]=Jo(se(t),e),l=n(e,u,c);return os(T(l,(e=>Ho(o,{...Go(s,e),key:e,tableId:a,rowId:e,store:i,debugIds:d}))),r,d,u)},es=e=>({checkpoints:t,checkpointComponent:o=ks,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=ue(t);return os(T(e(Po(n)),(e=>Ho(o,{...Go(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},ts=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:c,queriesById:i,checkpoints:a,checkpointsById:l,children:I})=>{const p=No(W),[g,b]=Xo({}),C=Ko(((e,t)=>b((o=>A(o,e)==t?o:{...o,[e]:t}))),[]),m=Ko((e=>b((t=>({...O(t,e)})))),[]);return Ho(W.Provider,{value:Uo((()=>[e??p[0],{...p[1],...t,...g},o??p[2],{...p[3],...s},r??p[4],{...p[5],...d},n??p[6],{...p[7],...u},c??p[8],{...p[9],...i},a??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,c,i,a,l,p,C,m])},I)},os=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:T(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},ss=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>os(o+(Ke(e,t,s,r)??o),void 0,d,s),rs=({tableId:e,rowId:t,store:o,cellComponent:s=ss,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>os(T(((e,t,o,s)=>{const r=Ge(t,o,s);return e??r})(d,e,t,o),(d=>Ho(s,{...Go(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),ds=e=>Yo(e,Qe(e.tableId,e.store)),ns=({cellId:e,descending:t,offset:o,limit:s,...r})=>Yo(r,We(r.tableId,e,t,o,s,r.store)),us=({store:e,tableComponent:t=ds,getTableComponentProps:o,separator:s,debugIds:r})=>os(T(Ve(e),(s=>Ho(t,{...Go(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),cs=({valueId:e,store:t,debugIds:s})=>os(o+(Ze(e,t)??o),void 0,s,e),is=({store:e,valueComponent:t=cs,getValueComponentProps:o,separator:s,debugIds:r})=>os(T(Xe(e),(s=>Ho(t,{...Go(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),as=({metricId:e,metrics:t,debugIds:s})=>os(Ht(e,t)??o,void 0,s,e),ls=({indexId:e,sliceId:t,indexes:o,rowComponent:s=rs,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,c,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(te(o),e),a=Jt(e,t,u);return os(T(a,(e=>Ho(s,{...Go(r,e),key:e,tableId:i,rowId:e,store:c,debugIds:n}))),d,n,t)},Is=({indexId:e,indexes:t,sliceComponent:o=ls,getSliceComponentProps:s,separator:r,debugIds:d})=>os(T(zt(e,t),(r=>Ho(o,{...Go(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ps=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=rs,getRowComponentProps:r,debugIds:d})=>{const[n,u,,c]=Jo(se(o),e),i=Zt(e,t,n);return os(R(c)||R(i)?null:Ho(s,{...Go(r,i),key:i,tableId:c,rowId:i,store:u,debugIds:d}),void 0,d,t)},gs=e=>$o(e,$t,e.remoteRowId),bs=e=>$o(e,eo,e.firstRowId),Cs=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>os(o+(bo(e,t,s,r)??o),void 0,d,s),ms=({queryId:e,rowId:t,queries:o,resultCellComponent:s=Cs,getResultCellComponentProps:r,separator:d,debugIds:n})=>os(T(go(e,t,o),(d=>Ho(s,{...Go(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),ys=e=>Zo(e,lo(e.queryId,e.queries)),ws=({cellId:e,descending:t,offset:o,limit:s,...r})=>Zo(r,Io(r.queryId,e,t,o,s,r.queries)),ks=({checkpoints:e,checkpointId:t,debugIds:s})=>os(xo(t,e)??o,void 0,s,t),hs=es((e=>e[0])),Rs=es((e=>R(e[1])?[]:[e[1]])),vs=es((e=>e[2]));export{hs as BackwardCheckpointsView,ss as CellView,ks as CheckpointView,Rs as CurrentCheckpointView,vs as ForwardCheckpointsView,Is as IndexView,bs as LinkedRowsView,gs as LocalRowsView,as as MetricView,ts as Provider,ps as RemoteRowView,Cs as ResultCellView,ms as ResultRowView,ws as ResultSortedTableView,ys as ResultTableView,rs as RowView,ls as SliceView,ns as SortedTableView,ds as TableView,us as TablesView,cs as ValueView,is as ValuesView,ot as useAddRowCallback,Ke as useCell,Ge as useCellIds,Pt as useCellIdsListener,St as useCellListener,xo as useCheckpoint,Po as useCheckpointIds,Fo as useCheckpointIdsListener,Vo as useCheckpointListener,ne as useCheckpoints,qo as useCheckpointsIds,ue as useCheckpointsOrCheckpointsById,fo as useCreateCheckpoints,Wt as useCreateIndexes,Be as useCreateMergeableStore,Ot as useCreateMetrics,Ao as useCreatePersister,ro as useCreateQueries,Ut as useCreateRelationships,Te as useCreateStore,Oo as useCreateSynchronizer,lt as useDelCellCallback,at as useDelRowCallback,it as useDelTableCallback,ct as useDelTablesCallback,pt as useDelValueCallback,It as useDelValuesCallback,At as useDidFinishTransactionListener,Lo as useGoBackwardCallback,To as useGoForwardCallback,Bo as useGoToCallback,Je as useHasCell,xt as useHasCellListener,_e as useHasRow,ft as useHasRowListener,Ae as useHasTable,De as useHasTableCell,kt as useHasTableCellListener,mt as useHasTableListener,Me as useHasTables,gt as useHasTablesListener,Ye as useHasValue,Et as useHasValueListener,Ne as useHasValues,Lt as useHasValuesListener,Gt as useIndexIds,ee as useIndexes,_t as useIndexesIds,te as useIndexesOrIndexesById,eo as useLinkedRowIds,so as useLinkedRowIdsListener,$t as useLocalRowIds,oo as useLocalRowIdsListener,Ht as useMetric,Dt as useMetricIds,Qt as useMetricListener,Z as useMetrics,jt as useMetricsIds,$ as useMetricsOrMetricsById,Y as useProvideStore,re as useQueries,no as useQueriesIds,de as useQueriesOrQueriesById,uo as useQueryIds,Mo as useRedoInformation,Yt as useRelationshipIds,oe as useRelationships,Xt as useRelationshipsIds,se as useRelationshipsOrRelationshipsById,Zt as useRemoteRowId,to as useRemoteRowIdListener,bo as useResultCell,go as useResultCellIds,Ro as useResultCellIdsListener,vo as useResultCellListener,po as useResultRow,ao as useResultRowCount,yo as useResultRowCountListener,lo as useResultRowIds,wo as useResultRowIdsListener,ho as useResultRowListener,Io as useResultSortedRowIds,ko as useResultSortedRowIdsListener,co as useResultTable,io as useResultTableCellIds,mo as useResultTableCellIdsListener,Co as useResultTableListener,ze as useRow,He as useRowCount,ht as useRowCountListener,Qe as useRowIds,Rt as useRowIdsListener,qt as useRowListener,rt as useSetCellCallback,So as useSetCheckpointCallback,st as useSetPartialRowCallback,nt as useSetPartialValuesCallback,tt as useSetRowCallback,et as useSetTableCallback,$e as useSetTablesCallback,ut as useSetValueCallback,dt as useSetValuesCallback,zt as useSliceIds,Kt as useSliceIdsListener,Jt as useSliceRowIds,Nt as useSliceRowIdsListener,We as useSortedRowIds,vt as useSortedRowIdsListener,Ft as useStartTransactionListener,U as useStore,Ee as useStoreIds,X as useStoreOrStoreById,Oe as useTable,je as useTableCellIds,wt as useTableCellIdsListener,Ve as useTableIds,Ct as useTableIdsListener,yt as useTableListener,Fe as useTables,bt as useTablesListener,Eo as useUndoInformation,Ze as useValue,Xe as useValueIds,Bt as useValueIdsListener,Mt as useValueListener,Ue as useValues,Tt as useValuesListener,Vt as useWillFinishTransactionListener};
1
+ import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",c="Ids",i="Table",a=i+"s",l=i+c,I="Row",p=I+"Count",g=I+c,b="Sorted"+I+c,C="Cell",m=C+c,y="Value",w=y+"s",k=y+c,h=globalThis,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=e=>e.length,x=()=>{},S=(e,t)=>e.every(t),L=(e,t)=>P(e)===P(t)&&S(e,((e,o)=>t[o]===e)),T=(e,t)=>e.map(t),B=(e,t,o)=>e.with(t,o),E=Object,M=e=>E.getPrototypeOf(e),F=E.entries,V=e=>!R(e)&&v(M(e),(e=>e==E.prototype||R(M(e))),(()=>!0)),A=E.keys,O=(e,t)=>v(e,(e=>e[t])),j=(e,t)=>t in e,D=(e,t)=>{const o=F(e);return P(o)===P(A(t))&&S(o,(([e,o])=>V(o)?!!V(t[e])&&D(t[e],o):t[e]===o))},{createContext:H,useContext:Q,useEffect:W}=e,_=(J=()=>H([]),j(z=h,G="tinybase_uirc")||(z[G]=J()),z[G]);var z,G,J;const K=(e,t)=>{const o=Q(_);return R(e)?o[t]:f(e)?O(o[t+1]??{},e):e},N=(e,t)=>{const o=K(e,t);return R(e)||f(e)?o:e},U=(e,t,o)=>{const{12:s,13:r}=Q(_);W((()=>(s?.(o,e,t),()=>r?.(o,e))),[s,e,t,o,r])},X=e=>A(Q(_)[e]??{}),Y=e=>K(e,0),Z=e=>N(e,0),$=(e,t)=>U(e,t,0),ee=e=>K(e,2),te=e=>N(e,2),oe=(e,t)=>U(e,t,1),se=e=>K(e,4),re=e=>N(e,4),de=(e,t)=>U(e,t,2),ne=e=>K(e,6),ue=e=>N(e,6),ce=(e,t)=>U(e,t,3),ie=e=>K(e,8),ae=e=>N(e,8),le=(e,t)=>U(e,t,4),Ie=e=>K(e,10),pe=e=>N(e,10),ge=(e,t)=>U(e,t,5),be=e=>e.toLowerCase();be(d);const Ce="Transaction";be(Ce);const{useCallback:me,useEffect:ye,useMemo:we,useLayoutEffect:ke,useRef:he,useState:Re,useSyncExternalStore:ve}=e,fe=[],qe=[{},[],[fe,void 0,fe],void 0,!1,0],Pe=[D,L,([e,t,o],[s,r,d])=>t===r&&L(e,s)&&L(o,d)],xe=(e,t)=>e===t,Se=(e,t,o=fe)=>{const[,s]=Re(),[r,d]=Re();return ye((()=>{const o=e?t(e):void 0;return d(o),s([]),o?.destroy}),[e,...o]),r},Le=(e,t,...o)=>{const s=e?.["add"+t+d]?.(...o);return()=>e?.delListener(s)},Te=(e,t,s,r=fe)=>{const d=he(qe[s]),n=me((()=>{const o=t?.[(4==s?"has":"get")+e]?.(...r)??qe[s];return(Pe[s]??xe)(o,d.current)?d.current:d.current=o}),[t,s,e,...r]),c=me((d=>Le(t,(4==s?u:o)+e,...r,d)),[t,s,e,...r]);return ve(c,n)},Be=(e,t,o,s=fe,r=fe,...d)=>ke((()=>Le(t,e,...r,o,...d)),[t,e,...r,...s,...d]),Ee=(e,t,o,s=fe,r=x,d=fe,...n)=>{const u=Z(e);return me((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...Me(n,s,e),o),o)))))),[u,t,...s,...d,...Fe(n)])},Me=(e,t,o)=>T(e,(e=>q(e)?e(o,t):e)),Fe=e=>{return t=e=>!q(e),e.filter(t);var t},Ve=(e,t,o=x,s=fe,...r)=>{const d=Z(e);return me((e=>o(d?.["del"+t](...Me(r,d,e)))),[d,t,...s,...Fe(r)])},Ae=(e,t,o)=>{const s=pe(e);return me((()=>s?.[t](o)),[s,t,o])},Oe=(e,t=fe)=>we(e,t),je=(e,t=fe)=>we(e,t),De=()=>X(1),He=e=>Te(a,Z(e),4,[]),Qe=e=>Te(a,Z(e),0),We=e=>Te(l,Z(e),1),_e=(e,t)=>Te(i,Z(t),4,[e]),ze=(e,t)=>Te(i,Z(t),0,[e]),Ge=(e,t)=>Te(i+m,Z(t),1,[e]),Je=(e,t,o)=>Te(i+C,Z(o),4,[e,t]),Ke=(e,t)=>Te(p,Z(t),5,[e]),Ne=(e,t)=>Te(g,Z(t),1,[e]),Ue=(e,t,o,s=0,r,d)=>Te(b,Z(d),1,[e,t,o,s,r]),Xe=(e,t,o)=>Te(I,Z(o),4,[e,t]),Ye=(e,t,o)=>Te(I,Z(o),0,[e,t]),Ze=(e,t,o)=>Te(m,Z(o),1,[e,t]),$e=(e,t,o,s)=>Te(C,Z(s),4,[e,t,o]),et=(e,t,o,s)=>Te(C,Z(s),3,[e,t,o]),tt=e=>Te(w,Z(e),4,[]),ot=e=>Te(w,Z(e),0),st=e=>Te(k,Z(e),1),rt=(e,t)=>Te(y,Z(t),4,[e]),dt=(e,t)=>Te(y,Z(t),3,[e]),nt=(e,t,o,s,r)=>Ee(o,a,e,t,s,r),ut=(e,t,o,s,r,d)=>Ee(s,i,t,o,r,d,e),ct=(e,t,o,s,r,d,n)=>Ee(r,I,o,s,d,n,e,t),it=(e,t,o=fe,s,r=x,d=fe,n=!0)=>{const u=Z(s);return me((o=>v(u,(s=>v(t(o,s),(t=>r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s),e,t,[],o),Ot=(e,t,o,s)=>Be(w,Z(s),e,t,fe,o),jt=(e,t,o,s)=>Be(k,Z(s),e,t,fe,o),Dt=(e,t,o,s,r)=>Be(u+y,Z(r),t,o,[e],s),Ht=(e,t,o,s,r)=>Be(y,Z(r),t,o,[e],s),Qt=(e,t,o)=>Be("Start"+Ce,Z(o),e,t),Wt=(e,t,o)=>Be("WillFinish"+Ce,Z(o),e,t),_t=(e,t,o)=>Be("DidFinish"+Ce,Z(o),e,t),zt=(e,t,o)=>Se(e,t,o),Gt=()=>X(3),Jt=e=>Te("MetricIds",te(e),1),Kt=(e,t)=>Te("Metric",te(t),3,[e]),Nt=(e,t,o,s)=>Be("Metric",te(s),t,o,[e]),Ut=(e,t,o)=>Se(e,t,o),Xt=()=>X(5),Yt=(e,t)=>Te("SliceIds",re(t),1,[e]),Zt=e=>Te("IndexIds",re(e),1),$t=(e,t,o)=>Te("Slice"+g,re(o),1,[e,t]),eo=(e,t,o,s)=>Be("SliceIds",re(s),t,o,[e]),to=(e,t,o,s,r)=>Be("Slice"+g,re(r),o,s,[e,t]),oo=(e,t,o)=>Se(e,t,o),so=()=>X(7),ro=e=>Te("RelationshipIds",ue(e),1),no=(e,t,o)=>Te("RemoteRowId",ue(o),3,[e,t]),uo=(e,t,o)=>Te("Local"+g,ue(o),1,[e,t]),co=(e,t,o)=>Te("Linked"+g,ue(o),1,[e,t]),io=(e,t,o,s,r)=>Be("RemoteRowId",ue(r),o,s,[e,t]),ao=(e,t,o,s,r)=>Be("Local"+g,ue(r),o,s,[e,t]),lo=(e,t,o,s,r)=>Be("Linked"+g,ue(r),o,s,[e,t]),Io=(e,t,o)=>Se(e,t,o),po=()=>X(9),go=e=>Te("QueryIds",ae(e),1),bo=(e,t)=>Te(n+i,ae(t),0,[e]),Co=(e,t)=>Te(n+i+m,ae(t),1,[e]),mo=(e,t)=>Te(n+p,ae(t),5,[e]),yo=(e,t)=>Te(n+g,ae(t),1,[e]),wo=(e,t,o,s=0,r,d)=>Te(n+b,ae(d),1,[e,t,o,s,r]),ko=(e,t,o)=>Te(n+I,ae(o),0,[e,t]),ho=(e,t,o)=>Te(n+m,ae(o),1,[e,t]),Ro=(e,t,o,s)=>Te(n+C,ae(s),3,[e,t,o]),vo=(e,t,o,s)=>Be(n+i,ae(s),t,o,[e]),fo=(e,t,o,s)=>Be(n+i+m,ae(s),t,o,[e]),qo=(e,t,o,s)=>Be(n+p,ae(s),t,o,[e]),Po=(e,t,o,s)=>Be(n+g,ae(s),t,o,[e]),xo=(e,t,o,s,r,d,u,c)=>Be(n+b,ae(c),d,u,[e,t,o,s,r]),So=(e,t,o,s,r)=>Be(n+I,ae(r),o,s,[e,t]),Lo=(e,t,o,s,r)=>Be(n+m,ae(r),o,s,[e,t]),To=(e,t,o,s,r,d)=>Be(n+C,ae(d),s,r,[e,t,o]),Bo=(e,t,o)=>Se(e,t,o),Eo=()=>X(11),Mo=e=>Te("CheckpointIds",pe(e),2),Fo=(e,t)=>Te("Checkpoint",pe(t),3,[e]),Vo=(e=x,t=fe,o,s=x,r=fe)=>{const d=pe(o);return me((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Ao=e=>Ae(e,"goBackward"),Oo=e=>Ae(e,"goForward"),jo=(e,t=fe,o,s=x,r=fe)=>{const d=pe(o);return me((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Do=e=>{const t=pe(e),[s,r]=Mo(t);return[(d=s,!(0==P(d))),Ao(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Ho=e=>{const t=pe(e),[,,[s]]=Mo(t);return[!R(s),Oo(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},Qo=(e,t,o)=>Be("CheckpointIds",pe(o),e,t),Wo=(e,t,o,s)=>Be("Checkpoint",pe(s),t,o,[e]),_o=(e,t,o=fe,s,r=fe,d,n=fe)=>{const[,u]=Re(),[c,i]=Re();return ye((()=>{(async()=>{const o=e?await t(e):void 0;i(o),o&&s&&(async()=>{await s(o),u([])})()})()}),[e,...o,...r]),ye((()=>()=>{c&&(c.destroy(),d?.(c))}),[c,...n]),c},zo=(e,t,o=fe,s,r=fe)=>{const[d,n]=Re();return ye((()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()}),[e,...o]),ye((()=>()=>{d&&(d.destroy(),s?.(d))}),[d,...r]),d},{PureComponent:Go,Fragment:Jo,createElement:Ko,useCallback:No,useLayoutEffect:Uo,useRef:Xo,useState:Yo}=e,Zo=(e,...t)=>R(e)?{}:e(...t),$o=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:es,useContext:ts,useMemo:os,useState:ss}=e,rs=({tableId:e,store:t,rowComponent:o=ls,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>is(T(u,(d=>Ko(o,{...Zo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),ds=({queryId:e,queries:t,resultRowComponent:o=fs,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>is(T(n,(r=>Ko(o,{...Zo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),ns=({relationshipId:e,relationships:t,rowComponent:o=ls,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[c,i,a]=$o(ue(t),e),l=n(e,u,c);return is(T(l,(e=>Ko(o,{...Zo(s,e),key:e,tableId:a,rowId:e,store:i,debugIds:d}))),r,d,u)},us=e=>({checkpoints:t,checkpointComponent:o=xs,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=pe(t);return is(T(e(Mo(n)),(e=>Ko(o,{...Zo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},cs=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:c,queriesById:i,checkpoints:a,checkpointsById:l,children:I})=>{const p=ts(_),[g,b]=ss([{},{},{},{},{},{}]),C=es(((e,t,o)=>b((s=>O(s[e],t)==o?s:B(s,e,{...s[e],[t]:o})))),[]),m=es(((e,t)=>b((o=>j(o[e],t)?B(o,e,((e,t)=>(delete e[t],e))(o[e],t)):o))),[]);return Ko(_.Provider,{value:os((()=>[e??p[0],{...p[1],...t,...g[0]},o??p[2],{...p[3],...s,...g[1]},r??p[4],{...p[5],...d,...g[2]},n??p[6],{...p[7],...u,...g[3]},c??p[8],{...p[9],...i,...g[4]},a??p[10],{...p[11],...l,...g[5]},C,m]),[e,t,g,o,s,r,d,n,u,c,i,a,l,p,C,m])},I)},is=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:T(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},as=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>is(o+(et(e,t,s,r)??o),void 0,d,s),ls=({tableId:e,rowId:t,store:o,cellComponent:s=as,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>is(T(((e,t,o,s)=>{const r=Ze(t,o,s);return e??r})(d,e,t,o),(d=>Ko(s,{...Zo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Is=e=>rs(e,Ne(e.tableId,e.store)),ps=({cellId:e,descending:t,offset:o,limit:s,...r})=>rs(r,Ue(r.tableId,e,t,o,s,r.store)),gs=({store:e,tableComponent:t=Is,getTableComponentProps:o,separator:s,debugIds:r})=>is(T(We(e),(s=>Ko(t,{...Zo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),bs=({valueId:e,store:t,debugIds:s})=>is(o+(dt(e,t)??o),void 0,s,e),Cs=({store:e,valueComponent:t=bs,getValueComponentProps:o,separator:s,debugIds:r})=>is(T(st(e),(s=>Ko(t,{...Zo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ms=({metricId:e,metrics:t,debugIds:s})=>is(Kt(e,t)??o,void 0,s,e),ys=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ls,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,c,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(re(o),e),a=$t(e,t,u);return is(T(a,(e=>Ko(s,{...Zo(r,e),key:e,tableId:i,rowId:e,store:c,debugIds:n}))),d,n,t)},ws=({indexId:e,indexes:t,sliceComponent:o=ys,getSliceComponentProps:s,separator:r,debugIds:d})=>is(T(Yt(e,t),(r=>Ko(o,{...Zo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ks=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ls,getRowComponentProps:r,debugIds:d})=>{const[n,u,,c]=$o(ue(o),e),i=no(e,t,n);return is(R(c)||R(i)?null:Ko(s,{...Zo(r,i),key:i,tableId:c,rowId:i,store:u,debugIds:d}),void 0,d,t)},hs=e=>ns(e,uo,e.remoteRowId),Rs=e=>ns(e,co,e.firstRowId),vs=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>is(o+(Ro(e,t,s,r)??o),void 0,d,s),fs=({queryId:e,rowId:t,queries:o,resultCellComponent:s=vs,getResultCellComponentProps:r,separator:d,debugIds:n})=>is(T(ho(e,t,o),(d=>Ko(s,{...Zo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),qs=e=>ds(e,yo(e.queryId,e.queries)),Ps=({cellId:e,descending:t,offset:o,limit:s,...r})=>ds(r,wo(r.queryId,e,t,o,s,r.queries)),xs=({checkpoints:e,checkpointId:t,debugIds:s})=>is(Fo(t,e)??o,void 0,s,t),Ss=us((e=>e[0])),Ls=us((e=>R(e[1])?[]:[e[1]])),Ts=us((e=>e[2]));export{Ss as BackwardCheckpointsView,as as CellView,xs as CheckpointView,Ls as CurrentCheckpointView,Ts as ForwardCheckpointsView,ws as IndexView,Rs as LinkedRowsView,hs as LocalRowsView,ms as MetricView,cs as Provider,ks as RemoteRowView,vs as ResultCellView,fs as ResultRowView,Ps as ResultSortedTableView,qs as ResultTableView,ls as RowView,ys as SliceView,ps as SortedTableView,Is as TableView,gs as TablesView,bs as ValueView,Cs as ValuesView,it as useAddRowCallback,et as useCell,Ze as useCellIds,Mt as useCellIdsListener,Vt as useCellListener,Fo as useCheckpoint,Mo as useCheckpointIds,Qo as useCheckpointIdsListener,Wo as useCheckpointListener,Ie as useCheckpoints,Eo as useCheckpointsIds,pe as useCheckpointsOrCheckpointsById,Bo as useCreateCheckpoints,Ut as useCreateIndexes,je as useCreateMergeableStore,zt as useCreateMetrics,_o as useCreatePersister,Io as useCreateQueries,oo as useCreateRelationships,Oe as useCreateStore,zo as useCreateSynchronizer,yt as useDelCellCallback,mt as useDelRowCallback,Ct as useDelTableCallback,bt as useDelTablesCallback,kt as useDelValueCallback,wt as useDelValuesCallback,_t as useDidFinishTransactionListener,Ao as useGoBackwardCallback,Oo as useGoForwardCallback,jo as useGoToCallback,$e as useHasCell,Ft as useHasCellListener,Xe as useHasRow,Bt as useHasRowListener,_e as useHasTable,Je as useHasTableCell,xt as useHasTableCellListener,ft as useHasTableListener,He as useHasTables,ht as useHasTablesListener,rt as useHasValue,Dt as useHasValueListener,tt as useHasValues,At as useHasValuesListener,Zt as useIndexIds,se as useIndexes,Xt as useIndexesIds,re as useIndexesOrIndexesById,co as useLinkedRowIds,lo as useLinkedRowIdsListener,uo as useLocalRowIds,ao as useLocalRowIdsListener,Kt as useMetric,Jt as useMetricIds,Nt as useMetricListener,ee as useMetrics,Gt as useMetricsIds,te as useMetricsOrMetricsById,ge as useProvideCheckpoints,de as useProvideIndexes,oe as useProvideMetrics,le as useProvideQueries,ce as useProvideRelationships,$ as useProvideStore,ie as useQueries,po as useQueriesIds,ae as useQueriesOrQueriesById,go as useQueryIds,Ho as useRedoInformation,ro as useRelationshipIds,ne as useRelationships,so as useRelationshipsIds,ue as useRelationshipsOrRelationshipsById,no as useRemoteRowId,io as useRemoteRowIdListener,Ro as useResultCell,ho as useResultCellIds,Lo as useResultCellIdsListener,To as useResultCellListener,ko as useResultRow,mo as useResultRowCount,qo as useResultRowCountListener,yo as useResultRowIds,Po as useResultRowIdsListener,So as useResultRowListener,wo as useResultSortedRowIds,xo as useResultSortedRowIdsListener,bo as useResultTable,Co as useResultTableCellIds,fo as useResultTableCellIdsListener,vo as useResultTableListener,Ye as useRow,Ke as useRowCount,St as useRowCountListener,Ne as useRowIds,Lt as useRowIdsListener,Et as useRowListener,lt as useSetCellCallback,Vo as useSetCheckpointCallback,at as useSetPartialRowCallback,pt as useSetPartialValuesCallback,ct as useSetRowCallback,ut as useSetTableCallback,nt as useSetTablesCallback,gt as useSetValueCallback,It as useSetValuesCallback,Yt as useSliceIds,eo as useSliceIdsListener,$t as useSliceRowIds,to as useSliceRowIdsListener,Ue as useSortedRowIds,Tt as useSortedRowIdsListener,Qt as useStartTransactionListener,Y as useStore,De as useStoreIds,Z as useStoreOrStoreById,ze as useTable,Ge as useTableCellIds,Pt as useTableCellIdsListener,We as useTableIds,vt as useTableIdsListener,qt as useTableListener,Qe as useTables,Rt as useTablesListener,Do as useUndoInformation,dt as useValue,st as useValueIds,jt as useValueIdsListener,Ht as useValueListener,ot as useValues,Ot as useValuesListener,Wt as useWillFinishTransactionListener};
Binary file
@@ -1 +1 @@
1
- import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",c="Ids",i="Table",a=i+"s",l=i+c,I="Row",p=I+"Count",g=I+c,b="Sorted"+I+c,C="Cell",m=C+c,y="Value",w=y+"s",k=y+c,h=globalThis,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=e=>e.length,x=()=>{},S=(e,t)=>e.every(t),L=(e,t)=>P(e)===P(t)&&S(e,((e,o)=>t[o]===e)),T=(e,t)=>e.map(t),B=Object,E=e=>B.getPrototypeOf(e),M=B.entries,F=e=>!R(e)&&v(E(e),(e=>e==B.prototype||R(E(e))),(()=>!0)),V=B.keys,A=(e,t)=>v(e,(e=>e[t])),O=(e,t)=>(delete e[t],e),j=(e,t)=>{const o=M(e);return P(o)===P(V(t))&&S(o,(([e,o])=>F(o)?!!F(t[e])&&j(t[e],o):t[e]===o))},{createContext:D,useContext:H,useEffect:Q}=e,W=(G=()=>D([]),((e,t)=>t in e)(_=h,z="tinybase_uirc")||(_[z]=G()),_[z]);var _,z,G;const J=(e,t)=>{const o=H(W);return R(e)?o[t]:f(e)?A(o[t+1]??{},e):e},K=(e,t)=>{const o=J(e,t);return R(e)||f(e)?o:e},N=e=>V(H(W)[e]??{}),U=e=>J(e,0),X=e=>K(e,0),Y=(e,t)=>{const{12:o,13:s}=H(W);Q((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},Z=e=>J(e,2),$=e=>K(e,2),ee=e=>J(e,4),te=e=>K(e,4),oe=e=>J(e,6),se=e=>K(e,6),re=e=>J(e,8),de=e=>K(e,8),ne=e=>J(e,10),ue=e=>K(e,10),ce=e=>e.toLowerCase();ce(d);const ie="Transaction";ce(ie);const{useCallback:ae,useEffect:le,useMemo:Ie,useLayoutEffect:pe,useRef:ge,useState:be,useSyncExternalStore:Ce}=e,me=[],ye=[{},[],[me,void 0,me],void 0,!1,0],we=[j,L,([e,t,o],[s,r,d])=>t===r&&L(e,s)&&L(o,d)],ke=(e,t)=>e===t,he=(e,t,o=me)=>{const[,s]=be(),[r,d]=be();return le((()=>{const o=e?t(e):void 0;return d(o),s([]),o?.destroy}),[e,...o]),r},Re=(e,t,...o)=>{const s=e?.["add"+t+d]?.(...o);return()=>e?.delListener(s)},ve=(e,t,s,r=me)=>{const d=ge(ye[s]),n=ae((()=>{const o=t?.[(4==s?"has":"get")+e]?.(...r)??ye[s];return(we[s]??ke)(o,d.current)?d.current:d.current=o}),[t,s,e,...r]),c=ae((d=>Re(t,(4==s?u:o)+e,...r,d)),[t,s,e,...r]);return Ce(c,n)},fe=(e,t,o,s=me,r=me,...d)=>pe((()=>Re(t,e,...r,o,...d)),[t,e,...r,...s,...d]),qe=(e,t,o,s=me,r=x,d=me,...n)=>{const u=X(e);return ae((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...Pe(n,s,e),o),o)))))),[u,t,...s,...d,...xe(n)])},Pe=(e,t,o)=>T(e,(e=>q(e)?e(o,t):e)),xe=e=>{return t=e=>!q(e),e.filter(t);var t},Se=(e,t,o=x,s=me,...r)=>{const d=X(e);return ae((e=>o(d?.["del"+t](...Pe(r,d,e)))),[d,t,...s,...xe(r)])},Le=(e,t,o)=>{const s=ue(e);return ae((()=>s?.[t](o)),[s,t,o])},Te=(e,t=me)=>Ie(e,t),Be=(e,t=me)=>Ie(e,t),Ee=()=>N(1),Me=e=>ve(a,X(e),4,[]),Fe=e=>ve(a,X(e),0),Ve=e=>ve(l,X(e),1),Ae=(e,t)=>ve(i,X(t),4,[e]),Oe=(e,t)=>ve(i,X(t),0,[e]),je=(e,t)=>ve(i+m,X(t),1,[e]),De=(e,t,o)=>ve(i+C,X(o),4,[e,t]),He=(e,t)=>ve(p,X(t),5,[e]),Qe=(e,t)=>ve(g,X(t),1,[e]),We=(e,t,o,s=0,r,d)=>ve(b,X(d),1,[e,t,o,s,r]),_e=(e,t,o)=>ve(I,X(o),4,[e,t]),ze=(e,t,o)=>ve(I,X(o),0,[e,t]),Ge=(e,t,o)=>ve(m,X(o),1,[e,t]),Je=(e,t,o,s)=>ve(C,X(s),4,[e,t,o]),Ke=(e,t,o,s)=>ve(C,X(s),3,[e,t,o]),Ne=e=>ve(w,X(e),4,[]),Ue=e=>ve(w,X(e),0),Xe=e=>ve(k,X(e),1),Ye=(e,t)=>ve(y,X(t),4,[e]),Ze=(e,t)=>ve(y,X(t),3,[e]),$e=(e,t,o,s,r)=>qe(o,a,e,t,s,r),et=(e,t,o,s,r,d)=>qe(s,i,t,o,r,d,e),tt=(e,t,o,s,r,d,n)=>qe(r,I,o,s,d,n,e,t),ot=(e,t,o=me,s,r=x,d=me,n=!0)=>{const u=X(s);return ae((o=>v(u,(s=>v(t(o,s),(t=>r(s.addRow(q(e)?e(o,s):e,t,n),s,t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X(s),e,t,me,o),Et=(e,t,o,s,r)=>fe(u+y,X(r),t,o,[e],s),Mt=(e,t,o,s,r)=>fe(y,X(r),t,o,[e],s),Ft=(e,t,o)=>fe("Start"+ie,X(o),e,t),Vt=(e,t,o)=>fe("WillFinish"+ie,X(o),e,t),At=(e,t,o)=>fe("DidFinish"+ie,X(o),e,t),Ot=(e,t,o)=>he(e,t,o),jt=()=>N(3),Dt=e=>ve("MetricIds",$(e),1),Ht=(e,t)=>ve("Metric",$(t),3,[e]),Qt=(e,t,o,s)=>fe("Metric",$(s),t,o,[e]),Wt=(e,t,o)=>he(e,t,o),_t=()=>N(5),zt=(e,t)=>ve("SliceIds",te(t),1,[e]),Gt=e=>ve("IndexIds",te(e),1),Jt=(e,t,o)=>ve("Slice"+g,te(o),1,[e,t]),Kt=(e,t,o,s)=>fe("SliceIds",te(s),t,o,[e]),Nt=(e,t,o,s,r)=>fe("Slice"+g,te(r),o,s,[e,t]),Ut=(e,t,o)=>he(e,t,o),Xt=()=>N(7),Yt=e=>ve("RelationshipIds",se(e),1),Zt=(e,t,o)=>ve("RemoteRowId",se(o),3,[e,t]),$t=(e,t,o)=>ve("Local"+g,se(o),1,[e,t]),eo=(e,t,o)=>ve("Linked"+g,se(o),1,[e,t]),to=(e,t,o,s,r)=>fe("RemoteRowId",se(r),o,s,[e,t]),oo=(e,t,o,s,r)=>fe("Local"+g,se(r),o,s,[e,t]),so=(e,t,o,s,r)=>fe("Linked"+g,se(r),o,s,[e,t]),ro=(e,t,o)=>he(e,t,o),no=()=>N(9),uo=e=>ve("QueryIds",de(e),1),co=(e,t)=>ve(n+i,de(t),0,[e]),io=(e,t)=>ve(n+i+m,de(t),1,[e]),ao=(e,t)=>ve(n+p,de(t),5,[e]),lo=(e,t)=>ve(n+g,de(t),1,[e]),Io=(e,t,o,s=0,r,d)=>ve(n+b,de(d),1,[e,t,o,s,r]),po=(e,t,o)=>ve(n+I,de(o),0,[e,t]),go=(e,t,o)=>ve(n+m,de(o),1,[e,t]),bo=(e,t,o,s)=>ve(n+C,de(s),3,[e,t,o]),Co=(e,t,o,s)=>fe(n+i,de(s),t,o,[e]),mo=(e,t,o,s)=>fe(n+i+m,de(s),t,o,[e]),yo=(e,t,o,s)=>fe(n+p,de(s),t,o,[e]),wo=(e,t,o,s)=>fe(n+g,de(s),t,o,[e]),ko=(e,t,o,s,r,d,u,c)=>fe(n+b,de(c),d,u,[e,t,o,s,r]),ho=(e,t,o,s,r)=>fe(n+I,de(r),o,s,[e,t]),Ro=(e,t,o,s,r)=>fe(n+m,de(r),o,s,[e,t]),vo=(e,t,o,s,r,d)=>fe(n+C,de(d),s,r,[e,t,o]),fo=(e,t,o)=>he(e,t,o),qo=()=>N(11),Po=e=>ve("CheckpointIds",ue(e),2),xo=(e,t)=>ve("Checkpoint",ue(t),3,[e]),So=(e=x,t=me,o,s=x,r=me)=>{const d=ue(o);return ae((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Lo=e=>Le(e,"goBackward"),To=e=>Le(e,"goForward"),Bo=(e,t=me,o,s=x,r=me)=>{const d=ue(o);return ae((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Eo=e=>{const t=ue(e),[s,r]=Po(t);return[(d=s,!(0==P(d))),Lo(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Mo=e=>{const t=ue(e),[,,[s]]=Po(t);return[!R(s),To(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},Fo=(e,t,o)=>fe("CheckpointIds",ue(o),e,t),Vo=(e,t,o,s)=>fe("Checkpoint",ue(s),t,o,[e]),Ao=(e,t,o=me,s,r=me,d,n=me)=>{const[,u]=be(),[c,i]=be();return le((()=>{(async()=>{const o=e?await t(e):void 0;i(o),o&&s&&(async()=>{await s(o),u([])})()})()}),[e,...o,...r]),le((()=>()=>{c&&(c.destroy(),d?.(c))}),[c,...n]),c},Oo=(e,t,o=me,s,r=me)=>{const[d,n]=be();return le((()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()}),[e,...o]),le((()=>()=>{d&&(d.destroy(),s?.(d))}),[d,...r]),d},{PureComponent:jo,Fragment:Do,createElement:Ho,useCallback:Qo,useLayoutEffect:Wo,useRef:_o,useState:zo}=e,Go=(e,...t)=>R(e)?{}:e(...t),Jo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:Ko,useContext:No,useMemo:Uo,useState:Xo}=e,Yo=({tableId:e,store:t,rowComponent:o=rs,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>os(T(u,(d=>Ho(o,{...Go(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Zo=({queryId:e,queries:t,resultRowComponent:o=ms,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>os(T(n,(r=>Ho(o,{...Go(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),$o=({relationshipId:e,relationships:t,rowComponent:o=rs,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[c,i,a]=Jo(se(t),e),l=n(e,u,c);return os(T(l,(e=>Ho(o,{...Go(s,e),key:e,tableId:a,rowId:e,store:i,debugIds:d}))),r,d,u)},es=e=>({checkpoints:t,checkpointComponent:o=ks,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=ue(t);return os(T(e(Po(n)),(e=>Ho(o,{...Go(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},ts=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:c,queriesById:i,checkpoints:a,checkpointsById:l,children:I})=>{const p=No(W),[g,b]=Xo({}),C=Ko(((e,t)=>b((o=>A(o,e)==t?o:{...o,[e]:t}))),[]),m=Ko((e=>b((t=>({...O(t,e)})))),[]);return Ho(W.Provider,{value:Uo((()=>[e??p[0],{...p[1],...t,...g},o??p[2],{...p[3],...s},r??p[4],{...p[5],...d},n??p[6],{...p[7],...u},c??p[8],{...p[9],...i},a??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,c,i,a,l,p,C,m])},I)},os=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:T(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},ss=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>os(o+(Ke(e,t,s,r)??o),void 0,d,s),rs=({tableId:e,rowId:t,store:o,cellComponent:s=ss,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>os(T(((e,t,o,s)=>{const r=Ge(t,o,s);return e??r})(d,e,t,o),(d=>Ho(s,{...Go(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),ds=e=>Yo(e,Qe(e.tableId,e.store)),ns=({cellId:e,descending:t,offset:o,limit:s,...r})=>Yo(r,We(r.tableId,e,t,o,s,r.store)),us=({store:e,tableComponent:t=ds,getTableComponentProps:o,separator:s,debugIds:r})=>os(T(Ve(e),(s=>Ho(t,{...Go(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),cs=({valueId:e,store:t,debugIds:s})=>os(o+(Ze(e,t)??o),void 0,s,e),is=({store:e,valueComponent:t=cs,getValueComponentProps:o,separator:s,debugIds:r})=>os(T(Xe(e),(s=>Ho(t,{...Go(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),as=({metricId:e,metrics:t,debugIds:s})=>os(Ht(e,t)??o,void 0,s,e),ls=({indexId:e,sliceId:t,indexes:o,rowComponent:s=rs,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,c,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(te(o),e),a=Jt(e,t,u);return os(T(a,(e=>Ho(s,{...Go(r,e),key:e,tableId:i,rowId:e,store:c,debugIds:n}))),d,n,t)},Is=({indexId:e,indexes:t,sliceComponent:o=ls,getSliceComponentProps:s,separator:r,debugIds:d})=>os(T(zt(e,t),(r=>Ho(o,{...Go(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ps=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=rs,getRowComponentProps:r,debugIds:d})=>{const[n,u,,c]=Jo(se(o),e),i=Zt(e,t,n);return os(R(c)||R(i)?null:Ho(s,{...Go(r,i),key:i,tableId:c,rowId:i,store:u,debugIds:d}),void 0,d,t)},gs=e=>$o(e,$t,e.remoteRowId),bs=e=>$o(e,eo,e.firstRowId),Cs=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>os(o+(bo(e,t,s,r)??o),void 0,d,s),ms=({queryId:e,rowId:t,queries:o,resultCellComponent:s=Cs,getResultCellComponentProps:r,separator:d,debugIds:n})=>os(T(go(e,t,o),(d=>Ho(s,{...Go(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),ys=e=>Zo(e,lo(e.queryId,e.queries)),ws=({cellId:e,descending:t,offset:o,limit:s,...r})=>Zo(r,Io(r.queryId,e,t,o,s,r.queries)),ks=({checkpoints:e,checkpointId:t,debugIds:s})=>os(xo(t,e)??o,void 0,s,t),hs=es((e=>e[0])),Rs=es((e=>R(e[1])?[]:[e[1]])),vs=es((e=>e[2]));export{hs as BackwardCheckpointsView,ss as CellView,ks as CheckpointView,Rs as CurrentCheckpointView,vs as ForwardCheckpointsView,Is as IndexView,bs as LinkedRowsView,gs as LocalRowsView,as as MetricView,ts as Provider,ps as RemoteRowView,Cs as ResultCellView,ms as ResultRowView,ws as ResultSortedTableView,ys as ResultTableView,rs as RowView,ls as SliceView,ns as SortedTableView,ds as TableView,us as TablesView,cs as ValueView,is as ValuesView,ot as useAddRowCallback,Ke as useCell,Ge as useCellIds,Pt as useCellIdsListener,St as useCellListener,xo as useCheckpoint,Po as useCheckpointIds,Fo as useCheckpointIdsListener,Vo as useCheckpointListener,ne as useCheckpoints,qo as useCheckpointsIds,ue as useCheckpointsOrCheckpointsById,fo as useCreateCheckpoints,Wt as useCreateIndexes,Be as useCreateMergeableStore,Ot as useCreateMetrics,Ao as useCreatePersister,ro as useCreateQueries,Ut as useCreateRelationships,Te as useCreateStore,Oo as useCreateSynchronizer,lt as useDelCellCallback,at as useDelRowCallback,it as useDelTableCallback,ct as useDelTablesCallback,pt as useDelValueCallback,It as useDelValuesCallback,At as useDidFinishTransactionListener,Lo as useGoBackwardCallback,To as useGoForwardCallback,Bo as useGoToCallback,Je as useHasCell,xt as useHasCellListener,_e as useHasRow,ft as useHasRowListener,Ae as useHasTable,De as useHasTableCell,kt as useHasTableCellListener,mt as useHasTableListener,Me as useHasTables,gt as useHasTablesListener,Ye as useHasValue,Et as useHasValueListener,Ne as useHasValues,Lt as useHasValuesListener,Gt as useIndexIds,ee as useIndexes,_t as useIndexesIds,te as useIndexesOrIndexesById,eo as useLinkedRowIds,so as useLinkedRowIdsListener,$t as useLocalRowIds,oo as useLocalRowIdsListener,Ht as useMetric,Dt as useMetricIds,Qt as useMetricListener,Z as useMetrics,jt as useMetricsIds,$ as useMetricsOrMetricsById,Y as useProvideStore,re as useQueries,no as useQueriesIds,de as useQueriesOrQueriesById,uo as useQueryIds,Mo as useRedoInformation,Yt as useRelationshipIds,oe as useRelationships,Xt as useRelationshipsIds,se as useRelationshipsOrRelationshipsById,Zt as useRemoteRowId,to as useRemoteRowIdListener,bo as useResultCell,go as useResultCellIds,Ro as useResultCellIdsListener,vo as useResultCellListener,po as useResultRow,ao as useResultRowCount,yo as useResultRowCountListener,lo as useResultRowIds,wo as useResultRowIdsListener,ho as useResultRowListener,Io as useResultSortedRowIds,ko as useResultSortedRowIdsListener,co as useResultTable,io as useResultTableCellIds,mo as useResultTableCellIdsListener,Co as useResultTableListener,ze as useRow,He as useRowCount,ht as useRowCountListener,Qe as useRowIds,Rt as useRowIdsListener,qt as useRowListener,rt as useSetCellCallback,So as useSetCheckpointCallback,st as useSetPartialRowCallback,nt as useSetPartialValuesCallback,tt as useSetRowCallback,et as useSetTableCallback,$e as useSetTablesCallback,ut as useSetValueCallback,dt as useSetValuesCallback,zt as useSliceIds,Kt as useSliceIdsListener,Jt as useSliceRowIds,Nt as useSliceRowIdsListener,We as useSortedRowIds,vt as useSortedRowIdsListener,Ft as useStartTransactionListener,U as useStore,Ee as useStoreIds,X as useStoreOrStoreById,Oe as useTable,je as useTableCellIds,wt as useTableCellIdsListener,Ve as useTableIds,Ct as useTableIdsListener,yt as useTableListener,Fe as useTables,bt as useTablesListener,Eo as useUndoInformation,Ze as useValue,Xe as useValueIds,Bt as useValueIdsListener,Mt as useValueListener,Ue as useValues,Tt as useValuesListener,Vt as useWillFinishTransactionListener};
1
+ import e from"react";const t=e=>typeof e,o="",s=t(o),r=t(t),d="Listener",n="Result",u="Has",c="Ids",i="Table",a=i+"s",l=i+c,I="Row",p=I+"Count",g=I+c,b="Sorted"+I+c,C="Cell",m=C+c,y="Value",w=y+"s",k=y+c,h=globalThis,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),f=e=>t(e)==s,q=e=>t(e)==r,P=e=>e.length,x=()=>{},S=(e,t)=>e.every(t),L=(e,t)=>P(e)===P(t)&&S(e,((e,o)=>t[o]===e)),T=(e,t)=>e.map(t),B=(e,t,o)=>e.with(t,o),E=Object,M=e=>E.getPrototypeOf(e),F=E.entries,V=e=>!R(e)&&v(M(e),(e=>e==E.prototype||R(M(e))),(()=>!0)),A=E.keys,O=(e,t)=>v(e,(e=>e[t])),j=(e,t)=>t in e,D=(e,t)=>{const o=F(e);return P(o)===P(A(t))&&S(o,(([e,o])=>V(o)?!!V(t[e])&&D(t[e],o):t[e]===o))},{createContext:H,useContext:Q,useEffect:W}=e,_=(J=()=>H([]),j(z=h,G="tinybase_uirc")||(z[G]=J()),z[G]);var z,G,J;const K=(e,t)=>{const o=Q(_);return R(e)?o[t]:f(e)?O(o[t+1]??{},e):e},N=(e,t)=>{const o=K(e,t);return R(e)||f(e)?o:e},U=(e,t,o)=>{const{12:s,13:r}=Q(_);W((()=>(s?.(o,e,t),()=>r?.(o,e))),[s,e,t,o,r])},X=e=>A(Q(_)[e]??{}),Y=e=>K(e,0),Z=e=>N(e,0),$=(e,t)=>U(e,t,0),ee=e=>K(e,2),te=e=>N(e,2),oe=(e,t)=>U(e,t,1),se=e=>K(e,4),re=e=>N(e,4),de=(e,t)=>U(e,t,2),ne=e=>K(e,6),ue=e=>N(e,6),ce=(e,t)=>U(e,t,3),ie=e=>K(e,8),ae=e=>N(e,8),le=(e,t)=>U(e,t,4),Ie=e=>K(e,10),pe=e=>N(e,10),ge=(e,t)=>U(e,t,5),be=e=>e.toLowerCase();be(d);const Ce="Transaction";be(Ce);const{useCallback:me,useEffect:ye,useMemo:we,useLayoutEffect:ke,useRef:he,useState:Re,useSyncExternalStore:ve}=e,fe=[],qe=[{},[],[fe,void 0,fe],void 0,!1,0],Pe=[D,L,([e,t,o],[s,r,d])=>t===r&&L(e,s)&&L(o,d)],xe=(e,t)=>e===t,Se=(e,t,o=fe)=>{const[,s]=Re(),[r,d]=Re();return ye((()=>{const o=e?t(e):void 0;return d(o),s([]),o?.destroy}),[e,...o]),r},Le=(e,t,...o)=>{const s=e?.["add"+t+d]?.(...o);return()=>e?.delListener(s)},Te=(e,t,s,r=fe)=>{const d=he(qe[s]),n=me((()=>{const o=t?.[(4==s?"has":"get")+e]?.(...r)??qe[s];return(Pe[s]??xe)(o,d.current)?d.current:d.current=o}),[t,s,e,...r]),c=me((d=>Le(t,(4==s?u:o)+e,...r,d)),[t,s,e,...r]);return ve(c,n)},Be=(e,t,o,s=fe,r=fe,...d)=>ke((()=>Le(t,e,...r,o,...d)),[t,e,...r,...s,...d]),Ee=(e,t,o,s=fe,r=x,d=fe,...n)=>{const u=Z(e);return me((e=>v(u,(s=>v(o(e,s),(o=>r(s["set"+t](...Me(n,s,e),o),o)))))),[u,t,...s,...d,...Fe(n)])},Me=(e,t,o)=>T(e,(e=>q(e)?e(o,t):e)),Fe=e=>{return t=e=>!q(e),e.filter(t);var t},Ve=(e,t,o=x,s=fe,...r)=>{const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"+Ce,Z(o),e,t),Wt=(e,t,o)=>Be("WillFinish"+Ce,Z(o),e,t),_t=(e,t,o)=>Be("DidFinish"+Ce,Z(o),e,t),zt=(e,t,o)=>Se(e,t,o),Gt=()=>X(3),Jt=e=>Te("MetricIds",te(e),1),Kt=(e,t)=>Te("Metric",te(t),3,[e]),Nt=(e,t,o,s)=>Be("Metric",te(s),t,o,[e]),Ut=(e,t,o)=>Se(e,t,o),Xt=()=>X(5),Yt=(e,t)=>Te("SliceIds",re(t),1,[e]),Zt=e=>Te("IndexIds",re(e),1),$t=(e,t,o)=>Te("Slice"+g,re(o),1,[e,t]),eo=(e,t,o,s)=>Be("SliceIds",re(s),t,o,[e]),to=(e,t,o,s,r)=>Be("Slice"+g,re(r),o,s,[e,t]),oo=(e,t,o)=>Se(e,t,o),so=()=>X(7),ro=e=>Te("RelationshipIds",ue(e),1),no=(e,t,o)=>Te("RemoteRowId",ue(o),3,[e,t]),uo=(e,t,o)=>Te("Local"+g,ue(o),1,[e,t]),co=(e,t,o)=>Te("Linked"+g,ue(o),1,[e,t]),io=(e,t,o,s,r)=>Be("RemoteRowId",ue(r),o,s,[e,t]),ao=(e,t,o,s,r)=>Be("Local"+g,ue(r),o,s,[e,t]),lo=(e,t,o,s,r)=>Be("Linked"+g,ue(r),o,s,[e,t]),Io=(e,t,o)=>Se(e,t,o),po=()=>X(9),go=e=>Te("QueryIds",ae(e),1),bo=(e,t)=>Te(n+i,ae(t),0,[e]),Co=(e,t)=>Te(n+i+m,ae(t),1,[e]),mo=(e,t)=>Te(n+p,ae(t),5,[e]),yo=(e,t)=>Te(n+g,ae(t),1,[e]),wo=(e,t,o,s=0,r,d)=>Te(n+b,ae(d),1,[e,t,o,s,r]),ko=(e,t,o)=>Te(n+I,ae(o),0,[e,t]),ho=(e,t,o)=>Te(n+m,ae(o),1,[e,t]),Ro=(e,t,o,s)=>Te(n+C,ae(s),3,[e,t,o]),vo=(e,t,o,s)=>Be(n+i,ae(s),t,o,[e]),fo=(e,t,o,s)=>Be(n+i+m,ae(s),t,o,[e]),qo=(e,t,o,s)=>Be(n+p,ae(s),t,o,[e]),Po=(e,t,o,s)=>Be(n+g,ae(s),t,o,[e]),xo=(e,t,o,s,r,d,u,c)=>Be(n+b,ae(c),d,u,[e,t,o,s,r]),So=(e,t,o,s,r)=>Be(n+I,ae(r),o,s,[e,t]),Lo=(e,t,o,s,r)=>Be(n+m,ae(r),o,s,[e,t]),To=(e,t,o,s,r,d)=>Be(n+C,ae(d),s,r,[e,t,o]),Bo=(e,t,o)=>Se(e,t,o),Eo=()=>X(11),Mo=e=>Te("CheckpointIds",pe(e),2),Fo=(e,t)=>Te("Checkpoint",pe(t),3,[e]),Vo=(e=x,t=fe,o,s=x,r=fe)=>{const d=pe(o);return me((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Ao=e=>Ae(e,"goBackward"),Oo=e=>Ae(e,"goForward"),jo=(e,t=fe,o,s=x,r=fe)=>{const d=pe(o);return me((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Do=e=>{const t=pe(e),[s,r]=Mo(t);return[(d=s,!(0==P(d))),Ao(t),r,v(r,(e=>t?.getCheckpoint(e)))??o];var d},Ho=e=>{const t=pe(e),[,,[s]]=Mo(t);return[!R(s),Oo(t),s,v(s,(e=>t?.getCheckpoint(e)))??o]},Qo=(e,t,o)=>Be("CheckpointIds",pe(o),e,t),Wo=(e,t,o,s)=>Be("Checkpoint",pe(s),t,o,[e]),_o=(e,t,o=fe,s,r=fe,d,n=fe)=>{const[,u]=Re(),[c,i]=Re();return ye((()=>{(async()=>{const o=e?await t(e):void 0;i(o),o&&s&&(async()=>{await s(o),u([])})()})()}),[e,...o,...r]),ye((()=>()=>{c&&(c.destroy(),d?.(c))}),[c,...n]),c},zo=(e,t,o=fe,s,r=fe)=>{const[d,n]=Re();return ye((()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()}),[e,...o]),ye((()=>()=>{d&&(d.destroy(),s?.(d))}),[d,...r]),d},{PureComponent:Go,Fragment:Jo,createElement:Ko,useCallback:No,useLayoutEffect:Uo,useRef:Xo,useState:Yo}=e,Zo=(e,...t)=>R(e)?{}:e(...t),$o=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:es,useContext:ts,useMemo:os,useState:ss}=e,rs=({tableId:e,store:t,rowComponent:o=ls,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>is(T(u,(d=>Ko(o,{...Zo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),ds=({queryId:e,queries:t,resultRowComponent:o=fs,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>is(T(n,(r=>Ko(o,{...Zo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),ns=({relationshipId:e,relationships:t,rowComponent:o=ls,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[c,i,a]=$o(ue(t),e),l=n(e,u,c);return is(T(l,(e=>Ko(o,{...Zo(s,e),key:e,tableId:a,rowId:e,store:i,debugIds:d}))),r,d,u)},us=e=>({checkpoints:t,checkpointComponent:o=xs,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=pe(t);return is(T(e(Mo(n)),(e=>Ko(o,{...Zo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},cs=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:c,queriesById:i,checkpoints:a,checkpointsById:l,children:I})=>{const p=ts(_),[g,b]=ss([{},{},{},{},{},{}]),C=es(((e,t,o)=>b((s=>O(s[e],t)==o?s:B(s,e,{...s[e],[t]:o})))),[]),m=es(((e,t)=>b((o=>j(o[e],t)?B(o,e,((e,t)=>(delete e[t],e))(o[e],t)):o))),[]);return Ko(_.Provider,{value:os((()=>[e??p[0],{...p[1],...t,...g[0]},o??p[2],{...p[3],...s,...g[1]},r??p[4],{...p[5],...d,...g[2]},n??p[6],{...p[7],...u,...g[3]},c??p[8],{...p[9],...i,...g[4]},a??p[10],{...p[11],...l,...g[5]},C,m]),[e,t,g,o,s,r,d,n,u,c,i,a,l,p,C,m])},I)},is=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:T(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},as=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>is(o+(et(e,t,s,r)??o),void 0,d,s),ls=({tableId:e,rowId:t,store:o,cellComponent:s=as,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>is(T(((e,t,o,s)=>{const r=Ze(t,o,s);return e??r})(d,e,t,o),(d=>Ko(s,{...Zo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Is=e=>rs(e,Ne(e.tableId,e.store)),ps=({cellId:e,descending:t,offset:o,limit:s,...r})=>rs(r,Ue(r.tableId,e,t,o,s,r.store)),gs=({store:e,tableComponent:t=Is,getTableComponentProps:o,separator:s,debugIds:r})=>is(T(We(e),(s=>Ko(t,{...Zo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),bs=({valueId:e,store:t,debugIds:s})=>is(o+(dt(e,t)??o),void 0,s,e),Cs=({store:e,valueComponent:t=bs,getValueComponentProps:o,separator:s,debugIds:r})=>is(T(st(e),(s=>Ko(t,{...Zo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ms=({metricId:e,metrics:t,debugIds:s})=>is(Kt(e,t)??o,void 0,s,e),ys=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ls,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,c,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(re(o),e),a=$t(e,t,u);return is(T(a,(e=>Ko(s,{...Zo(r,e),key:e,tableId:i,rowId:e,store:c,debugIds:n}))),d,n,t)},ws=({indexId:e,indexes:t,sliceComponent:o=ys,getSliceComponentProps:s,separator:r,debugIds:d})=>is(T(Yt(e,t),(r=>Ko(o,{...Zo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ks=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ls,getRowComponentProps:r,debugIds:d})=>{const[n,u,,c]=$o(ue(o),e),i=no(e,t,n);return is(R(c)||R(i)?null:Ko(s,{...Zo(r,i),key:i,tableId:c,rowId:i,store:u,debugIds:d}),void 0,d,t)},hs=e=>ns(e,uo,e.remoteRowId),Rs=e=>ns(e,co,e.firstRowId),vs=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>is(o+(Ro(e,t,s,r)??o),void 0,d,s),fs=({queryId:e,rowId:t,queries:o,resultCellComponent:s=vs,getResultCellComponentProps:r,separator:d,debugIds:n})=>is(T(ho(e,t,o),(d=>Ko(s,{...Zo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),qs=e=>ds(e,yo(e.queryId,e.queries)),Ps=({cellId:e,descending:t,offset:o,limit:s,...r})=>ds(r,wo(r.queryId,e,t,o,s,r.queries)),xs=({checkpoints:e,checkpointId:t,debugIds:s})=>is(Fo(t,e)??o,void 0,s,t),Ss=us((e=>e[0])),Ls=us((e=>R(e[1])?[]:[e[1]])),Ts=us((e=>e[2]));export{Ss as BackwardCheckpointsView,as as CellView,xs as CheckpointView,Ls as CurrentCheckpointView,Ts as ForwardCheckpointsView,ws as IndexView,Rs as LinkedRowsView,hs as LocalRowsView,ms as MetricView,cs as Provider,ks as RemoteRowView,vs as ResultCellView,fs as ResultRowView,Ps as ResultSortedTableView,qs as ResultTableView,ls as RowView,ys as SliceView,ps as SortedTableView,Is as TableView,gs as TablesView,bs as ValueView,Cs as ValuesView,it as useAddRowCallback,et as useCell,Ze as useCellIds,Mt as useCellIdsListener,Vt as useCellListener,Fo as useCheckpoint,Mo as useCheckpointIds,Qo as useCheckpointIdsListener,Wo as useCheckpointListener,Ie as useCheckpoints,Eo as useCheckpointsIds,pe as useCheckpointsOrCheckpointsById,Bo as useCreateCheckpoints,Ut as useCreateIndexes,je as useCreateMergeableStore,zt as useCreateMetrics,_o as useCreatePersister,Io as useCreateQueries,oo as useCreateRelationships,Oe as useCreateStore,zo as useCreateSynchronizer,yt as useDelCellCallback,mt as useDelRowCallback,Ct as useDelTableCallback,bt as useDelTablesCallback,kt as useDelValueCallback,wt as useDelValuesCallback,_t as useDidFinishTransactionListener,Ao as useGoBackwardCallback,Oo as useGoForwardCallback,jo as useGoToCallback,$e as useHasCell,Ft as useHasCellListener,Xe as useHasRow,Bt as useHasRowListener,_e as useHasTable,Je as useHasTableCell,xt as useHasTableCellListener,ft as useHasTableListener,He as useHasTables,ht as useHasTablesListener,rt as useHasValue,Dt as useHasValueListener,tt as useHasValues,At as useHasValuesListener,Zt as useIndexIds,se as useIndexes,Xt as useIndexesIds,re as useIndexesOrIndexesById,co as useLinkedRowIds,lo as useLinkedRowIdsListener,uo as useLocalRowIds,ao as useLocalRowIdsListener,Kt as useMetric,Jt as useMetricIds,Nt as useMetricListener,ee as useMetrics,Gt as useMetricsIds,te as useMetricsOrMetricsById,ge as useProvideCheckpoints,de as useProvideIndexes,oe as useProvideMetrics,le as useProvideQueries,ce as useProvideRelationships,$ as useProvideStore,ie as useQueries,po as useQueriesIds,ae as useQueriesOrQueriesById,go as useQueryIds,Ho as useRedoInformation,ro as useRelationshipIds,ne as useRelationships,so as useRelationshipsIds,ue as useRelationshipsOrRelationshipsById,no as useRemoteRowId,io as useRemoteRowIdListener,Ro as useResultCell,ho as useResultCellIds,Lo as useResultCellIdsListener,To as useResultCellListener,ko as useResultRow,mo as useResultRowCount,qo as useResultRowCountListener,yo as useResultRowIds,Po as useResultRowIdsListener,So as useResultRowListener,wo as useResultSortedRowIds,xo as useResultSortedRowIdsListener,bo as useResultTable,Co as useResultTableCellIds,fo as useResultTableCellIdsListener,vo as useResultTableListener,Ye as useRow,Ke as useRowCount,St as useRowCountListener,Ne as useRowIds,Lt as useRowIdsListener,Et as useRowListener,lt as useSetCellCallback,Vo as useSetCheckpointCallback,at as useSetPartialRowCallback,pt as useSetPartialValuesCallback,ct as useSetRowCallback,ut as useSetTableCallback,nt as useSetTablesCallback,gt as useSetValueCallback,It as useSetValuesCallback,Yt as useSliceIds,eo as useSliceIdsListener,$t as useSliceRowIds,to as useSliceRowIdsListener,Ue as useSortedRowIds,Tt as useSortedRowIdsListener,Qt as useStartTransactionListener,Y as useStore,De as useStoreIds,Z as useStoreOrStoreById,ze as useTable,Ge as useTableCellIds,Pt as useTableCellIdsListener,We as useTableIds,vt as useTableIdsListener,qt as useTableListener,Qe as useTables,Rt as useTablesListener,Do as useUndoInformation,dt as useValue,st as useValueIds,jt as useValueIdsListener,Ht as useValueListener,ot as useValues,Ot as useValuesListener,Wt as useWillFinishTransactionListener};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "5.2.2",
3
+ "version": "5.3.0-beta.1",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",