tinybase 4.5.0-beta.0 → 4.5.0

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 (69) hide show
  1. package/lib/cjs/persisters/persister-expo-sqlite-next.cjs +1 -0
  2. package/lib/cjs/persisters/persister-expo-sqlite-next.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
  4. package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
  5. package/lib/cjs/ui-react.cjs +1 -1
  6. package/lib/cjs/ui-react.cjs.gz +0 -0
  7. package/lib/cjs-es6/persisters/persister-expo-sqlite-next.cjs +1 -0
  8. package/lib/cjs-es6/persisters/persister-expo-sqlite-next.cjs.gz +0 -0
  9. package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
  10. package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
  11. package/lib/cjs-es6/ui-react.cjs +1 -1
  12. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  13. package/lib/debug/checkpoints.js +8 -8
  14. package/lib/debug/indexes.js +8 -8
  15. package/lib/debug/metrics.js +8 -8
  16. package/lib/debug/persisters/persister-automerge.js +23 -23
  17. package/lib/debug/persisters/persister-expo-sqlite-next.js +835 -0
  18. package/lib/debug/persisters/persister-partykit-server.js +35 -21
  19. package/lib/debug/persisters/persister-yjs.js +23 -23
  20. package/lib/debug/queries.js +10 -10
  21. package/lib/debug/relationships.js +6 -6
  22. package/lib/debug/store.js +10 -10
  23. package/lib/debug/tinybase.js +24 -24
  24. package/lib/debug/tools.js +2 -2
  25. package/lib/debug/ui-react-dom.js +12 -12
  26. package/lib/debug/ui-react.js +56 -22
  27. package/lib/es6/persisters/persister-expo-sqlite-next.js +1 -0
  28. package/lib/es6/persisters/persister-expo-sqlite-next.js.gz +0 -0
  29. package/lib/es6/persisters/persister-partykit-server.js +1 -1
  30. package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
  31. package/lib/es6/ui-react.js +1 -1
  32. package/lib/es6/ui-react.js.gz +0 -0
  33. package/lib/persisters/persister-expo-sqlite-next.js +1 -0
  34. package/lib/persisters/persister-expo-sqlite-next.js.gz +0 -0
  35. package/lib/persisters/persister-partykit-server.js +1 -1
  36. package/lib/persisters/persister-partykit-server.js.gz +0 -0
  37. package/lib/types/metrics.d.ts +2 -2
  38. package/lib/types/persisters/persister-expo-sqlite-next.d.ts +168 -0
  39. package/lib/types/persisters/persister-expo-sqlite.d.ts +8 -0
  40. package/lib/types/persisters/persister-partykit-server.d.ts +58 -2
  41. package/lib/types/persisters/persister-remote.d.ts +6 -1
  42. package/lib/types/persisters.d.ts +1 -0
  43. package/lib/types/queries.d.ts +2 -45
  44. package/lib/types/ui-react.d.ts +53 -0
  45. package/lib/types/with-schemas/metrics.d.ts +2 -2
  46. package/lib/types/with-schemas/persisters/persister-expo-sqlite-next.d.ts +181 -0
  47. package/lib/types/with-schemas/persisters/persister-expo-sqlite.d.ts +8 -0
  48. package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +61 -0
  49. package/lib/types/with-schemas/persisters/persister-remote.d.ts +6 -1
  50. package/lib/types/with-schemas/persisters.d.ts +1 -0
  51. package/lib/types/with-schemas/queries.d.ts +2 -45
  52. package/lib/types/with-schemas/store.d.ts +8 -8
  53. package/lib/types/with-schemas/ui-react.d.ts +59 -0
  54. package/lib/ui-react.js +1 -1
  55. package/lib/ui-react.js.gz +0 -0
  56. package/lib/umd/persisters/persister-expo-sqlite-next.js +1 -0
  57. package/lib/umd/persisters/persister-expo-sqlite-next.js.gz +0 -0
  58. package/lib/umd/persisters/persister-partykit-server.js +1 -1
  59. package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
  60. package/lib/umd/ui-react.js +1 -1
  61. package/lib/umd/ui-react.js.gz +0 -0
  62. package/lib/umd-es6/persisters/persister-expo-sqlite-next.js +1 -0
  63. package/lib/umd-es6/persisters/persister-expo-sqlite-next.js.gz +0 -0
  64. package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
  65. package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
  66. package/lib/umd-es6/ui-react.js +1 -1
  67. package/lib/umd-es6/ui-react.js.gz +0 -0
  68. package/package.json +22 -23
  69. package/readme.md +13 -13
@@ -531,6 +531,65 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
531
531
  storeOrStoreId?: StoreOrStoreId<Schemas>,
532
532
  ) => Store<Schemas> | undefined;
533
533
 
