tinybase 2.2.6 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/bin/cli.js +1 -1
  2. package/lib/checkpoints.d.ts +18 -3
  3. package/lib/checkpoints.js +1 -1
  4. package/lib/checkpoints.js.gz +0 -0
  5. package/lib/debug/checkpoints.d.ts +18 -3
  6. package/lib/debug/checkpoints.js +97 -49
  7. package/lib/debug/indexes.js +31 -16
  8. package/lib/debug/metrics.js +31 -16
  9. package/lib/debug/persisters.d.ts +33 -23
  10. package/lib/debug/persisters.js +10 -5
  11. package/lib/debug/queries.js +2 -2
  12. package/lib/debug/relationships.js +31 -16
  13. package/lib/debug/store.d.ts +2022 -383
  14. package/lib/debug/store.js +440 -108
  15. package/lib/debug/tinybase.js +508 -140
  16. package/lib/debug/tools.d.ts +89 -38
  17. package/lib/debug/tools.js +757 -453
  18. package/lib/debug/ui-react.d.ts +1525 -381
  19. package/lib/debug/ui-react.js +163 -12
  20. package/lib/es6/checkpoints.d.ts +18 -3
  21. package/lib/es6/checkpoints.js +1 -1
  22. package/lib/es6/checkpoints.js.gz +0 -0
  23. package/lib/es6/indexes.js +1 -1
  24. package/lib/es6/indexes.js.gz +0 -0
  25. package/lib/es6/metrics.js +1 -1
  26. package/lib/es6/metrics.js.gz +0 -0
  27. package/lib/es6/persisters.d.ts +33 -23
  28. package/lib/es6/persisters.js +1 -1
  29. package/lib/es6/persisters.js.gz +0 -0
  30. package/lib/es6/relationships.js +1 -1
  31. package/lib/es6/relationships.js.gz +0 -0
  32. package/lib/es6/store.d.ts +2022 -383
  33. package/lib/es6/store.js +1 -1
  34. package/lib/es6/store.js.gz +0 -0
  35. package/lib/es6/tinybase.js +1 -1
  36. package/lib/es6/tinybase.js.gz +0 -0
  37. package/lib/es6/tools.d.ts +89 -38
  38. package/lib/es6/tools.js +1 -1
  39. package/lib/es6/tools.js.gz +0 -0
  40. package/lib/es6/ui-react.d.ts +1525 -381
  41. package/lib/es6/ui-react.js +1 -1
  42. package/lib/es6/ui-react.js.gz +0 -0
  43. package/lib/indexes.js +1 -1
  44. package/lib/indexes.js.gz +0 -0
  45. package/lib/metrics.js +1 -1
  46. package/lib/metrics.js.gz +0 -0
  47. package/lib/persisters.d.ts +33 -23
  48. package/lib/persisters.js +1 -1
  49. package/lib/persisters.js.gz +0 -0
  50. package/lib/relationships.js +1 -1
  51. package/lib/relationships.js.gz +0 -0
  52. package/lib/store.d.ts +2022 -383
  53. package/lib/store.js +1 -1
  54. package/lib/store.js.gz +0 -0
  55. package/lib/tinybase.js +1 -1
  56. package/lib/tinybase.js.gz +0 -0
  57. package/lib/tools.d.ts +89 -38
  58. package/lib/tools.js +1 -1
  59. package/lib/tools.js.gz +0 -0
  60. package/lib/ui-react.d.ts +1525 -381
  61. package/lib/ui-react.js +1 -1
  62. package/lib/ui-react.js.gz +0 -0
  63. package/lib/umd/checkpoints.d.ts +18 -3
  64. package/lib/umd/checkpoints.js +1 -1
  65. package/lib/umd/checkpoints.js.gz +0 -0
  66. package/lib/umd/indexes.js +1 -1
  67. package/lib/umd/indexes.js.gz +0 -0
  68. package/lib/umd/metrics.js +1 -1
  69. package/lib/umd/metrics.js.gz +0 -0
  70. package/lib/umd/persisters.d.ts +33 -23
  71. package/lib/umd/persisters.js +1 -1
  72. package/lib/umd/persisters.js.gz +0 -0
  73. package/lib/umd/relationships.js +1 -1
  74. package/lib/umd/relationships.js.gz +0 -0
  75. package/lib/umd/store.d.ts +2022 -383
  76. package/lib/umd/store.js +1 -1
  77. package/lib/umd/store.js.gz +0 -0
  78. package/lib/umd/tinybase.js +1 -1
  79. package/lib/umd/tinybase.js.gz +0 -0
  80. package/lib/umd/tools.d.ts +89 -38
  81. package/lib/umd/tools.js +1 -1
  82. package/lib/umd/tools.js.gz +0 -0
  83. package/lib/umd/ui-react.d.ts +1525 -381
  84. package/lib/umd/ui-react.js +1 -1
  85. package/lib/umd/ui-react.js.gz +0 -0
  86. package/lib/umd-es6/checkpoints.d.ts +18 -3
  87. package/lib/umd-es6/checkpoints.js +1 -1
  88. package/lib/umd-es6/checkpoints.js.gz +0 -0
  89. package/lib/umd-es6/indexes.js +1 -1
  90. package/lib/umd-es6/indexes.js.gz +0 -0
  91. package/lib/umd-es6/metrics.js +1 -1
  92. package/lib/umd-es6/metrics.js.gz +0 -0
  93. package/lib/umd-es6/persisters.d.ts +33 -23
  94. package/lib/umd-es6/persisters.js +1 -1
  95. package/lib/umd-es6/persisters.js.gz +0 -0
  96. package/lib/umd-es6/relationships.js +1 -1
  97. package/lib/umd-es6/relationships.js.gz +0 -0
  98. package/lib/umd-es6/store.d.ts +2022 -383
  99. package/lib/umd-es6/store.js +1 -1
  100. package/lib/umd-es6/store.js.gz +0 -0
  101. package/lib/umd-es6/tinybase.js +1 -1
  102. package/lib/umd-es6/tinybase.js.gz +0 -0
  103. package/lib/umd-es6/tools.d.ts +89 -38
  104. package/lib/umd-es6/tools.js +1 -1
  105. package/lib/umd-es6/tools.js.gz +0 -0
  106. package/lib/umd-es6/ui-react.d.ts +1525 -381
  107. package/lib/umd-es6/ui-react.js +1 -1
  108. package/lib/umd-es6/ui-react.js.gz +0 -0
  109. package/package.json +26 -26
  110. package/readme.md +20 -19
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",l=t(o),r="Tables",n="TableIds",d="Table",u="RowIds",i="SortedRowIds",a="Row",c="CellIds",I="Cell",w=(e,s)=>e.map(s),R=e=>null==e,p=(e,s,t)=>R(e)?null==t?void 0:t():s(e),b=()=>{},{createContext:C,useContext:k}=s,g=C([]),v=(e,s)=>{const t=k(g);return R(e)?t[s]:((e,s)=>p(e,(e=>e[s])))(t[s+1],e)},m=(e,s)=>{const o=v(e,s);return R(e)||(e=>t(e)==l)(e)?o:e},h=e=>m(e,0),y=e=>m(e,2),f=e=>m(e,4),L=e=>m(e,6),S=e=>m(e,8),T=e=>m(e,10),{useCallback:P,useEffect:x,useMemo:V,useRef:q,useState:O}=s,B=(e,s,t=[])=>{const o=V((()=>s(e)),[e,...t]);return x((()=>()=>o.destroy()),[o]),o},M=(e,s,t,o=[],l)=>{const[,r]=O(),n=P((()=>{var l,r;return null!=(r=null==(l=null==s?void 0:s["get"+e])?void 0:l.call(s,...o))?r:t}),[s,...o]),[d]=O(n),u=q(d);return V((()=>u.current=n()),[n]),j(e,s,((...e)=>{u.current=R(l)?n():e[l],r([])}),[],o),u.current},j=(e,s,t,o=[],l=[],...r)=>x((()=>{var o;const n=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...l,t,...r);return()=>null==s?void 0:s.delListener(n)}),[s,...l,...o,...r]),D=(e,s,t,o=[],l=b,r=[],...n)=>{const d=h(e);return P((e=>p(d,(o=>p(t(e,o),(e=>l(o["set"+s](...n,e),e)))))),[d,s,...o,...r,...n])},A=(e,s,t=b,o=[],...l)=>{const r=h(e);return P((()=>t(null==r?void 0:r["del"+s](...l))),[r,s,...o,...l])},E=(e,s,t)=>{const o=T(e);return P((()=>null==o?void 0:o[s](t)),[o,s,t])},F=e=>M(n,h(e),[],[]),G=(e,s)=>M(u,h(s),[],[e]),Q=(e,s,t,o=0,l,r)=>M(i,h(r),[],[e,s,t,o,l],6),U=(e,s,t)=>M(c,h(t),[],[e,s]),z=(e,s,t,o)=>M(I,h(o),void 0,[e,s,t],4),H=(e,s)=>M("Metric",y(s),void 0,[e]),J=(e,s)=>M("SliceIds",f(s),[],[e]),K=(e,s,t)=>M("SliceRowIds",f(t),[],[e,s]),N=(e,s,t)=>M("RemoteRowId",L(t),void 0,[e,s]),W=(e,s,t)=>M("LocalRowIds",L(t),[],[e,s]),X=(e,s,t)=>M("LinkedRowIds",L(t),[],[e,s]),Y=(e,s)=>M("ResultRowIds",S(s),[],[e]),Z=(e,s,t,o=0,l,r)=>M("ResultSortedRowIds",S(r),[],[e,s,t,o,l],6),$=(e,s,t)=>M("ResultCellIds",S(t),[],[e,s]),_=(e,s,t,o)=>M("ResultCell",S(o),void 0,[e,s,t]),ee=e=>M("CheckpointIds",T(e),[[],void 0,[]]),se=(e,s)=>M("Checkpoint",T(s),void 0,[e]),te=e=>E(e,"goBackward"),oe=e=>E(e,"goForward");var le=Object.defineProperty,re=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,ae=(e,s,t)=>s in e?le(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ce=(e,s)=>{for(var t in s||(s={}))ue.call(s,t)&&ae(e,t,s[t]);if(de)for(var t of de(s))ie.call(s,t)&&ae(e,t,s[t]);return e},Ie=(e,s)=>re(e,ne(s)),we=(e,s)=>{var t={};for(var o in e)ue.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&de)for(var o of de(e))s.indexOf(o)<0&&ie.call(e,o)&&(t[o]=e[o]);return t};const{createElement:Re,useMemo:pe}=s,be=({tableId:e,store:s,rowComponent:t=fe,getRowComponentProps:o,separator:l,debugIds:r},n)=>he(w(n,(l=>Re(t,Ie(ce({},me(o,l)),{key:l,tableId:e,rowId:l,store:s,debugIds:r})))),l,r,e),Ce=({queryId:e,queries:s,resultRowComponent:t=Pe,getResultRowComponentProps:o,separator:l,debugIds:r},n)=>he(w(n,(l=>Re(t,Ie(ce({},me(o,l)),{key:l,queryId:e,rowId:l,queries:s,debugIds:r})))),l,r,e),ke=e=>{const s=L(e);return[s,null==s?void 0:s.getStore()]},ge=({relationshipId:e,relationships:s,rowComponent:t=fe,getRowComponentProps:o,separator:l,debugIds:r},n,d)=>{const[u,i]=ke(s),a=null==u?void 0:u.getLocalTableId(e),c=n(e,d,u);return he(w(c,(e=>Re(t,Ie(ce({},me(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),l,r,d)},ve=e=>({checkpoints:s,checkpointComponent:t=xe,getCheckpointComponentProps:o,separator:l,debugIds:r})=>{const n=T(s);return he(w(e(ee(n)),(e=>Re(t,Ie(ce({},me(o,e)),{key:e,checkpoints:n,checkpointId:e,debugIds:r})))),l)},me=(e,s)=>R(e)?{}:e(s),he=(e,s,t,o)=>{const l=R(s)||!Array.isArray(e)?e:w(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",l,"}"]:l},ye=({tableId:e,rowId:s,cellId:t,store:l,debugIds:r})=>{var n;return he(o+(null!=(n=z(e,s,t,l))?n:o),void 0,r,t)},fe=({tableId:e,rowId:s,store:t,cellComponent:o=ye,getCellComponentProps:l,separator:r,debugIds:n})=>he(w(U(e,s,t),(r=>Re(o,Ie(ce({},me(l,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),r,n,s),Le=e=>be(e,G(e.tableId,e.store)),Se=({indexId:e,sliceId:s,indexes:t,rowComponent:o=fe,getRowComponentProps:l,separator:r,debugIds:n})=>{const d=f(t),u=null==d?void 0:d.getStore(),i=null==d?void 0:d.getTableId(e),a=K(e,s,d);return he(w(a,(e=>Re(o,Ie(ce({},me(l,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:n})))),r,n,s)},Te=({queryId:e,rowId:s,cellId:t,queries:l,debugIds:r})=>{var n;return he(o+(null!=(n=_(e,s,t,l))?n:o),void 0,r,t)},Pe=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Te,getResultCellComponentProps:l,separator:r,debugIds:n})=>he(w($(e,s,t),(r=>Re(o,Ie(ce({},me(l,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:n})))),r,n,s),xe=({checkpoints:e,checkpointId:s,debugIds:t})=>{var l;return he(null!=(l=se(s,e))?l:o,void 0,t,s)},Ve=ve((e=>e[0])),qe=ve((e=>R(e[1])?[]:[e[1]])),Oe=ve((e=>e[2]));e.BackwardCheckpointsView=Ve,e.CellView=ye,e.CheckpointView=xe,e.CurrentCheckpointView=qe,e.ForwardCheckpointsView=Oe,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Se,getSliceComponentProps:o,separator:l,debugIds:r})=>he(w(J(e,s),(l=>Re(t,Ie(ce({},me(o,l)),{key:l,indexId:e,sliceId:l,indexes:s,debugIds:r})))),l,r,e),e.LinkedRowsView=e=>ge(e,X,e.firstRowId),e.LocalRowsView=e=>ge(e,W,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var l;return he(null!=(l=H(e,s))?l:o,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:o,metricsById:l,indexes:r,indexesById:n,relationships:d,relationshipsById:u,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const R=s.useContext(g);return Re(g.Provider,{value:pe((()=>[null!=e?e:R[0],ce(ce({},R[1]),t),null!=o?o:R[2],ce(ce({},R[3]),l),null!=r?r:R[4],ce(ce({},R[5]),n),null!=d?d:R[6],ce(ce({},R[7]),u),null!=i?i:R[8],ce(ce({},R[9]),a),null!=c?c:R[10],ce(ce({},R[11]),I)]),[e,t,o,l,r,n,d,u,i,a,c,I,R])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=fe,getRowComponentProps:l,debugIds:r})=>{const[n,d]=ke(t),u=null==n?void 0:n.getRemoteTableId(e),i=N(e,s,n);return he(R(u)||R(i)?null:Re(o,Ie(ce({},me(l,i)),{key:i,tableId:u,rowId:i,store:d,debugIds:r})),void 0,r,s)},e.ResultCellView=Te,e.ResultRowView=Pe,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,n=we(s,["cellId","descending","offset","limit"]);return Ce(n,Z(n.queryId,t,o,l,r,n.queries))},e.ResultTableView=e=>Ce(e,Y(e.queryId,e.queries)),e.RowView=fe,e.SliceView=Se,e.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,n=we(s,["cellId","descending","offset","limit"]);return be(n,Q(n.tableId,t,o,l,r,n.store))},e.TableView=Le,e.TablesView=({store:e,tableComponent:s=Le,getTableComponentProps:t,separator:o,debugIds:l})=>he(w(F(e),(o=>Re(s,Ie(ce({},me(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),o),e.tableView=be,e.useAddRowCallback=(e,s,t=[],o,l=b,r=[])=>{const n=h(o);return P((t=>p(n,(o=>p(s(t,o),(s=>l(o.addRow(e,s),o,s)))))),[n,e,...t,...r])},e.useCell=z,e.useCellIds=U,e.useCellIdsListener=(e,s,t,o,l,r)=>j(c,h(r),t,o,[e,s],l),e.useCellListener=(e,s,t,o,l,r,n)=>j(I,h(n),o,l,[e,s,t],r),e.useCheckpoint=se,e.useCheckpointIds=ee,e.useCheckpointIdsListener=(e,s,t)=>j("CheckpointIds",T(t),e,s),e.useCheckpointListener=(e,s,t,o)=>j("Checkpoint",T(o),s,t,[e]),e.useCheckpoints=e=>v(e,10),e.useCreateCheckpoints=(e,s,t)=>B(e,s,t),e.useCreateIndexes=(e,s,t)=>B(e,s,t),e.useCreateMetrics=(e,s,t)=>B(e,s,t),e.useCreatePersister=(e,s,t=[],o,l=[])=>{const[,r]=O(),n=V((()=>s(e)),[e,...t]);return x((()=>{var e;return e=function*(){yield null==o?void 0:o(n),r(1)},new Promise(((s,t)=>{var o=s=>{try{r(e.next(s))}catch(e){t(e)}},l=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,l);r((e=e.apply(void 0,null)).next())})),()=>{n.destroy()}}),[n,...l]),n},e.useCreateQueries=(e,s,t)=>B(e,s,t),e.useCreateRelationships=(e,s,t)=>B(e,s,t),e.useCreateStore=(e,s=[])=>V(e,s),e.useDelCellCallback=(e,s,t,o,l,r,n)=>A(l,I,r,n,e,s,t,o),e.useDelRowCallback=(e,s,t,o,l)=>A(t,a,o,l,e,s),e.useDelTableCallback=(e,s,t,o)=>A(s,d,t,o,e),e.useDelTablesCallback=(e,s,t)=>A(e,r,s,t),e.useGoBackwardCallback=te,e.useGoForwardCallback=oe,e.useGoToCallback=(e,s=[],t,o=b,l=[])=>{const r=T(t);return P((s=>p(r,(t=>p(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...l])},e.useIndexes=e=>v(e,4),e.useLinkedRowIds=X,e.useLinkedRowIdsListener=(e,s,t,o,l)=>j("LinkedRowIds",L(l),t,o,[e,s]),e.useLocalRowIds=W,e.useLocalRowIdsListener=(e,s,t,o,l)=>j("LocalRowIds",L(l),t,o,[e,s]),e.useMetric=H,e.useMetricListener=(e,s,t,o)=>j("Metric",y(o),s,t,[e]),e.useMetrics=e=>v(e,2),e.useQueries=e=>v(e,8),e.useRedoInformation=e=>{var s;const t=T(e),[,,[l]]=ee(t);return[!R(l),oe(t),l,null!=(s=p(l,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o]},e.useRelationships=e=>v(e,6),e.useRemoteRowId=N,e.useRemoteRowIdListener=(e,s,t,o,l)=>j("RemoteRowId",L(l),t,o,[e,s]),e.useResultCell=_,e.useResultCellIds=$,e.useResultCellIdsListener=(e,s,t,o,l)=>j("ResultCellIds",S(l),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,l,r)=>j("ResultCell",S(r),o,l,[e,s,t]),e.useResultRow=(e,s,t)=>M("ResultRow",S(t),{},[e,s]),e.useResultRowIds=Y,e.useResultRowIdsListener=(e,s,t,o)=>j("ResultRowIds",S(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,l)=>j("ResultRow",S(l),t,o,[e,s]),e.useResultSortedRowIds=Z,e.useResultSortedRowIdsListener=(e,s,t,o,l,r,n,d)=>j("ResultSortedRowIds",S(d),r,n,[e,s,t,o,l]),e.useResultTable=(e,s)=>M("ResultTable",S(s),{},[e]),e.useResultTableListener=(e,s,t,o)=>j("ResultTable",S(o),s,t,[e]),e.useRow=(e,s,t)=>M(a,h(t),{},[e,s]),e.useRowIds=G,e.useRowIdsListener=(e,s,t,o,l)=>j(u,h(l),s,t,[e],o),e.useRowListener=(e,s,t,o,l,r)=>j(a,h(r),t,o,[e,s],l),e.useSetCellCallback=(e,s,t,o,l,r,n,d)=>D(r,I,o,l,n,d,e,s,t),e.useSetCheckpointCallback=(e=b,s=[],t,o=b,l=[])=>{const r=T(t);return P((s=>p(r,(t=>{const l=e(s);o(t.addCheckpoint(l),t,l)}))),[r,...s,...l])},e.useSetPartialRowCallback=(e,s,t,o,l,r,n)=>D(l,"PartialRow",t,o,r,n,e,s),e.useSetRowCallback=(e,s,t,o,l,r,n)=>D(l,a,t,o,r,n,e,s),e.useSetTableCallback=(e,s,t,o,l,r)=>D(o,d,s,t,l,r,e),e.useSetTablesCallback=(e,s,t,o,l)=>D(t,r,e,s,o,l),e.useSliceIds=J,e.useSliceIdsListener=(e,s,t,o)=>j("SliceIds",f(o),s,t,[e]),e.useSliceRowIds=K,e.useSliceRowIdsListener=(e,s,t,o,l)=>j("SliceRowIds",f(l),t,o,[e,s]),e.useSortedRowIds=Q,e.useSortedRowIdsListener=(e,s,t,o,l,r,n,d,u)=>j(i,h(u),r,n,[e,s,t,o,l],d),e.useStore=e=>v(e,0),e.useTable=(e,s)=>M(d,h(s),{},[e]),e.useTableIds=F,e.useTableIdsListener=(e,s,t,o)=>j(n,h(o),e,s,[],t),e.useTableListener=(e,s,t,o,l)=>j(d,h(l),s,t,[e],o),e.useTables=e=>M(r,h(e),{}),e.useTablesListener=(e,s,t,o)=>j(r,h(o),e,s,[],t),e.useUndoInformation=e=>{var s;const t=T(e),[l,r]=ee(t);return[(n=l,!(0==(e=>e.length)(n))),te(t),r,null!=(s=p(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o];var n}},"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="",l=t(o),r="Tables",u="TableIds",d="Table",n="RowIds",i="SortedRowIds",a="Row",c="CellIds",I="Cell",w="Values",p="ValueIds",b="Value",R=(e,s)=>e.map(s),C=e=>null==e,k=(e,s,t)=>C(e)?null==t?void 0:t():s(e),v=()=>{},{createContext:g,useContext:m}=s,y=g([]),h=(e,s)=>{const t=m(y);return C(e)?t[s]:((e,s)=>k(e,(e=>e[s])))(t[s+1],e)},f=(e,s)=>{const o=h(e,s);return C(e)||(e=>t(e)==l)(e)?o:e},V=e=>f(e,0),L=e=>f(e,2),S=e=>f(e,4),T=e=>f(e,6),P=e=>f(e,8),x=e=>f(e,10),{useCallback:q,useEffect:O,useMemo:B,useRef:M,useState:j}=s,D=(e,s,t=[])=>{const o=B((()=>s(e)),[e,...t]);return O((()=>()=>o.destroy()),[o]),o},A=(e,s,t,o=[],l)=>{const[,r]=j(),u=q((()=>{var l,r;return null!=(r=null==(l=null==s?void 0:s["get"+e])?void 0:l.call(s,...o))?r:t}),[s,...o]),[d]=j(u),n=M(d);return B((()=>n.current=u()),[u]),E(e,s,((...e)=>{n.current=C(l)?u():e[l],r([])}),[],o),n.current},E=(e,s,t,o=[],l=[],...r)=>O((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...l,t,...r);return()=>null==s?void 0:s.delListener(u)}),[s,...l,...o,...r]),F=(e,s,t,o=[],l=v,r=[],...u)=>{const d=V(e);return q((e=>k(d,(o=>k(t(e,o),(e=>l(o["set"+s](...u,e),e)))))),[d,s,...o,...r,...u])},G=(e,s,t=v,o=[],...l)=>{const r=V(e);return q((()=>t(null==r?void 0:r["del"+s](...l))),[r,s,...o,...l])},Q=(e,s,t)=>{const o=x(e);return q((()=>null==o?void 0:o[s](t)),[o,s,t])},U=e=>A(u,V(e),[],[]),z=(e,s)=>A(n,V(s),[],[e]),H=(e,s,t,o=0,l,r)=>A(i,V(r),[],[e,s,t,o,l],6),J=(e,s,t)=>A(c,V(t),[],[e,s]),K=(e,s,t,o)=>A(I,V(o),void 0,[e,s,t],4),N=e=>A(p,V(e),[],[]),W=(e,s)=>A(b,V(s),void 0,[e]),X=(e,s)=>A("Metric",L(s),void 0,[e]),Y=(e,s)=>A("SliceIds",S(s),[],[e]),Z=(e,s,t)=>A("SliceRowIds",S(t),[],[e,s]),$=(e,s,t)=>A("RemoteRowId",T(t),void 0,[e,s]),_=(e,s,t)=>A("LocalRowIds",T(t),[],[e,s]),ee=(e,s,t)=>A("LinkedRowIds",T(t),[],[e,s]),se=(e,s)=>A("ResultRowIds",P(s),[],[e]),te=(e,s,t,o=0,l,r)=>A("ResultSortedRowIds",P(r),[],[e,s,t,o,l],6),oe=(e,s,t)=>A("ResultCellIds",P(t),[],[e,s]),le=(e,s,t,o)=>A("ResultCell",P(o),void 0,[e,s,t]),re=e=>A("CheckpointIds",x(e),[[],void 0,[]]),ue=(e,s)=>A("Checkpoint",x(s),void 0,[e]),de=e=>Q(e,"goBackward"),ne=e=>Q(e,"goForward");var ie=Object.defineProperty,ae=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,be=(e,s,t)=>s in e?ie(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Re=(e,s)=>{for(var t in s||(s={}))we.call(s,t)&&be(e,t,s[t]);if(Ie)for(var t of Ie(s))pe.call(s,t)&&be(e,t,s[t]);return e},Ce=(e,s)=>ae(e,ce(s)),ke=(e,s)=>{var t={};for(var o in e)we.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&Ie)for(var o of Ie(e))s.indexOf(o)<0&&pe.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ve,useMemo:ge}=s,me=({tableId:e,store:s,rowComponent:t=Pe,getRowComponentProps:o,separator:l,debugIds:r},u)=>Se(R(u,(l=>ve(t,Ce(Re({},Le(o,l)),{key:l,tableId:e,rowId:l,store:s,debugIds:r})))),l,r,e),ye=({queryId:e,queries:s,resultRowComponent:t=Me,getResultRowComponentProps:o,separator:l,debugIds:r},u)=>Se(R(u,(l=>ve(t,Ce(Re({},Le(o,l)),{key:l,queryId:e,rowId:l,queries:s,debugIds:r})))),l,r,e),he=e=>{const s=T(e);return[s,null==s?void 0:s.getStore()]},fe=({relationshipId:e,relationships:s,rowComponent:t=Pe,getRowComponentProps:o,separator:l,debugIds:r},u,d)=>{const[n,i]=he(s),a=null==n?void 0:n.getLocalTableId(e),c=u(e,d,n);return Se(R(c,(e=>ve(t,Ce(Re({},Le(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),l,r,d)},Ve=e=>({checkpoints:s,checkpointComponent:t=je,getCheckpointComponentProps:o,separator:l,debugIds:r})=>{const u=x(s);return Se(R(e(re(u)),(e=>ve(t,Ce(Re({},Le(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),l)},Le=(e,s)=>C(e)?{}:e(s),Se=(e,s,t,o)=>{const l=C(s)||!Array.isArray(e)?e:R(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",l,"}"]:l},Te=({tableId:e,rowId:s,cellId:t,store:l,debugIds:r})=>{var u;return Se(o+(null!=(u=K(e,s,t,l))?u:o),void 0,r,t)},Pe=({tableId:e,rowId:s,store:t,cellComponent:o=Te,getCellComponentProps:l,separator:r,debugIds:u})=>Se(R(J(e,s,t),(r=>ve(o,Ce(Re({},Le(l,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:u})))),r,u,s),xe=e=>me(e,z(e.tableId,e.store)),qe=({valueId:e,store:s,debugIds:t})=>{var l;return Se(o+(null!=(l=W(e,s))?l:o),void 0,t,e)},Oe=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Pe,getRowComponentProps:l,separator:r,debugIds:u})=>{const d=S(t),n=null==d?void 0:d.getStore(),i=null==d?void 0:d.getTableId(e),a=Z(e,s,d);return Se(R(a,(e=>ve(o,Ce(Re({},Le(l,e)),{key:e,tableId:i,rowId:e,store:n,debugIds:u})))),r,u,s)},Be=({queryId:e,rowId:s,cellId:t,queries:l,debugIds:r})=>{var u;return Se(o+(null!=(u=le(e,s,t,l))?u:o),void 0,r,t)},Me=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Be,getResultCellComponentProps:l,separator:r,debugIds:u})=>Se(R(oe(e,s,t),(r=>ve(o,Ce(Re({},Le(l,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),je=({checkpoints:e,checkpointId:s,debugIds:t})=>{var l;return Se(null!=(l=ue(s,e))?l:o,void 0,t,s)},De=Ve((e=>e[0])),Ae=Ve((e=>C(e[1])?[]:[e[1]])),Ee=Ve((e=>e[2]));e.BackwardCheckpointsView=De,e.CellView=Te,e.CheckpointView=je,e.CurrentCheckpointView=Ae,e.ForwardCheckpointsView=Ee,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Oe,getSliceComponentProps:o,separator:l,debugIds:r})=>Se(R(Y(e,s),(l=>ve(t,Ce(Re({},Le(o,l)),{key:l,indexId:e,sliceId:l,indexes:s,debugIds:r})))),l,r,e),e.LinkedRowsView=e=>fe(e,ee,e.firstRowId),e.LocalRowsView=e=>fe(e,_,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var l;return Se(null!=(l=X(e,s))?l:o,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:o,metricsById:l,indexes:r,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(y);return ve(y.Provider,{value:ge((()=>[null!=e?e:p[0],Re(Re({},p[1]),t),null!=o?o:p[2],Re(Re({},p[3]),l),null!=r?r:p[4],Re(Re({},p[5]),u),null!=d?d:p[6],Re(Re({},p[7]),n),null!=i?i:p[8],Re(Re({},p[9]),a),null!=c?c:p[10],Re(Re({},p[11]),I)]),[e,t,o,l,r,u,d,n,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Pe,getRowComponentProps:l,debugIds:r})=>{const[u,d]=he(t),n=null==u?void 0:u.getRemoteTableId(e),i=$(e,s,u);return Se(C(n)||C(i)?null:ve(o,Ce(Re({},Le(l,i)),{key:i,tableId:n,rowId:i,store:d,debugIds:r})),void 0,r,s)},e.ResultCellView=Be,e.ResultRowView=Me,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ke(s,["cellId","descending","offset","limit"]);return ye(u,te(u.queryId,t,o,l,r,u.queries))},e.ResultTableView=e=>ye(e,se(e.queryId,e.queries)),e.RowView=Pe,e.SliceView=Oe,e.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ke(s,["cellId","descending","offset","limit"]);return me(u,H(u.tableId,t,o,l,r,u.store))},e.TableView=xe,e.TablesView=({store:e,tableComponent:s=xe,getTableComponentProps:t,separator:o,debugIds:l})=>Se(R(U(e),(o=>ve(s,Ce(Re({},Le(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),o),e.ValueView=qe,e.ValuesView=({store:e,valueComponent:s=qe,getValueComponentProps:t,separator:o,debugIds:l})=>Se(R(N(e),(o=>ve(s,Ce(Re({},Le(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),o),e.tableView=me,e.useAddRowCallback=(e,s,t=[],o,l=v,r=[])=>{const u=V(o);return q((t=>k(u,(o=>k(s(t,o),(s=>l(o.addRow(e,s),o,s)))))),[u,e,...t,...r])},e.useCell=K,e.useCellIds=J,e.useCellIdsListener=(e,s,t,o,l,r)=>E(c,V(r),t,o,[e,s],l),e.useCellListener=(e,s,t,o,l,r,u)=>E(I,V(u),o,l,[e,s,t],r),e.useCheckpoint=ue,e.useCheckpointIds=re,e.useCheckpointIdsListener=(e,s,t)=>E("CheckpointIds",x(t),e,s),e.useCheckpointListener=(e,s,t,o)=>E("Checkpoint",x(o),s,t,[e]),e.useCheckpoints=e=>h(e,10),e.useCreateCheckpoints=(e,s,t)=>D(e,s,t),e.useCreateIndexes=(e,s,t)=>D(e,s,t),e.useCreateMetrics=(e,s,t)=>D(e,s,t),e.useCreatePersister=(e,s,t=[],o,l=[])=>{const[,r]=j(),u=B((()=>s(e)),[e,...t]);return O((()=>{var e;return e=function*(){yield null==o?void 0:o(u),r(1)},new Promise(((s,t)=>{var o=s=>{try{r(e.next(s))}catch(e){t(e)}},l=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,l);r((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...l]),u},e.useCreateQueries=(e,s,t)=>D(e,s,t),e.useCreateRelationships=(e,s,t)=>D(e,s,t),e.useCreateStore=(e,s=[])=>B(e,s),e.useDelCellCallback=(e,s,t,o,l,r,u)=>G(l,I,r,u,e,s,t,o),e.useDelRowCallback=(e,s,t,o,l)=>G(t,a,o,l,e,s),e.useDelTableCallback=(e,s,t,o)=>G(s,d,t,o,e),e.useDelTablesCallback=(e,s,t)=>G(e,r,s,t),e.useDelValueCallback=(e,s,t,o)=>G(s,b,t,o,e),e.useDelValuesCallback=(e,s,t)=>G(e,w,s,t),e.useGoBackwardCallback=de,e.useGoForwardCallback=ne,e.useGoToCallback=(e,s=[],t,o=v,l=[])=>{const r=x(t);return q((s=>k(r,(t=>k(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...l])},e.useIndexes=e=>h(e,4),e.useLinkedRowIds=ee,e.useLinkedRowIdsListener=(e,s,t,o,l)=>E("LinkedRowIds",T(l),t,o,[e,s]),e.useLocalRowIds=_,e.useLocalRowIdsListener=(e,s,t,o,l)=>E("LocalRowIds",T(l),t,o,[e,s]),e.useMetric=X,e.useMetricListener=(e,s,t,o)=>E("Metric",L(o),s,t,[e]),e.useMetrics=e=>h(e,2),e.useQueries=e=>h(e,8),e.useRedoInformation=e=>{var s;const t=x(e),[,,[l]]=re(t);return[!C(l),ne(t),l,null!=(s=k(l,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o]},e.useRelationships=e=>h(e,6),e.useRemoteRowId=$,e.useRemoteRowIdListener=(e,s,t,o,l)=>E("RemoteRowId",T(l),t,o,[e,s]),e.useResultCell=le,e.useResultCellIds=oe,e.useResultCellIdsListener=(e,s,t,o,l)=>E("ResultCellIds",P(l),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,l,r)=>E("ResultCell",P(r),o,l,[e,s,t]),e.useResultRow=(e,s,t)=>A("ResultRow",P(t),{},[e,s]),e.useResultRowIds=se,e.useResultRowIdsListener=(e,s,t,o)=>E("ResultRowIds",P(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,l)=>E("ResultRow",P(l),t,o,[e,s]),e.useResultSortedRowIds=te,e.useResultSortedRowIdsListener=(e,s,t,o,l,r,u,d)=>E("ResultSortedRowIds",P(d),r,u,[e,s,t,o,l]),e.useResultTable=(e,s)=>A("ResultTable",P(s),{},[e]),e.useResultTableListener=(e,s,t,o)=>E("ResultTable",P(o),s,t,[e]),e.useRow=(e,s,t)=>A(a,V(t),{},[e,s]),e.useRowIds=z,e.useRowIdsListener=(e,s,t,o,l)=>E(n,V(l),s,t,[e],o),e.useRowListener=(e,s,t,o,l,r)=>E(a,V(r),t,o,[e,s],l),e.useSetCellCallback=(e,s,t,o,l,r,u,d)=>F(r,I,o,l,u,d,e,s,t),e.useSetCheckpointCallback=(e=v,s=[],t,o=v,l=[])=>{const r=x(t);return q((s=>k(r,(t=>{const l=e(s);o(t.addCheckpoint(l),t,l)}))),[r,...s,...l])},e.useSetPartialRowCallback=(e,s,t,o,l,r,u)=>F(l,"PartialRow",t,o,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,o,l)=>F(t,"PartialValues",e,s,o,l),e.useSetRowCallback=(e,s,t,o,l,r,u)=>F(l,a,t,o,r,u,e,s),e.useSetTableCallback=(e,s,t,o,l,r)=>F(o,d,s,t,l,r,e),e.useSetTablesCallback=(e,s,t,o,l)=>F(t,r,e,s,o,l),e.useSetValueCallback=(e,s,t,o,l,r)=>F(o,b,s,t,l,r,e),e.useSetValuesCallback=(e,s,t,o,l)=>F(t,w,e,s,o,l),e.useSliceIds=Y,e.useSliceIdsListener=(e,s,t,o)=>E("SliceIds",S(o),s,t,[e]),e.useSliceRowIds=Z,e.useSliceRowIdsListener=(e,s,t,o,l)=>E("SliceRowIds",S(l),t,o,[e,s]),e.useSortedRowIds=H,e.useSortedRowIdsListener=(e,s,t,o,l,r,u,d,n)=>E(i,V(n),r,u,[e,s,t,o,l],d),e.useStore=e=>h(e,0),e.useTable=(e,s)=>A(d,V(s),{},[e]),e.useTableIds=U,e.useTableIdsListener=(e,s,t,o)=>E(u,V(o),e,s,[],t),e.useTableListener=(e,s,t,o,l)=>E(d,V(l),s,t,[e],o),e.useTables=e=>A(r,V(e),{}),e.useTablesListener=(e,s,t,o)=>E(r,V(o),e,s,[],t),e.useUndoInformation=e=>{var s;const t=x(e),[l,r]=re(t);return[(u=l,!(0==(e=>e.length)(u))),de(t),r,null!=(s=k(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o];var u},e.useValue=W,e.useValueIds=N,e.useValueIdsListener=(e,s,t,o)=>E(p,V(o),e,s,[],t),e.useValueListener=(e,s,t,o,l)=>E(b,V(l),s,t,[e],o),e.useValues=e=>A(w,V(e),{}),e.useValuesListener=(e,s,t,o)=>E(w,V(o),e,s,[],t)},"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": "2.2.6",
3
+ "version": "3.0.0-beta.1",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -63,40 +63,40 @@
63
63
  "publishPackage": "gulp publishPackage"
64
64
  },
65
65
  "devDependencies": {
66
- "@babel/cli": "^7.19.3",
67
- "@babel/core": "^7.20.5",
66
+ "@babel/cli": "^7.20.7",
67
+ "@babel/core": "^7.20.12",
68
68
  "@babel/preset-env": "^7.20.2",
69
69
  "@babel/preset-react": "^7.18.6",
70
70
  "@babel/preset-typescript": "^7.18.6",
71
- "@rollup/plugin-replace": "^5.0.1",
72
- "@rollup/plugin-terser": "^0.1.0",
71
+ "@rollup/plugin-replace": "^5.0.2",
72
+ "@rollup/plugin-terser": "^0.3.0",
73
73
  "@types/asciichart": "^1.5.6",
74
74
  "@types/expect-puppeteer": "^5.0.2",
75
75
  "@types/http-server": "^0.12.1",
76
- "@types/jest": "^29.2.4",
76
+ "@types/jest": "^29.2.6",
77
77
  "@types/jest-environment-puppeteer": "^5.0.3",
78
78
  "@types/less": "^3.0.3",
79
- "@types/node": "^18.11.14",
79
+ "@types/node": "^18.11.18",
80
80
  "@types/puppeteer": "^5.4.7",
81
- "@types/react": "^17.0.41",
82
- "@types/react-dom": "^17.0.14",
83
- "@types/react-test-renderer": "^17.0.1",
81
+ "@types/react": "^18.0.27",
82
+ "@types/react-dom": "^18.0.10",
83
+ "@types/react-test-renderer": "^18.0.0",
84
84
  "@types/tmp": "^0.2.3",
85
- "@typescript-eslint/eslint-plugin": "^5.46.1",
86
- "@typescript-eslint/parser": "^5.46.1",
85
+ "@typescript-eslint/eslint-plugin": "^5.48.2",
86
+ "@typescript-eslint/parser": "^5.48.2",
87
87
  "asciichart": "^1.5.25",
88
88
  "babel-eslint": "^10.1.0",
89
89
  "babel-jest": "^29.3.1",
90
90
  "babel-preset-minify": "^0.5.2",
91
91
  "buffer-replace": "^1.0.0",
92
92
  "country-flag-emoji-json": "^2.0.0",
93
- "cspell": "^6.17.0",
94
- "esbuild": "^0.16.5",
95
- "eslint": "^8.29.0",
96
- "eslint-config-prettier": "^8.5.0",
97
- "eslint-plugin-jest": "^27.1.6",
98
- "eslint-plugin-jsdoc": "^39.6.4",
99
- "eslint-plugin-react": "^7.31.11",
93
+ "cspell": "^6.19.2",
94
+ "esbuild": "^0.17.4",
95
+ "eslint": "^8.32.0",
96
+ "eslint-config-prettier": "^8.6.0",
97
+ "eslint-plugin-jest": "^27.2.1",
98
+ "eslint-plugin-jsdoc": "^39.6.7",
99
+ "eslint-plugin-react": "^7.32.1",
100
100
  "eslint-plugin-react-hooks": "^4.6.0",
101
101
  "gulp": "^4.0.2",
102
102
  "gulp-gzip": "^1.4.2",
@@ -106,19 +106,19 @@
106
106
  "jest-fetch-mock": "^3.0.3",
107
107
  "jest-puppeteer": "^6.2.0",
108
108
  "less": "^4.1.3",
109
- "prettier": "^2.8.1",
109
+ "prettier": "^2.8.3",
110
110
  "puppeteer": "^17.1.3",
111
- "react": "^17.0.2",
112
- "react-dom": "^17.0.2",
113
- "react-test-renderer": "^17.0.2",
114
- "rollup": "^3.7.4",
111
+ "react": "^18.2.0",
112
+ "react-dom": "^18.2.0",
113
+ "react-test-renderer": "^18.2.0",
114
+ "rollup": "^3.10.1",
115
115
  "rollup-plugin-esbuild": "^5.0.0",
116
116
  "rollup-plugin-gzip": "^3.1.0",
117
117
  "rollup-plugin-preserve-shebang": "^1.0.1",
118
118
  "rollup-plugin-prettier": "^3.0.0",
119
- "tinydocs": "^0.1.15",
119
+ "tinydocs": "^0.1.23",
120
120
  "tmp": "^0.2.1",
121
- "ts-unused-exports": "^8.0.5",
121
+ "ts-unused-exports": "^9.0.2",
122
122
  "typescript": "4.9.4"
123
123
  },
124
124
  "peerDependencies": {
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 local‑first apps.</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Why sacrifice store features for bundle size? And why should the cloud do all the work <a href="https://www.inkandswitch.com/local-first/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Familiar concepts of <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>, and <a href="#apply-schemas-to-tables">schematization</a> to model your data domain.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so your UI only spends cycles on the data that changes.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#configure-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state! - out of the box.</li><li>Easily <a href="#persist-data-to-browser-file-or-server">sync your data</a> to local or remote storage, and use <a href="#call-hooks-to-bind-to-data">idiomatic bindings</a> to your UI.</li><li><em>NEW!</em> <a href="#generate-orm-like-apis">Generate ORM-like APIs</a> in TypeScript, based on your schema or inferred from actual data.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">3.5kB - 7.9kB</a> when compressed, and has zero dependencies. And of course it&#x27;s <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>. Other <a href="https://tinybase.org/guides/faq/">FAQs</a>?</p></section><p><a id="new" href="https://tinybase.org/guides/releases/#v2-2"><em>NEW!</em> v2.2 release</a></p><hr><p><a id="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><h2 id="set-and-get-tables-rows-and-cells">Set and get tables, rows, and cells.</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/table"><code>Table</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a>, or <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values by their <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a>. And of course you can easily get the values back out again.</p><p>Read more about setting and changing 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 local‑first apps.</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Why sacrifice store features for bundle size? And why should the cloud do all the work <a href="https://www.inkandswitch.com/local-first/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Familiar concepts of <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>, and <a href="#apply-schemas-to-tables">schematization</a> to model your data domain.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so your UI only spends cycles on the data that changes.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#configure-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state! - out of the box.</li><li>Easily <a href="#persist-data-to-browser-file-or-server">sync your data</a> to local or remote storage, and use <a href="#call-hooks-to-bind-to-data">idiomatic bindings</a> to your UI.</li><li><em>NEW!</em> <a href="#generate-orm-like-apis">Generate ORM-like APIs</a> in TypeScript, based on your schema or inferred from actual data.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">4.2kB - 8.7kB</a> when compressed, and has zero dependencies. And of course it&#x27;s <a href="#well-tested-and-documented">well tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>. Other <a href="https://beta.tinybase.org/guides/faq/">FAQs</a>?</p></section><p><a id="new" href="https://beta.tinybase.org/guides/releases/#v2-2"><em>NEW!</em> v2.2 release</a></p><hr><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="set-and-get-tables-rows-and-cells">Set and get tables, rows, and cells.</h2><p>Creating a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a>, <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a>, or <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> values by their <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get the values back out again.</p><p>Read more about setting and changing data in <a href="https://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()
@@ -9,7 +9,7 @@ console.log(store.getRow('pets', 'fido'));
9
9
  // -> {species: 'dog', color: 'brown'}
10
10
  ```
11
11
 
12
- <section><h2 id="register-listeners-at-any-granularity">Register listeners at any granularity.</h2><p>The magic starts to happen when you register listeners on a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a>, or <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a>. They get called when any part of that object changes. You can also use wildcards - useful when you don&#x27;t know the <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a> of the objects that might change.</p><p>Read more about listeners in the <a href="https://tinybase.org/guides/the-basics/listening-to-stores">Listening To Stores</a> guide.</p></section>
12
+ <section><h2 id="register-listeners-at-any-granularity">Register listeners at any granularity.</h2><p>The magic starts to happen when you register listeners on a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>, <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a>, <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a>, or <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a>. They get called when any part of that object changes. You can also use wildcards - useful when you don&#x27;t know the <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a> of the objects that might change.</p><p>Read more about listeners in the <a href="https://beta.tinybase.org/guides/the-basics/listening-to-stores/">Listening To Stores</a> guide.</p></section>
13
13
 
14
14
  ```js
15
15
  const listenerId = store.addTableListener('pets', () =>
@@ -22,7 +22,7 @@ store.setCell('pets', 'fido', 'sold', false);
22
22
  store.delListener(listenerId);
23
23
  ```
24
24
 
25
- <section><h2 id="call-hooks-to-bind-to-data">Call hooks to bind to data.</h2><p>If you&#x27;re using React in your application, the optional <a href="https://tinybase.org/api/ui-react"><code>ui-react</code></a> module provides hooks to bind to the data in a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a>.</p><p>More magic! The <a href="https://tinybase.org/api/ui-react/functions/store-hooks/usecell"><code>useCell</code></a> hook in this example fetches the dog&#x27;s color. But it also registers a listener on that cell that will fire and re-render the component whenever the value changes.</p><p>Basically you simply describe what data you want in your user interface and TinyBase will take care of the whole lifecycle of updating it for you.</p><p>Read more about the using hooks in the <a href="https://tinybase.org/guides/building-uis/using-react-hooks">Using React Hooks</a> guide.</p></section>
25
+ <section><h2 id="call-hooks-to-bind-to-data">Call hooks to bind to data.</h2><p>If you&#x27;re using React in your application, the optional <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module provides hooks to bind to the data in a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>.</p><p>More magic! The <a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usecell/"><code>useCell</code></a> hook in this example fetches the dog&#x27;s color. But it also registers a listener on that cell that will fire and re-render the component whenever the value changes.</p><p>Basically you simply describe what data you want in your user interface and TinyBase will take care of the whole lifecycle of updating it for you.</p><p>Read more about the using hooks in the <a href="https://beta.tinybase.org/guides/building-uis/using-react-hooks/">Using React Hooks</a> guide.</p></section>
26
26
 
27
27
  ```jsx
28
28
  const App1 = () => {
@@ -31,7 +31,8 @@ const App1 = () => {
31
31
  };
32
32
 
33
33
  const app = document.createElement('div');
34
- ReactDOM.render(<App1 />, app);
34
+ const root = ReactDOMClient.createRoot(app);
35
+ root.render(<App1 />);
35
36
  console.log(app.innerHTML);
36
37
  // -> 'Color: brown'
37
38
 
@@ -40,7 +41,7 @@ console.log(app.innerHTML);
40
41
  // -> 'Color: walnut'
41
42
  ```
42
43
 
43
- <section><h2 id="use-components-to-make-reactive-apps">Use components to make reactive apps.</h2><p>The react module provides simple React components with bindings that make it easy to create a fully reactive user interface based on a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a>.</p><p>In this example, the library&#x27;s <a href="https://tinybase.org/api/ui-react/functions/store-components/rowview"><code>RowView</code></a> component just needs a reference to the <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a>, the <code>tableId</code>, and the <code>rowId</code> in order to render the contents of that row. An optional <code>cellComponent</code> prop lets you override how you want each <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> rendered. Again, all the listeners and updates are taken care of for you.</p><p>The module also includes a context Provider that sets up default for an entire app to use, reducing the need to drill all your props down into your app&#x27;s hierarchy.</p><p>Most of the demos showcase the use of these React hooks and components. Take a look at <a href="https://tinybase.org/demos/todo-app/todo-app-v1-the-basics">Todo App v1 (the basics)</a> to see these user interface binding patterns in action.</p><p>Read more about the <a href="https://tinybase.org/api/ui-react"><code>ui-react</code></a> module in the <a href="https://tinybase.org/guides/building-uis">Building UIs</a> guides.</p></section>
44
+ <section><h2 id="use-components-to-make-reactive-apps">Use components to make reactive apps.</h2><p>The react module provides simple React components with bindings that make it easy to create a fully reactive user interface based on a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>.</p><p>In this example, the library&#x27;s <a href="https://beta.tinybase.org/api/ui-react/functions/store-components/rowview/"><code>RowView</code></a> component just needs a reference to the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>, the <code>tableId</code>, and the <code>rowId</code> in order to render the contents of that row. An optional <code>cellComponent</code> prop lets you override how you want each <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> rendered. Again, all the listeners and updates are taken care of for you.</p><p>The module also includes a context Provider that sets up default for an entire app to use, reducing the need to drill all your props down into your app&#x27;s hierarchy.</p><p>Most of the demos showcase the use of these React hooks and components. Take a look at <a href="https://beta.tinybase.org/demos/todo-app/todo-app-v1-the-basics/">Todo App v1 (the basics)</a> to see these user interface binding patterns in action.</p><p>Read more about the <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module in the <a href="https://beta.tinybase.org/guides/building-uis/">Building UIs</a> guides.</p></section>
44
45
 
45
46
  ```jsx
46
47
  const MyCellView = (props) => (
@@ -59,7 +60,7 @@ const App2 = () => (
59
60
  />
60
61
  );
61
62
 
62
- ReactDOM.render(<App2 />, app);
63
+ root.render(<App2 />);
63
64
  console.log(app.innerHTML);
64
65
  // -> 'species: dog<hr>color: walnut<hr>sold: false<hr>'
65
66
 
@@ -67,13 +68,13 @@ store.setCell('pets', 'fido', 'sold', true);
67
68
  console.log(app.innerHTML);
68
69
  // -> 'species: dog<hr>color: walnut<hr>sold: true<hr>'
69
70
 
70
- ReactDOM.unmountComponentAtNode(app);
71
+ root.unmount();
71
72
  ```
72
73
 
73
- <section><h2 id="apply-schemas-to-tables">Apply schemas to tables.</h2><p>By default, a <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> can contain any arbitrary <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a>. But you can add a schema to a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a> to ensure that the values are always what you expect. For example, you can limit their types, and provide defaults. You can also create mutating listeners that can programmatically enforce a schema.</p><p>In this example, we set a second <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> without the <code>sold</code> <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> in it. The schema ensures it&#x27;s present with default of <code>false</code>.</p><p>Read more about schemas in the <a href="https://tinybase.org/guides/schemas-and-persistence/using-schemas">Using Schemas</a> guide.</p></section>
74
+ <section><h2 id="apply-schemas-to-tables">Apply schemas to tables.</h2><p>By default, a <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> can contain any arbitrary <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a>. But you can add a schema to a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> to ensure that the values are always what you expect. For example, you can limit their types, and provide defaults. You can also create mutating listeners that can programmatically enforce a schema.</p><p>In this example, we set a second <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> without the <code>sold</code> <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> in it. The schema ensures it&#x27;s present with default of <code>false</code>.</p><p>Read more about schemas in the <a href="https://beta.tinybase.org/guides/schemas-and-persistence/using-schemas/">Using Schemas</a> guide.</p></section>
74
75
 
75
76
  ```js
76
- store.setSchema({
77
+ store.setTablesSchema({
77
78
  pets: {
78
79
  species: {type: 'string'},
79
80
  color: {type: 'string'},
@@ -85,23 +86,23 @@ store.setRow('pets', 'felix', {species: 'cat'});
85
86
  console.log(store.getRow('pets', 'felix'));
86
87
  // -> {species: 'cat', sold: false}
87
88
 
88
- store.delSchema();
89
+ store.delTablesSchema();
89
90
  ```
90
91
 
91
- <section><h2 id="persist-data-to-browser-file-or-server">Persist data to browser, file, or server.</h2><p>You can easily persist a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a> between browser page reloads or sessions. You can also synchronize it with a web endpoint, or (if you&#x27;re using TinyBase in an appropriate environment), load and save it to a file.</p><p>Read more about persisters in the <a href="https://tinybase.org/guides/schemas-and-persistence/persisting-data">Persisting Data</a> guide.</p></section>
92
+ <section><h2 id="persist-data-to-browser-file-or-server">Persist data to browser, file, or server.</h2><p>You can easily persist a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> between browser page reloads or sessions. You can also synchronize it with a web endpoint, or (if you&#x27;re using TinyBase in an appropriate environment), load and save it to a file.</p><p>Read more about persisters in the <a href="https://beta.tinybase.org/guides/schemas-and-persistence/persisting-data/">Persisting Data</a> guide.</p></section>
92
93
 
93
94
  ```js
94
95
  const persister = createSessionPersister(store, 'demo');
95
96
  await persister.save();
96
97
 
97
98
  console.log(sessionStorage.getItem('demo'));
98
- // -> '{"pets":{"fido":{"species":"dog","color":"walnut","sold":true},"felix":{"species":"cat","sold":false}}}'
99
+ // -> '[{"pets":{"fido":{"species":"dog","color":"walnut","sold":true},"felix":{"species":"cat","sold":false}}},{}]'
99
100
 
100
101
  persister.destroy();
101
102
  sessionStorage.clear();
102
103
  ```
103
104
 
104
- <section><h2 id="build-complex-queries-with-tinyql">Build complex queries with <a href="https://tinybase.org/guides/making-queries/tinyql">TinyQL</a>.</h2><p>The <a href="https://tinybase.org/api/queries/interfaces/queries/queries"><code>Queries</code></a> object lets you query data across tables, with filtering and aggregation - using a SQL-adjacent syntax called <a href="https://tinybase.org/guides/making-queries/tinyql">TinyQL</a>.</p><p>Accessors and listeners let you sort and paginate the results efficiently, making building rich tabular interfaces easier than ever.</p><p>In this example, we have two tables: of pets and their owners. They are joined together by the pet&#x27;s ownerId <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a>. We select the pet&#x27;s species, and the owner&#x27;s state, and then aggregate the prices for the combinations.</p><p>We access the results by descending price, essentially answering the question: &quot;which is the highest-priced species, and in which state?&quot;</p><p>Needless to say, the results are reactive too! You can add listeners to queries just as easily as you do to raw tables.</p><p>Read more about <a href="https://tinybase.org/api/queries/interfaces/queries/queries"><code>Queries</code></a> in the <a href="https://tinybase.org/guides/releases/#v2-0">v2.0 Release Notes</a>, the <a href="https://tinybase.org/guides/making-queries">Making Queries</a> guide, and the <a href="https://tinybase.org/demos/car-analysis">Car Analysis</a> demo and <a href="https://tinybase.org/demos/movie-database">Movie Database</a> demo.</p></section>
105
+ <section><h2 id="build-complex-queries-with-tinyql">Build complex queries with <a href="https://beta.tinybase.org/guides/making-queries/tinyql/">TinyQL</a>.</h2><p>The <a href="https://beta.tinybase.org/api/queries/interfaces/queries/queries/"><code>Queries</code></a> object lets you query data across tables, with filtering and aggregation - using a SQL-adjacent syntax called <a href="https://beta.tinybase.org/guides/making-queries/tinyql/">TinyQL</a>.</p><p>Accessors and listeners let you sort and paginate the results efficiently, making building rich tabular interfaces easier than ever.</p><p>In this example, we have two tables: of pets and their owners. They are joined together by the pet&#x27;s ownerId <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a>. We select the pet&#x27;s species, and the owner&#x27;s state, and then aggregate the prices for the combinations.</p><p>We access the results by descending price, essentially answering the question: &quot;which is the highest-priced species, and in which state?&quot;</p><p>Needless to say, the results are reactive too! You can add listeners to queries just as easily as you do to raw tables.</p><p>Read more about <a href="https://beta.tinybase.org/api/queries/interfaces/queries/queries/"><code>Queries</code></a> in the <a href="https://beta.tinybase.org/guides/releases/#v2-0">v2.0 Release Notes</a>, the <a href="https://beta.tinybase.org/guides/making-queries/">Making Queries</a> guide, and the <a href="https://beta.tinybase.org/demos/car-analysis/">Car Analysis</a> demo and <a href="https://beta.tinybase.org/demos/movie-database/">Movie Database</a> demo.</p></section>
105
106
 
106
107
  ```js
107
108
  store
@@ -142,7 +143,7 @@ queries
142
143
  queries.destroy();
143
144
  ```
144
145
 
145
- <section><h2 id="define-metrics-and-aggregations">Define metrics and aggregations.</h2><p>A <a href="https://tinybase.org/api/metrics/interfaces/metrics/metrics"><code>Metrics</code></a> object makes it easy to keep a running aggregation of <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values in each <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> of a <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>. This is useful for counting rows, but also supports averages, ranges of values, or arbitrary aggregations.</p><p>In this example, we create a new table of the pet species, and keep a track of which is most expensive. When we add horses to our pet store, the listener detects that the highest price has changed.</p><p>Read more about <a href="https://tinybase.org/api/metrics/interfaces/metrics/metrics"><code>Metrics</code></a> in the <a href="https://tinybase.org/guides/metrics-and-indexes/using-metrics">Using Metrics</a> guide.</p></section>
146
+ <section><h2 id="define-metrics-and-aggregations">Define metrics and aggregations.</h2><p>A <a href="https://beta.tinybase.org/api/metrics/interfaces/metrics/metrics/"><code>Metrics</code></a> object makes it easy to keep a running aggregation of <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> values in each <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> of a <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a>. This is useful for counting rows, but also supports averages, ranges of values, or arbitrary aggregations.</p><p>In this example, we create a new table of the pet species, and keep a track of which is most expensive. When we add horses to our pet store, the listener detects that the highest price has changed.</p><p>Read more about <a href="https://beta.tinybase.org/api/metrics/interfaces/metrics/metrics/"><code>Metrics</code></a> in the <a href="https://beta.tinybase.org/guides/metrics-and-indexes/using-metrics/">Using Metrics</a> guide.</p></section>
146
147
 
147
148
  ```js
148
149
  store.setTable('species', {
@@ -171,7 +172,7 @@ store.setCell('species', 'horse', 'price', 20);
171
172
  metrics.destroy();
172
173
  ```
173
174
 
174
- <section><h2 id="create-indexes-for-fast-lookups">Create indexes for fast lookups.</h2><p>An <a href="https://tinybase.org/api/indexes/interfaces/indexes/indexes"><code>Indexes</code></a> object makes it easy to look up all the <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> objects that have a certain value in a <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a>.</p><p>In this example, we create an index on the <code>species</code> <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values. We can then get the the list of distinct <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> value present for that index (known as &#x27;slices&#x27;), and the set of <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> objects that match each value.</p><p><a href="https://tinybase.org/api/indexes/interfaces/indexes/indexes"><code>Indexes</code></a> objects are reactive too. So you can set listeners on them just as you do for the data in the underlying <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a>.</p><p>Read more about <a href="https://tinybase.org/api/indexes/interfaces/indexes/indexes"><code>Indexes</code></a> in the <a href="https://tinybase.org/guides/metrics-and-indexes/using-indexes">Using Indexes</a> guide.</p></section>
175
+ <section><h2 id="create-indexes-for-fast-lookups">Create indexes for fast lookups.</h2><p>An <a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a> object makes it easy to look up all the <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> objects that have a certain value in a <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a>.</p><p>In this example, we create an index on the <code>species</code> <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> values. We can then get the the list of distinct <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> value present for that index (known as &#x27;slices&#x27;), and the set of <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> objects that match each value.</p><p><a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a> objects are reactive too. So you can set listeners on them just as you do for the data in the underlying <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>.</p><p>Read more about <a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a> in the <a href="https://beta.tinybase.org/guides/metrics-and-indexes/using-indexes/">Using Indexes</a> guide.</p></section>
175
176
 
176
177
  ```js
177
178
  const indexes = createIndexes(store);
@@ -195,7 +196,7 @@ store.setRow('pets', 'lowly', {species: 'worm'});
195
196
  indexes.destroy();
196
197
  ```
197
198
 
198
- <section><h2 id="model-relationships-between-tables">Model relationships between tables.</h2><p>A <a href="https://tinybase.org/api/relationships/interfaces/relationships/relationships"><code>Relationships</code></a> object lets you associate a <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> in a local <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a> with the <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a> of a <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a> in a remote <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>. You can also reference a table to itself to create linked lists.</p><p>In this example, the <code>species</code> <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> of the <code>pets</code> <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a> is used to create a relationship to the <code>species</code> <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>, so that we can access the price of a given pet.</p><p>Like everything else, you can set listeners on <a href="https://tinybase.org/api/relationships/interfaces/relationships/relationships"><code>Relationships</code></a> too.</p><p>Read more about <a href="https://tinybase.org/api/relationships/interfaces/relationships/relationships"><code>Relationships</code></a> in the <a href="https://tinybase.org/guides/relationships-and-checkpoints/using-relationships">Using Relationships</a> guide.</p></section>
199
+ <section><h2 id="model-relationships-between-tables">Model relationships between tables.</h2><p>A <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a> object lets you associate a <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> in a local <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a> with the <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a> of a <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> in a remote <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a>. You can also reference a table to itself to create linked lists.</p><p>In this example, the <code>species</code> <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> of the <code>pets</code> <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a> is used to create a relationship to the <code>species</code> <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a>, so that we can access the price of a given pet.</p><p>Like everything else, you can set listeners on <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a> too.</p><p>Read more about <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a> in the <a href="https://beta.tinybase.org/guides/relationships-and-checkpoints/using-relationships/">Using Relationships</a> guide.</p></section>
199
200
 
200
201
  ```js
201
202
  const relationships = createRelationships(store);
@@ -218,7 +219,7 @@ console.log(
218
219
  relationships.destroy();
219
220
  ```
220
221
 
221
- <section><h2 id="set-checkpoints-for-an-undo-stack">Set checkpoints for an undo stack.</h2><p>A <a href="https://tinybase.org/api/checkpoints/interfaces/checkpoints/checkpoints"><code>Checkpoints</code></a> object lets you set checkpoints on a <a href="https://tinybase.org/api/store/interfaces/store/store"><code>Store</code></a>. Move forward and backward through them to create undo and redo functions.</p><p>In this example, we set a checkpoint, then sell one of the pets. Later, the pet is brought back to the shop, and we go back to that checkpoint to revert the store to its previous state.</p><p>Read more about <a href="https://tinybase.org/api/checkpoints/interfaces/checkpoints/checkpoints"><code>Checkpoints</code></a> in the <a href="https://tinybase.org/guides/relationships-and-checkpoints/using-checkpoints">Using Checkpoints</a> guide.</p></section>
222
+ <section><h2 id="set-checkpoints-for-an-undo-stack">Set checkpoints for an undo stack.</h2><p>A <a href="https://beta.tinybase.org/api/checkpoints/interfaces/checkpoints/checkpoints/"><code>Checkpoints</code></a> object lets you set checkpoints on a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>. Move forward and backward through them to create undo and redo functions.</p><p>In this example, we set a checkpoint, then sell one of the pets. Later, the pet is brought back to the shop, and we go back to that checkpoint to revert the store to its previous state.</p><p>Read more about <a href="https://beta.tinybase.org/api/checkpoints/interfaces/checkpoints/checkpoints/"><code>Checkpoints</code></a> in the <a href="https://beta.tinybase.org/guides/relationships-and-checkpoints/using-checkpoints/">Using Checkpoints</a> guide.</p></section>
222
223
 
223
224
  ```js
224
225
  const checkpoints = createCheckpoints(store);
@@ -235,7 +236,7 @@ console.log(store.getCell('pets', 'felix', 'sold'));
235
236
  // -> false
236
237
  ```
237
238
 
238
- <section><h2 id="generate-orm-like-apis">Generate ORM-like APIs</h2><p>You can easily create TypeScript <code>.d.ts</code> definitions that model your data and encourage type-safety when reading and writing data - as well as <code>.ts</code> implementations that provide ORM-like methods for your named tables.</p><p>Read more about TinyBase&#x27;s tools and CLI in the <a href="https://tinybase.org/guides/developer-tools">Developer Tools</a> guide.</p></section>
239
+ <section><h2 id="generate-orm-like-apis">Generate ORM-like APIs</h2><p>You can easily create TypeScript <code>.d.ts</code> definitions that model your data and encourage type-safety when reading and writing data - as well as <code>.ts</code> implementations that provide ORM-like methods for your named tables.</p><p>Read more about TinyBase&#x27;s tools and CLI in the <a href="https://beta.tinybase.org/guides/developer-tools/">Developer Tools</a> guide.</p></section>
239
240
 
240
241
  ```js yolo
241
242
  const tools = createTools(store);
@@ -254,4 +255,4 @@ export const createShop: typeof createShopDecl = () => {
254
255
  };
255
256
  ```
256
257
 
257
- <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>3.5kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>7.9kB</em>.</p><p>The <code>ui-react</code> adaptor is just another <em>3.2kB</em>, the developer <a href="https://tinybase.org/api/tools"><code>tools</code></a> module is <em>4.7kB</em>, and everything is fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured 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>3.5kB</td><td>7.7kB</td><td>33.2kB</td><td>127.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics">metrics</a></th><td>1.8kB</td><td>3.5kB</td><td>14.7kB</td><td>29.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.5kB</td><td>33.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships">relationships</a></th><td>1.8kB</td><td>3.6kB</td><td>16.6kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries">queries</a></th><td>2.6kB</td><td>5.5kB</td><td>24.9kB</td><td>106.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints">checkpoints</a></th><td>1.4kB</td><td>2.8kB</td><td>11.3kB</td><td>33.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters">persisters</a></th><td>0.8kB</td><td>1.6kB</td><td>5.0kB</td><td>26.8kB</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>7.9kB</td><td>18.4kB</td><td>81.0kB</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 to get 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,249</td><td>1,249</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,353</td><td>1,353</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>511</td><td>511</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>471</td><td>471</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">2,157</td></tr><tr><th class="right">Assertions</th><td colspan="3">11,068</td></tr></tbody></table></div><hr><p><a id="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><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a> and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/2.2.6">NPM</a>.</li><li><a href="https://github.com/tinyplex/tinybase/issues">Issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was an interesting exercise in API design, minification, and documentation. 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 we hope you enjoy using it!</p></section>
258
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://beta.tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>4.2kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>8.7kB</em>.</p><p>The <code>ui-react</code> adaptor is just another <em>3.4kB</em>, the developer <a href="https://beta.tinybase.org/api/tools/"><code>tools</code></a> module is <em>5.4kB</em>, and everything is fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured in the <a href="https://beta.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://beta.tinybase.org/api/store/">store</a></th><td>4.2kB</td><td>10.0kB</td><td>43.8kB</td><td>183.8kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>14.8kB</td><td>29.1kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.6kB</td><td>33.9kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/relationships/">relationships</a></th><td>1.8kB</td><td>3.6kB</td><td>16.8kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/queries/">queries</a></th><td>2.6kB</td><td>5.5kB</td><td>24.9kB</td><td>106.8kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.0kB</td><td>12.5kB</td><td>33.4kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.7kB</td><td>5.2kB</td><td>27.2kB</td></tr><tr><th class="right"><a href="https://beta.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>8.7kB</td><td>21.0kB</td><td>92.7kB</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 to get up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://beta.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,790</td><td>1,790</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,928</td><td>1,928</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>766</td><td>766</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>628</td><td>628</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">2,579</td></tr><tr><th class="right">Assertions</th><td colspan="3">12,399</td></tr></tbody></table></div><hr><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a> and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://beta.tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/3.0.0-beta.1">NPM</a>.</li><li><a href="https://github.com/tinyplex/tinybase/issues">Issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://hachyderm.io/@jamesgpearce">me</a> in API design, minification, and documentation. It could not have been built without these great <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it!</p></section>