tinybase 4.4.1 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -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
@@ -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.4.1",
3
+ "version": "4.4.2",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -213,31 +213,31 @@
213
213
  "publishPackage": "gulp publishPackage"
214
214
  },
215
215
  "devDependencies": {
216
- "@automerge/automerge": "^2.1.6",
216
+ "@automerge/automerge": "^2.1.7",
217
217
  "@babel/cli": "^7.23.0",
218
- "@babel/core": "^7.23.2",
219
- "@babel/preset-env": "^7.23.2",
220
- "@babel/preset-react": "^7.22.15",
221
- "@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",
222
222
  "@prettier/sync": "^0.3.0",
223
223
  "@rollup/plugin-image": "^3.0.3",
224
224
  "@rollup/plugin-replace": "^5.0.5",
225
225
  "@rollup/plugin-terser": "^0.4.4",
226
- "@sqlite.org/sqlite-wasm": "^3.44.0-build1",
226
+ "@sqlite.org/sqlite-wasm": "^3.44.0-build2",
227
227
  "@types/asciichart": "^1.5.8",
228
228
  "@types/expect-puppeteer": "^5.0.6",
229
229
  "@types/http-server": "^0.12.4",
230
- "@types/jest": "^29.5.7",
230
+ "@types/jest": "^29.5.8",
231
231
  "@types/jest-environment-puppeteer": "^5.0.6",
232
232
  "@types/less": "^3.0.6",
233
- "@types/node": "^20.8.10",
233
+ "@types/node": "^20.9.0",
234
234
  "@types/puppeteer": "^5.4.7",
235
- "@types/react": "^18.2.36",
236
- "@types/react-dom": "^18.2.14",
237
- "@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",
238
238
  "@types/tmp": "^0.2.6",
239
- "@typescript-eslint/eslint-plugin": "^6.10.0",
240
- "@typescript-eslint/parser": "^6.10.0",
239
+ "@typescript-eslint/eslint-plugin": "^6.11.0",
240
+ "@typescript-eslint/parser": "^6.11.0",
241
241
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
242
242
  "asciichart": "^1.5.25",
243
243
  "automerge-repo": "^0.1.0",
@@ -253,7 +253,7 @@
253
253
  "eslint": "^8.53.0",
254
254
  "eslint-config-prettier": "^9.0.0",
255
255
  "eslint-plugin-jest": "^27.6.0",
256
- "eslint-plugin-jsdoc": "^46.8.2",
256
+ "eslint-plugin-jsdoc": "^46.9.0",
257
257
  "eslint-plugin-react": "7.33.2",
258
258
  "eslint-plugin-react-hooks": "^4.6.0",
259
259
  "expo-sqlite": "^11.6.0",
@@ -267,14 +267,14 @@
267
267
  "jest-fetch-mock": "^3.0.3",
268
268
  "jest-puppeteer": "^9.0.1",
269
269
  "less": "^4.2.0",
270
- "partykit": "^0.0.34",
270
+ "partykit": "^0.0.35",
271
271
  "partysocket": "^0.0.14",
272
- "prettier": "^3.0.3",
272
+ "prettier": "^3.1.0",
273
273
  "puppeteer": "21.1.1",
274
274
  "react": "^18.2.0",
275
275
  "react-dom": "^18.2.0",
276
276
  "react-test-renderer": "^18.2.0",
277
- "rollup": "^4.3.0",
277
+ "rollup": "^4.4.1",
278
278
  "rollup-plugin-esbuild": "^6.1.0",
279
279
  "rollup-plugin-gzip": "^3.1.0",
280
280
  "rollup-plugin-preserve-shebang": "^1.0.1",
@@ -291,7 +291,7 @@
291
291
  "@sqlite.org/sqlite-wasm": "^3.44.0-build1",
292
292
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
293
293
  "automerge-repo": "^0.1.0",
294
- "partykit": "^0.0.34",
294
+ "partykit": "^0.0.35",
295
295
  "partysocket": "^0.0.14",
296
296
  "prettier": "^3.0.3",
297
297
  "react": "^18.2.0",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-4"><em>NEW!</em> v4.4 release</a> <span id="one-with">&quot;The One With More Listeners&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, zero dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.4.1" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-4"><em>NEW!</em> v4.4 release</a> <span id="one-with">&quot;The One With More Listeners&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.4.2" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()
@@ -247,4 +247,4 @@ export const createShop: typeof createShopDecl = () => {
247
247
  };
248
248
  ```
249
249
 
250
- <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>5.0kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.4kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>4.1kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>11.1kB</em>, and everything is super fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>5.0kB</td><td>12.0kB</td><td>51.6kB</td><td>252.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.0kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.1kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>127.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.4kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.5kB</td><td>5.3kB</td><td>43.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.4kB</td><td>23.2kB</td><td>100.5kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,946</td><td>1,946</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,102</td><td>2,102</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>837</td><td>837</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>711</td><td>711</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,778</td></tr><tr><th class="right">Assertions</th><td colspan="3">17,830</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
250
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>5.0kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.4kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>4.3kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>11.1kB</em>, and everything is super fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>5.0kB</td><td>12.0kB</td><td>51.6kB</td><td>252.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.0kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.1kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>126.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.5kB</td><td>5.3kB</td><td>43.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.4kB</td><td>23.2kB</td><td>100.6kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,960</td><td>1,960</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,118</td><td>2,118</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>845</td><td>845</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>713</td><td>713</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,779</td></tr><tr><th class="right">Assertions</th><td colspan="3">17,838</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>