534
+ /**
535
+ * The useProvideStore hook is used to add a Store object by Id to a Provider
536
+ * component, but imperatively from a component within it.
537
+ *
538
+ * This has schema-based typing. The following is a simplified representation:
539
+ *
540
+ * ```ts override
541
+ * useProvideStore(storeId: Id, store: Store): void;
542
+ * ```
543
+ *
544
+ * Normally you will register a Store by Id in a context by using the
545
+ * `storesById` prop of the top-level Provider component. This hook, however,
546
+ * lets you dynamically add a new Store to the context, from within a descendent
547
+ * component. This is useful for applications where the set of Stores is not
548
+ * known at the time of the first render of the root Provider.
549
+ *
550
+ * A Store added to the Provider context in this way will be available to other
551
+ * components within the context (using the useStore hook and so on). If you use
552
+ * the same Id as an existing Store registration, the new one will take priority
553
+ * over one provided by the `storesById` prop.
554
+ *
555
+ * Note that other components that consume a Store registered like this should
556
+ * defend against it being undefined at first. On the first render, the other
557
+ * component will likely not yet have completed the registration. In the example
558
+ * below, we use the null-safe `useStore('petStore')?.getTableIds()` to do this.
559
+ * @param storeId The Id of the Store object to be registered with the Provider.
560
+ * @param store The Store object to be registered.
561
+ * @example
562
+ * This example creates a Provider context. A child component registers a Store
563
+ * into it which is then consumable by a peer child component.
564
+ * ```jsx
565
+ * const App = () => (
566
+ * <Provider>
567
+ * <RegisterStore />
568
+ * <ConsumeStore />
569
+ * </Provider>
570
+ * );
571
+ * const RegisterStore = () => {
572
+ * const store = useCreateStore(() =>
573
+ * createStore().setCell('pets', 'fido', 'color', 'brown'),
574
+ * );
575
+ * useProvideStore('petStore', store);
576
+ * return null;
577
+ * };
578
+ * const ConsumeStore = () => (
579
+ * <span>{JSON.stringify(useStore('petStore')?.getTableIds())}</span>
580
+ * );
581
+ *
582
+ * const app = document.createElement('div');
583
+ * const root = ReactDOMClient.createRoot(app);
584
+ * root.render(<App />); // !act
585
+ * console.log(app.innerHTML);
586
+ * // -> '<span>["pets"]</span>'
587
+ * ```
588
+ * @category Store hooks
589
+ * @since v4.4.2
590
+ */
591
+ useProvideStore: (storeId: Id, store: Store<Schemas>) => void;
592
+
534
593
  /**
535
594
  * The useHasTables hook returns a boolean indicating whether any Table objects
536
595
  * exist in the Store, and registers a listener so that any changes to that
package/lib/ui-react.js CHANGED
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Listener",n="Result",u="Has",I="has",i="Ids",c="Table",l=c+"s",a=c+i,p="Row",g=p+"Count",b=p+i,C="Sorted"+p+i,m="Cell",y=m+i,k="Value",w=k+"s",h=k+i,R=e=>null==e,v=(e,t,o)=>R(e)?o?.():t(e),q=e=>o(e)==r,f=()=>{},P=(e,t)=>e.map(t),x=Object.keys,{createContext:S,useContext:L}=e,B=S([]),T=(e,t)=>{const o=L(B);return R(e)?o[t]:q(e)?((e,t)=>v(e,(e=>e[t])))(o[t+1]??{},e):e},M=(e,t)=>{const o=T(e,t);return R(e)||q(e)?o:e},E=e=>x(L(B)[e]??{}),F=e=>T(e,0),V=e=>M(e,0),A=e=>T(e,2),j=e=>M(e,2),D=e=>T(e,4),H=e=>M(e,4),O=e=>T(e,6),Q=e=>M(e,6),W=e=>T(e,8),z=e=>M(e,8),G=e=>T(e,10),J=e=>M(e,10),K=e=>e.toLowerCase();K(d);const N="Transaction";K(N);const{useCallback:U,useEffect:X,useMemo:Y,useLayoutEffect:Z,useRef:$,useState:_}=e,ee=[],te={},oe=[[],void 0,[]],se=(e,t,o=ee)=>{const s=Y((()=>t(e)),[e,...o]);return X((()=>()=>s.destroy()),[s]),s},re=(e,t,o,s=ee,r,d="get",n="")=>{const[,u]=_(),I=U((()=>t?.[d+e]?.(...s)??o),[t,e,...s,o]),i=$();return Y((()=>i.current=I()),[I]),de(n+e,t,((...e)=>{i.current=R(r)?I():e[r],u([])}),[I,r],s),i.current},de=(e,t,o,s=ee,r=ee,...n)=>Z((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,e,...r,...s,...n]),ne=(e,t,o,s=ee,r=f,d=ee,...n)=>{const u=V(e);return U((e=>v(u,(s=>v(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[u,t,...s,...d,...n])},ue=(e,t,o=f,s=ee,...r)=>{const d=V(e);return U((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},Ie=(e,t,o)=>{const s=J(e);return U((()=>s?.[t](o)),[s,t,o])},ie=(e,t=ee)=>Y(e,t),ce=()=>E(1),le=e=>re(l,V(e),!1,[],1,I,u),ae=e=>re(l,V(e),te),pe=e=>re(a,V(e),ee),ge=(e,t)=>re(c,V(t),!1,[e],2,I,u),be=(e,t)=>re(c,V(t),te,[e]),Ce=(e,t)=>re(c+y,V(t),ee,[e]),me=(e,t,o)=>re(c+m,V(o),!1,[e,t],3,I,u),ye=(e,t)=>re(g,V(t),0,[e]),ke=(e,t)=>re(b,V(t),ee,[e]),we=(e,t,o,s=0,r,d)=>re(C,V(d),ee,[e,t,o,s,r],6),he=(e,t,o)=>re(p,V(o),!1,[e,t],3,I,u),Re=(e,t,o)=>re(p,V(o),te,[e,t]),ve=(e,t,o)=>re(y,V(o),ee,[e,t]),qe=(e,t,o,s)=>re(m,V(s),!1,[e,t,o],4,I,u),fe=(e,t,o,s)=>re(m,V(s),void 0,[e,t,o],4),Pe=e=>re(w,V(e),!1,[],1,I,u),xe=e=>re(w,V(e),te),Se=e=>re(h,V(e),ee),Le=(e,t)=>re(k,V(t),!1,[e],2,I,u),Be=(e,t)=>re(k,V(t),void 0,[e]),Te=(e,t,o,s,r)=>ne(o,l,e,t,s,r),Me=(e,t,o,s,r,d)=>ne(s,c,t,o,r,d,e),Ee=(e,t,o,s,r,d,n)=>ne(r,p,o,s,d,n,e,t),Fe=(e,t,o=ee,s,r=f,d=ee,n=!0)=>{const u=V(s);return U((o=>v(u,(s=>v(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[u,e,...o,...d,n])},Ve=(e,t,o,s,r,d,n)=>ne(r,"PartialRow",o,s,d,n,e,t),Ae=(e,t,o,s,r,d,n,u)=>ne(d,m,s,r,n,u,e,t,o),je=(e,t,o,s,r)=>ne(o,w,e,t,s,r),De=(e,t,o,s,r)=>ne(o,"PartialValues",e,t,s,r),He=(e,t,o,s,r,d)=>ne(s,k,t,o,r,d,e),Oe=(e,t,o)=>ue(e,l,t,o),Qe=(e,t,o,s)=>ue(t,c,o,s,e),We=(e,t,o,s,r)=>ue(o,p,s,r,e,t),ze=(e,t,o,s,r,d,n)=>ue(r,m,d,n,e,t,o,s),Ge=(e,t,o)=>ue(e,w,t,o),Je=(e,t,o,s)=>ue(t,k,o,s,e),Ke=(e,t,o,s)=>de(u+l,V(s),e,t,[],o),Ne=(e,t,o,s)=>de(l,V(s),e,t,ee,o),Ue=(e,t,o,s)=>de(a,V(s),e,t,ee,o),Xe=(e,t,o,s,r)=>de(u+c,V(r),t,o,[e],s),Ye=(e,t,o,s,r)=>de(c,V(r),t,o,[e],s),Ze=(e,t,o,s,r)=>de(c+y,V(r),t,o,[e],s),$e=(e,t,o,s,r,d)=>de(u+c+m,V(d),o,s,[e,t],r),_e=(e,t,o,s,r)=>de(g,V(r),t,o,[e],s),et=(e,t,o,s,r)=>de(b,V(r),t,o,[e],s),tt=(e,t,o,s,r,d,n,u,I)=>de(C,V(I),d,n,[e,t,o,s,r],u),ot=(e,t,o,s,r,d)=>de(u+p,V(d),o,s,[e,t],r),st=(e,t,o,s,r,d)=>de(p,V(d),o,s,[e,t],r),rt=(e,t,o,s,r,d)=>de(y,V(d),o,s,[e,t],r),dt=(e,t,o,s,r,d,n)=>de(u+m,V(n),s,r,[e,t,o],d),nt=(e,t,o,s,r,d,n)=>de(m,V(n),s,r,[e,t,o],d),ut=(e,t,o,s)=>de(u+w,V(s),e,t,[],o),It=(e,t,o,s)=>de(w,V(s),e,t,ee,o),it=(e,t,o,s)=>de(h,V(s),e,t,ee,o),ct=(e,t,o,s,r)=>de(u+k,V(r),t,o,[e],s),lt=(e,t,o,s,r)=>de(k,V(r),t,o,[e],s),at=(e,t,o)=>de("Start"+N,V(o),e,t),pt=(e,t,o)=>de("WillFinish"+N,V(o),e,t),gt=(e,t,o)=>de("DidFinish"+N,V(o),e,t),bt=(e,t,o)=>se(e,t,o),Ct=()=>E(3),mt=e=>re("MetricIds",j(e),ee),yt=(e,t)=>re("Metric",j(t),void 0,[e]),kt=(e,t,o,s)=>de("Metric",j(s),t,o,[e]),wt=(e,t,o)=>se(e,t,o),ht=()=>E(5),Rt=(e,t)=>re("SliceIds",H(t),ee,[e]),vt=e=>re("IndexIds",H(e),ee),qt=(e,t,o)=>re("Slice"+b,H(o),ee,[e,t]),ft=(e,t,o,s)=>de("SliceIds",H(s),t,o,[e]),Pt=(e,t,o,s,r)=>de("Slice"+b,H(r),o,s,[e,t]),xt=(e,t,o)=>se(e,t,o),St=()=>E(7),Lt=e=>re("RelationshipIds",Q(e),ee),Bt=(e,t,o)=>re("RemoteRowId",Q(o),void 0,[e,t]),Tt=(e,t,o)=>re("Local"+b,Q(o),ee,[e,t]),Mt=(e,t,o)=>re("Linked"+b,Q(o),ee,[e,t]),Et=(e,t,o,s,r)=>de("RemoteRowId",Q(r),o,s,[e,t]),Ft=(e,t,o,s,r)=>de("Local"+b,Q(r),o,s,[e,t]),Vt=(e,t,o,s,r)=>de("Linked"+b,Q(r),o,s,[e,t]),At=(e,t,o)=>se(e,t,o),jt=()=>E(9),Dt=e=>re("QueryIds",z(e),ee),Ht=(e,t)=>re(n+c,z(t),te,[e]),Ot=(e,t)=>re(n+c+y,z(t),ee,[e]),Qt=(e,t)=>re(n+g,z(t),0,[e]),Wt=(e,t)=>re(n+b,z(t),ee,[e]),zt=(e,t,o,s=0,r,d)=>re(n+C,z(d),ee,[e,t,o,s,r],6),Gt=(e,t,o)=>re(n+p,z(o),te,[e,t]),Jt=(e,t,o)=>re(n+y,z(o),ee,[e,t]),Kt=(e,t,o,s)=>re(n+m,z(s),void 0,[e,t,o]),Nt=(e,t,o,s)=>de(n+c,z(s),t,o,[e]),Ut=(e,t,o,s)=>de(n+c+y,z(s),t,o,[e]),Xt=(e,t,o,s)=>de(n+g,z(s),t,o,[e]),Yt=(e,t,o,s)=>de(n+b,z(s),t,o,[e]),Zt=(e,t,o,s,r,d,u,I)=>de(n+C,z(I),d,u,[e,t,o,s,r]),$t=(e,t,o,s,r)=>de(n+p,z(r),o,s,[e,t]),_t=(e,t,o,s,r)=>de(n+y,z(r),o,s,[e,t]),eo=(e,t,o,s,r,d)=>de(n+m,z(d),s,r,[e,t,o]),to=(e,t,o)=>se(e,t,o),oo=()=>E(11),so=e=>re("CheckpointIds",J(e),oe),ro=(e,t)=>re("Checkpoint",J(t),void 0,[e]),no=(e=f,t=ee,o,s=f,r=ee)=>{const d=J(o);return U((t=>v(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},uo=e=>Ie(e,"goBackward"),Io=e=>Ie(e,"goForward"),io=(e,t=ee,o,s=f,r=ee)=>{const d=J(o);return U((t=>v(d,(o=>v(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},co=e=>{const t=J(e),[o,r]=so(t);return[(d=o,!(0==d.length)),uo(t),r,v(r,(e=>t?.getCheckpoint(e)))??s];var d},lo=e=>{const t=J(e),[,,[o]]=so(t);return[!R(o),Io(t),o,v(o,(e=>t?.getCheckpoint(e)))??s]},ao=(e,t,o)=>de("CheckpointIds",J(o),e,t),po=(e,t,o,s)=>de("Checkpoint",J(s),t,o,[e]),go=(e,t,o=ee,s,r=ee,d,n=ee)=>{const[,u]=_(),I=Y((()=>t(e)),[e,...o]);return X((()=>((async()=>{s&&(await s(I),u([]))})(),()=>{I?.destroy(),d?.(I)})),[I,...r,...n]),I},{PureComponent:bo,Fragment:Co,createElement:mo,useCallback:yo,useLayoutEffect:ko,useRef:wo,useState:ho}=e,Ro=(e,...t)=>R(e)?{}:e(...t),vo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:qo}=e,fo=({tableId:e,store:t,rowComponent:o=Mo,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>Bo(P(u,(d=>mo(o,{...Ro(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Po=({queryId:e,queries:t,resultRowComponent:o=Jo,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>Bo(P(n,(r=>mo(o,{...Ro(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),xo=({relationshipId:e,relationships:t,rowComponent:o=Mo,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[I,i,c]=vo(Q(t),e),l=n(e,u,I);return Bo(P(l,(e=>mo(o,{...Ro(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:d}))),r,d,u)},So=e=>({checkpoints:t,checkpointComponent:o=Uo,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=J(t);return Bo(P(e(so(n)),(e=>mo(o,{...Ro(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},Lo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:u,relationshipsById:I,queries:i,queriesById:c,checkpoints:l,checkpointsById:a,children:p})=>{const g=t(B);return mo(B.Provider,{value:qo((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},u??g[6],{...g[7],...I},i??g[8],{...g[9],...c},l??g[10],{...g[11],...a}]),[e,o,s,r,d,n,u,I,i,c,l,a,g])},p)},Bo=(e,t,o,s)=>{const r=R(t)||!Array.isArray(e)?e:P(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},To=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>Bo(s+(fe(e,t,o,r)??s),void 0,d,o),Mo=({tableId:e,rowId:t,store:o,cellComponent:s=To,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>Bo(P(((e,t,o,s)=>{const r=ve(t,o,s);return e??r})(d,e,t,o),(d=>mo(s,{...Ro(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Eo=e=>fo(e,ke(e.tableId,e.store)),Fo=({cellId:e,descending:t,offset:o,limit:s,...r})=>fo(r,we(r.tableId,e,t,o,s,r.store)),Vo=({store:e,tableComponent:t=Eo,getTableComponentProps:o,separator:s,debugIds:r})=>Bo(P(pe(e),(s=>mo(t,{...Ro(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Ao=({valueId:e,store:t,debugIds:o})=>Bo(s+(Be(e,t)??s),void 0,o,e),jo=({store:e,valueComponent:t=Ao,getValueComponentProps:o,separator:s,debugIds:r})=>Bo(P(Se(e),(s=>mo(t,{...Ro(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),Do=({metricId:e,metrics:t,debugIds:o})=>Bo(yt(e,t)??s,void 0,o,e),Ho=({indexId:e,sliceId:t,indexes:o,rowComponent:s=Mo,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,I,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(H(o),e),c=qt(e,t,u);return Bo(P(c,(e=>mo(s,{...Ro(r,e),key:e,tableId:i,rowId:e,store:I,debugIds:n}))),d,n,t)},Oo=({indexId:e,indexes:t,sliceComponent:o=Ho,getSliceComponentProps:s,separator:r,debugIds:d})=>Bo(P(Rt(e,t),(r=>mo(o,{...Ro(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),Qo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=Mo,getRowComponentProps:r,debugIds:d})=>{const[n,u,,I]=vo(Q(o),e),i=Bt(e,t,n);return Bo(R(I)||R(i)?null:mo(s,{...Ro(r,i),key:i,tableId:I,rowId:i,store:u,debugIds:d}),void 0,d,t)},Wo=e=>xo(e,Tt,e.remoteRowId),zo=e=>xo(e,Mt,e.firstRowId),Go=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>Bo(s+(Kt(e,t,o,r)??s),void 0,d,o),Jo=({queryId:e,rowId:t,queries:o,resultCellComponent:s=Go,getResultCellComponentProps:r,separator:d,debugIds:n})=>Bo(P(Jt(e,t,o),(d=>mo(s,{...Ro(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),Ko=e=>Po(e,Wt(e.queryId,e.queries)),No=({cellId:e,descending:t,offset:o,limit:s,...r})=>Po(r,zt(r.queryId,e,t,o,s,r.queries)),Uo=({checkpoints:e,checkpointId:t,debugIds:o})=>Bo(ro(t,e)??s,void 0,o,t),Xo=So((e=>e[0])),Yo=So((e=>R(e[1])?[]:[e[1]])),Zo=So((e=>e[2]));export{Xo as BackwardCheckpointsView,To as CellView,Uo as CheckpointView,Yo as CurrentCheckpointView,Zo as ForwardCheckpointsView,Oo as IndexView,zo as LinkedRowsView,Wo as LocalRowsView,Do as MetricView,Lo as Provider,Qo as RemoteRowView,Go as ResultCellView,Jo as ResultRowView,No as ResultSortedTableView,Ko as ResultTableView,Mo as RowView,Ho as SliceView,Fo as SortedTableView,Eo as TableView,Vo as TablesView,Ao as ValueView,jo as ValuesView,Fe as useAddRowCallback,fe as useCell,ve as useCellIds,rt as useCellIdsListener,nt as useCellListener,ro as useCheckpoint,so as useCheckpointIds,ao as useCheckpointIdsListener,po as useCheckpointListener,G as useCheckpoints,oo as useCheckpointsIds,J as useCheckpointsOrCheckpointsById,to as useCreateCheckpoints,wt as useCreateIndexes,bt as useCreateMetrics,go as useCreatePersister,At as useCreateQueries,xt as useCreateRelationships,ie as useCreateStore,ze as useDelCellCallback,We as useDelRowCallback,Qe as useDelTableCallback,Oe as useDelTablesCallback,Je as useDelValueCallback,Ge as useDelValuesCallback,gt as useDidFinishTransactionListener,uo as useGoBackwardCallback,Io as useGoForwardCallback,io as useGoToCallback,qe as useHasCell,dt as useHasCellListener,he as useHasRow,ot as useHasRowListener,ge as useHasTable,me as useHasTableCell,$e as useHasTableCellListener,Xe as useHasTableListener,le as useHasTables,Ke as useHasTablesListener,Le as useHasValue,ct as useHasValueListener,Pe as useHasValues,ut as useHasValuesListener,vt as useIndexIds,D as useIndexes,ht as useIndexesIds,H as useIndexesOrIndexesById,Mt as useLinkedRowIds,Vt as useLinkedRowIdsListener,Tt as useLocalRowIds,Ft as useLocalRowIdsListener,yt as useMetric,mt as useMetricIds,kt as useMetricListener,A as useMetrics,Ct as useMetricsIds,j as useMetricsOrMetricsById,W as useQueries,jt as useQueriesIds,z as useQueriesOrQueriesById,Dt as useQueryIds,lo as useRedoInformation,Lt as useRelationshipIds,O as useRelationships,St as useRelationshipsIds,Q as useRelationshipsOrRelationshipsById,Bt as useRemoteRowId,Et as useRemoteRowIdListener,Kt as useResultCell,Jt as useResultCellIds,_t as useResultCellIdsListener,eo as useResultCellListener,Gt as useResultRow,Qt as useResultRowCount,Xt as useResultRowCountListener,Wt as useResultRowIds,Yt as useResultRowIdsListener,$t as useResultRowListener,zt as useResultSortedRowIds,Zt as useResultSortedRowIdsListener,Ht as useResultTable,Ot as useResultTableCellIds,Ut as useResultTableCellIdsListener,Nt as useResultTableListener,Re as useRow,ye as useRowCount,_e as useRowCountListener,ke as useRowIds,et as useRowIdsListener,st as useRowListener,Ae as useSetCellCallback,no as useSetCheckpointCallback,Ve as useSetPartialRowCallback,De as useSetPartialValuesCallback,Ee as useSetRowCallback,Me as useSetTableCallback,Te as useSetTablesCallback,He as useSetValueCallback,je as useSetValuesCallback,Rt as useSliceIds,ft as useSliceIdsListener,qt as useSliceRowIds,Pt as useSliceRowIdsListener,we as useSortedRowIds,tt as useSortedRowIdsListener,at as useStartTransactionListener,F as useStore,ce as useStoreIds,V as useStoreOrStoreById,be as useTable,Ce as useTableCellIds,Ze as useTableCellIdsListener,pe as useTableIds,Ue as useTableIdsListener,Ye as useTableListener,ae as useTables,Ne as useTablesListener,co as useUndoInformation,Be as useValue,Se as useValueIds,it as useValueIdsListener,lt as useValueListener,xe as useValues,It as useValuesListener,pt as useWillFinishTransactionListener};
1
+ import e from"react";const t=e=>typeof e,o="",s=t(o),r="Listener",d="Result",n="Has",u="has",I="Ids",i="Table",c=i+"s",l=i+I,a="Row",p=a+"Count",g=a+I,b="Sorted"+a+I,C="Cell",m=C+I,k="Value",y=k+"s",w=k+I,h=e=>null==e,R=(e,t,o)=>h(e)?o?.():t(e),v=e=>t(e)==s,f=()=>{},q=(e,t)=>e.map(t),P=Object.keys,x=(e,t)=>R(e,(e=>e[t])),S=(e,t)=>(delete e[t],e),{createContext:L,useContext:B,useEffect:T}=e,E=L([]),M=(e,t)=>{const o=B(E);return h(e)?o[t]:v(e)?x(o[t+1]??{},e):e},F=(e,t)=>{const o=M(e,t);return h(e)||v(e)?o:e},V=e=>P(B(E)[e]??{}),A=e=>M(e,0),j=e=>F(e,0),D=(e,t)=>{const{12:o,13:s}=B(E);T((()=>(o?.(e,t),()=>s?.(e))),[o,e,t,s])},H=e=>M(e,2),O=e=>F(e,2),Q=e=>M(e,4),W=e=>F(e,4),z=e=>M(e,6),G=e=>F(e,6),J=e=>M(e,8),K=e=>F(e,8),N=e=>M(e,10),U=e=>F(e,10),X=e=>e.toLowerCase();X(r);const Y="Transaction";X(Y);const{useCallback:Z,useEffect:$,useMemo:_,useLayoutEffect:ee,useRef:te,useState:oe}=e,se=[],re={},de=[[],void 0,[]],ne=(e,t,o=se)=>{const s=_((()=>t(e)),[e,...o]);return $((()=>()=>s.destroy()),[s]),s},ue=(e,t,o,s=se,r,d="get",n="")=>{const[,u]=oe(),I=Z((()=>t?.[d+e]?.(...s)??o),[t,e,...s,o]),i=te();return _((()=>i.current=I()),[I]),Ie(n+e,t,((...e)=>{i.current=h(r)?I():e[r],u([])}),[I,r],s),i.current},Ie=(e,t,o,s=se,d=se,...n)=>ee((()=>{const s=t?.["add"+e+r]?.(...d,o,...n);return()=>t?.delListener(s)}),[t,e,...d,...s,...n]),ie=(e,t,o,s=se,r=f,d=se,...n)=>{const u=j(e);return Z((e=>R(u,(s=>R(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[u,t,...s,...d,...n])},ce=(e,t,o=f,s=se,...r)=>{const d=j(e);return Z((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},le=(e,t,o)=>{const s=U(e);return Z((()=>s?.[t](o)),[s,t,o])},ae=(e,t=se)=>_(e,t),pe=()=>V(1),ge=e=>ue(c,j(e),!1,[],1,u,n),be=e=>ue(c,j(e),re),Ce=e=>ue(l,j(e),se),me=(e,t)=>ue(i,j(t),!1,[e],2,u,n),ke=(e,t)=>ue(i,j(t),re,[e]),ye=(e,t)=>ue(i+m,j(t),se,[e]),we=(e,t,o)=>ue(i+C,j(o),!1,[e,t],3,u,n),he=(e,t)=>ue(p,j(t),0,[e]),Re=(e,t)=>ue(g,j(t),se,[e]),ve=(e,t,o,s=0,r,d)=>ue(b,j(d),se,[e,t,o,s,r],6),fe=(e,t,o)=>ue(a,j(o),!1,[e,t],3,u,n),qe=(e,t,o)=>ue(a,j(o),re,[e,t]),Pe=(e,t,o)=>ue(m,j(o),se,[e,t]),xe=(e,t,o,s)=>ue(C,j(s),!1,[e,t,o],4,u,n),Se=(e,t,o,s)=>ue(C,j(s),void 0,[e,t,o],4),Le=e=>ue(y,j(e),!1,[],1,u,n),Be=e=>ue(y,j(e),re),Te=e=>ue(w,j(e),se),Ee=(e,t)=>ue(k,j(t),!1,[e],2,u,n),Me=(e,t)=>ue(k,j(t),void 0,[e]),Fe=(e,t,o,s,r)=>ie(o,c,e,t,s,r),Ve=(e,t,o,s,r,d)=>ie(s,i,t,o,r,d,e),Ae=(e,t,o,s,r,d,n)=>ie(r,a,o,s,d,n,e,t),je=(e,t,o=se,s,r=f,d=se,n=!0)=>{const u=j(s);return Z((o=>R(u,(s=>R(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[u,e,...o,...d,n])},De=(e,t,o,s,r,d,n)=>ie(r,"PartialRow",o,s,d,n,e,t),He=(e,t,o,s,r,d,n,u)=>ie(d,C,s,r,n,u,e,t,o),Oe=(e,t,o,s,r)=>ie(o,y,e,t,s,r),Qe=(e,t,o,s,r)=>ie(o,"PartialValues",e,t,s,r),We=(e,t,o,s,r,d)=>ie(s,k,t,o,r,d,e),ze=(e,t,o)=>ce(e,c,t,o),Ge=(e,t,o,s)=>ce(t,i,o,s,e),Je=(e,t,o,s,r)=>ce(o,a,s,r,e,t),Ke=(e,t,o,s,r,d,n)=>ce(r,C,d,n,e,t,o,s),Ne=(e,t,o)=>ce(e,y,t,o),Ue=(e,t,o,s)=>ce(t,k,o,s,e),Xe=(e,t,o,s)=>Ie(n+c,j(s),e,t,[],o),Ye=(e,t,o,s)=>Ie(c,j(s),e,t,se,o),Ze=(e,t,o,s)=>Ie(l,j(s),e,t,se,o),$e=(e,t,o,s,r)=>Ie(n+i,j(r),t,o,[e],s),_e=(e,t,o,s,r)=>Ie(i,j(r),t,o,[e],s),et=(e,t,o,s,r)=>Ie(i+m,j(r),t,o,[e],s),tt=(e,t,o,s,r,d)=>Ie(n+i+C,j(d),o,s,[e,t],r),ot=(e,t,o,s,r)=>Ie(p,j(r),t,o,[e],s),st=(e,t,o,s,r)=>Ie(g,j(r),t,o,[e],s),rt=(e,t,o,s,r,d,n,u,I)=>Ie(b,j(I),d,n,[e,t,o,s,r],u),dt=(e,t,o,s,r,d)=>Ie(n+a,j(d),o,s,[e,t],r),nt=(e,t,o,s,r,d)=>Ie(a,j(d),o,s,[e,t],r),ut=(e,t,o,s,r,d)=>Ie(m,j(d),o,s,[e,t],r),It=(e,t,o,s,r,d,u)=>Ie(n+C,j(u),s,r,[e,t,o],d),it=(e,t,o,s,r,d,n)=>Ie(C,j(n),s,r,[e,t,o],d),ct=(e,t,o,s)=>Ie(n+y,j(s),e,t,[],o),lt=(e,t,o,s)=>Ie(y,j(s),e,t,se,o),at=(e,t,o,s)=>Ie(w,j(s),e,t,se,o),pt=(e,t,o,s,r)=>Ie(n+k,j(r),t,o,[e],s),gt=(e,t,o,s,r)=>Ie(k,j(r),t,o,[e],s),bt=(e,t,o)=>Ie("Start"+Y,j(o),e,t),Ct=(e,t,o)=>Ie("WillFinish"+Y,j(o),e,t),mt=(e,t,o)=>Ie("DidFinish"+Y,j(o),e,t),kt=(e,t,o)=>ne(e,t,o),yt=()=>V(3),wt=e=>ue("MetricIds",O(e),se),ht=(e,t)=>ue("Metric",O(t),void 0,[e]),Rt=(e,t,o,s)=>Ie("Metric",O(s),t,o,[e]),vt=(e,t,o)=>ne(e,t,o),ft=()=>V(5),qt=(e,t)=>ue("SliceIds",W(t),se,[e]),Pt=e=>ue("IndexIds",W(e),se),xt=(e,t,o)=>ue("Slice"+g,W(o),se,[e,t]),St=(e,t,o,s)=>Ie("SliceIds",W(s),t,o,[e]),Lt=(e,t,o,s,r)=>Ie("Slice"+g,W(r),o,s,[e,t]),Bt=(e,t,o)=>ne(e,t,o),Tt=()=>V(7),Et=e=>ue("RelationshipIds",G(e),se),Mt=(e,t,o)=>ue("RemoteRowId",G(o),void 0,[e,t]),Ft=(e,t,o)=>ue("Local"+g,G(o),se,[e,t]),Vt=(e,t,o)=>ue("Linked"+g,G(o),se,[e,t]),At=(e,t,o,s,r)=>Ie("RemoteRowId",G(r),o,s,[e,t]),jt=(e,t,o,s,r)=>Ie("Local"+g,G(r),o,s,[e,t]),Dt=(e,t,o,s,r)=>Ie("Linked"+g,G(r),o,s,[e,t]),Ht=(e,t,o)=>ne(e,t,o),Ot=()=>V(9),Qt=e=>ue("QueryIds",K(e),se),Wt=(e,t)=>ue(d+i,K(t),re,[e]),zt=(e,t)=>ue(d+i+m,K(t),se,[e]),Gt=(e,t)=>ue(d+p,K(t),0,[e]),Jt=(e,t)=>ue(d+g,K(t),se,[e]),Kt=(e,t,o,s=0,r,n)=>ue(d+b,K(n),se,[e,t,o,s,r],6),Nt=(e,t,o)=>ue(d+a,K(o),re,[e,t]),Ut=(e,t,o)=>ue(d+m,K(o),se,[e,t]),Xt=(e,t,o,s)=>ue(d+C,K(s),void 0,[e,t,o]),Yt=(e,t,o,s)=>Ie(d+i,K(s),t,o,[e]),Zt=(e,t,o,s)=>Ie(d+i+m,K(s),t,o,[e]),$t=(e,t,o,s)=>Ie(d+p,K(s),t,o,[e]),_t=(e,t,o,s)=>Ie(d+g,K(s),t,o,[e]),eo=(e,t,o,s,r,n,u,I)=>Ie(d+b,K(I),n,u,[e,t,o,s,r]),to=(e,t,o,s,r)=>Ie(d+a,K(r),o,s,[e,t]),oo=(e,t,o,s,r)=>Ie(d+m,K(r),o,s,[e,t]),so=(e,t,o,s,r,n)=>Ie(d+C,K(n),s,r,[e,t,o]),ro=(e,t,o)=>ne(e,t,o),no=()=>V(11),uo=e=>ue("CheckpointIds",U(e),de),Io=(e,t)=>ue("Checkpoint",U(t),void 0,[e]),io=(e=f,t=se,o,s=f,r=se)=>{const d=U(o);return Z((t=>R(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},co=e=>le(e,"goBackward"),lo=e=>le(e,"goForward"),ao=(e,t=se,o,s=f,r=se)=>{const d=U(o);return Z((t=>R(d,(o=>R(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},po=e=>{const t=U(e),[s,r]=uo(t);return[(d=s,!(0==d.length)),co(t),r,R(r,(e=>t?.getCheckpoint(e)))??o];var d},go=e=>{const t=U(e),[,,[s]]=uo(t);return[!h(s),lo(t),s,R(s,(e=>t?.getCheckpoint(e)))??o]},bo=(e,t,o)=>Ie("CheckpointIds",U(o),e,t),Co=(e,t,o,s)=>Ie("Checkpoint",U(s),t,o,[e]),mo=(e,t,o=se,s,r=se,d,n=se)=>{const[,u]=oe(),I=_((()=>t(e)),[e,...o]);return $((()=>((async()=>{s&&(await s(I),u([]))})(),()=>{I?.destroy(),d?.(I)})),[I,...r,...n]),I},{PureComponent:ko,Fragment:yo,createElement:wo,useCallback:ho,useLayoutEffect:Ro,useRef:vo,useState:fo}=e,qo=(e,...t)=>h(e)?{}:e(...t),Po=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useCallback:xo,useContext:So,useMemo:Lo,useState:Bo}=e,To=({tableId:e,store:t,rowComponent:o=Do,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},u)=>Ao(q(u,(d=>wo(o,{...qo(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),Eo=({queryId:e,queries:t,resultRowComponent:o=Zo,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>Ao(q(n,(r=>wo(o,{...qo(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Mo=({relationshipId:e,relationships:t,rowComponent:o=Do,getRowComponentProps:s,separator:r,debugIds:d},n,u)=>{const[I,i,c]=Po(G(t),e),l=n(e,u,I);return Ao(q(l,(e=>wo(o,{...qo(s,e),key:e,tableId:c,rowId:e,store:i,debugIds:d}))),r,d,u)},Fo=e=>({checkpoints:t,checkpointComponent:o=es,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=U(t);return Ao(q(e(uo(n)),(e=>wo(o,{...qo(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},Vo=({store:e,storesById:t,metrics:o,metricsById:s,indexes:r,indexesById:d,relationships:n,relationshipsById:u,queries:I,queriesById:i,checkpoints:c,checkpointsById:l,children:a})=>{const p=So(E),[g,b]=Bo({}),C=xo(((e,t)=>b((o=>x(o,e)==t?o:{...o,[e]:t}))),[]),m=xo((e=>b((t=>({...S(t,e)})))),[]);return wo(E.Provider,{value:Lo((()=>[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},I??p[8],{...p[9],...i},c??p[10],{...p[11],...l},C,m]),[e,t,g,o,s,r,d,n,u,I,i,c,l,p,C,m])},a)},Ao=(e,t,o,s)=>{const r=h(t)||!Array.isArray(e)?e:q(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},jo=({tableId:e,rowId:t,cellId:s,store:r,debugIds:d})=>Ao(o+(Se(e,t,s,r)??o),void 0,d,s),Do=({tableId:e,rowId:t,store:o,cellComponent:s=jo,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:u})=>Ao(q(((e,t,o,s)=>{const r=Pe(t,o,s);return e??r})(d,e,t,o),(d=>wo(s,{...qo(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:u}))),n,u,t),Ho=e=>To(e,Re(e.tableId,e.store)),Oo=({cellId:e,descending:t,offset:o,limit:s,...r})=>To(r,ve(r.tableId,e,t,o,s,r.store)),Qo=({store:e,tableComponent:t=Ho,getTableComponentProps:o,separator:s,debugIds:r})=>Ao(q(Ce(e),(s=>wo(t,{...qo(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Wo=({valueId:e,store:t,debugIds:s})=>Ao(o+(Me(e,t)??o),void 0,s,e),zo=({store:e,valueComponent:t=Wo,getValueComponentProps:o,separator:s,debugIds:r})=>Ao(q(Te(e),(s=>wo(t,{...qo(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),Go=({metricId:e,metrics:t,debugIds:s})=>Ao(ht(e,t)??o,void 0,s,e),Jo=({indexId:e,sliceId:t,indexes:o,rowComponent:s=Do,getRowComponentProps:r,separator:d,debugIds:n})=>{const[u,I,i]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(W(o),e),c=xt(e,t,u);return Ao(q(c,(e=>wo(s,{...qo(r,e),key:e,tableId:i,rowId:e,store:I,debugIds:n}))),d,n,t)},Ko=({indexId:e,indexes:t,sliceComponent:o=Jo,getSliceComponentProps:s,separator:r,debugIds:d})=>Ao(q(qt(e,t),(r=>wo(o,{...qo(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),No=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=Do,getRowComponentProps:r,debugIds:d})=>{const[n,u,,I]=Po(G(o),e),i=Mt(e,t,n);return Ao(h(I)||h(i)?null:wo(s,{...qo(r,i),key:i,tableId:I,rowId:i,store:u,debugIds:d}),void 0,d,t)},Uo=e=>Mo(e,Ft,e.remoteRowId),Xo=e=>Mo(e,Vt,e.firstRowId),Yo=({queryId:e,rowId:t,cellId:s,queries:r,debugIds:d})=>Ao(o+(Xt(e,t,s,r)??o),void 0,d,s),Zo=({queryId:e,rowId:t,queries:o,resultCellComponent:s=Yo,getResultCellComponentProps:r,separator:d,debugIds:n})=>Ao(q(Ut(e,t,o),(d=>wo(s,{...qo(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),$o=e=>Eo(e,Jt(e.queryId,e.queries)),_o=({cellId:e,descending:t,offset:o,limit:s,...r})=>Eo(r,Kt(r.queryId,e,t,o,s,r.queries)),es=({checkpoints:e,checkpointId:t,debugIds:s})=>Ao(Io(t,e)??o,void 0,s,t),ts=Fo((e=>e[0])),os=Fo((e=>h(e[1])?[]:[e[1]])),ss=Fo((e=>e[2]));export{ts as BackwardCheckpointsView,jo as CellView,es as CheckpointView,os as CurrentCheckpointView,ss as ForwardCheckpointsView,Ko as IndexView,Xo as LinkedRowsView,Uo as LocalRowsView,Go as MetricView,Vo as Provider,No as RemoteRowView,Yo as ResultCellView,Zo as ResultRowView,_o as ResultSortedTableView,$o as ResultTableView,Do as RowView,Jo as SliceView,Oo as SortedTableView,Ho as TableView,Qo as TablesView,Wo as ValueView,zo as ValuesView,je as useAddRowCallback,Se as useCell,Pe as useCellIds,ut as useCellIdsListener,it as useCellListener,Io as useCheckpoint,uo as useCheckpointIds,bo as useCheckpointIdsListener,Co as useCheckpointListener,N as useCheckpoints,no as useCheckpointsIds,U as useCheckpointsOrCheckpointsById,ro as useCreateCheckpoints,vt as useCreateIndexes,kt as useCreateMetrics,mo as useCreatePersister,Ht as useCreateQueries,Bt as useCreateRelationships,ae as useCreateStore,Ke as useDelCellCallback,Je as useDelRowCallback,Ge as useDelTableCallback,ze as useDelTablesCallback,Ue as useDelValueCallback,Ne as useDelValuesCallback,mt as useDidFinishTransactionListener,co as useGoBackwardCallback,lo as useGoForwardCallback,ao as useGoToCallback,xe as useHasCell,It as useHasCellListener,fe as useHasRow,dt as useHasRowListener,me as useHasTable,we as useHasTableCell,tt as useHasTableCellListener,$e as useHasTableListener,ge as useHasTables,Xe as useHasTablesListener,Ee as useHasValue,pt as useHasValueListener,Le as useHasValues,ct as useHasValuesListener,Pt as useIndexIds,Q as useIndexes,ft as useIndexesIds,W as useIndexesOrIndexesById,Vt as useLinkedRowIds,Dt as useLinkedRowIdsListener,Ft as useLocalRowIds,jt as useLocalRowIdsListener,ht as useMetric,wt as useMetricIds,Rt as useMetricListener,H as useMetrics,yt as useMetricsIds,O as useMetricsOrMetricsById,D as useProvideStore,J as useQueries,Ot as useQueriesIds,K as useQueriesOrQueriesById,Qt as useQueryIds,go as useRedoInformation,Et as useRelationshipIds,z as useRelationships,Tt as useRelationshipsIds,G as useRelationshipsOrRelationshipsById,Mt as useRemoteRowId,At as useRemoteRowIdListener,Xt as useResultCell,Ut as useResultCellIds,oo as useResultCellIdsListener,so as useResultCellListener,Nt as useResultRow,Gt as useResultRowCount,$t as useResultRowCountListener,Jt as useResultRowIds,_t as useResultRowIdsListener,to as useResultRowListener,Kt as useResultSortedRowIds,eo as useResultSortedRowIdsListener,Wt as useResultTable,zt as useResultTableCellIds,Zt as useResultTableCellIdsListener,Yt as useResultTableListener,qe as useRow,he as useRowCount,ot as useRowCountListener,Re as useRowIds,st as useRowIdsListener,nt as useRowListener,He as useSetCellCallback,io as useSetCheckpointCallback,De as useSetPartialRowCallback,Qe as useSetPartialValuesCallback,Ae as useSetRowCallback,Ve as useSetTableCallback,Fe as useSetTablesCallback,We as useSetValueCallback,Oe as useSetValuesCallback,qt as useSliceIds,St as useSliceIdsListener,xt as useSliceRowIds,Lt as useSliceRowIdsListener,ve as useSortedRowIds,rt as useSortedRowIdsListener,bt as useStartTransactionListener,A as useStore,pe as useStoreIds,j as useStoreOrStoreById,ke as useTable,ye as useTableCellIds,et as useTableCellIdsListener,Ce as useTableIds,Ze as useTableIdsListener,_e as useTableListener,be as useTables,Ye as useTablesListener,po as useUndoInformation,Me as useValue,Te as useValueIds,at as useValueIdsListener,gt as useValueListener,Be as useValues,lt as useValuesListener,Ct as useWillFinishTransactionListener};
Binary file
@@ -0,0 +1 @@
1
+ var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n=",",i=e(""),o=(a,t)=>a.repeat(t),c=Promise,r=setInterval,l=clearInterval,y=a=>null==a,w=(a,t,e)=>y(a)?e?.():t(a),E=a=>e(a)==i,d=(a,t,e)=>a.slice(t,e),u=a=>a.length,p=async a=>c.all(a),f=(a,t="")=>a.join(t),T=(a,t)=>a.map(t),m=a=>0==u(a),v=(a,t)=>a.filter(t),A=(a,...t)=>a.push(...t),L=(a,t)=>a?.has(t)??!1,h=a=>[...a?.values()??[]],N=(a,t)=>a?.delete(t),O=Object,R=a=>O.getPrototypeOf(a),S=O.keys,b=O.freeze,g=(a=[])=>O.fromEntries(a),C=(...a)=>O.assign({},...a),D=(a,t)=>T(O.entries(a),(([a,e])=>t(e,a))),x=a=>O.values(a),I=a=>u(S(a)),F=a=>(a=>!y(a)&&w(R(a),(a=>a==O.prototype||y(R(a))),(()=>!0)))(a)&&0==I(a),M=a=>new Map(a),P=a=>[...a?.keys()??[]],$=(a,t)=>a?.get(t),_=(a,t)=>T([...a?.entries()??[]],(([a,e])=>t(e,a))),q=(a,t,e)=>y(e)?(N(a,t),a):a?.set(t,e),B=(a,t,e)=>(L(a,t)||q(a,t,e()),$(a,t)),j=(a,t,e,s=q)=>(D(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>((a,t)=>!y(((a,t)=>w(a,(a=>a[t])))(a,t)))(t,e)?0:s(a,e))),a),H=a=>new Set(Array.isArray(a)||y(a)?a:[a]),W=(a,t)=>a?.add(t),k="_",J="_id",U=a=>`"${a.replace(/"/g,'""')}"`,Y="FROM pragma_table_",z="WHERE",G=(a,t,e)=>{const s=M();return[async()=>j(s,g(await p(T(await a("SELECT name "+Y+"list WHERE schema='main'AND type='table'AND name IN("+V(t)+")",t),(async({name:t})=>[t,g(T(await a("SELECT name,type "+Y+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>q(s,t,j(B(s,t,M),e,((a,t,e)=>{e!=$(a,t)&&q(a,t,e)}),((a,t)=>q(a,t))))),((a,t)=>q(s,t))),async(t,e)=>((a,t)=>!y($($(s,a),t)))(t,e)?g(v(T(await a("SELECT*FROM"+U(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!y(a)&&!F(t)))):{},async(t,e,i,o,c,r=!1)=>{const l=H();D(i??{},(a=>T(S(a??{}),(a=>W(l,a)))));const w=h(l);if(!r&&c&&m(w)&&L(s,t))return await a("DROP TABLE"+U(t)),void q(s,t);if(m(w)||L(s,t)){const n=$(s,t),i=H(P(n));await p([...T(w,(async e=>{N(i,e)||(await a(`ALTER TABLE${U(t)}ADD${U(e)}`),q(n,e,""))})),...!r&&o?T(h(i),(async s=>{s!=e&&(await a(`ALTER TABLE${U(t)}DROP${U(s)}`),q(n,s))})):[]])}else await a(`CREATE TABLE${U(t)}(${U(e)} PRIMARY KEY ON CONFLICT REPLACE${f(T(w,(a=>n+U(a))))});`),q(s,t,M([[e,""],...T(w,(a=>[a,""]))]));if(r)y(i)?await a("DELETE FROM"+U(t)+"WHERE 1"):await p(D(i,(async(s,n)=>{y(s)?await a("DELETE FROM"+U(t)+z+U(e)+"=?",[n]):m(w)||await K(a,t,e,S(s),[n,...x(s)])})));else if(m(w))L(s,t)&&await a("DELETE FROM"+U(t)+"WHERE 1");else{const n=v(P($(s,t)),(a=>a!=e)),o=[],c=[];D(i??{},((a,t)=>{A(o,t,...T(n,(t=>a?.[t]))),A(c,t)})),await K(a,t,e,n,o),await a("DELETE FROM"+U(t)+z+U(e)+"NOT IN("+V(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},K=async(a,t,e,s,i)=>await a("INSERT INTO"+U(t)+"("+U(e)+f(T(s,(a=>n+U(a))))+")VALUES"+d(o(`,(?${o(",?",u(s))})`,u(i)/(u(s)+1)),1)+"ON CONFLICT("+U(e)+")DO UPDATE SET"+f(T(s,(a=>U(a)+"=excluded."+U(a))),n),i),V=a=>f(T(a,(()=>"?")),n),Q=JSON.parse,X=M(),Z=M(),aa=(a,t,e,s,n,i,[o,c]=[],r=[])=>{let l,E,d,u=0,p=0;B(X,r,(()=>0)),B(Z,r,(()=>[]));const f=async a=>(2!=u&&(u=1,await T.schedule((async()=>{await a(),u=0}))),T),T={load:async(e,s)=>await f((async()=>{try{a.setContent(await t())}catch{a.setContent([e,s])}})),startAutoLoad:async(e={},n={})=>(T.stopAutoLoad(),await T.load(e,n),p=1,d=s((async(e,s)=>{if(s){const t=s();await f((async()=>a.setTransactionChanges(t)))}else await f((async()=>{try{a.setContent(e?.()??await t())}catch(a){i?.(a)}}))})),T),stopAutoLoad:()=>(p&&(n(d),d=void 0,p=0),T),save:async t=>(1!=u&&(u=2,await T.schedule((async()=>{try{await e(a.getContent,t)}catch(a){i?.(a)}u=0}))),T),startAutoSave:async()=>(await T.stopAutoSave().save(),l=a.addDidFinishTransactionListener(((a,t)=>{const[e,s]=t();F(e)&&F(s)||T.save((()=>[e,s]))})),T),stopAutoSave:()=>(w(l,a.delListener),l=void 0,T),schedule:async(...a)=>(A($(Z,r),...a),await(async()=>{if(!$(X,r)){for(q(X,r,1);!y((a=$(Z,r),E=a.shift()));)try{await E()}catch(a){i?.(a)}q(X,r,0)}var a})(),T),getStore:()=>a,destroy:()=>T.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return o&&(T[o]=()=>c),b(T)},ta="store",ea=(a,t,e,s,n,[i],o,c)=>{const[r,l,y,w]=G(t,o,n);return aa(a,(async()=>await w((async()=>(await r(),Q((await l(i,J))[k]?.[ta]??"null"))))),(async a=>await w((async()=>{var t;await r(),await y(i,J,{[k]:{[ta]:(t=a()??null,JSON.stringify(t,((a,t)=>t instanceof Map?O.fromEntries([...t]):t)))}},!0,!0)}))),e,s,n,["getDb",c],c)},sa=(a,t,e,s,n,[i,o,[c,r,l]],w,E)=>{const[d,u,f,T]=G(t,w,n),m=async(a,t)=>await p(_(o,(async([e,s,n,i],o)=>{const c=a[o];t&&void 0===c||await f(e,s,c,n,i,t)}))),A=async(a,t)=>r?await f(l,J,{[k]:a},!0,!0,t):null;return aa(a,(async()=>await T((async()=>{await d();const a=await(async()=>g(v(await p(_(i,(async([a,t],e)=>[a,await u(e,t)]))),(a=>!F(a[1])))))(),t=await(async()=>c?(await u(l,J))[k]:{})();return F(a)&&y(t)?void 0:[a,t]}))),(async(a,t)=>await T((async()=>{if(await d(),y(t)){const[t,e]=a();await m(t),await A(e)}else{const[a,e]=t();await m(a,!0),await A(e,!0)}}))),e,s,n,["getDb",E],E)},na="json",ia="autoLoadIntervalSeconds",oa="rowIdColumnName",ca="tableId",ra="tableName",la={mode:na,[ia]:1},ya={load:0,save:0,[ra]:s+"_values"},wa=(a,t,e,s)=>{const n=M();return D(a,((a,i)=>{const o=d(x(C(t,E(a)?{[e]:a}:a)),0,I(t));y(o[0])||s(i,o[0])||q(n,i,o)})),n},Ea="pragma ",da="data_version",ua="schema_version",pa=(a,t,e,n,i,o,c,y)=>{let w,u;const[p,f,T,m]=(a=>{const t=(a=>C(la,E(a)?{storeTableName:a}:a??{}))(a),e=t[ia];if(t.mode==na){const{storeTableName:a=s}=t;return[1,e,[a],H(a)]}const{tables:{load:n={},save:i={}}={},values:o={}}=t,c=d(x(C(ya,o)),0,I(ya)),r=c[2],l=H(r);return[0,e,[wa(n,{[ca]:null,[oa]:J},ca,(a=>W(l,a)&&a==r)),wa(i,{[ra]:null,[oa]:J,deleteEmptyColumns:0,deleteEmptyTable:0},ra,((a,t)=>W(l,t)&&t==r)),c],l]})(t);return(p?ea:sa)(a,o?async(a,t)=>(o(a,t),await e(a,t)):e,(a=>[r((async()=>{try{const t=(await e(Ea+da))[0][da],s=(await e(Ea+ua))[0][ua];t==(w??=t)&&s==(u??=s)||(a(),w=t,u=s)}catch{}}),1e3*f),n((t=>m.has(t)?a():0))]),(([a,t])=>{l(a),w=u=null,i(t)}),c,T,h(m),y)};a.createExpoSqliteNextPersister=(a,e,s,n,i)=>pa(a,s,(async(a,t=[])=>await e.allAsync(a,t)),(a=>t.addDatabaseChangeListener((({tableName:t})=>a(t)))),(a=>a.remove()),n,i,e)},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("expo-sqlite/next")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite/next"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterExpoSqliteNext={},a["expo-sqlite/next"]);
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";const e=t=>typeof t,a="",s=e(a),n="t",i=(t,e)=>t.startsWith(e),r=Promise,o=t=>null==t,c=(t,e,a)=>o(t)?a?.():e(t),l=(t,e,a)=>t.slice(e,a),f=t=>t.length,u=async t=>r.all(t),h=(t,e)=>t.map(e),y=(t,...e)=>t.push(...e),w=Object,g=(t=[])=>w.fromEntries(t),p=(t,e)=>h(w.entries(t),(([t,a])=>e(a,t))),d=(t,e,a)=>(((t,e)=>!o(((t,e)=>c(t,(t=>t[e])))(t,e)))(t,e)||(t[e]=a()),t[e]),S=t=>JSON.stringify(t,((t,e)=>e instanceof Map?w.fromEntries([...e]):e)),P=JSON.parse,b=(t,a,n)=>t+a+(e(n)==s?n:S(n)),m=(t,e,a)=>{const s=f(t);return i(e,t)?[e[s],(a?P:String)(l(e,s+1))]:void 0},T=(t,e)=>((t,e)=>t?.forEach(e))(t,((t,a)=>e(a,t))),x="hasStore",D=g(h(["Origin","Methods","Headers"],(t=>["Access-Control-Allow-"+t,"*"]))),v=async t=>await t.party.storage.get((t.config.storagePrefix??a)+x),R=async(t,e,s,r)=>{const c=t.party.storage,l=t.config.storagePrefix??a,h={[l+x]:1},w=[],g=[];await u(p(e[0],(async(e,a)=>o(e)?!s&&t.canDelTable(a,r)&&((t,...e)=>t.unshift(...e))(g,C(l,n,a)):t.canSetTable(a,s,r)&&await u(p(e,(async(e,i)=>o(e)?!s&&t.canDelRow(a,i,r)&&y(g,C(l,n,a,i)):t.canSetRow(a,i,s,r)&&await u(p(e,(async(e,f)=>{const u=[a,i,f],g=C(l,n,...u);o(e)?!s&&t.canDelCell(...u,r)&&y(w,g):t.canSetCell(...u,e,s,r,await c.get(g))&&(h[g]=e)}))))))))),await u(p(e[1],(async(e,a)=>{const n=l+"v"+a;o(e)?!s&&t.canDelValue(a,r)&&y(w,n):t.canSetValue(a,e,s,r,await c.get(n))&&(h[n]=e)}))),0!=f(g)&&T(await c.list(),(t=>g.every((e=>!i(t,e)||y(w,t)&&0)))),await c.delete(w),await c.put(h)},C=(t,e,...a)=>b(t,e,l(S(a),1,-1)),O=async(t,e,a=null)=>new Response(a,{status:e,headers:t.config.responseHeaders??D});t.TinyBasePartyKitServer=class{constructor(t){this.party=t,this.config={}}async onRequest(t){const e=this.config.storePath??"/store";if(new URL(t.url).pathname.endsWith(e)){const e=await v(this),s=await t.text();return"PUT"==t.method?e?O(this,205):(await R(this,P(s),!0,t),O(this,201)):O(this,200,e?S(await(async t=>{const e={},s={},i=t.config.storagePrefix??a;return T(await t.party.storage.list(),((t,a)=>c(m(i,t),(([t,i])=>{if(t==n){const[t,s,n]=P("["+i+"]");d(d(e,t,g),s,g)[n]=a}else"v"==t&&(s[i]=a)})))),[e,s]})(this)):a)}return O(this,404)}async onMessage(t,e){const s=this.config.messagePrefix??a;await c(m(s,t,1),(async([t,a])=>{"s"==t&&await v(this)&&(await R(this,a,!1,e),this.party.broadcast(b(s,"s",a)))}))}canSetTable(t,e,a){return!0}canDelTable(t,e){return!0}canSetRow(t,e,a,s){return!0}canDelRow(t,e,a){return!0}canSetCell(t,e,a,s,n,i,r){return!0}canDelCell(t,e,a,s){return!0}canSetValue(t,e,a,s,n){return!0}canDelValue(t,e){return!0}}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterPartyKitServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,a=t(""),s="t",n=(e,t)=>e.startsWith(t),r=Promise,i=e=>null==e,o=(e,t,a)=>i(e)?a?.():t(e),c=(e,t,a)=>e.slice(t,a),l=e=>e.length,f=async e=>r.all(e),h=(e,t)=>e.map(t),u=(e,...t)=>e.push(...t),g=Object,y=(e=[])=>g.fromEntries(e),w=(e,t)=>h(g.entries(e),(([e,a])=>t(a,e))),d=(e,t,a)=>(((e,t)=>!i(((e,t)=>o(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=a()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?g.fromEntries([...t]):t)),S=JSON.parse,P=(e,s,n)=>e+s+(t(n)==a?n:p(n)),m=(e,t,a)=>{const s=l(e);return n(t,e)?[t[s],(a?S:String)(c(t,s+1))]:void 0},x=(e,t)=>((e,t)=>e?.forEach(t))(e,((e,a)=>t(a,e))),b="hasStore",T=y(h(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=async(e,t="")=>!!await e.get(t+b),v=async(e,t="")=>{const a={},n={};return x(await e.list(),((e,r)=>o(m(t,e),(([e,t])=>{if(e==s){const[e,s,n]=S("["+t+"]");d(d(a,e,y),s,y)[n]=r}else"v"==e&&(n[t]=r)})))),[a,n]},R=async(e,t,a,r)=>{const o=e.party.storage,c=e.config.storagePrefix,h={[c+b]:1},g=[],y=[];await f(w(t[0],(async(t,n)=>i(t)?!a&&e.canDelTable(n,r)&&((e,...t)=>e.unshift(...t))(y,C(c,s,n)):e.canSetTable(n,a,r)&&await f(w(t,(async(t,l)=>i(t)?!a&&e.canDelRow(n,l,r)&&u(y,C(c,s,n,l)):e.canSetRow(n,l,a,r)&&await f(w(t,(async(t,f)=>{const y=[n,l,f],w=C(c,s,...y);i(t)?!a&&e.canDelCell(...y,r)&&u(g,w):e.canSetCell(...y,t,a,r,await o.get(w))&&(h[w]=t)}))))))))),await f(w(t[1],(async(t,s)=>{const n=c+"v"+s;i(t)?!a&&e.canDelValue(s,r)&&u(g,n):e.canSetValue(s,t,a,r,await o.get(n))&&(h[n]=t)}))),0!=l(y)&&x(await o.list(),(e=>y.every((t=>!n(e,t)||u(g,e)&&0)))),await o.delete(g),await o.put(h)},C=(e,t,...a)=>P(e,t,c(p(a),1,-1)),O=async(e,t,a=null)=>new Response(a,{status:t,headers:e.config.responseHeaders});e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={},this.config.storePath??="/store",this.config.messagePrefix??="",this.config.storagePrefix??="",this.config.responseHeaders??=T}async onRequest(e){const{party:{storage:t},config:{storePath:a,storagePrefix:s}}=this;if(new URL(e.url).pathname.endsWith(a)){const a=await D(t,s),n=await e.text();return"PUT"==e.method?a?O(this,205):(await R(this,S(n),!0,e),O(this,201)):O(this,200,a?p(await v(t,s)):"")}return O(this,404)}async onMessage(e,t){const{party:{storage:a,broadcast:s},config:{messagePrefix:n,storagePrefix:r}}=this;await o(m(n,e,1),(async([e,i])=>{"s"==e&&await D(a,r)&&(await R(this,i,!1,t),s(P(n,"s",i),[t.id]))}))}canSetTable(e,t,a){return!0}canDelTable(e,t){return!0}canSetRow(e,t,a,s){return!0}canDelRow(e,t,a){return!0}canSetCell(e,t,a,s,n,r,i){return!0}canDelCell(e,t,a,s){return!0}canSetValue(e,t,a,s,n){return!0}canDelValue(e,t){return!0}},e.hasStoreInStorage=D,e.loadStoreFromStorage=v},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",u=t(o),r="Listener",l="Result",d="Has",n="has",i="Ids",a="Table",c=a+"s",I=a+i,C="Row",b=C+"Count",p=C+i,w="Sorted"+C+i,R="Cell",k=R+i,g="Value",L=g+"s",h=g+i,m=e=>null==e,y=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==u,V=()=>{},S=(e,s)=>e.map(s),f=Object.keys,{createContext:x,useContext:v}=s,P=x([]),q=(e,s)=>{const t=v(P);return m(e)?t[s]:T(e)?((e,s)=>y(e,(e=>e[s])))(t[s+1]??{},e):e},B=(e,s)=>{const t=q(e,s);return m(e)||T(e)?t:e},H=e=>f(v(P)[e]??{}),M=e=>B(e,0),D=e=>B(e,2),F=e=>B(e,4),O=e=>B(e,6),Q=e=>B(e,8),E=e=>B(e,10),A=e=>e.toLowerCase();A(r);const G="Transaction";A(G);const{useCallback:j,useEffect:U,useMemo:W,useLayoutEffect:z,useRef:J,useState:K}=s,N=[],X={},Y=[[],void 0,[]],Z=(e,s,t=N)=>{const o=W((()=>s(e)),[e,...t]);return U((()=>()=>o.destroy()),[o]),o},$=(e,s,t,o=N,u,r="get",l="")=>{const[,d]=K(),n=j((()=>s?.[r+e]?.(...o)??t),[s,e,...o,t]),i=J();return W((()=>i.current=n()),[n]),_(l+e,s,((...e)=>{i.current=m(u)?n():e[u],d([])}),[n,u],o),i.current},_=(e,s,t,o=N,u=N,...l)=>z((()=>{const o=s?.["add"+e+r]?.(...u,t,...l);return()=>s?.delListener(o)}),[s,e,...u,...o,...l]),ee=(e,s,t,o=N,u=V,r=N,...l)=>{const d=M(e);return j((e=>y(d,(o=>y(t(e,o),(e=>u(o["set"+s](...l,e),e)))))),[d,s,...o,...r,...l])},se=(e,s,t=V,o=N,...u)=>{const r=M(e);return j((()=>t(r?.["del"+s](...u))),[r,s,...o,...u])},te=(e,s,t)=>{const o=E(e);return j((()=>o?.[s](t)),[o,s,t])},oe=e=>$(I,M(e),N),ue=(e,s)=>$(p,M(s),N,[e]),re=(e,s,t,o=0,u,r)=>$(w,M(r),N,[e,s,t,o,u],6),le=(e,s,t)=>$(k,M(t),N,[e,s]),de=(e,s,t,o)=>$(R,M(o),void 0,[e,s,t],4),ne=e=>$(h,M(e),N),ie=(e,s)=>$(g,M(s),void 0,[e]),ae=(e,s)=>$("Metric",D(s),void 0,[e]),ce=(e,s)=>$("SliceIds",F(s),N,[e]),Ie=(e,s,t)=>$("Slice"+p,F(t),N,[e,s]),Ce=(e,s,t)=>$("RemoteRowId",O(t),void 0,[e,s]),be=(e,s,t)=>$("Local"+p,O(t),N,[e,s]),pe=(e,s,t)=>$("Linked"+p,O(t),N,[e,s]),we=(e,s)=>$(l+p,Q(s),N,[e]),Re=(e,s,t,o=0,u,r)=>$(l+w,Q(r),N,[e,s,t,o,u],6),ke=(e,s,t)=>$(l+k,Q(t),N,[e,s]),ge=(e,s,t,o)=>$(l+R,Q(o),void 0,[e,s,t]),Le=e=>$("CheckpointIds",E(e),Y),he=(e,s)=>$("Checkpoint",E(s),void 0,[e]),me=e=>te(e,"goBackward"),ye=e=>te(e,"goForward"),{PureComponent:Te,Fragment:Ve,createElement:Se,useCallback:fe,useLayoutEffect:xe,useRef:ve,useState:Pe}=s,qe=(e,...s)=>m(e)?{}:e(...s),Be=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useMemo:He}=s,Me=({tableId:e,store:s,rowComponent:t=Ae,getRowComponentProps:o,customCellIds:u,separator:r,debugIds:l},d)=>Qe(S(d,(r=>Se(t,{...qe(o,r),key:r,tableId:e,rowId:r,customCellIds:u,store:s,debugIds:l}))),r,l,e),De=({queryId:e,queries:s,resultRowComponent:t=ze,getResultRowComponentProps:o,separator:u,debugIds:r},l)=>Qe(S(l,(u=>Se(t,{...qe(o,u),key:u,queryId:e,rowId:u,queries:s,debugIds:r}))),u,r,e),Fe=({relationshipId:e,relationships:s,rowComponent:t=Ae,getRowComponentProps:o,separator:u,debugIds:r},l,d)=>{const[n,i,a]=Be(O(s),e),c=l(e,d,n);return Qe(S(c,(e=>Se(t,{...qe(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:r}))),u,r,d)},Oe=e=>({checkpoints:s,checkpointComponent:t=Je,getCheckpointComponentProps:o,separator:u,debugIds:r})=>{const l=E(s);return Qe(S(e(Le(l)),(e=>Se(t,{...qe(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:r}))),u)},Qe=(e,s,t,o)=>{const u=m(s)||!Array.isArray(e)?e:S(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",u,"}"]:u},Ee=({tableId:e,rowId:s,cellId:t,store:u,debugIds:r})=>Qe(o+(de(e,s,t,u)??o),void 0,r,t),Ae=({tableId:e,rowId:s,store:t,cellComponent:o=Ee,getCellComponentProps:u,customCellIds:r,separator:l,debugIds:d})=>Qe(S(((e,s,t,o)=>{const u=le(s,t,o);return e??u})(r,e,s,t),(r=>Se(o,{...qe(u,r),key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:d}))),l,d,s),Ge=e=>Me(e,ue(e.tableId,e.store)),je=({valueId:e,store:s,debugIds:t})=>Qe(o+(ie(e,s)??o),void 0,t,e),Ue=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Ae,getRowComponentProps:u,separator:r,debugIds:l})=>{const[d,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(F(t),e),a=Ie(e,s,d);return Qe(S(a,(e=>Se(o,{...qe(u,e),key:e,tableId:i,rowId:e,store:n,debugIds:l}))),r,l,s)},We=({queryId:e,rowId:s,cellId:t,queries:u,debugIds:r})=>Qe(o+(ge(e,s,t,u)??o),void 0,r,t),ze=({queryId:e,rowId:s,queries:t,resultCellComponent:o=We,getResultCellComponentProps:u,separator:r,debugIds:l})=>Qe(S(ke(e,s,t),(r=>Se(o,{...qe(u,r),key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:l}))),r,l,s),Je=({checkpoints:e,checkpointId:s,debugIds:t})=>Qe(he(s,e)??o,void 0,t,s),Ke=Oe((e=>e[0])),Ne=Oe((e=>m(e[1])?[]:[e[1]])),Xe=Oe((e=>e[2]));e.BackwardCheckpointsView=Ke,e.CellView=Ee,e.CheckpointView=Je,e.CurrentCheckpointView=Ne,e.ForwardCheckpointsView=Xe,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Ue,getSliceComponentProps:o,separator:u,debugIds:r})=>Qe(S(ce(e,s),(u=>Se(t,{...qe(o,u),key:u,indexId:e,sliceId:u,indexes:s,debugIds:r}))),u,r,e),e.LinkedRowsView=e=>Fe(e,pe,e.firstRowId),e.LocalRowsView=e=>Fe(e,be,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>Qe(ae(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:t,metrics:o,metricsById:u,indexes:r,indexesById:l,relationships:d,relationshipsById:n,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:C})=>{const b=s.useContext(P);return Se(P.Provider,{value:He((()=>[e??b[0],{...b[1],...t},o??b[2],{...b[3],...u},r??b[4],{...b[5],...l},d??b[6],{...b[7],...n},i??b[8],{...b[9],...a},c??b[10],{...b[11],...I}]),[e,t,o,u,r,l,d,n,i,a,c,I,b])},C)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Ae,getRowComponentProps:u,debugIds:r})=>{const[l,d,,n]=Be(O(t),e),i=Ce(e,s,l);return Qe(m(n)||m(i)?null:Se(o,{...qe(u,i),key:i,tableId:n,rowId:i,store:d,debugIds:r}),void 0,r,s)},e.ResultCellView=We,e.ResultRowView=ze,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>De(u,Re(u.queryId,e,s,t,o,u.queries)),e.ResultTableView=e=>De(e,we(e.queryId,e.queries)),e.RowView=Ae,e.SliceView=Ue,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Me(u,re(u.tableId,e,s,t,o,u.store)),e.TableView=Ge,e.TablesView=({store:e,tableComponent:s=Ge,getTableComponentProps:t,separator:o,debugIds:u})=>Qe(S(oe(e),(o=>Se(s,{...qe(t,o),key:o,tableId:o,store:e,debugIds:u}))),o),e.ValueView=je,e.ValuesView=({store:e,valueComponent:s=je,getValueComponentProps:t,separator:o,debugIds:u})=>Qe(S(ne(e),(o=>Se(s,{...qe(t,o),key:o,valueId:o,store:e,debugIds:u}))),o),e.useAddRowCallback=(e,s,t=N,o,u=V,r=N,l=!0)=>{const d=M(o);return j((t=>y(d,(o=>y(s(t,o),(s=>u(o.addRow(e,s,l),o,s)))))),[d,e,...t,...r,l])},e.useCell=de,e.useCellIds=le,e.useCellIdsListener=(e,s,t,o,u,r)=>_(k,M(r),t,o,[e,s],u),e.useCellListener=(e,s,t,o,u,r,l)=>_(R,M(l),o,u,[e,s,t],r),e.useCheckpoint=he,e.useCheckpointIds=Le,e.useCheckpointIdsListener=(e,s,t)=>_("CheckpointIds",E(t),e,s),e.useCheckpointListener=(e,s,t,o)=>_("Checkpoint",E(o),s,t,[e]),e.useCheckpoints=e=>q(e,10),e.useCheckpointsIds=()=>H(11),e.useCheckpointsOrCheckpointsById=E,e.useCreateCheckpoints=(e,s,t)=>Z(e,s,t),e.useCreateIndexes=(e,s,t)=>Z(e,s,t),e.useCreateMetrics=(e,s,t)=>Z(e,s,t),e.useCreatePersister=(e,s,t=N,o,u=N,r,l=N)=>{const[,d]=K(),n=W((()=>s(e)),[e,...t]);return U((()=>((async()=>{o&&(await o(n),d([]))})(),()=>{n?.destroy(),r?.(n)})),[n,...u,...l]),n},e.useCreateQueries=(e,s,t)=>Z(e,s,t),e.useCreateRelationships=(e,s,t)=>Z(e,s,t),e.useCreateStore=(e,s=N)=>W(e,s),e.useDelCellCallback=(e,s,t,o,u,r,l)=>se(u,R,r,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,u)=>se(t,C,o,u,e,s),e.useDelTableCallback=(e,s,t,o)=>se(s,a,t,o,e),e.useDelTablesCallback=(e,s,t)=>se(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>se(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>se(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>_("DidFinish"+G,M(t),e,s),e.useGoBackwardCallback=me,e.useGoForwardCallback=ye,e.useGoToCallback=(e,s=N,t,o=V,u=N)=>{const r=E(t);return j((s=>y(r,(t=>y(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...u])},e.useHasCell=(e,s,t,o)=>$(R,M(o),!1,[e,s,t],4,n,d),e.useHasCellListener=(e,s,t,o,u,r,l)=>_(d+R,M(l),o,u,[e,s,t],r),e.useHasRow=(e,s,t)=>$(C,M(t),!1,[e,s],3,n,d),e.useHasRowListener=(e,s,t,o,u,r)=>_(d+C,M(r),t,o,[e,s],u),e.useHasTable=(e,s)=>$(a,M(s),!1,[e],2,n,d),e.useHasTableCell=(e,s,t)=>$(a+R,M(t),!1,[e,s],3,n,d),e.useHasTableCellListener=(e,s,t,o,u,r)=>_(d+a+R,M(r),t,o,[e,s],u),e.useHasTableListener=(e,s,t,o,u)=>_(d+a,M(u),s,t,[e],o),e.useHasTables=e=>$(c,M(e),!1,[],1,n,d),e.useHasTablesListener=(e,s,t,o)=>_(d+c,M(o),e,s,[],t),e.useHasValue=(e,s)=>$(g,M(s),!1,[e],2,n,d),e.useHasValueListener=(e,s,t,o,u)=>_(d+g,M(u),s,t,[e],o),e.useHasValues=e=>$(L,M(e),!1,[],1,n,d),e.useHasValuesListener=(e,s,t,o)=>_(d+L,M(o),e,s,[],t),e.useIndexIds=e=>$("IndexIds",F(e),N),e.useIndexes=e=>q(e,4),e.useIndexesIds=()=>H(5),e.useIndexesOrIndexesById=F,e.useLinkedRowIds=pe,e.useLinkedRowIdsListener=(e,s,t,o,u)=>_("Linked"+p,O(u),t,o,[e,s]),e.useLocalRowIds=be,e.useLocalRowIdsListener=(e,s,t,o,u)=>_("Local"+p,O(u),t,o,[e,s]),e.useMetric=ae,e.useMetricIds=e=>$("MetricIds",D(e),N),e.useMetricListener=(e,s,t,o)=>_("Metric",D(o),s,t,[e]),e.useMetrics=e=>q(e,2),e.useMetricsIds=()=>H(3),e.useMetricsOrMetricsById=D,e.useQueries=e=>q(e,8),e.useQueriesIds=()=>H(9),e.useQueriesOrQueriesById=Q,e.useQueryIds=e=>$("QueryIds",Q(e),N),e.useRedoInformation=e=>{const s=E(e),[,,[t]]=Le(s);return[!m(t),ye(s),t,y(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>$("RelationshipIds",O(e),N),e.useRelationships=e=>q(e,6),e.useRelationshipsIds=()=>H(7),e.useRelationshipsOrRelationshipsById=O,e.useRemoteRowId=Ce,e.useRemoteRowIdListener=(e,s,t,o,u)=>_("RemoteRowId",O(u),t,o,[e,s]),e.useResultCell=ge,e.useResultCellIds=ke,e.useResultCellIdsListener=(e,s,t,o,u)=>_(l+k,Q(u),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,u,r)=>_(l+R,Q(r),o,u,[e,s,t]),e.useResultRow=(e,s,t)=>$(l+C,Q(t),X,[e,s]),e.useResultRowCount=(e,s)=>$(l+b,Q(s),0,[e]),e.useResultRowCountListener=(e,s,t,o)=>_(l+b,Q(o),s,t,[e]),e.useResultRowIds=we,e.useResultRowIdsListener=(e,s,t,o)=>_(l+p,Q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,u)=>_(l+C,Q(u),t,o,[e,s]),e.useResultSortedRowIds=Re,e.useResultSortedRowIdsListener=(e,s,t,o,u,r,d,n)=>_(l+w,Q(n),r,d,[e,s,t,o,u]),e.useResultTable=(e,s)=>$(l+a,Q(s),X,[e]),e.useResultTableCellIds=(e,s)=>$(l+a+k,Q(s),N,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>_(l+a+k,Q(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>_(l+a,Q(o),s,t,[e]),e.useRow=(e,s,t)=>$(C,M(t),X,[e,s]),e.useRowCount=(e,s)=>$(b,M(s),0,[e]),e.useRowCountListener=(e,s,t,o,u)=>_(b,M(u),s,t,[e],o),e.useRowIds=ue,e.useRowIdsListener=(e,s,t,o,u)=>_(p,M(u),s,t,[e],o),e.useRowListener=(e,s,t,o,u,r)=>_(C,M(r),t,o,[e,s],u),e.useSetCellCallback=(e,s,t,o,u,r,l,d)=>ee(r,R,o,u,l,d,e,s,t),e.useSetCheckpointCallback=(e=V,s=N,t,o=V,u=N)=>{const r=E(t);return j((s=>y(r,(t=>{const u=e(s);o(t.addCheckpoint(u),t,u)}))),[r,...s,...u])},e.useSetPartialRowCallback=(e,s,t,o,u,r,l)=>ee(u,"PartialRow",t,o,r,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,u)=>ee(t,"PartialValues",e,s,o,u),e.useSetRowCallback=(e,s,t,o,u,r,l)=>ee(u,C,t,o,r,l,e,s),e.useSetTableCallback=(e,s,t,o,u,r)=>ee(o,a,s,t,u,r,e),e.useSetTablesCallback=(e,s,t,o,u)=>ee(t,c,e,s,o,u),e.useSetValueCallback=(e,s,t,o,u,r)=>ee(o,g,s,t,u,r,e),e.useSetValuesCallback=(e,s,t,o,u)=>ee(t,L,e,s,o,u),e.useSliceIds=ce,e.useSliceIdsListener=(e,s,t,o)=>_("SliceIds",F(o),s,t,[e]),e.useSliceRowIds=Ie,e.useSliceRowIdsListener=(e,s,t,o,u)=>_("Slice"+p,F(u),t,o,[e,s]),e.useSortedRowIds=re,e.useSortedRowIdsListener=(e,s,t,o,u,r,l,d,n)=>_(w,M(n),r,l,[e,s,t,o,u],d),e.useStartTransactionListener=(e,s,t)=>_("Start"+G,M(t),e,s),e.useStore=e=>q(e,0),e.useStoreIds=()=>H(1),e.useStoreOrStoreById=M,e.useTable=(e,s)=>$(a,M(s),X,[e]),e.useTableCellIds=(e,s)=>$(a+k,M(s),N,[e]),e.useTableCellIdsListener=(e,s,t,o,u)=>_(a+k,M(u),s,t,[e],o),e.useTableIds=oe,e.useTableIdsListener=(e,s,t,o)=>_(I,M(o),e,s,N,t),e.useTableListener=(e,s,t,o,u)=>_(a,M(u),s,t,[e],o),e.useTables=e=>$(c,M(e),X),e.useTablesListener=(e,s,t,o)=>_(c,M(o),e,s,N,t),e.useUndoInformation=e=>{const s=E(e),[t,u]=Le(s);return[(r=t,!(0==r.length)),me(s),u,y(u,(e=>s?.getCheckpoint(e)))??o];var r},e.useValue=ie,e.useValueIds=ne,e.useValueIdsListener=(e,s,t,o)=>_(h,M(o),e,s,N,t),e.useValueListener=(e,s,t,o,u)=>_(g,M(u),s,t,[e],o),e.useValues=e=>$(L,M(e),X),e.useValuesListener=(e,s,t,o)=>_(L,M(o),e,s,N,t),e.useWillFinishTransactionListener=(e,s,t)=>_("WillFinish"+G,M(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",u=t(o),r="Listener",l="Result",d="Has",n="has",i="Ids",a="Table",c=a+"s",I=a+i,C="Row",b=C+"Count",p=C+i,w="Sorted"+C+i,R="Cell",k=R+i,g="Value",L=g+"s",h=g+i,m=e=>null==e,y=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==u,V=()=>{},S=(e,s)=>e.map(s),f=Object.keys,v=(e,s)=>y(e,(e=>e[s])),x=(e,s)=>(delete e[s],e),{createContext:P,useContext:q,useEffect:B}=s,H=P([]),M=(e,s)=>{const t=q(H);return m(e)?t[s]:T(e)?v(t[s+1]??{},e):e},D=(e,s)=>{const t=M(e,s);return m(e)||T(e)?t:e},F=e=>f(q(H)[e]??{}),O=e=>D(e,0),Q=e=>D(e,2),E=e=>D(e,4),A=e=>D(e,6),G=e=>D(e,8),j=e=>D(e,10),U=e=>e.toLowerCase();U(r);const W="Transaction";U(W);const{useCallback:z,useEffect:J,useMemo:K,useLayoutEffect:N,useRef:X,useState:Y}=s,Z=[],$={},_=[[],void 0,[]],ee=(e,s,t=Z)=>{const o=K((()=>s(e)),[e,...t]);return J((()=>()=>o.destroy()),[o]),o},se=(e,s,t,o=Z,u,r="get",l="")=>{const[,d]=Y(),n=z((()=>s?.[r+e]?.(...o)??t),[s,e,...o,t]),i=X();return K((()=>i.current=n()),[n]),te(l+e,s,((...e)=>{i.current=m(u)?n():e[u],d([])}),[n,u],o),i.current},te=(e,s,t,o=Z,u=Z,...l)=>N((()=>{const o=s?.["add"+e+r]?.(...u,t,...l);return()=>s?.delListener(o)}),[s,e,...u,...o,...l]),oe=(e,s,t,o=Z,u=V,r=Z,...l)=>{const d=O(e);return z((e=>y(d,(o=>y(t(e,o),(e=>u(o["set"+s](...l,e),e)))))),[d,s,...o,...r,...l])},ue=(e,s,t=V,o=Z,...u)=>{const r=O(e);return z((()=>t(r?.["del"+s](...u))),[r,s,...o,...u])},re=(e,s,t)=>{const o=j(e);return z((()=>o?.[s](t)),[o,s,t])},le=e=>se(I,O(e),Z),de=(e,s)=>se(p,O(s),Z,[e]),ne=(e,s,t,o=0,u,r)=>se(w,O(r),Z,[e,s,t,o,u],6),ie=(e,s,t)=>se(k,O(t),Z,[e,s]),ae=(e,s,t,o)=>se(R,O(o),void 0,[e,s,t],4),ce=e=>se(h,O(e),Z),Ie=(e,s)=>se(g,O(s),void 0,[e]),Ce=(e,s)=>se("Metric",Q(s),void 0,[e]),be=(e,s)=>se("SliceIds",E(s),Z,[e]),pe=(e,s,t)=>se("Slice"+p,E(t),Z,[e,s]),we=(e,s,t)=>se("RemoteRowId",A(t),void 0,[e,s]),Re=(e,s,t)=>se("Local"+p,A(t),Z,[e,s]),ke=(e,s,t)=>se("Linked"+p,A(t),Z,[e,s]),ge=(e,s)=>se(l+p,G(s),Z,[e]),Le=(e,s,t,o=0,u,r)=>se(l+w,G(r),Z,[e,s,t,o,u],6),he=(e,s,t)=>se(l+k,G(t),Z,[e,s]),me=(e,s,t,o)=>se(l+R,G(o),void 0,[e,s,t]),ye=e=>se("CheckpointIds",j(e),_),Te=(e,s)=>se("Checkpoint",j(s),void 0,[e]),Ve=e=>re(e,"goBackward"),Se=e=>re(e,"goForward"),{PureComponent:fe,Fragment:ve,createElement:xe,useCallback:Pe,useLayoutEffect:qe,useRef:Be,useState:He}=s,Me=(e,...s)=>m(e)?{}:e(...s),De=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Fe,useContext:Oe,useMemo:Qe,useState:Ee}=s,Ae=({tableId:e,store:s,rowComponent:t=Je,getRowComponentProps:o,customCellIds:u,separator:r,debugIds:l},d)=>We(S(d,(r=>xe(t,{...Me(o,r),key:r,tableId:e,rowId:r,customCellIds:u,store:s,debugIds:l}))),r,l,e),Ge=({queryId:e,queries:s,resultRowComponent:t=Ze,getResultRowComponentProps:o,separator:u,debugIds:r},l)=>We(S(l,(u=>xe(t,{...Me(o,u),key:u,queryId:e,rowId:u,queries:s,debugIds:r}))),u,r,e),je=({relationshipId:e,relationships:s,rowComponent:t=Je,getRowComponentProps:o,separator:u,debugIds:r},l,d)=>{const[n,i,a]=De(A(s),e),c=l(e,d,n);return We(S(c,(e=>xe(t,{...Me(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:r}))),u,r,d)},Ue=e=>({checkpoints:s,checkpointComponent:t=$e,getCheckpointComponentProps:o,separator:u,debugIds:r})=>{const l=j(s);return We(S(e(ye(l)),(e=>xe(t,{...Me(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:r}))),u)},We=(e,s,t,o)=>{const u=m(s)||!Array.isArray(e)?e:S(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",u,"}"]:u},ze=({tableId:e,rowId:s,cellId:t,store:u,debugIds:r})=>We(o+(ae(e,s,t,u)??o),void 0,r,t),Je=({tableId:e,rowId:s,store:t,cellComponent:o=ze,getCellComponentProps:u,customCellIds:r,separator:l,debugIds:d})=>We(S(((e,s,t,o)=>{const u=ie(s,t,o);return e??u})(r,e,s,t),(r=>xe(o,{...Me(u,r),key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:d}))),l,d,s),Ke=e=>Ae(e,de(e.tableId,e.store)),Ne=({valueId:e,store:s,debugIds:t})=>We(o+(Ie(e,s)??o),void 0,t,e),Xe=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Je,getRowComponentProps:u,separator:r,debugIds:l})=>{const[d,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(E(t),e),a=pe(e,s,d);return We(S(a,(e=>xe(o,{...Me(u,e),key:e,tableId:i,rowId:e,store:n,debugIds:l}))),r,l,s)},Ye=({queryId:e,rowId:s,cellId:t,queries:u,debugIds:r})=>We(o+(me(e,s,t,u)??o),void 0,r,t),Ze=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Ye,getResultCellComponentProps:u,separator:r,debugIds:l})=>We(S(he(e,s,t),(r=>xe(o,{...Me(u,r),key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:l}))),r,l,s),$e=({checkpoints:e,checkpointId:s,debugIds:t})=>We(Te(s,e)??o,void 0,t,s),_e=Ue((e=>e[0])),es=Ue((e=>m(e[1])?[]:[e[1]])),ss=Ue((e=>e[2]));e.BackwardCheckpointsView=_e,e.CellView=ze,e.CheckpointView=$e,e.CurrentCheckpointView=es,e.ForwardCheckpointsView=ss,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Xe,getSliceComponentProps:o,separator:u,debugIds:r})=>We(S(be(e,s),(u=>xe(t,{...Me(o,u),key:u,indexId:e,sliceId:u,indexes:s,debugIds:r}))),u,r,e),e.LinkedRowsView=e=>je(e,ke,e.firstRowId),e.LocalRowsView=e=>je(e,Re,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>We(Ce(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:u,indexesById:r,relationships:l,relationshipsById:d,queries:n,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Oe(H),[b,p]=Ee({}),w=Fe(((e,s)=>p((t=>v(t,e)==s?t:{...t,[e]:s}))),[]),R=Fe((e=>p((s=>({...x(s,e)})))),[]);return xe(H.Provider,{value:Qe((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},u??C[4],{...C[5],...r},l??C[6],{...C[7],...d},n??C[8],{...C[9],...i},a??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,u,r,l,d,n,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Je,getRowComponentProps:u,debugIds:r})=>{const[l,d,,n]=De(A(t),e),i=we(e,s,l);return We(m(n)||m(i)?null:xe(o,{...Me(u,i),key:i,tableId:n,rowId:i,store:d,debugIds:r}),void 0,r,s)},e.ResultCellView=Ye,e.ResultRowView=Ze,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ge(u,Le(u.queryId,e,s,t,o,u.queries)),e.ResultTableView=e=>Ge(e,ge(e.queryId,e.queries)),e.RowView=Je,e.SliceView=Xe,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...u})=>Ae(u,ne(u.tableId,e,s,t,o,u.store)),e.TableView=Ke,e.TablesView=({store:e,tableComponent:s=Ke,getTableComponentProps:t,separator:o,debugIds:u})=>We(S(le(e),(o=>xe(s,{...Me(t,o),key:o,tableId:o,store:e,debugIds:u}))),o),e.ValueView=Ne,e.ValuesView=({store:e,valueComponent:s=Ne,getValueComponentProps:t,separator:o,debugIds:u})=>We(S(ce(e),(o=>xe(s,{...Me(t,o),key:o,valueId:o,store:e,debugIds:u}))),o),e.useAddRowCallback=(e,s,t=Z,o,u=V,r=Z,l=!0)=>{const d=O(o);return z((t=>y(d,(o=>y(s(t,o),(s=>u(o.addRow(e,s,l),o,s)))))),[d,e,...t,...r,l])},e.useCell=ae,e.useCellIds=ie,e.useCellIdsListener=(e,s,t,o,u,r)=>te(k,O(r),t,o,[e,s],u),e.useCellListener=(e,s,t,o,u,r,l)=>te(R,O(l),o,u,[e,s,t],r),e.useCheckpoint=Te,e.useCheckpointIds=ye,e.useCheckpointIdsListener=(e,s,t)=>te("CheckpointIds",j(t),e,s),e.useCheckpointListener=(e,s,t,o)=>te("Checkpoint",j(o),s,t,[e]),e.useCheckpoints=e=>M(e,10),e.useCheckpointsIds=()=>F(11),e.useCheckpointsOrCheckpointsById=j,e.useCreateCheckpoints=(e,s,t)=>ee(e,s,t),e.useCreateIndexes=(e,s,t)=>ee(e,s,t),e.useCreateMetrics=(e,s,t)=>ee(e,s,t),e.useCreatePersister=(e,s,t=Z,o,u=Z,r,l=Z)=>{const[,d]=Y(),n=K((()=>s(e)),[e,...t]);return J((()=>((async()=>{o&&(await o(n),d([]))})(),()=>{n?.destroy(),r?.(n)})),[n,...u,...l]),n},e.useCreateQueries=(e,s,t)=>ee(e,s,t),e.useCreateRelationships=(e,s,t)=>ee(e,s,t),e.useCreateStore=(e,s=Z)=>K(e,s),e.useDelCellCallback=(e,s,t,o,u,r,l)=>ue(u,R,r,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,u)=>ue(t,C,o,u,e,s),e.useDelTableCallback=(e,s,t,o)=>ue(s,a,t,o,e),e.useDelTablesCallback=(e,s,t)=>ue(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>ue(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>ue(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>te("DidFinish"+W,O(t),e,s),e.useGoBackwardCallback=Ve,e.useGoForwardCallback=Se,e.useGoToCallback=(e,s=Z,t,o=V,u=Z)=>{const r=j(t);return z((s=>y(r,(t=>y(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...u])},e.useHasCell=(e,s,t,o)=>se(R,O(o),!1,[e,s,t],4,n,d),e.useHasCellListener=(e,s,t,o,u,r,l)=>te(d+R,O(l),o,u,[e,s,t],r),e.useHasRow=(e,s,t)=>se(C,O(t),!1,[e,s],3,n,d),e.useHasRowListener=(e,s,t,o,u,r)=>te(d+C,O(r),t,o,[e,s],u),e.useHasTable=(e,s)=>se(a,O(s),!1,[e],2,n,d),e.useHasTableCell=(e,s,t)=>se(a+R,O(t),!1,[e,s],3,n,d),e.useHasTableCellListener=(e,s,t,o,u,r)=>te(d+a+R,O(r),t,o,[e,s],u),e.useHasTableListener=(e,s,t,o,u)=>te(d+a,O(u),s,t,[e],o),e.useHasTables=e=>se(c,O(e),!1,[],1,n,d),e.useHasTablesListener=(e,s,t,o)=>te(d+c,O(o),e,s,[],t),e.useHasValue=(e,s)=>se(g,O(s),!1,[e],2,n,d),e.useHasValueListener=(e,s,t,o,u)=>te(d+g,O(u),s,t,[e],o),e.useHasValues=e=>se(L,O(e),!1,[],1,n,d),e.useHasValuesListener=(e,s,t,o)=>te(d+L,O(o),e,s,[],t),e.useIndexIds=e=>se("IndexIds",E(e),Z),e.useIndexes=e=>M(e,4),e.useIndexesIds=()=>F(5),e.useIndexesOrIndexesById=E,e.useLinkedRowIds=ke,e.useLinkedRowIdsListener=(e,s,t,o,u)=>te("Linked"+p,A(u),t,o,[e,s]),e.useLocalRowIds=Re,e.useLocalRowIdsListener=(e,s,t,o,u)=>te("Local"+p,A(u),t,o,[e,s]),e.useMetric=Ce,e.useMetricIds=e=>se("MetricIds",Q(e),Z),e.useMetricListener=(e,s,t,o)=>te("Metric",Q(o),s,t,[e]),e.useMetrics=e=>M(e,2),e.useMetricsIds=()=>F(3),e.useMetricsOrMetricsById=Q,e.useProvideStore=(e,s)=>{const{12:t,13:o}=q(H);B((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>M(e,8),e.useQueriesIds=()=>F(9),e.useQueriesOrQueriesById=G,e.useQueryIds=e=>se("QueryIds",G(e),Z),e.useRedoInformation=e=>{const s=j(e),[,,[t]]=ye(s);return[!m(t),Se(s),t,y(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>se("RelationshipIds",A(e),Z),e.useRelationships=e=>M(e,6),e.useRelationshipsIds=()=>F(7),e.useRelationshipsOrRelationshipsById=A,e.useRemoteRowId=we,e.useRemoteRowIdListener=(e,s,t,o,u)=>te("RemoteRowId",A(u),t,o,[e,s]),e.useResultCell=me,e.useResultCellIds=he,e.useResultCellIdsListener=(e,s,t,o,u)=>te(l+k,G(u),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,u,r)=>te(l+R,G(r),o,u,[e,s,t]),e.useResultRow=(e,s,t)=>se(l+C,G(t),$,[e,s]),e.useResultRowCount=(e,s)=>se(l+b,G(s),0,[e]),e.useResultRowCountListener=(e,s,t,o)=>te(l+b,G(o),s,t,[e]),e.useResultRowIds=ge,e.useResultRowIdsListener=(e,s,t,o)=>te(l+p,G(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,u)=>te(l+C,G(u),t,o,[e,s]),e.useResultSortedRowIds=Le,e.useResultSortedRowIdsListener=(e,s,t,o,u,r,d,n)=>te(l+w,G(n),r,d,[e,s,t,o,u]),e.useResultTable=(e,s)=>se(l+a,G(s),$,[e]),e.useResultTableCellIds=(e,s)=>se(l+a+k,G(s),Z,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>te(l+a+k,G(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>te(l+a,G(o),s,t,[e]),e.useRow=(e,s,t)=>se(C,O(t),$,[e,s]),e.useRowCount=(e,s)=>se(b,O(s),0,[e]),e.useRowCountListener=(e,s,t,o,u)=>te(b,O(u),s,t,[e],o),e.useRowIds=de,e.useRowIdsListener=(e,s,t,o,u)=>te(p,O(u),s,t,[e],o),e.useRowListener=(e,s,t,o,u,r)=>te(C,O(r),t,o,[e,s],u),e.useSetCellCallback=(e,s,t,o,u,r,l,d)=>oe(r,R,o,u,l,d,e,s,t),e.useSetCheckpointCallback=(e=V,s=Z,t,o=V,u=Z)=>{const r=j(t);return z((s=>y(r,(t=>{const u=e(s);o(t.addCheckpoint(u),t,u)}))),[r,...s,...u])},e.useSetPartialRowCallback=(e,s,t,o,u,r,l)=>oe(u,"PartialRow",t,o,r,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,u)=>oe(t,"PartialValues",e,s,o,u),e.useSetRowCallback=(e,s,t,o,u,r,l)=>oe(u,C,t,o,r,l,e,s),e.useSetTableCallback=(e,s,t,o,u,r)=>oe(o,a,s,t,u,r,e),e.useSetTablesCallback=(e,s,t,o,u)=>oe(t,c,e,s,o,u),e.useSetValueCallback=(e,s,t,o,u,r)=>oe(o,g,s,t,u,r,e),e.useSetValuesCallback=(e,s,t,o,u)=>oe(t,L,e,s,o,u),e.useSliceIds=be,e.useSliceIdsListener=(e,s,t,o)=>te("SliceIds",E(o),s,t,[e]),e.useSliceRowIds=pe,e.useSliceRowIdsListener=(e,s,t,o,u)=>te("Slice"+p,E(u),t,o,[e,s]),e.useSortedRowIds=ne,e.useSortedRowIdsListener=(e,s,t,o,u,r,l,d,n)=>te(w,O(n),r,l,[e,s,t,o,u],d),e.useStartTransactionListener=(e,s,t)=>te("Start"+W,O(t),e,s),e.useStore=e=>M(e,0),e.useStoreIds=()=>F(1),e.useStoreOrStoreById=O,e.useTable=(e,s)=>se(a,O(s),$,[e]),e.useTableCellIds=(e,s)=>se(a+k,O(s),Z,[e]),e.useTableCellIdsListener=(e,s,t,o,u)=>te(a+k,O(u),s,t,[e],o),e.useTableIds=le,e.useTableIdsListener=(e,s,t,o)=>te(I,O(o),e,s,Z,t),e.useTableListener=(e,s,t,o,u)=>te(a,O(u),s,t,[e],o),e.useTables=e=>se(c,O(e),$),e.useTablesListener=(e,s,t,o)=>te(c,O(o),e,s,Z,t),e.useUndoInformation=e=>{const s=j(e),[t,u]=ye(s);return[(r=t,!(0==r.length)),Ve(s),u,y(u,(e=>s?.getCheckpoint(e)))??o];var r},e.useValue=Ie,e.useValueIds=ce,e.useValueIdsListener=(e,s,t,o)=>te(h,O(o),e,s,Z,t),e.useValueListener=(e,s,t,o,u)=>te(g,O(u),s,t,[e],o),e.useValues=e=>se(L,O(e),$),e.useValuesListener=(e,s,t,o)=>te(L,O(o),e,s,Z,t),e.useWillFinishTransactionListener=(e,s,t)=>te("WillFinish"+W,O(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
@@ -0,0 +1 @@
1
+ var e,n;e=this,n=function(e,n){"use strict";const t=e=>typeof e,l="tinybase",o=",",i=t(""),r=(e,n)=>e.repeat(n),u=Promise,d=setInterval,a=clearInterval,s=e=>null==e,c=(e,n,t)=>s(e)?null==t?void 0:t():n(e),v=e=>t(e)==i,y=(e,n,t)=>e.slice(n,t),f=e=>e.length,p=e=>{return n=function*(){return u.all(e)},new Promise(((e,t)=>{var l=e=>{try{i(n.next(e))}catch(e){t(e)}},o=e=>{try{i(n.throw(e))}catch(e){t(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);i((n=n.apply(void 0,null)).next())}));var n},h=(e,n="")=>e.join(n),E=(e,n)=>e.map(n),m=e=>0==f(e),T=(e,n)=>e.filter(n),x=(e,...n)=>e.push(...n),b=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},P=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},A=(e,n)=>null==e?void 0:e.delete(n),L=Object,O=e=>L.getPrototypeOf(e),N=L.keys,w=L.freeze,g=(e=[])=>L.fromEntries(e),R=(...e)=>L.assign({},...e),S=(e,n)=>E(L.entries(e),(([e,t])=>n(t,e))),C=e=>L.values(e),D=e=>f(N(e)),I=e=>(e=>!s(e)&&c(O(e),(e=>e==L.prototype||s(O(e))),(()=>!0)))(e)&&0==D(e),F=e=>new Map(e),M=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},$=(e,n)=>null==e?void 0:e.get(n),j=(e,n)=>{var t;return E([...null!=(t=null==e?void 0:e.entries())?t:[]],(([e,t])=>n(t,e)))},_=(e,n,t)=>s(t)?(A(e,n),e):null==e?void 0:e.set(n,t),q=(e,n,t)=>(b(e,n)||_(e,n,t()),$(e,n)),B=(e,n,t,l=_)=>(S(n,((n,l)=>t(e,l,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,t)=>n(t)))})(e,(t=>((e,n)=>!s(((e,n)=>c(e,(e=>e[n])))(e,n)))(n,t)?0:l(e,t))),e),H=e=>new Set(Array.isArray(e)||s(e)?e:[e]),W=(e,n)=>null==e?void 0:e.add(n),k="_",J="_id",U=e=>`"${e.replace(/"/g,'""')}"`;var Y=Object.defineProperty,z=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(e,n,t)=>n in e?Y(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Q=(e,n)=>{for(var t in n||(n={}))G.call(n,t)&&V(e,t,n[t]);if(z)for(var t of z(n))K.call(n,t)&&V(e,t,n[t]);return e},X=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const Z="FROM pragma_table_",ee="WHERE",ne=(e,n,t)=>{const l=F();return[()=>X(void 0,null,(function*(){return B(l,g(yield p(E(yield e("SELECT name "+Z+"list WHERE schema='main'AND type='table'AND name IN("+le(n)+")",n),(n=>X(void 0,[n],(function*({name:n}){return[n,g(E(yield e("SELECT name,type "+Z+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,t)=>_(l,n,B(q(l,n,F),t,((e,n,t)=>{t!=$(e,n)&&_(e,n,t)}),((e,n)=>_(e,n))))),((e,n)=>_(l,n)))})),(n,t)=>X(void 0,null,(function*(){return((e,n)=>!s($($(l,e),n)))(n,t)?g(T(E(yield e("SELECT*FROM"+U(n)),(e=>{return[e[t],(n=Q({},e),l=t,delete n[l],n)];var n,l})),(([e,n])=>!s(e)&&!I(n)))):{}})),(n,t,i,r,u,d=!1)=>X(void 0,null,(function*(){const a=H();S(null!=i?i:{},(e=>E(N(null!=e?e:{}),(e=>W(a,e)))));const c=P(a);if(!d&&u&&m(c)&&b(l,n))return yield e("DROP TABLE"+U(n)),void _(l,n);if(m(c)||b(l,n)){const o=$(l,n),i=H(M(o));yield p([...E(c,(t=>X(void 0,null,(function*(){A(i,t)||(yield e(`ALTER TABLE${U(n)}ADD${U(t)}`),_(o,t,""))})))),...!d&&r?E(P(i),(l=>X(void 0,null,(function*(){l!=t&&(yield e(`ALTER TABLE${U(n)}DROP${U(l)}`),_(o,l))})))):[]])}else yield e(`CREATE TABLE${U(n)}(${U(t)} PRIMARY KEY ON CONFLICT REPLACE${h(E(c,(e=>o+U(e))))});`),_(l,n,F([[t,""],...E(c,(e=>[e,""]))]));if(d)s(i)?yield e("DELETE FROM"+U(n)+"WHERE 1"):yield p(S(i,((l,o)=>X(void 0,null,(function*(){s(l)?yield e("DELETE FROM"+U(n)+ee+U(t)+"=?",[o]):m(c)||(yield te(e,n,t,N(l),[o,...C(l)]))})))));else if(m(c))b(l,n)&&(yield e("DELETE FROM"+U(n)+"WHERE 1"));else{const o=T(M($(l,n)),(e=>e!=t)),r=[],u=[];S(null!=i?i:{},((e,n)=>{x(r,n,...E(o,(n=>null==e?void 0:e[n]))),x(u,n)})),yield te(e,n,t,o,r),yield e("DELETE FROM"+U(n)+ee+U(t)+"NOT IN("+le(u)+")",u)}})),n=>X(void 0,null,(function*(){let l;yield e("BEGIN");try{l=yield n()}catch(e){null==t||t(e)}return yield e("END"),l}))]},te=(e,n,t,l,i)=>X(void 0,null,(function*(){return yield e("INSERT INTO"+U(n)+"("+U(t)+h(E(l,(e=>o+U(e))))+")VALUES"+y(r(`,(?${r(",?",f(l))})`,f(i)/(f(l)+1)),1)+"ON CONFLICT("+U(t)+")DO UPDATE SET"+h(E(l,(e=>U(e)+"=excluded."+U(e))),o),i)})),le=e=>h(E(e,(()=>"?")),o),oe=JSON.parse;var ie=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const re=F(),ue=F(),de=(e,n,t,l,o,i,[r,u]=[],d=[])=>{let a,v,y,f=0,p=0;q(re,d,(()=>0)),q(ue,d,(()=>[]));const h=e=>ie(void 0,null,(function*(){return 2!=f&&(f=1,yield E.schedule((()=>ie(void 0,null,(function*(){yield e(),f=0}))))),E})),E={load:(t,l)=>ie(void 0,null,(function*(){return yield h((()=>ie(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([t,l])}}))))})),startAutoLoad:(...t)=>ie(void 0,[...t],(function*(t={},o={}){return E.stopAutoLoad(),yield E.load(t,o),p=1,y=l(((t,l)=>ie(void 0,null,(function*(){if(l){const n=l();yield h((()=>ie(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>ie(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==t?void 0:t())?l:yield n())}catch(e){null==i||i(e)}}))))})))),E})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),E),save:n=>ie(void 0,null,(function*(){return 1!=f&&(f=2,yield E.schedule((()=>ie(void 0,null,(function*(){try{yield t(e.getContent,n)}catch(e){null==i||i(e)}f=0}))))),E})),startAutoSave:()=>ie(void 0,null,(function*(){return yield E.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,n)=>{const[t,l]=n();I(t)&&I(l)||E.save((()=>[t,l]))})),E})),stopAutoSave:()=>(c(a,e.delListener),a=void 0,E),schedule:(...e)=>ie(void 0,null,(function*(){return x($(ue,d),...e),yield ie(void 0,null,(function*(){if(!$(re,d)){for(_(re,d,1);!s((e=$(ue,d),v=e.shift()));)try{yield v()}catch(e){null==i||i(e)}_(re,d,0)}var e})),E})),getStore:()=>e,destroy:()=>E.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return r&&(E[r]=()=>u),w(E)};var ae=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const se="store",ce=(e,n,t,l,o,[i],r,u)=>{const[d,a,s,c]=ne(n,r,o);return de(e,(()=>ae(void 0,null,(function*(){return yield c((()=>ae(void 0,null,(function*(){var e,n;return yield d(),oe(null!=(n=null==(e=(yield a(i,J))[k])?void 0:e[se])?n:"null")}))))}))),(e=>ae(void 0,null,(function*(){return yield c((()=>ae(void 0,null,(function*(){var n,t;yield d(),yield s(i,J,{[k]:{[se]:(t=null!=(n=e())?n:null,JSON.stringify(t,((e,n)=>n instanceof Map?L.fromEntries([...n]):n)))}},!0,!0)}))))}))),t,l,o,["getDb",u],u)};var ve=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const ye=(e,n,t,l,o,[i,r,[u,d,a]],c,v)=>{const[y,f,h,E]=ne(n,c,o),m=(e,n)=>ve(void 0,null,(function*(){return yield p(j(r,((t,l)=>ve(void 0,[t,l],(function*([t,l,o,i],r){const u=e[r];n&&void 0===u||(yield h(t,l,u,o,i,n))})))))})),x=(e,n)=>ve(void 0,null,(function*(){return d?yield h(a,J,{[k]:e},!0,!0,n):null}));return de(e,(()=>ve(void 0,null,(function*(){return yield E((()=>ve(void 0,null,(function*(){yield y();const e=yield ve(void 0,null,(function*(){return g(T(yield p(j(i,((e,n)=>ve(void 0,[e,n],(function*([e,n],t){return[e,yield f(t,n)]}))))),(e=>!I(e[1]))))})),n=yield ve(void 0,null,(function*(){return u?(yield f(a,J))[k]:{}}));return I(e)&&s(n)?void 0:[e,n]}))))}))),((e,n)=>ve(void 0,null,(function*(){return yield E((()=>ve(void 0,null,(function*(){if(yield y(),s(n)){const[n,t]=e();yield m(n),yield x(t)}else{const[e,t]=n();yield m(e,!0),yield x(t,!0)}}))))}))),t,l,o,["getDb",v],v)},fe="json",pe="autoLoadIntervalSeconds",he="rowIdColumnName",Ee="tableId",me="tableName",Te={mode:fe,[pe]:1},xe={load:0,save:0,[me]:l+"_values"},be=(e,n,t,l)=>{const o=F();return S(e,((e,i)=>{const r=y(C(R(n,v(e)?{[t]:e}:e)),0,D(n));s(r[0])||l(i,r[0])||_(o,i,r)})),o};var Pe=(e,n,t)=>new Promise(((l,o)=>{var i=e=>{try{u(t.next(e))}catch(e){o(e)}},r=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);u((t=t.apply(e,n)).next())}));const Ae="pragma ",Le="data_version",Oe="schema_version",Ne=(e,n,t,o,i,r,u,s)=>{let c,f;const[p,h,E,m]=(e=>{const n=(e=>R(Te,v(e)?{storeTableName:e}:null!=e?e:{}))(e),t=n[pe];if(n.mode==fe){const{storeTableName:e=l}=n;return[1,t,[e],H(e)]}const{tables:{load:o={},save:i={}}={},values:r={}}=n,u=y(C(R(xe,r)),0,D(xe)),d=u[2],a=H(d);return[0,t,[be(o,{[Ee]:null,[he]:J},Ee,(e=>W(a,e)&&e==d)),be(i,{[me]:null,[he]:J,deleteEmptyColumns:0,deleteEmptyTable:0},me,((e,n)=>W(a,n)&&n==d)),u],a]})(n);return(p?ce:ye)(e,r?(e,n)=>Pe(void 0,null,(function*(){return r(e,n),yield t(e,n)})):t,(e=>[d((()=>Pe(void 0,null,(function*(){try{const n=(yield t(Ae+Le))[0][Le],l=(yield t(Ae+Oe))[0][Oe];n==(null!=c?c:c=n)&&l==(null!=f?f:f=l)||(e(),c=n,f=l)}catch(e){}}))),1e3*h),o((n=>m.has(n)?e():0))]),(([e,n])=>{a(e),c=f=null,i(n)}),u,E,P(m),s)};e.createExpoSqliteNextPersister=(e,t,l,o,i)=>Ne(e,l,((e,...n)=>{return l=[e,...n],o=function*(e,n=[]){return yield t.allAsync(e,n)},new Promise(((e,n)=>{var t=e=>{try{r(o.next(e))}catch(e){n(e)}},i=e=>{try{r(o.throw(e))}catch(e){n(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,i);r((o=o.apply(void 0,l)).next())}));var l,o}),(e=>n.addDatabaseChangeListener((({tableName:n})=>e(n)))),(e=>e.remove()),o,i,t)},"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("expo-sqlite/next")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite/next"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterExpoSqliteNext={},e["expo-sqlite/next"]);
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",r=t(n),l="t",i=(e,t)=>e.startsWith(t),o=Promise,s=e=>null==e,a=(e,t,n)=>s(e)?null==n?void 0:n():t(e),u=(e,t,n)=>e.slice(t,n),c=e=>e.length,d=e=>{return t=function*(){return o.all(e)},new Promise(((e,n)=>{var r=e=>{try{i(t.next(e))}catch(e){n(e)}},l=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,l);i((t=t.apply(void 0,null)).next())}));var t},f=(e,t)=>e.map(t),h=(e,...t)=>e.push(...t),y=Object,v=(e=[])=>y.fromEntries(e),p=(e,t)=>f(y.entries(e),(([e,n])=>t(n,e))),g=(e,t,n)=>(((e,t)=>!s(((e,t)=>a(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),P=e=>JSON.stringify(e,((e,t)=>t instanceof Map?y.fromEntries([...t]):t)),S=JSON.parse,m=(e,n,l)=>e+n+(t(l)==r?l:P(l)),x=(e,t,n)=>{const r=c(e);return i(t,e)?[t[r],(n?S:String)(u(t,r+1))]:void 0},w=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var b=(e,t,n)=>new Promise(((r,l)=>{var i=e=>{try{s(n.next(e))}catch(e){l(e)}},o=e=>{try{s(n.throw(e))}catch(e){l(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,o);s((n=n.apply(e,t)).next())}));const T="hasStore",D=v(f(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),R=e=>b(void 0,null,(function*(){var t;return yield e.party.storage.get((null!=(t=e.config.storagePrefix)?t:n)+T)})),C=(e,t,r,o)=>b(void 0,null,(function*(){var a;const u=e.party.storage,f=null!=(a=e.config.storagePrefix)?a:n,y={[f+T]:1},v=[],g=[];yield d(p(t[0],((t,n)=>b(void 0,null,(function*(){return s(t)?!r&&e.canDelTable(n,o)&&((e,...t)=>e.unshift(...t))(g,O(f,l,n)):e.canSetTable(n,r,o)&&(yield d(p(t,((t,i)=>b(void 0,null,(function*(){return s(t)?!r&&e.canDelRow(n,i,o)&&h(g,O(f,l,n,i)):e.canSetRow(n,i,r,o)&&(yield d(p(t,((t,a)=>b(void 0,null,(function*(){const c=[n,i,a],d=O(f,l,...c);s(t)?!r&&e.canDelCell(...c,o)&&h(v,d):e.canSetCell(...c,t,r,o,yield u.get(d))&&(y[d]=t)}))))))}))))))}))))),yield d(p(t[1],((t,n)=>b(void 0,null,(function*(){const l=f+"v"+n;s(t)?!r&&e.canDelValue(n,o)&&h(v,l):e.canSetValue(n,t,r,o,yield u.get(l))&&(y[l]=t)}))))),0!=c(g)&&w(yield u.list(),(e=>g.every((t=>!i(e,t)||h(v,e)&&0)))),yield u.delete(v),yield u.put(y)})),O=(e,t,...n)=>m(e,t,u(P(n),1,-1)),V=(e,t,n=null)=>b(void 0,null,(function*(){var r;return new Response(n,{status:t,headers:null!=(r=e.config.responseHeaders)?r:D})}));e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={}}onRequest(e){return b(this,null,(function*(){var t;const r=null!=(t=this.config.storePath)?t:"/store";if(new URL(e.url).pathname.endsWith(r)){const t=yield R(this),r=yield e.text();return"PUT"==e.method?t?V(this,205):(yield C(this,S(r),!0,e),V(this,201)):V(this,200,t?P(yield(i=this,b(void 0,null,(function*(){var e;const t={},r={},o=null!=(e=i.config.storagePrefix)?e:n;return w(yield i.party.storage.list(),((e,n)=>a(x(o,e),(([e,i])=>{if(e==l){const[e,r,l]=S("["+i+"]");g(g(t,e,v),r,v)[l]=n}else"v"==e&&(r[i]=n)})))),[t,r]})))):n)}var i;return V(this,404)}))}onMessage(e,t){return b(this,null,(function*(){var r;const l=null!=(r=this.config.messagePrefix)?r:n;yield a(x(l,e,1),(e=>b(this,[e],(function*([e,n]){"s"==e&&(yield R(this))&&(yield C(this,n,!1,t),this.party.broadcast(m(l,"s",n)))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,l,i,o){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r,l){return!0}canDelValue(e,t){return!0}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),r="t",i=(e,t)=>e.startsWith(t),o=Promise,s=e=>null==e,l=(e,t,n)=>s(e)?null==n?void 0:n():t(e),a=(e,t,n)=>e.slice(t,n),c=e=>e.length,u=e=>{return t=function*(){return o.all(e)},new Promise(((e,n)=>{var r=e=>{try{o(t.next(e))}catch(e){n(e)}},i=e=>{try{o(t.throw(e))}catch(e){n(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,i);o((t=t.apply(void 0,null)).next())}));var t},d=(e,t)=>e.map(t),f=(e,...t)=>e.push(...t),h=Object,y=(e=[])=>h.fromEntries(e),g=(e,t)=>d(h.entries(e),(([e,n])=>t(n,e))),v=(e,t,n)=>(((e,t)=>!s(((e,t)=>l(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),p=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),P=JSON.parse,S=(e,r,i)=>e+r+(t(i)==n?i:p(i)),m=(e,t,n)=>{const r=c(e);return i(t,e)?[t[r],(n?P:String)(a(t,r+1))]:void 0},x=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var w=(e,t,n)=>new Promise(((r,i)=>{var o=e=>{try{l(n.next(e))}catch(e){i(e)}},s=e=>{try{l(n.throw(e))}catch(e){i(e)}},l=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,s);l((n=n.apply(e,t)).next())}));const b="hasStore",T=y(d(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=(e,...t)=>w(void 0,[e,...t],(function*(e,t=""){return!!(yield e.get(t+b))})),R=(e,...t)=>w(void 0,[e,...t],(function*(e,t=""){const n={},i={};return x(yield e.list(),((e,o)=>l(m(t,e),(([e,t])=>{if(e==r){const[e,r,i]=P("["+t+"]");v(v(n,e,y),r,y)[i]=o}else"v"==e&&(i[t]=o)})))),[n,i]})),C=(e,t,n,o)=>w(void 0,null,(function*(){const l=e.party.storage,a=e.config.storagePrefix,d={[a+b]:1},h=[],y=[];yield u(g(t[0],((t,i)=>w(void 0,null,(function*(){return s(t)?!n&&e.canDelTable(i,o)&&((e,...t)=>e.unshift(...t))(y,H(a,r,i)):e.canSetTable(i,n,o)&&(yield u(g(t,((t,c)=>w(void 0,null,(function*(){return s(t)?!n&&e.canDelRow(i,c,o)&&f(y,H(a,r,i,c)):e.canSetRow(i,c,n,o)&&(yield u(g(t,((t,u)=>w(void 0,null,(function*(){const y=[i,c,u],g=H(a,r,...y);s(t)?!n&&e.canDelCell(...y,o)&&f(h,g):e.canSetCell(...y,t,n,o,yield l.get(g))&&(d[g]=t)}))))))}))))))}))))),yield u(g(t[1],((t,r)=>w(void 0,null,(function*(){const i=a+"v"+r;s(t)?!n&&e.canDelValue(r,o)&&f(h,i):e.canSetValue(r,t,n,o,yield l.get(i))&&(d[i]=t)}))))),0!=c(y)&&x(yield l.list(),(e=>y.every((t=>!i(e,t)||f(h,e)&&0)))),yield l.delete(h),yield l.put(d)})),H=(e,t,...n)=>S(e,t,a(p(n),1,-1)),O=(e,t,n=null)=>w(void 0,null,(function*(){return new Response(n,{status:t,headers:e.config.responseHeaders})}));e.TinyBasePartyKitServer=class{constructor(e){var t,n,r,i;this.party=e,this.config={},null!=(t=this.config).storePath||(t.storePath="/store"),null!=(n=this.config).messagePrefix||(n.messagePrefix=""),null!=(r=this.config).storagePrefix||(r.storagePrefix=""),null!=(i=this.config).responseHeaders||(i.responseHeaders=T)}onRequest(e){return w(this,null,(function*(){const{party:{storage:t},config:{storePath:n,storagePrefix:r}}=this;if(new URL(e.url).pathname.endsWith(n)){const n=yield D(t,r),i=yield e.text();return"PUT"==e.method?n?O(this,205):(yield C(this,P(i),!0,e),O(this,201)):O(this,200,n?p(yield R(t,r)):"")}return O(this,404)}))}onMessage(e,t){return w(this,null,(function*(){const{party:{storage:n,broadcast:r},config:{messagePrefix:i,storagePrefix:o}}=this;yield l(m(i,e,1),(e=>w(this,[e],(function*([e,s]){"s"==e&&(yield D(n,o))&&(yield C(this,s,!1,t),r(S(i,"s",s),[t.id]))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,i,o,s){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r,i){return!0}canDelValue(e,t){return!0}},e.hasStoreInStorage=D,e.loadStoreFromStorage=R},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r="Listener",u="Result",n="Has",d="has",i="Ids",a="Table",c=a+"s",I=a+i,p="Row",C=p+"Count",b=p+i,w="Sorted"+p+i,R="Cell",k=R+i,v="Value",g=v+"s",h=v+i,y=e=>null==e,m=(e,s,t)=>y(e)?null==t?void 0:t():s(e),L=e=>t(e)==o,f=()=>{},T=(e,s)=>e.map(s),V=Object.keys,{createContext:S,useContext:x}=s,P=S([]),O=(e,s)=>{var t;const l=x(P);return y(e)?l[s]:L(e)?((e,s)=>m(e,(e=>e[s])))(null!=(t=l[s+1])?t:{},e):e},q=(e,s)=>{const t=O(e,s);return y(e)||L(e)?t:e},B=e=>{var s;return V(null!=(s=x(P)[e])?s:{})},H=e=>q(e,0),M=e=>q(e,2),D=e=>q(e,4),j=e=>q(e,6),F=e=>q(e,8),Q=e=>q(e,10),E=e=>e.toLowerCase();E(r);const A="Transaction";E(A);const{useCallback:G,useEffect:U,useMemo:W,useLayoutEffect:z,useRef:J,useState:K}=s,N=[],X={},Y=[[],void 0,[]],Z=(e,s,t=N)=>{const l=W((()=>s(e)),[e,...t]);return U((()=>()=>l.destroy()),[l]),l},$=(e,s,t,l=N,o,r="get",u="")=>{const[,n]=K(),d=G((()=>{var o,u;return null!=(u=null==(o=null==s?void 0:s[r+e])?void 0:o.call(s,...l))?u:t}),[s,e,...l,t]),i=J();return W((()=>i.current=d()),[d]),_(u+e,s,((...e)=>{i.current=y(o)?d():e[o],n([])}),[d,o],l),i.current},_=(e,s,t,l=N,o=N,...u)=>z((()=>{var l;const n=null==(l=null==s?void 0:s["add"+e+r])?void 0:l.call(s,...o,t,...u);return()=>null==s?void 0:s.delListener(n)}),[s,e,...o,...l,...u]),ee=(e,s,t,l=N,o=f,r=N,...u)=>{const n=H(e);return G((e=>m(n,(l=>m(t(e,l),(e=>o(l["set"+s](...u,e),e)))))),[n,s,...l,...r,...u])},se=(e,s,t=f,l=N,...o)=>{const r=H(e);return G((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},te=(e,s,t)=>{const l=Q(e);return G((()=>null==l?void 0:l[s](t)),[l,s,t])},le=e=>$(I,H(e),N),oe=(e,s)=>$(b,H(s),N,[e]),re=(e,s,t,l=0,o,r)=>$(w,H(r),N,[e,s,t,l,o],6),ue=(e,s,t)=>$(k,H(t),N,[e,s]),ne=(e,s,t,l)=>$(R,H(l),void 0,[e,s,t],4),de=e=>$(h,H(e),N),ie=(e,s)=>$(v,H(s),void 0,[e]),ae=(e,s)=>$("Metric",M(s),void 0,[e]),ce=(e,s)=>$("SliceIds",D(s),N,[e]),Ie=(e,s,t)=>$("Slice"+b,D(t),N,[e,s]),pe=(e,s,t)=>$("RemoteRowId",j(t),void 0,[e,s]),Ce=(e,s,t)=>$("Local"+b,j(t),N,[e,s]),be=(e,s,t)=>$("Linked"+b,j(t),N,[e,s]),we=(e,s)=>$(u+b,F(s),N,[e]),Re=(e,s,t,l=0,o,r)=>$(u+w,F(r),N,[e,s,t,l,o],6),ke=(e,s,t)=>$(u+k,F(t),N,[e,s]),ve=(e,s,t,l)=>$(u+R,F(l),void 0,[e,s,t]),ge=e=>$("CheckpointIds",Q(e),Y),he=(e,s)=>$("Checkpoint",Q(s),void 0,[e]),ye=e=>te(e,"goBackward"),me=e=>te(e,"goForward"),{PureComponent:Le,Fragment:fe,createElement:Te,useCallback:Ve,useLayoutEffect:Se,useRef:xe,useState:Pe}=s,Oe=(e,...s)=>y(e)?{}:e(...s),qe=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var Be=Object.defineProperty,He=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,De=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable,Qe=(e,s,t)=>s in e?Be(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Ee=(e,s)=>{for(var t in s||(s={}))je.call(s,t)&&Qe(e,t,s[t]);if(De)for(var t of De(s))Fe.call(s,t)&&Qe(e,t,s[t]);return e},Ae=(e,s)=>He(e,Me(s)),Ge=(e,s)=>{var t={};for(var l in e)je.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&De)for(var l of De(e))s.indexOf(l)<0&&Fe.call(e,l)&&(t[l]=e[l]);return t};const{useMemo:Ue}=s,We=({tableId:e,store:s,rowComponent:t=Ye,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>Ne(T(n,(r=>Te(t,Ae(Ee({},Oe(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),ze=({queryId:e,queries:s,resultRowComponent:t=ss,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Ne(T(u,(o=>Te(t,Ae(Ee({},Oe(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),Je=({relationshipId:e,relationships:s,rowComponent:t=Ye,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=qe(j(s),e),c=u(e,n,d);return Ne(T(c,(e=>Te(t,Ae(Ee({},Oe(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},Ke=e=>({checkpoints:s,checkpointComponent:t=ts,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=Q(s);return Ne(T(e(ge(u)),(e=>Te(t,Ae(Ee({},Oe(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Ne=(e,s,t,l)=>{const o=y(s)||!Array.isArray(e)?e:T(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},Xe=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Ne(l+(null!=(u=ne(e,s,t,o))?u:l),void 0,r,t)},Ye=({tableId:e,rowId:s,store:t,cellComponent:l=Xe,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>Ne(T(((e,s,t,l)=>{const o=ue(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Te(l,Ae(Ee({},Oe(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),Ze=e=>We(e,oe(e.tableId,e.store)),$e=({valueId:e,store:s,debugIds:t})=>{var o;return Ne(l+(null!=(o=ie(e,s))?o:l),void 0,t,e)},_e=({indexId:e,sliceId:s,indexes:t,rowComponent:l=Ye,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(D(t),e),a=Ie(e,s,n);return Ne(T(a,(e=>Te(l,Ae(Ee({},Oe(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},es=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Ne(l+(null!=(u=ve(e,s,t,o))?u:l),void 0,r,t)},ss=({queryId:e,rowId:s,queries:t,resultCellComponent:l=es,getResultCellComponentProps:o,separator:r,debugIds:u})=>Ne(T(ke(e,s,t),(r=>Te(l,Ae(Ee({},Oe(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),ts=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Ne(null!=(o=he(s,e))?o:l,void 0,t,s)},ls=Ke((e=>e[0])),os=Ke((e=>y(e[1])?[]:[e[1]])),rs=Ke((e=>e[2]));e.BackwardCheckpointsView=ls,e.CellView=Xe,e.CheckpointView=ts,e.CurrentCheckpointView=os,e.ForwardCheckpointsView=rs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=_e,getSliceComponentProps:l,separator:o,debugIds:r})=>Ne(T(ce(e,s),(o=>Te(t,Ae(Ee({},Oe(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>Je(e,be,e.firstRowId),e.LocalRowsView=e=>Je(e,Ce,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Ne(null!=(o=ae(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:l,metricsById:o,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:p})=>{const C=s.useContext(P);return Te(P.Provider,{value:Ue((()=>[null!=e?e:C[0],Ee(Ee({},C[1]),t),null!=l?l:C[2],Ee(Ee({},C[3]),o),null!=r?r:C[4],Ee(Ee({},C[5]),u),null!=n?n:C[6],Ee(Ee({},C[7]),d),null!=i?i:C[8],Ee(Ee({},C[9]),a),null!=c?c:C[10],Ee(Ee({},C[11]),I)]),[e,t,l,o,r,u,n,d,i,a,c,I,C])},p)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=Ye,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=qe(j(t),e),i=pe(e,s,u);return Ne(y(d)||y(i)?null:Te(l,Ae(Ee({},Oe(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=es,e.ResultRowView=ss,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=Ge(s,["cellId","descending","offset","limit"]);return ze(u,Re(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>ze(e,we(e.queryId,e.queries)),e.RowView=Ye,e.SliceView=_e,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=Ge(s,["cellId","descending","offset","limit"]);return We(u,re(u.tableId,t,l,o,r,u.store))},e.TableView=Ze,e.TablesView=({store:e,tableComponent:s=Ze,getTableComponentProps:t,separator:l,debugIds:o})=>Ne(T(le(e),(l=>Te(s,Ae(Ee({},Oe(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=$e,e.ValuesView=({store:e,valueComponent:s=$e,getValueComponentProps:t,separator:l,debugIds:o})=>Ne(T(de(e),(l=>Te(s,Ae(Ee({},Oe(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=N,l,o=f,r=N,u=!0)=>{const n=H(l);return G((t=>m(n,(l=>m(s(t,l),(s=>o(l.addRow(e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=ne,e.useCellIds=ue,e.useCellIdsListener=(e,s,t,l,o,r)=>_(k,H(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>_(R,H(u),l,o,[e,s,t],r),e.useCheckpoint=he,e.useCheckpointIds=ge,e.useCheckpointIdsListener=(e,s,t)=>_("CheckpointIds",Q(t),e,s),e.useCheckpointListener=(e,s,t,l)=>_("Checkpoint",Q(l),s,t,[e]),e.useCheckpoints=e=>O(e,10),e.useCheckpointsIds=()=>B(11),e.useCheckpointsOrCheckpointsById=Q,e.useCreateCheckpoints=(e,s,t)=>Z(e,s,t),e.useCreateIndexes=(e,s,t)=>Z(e,s,t),e.useCreateMetrics=(e,s,t)=>Z(e,s,t),e.useCreatePersister=(e,s,t=N,l,o=N,r,u=N)=>{const[,n]=K(),d=W((()=>s(e)),[e,...t]);return U((()=>{var e;return e=function*(){l&&(yield l(d),n([]))},new Promise(((s,t)=>{var l=s=>{try{r(e.next(s))}catch(e){t(e)}},o=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);r((e=e.apply(void 0,null)).next())})),()=>{null==d||d.destroy(),null==r||r(d)}}),[d,...o,...u]),d},e.useCreateQueries=(e,s,t)=>Z(e,s,t),e.useCreateRelationships=(e,s,t)=>Z(e,s,t),e.useCreateStore=(e,s=N)=>W(e,s),e.useDelCellCallback=(e,s,t,l,o,r,u)=>se(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>se(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>se(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>se(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>se(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>se(e,g,s,t),e.useDidFinishTransactionListener=(e,s,t)=>_("DidFinish"+A,H(t),e,s),e.useGoBackwardCallback=ye,e.useGoForwardCallback=me,e.useGoToCallback=(e,s=N,t,l=f,o=N)=>{const r=Q(t);return G((s=>m(r,(t=>m(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>$(R,H(l),!1,[e,s,t],4,d,n),e.useHasCellListener=(e,s,t,l,o,r,u)=>_(n+R,H(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>$(p,H(t),!1,[e,s],3,d,n),e.useHasRowListener=(e,s,t,l,o,r)=>_(n+p,H(r),t,l,[e,s],o),e.useHasTable=(e,s)=>$(a,H(s),!1,[e],2,d,n),e.useHasTableCell=(e,s,t)=>$(a+R,H(t),!1,[e,s],3,d,n),e.useHasTableCellListener=(e,s,t,l,o,r)=>_(n+a+R,H(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>_(n+a,H(o),s,t,[e],l),e.useHasTables=e=>$(c,H(e),!1,[],1,d,n),e.useHasTablesListener=(e,s,t,l)=>_(n+c,H(l),e,s,[],t),e.useHasValue=(e,s)=>$(v,H(s),!1,[e],2,d,n),e.useHasValueListener=(e,s,t,l,o)=>_(n+v,H(o),s,t,[e],l),e.useHasValues=e=>$(g,H(e),!1,[],1,d,n),e.useHasValuesListener=(e,s,t,l)=>_(n+g,H(l),e,s,[],t),e.useIndexIds=e=>$("IndexIds",D(e),N),e.useIndexes=e=>O(e,4),e.useIndexesIds=()=>B(5),e.useIndexesOrIndexesById=D,e.useLinkedRowIds=be,e.useLinkedRowIdsListener=(e,s,t,l,o)=>_("Linked"+b,j(o),t,l,[e,s]),e.useLocalRowIds=Ce,e.useLocalRowIdsListener=(e,s,t,l,o)=>_("Local"+b,j(o),t,l,[e,s]),e.useMetric=ae,e.useMetricIds=e=>$("MetricIds",M(e),N),e.useMetricListener=(e,s,t,l)=>_("Metric",M(l),s,t,[e]),e.useMetrics=e=>O(e,2),e.useMetricsIds=()=>B(3),e.useMetricsOrMetricsById=M,e.useQueries=e=>O(e,8),e.useQueriesIds=()=>B(9),e.useQueriesOrQueriesById=F,e.useQueryIds=e=>$("QueryIds",F(e),N),e.useRedoInformation=e=>{var s;const t=Q(e),[,,[o]]=ge(t);return[!y(o),me(t),o,null!=(s=m(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>$("RelationshipIds",j(e),N),e.useRelationships=e=>O(e,6),e.useRelationshipsIds=()=>B(7),e.useRelationshipsOrRelationshipsById=j,e.useRemoteRowId=pe,e.useRemoteRowIdListener=(e,s,t,l,o)=>_("RemoteRowId",j(o),t,l,[e,s]),e.useResultCell=ve,e.useResultCellIds=ke,e.useResultCellIdsListener=(e,s,t,l,o)=>_(u+k,F(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>_(u+R,F(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>$(u+p,F(t),X,[e,s]),e.useResultRowCount=(e,s)=>$(u+C,F(s),0,[e]),e.useResultRowCountListener=(e,s,t,l)=>_(u+C,F(l),s,t,[e]),e.useResultRowIds=we,e.useResultRowIdsListener=(e,s,t,l)=>_(u+b,F(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>_(u+p,F(o),t,l,[e,s]),e.useResultSortedRowIds=Re,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,n,d)=>_(u+w,F(d),r,n,[e,s,t,l,o]),e.useResultTable=(e,s)=>$(u+a,F(s),X,[e]),e.useResultTableCellIds=(e,s)=>$(u+a+k,F(s),N,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>_(u+a+k,F(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>_(u+a,F(l),s,t,[e]),e.useRow=(e,s,t)=>$(p,H(t),X,[e,s]),e.useRowCount=(e,s)=>$(C,H(s),0,[e]),e.useRowCountListener=(e,s,t,l,o)=>_(C,H(o),s,t,[e],l),e.useRowIds=oe,e.useRowIdsListener=(e,s,t,l,o)=>_(b,H(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>_(p,H(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>ee(r,R,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=N,t,l=f,o=N)=>{const r=Q(t);return G((s=>m(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>ee(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>ee(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>ee(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>ee(l,a,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>ee(t,c,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>ee(l,v,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>ee(t,g,e,s,l,o),e.useSliceIds=ce,e.useSliceIdsListener=(e,s,t,l)=>_("SliceIds",D(l),s,t,[e]),e.useSliceRowIds=Ie,e.useSliceRowIdsListener=(e,s,t,l,o)=>_("Slice"+b,D(o),t,l,[e,s]),e.useSortedRowIds=re,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>_(w,H(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>_("Start"+A,H(t),e,s),e.useStore=e=>O(e,0),e.useStoreIds=()=>B(1),e.useStoreOrStoreById=H,e.useTable=(e,s)=>$(a,H(s),X,[e]),e.useTableCellIds=(e,s)=>$(a+k,H(s),N,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>_(a+k,H(o),s,t,[e],l),e.useTableIds=le,e.useTableIdsListener=(e,s,t,l)=>_(I,H(l),e,s,N,t),e.useTableListener=(e,s,t,l,o)=>_(a,H(o),s,t,[e],l),e.useTables=e=>$(c,H(e),X),e.useTablesListener=(e,s,t,l)=>_(c,H(l),e,s,N,t),e.useUndoInformation=e=>{var s;const t=Q(e),[o,r]=ge(t);return[(u=o,!(0==u.length)),ye(t),r,null!=(s=m(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=ie,e.useValueIds=de,e.useValueIdsListener=(e,s,t,l)=>_(h,H(l),e,s,N,t),e.useValueListener=(e,s,t,l,o)=>_(v,H(o),s,t,[e],l),e.useValues=e=>$(g,H(e),X),e.useValuesListener=(e,s,t,l)=>_(g,H(l),e,s,N,t),e.useWillFinishTransactionListener=(e,s,t)=>_("WillFinish"+A,H(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r="Listener",u="Result",n="Has",d="has",i="Ids",a="Table",c=a+"s",I=a+i,C="Row",p=C+"Count",b=C+i,w="Sorted"+C+i,R="Cell",k=R+i,v="Value",g=v+"s",h=v+i,y=e=>null==e,m=(e,s,t)=>y(e)?null==t?void 0:t():s(e),L=e=>t(e)==o,f=()=>{},T=(e,s)=>e.map(s),V=Object.keys,S=(e,s)=>m(e,(e=>e[s])),{createContext:P,useContext:x,useEffect:O}=s,q=P([]),B=(e,s)=>{var t;const l=x(q);return y(e)?l[s]:L(e)?S(null!=(t=l[s+1])?t:{},e):e},H=(e,s)=>{const t=B(e,s);return y(e)||L(e)?t:e},M=e=>{var s;return V(null!=(s=x(q)[e])?s:{})},D=e=>H(e,0),j=e=>H(e,2),F=e=>H(e,4),Q=e=>H(e,6),E=e=>H(e,8),A=e=>H(e,10),G=e=>e.toLowerCase();G(r);const U="Transaction";G(U);const{useCallback:W,useEffect:z,useMemo:J,useLayoutEffect:K,useRef:N,useState:X}=s,Y=[],Z={},$=[[],void 0,[]],_=(e,s,t=Y)=>{const l=J((()=>s(e)),[e,...t]);return z((()=>()=>l.destroy()),[l]),l},ee=(e,s,t,l=Y,o,r="get",u="")=>{const[,n]=X(),d=W((()=>{var o,u;return null!=(u=null==(o=null==s?void 0:s[r+e])?void 0:o.call(s,...l))?u:t}),[s,e,...l,t]),i=N();return J((()=>i.current=d()),[d]),se(u+e,s,((...e)=>{i.current=y(o)?d():e[o],n([])}),[d,o],l),i.current},se=(e,s,t,l=Y,o=Y,...u)=>K((()=>{var l;const n=null==(l=null==s?void 0:s["add"+e+r])?void 0:l.call(s,...o,t,...u);return()=>null==s?void 0:s.delListener(n)}),[s,e,...o,...l,...u]),te=(e,s,t,l=Y,o=f,r=Y,...u)=>{const n=D(e);return W((e=>m(n,(l=>m(t(e,l),(e=>o(l["set"+s](...u,e),e)))))),[n,s,...l,...r,...u])},le=(e,s,t=f,l=Y,...o)=>{const r=D(e);return W((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},oe=(e,s,t)=>{const l=A(e);return W((()=>null==l?void 0:l[s](t)),[l,s,t])},re=e=>ee(I,D(e),Y),ue=(e,s)=>ee(b,D(s),Y,[e]),ne=(e,s,t,l=0,o,r)=>ee(w,D(r),Y,[e,s,t,l,o],6),de=(e,s,t)=>ee(k,D(t),Y,[e,s]),ie=(e,s,t,l)=>ee(R,D(l),void 0,[e,s,t],4),ae=e=>ee(h,D(e),Y),ce=(e,s)=>ee(v,D(s),void 0,[e]),Ie=(e,s)=>ee("Metric",j(s),void 0,[e]),Ce=(e,s)=>ee("SliceIds",F(s),Y,[e]),pe=(e,s,t)=>ee("Slice"+b,F(t),Y,[e,s]),be=(e,s,t)=>ee("RemoteRowId",Q(t),void 0,[e,s]),we=(e,s,t)=>ee("Local"+b,Q(t),Y,[e,s]),Re=(e,s,t)=>ee("Linked"+b,Q(t),Y,[e,s]),ke=(e,s)=>ee(u+b,E(s),Y,[e]),ve=(e,s,t,l=0,o,r)=>ee(u+w,E(r),Y,[e,s,t,l,o],6),ge=(e,s,t)=>ee(u+k,E(t),Y,[e,s]),he=(e,s,t,l)=>ee(u+R,E(l),void 0,[e,s,t]),ye=e=>ee("CheckpointIds",A(e),$),me=(e,s)=>ee("Checkpoint",A(s),void 0,[e]),Le=e=>oe(e,"goBackward"),fe=e=>oe(e,"goForward"),{PureComponent:Te,Fragment:Ve,createElement:Se,useCallback:Pe,useLayoutEffect:xe,useRef:Oe,useState:qe}=s,Be=(e,...s)=>y(e)?{}:e(...s),He=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var Me=Object.defineProperty,De=Object.defineProperties,je=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Ae=(e,s,t)=>s in e?Me(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Ge=(e,s)=>{for(var t in s||(s={}))Qe.call(s,t)&&Ae(e,t,s[t]);if(Fe)for(var t of Fe(s))Ee.call(s,t)&&Ae(e,t,s[t]);return e},Ue=(e,s)=>De(e,je(s)),We=(e,s)=>{var t={};for(var l in e)Qe.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&Fe)for(var l of Fe(e))s.indexOf(l)<0&&Ee.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:ze,useContext:Je,useMemo:Ke,useState:Ne}=s,Xe=({tableId:e,store:s,rowComponent:t=ss,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>_e(T(n,(r=>Se(t,Ue(Ge({},Be(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),Ye=({queryId:e,queries:s,resultRowComponent:t=us,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>_e(T(u,(o=>Se(t,Ue(Ge({},Be(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),Ze=({relationshipId:e,relationships:s,rowComponent:t=ss,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=He(Q(s),e),c=u(e,n,d);return _e(T(c,(e=>Se(t,Ue(Ge({},Be(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},$e=e=>({checkpoints:s,checkpointComponent:t=ns,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=A(s);return _e(T(e(ye(u)),(e=>Se(t,Ue(Ge({},Be(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},_e=(e,s,t,l)=>{const o=y(s)||!Array.isArray(e)?e:T(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},es=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return _e(l+(null!=(u=ie(e,s,t,o))?u:l),void 0,r,t)},ss=({tableId:e,rowId:s,store:t,cellComponent:l=es,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>_e(T(((e,s,t,l)=>{const o=de(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Se(l,Ue(Ge({},Be(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),ts=e=>Xe(e,ue(e.tableId,e.store)),ls=({valueId:e,store:s,debugIds:t})=>{var o;return _e(l+(null!=(o=ce(e,s))?o:l),void 0,t,e)},os=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ss,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(F(t),e),a=pe(e,s,n);return _e(T(a,(e=>Se(l,Ue(Ge({},Be(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},rs=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return _e(l+(null!=(u=he(e,s,t,o))?u:l),void 0,r,t)},us=({queryId:e,rowId:s,queries:t,resultCellComponent:l=rs,getResultCellComponentProps:o,separator:r,debugIds:u})=>_e(T(ge(e,s,t),(r=>Se(l,Ue(Ge({},Be(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),ns=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return _e(null!=(o=me(s,e))?o:l,void 0,t,s)},ds=$e((e=>e[0])),is=$e((e=>y(e[1])?[]:[e[1]])),as=$e((e=>e[2]));e.BackwardCheckpointsView=ds,e.CellView=es,e.CheckpointView=ns,e.CurrentCheckpointView=is,e.ForwardCheckpointsView=as,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=os,getSliceComponentProps:l,separator:o,debugIds:r})=>_e(T(Ce(e,s),(o=>Se(t,Ue(Ge({},Be(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>Ze(e,Re,e.firstRowId),e.LocalRowsView=e=>Ze(e,we,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return _e(null!=(o=Ie(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const C=Je(q),[p,b]=Ne({}),w=ze(((e,s)=>b((t=>S(t,e)==s?t:Ue(Ge({},t),{[e]:s})))),[]),R=ze((e=>b((s=>Ge({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Se(q.Provider,{value:Ke((()=>[null!=e?e:C[0],Ge(Ge(Ge({},C[1]),s),p),null!=t?t:C[2],Ge(Ge({},C[3]),l),null!=o?o:C[4],Ge(Ge({},C[5]),r),null!=u?u:C[6],Ge(Ge({},C[7]),n),null!=d?d:C[8],Ge(Ge({},C[9]),i),null!=a?a:C[10],Ge(Ge({},C[11]),c),w,R]),[e,s,p,t,l,o,r,u,n,d,i,a,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ss,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=He(Q(t),e),i=be(e,s,u);return _e(y(d)||y(i)?null:Se(l,Ue(Ge({},Be(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=rs,e.ResultRowView=us,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=We(s,["cellId","descending","offset","limit"]);return Ye(u,ve(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>Ye(e,ke(e.queryId,e.queries)),e.RowView=ss,e.SliceView=os,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=We(s,["cellId","descending","offset","limit"]);return Xe(u,ne(u.tableId,t,l,o,r,u.store))},e.TableView=ts,e.TablesView=({store:e,tableComponent:s=ts,getTableComponentProps:t,separator:l,debugIds:o})=>_e(T(re(e),(l=>Se(s,Ue(Ge({},Be(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=ls,e.ValuesView=({store:e,valueComponent:s=ls,getValueComponentProps:t,separator:l,debugIds:o})=>_e(T(ae(e),(l=>Se(s,Ue(Ge({},Be(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=Y,l,o=f,r=Y,u=!0)=>{const n=D(l);return W((t=>m(n,(l=>m(s(t,l),(s=>o(l.addRow(e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=ie,e.useCellIds=de,e.useCellIdsListener=(e,s,t,l,o,r)=>se(k,D(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>se(R,D(u),l,o,[e,s,t],r),e.useCheckpoint=me,e.useCheckpointIds=ye,e.useCheckpointIdsListener=(e,s,t)=>se("CheckpointIds",A(t),e,s),e.useCheckpointListener=(e,s,t,l)=>se("Checkpoint",A(l),s,t,[e]),e.useCheckpoints=e=>B(e,10),e.useCheckpointsIds=()=>M(11),e.useCheckpointsOrCheckpointsById=A,e.useCreateCheckpoints=(e,s,t)=>_(e,s,t),e.useCreateIndexes=(e,s,t)=>_(e,s,t),e.useCreateMetrics=(e,s,t)=>_(e,s,t),e.useCreatePersister=(e,s,t=Y,l,o=Y,r,u=Y)=>{const[,n]=X(),d=J((()=>s(e)),[e,...t]);return z((()=>{var e;return e=function*(){l&&(yield l(d),n([]))},new Promise(((s,t)=>{var l=s=>{try{r(e.next(s))}catch(e){t(e)}},o=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);r((e=e.apply(void 0,null)).next())})),()=>{null==d||d.destroy(),null==r||r(d)}}),[d,...o,...u]),d},e.useCreateQueries=(e,s,t)=>_(e,s,t),e.useCreateRelationships=(e,s,t)=>_(e,s,t),e.useCreateStore=(e,s=Y)=>J(e,s),e.useDelCellCallback=(e,s,t,l,o,r,u)=>le(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>le(t,C,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>le(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>le(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>le(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>le(e,g,s,t),e.useDidFinishTransactionListener=(e,s,t)=>se("DidFinish"+U,D(t),e,s),e.useGoBackwardCallback=Le,e.useGoForwardCallback=fe,e.useGoToCallback=(e,s=Y,t,l=f,o=Y)=>{const r=A(t);return W((s=>m(r,(t=>m(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>ee(R,D(l),!1,[e,s,t],4,d,n),e.useHasCellListener=(e,s,t,l,o,r,u)=>se(n+R,D(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>ee(C,D(t),!1,[e,s],3,d,n),e.useHasRowListener=(e,s,t,l,o,r)=>se(n+C,D(r),t,l,[e,s],o),e.useHasTable=(e,s)=>ee(a,D(s),!1,[e],2,d,n),e.useHasTableCell=(e,s,t)=>ee(a+R,D(t),!1,[e,s],3,d,n),e.useHasTableCellListener=(e,s,t,l,o,r)=>se(n+a+R,D(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>se(n+a,D(o),s,t,[e],l),e.useHasTables=e=>ee(c,D(e),!1,[],1,d,n),e.useHasTablesListener=(e,s,t,l)=>se(n+c,D(l),e,s,[],t),e.useHasValue=(e,s)=>ee(v,D(s),!1,[e],2,d,n),e.useHasValueListener=(e,s,t,l,o)=>se(n+v,D(o),s,t,[e],l),e.useHasValues=e=>ee(g,D(e),!1,[],1,d,n),e.useHasValuesListener=(e,s,t,l)=>se(n+g,D(l),e,s,[],t),e.useIndexIds=e=>ee("IndexIds",F(e),Y),e.useIndexes=e=>B(e,4),e.useIndexesIds=()=>M(5),e.useIndexesOrIndexesById=F,e.useLinkedRowIds=Re,e.useLinkedRowIdsListener=(e,s,t,l,o)=>se("Linked"+b,Q(o),t,l,[e,s]),e.useLocalRowIds=we,e.useLocalRowIdsListener=(e,s,t,l,o)=>se("Local"+b,Q(o),t,l,[e,s]),e.useMetric=Ie,e.useMetricIds=e=>ee("MetricIds",j(e),Y),e.useMetricListener=(e,s,t,l)=>se("Metric",j(l),s,t,[e]),e.useMetrics=e=>B(e,2),e.useMetricsIds=()=>M(3),e.useMetricsOrMetricsById=j,e.useProvideStore=(e,s)=>{const{12:t,13:l}=x(q);O((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>B(e,8),e.useQueriesIds=()=>M(9),e.useQueriesOrQueriesById=E,e.useQueryIds=e=>ee("QueryIds",E(e),Y),e.useRedoInformation=e=>{var s;const t=A(e),[,,[o]]=ye(t);return[!y(o),fe(t),o,null!=(s=m(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>ee("RelationshipIds",Q(e),Y),e.useRelationships=e=>B(e,6),e.useRelationshipsIds=()=>M(7),e.useRelationshipsOrRelationshipsById=Q,e.useRemoteRowId=be,e.useRemoteRowIdListener=(e,s,t,l,o)=>se("RemoteRowId",Q(o),t,l,[e,s]),e.useResultCell=he,e.useResultCellIds=ge,e.useResultCellIdsListener=(e,s,t,l,o)=>se(u+k,E(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>se(u+R,E(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>ee(u+C,E(t),Z,[e,s]),e.useResultRowCount=(e,s)=>ee(u+p,E(s),0,[e]),e.useResultRowCountListener=(e,s,t,l)=>se(u+p,E(l),s,t,[e]),e.useResultRowIds=ke,e.useResultRowIdsListener=(e,s,t,l)=>se(u+b,E(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>se(u+C,E(o),t,l,[e,s]),e.useResultSortedRowIds=ve,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,n,d)=>se(u+w,E(d),r,n,[e,s,t,l,o]),e.useResultTable=(e,s)=>ee(u+a,E(s),Z,[e]),e.useResultTableCellIds=(e,s)=>ee(u+a+k,E(s),Y,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>se(u+a+k,E(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>se(u+a,E(l),s,t,[e]),e.useRow=(e,s,t)=>ee(C,D(t),Z,[e,s]),e.useRowCount=(e,s)=>ee(p,D(s),0,[e]),e.useRowCountListener=(e,s,t,l,o)=>se(p,D(o),s,t,[e],l),e.useRowIds=ue,e.useRowIdsListener=(e,s,t,l,o)=>se(b,D(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>se(C,D(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>te(r,R,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=Y,t,l=f,o=Y)=>{const r=A(t);return W((s=>m(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>te(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>te(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>te(o,C,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>te(l,a,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>te(t,c,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>te(l,v,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>te(t,g,e,s,l,o),e.useSliceIds=Ce,e.useSliceIdsListener=(e,s,t,l)=>se("SliceIds",F(l),s,t,[e]),e.useSliceRowIds=pe,e.useSliceRowIdsListener=(e,s,t,l,o)=>se("Slice"+b,F(o),t,l,[e,s]),e.useSortedRowIds=ne,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>se(w,D(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>se("Start"+U,D(t),e,s),e.useStore=e=>B(e,0),e.useStoreIds=()=>M(1),e.useStoreOrStoreById=D,e.useTable=(e,s)=>ee(a,D(s),Z,[e]),e.useTableCellIds=(e,s)=>ee(a+k,D(s),Y,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>se(a+k,D(o),s,t,[e],l),e.useTableIds=re,e.useTableIdsListener=(e,s,t,l)=>se(I,D(l),e,s,Y,t),e.useTableListener=(e,s,t,l,o)=>se(a,D(o),s,t,[e],l),e.useTables=e=>ee(c,D(e),Z),e.useTablesListener=(e,s,t,l)=>se(c,D(l),e,s,Y,t),e.useUndoInformation=e=>{var s;const t=A(e),[o,r]=ye(t);return[(u=o,!(0==u.length)),Le(t),r,null!=(s=m(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=ce,e.useValueIds=ae,e.useValueIdsListener=(e,s,t,l)=>se(h,D(l),e,s,Y,t),e.useValueListener=(e,s,t,l,o)=>se(v,D(o),s,t,[e],l),e.useValues=e=>ee(g,D(e),Z),e.useValuesListener=(e,s,t,l)=>se(g,D(l),e,s,Y,t),e.useWillFinishTransactionListener=(e,s,t)=>se("WillFinish"+U,D(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.5.0-beta.0",
3
+ "version": "4.5.0",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -8,7 +8,6 @@
8
8
  "description": "The reactive data store for local-first apps.",
9
9
  "keywords": [
10
10
  "tiny",
11
- "local-first",
12
11
  "reactive",
13
12
  "state",
14
13
  "data",
@@ -214,31 +213,31 @@
214
213
  "publishPackage": "gulp publishPackage"
215
214
  },
216
215
  "devDependencies": {
217
- "@automerge/automerge": "^2.1.6",
216
+ "@automerge/automerge": "^2.1.7",
218
217
  "@babel/cli": "^7.23.0",
219
- "@babel/core": "^7.23.2",
220
- "@babel/preset-env": "^7.23.2",
221
- "@babel/preset-react": "^7.22.15",
222
- "@babel/preset-typescript": "^7.23.2",
218
+ "@babel/core": "^7.23.3",
219
+ "@babel/preset-env": "^7.23.3",
220
+ "@babel/preset-react": "^7.23.3",
221
+ "@babel/preset-typescript": "^7.23.3",
223
222
  "@prettier/sync": "^0.3.0",
224
223
  "@rollup/plugin-image": "^3.0.3",
225
224
  "@rollup/plugin-replace": "^5.0.5",
226
225
  "@rollup/plugin-terser": "^0.4.4",
227
- "@sqlite.org/sqlite-wasm": "^3.44.0-build1",
226
+ "@sqlite.org/sqlite-wasm": "^3.44.0-build2",
228
227
  "@types/asciichart": "^1.5.8",
229
228
  "@types/expect-puppeteer": "^5.0.6",
230
229
  "@types/http-server": "^0.12.4",
231
- "@types/jest": "^29.5.7",
230
+ "@types/jest": "^29.5.8",
232
231
  "@types/jest-environment-puppeteer": "^5.0.6",
233
232
  "@types/less": "^3.0.6",
234
- "@types/node": "^20.8.10",
233
+ "@types/node": "^20.9.0",
235
234
  "@types/puppeteer": "^5.4.7",
236
- "@types/react": "^18.2.36",
237
- "@types/react-dom": "^18.2.14",
238
- "@types/react-test-renderer": "^18.0.5",
235
+ "@types/react": "^18.2.37",
236
+ "@types/react-dom": "^18.2.15",
237
+ "@types/react-test-renderer": "^18.0.6",
239
238
  "@types/tmp": "^0.2.6",
240
- "@typescript-eslint/eslint-plugin": "^6.10.0",
241
- "@typescript-eslint/parser": "^6.10.0",
239
+ "@typescript-eslint/eslint-plugin": "^6.11.0",
240
+ "@typescript-eslint/parser": "^6.11.0",
242
241
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
243
242
  "asciichart": "^1.5.25",
244
243
  "automerge-repo": "^0.1.0",
@@ -254,10 +253,10 @@
254
253
  "eslint": "^8.53.0",
255
254
  "eslint-config-prettier": "^9.0.0",
256
255
  "eslint-plugin-jest": "^27.6.0",
257
- "eslint-plugin-jsdoc": "^46.8.2",
256
+ "eslint-plugin-jsdoc": "^46.9.0",
258
257
  "eslint-plugin-react": "7.33.2",
259
258
  "eslint-plugin-react-hooks": "^4.6.0",
260
- "expo-sqlite": "^11.6.0",
259
+ "expo-sqlite": "^12.1.0",
261
260
  "fake-indexeddb": "^5.0.1",
262
261
  "gulp": "^4.0.2",
263
262
  "gulp-gzip": "^1.4.2",
@@ -268,14 +267,14 @@
268
267
  "jest-fetch-mock": "^3.0.3",
269
268
  "jest-puppeteer": "^9.0.1",
270
269
  "less": "^4.2.0",
271
- "partykit": "^0.0.34",
272
- "partysocket": "^0.0.14",
273
- "prettier": "^3.0.3",
270
+ "partykit": "^0.0.37",
271
+ "partysocket": "^0.0.15",
272
+ "prettier": "^3.1.0",
274
273
  "puppeteer": "21.1.1",
275
274
  "react": "^18.2.0",
276
275
  "react-dom": "^18.2.0",
277
276
  "react-test-renderer": "^18.2.0",
278
- "rollup": "^4.3.0",
277
+ "rollup": "^4.4.1",
279
278
  "rollup-plugin-esbuild": "^6.1.0",
280
279
  "rollup-plugin-gzip": "^3.1.0",
281
280
  "rollup-plugin-preserve-shebang": "^1.0.1",
@@ -292,8 +291,8 @@
292
291
  "@sqlite.org/sqlite-wasm": "^3.44.0-build1",
293
292
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
294
293
  "automerge-repo": "^0.1.0",
295
- "partykit": "^0.0.34",
296
- "partysocket": "^0.0.14",
294
+ "partykit": "^0.0.37",
295
+ "partysocket": "^0.0.15",
297
296
  "prettier": "^3.0.3",
298
297
  "react": "^18.2.0",
299
298
  "react-dom": "^18.2.0",