tinybase 3.2.0-beta.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/cjs/checkpoints.cjs +1 -1
- package/lib/cjs/checkpoints.cjs.gz +0 -0
- package/lib/cjs/indexes.cjs +1 -1
- package/lib/cjs/indexes.cjs.gz +0 -0
- package/lib/cjs/metrics.cjs +1 -1
- package/lib/cjs/metrics.cjs.gz +0 -0
- package/lib/cjs/persisters.cjs +1 -1
- package/lib/cjs/persisters.cjs.gz +0 -0
- package/lib/cjs/queries.cjs +1 -1
- package/lib/cjs/queries.cjs.gz +0 -0
- package/lib/cjs/relationships.cjs +1 -1
- package/lib/cjs/relationships.cjs.gz +0 -0
- package/lib/cjs/store.cjs +1 -1
- package/lib/cjs/store.cjs.gz +0 -0
- package/lib/cjs/tinybase.cjs +1 -1
- package/lib/cjs/tinybase.cjs.gz +0 -0
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/checkpoints.cjs +1 -1
- package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
- package/lib/cjs-es6/indexes.cjs +1 -1
- package/lib/cjs-es6/indexes.cjs.gz +0 -0
- package/lib/cjs-es6/metrics.cjs +1 -1
- package/lib/cjs-es6/metrics.cjs.gz +0 -0
- package/lib/cjs-es6/persisters.cjs +1 -1
- package/lib/cjs-es6/persisters.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/relationships.cjs +1 -1
- package/lib/cjs-es6/relationships.cjs.gz +0 -0
- package/lib/cjs-es6/store.cjs +1 -1
- package/lib/cjs-es6/store.cjs.gz +0 -0
- package/lib/cjs-es6/tinybase.cjs +1 -1
- package/lib/cjs-es6/tinybase.cjs.gz +0 -0
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/checkpoints.js +2 -2
- package/lib/debug/indexes.js +2 -2
- package/lib/debug/metrics.js +2 -2
- package/lib/debug/persisters.js +2 -2
- package/lib/debug/queries.js +1 -1
- package/lib/debug/relationships.js +2 -2
- package/lib/debug/store.js +36 -35
- package/lib/debug/tinybase.js +39 -38
- package/lib/debug/tools.js +13 -4
- package/lib/debug/ui-react.js +3 -2
- package/lib/es6/checkpoints.js +1 -1
- package/lib/es6/checkpoints.js.gz +0 -0
- package/lib/es6/indexes.js +1 -1
- package/lib/es6/indexes.js.gz +0 -0
- package/lib/es6/metrics.js +1 -1
- package/lib/es6/metrics.js.gz +0 -0
- package/lib/es6/persisters.js +1 -1
- package/lib/es6/persisters.js.gz +0 -0
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/relationships.js +1 -1
- package/lib/es6/relationships.js.gz +0 -0
- package/lib/es6/store.js +1 -1
- package/lib/es6/store.js.gz +0 -0
- package/lib/es6/tinybase.js +1 -1
- package/lib/es6/tinybase.js.gz +0 -0
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/types/store.d.ts +84 -21
- package/lib/types/ui-react.d.ts +11 -0
- package/lib/types/with-schemas/store.d.ts +91 -21
- package/lib/types/with-schemas/ui-react.d.ts +12 -0
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/persisters.js +1 -1
- package/lib/umd/persisters.js.gz +0 -0
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/checkpoints.js +1 -1
- package/lib/umd-es6/checkpoints.js.gz +0 -0
- package/lib/umd-es6/indexes.js +1 -1
- package/lib/umd-es6/indexes.js.gz +0 -0
- package/lib/umd-es6/metrics.js +1 -1
- package/lib/umd-es6/metrics.js.gz +0 -0
- package/lib/umd-es6/persisters.js +1 -1
- package/lib/umd-es6/persisters.js.gz +0 -0
- package/lib/umd-es6/queries.js +1 -1
- package/lib/umd-es6/queries.js.gz +0 -0
- package/lib/umd-es6/relationships.js +1 -1
- package/lib/umd-es6/relationships.js.gz +0 -0
- package/lib/umd-es6/store.js +1 -1
- package/lib/umd-es6/store.js.gz +0 -0
- package/lib/umd-es6/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +50 -26
- package/readme.md +14 -14
package/lib/umd-es6/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",l=t(o),r="Ids",u="Table",n="Tables",d=u+r,i="Row",a=i+r,c="SortedRowIds",I="Cell",w=I+r,p="Value",b="Values",R=p+r,C=(e,s)=>e.map(s),k=e=>null==e,v=(e,s,t)=>k(e)?null==t?void 0:t():s(e),g=e=>t(e)==l,m=()=>{},{createContext:y,useContext:h}=s,f=y([]),V=(e,s)=>{const t=h(f);return k(e)?t[s]:g(e)?((e,s)=>v(e,(e=>e[s])))(t[s+1],e):e},L=(e,s)=>{const t=V(e,s);return k(e)||g(e)?t:e},S=e=>L(e,0),T=e=>L(e,2),P=e=>L(e,4),x=e=>L(e,6),q=e=>L(e,8),O=e=>L(e,10),{useCallback:B,useEffect:M,useMemo:j,useRef:D,useState:A}=s,E=(e,s,t=[])=>{const o=j((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},F=(e,s,t,o=[],l)=>{const[,r]=A(),u=B((()=>{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]),[n]=A(u),d=D(n);return j((()=>d.current=u()),[u]),G(e,s,((...e)=>{d.current=k(l)?u():e[l],r([])}),[],o),d.current},G=(e,s,t,o=[],l=[],...r)=>M((()=>{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]),Q=(e,s,t,o=[],l=m,r=[],...u)=>{const n=S(e);return B((e=>v(n,(o=>v(t(e,o),(e=>l(o["set"+s](...u,e),e)))))),[n,s,...o,...r,...u])},U=(e,s,t=m,o=[],...l)=>{const r=S(e);return B((()=>t(null==r?void 0:r["del"+s](...l))),[r,s,...o,...l])},z=(e,s,t)=>{const o=O(e);return B((()=>null==o?void 0:o[s](t)),[o,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(a,S(s),[],[e]),K=(e,s,t,o=0,l,r)=>F(c,S(r),[],[e,s,t,o,l],6),N=(e,s,t)=>F(w,S(t),[],[e,s]),W=(e,s,t,o)=>F(I,S(o),void 0,[e,s,t],4),X=e=>F(R,S(e),[],[]),Y=(e,s)=>F(p,S(s),void 0,[e]),Z=(e,s)=>F("Metric",T(s),void 0,[e]),$=(e,s)=>F("SliceIds",P(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",P(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",x(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",x(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",x(t),[],[e,s]),oe=(e,s)=>F("ResultRowIds",q(s),[],[e]),le=(e,s,t,o=0,l,r)=>F("ResultSortedRowIds",q(r),[],[e,s,t,o,l],6),re=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,o)=>F("ResultCell",q(o),void 0,[e,s,t]),ne=e=>F("CheckpointIds",O(e),[[],void 0,[]]),de=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var ce=Object.defineProperty,Ie=Object.defineProperties,we=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,Ce=(e,s,t)=>s in e?ce(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ke=(e,s)=>{for(var t in s||(s={}))be.call(s,t)&&Ce(e,t,s[t]);if(pe)for(var t of pe(s))Re.call(s,t)&&Ce(e,t,s[t]);return e},ve=(e,s)=>Ie(e,we(s)),ge=(e,s)=>{var t={};for(var o in e)be.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&pe)for(var o of pe(e))s.indexOf(o)<0&&Re.call(e,o)&&(t[o]=e[o]);return t};const{createElement:me,useMemo:ye}=s,he=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,tableId:e,rowId:l,store:s,debugIds:r})))),l,r,e),fe=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,queryId:e,rowId:l,queries:s,debugIds:r})))),l,r,e),Ve=e=>{const s=x(e);return[s,null==s?void 0:s.getStore()]},Le=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u,n)=>{const[d,i]=Ve(s),a=null==d?void 0:d.getLocalTableId(e),c=u(e,n,d);return Pe(C(c,(e=>me(t,ve(ke({},Te(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),l,r,n)},Se=e=>({checkpoints:s,checkpointComponent:t=Ae,getCheckpointComponentProps:o,separator:l,debugIds:r})=>{const u=O(s);return Pe(C(e(ne(u)),(e=>me(t,ve(ke({},Te(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),l)},Te=(e,s)=>k(e)?{}:e(s),Pe=(e,s,t,o)=>{const l=k(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",l,"}"]:l},xe=({tableId:e,rowId:s,cellId:t,store:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=W(e,s,t,l))?u:o),void 0,r,t)},qe=({tableId:e,rowId:s,store:t,cellComponent:o=xe,getCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(N(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:u})))),r,u,s),Oe=e=>he(e,J(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>{var l;return Pe(o+(null!=(l=Y(e,s))?l:o),void 0,t,e)},Me=({indexId:e,sliceId:s,indexes:t,rowComponent:o=qe,getRowComponentProps:l,separator:r,debugIds:u})=>{const n=P(t),d=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),a=_(e,s,n);return Pe(C(a,(e=>me(o,ve(ke({},Te(l,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},je=({queryId:e,rowId:s,cellId:t,queries:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=ue(e,s,t,l))?u:o),void 0,r,t)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=je,getResultCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(re(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ae=({checkpoints:e,checkpointId:s,debugIds:t})=>{var l;return Pe(null!=(l=de(s,e))?l:o,void 0,t,s)},Ee=Se((e=>e[0])),Fe=Se((e=>k(e[1])?[]:[e[1]])),Ge=Se((e=>e[2]));e.BackwardCheckpointsView=Ee,e.CellView=xe,e.CheckpointView=Ae,e.CurrentCheckpointView=Fe,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:o,separator:l,debugIds:r})=>Pe(C($(e,s),(l=>me(t,ve(ke({},Te(o,l)),{key:l,indexId:e,sliceId:l,indexes:s,debugIds:r})))),l,r,e),e.LinkedRowsView=e=>Le(e,te,e.firstRowId),e.LocalRowsView=e=>Le(e,se,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var l;return Pe(null!=(l=Z(e,s))?l:o,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:o,metricsById:l,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(f);return me(f.Provider,{value:ye((()=>[null!=e?e:p[0],ke(ke({},p[1]),t),null!=o?o:p[2],ke(ke({},p[3]),l),null!=r?r:p[4],ke(ke({},p[5]),u),null!=n?n:p[6],ke(ke({},p[7]),d),null!=i?i:p[8],ke(ke({},p[9]),a),null!=c?c:p[10],ke(ke({},p[11]),I)]),[e,t,o,l,r,u,n,d,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=qe,getRowComponentProps:l,debugIds:r})=>{const[u,n]=Ve(t),d=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return Pe(k(d)||k(i)?null:me(o,ve(ke({},Te(l,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=je,e.ResultRowView=De,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return fe(u,le(u.queryId,t,o,l,r,u.queries))},e.ResultTableView=e=>fe(e,oe(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Me,e.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,o,l,r,u.store))},e.TableView=Oe,e.TablesView=({store:e,tableComponent:s=Oe,getTableComponentProps:t,separator:o,debugIds:l})=>Pe(C(H(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),o),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:o,debugIds:l})=>Pe(C(X(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),o),e.tableView=he,e.useAddRowCallback=(e,s,t=[],o,l=m,r=[])=>{const u=S(o);return B((t=>v(u,(o=>v(s(t,o),(s=>l(o.addRow(e,s),o,s)))))),[u,e,...t,...r])},e.useCell=W,e.useCellIds=N,e.useCellIdsListener=(e,s,t,o,l,r)=>G(w,S(r),t,o,[e,s],l),e.useCellListener=(e,s,t,o,l,r,u)=>G(I,S(u),o,l,[e,s,t],r),e.useCheckpoint=de,e.useCheckpointIds=ne,e.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),e.useCheckpointListener=(e,s,t,o)=>G("Checkpoint",O(o),s,t,[e]),e.useCheckpoints=e=>V(e,10),e.useCreateCheckpoints=(e,s,t)=>E(e,s,t),e.useCreateIndexes=(e,s,t)=>E(e,s,t),e.useCreateMetrics=(e,s,t)=>E(e,s,t),e.useCreatePersister=(e,s,t=[],o,l=[])=>{const[,r]=A(),u=j((()=>s(e)),[e,...t]);return M((()=>{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)=>E(e,s,t),e.useCreateRelationships=(e,s,t)=>E(e,s,t),e.useCreateStore=(e,s=[])=>j(e,s),e.useDelCellCallback=(e,s,t,o,l,r,u)=>U(l,I,r,u,e,s,t,o),e.useDelRowCallback=(e,s,t,o,l)=>U(t,i,o,l,e,s),e.useDelTableCallback=(e,s,t,o)=>U(s,u,t,o,e),e.useDelTablesCallback=(e,s,t)=>U(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>U(s,p,t,o,e),e.useDelValuesCallback=(e,s,t)=>U(e,b,s,t),e.useGoBackwardCallback=ie,e.useGoForwardCallback=ae,e.useGoToCallback=(e,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>v(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...l])},e.useIndexes=e=>V(e,4),e.useLinkedRowIds=te,e.useLinkedRowIdsListener=(e,s,t,o,l)=>G("LinkedRowIds",x(l),t,o,[e,s]),e.useLocalRowIds=se,e.useLocalRowIdsListener=(e,s,t,o,l)=>G("LocalRowIds",x(l),t,o,[e,s]),e.useMetric=Z,e.useMetricListener=(e,s,t,o)=>G("Metric",T(o),s,t,[e]),e.useMetrics=e=>V(e,2),e.useQueries=e=>V(e,8),e.useRedoInformation=e=>{var s;const t=O(e),[,,[l]]=ne(t);return[!k(l),ae(t),l,null!=(s=v(l,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o]},e.useRelationships=e=>V(e,6),e.useRemoteRowId=ee,e.useRemoteRowIdListener=(e,s,t,o,l)=>G("RemoteRowId",x(l),t,o,[e,s]),e.useResultCell=ue,e.useResultCellIds=re,e.useResultCellIdsListener=(e,s,t,o,l)=>G("ResultCellIds",q(l),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,l,r)=>G("ResultCell",q(r),o,l,[e,s,t]),e.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),e.useResultRowIds=oe,e.useResultRowIdsListener=(e,s,t,o)=>G("ResultRowIds",q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,l)=>G("ResultRow",q(l),t,o,[e,s]),e.useResultSortedRowIds=le,e.useResultSortedRowIdsListener=(e,s,t,o,l,r,u,n)=>G("ResultSortedRowIds",q(n),r,u,[e,s,t,o,l]),e.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),e.useResultTableListener=(e,s,t,o)=>G("ResultTable",q(o),s,t,[e]),e.useRow=(e,s,t)=>F(i,S(t),{},[e,s]),e.useRowIds=J,e.useRowIdsListener=(e,s,t,o,l)=>G(a,S(l),s,t,[e],o),e.useRowListener=(e,s,t,o,l,r)=>G(i,S(r),t,o,[e,s],l),e.useSetCellCallback=(e,s,t,o,l,r,u,n)=>Q(r,I,o,l,u,n,e,s,t),e.useSetCheckpointCallback=(e=m,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>{const l=e(s);o(t.addCheckpoint(l),t,l)}))),[r,...s,...l])},e.useSetPartialRowCallback=(e,s,t,o,l,r,u)=>Q(l,"PartialRow",t,o,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,o,l)=>Q(t,"PartialValues",e,s,o,l),e.useSetRowCallback=(e,s,t,o,l,r,u)=>Q(l,i,t,o,r,u,e,s),e.useSetTableCallback=(e,s,t,o,l,r)=>Q(o,u,s,t,l,r,e),e.useSetTablesCallback=(e,s,t,o,l)=>Q(t,n,e,s,o,l),e.useSetValueCallback=(e,s,t,o,l,r)=>Q(o,p,s,t,l,r,e),e.useSetValuesCallback=(e,s,t,o,l)=>Q(t,b,e,s,o,l),e.useSliceIds=$,e.useSliceIdsListener=(e,s,t,o)=>G("SliceIds",P(o),s,t,[e]),e.useSliceRowIds=_,e.useSliceRowIdsListener=(e,s,t,o,l)=>G("SliceRowIds",P(l),t,o,[e,s]),e.useSortedRowIds=K,e.useSortedRowIdsListener=(e,s,t,o,l,r,u,n,d)=>G(c,S(d),r,u,[e,s,t,o,l],n),e.useStore=e=>V(e,0),e.useTable=(e,s)=>F(u,S(s),{},[e]),e.useTableIds=H,e.useTableIdsListener=(e,s,t,o)=>G(d,S(o),e,s,[],t),e.useTableListener=(e,s,t,o,l)=>G(u,S(l),s,t,[e],o),e.useTables=e=>F(n,S(e),{}),e.useTablesListener=(e,s,t,o)=>G(n,S(o),e,s,[],t),e.useUndoInformation=e=>{var s;const t=O(e),[l,r]=ne(t);return[(u=l,!(0==(e=>e.length)(u))),ie(t),r,null!=(s=v(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o];var u},e.useValue=Y,e.useValueIds=X,e.useValueIdsListener=(e,s,t,o)=>G(R,S(o),e,s,[],t),e.useValueListener=(e,s,t,o,l)=>G(p,S(l),s,t,[e],o),e.useValues=e=>F(b,S(e),{}),e.useValuesListener=(e,s,t,o)=>G(b,S(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);
|
|
1
|
+
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",l=t(o),r="Ids",u="Table",n=u+"s",d=u+r,i="Row",a=i+r,c="Sorted"+i+r,I="Cell",w=I+r,p="Value",b=p+"s",R=p+r,C=(e,s)=>e.map(s),k=e=>null==e,v=(e,s,t)=>k(e)?null==t?void 0:t():s(e),g=e=>t(e)==l,m=()=>{},{createContext:y,useContext:h}=s,f=y([]),L=(e,s)=>{const t=h(f);return k(e)?t[s]:g(e)?((e,s)=>v(e,(e=>e[s])))(t[s+1],e):e},V=(e,s)=>{const t=L(e,s);return k(e)||g(e)?t:e},S=e=>V(e,0),T=e=>V(e,2),P=e=>V(e,4),x=e=>V(e,6),q=e=>V(e,8),O=e=>V(e,10),{useCallback:B,useEffect:M,useMemo:j,useRef:D,useState:A}=s,E=(e,s,t=[])=>{const o=j((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},F=(e,s,t,o=[],l)=>{const[,r]=A(),u=B((()=>{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]),[n]=A(u),d=D(n);return j((()=>d.current=u()),[u]),G(e,s,((...e)=>{d.current=k(l)?u():e[l],r([])}),[],o),d.current},G=(e,s,t,o=[],l=[],...r)=>M((()=>{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]),Q=(e,s,t,o=[],l=m,r=[],...u)=>{const n=S(e);return B((e=>v(n,(o=>v(t(e,o),(e=>l(o["set"+s](...u,e),e)))))),[n,s,...o,...r,...u])},U=(e,s,t=m,o=[],...l)=>{const r=S(e);return B((()=>t(null==r?void 0:r["del"+s](...l))),[r,s,...o,...l])},z=(e,s,t)=>{const o=O(e);return B((()=>null==o?void 0:o[s](t)),[o,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(a,S(s),[],[e]),K=(e,s,t,o=0,l,r)=>F(c,S(r),[],[e,s,t,o,l],6),N=(e,s,t)=>F(w,S(t),[],[e,s]),W=(e,s,t,o)=>F(I,S(o),void 0,[e,s,t],4),X=e=>F(R,S(e),[],[]),Y=(e,s)=>F(p,S(s),void 0,[e]),Z=(e,s)=>F("Metric",T(s),void 0,[e]),$=(e,s)=>F("SliceIds",P(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",P(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",x(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",x(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",x(t),[],[e,s]),oe=(e,s)=>F("ResultRowIds",q(s),[],[e]),le=(e,s,t,o=0,l,r)=>F("ResultSortedRowIds",q(r),[],[e,s,t,o,l],6),re=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,o)=>F("ResultCell",q(o),void 0,[e,s,t]),ne=e=>F("CheckpointIds",O(e),[[],void 0,[]]),de=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var ce=Object.defineProperty,Ie=Object.defineProperties,we=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,Ce=(e,s,t)=>s in e?ce(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ke=(e,s)=>{for(var t in s||(s={}))be.call(s,t)&&Ce(e,t,s[t]);if(pe)for(var t of pe(s))Re.call(s,t)&&Ce(e,t,s[t]);return e},ve=(e,s)=>Ie(e,we(s)),ge=(e,s)=>{var t={};for(var o in e)be.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&pe)for(var o of pe(e))s.indexOf(o)<0&&Re.call(e,o)&&(t[o]=e[o]);return t};const{createElement:me,useMemo:ye}=s,he=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,tableId:e,rowId:l,store:s,debugIds:r})))),l,r,e),fe=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,queryId:e,rowId:l,queries:s,debugIds:r})))),l,r,e),Le=e=>{const s=x(e);return[s,null==s?void 0:s.getStore()]},Ve=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u,n)=>{const[d,i]=Le(s),a=null==d?void 0:d.getLocalTableId(e),c=u(e,n,d);return Pe(C(c,(e=>me(t,ve(ke({},Te(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),l,r,n)},Se=e=>({checkpoints:s,checkpointComponent:t=Ae,getCheckpointComponentProps:o,separator:l,debugIds:r})=>{const u=O(s);return Pe(C(e(ne(u)),(e=>me(t,ve(ke({},Te(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),l)},Te=(e,s)=>k(e)?{}:e(s),Pe=(e,s,t,o)=>{const l=k(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",l,"}"]:l},xe=({tableId:e,rowId:s,cellId:t,store:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=W(e,s,t,l))?u:o),void 0,r,t)},qe=({tableId:e,rowId:s,store:t,cellComponent:o=xe,getCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(N(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:u})))),r,u,s),Oe=e=>he(e,J(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>{var l;return Pe(o+(null!=(l=Y(e,s))?l:o),void 0,t,e)},Me=({indexId:e,sliceId:s,indexes:t,rowComponent:o=qe,getRowComponentProps:l,separator:r,debugIds:u})=>{const n=P(t),d=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),a=_(e,s,n);return Pe(C(a,(e=>me(o,ve(ke({},Te(l,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},je=({queryId:e,rowId:s,cellId:t,queries:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=ue(e,s,t,l))?u:o),void 0,r,t)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=je,getResultCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(re(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ae=({checkpoints:e,checkpointId:s,debugIds:t})=>{var l;return Pe(null!=(l=de(s,e))?l:o,void 0,t,s)},Ee=Se((e=>e[0])),Fe=Se((e=>k(e[1])?[]:[e[1]])),Ge=Se((e=>e[2]));e.BackwardCheckpointsView=Ee,e.CellView=xe,e.CheckpointView=Ae,e.CurrentCheckpointView=Fe,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:o,separator:l,debugIds:r})=>Pe(C($(e,s),(l=>me(t,ve(ke({},Te(o,l)),{key:l,indexId:e,sliceId:l,indexes:s,debugIds:r})))),l,r,e),e.LinkedRowsView=e=>Ve(e,te,e.firstRowId),e.LocalRowsView=e=>Ve(e,se,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var l;return Pe(null!=(l=Z(e,s))?l:o,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:o,metricsById:l,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(f);return me(f.Provider,{value:ye((()=>[null!=e?e:p[0],ke(ke({},p[1]),t),null!=o?o:p[2],ke(ke({},p[3]),l),null!=r?r:p[4],ke(ke({},p[5]),u),null!=n?n:p[6],ke(ke({},p[7]),d),null!=i?i:p[8],ke(ke({},p[9]),a),null!=c?c:p[10],ke(ke({},p[11]),I)]),[e,t,o,l,r,u,n,d,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=qe,getRowComponentProps:l,debugIds:r})=>{const[u,n]=Le(t),d=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return Pe(k(d)||k(i)?null:me(o,ve(ke({},Te(l,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=je,e.ResultRowView=De,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return fe(u,le(u.queryId,t,o,l,r,u.queries))},e.ResultTableView=e=>fe(e,oe(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Me,e.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,o,l,r,u.store))},e.TableView=Oe,e.TablesView=({store:e,tableComponent:s=Oe,getTableComponentProps:t,separator:o,debugIds:l})=>Pe(C(H(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),o),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:o,debugIds:l})=>Pe(C(X(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),o),e.tableView=he,e.useAddRowCallback=(e,s,t=[],o,l=m,r=[],u=!0)=>{const n=S(o);return B((t=>v(n,(o=>v(s(t,o),(s=>l(o.addRow(e,s,u),o,s)))))),[n,e,...t,...r,u])},e.useCell=W,e.useCellIds=N,e.useCellIdsListener=(e,s,t,o,l,r)=>G(w,S(r),t,o,[e,s],l),e.useCellListener=(e,s,t,o,l,r,u)=>G(I,S(u),o,l,[e,s,t],r),e.useCheckpoint=de,e.useCheckpointIds=ne,e.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),e.useCheckpointListener=(e,s,t,o)=>G("Checkpoint",O(o),s,t,[e]),e.useCheckpoints=e=>L(e,10),e.useCreateCheckpoints=(e,s,t)=>E(e,s,t),e.useCreateIndexes=(e,s,t)=>E(e,s,t),e.useCreateMetrics=(e,s,t)=>E(e,s,t),e.useCreatePersister=(e,s,t=[],o,l=[])=>{const[,r]=A(),u=j((()=>s(e)),[e,...t]);return M((()=>{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)=>E(e,s,t),e.useCreateRelationships=(e,s,t)=>E(e,s,t),e.useCreateStore=(e,s=[])=>j(e,s),e.useDelCellCallback=(e,s,t,o,l,r,u)=>U(l,I,r,u,e,s,t,o),e.useDelRowCallback=(e,s,t,o,l)=>U(t,i,o,l,e,s),e.useDelTableCallback=(e,s,t,o)=>U(s,u,t,o,e),e.useDelTablesCallback=(e,s,t)=>U(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>U(s,p,t,o,e),e.useDelValuesCallback=(e,s,t)=>U(e,b,s,t),e.useGoBackwardCallback=ie,e.useGoForwardCallback=ae,e.useGoToCallback=(e,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>v(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...l])},e.useIndexes=e=>L(e,4),e.useLinkedRowIds=te,e.useLinkedRowIdsListener=(e,s,t,o,l)=>G("LinkedRowIds",x(l),t,o,[e,s]),e.useLocalRowIds=se,e.useLocalRowIdsListener=(e,s,t,o,l)=>G("LocalRowIds",x(l),t,o,[e,s]),e.useMetric=Z,e.useMetricListener=(e,s,t,o)=>G("Metric",T(o),s,t,[e]),e.useMetrics=e=>L(e,2),e.useQueries=e=>L(e,8),e.useRedoInformation=e=>{var s;const t=O(e),[,,[l]]=ne(t);return[!k(l),ae(t),l,null!=(s=v(l,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o]},e.useRelationships=e=>L(e,6),e.useRemoteRowId=ee,e.useRemoteRowIdListener=(e,s,t,o,l)=>G("RemoteRowId",x(l),t,o,[e,s]),e.useResultCell=ue,e.useResultCellIds=re,e.useResultCellIdsListener=(e,s,t,o,l)=>G("ResultCellIds",q(l),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,l,r)=>G("ResultCell",q(r),o,l,[e,s,t]),e.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),e.useResultRowIds=oe,e.useResultRowIdsListener=(e,s,t,o)=>G("ResultRowIds",q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,l)=>G("ResultRow",q(l),t,o,[e,s]),e.useResultSortedRowIds=le,e.useResultSortedRowIdsListener=(e,s,t,o,l,r,u,n)=>G("ResultSortedRowIds",q(n),r,u,[e,s,t,o,l]),e.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),e.useResultTableListener=(e,s,t,o)=>G("ResultTable",q(o),s,t,[e]),e.useRow=(e,s,t)=>F(i,S(t),{},[e,s]),e.useRowIds=J,e.useRowIdsListener=(e,s,t,o,l)=>G(a,S(l),s,t,[e],o),e.useRowListener=(e,s,t,o,l,r)=>G(i,S(r),t,o,[e,s],l),e.useSetCellCallback=(e,s,t,o,l,r,u,n)=>Q(r,I,o,l,u,n,e,s,t),e.useSetCheckpointCallback=(e=m,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>{const l=e(s);o(t.addCheckpoint(l),t,l)}))),[r,...s,...l])},e.useSetPartialRowCallback=(e,s,t,o,l,r,u)=>Q(l,"PartialRow",t,o,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,o,l)=>Q(t,"PartialValues",e,s,o,l),e.useSetRowCallback=(e,s,t,o,l,r,u)=>Q(l,i,t,o,r,u,e,s),e.useSetTableCallback=(e,s,t,o,l,r)=>Q(o,u,s,t,l,r,e),e.useSetTablesCallback=(e,s,t,o,l)=>Q(t,n,e,s,o,l),e.useSetValueCallback=(e,s,t,o,l,r)=>Q(o,p,s,t,l,r,e),e.useSetValuesCallback=(e,s,t,o,l)=>Q(t,b,e,s,o,l),e.useSliceIds=$,e.useSliceIdsListener=(e,s,t,o)=>G("SliceIds",P(o),s,t,[e]),e.useSliceRowIds=_,e.useSliceRowIdsListener=(e,s,t,o,l)=>G("SliceRowIds",P(l),t,o,[e,s]),e.useSortedRowIds=K,e.useSortedRowIdsListener=(e,s,t,o,l,r,u,n,d)=>G(c,S(d),r,u,[e,s,t,o,l],n),e.useStore=e=>L(e,0),e.useTable=(e,s)=>F(u,S(s),{},[e]),e.useTableIds=H,e.useTableIdsListener=(e,s,t,o)=>G(d,S(o),e,s,[],t),e.useTableListener=(e,s,t,o,l)=>G(u,S(l),s,t,[e],o),e.useTables=e=>F(n,S(e),{}),e.useTablesListener=(e,s,t,o)=>G(n,S(o),e,s,[],t),e.useUndoInformation=e=>{var s;const t=O(e),[l,r]=ne(t);return[(u=l,!(0==(e=>e.length)(u))),ie(t),r,null!=(s=v(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o];var u},e.useValue=Y,e.useValueIds=X,e.useValueIdsListener=(e,s,t,o)=>G(R,S(o),e,s,[],t),e.useValueListener=(e,s,t,o,l)=>G(p,S(l),s,t,[e],o),e.useValues=e=>F(b,S(e),{}),e.useValuesListener=(e,s,t,o)=>G(b,S(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": "3.2.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
"tinybase": "./bin/cli.js"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
|
-
".": "./lib/tinybase.js",
|
|
26
|
-
"./with-schemas": "./lib/tinybase.js",
|
|
27
25
|
"./package.json": "./package.json",
|
|
28
26
|
"./cjs": "./lib/cjs/tinybase.cjs",
|
|
29
27
|
"./cjs/with-schemas": "./lib/cjs/tinybase.cjs",
|
|
@@ -37,10 +35,6 @@
|
|
|
37
35
|
"./es6/with-schemas": "./lib/es6/tinybase.js",
|
|
38
36
|
"./es6/*/with-schemas": "./lib/es6/*.js",
|
|
39
37
|
"./es6/*": "./lib/es6/*.js",
|
|
40
|
-
"./debug": "./lib/debug/tinybase.js",
|
|
41
|
-
"./debug/with-schemas": "./lib/debug/tinybase.js",
|
|
42
|
-
"./debug/*/with-schemas": "./lib/debug/*.js",
|
|
43
|
-
"./debug/*": "./lib/debug/*.js",
|
|
44
38
|
"./umd": "./lib/umd/tinybase.js",
|
|
45
39
|
"./umd/with-schemas": "./lib/umd/tinybase.js",
|
|
46
40
|
"./umd/*/with-schemas": "./lib/umd/*.js",
|
|
@@ -53,8 +47,38 @@
|
|
|
53
47
|
"./lib/with-schemas": "./lib/tinybase.js",
|
|
54
48
|
"./lib/*/with-schemas": "./lib/*.js",
|
|
55
49
|
"./lib/*": "./lib/*.js",
|
|
56
|
-
"
|
|
57
|
-
|
|
50
|
+
"./debug": {
|
|
51
|
+
"types": "./lib/types/tinybase.d.ts",
|
|
52
|
+
"default": "./lib/debug/tinybase.js"
|
|
53
|
+
},
|
|
54
|
+
"./debug/with-schemas": {
|
|
55
|
+
"types": "./lib/types/with-schemas/tinybase.d.ts",
|
|
56
|
+
"default": "./lib/debug/tinybase.js"
|
|
57
|
+
},
|
|
58
|
+
"./debug/*/with-schemas": {
|
|
59
|
+
"types": "./lib/types/with-schemas/*.d.ts",
|
|
60
|
+
"default": "./lib/debug/*.js"
|
|
61
|
+
},
|
|
62
|
+
"./debug/*": {
|
|
63
|
+
"types": "./lib/types/*.d.ts",
|
|
64
|
+
"default": "./lib/debug/*.js"
|
|
65
|
+
},
|
|
66
|
+
".": {
|
|
67
|
+
"types": "./lib/types/tinybase.d.ts",
|
|
68
|
+
"default": "./lib/tinybase.js"
|
|
69
|
+
},
|
|
70
|
+
"./with-schemas": {
|
|
71
|
+
"types": "./lib/types/with-schemas/tinybase.d.ts",
|
|
72
|
+
"default": "./lib/tinybase.js"
|
|
73
|
+
},
|
|
74
|
+
"./*/with-schemas": {
|
|
75
|
+
"types": "./lib/types/with-schemas/*.d.ts",
|
|
76
|
+
"default": "./lib/*.js"
|
|
77
|
+
},
|
|
78
|
+
"./*": {
|
|
79
|
+
"types": "./lib/types/*.d.ts",
|
|
80
|
+
"default": "./lib/*.js"
|
|
81
|
+
}
|
|
58
82
|
},
|
|
59
83
|
"typesVersions": {
|
|
60
84
|
"*": {
|
|
@@ -187,26 +211,26 @@
|
|
|
187
211
|
},
|
|
188
212
|
"devDependencies": {
|
|
189
213
|
"@babel/cli": "^7.21.5",
|
|
190
|
-
"@babel/core": "^7.
|
|
191
|
-
"@babel/preset-env": "^7.
|
|
192
|
-
"@babel/preset-react": "^7.
|
|
214
|
+
"@babel/core": "^7.22.1",
|
|
215
|
+
"@babel/preset-env": "^7.22.4",
|
|
216
|
+
"@babel/preset-react": "^7.22.3",
|
|
193
217
|
"@babel/preset-typescript": "^7.21.5",
|
|
194
218
|
"@rollup/plugin-replace": "^5.0.2",
|
|
195
|
-
"@rollup/plugin-terser": "^0.4.
|
|
219
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
196
220
|
"@types/asciichart": "^1.5.6",
|
|
197
221
|
"@types/expect-puppeteer": "^5.0.3",
|
|
198
222
|
"@types/http-server": "^0.12.1",
|
|
199
|
-
"@types/jest": "^29.5.
|
|
223
|
+
"@types/jest": "^29.5.2",
|
|
200
224
|
"@types/jest-environment-puppeteer": "^5.0.3",
|
|
201
225
|
"@types/less": "^3.0.3",
|
|
202
|
-
"@types/node": "^
|
|
226
|
+
"@types/node": "^20.2.5",
|
|
203
227
|
"@types/puppeteer": "^5.4.7",
|
|
204
|
-
"@types/react": "^18.2.
|
|
205
|
-
"@types/react-dom": "^18.2.
|
|
228
|
+
"@types/react": "^18.2.8",
|
|
229
|
+
"@types/react-dom": "^18.2.4",
|
|
206
230
|
"@types/react-test-renderer": "^18.0.0",
|
|
207
231
|
"@types/tmp": "^0.2.3",
|
|
208
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
209
|
-
"@typescript-eslint/parser": "^5.59.
|
|
232
|
+
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
|
233
|
+
"@typescript-eslint/parser": "^5.59.8",
|
|
210
234
|
"asciichart": "^1.5.25",
|
|
211
235
|
"babel-eslint": "^10.1.0",
|
|
212
236
|
"babel-jest": "^29.5.0",
|
|
@@ -214,11 +238,11 @@
|
|
|
214
238
|
"buffer-replace": "^1.0.0",
|
|
215
239
|
"country-flag-emoji-json": "^2.0.0",
|
|
216
240
|
"cspell": "^6.31.1",
|
|
217
|
-
"esbuild": "^0.17.
|
|
218
|
-
"eslint": "^8.
|
|
241
|
+
"esbuild": "^0.17.19",
|
|
242
|
+
"eslint": "^8.42.0",
|
|
219
243
|
"eslint-config-prettier": "^8.8.0",
|
|
220
244
|
"eslint-plugin-jest": "^27.2.1",
|
|
221
|
-
"eslint-plugin-jsdoc": "^
|
|
245
|
+
"eslint-plugin-jsdoc": "^46.2.4",
|
|
222
246
|
"eslint-plugin-react": "^7.32.2",
|
|
223
247
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
224
248
|
"gulp": "^4.0.2",
|
|
@@ -227,14 +251,14 @@
|
|
|
227
251
|
"jest": "^29.5.0",
|
|
228
252
|
"jest-environment-jsdom": "^29.5.0",
|
|
229
253
|
"jest-fetch-mock": "^3.0.3",
|
|
230
|
-
"jest-puppeteer": "^
|
|
254
|
+
"jest-puppeteer": "^9.0.0",
|
|
231
255
|
"less": "^4.1.3",
|
|
232
256
|
"prettier": "^2.8.8",
|
|
233
|
-
"puppeteer": "^
|
|
257
|
+
"puppeteer": "^20.5.0",
|
|
234
258
|
"react": "^18.2.0",
|
|
235
259
|
"react-dom": "^18.2.0",
|
|
236
260
|
"react-test-renderer": "^18.2.0",
|
|
237
|
-
"rollup": "^3.
|
|
261
|
+
"rollup": "^3.23.1",
|
|
238
262
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
239
263
|
"rollup-plugin-gzip": "^3.1.0",
|
|
240
264
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
@@ -243,7 +267,7 @@
|
|
|
243
267
|
"tinydocs": "^0.1.26",
|
|
244
268
|
"tmp": "^0.2.1",
|
|
245
269
|
"ts-unused-exports": "^9.0.4",
|
|
246
|
-
"typescript": "5.
|
|
270
|
+
"typescript": "5.1.3"
|
|
247
271
|
},
|
|
248
272
|
"peerDependencies": {
|
|
249
273
|
"prettier": "^2.0.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>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://localfirstweb.dev/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a> (<em>new!</em>), <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-and-values">schematization</a> to model it.</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><a href="#type-definitions-orm-like-apis">Type definitions & ORM-like APIs</a> (<em>new!</em>), based on a 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.
|
|
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>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://localfirstweb.dev/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a> (<em>new!</em>), <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-and-values">schematization</a> to model it.</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><a href="#type-definitions-orm-like-apis">Type definitions & ORM-like APIs</a> (<em>new!</em>), based on a 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.3kB - 8.9kB</a> when compressed, and has zero dependencies. And of course it'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/#v3-2"><em>NEW!</em> v3.2 release</a></p><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><h3 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h3><p><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/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></p></section><section><h3 id="excited-to-be-used-by">Excited to be used by:</h3><p><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/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/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.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/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><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/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.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/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/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.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/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/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.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></p></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()
|
|
@@ -9,7 +9,7 @@ console.log(store.getValues());
|
|
|
9
9
|
// -> {employees: 3, open: true}
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
<section><h2 id="level-up-to-use-tabular-data">Level up to use tabular data.</h2><p>For other types of data applications, a tabular data structure is more useful. TinyBase lets you set and get nested <a href="https://
|
|
12
|
+
<section><h2 id="level-up-to-use-tabular-data">Level up to use tabular data.</h2><p>For other types of data applications, a tabular data structure is more useful. TinyBase lets you set and get nested <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> data, by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a> and in the same <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> as the keyed values.</p><p>Read more about setting and changing data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
13
13
|
|
|
14
14
|
```js
|
|
15
15
|
store
|
|
@@ -20,7 +20,7 @@ console.log(store.getRow('pets', 'fido'));
|
|
|
20
20
|
// -> {species: 'dog', color: 'brown'}
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
<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://
|
|
23
|
+
<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/type-aliases/store/value/"><code>Value</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'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>
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
26
|
const listenerId = store.addTableListener('pets', () =>
|
|
@@ -33,7 +33,7 @@ store.setCell('pets', 'fido', 'sold', false);
|
|
|
33
33
|
store.delListener(listenerId);
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
<section><h2 id="call-hooks-to-bind-to-data">Call hooks to bind to data.</h2><p>If you're using React in your application, the optional <a href="https://
|
|
36
|
+
<section><h2 id="call-hooks-to-bind-to-data">Call hooks to bind to data.</h2><p>If you'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'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>
|
|
37
37
|
|
|
38
38
|
```jsx
|
|
39
39
|
const App1 = () => {
|
|
@@ -52,7 +52,7 @@ console.log(app.innerHTML);
|
|
|
52
52
|
// -> 'Color: walnut'
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
<section><h2 id="use-components-for-reactive-apps">Use components for 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://
|
|
55
|
+
<section><h2 id="use-components-for-reactive-apps">Use components for 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'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'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>
|
|
56
56
|
|
|
57
57
|
```jsx
|
|
58
58
|
const MyCellView = (props) => (
|
|
@@ -82,7 +82,7 @@ console.log(app.innerHTML);
|
|
|
82
82
|
root.unmount();
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
<section><h2 id="apply-schemas-to-tables-and-values">Apply schemas to tables and values.</h2><p>By default, a <a href="https://
|
|
85
|
+
<section><h2 id="apply-schemas-to-tables-and-values">Apply schemas to tables and values.</h2><p>By default, a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> can contain any arbitrary <a href="https://tinybase.org/api/store/type-aliases/store/value/"><code>Value</code></a>, and 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 <a href="https://tinybase.org/api/store/type-aliases/schema/valuesschema/"><code>ValuesSchema</code></a> or a <a href="https://tinybase.org/api/store/type-aliases/schema/tablesschema/"><code>TablesSchema</code></a> 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: constraining their types, and providing defaults.</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'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>
|
|
86
86
|
|
|
87
87
|
```js
|
|
88
88
|
store.setTablesSchema({
|
|
@@ -100,7 +100,7 @@ console.log(store.getRow('pets', 'felix'));
|
|
|
100
100
|
store.delTablesSchema();
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
<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://
|
|
103
|
+
<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'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>
|
|
104
104
|
|
|
105
105
|
```js
|
|
106
106
|
const persister = createSessionPersister(store, 'demo');
|
|
@@ -113,7 +113,7 @@ persister.destroy();
|
|
|
113
113
|
sessionStorage.clear();
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
<section><h2 id="build-complex-queries-with-tinyql">Build complex queries with <a href="https://
|
|
116
|
+
<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's ownerId <a href="https://tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a>. We select the pet's species, and the owner's state, and then aggregate the prices for the combinations.</p><p>We access the results by descending price, essentially answering the question: "which is the highest-priced species, and in which state?"</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>
|
|
117
117
|
|
|
118
118
|
```js
|
|
119
119
|
store
|
|
@@ -154,7 +154,7 @@ queries
|
|
|
154
154
|
queries.destroy();
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
<section><h2 id="define-metrics-and-aggregations">Define metrics and aggregations.</h2><p>A <a href="https://
|
|
157
|
+
<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>
|
|
158
158
|
|
|
159
159
|
```js
|
|
160
160
|
store.setTable('species', {
|
|
@@ -183,7 +183,7 @@ store.setCell('species', 'horse', 'price', 20);
|
|
|
183
183
|
metrics.destroy();
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
<section><h2 id="create-indexes-for-fast-lookups">Create indexes for fast lookups.</h2><p>An <a href="https://
|
|
186
|
+
<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 'slices'), 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>
|
|
187
187
|
|
|
188
188
|
```js
|
|
189
189
|
const indexes = createIndexes(store);
|
|
@@ -207,7 +207,7 @@ store.setRow('pets', 'lowly', {species: 'worm'});
|
|
|
207
207
|
indexes.destroy();
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
-
<section><h2 id="model-relationships-between-tables">Model relationships between tables.</h2><p>A <a href="https://
|
|
210
|
+
<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>
|
|
211
211
|
|
|
212
212
|
```js
|
|
213
213
|
const relationships = createRelationships(store);
|
|
@@ -230,7 +230,7 @@ console.log(
|
|
|
230
230
|
relationships.destroy();
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
<section><h2 id="set-checkpoints-for-an-undo-stack">Set checkpoints for an undo stack.</h2><p>A <a href="https://
|
|
233
|
+
<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>
|
|
234
234
|
|
|
235
235
|
```js
|
|
236
236
|
const checkpoints = createCheckpoints(store);
|
|
@@ -247,7 +247,7 @@ console.log(store.getCell('pets', 'felix', 'sold'));
|
|
|
247
247
|
// -> false
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
-
<section><h2 id="type-definitions-orm-like-apis">Type definitions & ORM-like APIs</h2><p>TinyBase has comprehensive type definitions, and even offers definitions that infer API types from the data schemas you apply.</p><p>Furthermore, 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 the type support in the <a href="https://
|
|
250
|
+
<section><h2 id="type-definitions-orm-like-apis">Type definitions & ORM-like APIs</h2><p>TinyBase has comprehensive type definitions, and even offers definitions that infer API types from the data schemas you apply.</p><p>Furthermore, 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 the type support in the <a href="https://tinybase.org/guides/the-basics/tinybase-and-typescript/">TinyBase and TypeScript</a> guide.</p></section>
|
|
251
251
|
|
|
252
252
|
```js yolo
|
|
253
253
|
const tools = createTools(store);
|
|
@@ -266,4 +266,4 @@ export const createShop: typeof createShopDecl = () => {
|
|
|
266
266
|
};
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://
|
|
269
|
+
<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'll only add a gzipped <em>4.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.9kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>9.9kB</em>, and everything is super fast. Life'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>4.3kB</td><td>10.2kB</td><td>44.1kB</td><td>188.4kB</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>14.9kB</td><td>29.3kB</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.7kB</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.7kB</td><td>16.8kB</td><td>42.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>113.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.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.7kB</td><td>5.2kB</td><td>27.3kB</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>8.9kB</td><td>21.6kB</td><td>93.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,793</td><td>1,793</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,931</td><td>1,931</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>767</td><td>767</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>646</td><td>646</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">2,612</td></tr><tr><th class="right">Assertions</th><td colspan="3">13,179</td></tr></tbody></table></div><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><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a>, <a href="https://discord.com/invite/mGz3mevwP8">Discord</a>, and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/discussions">Discussions</a> and <a href="https://github.com/tinyplex/tinybase/issues">issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</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/3.2.0">NPM</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://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!</p></section>
|