tinybase 4.0.0-beta.1 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/persister-browser.cjs +1 -1
- package/lib/cjs/persister-browser.cjs.gz +0 -0
- package/lib/cjs/persister-file.cjs +1 -1
- package/lib/cjs/persister-file.cjs.gz +0 -0
- package/lib/cjs/persister-remote.cjs +1 -1
- package/lib/cjs/persister-remote.cjs.gz +0 -0
- package/lib/cjs/persister-yjs.cjs +1 -1
- package/lib/cjs/persister-yjs.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/persister-browser.cjs +1 -1
- package/lib/cjs-es6/persister-browser.cjs.gz +0 -0
- package/lib/cjs-es6/persister-file.cjs +1 -1
- package/lib/cjs-es6/persister-file.cjs.gz +0 -0
- package/lib/cjs-es6/persister-remote.cjs +1 -1
- package/lib/cjs-es6/persister-remote.cjs.gz +0 -0
- package/lib/cjs-es6/persister-yjs.cjs +1 -1
- package/lib/cjs-es6/persister-yjs.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 +3 -3
- package/lib/debug/indexes.js +3 -3
- package/lib/debug/metrics.js +3 -3
- package/lib/debug/persister-browser.js +38 -39
- package/lib/debug/persister-file.js +37 -37
- package/lib/debug/persister-remote.js +37 -34
- package/lib/debug/persister-yjs.js +225 -40
- package/lib/debug/persisters.js +36 -33
- package/lib/debug/queries.js +5 -5
- package/lib/debug/relationships.js +3 -3
- package/lib/debug/store.js +129 -94
- package/lib/debug/tinybase.js +165 -125
- package/lib/debug/tools.js +9 -9
- 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/persister-browser.js +1 -1
- package/lib/es6/persister-browser.js.gz +0 -0
- package/lib/es6/persister-file.js +1 -1
- package/lib/es6/persister-file.js.gz +0 -0
- package/lib/es6/persister-remote.js +1 -1
- package/lib/es6/persister-remote.js.gz +0 -0
- package/lib/es6/persister-yjs.js +1 -1
- package/lib/es6/persister-yjs.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/persister-browser.js +1 -1
- package/lib/persister-browser.js.gz +0 -0
- package/lib/persister-file.js +1 -1
- package/lib/persister-file.js.gz +0 -0
- package/lib/persister-remote.js +1 -1
- package/lib/persister-remote.js.gz +0 -0
- package/lib/persister-yjs.js +1 -1
- package/lib/persister-yjs.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/persister-yjs.d.ts +70 -8
- package/lib/types/persisters.d.ts +42 -17
- package/lib/types/queries.d.ts +52 -52
- package/lib/types/store.d.ts +399 -145
- package/lib/types/tools.d.ts +16 -16
- package/lib/types/ui-react.d.ts +56 -47
- package/lib/types/with-schemas/internal/ui-react.d.ts +2 -2
- package/lib/types/with-schemas/persister-yjs.d.ts +72 -9
- package/lib/types/with-schemas/persisters.d.ts +59 -18
- package/lib/types/with-schemas/queries.d.ts +52 -52
- package/lib/types/with-schemas/store.d.ts +480 -163
- package/lib/types/with-schemas/tools.d.ts +16 -16
- package/lib/types/with-schemas/ui-react.d.ts +54 -45
- 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/persister-browser.js +1 -1
- package/lib/umd/persister-browser.js.gz +0 -0
- package/lib/umd/persister-file.js +1 -1
- package/lib/umd/persister-file.js.gz +0 -0
- package/lib/umd/persister-remote.js +1 -1
- package/lib/umd/persister-remote.js.gz +0 -0
- package/lib/umd/persister-yjs.js +1 -1
- package/lib/umd/persister-yjs.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/persister-browser.js +1 -1
- package/lib/umd-es6/persister-browser.js.gz +0 -0
- package/lib/umd-es6/persister-file.js +1 -1
- package/lib/umd-es6/persister-file.js.gz +0 -0
- package/lib/umd-es6/persister-remote.js +1 -1
- package/lib/umd-es6/persister-remote.js.gz +0 -0
- package/lib/umd-es6/persister-yjs.js +1 -1
- package/lib/umd-es6/persister-yjs.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 +13 -13
- package/readme.md +2 -2
package/lib/umd-es6/tools.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="",a=t(l),n=t(!0),o=t(0),d="type",r="default",s="Listener",I="get",c="add",i="Ids",$="Table",u=$+"s",p=$+i,b="Row",C=b+i,h="Sorted"+b+i,g="Cell",m=g+i,f="Value",w=f+"s",y=f+i,v=(e,t)=>e.every(t),T=(e,t)=>e.sort(t),V=(e,t)=>e.forEach(t),x=(e,t)=>e.map(t),R=e=>e.length,P=e=>0==R(e),k=(e,t)=>e.filter(t),S=(e,...t)=>e.push(...t),A=e=>e.pop(),O=(e,...t)=>e.unshift(...t),E=e=>e.shift(),D=JSON.parse,j=isFinite,N=(e,t)=>e instanceof t,L=e=>null==e,M=e=>e==a||e==n,G=e=>t(e)==a,J=e=>Array.isArray(e),z=e=>{const l=t(e);return M(l)||l==o&&j(e)?l:void 0},W=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},B=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},F=(e,t)=>null==e?void 0:e.forEach(t),U=(e,t)=>null==e?void 0:e.delete(t),_=e=>new Map(e),Z=(e,t)=>null==e?void 0:e.get(t),H=(e,t)=>F(e,((e,l)=>t(l,e))),Q=(e,t)=>{var l;return x([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},q=(e,t,l)=>L(l)?(U(e,t),e):null==e?void 0:e.set(t,l),K=(e,t,l)=>(W(e,t)||q(e,t,l()),Z(e,t)),X=e=>e.toUpperCase(),Y=e=>e.toLowerCase(),ee="a ",te="A function for",le=", and registers a listener so that any changes to that result will cause a re-render",ae="Callback",ne="Del",oe="Deps",de=oe+"?: React.DependencyList",re="doRollback?: DoRollback",se="actions: () => Return, "+re,Ie="export",ce="Id",ie="Invalid",$e="Json",ue=Y(s),pe="?: ",be=" | undefined",Ce="NonNullable",he="Partial",ge="Props",me="Provider",fe=`Registers a ${ue} that will be called`,we="Represents",ye="rowId: "+ce,ve="Schema",Te="Set",Ve=", descending?: boolean, offset?: number, limit?: number",xe="[]",Re="the Store",Pe="Transaction",ke=Y(Pe),Se="Execute a "+ke+" to make multiple mutations",Ae="Explicitly starts a "+ke,Oe="Explicitly finishes a "+ke,Ee="the end of the "+ke,De="void",je=" => "+De,Ne="WhenSet",Le=" when setting it",Me=ee+"string serialization of",Ge=" ",Je="Gets a callback that can ",ze="the ",We=" the schema for",Be=(e=0,t=0)=>`the ${rt[e]}content of`+(t?Ge+Re:l),Fe=(e=0,t,a=0)=>nt[t]+Ge+Be(e,1)+(a?" when setting it":l),Ue=(e,t=0)=>we+` a Row when ${t?"s":"g"}etting ${Be()} the '${e}' `+$,_e=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,Ze=(e,t)=>`Calls a function for each ${e} in `+t,He=e=>"The props passed to a component that renders "+e,Qe=e=>"A function that takes "+e,qe=(e,t=0)=>te+" listening to changes to "+dt[e]+" in "+dt[t],Ke=(e,t,a=0)=>fe+" whenever "+dt[e]+" in "+dt[t]+" change"+(a?l:"s"),Xe=e=>`the '${e}' `+$,Ye=e=>"the specified Row in "+Xe(e),et=(e,t=0)=>nt[t]+` ${Be()} `+Xe(e),tt=(e,t=0)=>nt[t]+` ${Be()} `+Ye(e),lt=(e,t,l=0)=>nt[l]+` the '${t}' Cell for `+Ye(e),at=(e,t=0)=>nt[t]+` the '${e}' Value`,nt=["Gets","Checks existence of","Sets","Deletes","Sets part of",we,"Gets "+Me,"Sets "+Me,fe+" whenever",Je+"set",Je+"add",Je+"set part of",Je+"delete","Renders","Gets "+Me+We,"Sets"+We,"Deletes"+We],ot=[I,"has","set","del","set","forEach",c,l],dt=[Re,u,ze+$+Ge+i,ee+$,ze+b+Ge+i,ee+b,ze+g+Ge+i,ee+g,"invalid Cell changes",w,ze+f+Ge+i,ee+f,"invalid Value changes",ze+"sorted "+b+Ge+i],rt=[l,"tabular ","keyed value "],st=e=>new Set(J(e)||L(e)?e:[e]),It=(e,t)=>null==e?void 0:e.add(t),ct=/[^A-Za-z]+/,it=/[^A-Za-z0-9]+/,$t=/^( *)\/\*\* *(.*?) *\*\/$/gm,ut=(e,t,l)=>e.substring(t,l),pt=e=>e.includes(","),bt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return W(e,n)?bt(e,t,l,a+1):(q(e,n,l),n)},Ct=e=>e.replace($t,((e,t,l)=>{const a=77-ht(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),ht=e=>e.length,gt=(e,t=l)=>e.join(t),mt=e=>e.flat(1e3),ft=(e,t=0)=>gt(x(e.split(it),((e,l)=>(l>0||t?X:Y)(ut(e,0,1))+ut(e,1)))),wt=e=>X(gt((e&&!ct.test(e[0])?e:" "+e).split(it),"_")),yt=e=>`/** ${e}. */`,vt=(...e)=>gt(k(e,(e=>e)),", "),Tt=(...e)=>"{"+gt(e,"; ")+"}",Vt=(...e)=>Tt(...x(e,(e=>"readonly "+e))),xt=()=>{const e=[_(),_(),_(),_()],t=_(),a=_();return[(...e)=>gt(mt(e),"\n"),(t,l,...a)=>V(a,(a=>V([0,1],(n=>(null!=t?t:n)==n?It(K(e[n],l,st),a):0)))),(e,a,n,o=l,d=1)=>bt(t,e,[a,n,o,d]),(e,t,l)=>bt(a,e,J(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>Z(a,e)===t?e:bt(a,e,t),(t=0)=>x([...T(Q(e[t],((e,t)=>`import {${gt(T(B(e)),", ")}} from '${t}';`)),((e,t)=>pt(e)!=pt(t)?pt(e)?-1:1:e>t?1:-1)),l],(e=>e.replace("{React}","React"))),()=>Q(t,(([e,t,a,n],o)=>[yt(t),`${n?Ie+" ":l}type ${o}${a} = ${e};`,l])),()=>Q(a,((e,t)=>(e=J(e)?e:[e],S(e,A(e)+";"),[`const ${t} = ${E(e)}`,e,l])))]},Rt=Object,Pt=Rt.keys,kt=Rt.freeze,St=e=>N(e,Rt)&&e.constructor==Rt,At=(e,t)=>x(Rt.entries(e),(([e,l])=>t(l,e))),Ot=e=>St(e)&&P(Pt(e)),Et=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Dt=(e,t,l)=>[t=>At(e,((e,a)=>t(a,ft(a,1),l(wt(a),`'${a}'`)))),(t,a)=>At(e[t],((e,t)=>a(t,e[d],e[r],l(wt(t),`'${t}'`),ft(t,1)))),e=>At(t,((t,a)=>e(a,t[d],t[r],l(wt(a),`'${a}'`),ft(a,1))))],jt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(u,Tt(...t((e=>`'${e}'?: {[rowId: Id]: `+Tt(...a(e,((e,t,a)=>`'${e}'${L(a)?"?":l}: ${t}`)))+"}"))),Fe(1,5)),I=e(u+Ne,Tt(...t((e=>`'${e}'?: {[rowId: Id]: `+Tt(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Fe(1,5,1)),c=e($+ce,"keyof "+r,"A "+$+" Id in "+Re),i=`<TId extends ${c}>`,f=e($,Ce+`<${r}[TId]>`,"A "+$+" in "+Re,i),w=e($+Ne,Ce+`<${I}[TId]>`,"A "+$+" in "+Re+Le,i),y=e(b,f+"<TId>[Id]","A "+b+" in a "+$,i),v=e(b+Ne,w+"<TId>[Id]","A "+b+" in a "+$+Le,i),T=e(g+ce,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+b,i),V=e(g,Ce+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+b,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+b,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(g+ae,`(...[cellId, cell]: ${x}<TId>)`+je,Qe(ee+g+" Id, and "+g),i),P=e(b+ae,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+je+") "+je,Qe(ee+b+" Id, and a "+g+" iterator"),i),k=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${P}<TId>)${je}] : never`,$+" Ids and callback types",`<TId = ${c}>`,0),S=e($+ae,`(...[tableId, forEachRow]: ${k})`+je,Qe(ee+$+" Id, and a "+b+" iterator"),l),A=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),O=e("GetCellChange",`(...[tableId, rowId, cellId]: ${A}) => CellChange`,te+" returning information about any Cell's changes during a "+ke),E=e(u+s,`(${d}, getCellChange: ${O}${be})`+je,qe(1)),D=e(p+s,`(${d})`+je,qe(2)),j=e($+s,`(${d}, tableId: ${c}, getCellChange: ${O}${be})`+je,qe(3)),N=e(C+s,`(${d}, tableId: ${c})`+je,qe(4,3)),M=e(h+s,"("+vt(d,"tableId: "+c,"cellId: Id"+be,"descending: boolean","offset: number","limit: number"+be,"sortedRowIds: Ids")+")"+je,qe(13,3)),G=e(b+s,"("+vt(""+d,"tableId: "+c,ye,`getCellChange: ${O}${be}`)+")"+je,qe(5,3)),J=e(m+s,"("+vt(""+d,"tableId: "+c,ye)+")"+je,qe(6,5)),z=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${ye}, cellId: CId, newCell: ${V}<TId, CId> ${be}, oldCell: ${V}<TId, CId> ${be}, getCellChange: ${O} ${be}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${T}<TId>>`,0),W=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+z+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[r,I,c,f,w,y,v,T,V,R,P,S,E,D,j,N,M,G,J,e(g+s,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${W})`+je,qe(7,5)),e(ie+g+s,`(${d}, tableId: Id, ${ye}, cellId: Id, invalidCells: any[])`+je,qe(8))]},(t,a)=>{const o=t+": "+a,d=e(w,Tt(...n(((e,t,a)=>`'${e}'${L(a)?"?":l}: ${t}`))),Fe(2,5)),r=e(w+Ne,Tt(...n(((e,t)=>`'${e}'?: ${t}`))),Fe(2,5,1)),I=e(f+ce,"keyof "+d,"A "+f+" Id in "+Re),c=e(f,Ce+`<${d}[VId]>`,"A "+f+" Id in "+Re,`<VId extends ${I}>`),i=e("ValueIdValueArray",`VId extends ${I} ? [valueId: VId, value: ${c}<VId>] : never`,f+" Ids and types in "+Re,`<VId = ${I}>`,0),$=e(f+ae,`(...[valueId, value]: ${i})`+je,Qe(ee+f+" Id, and "+f)),u=e("GetValueChange",`(valueId: ${I}) => ValueChange`,te+" returning information about any Value's changes during a "+ke),p=e(w+s,`(${o}, getValueChange: ${u}${be})`+je,qe(9)),b=e(y+s,`(${o})`+je,qe(10)),C=e("ValueListenerArgsArray",`VId extends ${I} ? [${o}, valueId: VId, newValue: ${c}<VId> ${be}, oldValue: ${c}<VId> ${be}, getValueChange: ${u} ${be}] : never`,"Value args for ValueListener",`<VId = ${I}>`,0);return[d,r,I,c,$,p,b,e(f+s,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+je,qe(11)),e(ie+f+s,`(${o}, valueId: Id, invalidValues: any[])`+je,qe(12))]},(t,l)=>e(Pe+s,`(${t}: ${l}, cellsTouched: boolean, valuesTouched: boolean)`+je,te+" listening to the completion of a "+ke)],Nt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Lt=(e,t=l)=>`fluent(() => ${Nt(e,t)})`,Mt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,Gt=(e,t,a)=>{const[o,I,v,T,x,R,P,k]=xt(),[A,E,D]=Dt(e,t,x),[j,N,M]=jt(v,A,E,D),J=_(),z=(e=0)=>Q(J,(([t,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${a} => ${n},`]:[r+d+`(${t}): ${a};`];return e||O(s,yt(o)),S(s,l),s})),W=(e,t,a,n,o,d=l)=>bt(J,e,[t,a,n,o,d]),F=(e,t,a,n,o,d=l,r=l,s=l)=>W(ot[e]+t+(4==e?he:l)+a,d,n,(n==X?Lt:Nt)(ot[e]+(4==e?he:l)+a,r,e?void 0:n),o,s),U=(e,t,a,n=l,o=l,d=1,r=l)=>W(c+e+s,(n?n+", ":l)+ue+": "+t+(d?", mutator?: boolean":l),ce,Mt(c+e+s,o,d?"mutator":l),a,r),K=`./${ft(a)}.d`,X=ft(a,1),Y=ft(X),ee=[],te=_();let le=[],ne=[];if(I(1,K,X,`create${X} as create${X}Decl`),!Ot(e)){I(0,"tinybase","CellChange"),I(null,"tinybase",i);const[e,t,a,o,s,c,f,w,y,T,R,P,k,O,D,N,M,J,z,W,H]=j(Y,X),Q=_();A(((e,t)=>{const l=`<'${e}'>`,a=[v(t+$,o+l,we+` the '${e}' `+$),v(t+$+Ne,s+l,we+` the '${e}' `+$+Le),v(t+b,c+l,Ue(e)),v(t+b+Ne,f+l,Ue(e,1)),v(t+g+ce,w+l,`A Cell Id for the '${e}' `+$),v(t+g+ae,T+l,Qe(`a Cell Id and value from a Row in the '${e}' `+$)),v(t+b+ae,R+l,Qe(`a Row Id from the '${e}' Table, and a Cell iterator`))];q(Q,e,a),I(1,K,...a)})),I(1,K,e,t,a,w,P,k,O,D,N,M,J,z,W,H),le=[e,t,a,w,k,O,D,N,M,J,z,W,Q],V([[e],[n],[X,"tables: "+t,"tables"],[X]],(([e,t,a],n)=>F(n,l,u,e,Fe(1,n),t,a))),F(0,l,p,a+xe,_e($,Re)),F(5,l,$,De,Ze($,Re),"tableCallback: "+P,"tableCallback as any"),A(((e,t,a)=>{const[o,d,r,s,I,c,u]=Z(Q,e);V([[o],[n],[X,"table: "+d,", table"],[X]],(([n,o,d=l],r)=>F(r,t,$,n,et(e,r),o,a+d))),F(0,t,C,i,_e(b,Xe(e)),l,a),F(0,t,h,i,_e(b,Xe(e),1),"cellId?: "+I+Ve,a+", cellId, descending, offset, limit"),F(5,t,b,De,Ze(b,Xe(e)),"rowCallback: "+u,a+", rowCallback as any"),V([[r],[n],[X,", row: "+s,", row"],[X],[X,", partialRow: "+s,", partialRow"]],(([n,o=l,d=l],r)=>F(r,t,b,n,tt(e,r),ye+o,a+", rowId"+d))),F(6,t,b,ce+be,"Add a new Row to "+Xe(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),F(0,t,m,I+xe,_e(g,Ye(e)),ye,a+", rowId"),F(5,t,g,De,Ze(g,Ye(e)),ye+", cellCallback: "+c,a+", rowId, cellCallback as any"),E(e,((o,d,r,s,I)=>{const c="Map"+ft(d,1);q(te,d,c);const i=d+(L(r)?be:l);V([[i],[n],[X,`, cell: ${d} | `+c,", cell as any"],[X]],(([n,d=l,r=l],c)=>F(c,t+I,g,n,lt(e,o,c),ye+d,a+", rowId, "+s+r)))}))})),F(0,l,u+$e,$e,Fe(1,6)),F(2,l,u+$e,X,Fe(1,7),"tablesJson: "+$e,"tables"+$e),U(u,k,Fe(1,8)+" changes"),U(p,O,Ke(2,0,1)),U($,D,Ke(3,0),`tableId: ${a} | null`,"tableId"),U(C,N,Ke(4,3,1),`tableId: ${a} | null`,"tableId"),U(h,M,Ke(13,3,1),vt("tableId: TId",`cellId: ${w}<TId>`+be,"descending: boolean","offset: number","limit: number"+be),vt("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),U(b,J,Ke(5,3),`tableId: ${a} | null, rowId: IdOrNull`,"tableId, rowId"),U(m,z,Ke(6,5,1),`tableId: ${a} | null, rowId: IdOrNull`,"tableId, rowId"),U(g,W,Ke(7,5),`tableId: ${a} | null, rowId: IdOrNull, cellId: ${gt(A((e=>{var t,a;return null!=(a=null==(t=Z(Q,e))?void 0:t[4])?a:l}))," | ")} | null`,"tableId, rowId, cellId"),U(ie+g,H,fe+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),I(1,K,...B(te)),S(ee,".set"+u+ve+"({",mt(A(((e,t,a)=>[`[${a}]: {`,...E(e,((e,t,a,n)=>`[${n}]: {[${x(wt(d),`'${d}'`)}]: ${x(wt(t),`'${t}'`)}${L(a)?l:`, [${x(wt(r),`'${r}'`)}]: `+(G(a)?x(wt(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!Ot(t)){const[e,t,a,o,s,c,i,$,u]=N(Y,X);I(1,K,e,t,a,s,c,i,$,u),ne=[e,t,a,c,i,$],V([[e],[n],[X,"values: "+t,"values"],[X],[X,"partialValues: "+t,"partialValues"]],(([e,t,a],n)=>F(n,l,w,e,Fe(2,n),t,a))),F(0,l,y,a+xe,_e(f,Re)),F(5,l,f,"void",Ze(f,Re),"valueCallback: "+s,"valueCallback as any"),D(((e,t,a,o,d)=>{const r="Map"+ft(t,1);q(te,t,r),V([[t],[n],[X,`value: ${t} | `+r,", value as any"],[X]],(([t,a,n=l],r)=>F(r,d,f,t,at(e,r),a,o+n)))})),F(0,l,w+$e,$e,Fe(2,6)),F(2,l,w+$e,X,Fe(2,7),"valuesJson: "+$e,"values"+$e),U(w,c,Fe(2,8)+" changes"),U(y,i,Ke(10,0,1)),U(f,$,Ke(11,0),`valueId: ${a} | null`,"valueId"),U(ie+f,u,fe+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),I(1,K,...B(te)),I(0,"tinybase","ValueChange"),S(ee,".set"+w+ve+"({",D(((e,t,a,n)=>[`[${n}]: {[${x(wt(d),`'${d}'`)}]: ${x(wt(t),`'${t}'`)}${L(a)?l:`, [${x(wt(r),`'${r}'`)}]: `+(G(a)?x(wt(a),`'${a}'`):a)}},`])),"})")}H(te,((e,t)=>v(t,`(cell: ${e}${be}) => `+e,`Takes a ${e} Cell value and returns another`))),I(null,"tinybase","DoRollback",ce,"IdOrNull",$e,"Store"),F(0,l,$e,$e,Fe(0,6)),F(2,l,$e,X,Fe(0,7),"tablesAndValuesJson: "+$e,"tablesAndValuesJson"),F(7,l,ke,"Return",Se,se,"actions, doRollback","<Return>"),F(7,l,"start"+Pe,X,Ae),F(7,l,"finish"+Pe,X,Oe,re,"doRollback");const oe=M(Y,X);return U("WillFinish"+Pe,oe,fe+" just before "+Ee,l,l,0),U("DidFinish"+Pe,oe,fe+" just after "+Ee,l,l,0),F(7,l,"call"+s,X,"Manually provoke a listener to be called","listenerId: Id","listenerId"),F(3,l,s,X,"Remove a listener that was previously added to "+Re,"listenerId: Id","listenerId"),W("getStore",l,"Store","store",nt[0]+" the underlying Store object"),I(1,"tinybase","createStore"),I(1,K,X,`create${X} as create${X}Decl`,oe),x("store",["createStore()",...ee]),T("fluent","actions: () => Store",["actions();",`return ${Y};`]),T("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Y}, ...params)`),x(Y,["{",...z(1),"}"]),[o(...R(0),...P(),Ie+" interface "+X+" {",...z(0),"}",l,yt(`Creates a ${X} object`),Ie+" function create"+X+"(): "+X+";"),o(...R(1),Ie+" const create"+X+": typeof create"+X+"Decl = () => {",...k(),`return Object.freeze(${Y});`,"};"),le,ne]},Jt=e=>I+e,zt=e=>vt(Jt(e),Jt(e)+oe),Wt="debugIds?: boolean",Bt="debugIds={debugIds}",Ft="then"+de,Ut="Parameter",_t=": (parameter: "+Ut+", store: Store) => ",Zt="const contextValue = useContext(Context);",Ht=", based on a parameter",Qt=": ",qt="<"+Ut+",>",Kt=Ut+"ized"+ae+"<"+Ut+">",Xt="rowId",Yt="rowId={rowId}",el=", separator, debugIds",tl="separator?: ReactElement | string",ll="then?: (store: Store",al=vt(ll+")"+je,Ft),nl="then, then"+oe,ol=Xt+Qt+ce,dl="View",rl=(e,...t)=>vt(...t,ue+": "+e,ue+de,"mutator?: boolean"),sl=(...e)=>vt(...e,ue,ue+oe,"mutator"),Il=(e,t,a,n,o)=>{const[d,r,I,c,v,T,V,x]=xt(),[R,P,k]=Dt(e,t,v),A=`./${ft(a)}.d`,E=`./${ft(a)}-ui-react.d`,D="tinybase/ui-react",j=ft(a,1),N=ft(j),M=j+"Or"+j+ce,G=N+"Or"+j+ce,J=N+`={${N}}`,z=_(),W=(e,t,a,n,o,d=l)=>(r(1,E,e+" as "+e+"Decl"),bt(z,e,[t,a,n,o,d])),B=(e,t,a,n,o,d=l)=>W("use"+e,t,a,n,o,d),F=(e,t,a,n,o=l,d=l,s=l,I=l,c=l)=>(r(1,D,`use${t} as use${t}Core`),B(e,vt(o,X,I),a,te+`(${G}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,s)),U=(e,t,l,a)=>W(e,t,1,l,a),H=(e=0)=>Q(z,(([t,a,n,o,d],r)=>{const s=e?[Ie+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[Ie+` function ${r}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||O(s,yt(o)),S(s,l),s}));r(null,"tinybase",ce,"Store",ae,Ut+"ized"+ae),r(0,D,"ComponentReturnType"),r(null,D,"ExtraProps"),r(0,A,j);const q=I(M,j+" | "+ce,`Used when you need to refer to a ${j} in a React hook or component`),K=I(me+ge,Vt(N+pe+j,N+`ById?: {[${N}Id: Id]: ${j}}`),`Used with the ${me} component, so that a `+j+" can be passed into the context of an application");r(0,"react","ReactElement","ComponentType"),r(1,"react","React"),r(1,E,q,K);const X=G+pe+q;v("{createContext, useContext, useMemo}","React"),v("Context",`createContext<[${j}?, {[${N}Id: Id]: ${j}}?]>([])`),B("Create"+j,`create: () => ${j}, create`+de,j,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${j} within a React application with convenient memoization`);const Y=B(j,"id?: Id",j+be,["{",Zt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${j} from within a ${me} component context`),te=c("useHook",G+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${N} = ${Y}(${G} as Id);`,`return hook(...preParams, ((${G} == null || typeof ${G} == 'string')`,`? ${N} : ${G})?.getStore(), ...postParams)`]),oe=c("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),re=c("wrap",vt("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),se=v("NullComponent","() => null");if(!Ot(e)){const[e,t,a,o,d,f,w,y,v,T,V,x,k]=n;r(null,A,e,t,a,d,f,w,y,v,T,V,x),r(0,A,o),r(1,A,j),r(null,"tinybase",i,"IdOrNull");const S=c("tableView",`{${N}, rowComponent, getRowComponentProps`+el+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${re}(rowIds.map((rowId) => (`,"<Row","{..."+oe+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",Yt,J,Bt,"/>","))",el,", tableId,",");"]),O=c("getDefaultTableComponent","tableId: Id",gt(R(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+se),D=c("getDefaultCellComponent","tableId: Id, cellId: Id",gt(R(((e,t,l)=>`tableId == ${l} ? ${gt(P(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+se} : `)))+se);F(u,u,e,Fe(1,0)+le);const M=F(p,p,a+xe,_e($,Re)+le);F(Te+u+ae,Te+u+ae,Kt,Fe(1,9)+Ht,vt(Jt(u)+_t+t,Jt(u)+de),zt(u),qt,vt(ll,`tables: ${t})`+je,Ft),nl),F(ne+u+ae,ne+u+ae,ae,Fe(1,12),l,l,l,al,nl);const G=I(g+ge,Vt("tableId?: TId","rowId: Id","cellId?: CId",N+pe+j,Wt),He(ee+g),`<TId extends ${a}, CId extends ${o}<TId>>`),z=I(b+ge,Vt("tableId?: TId","rowId: Id",N+pe+j,"cellComponents?: {readonly [CId in "+o+`<TId>]?: ComponentType<${G}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${o}<TId>) => ExtraProps`,tl,Wt),He(ee+b),`<TId extends ${a}>`),W=I($+ge,Vt("tableId?: TId",N+pe+j,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",tl,Wt),He(ee+$),`<TId extends ${a}>`),B=I("Sorted"+$+ge,Vt("tableId?: TId","cellId?: "+o+"<TId>","descending?: boolean","offset?: number","limit?: number",N+pe+j,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",tl,Wt),He(ee+"sorted "+$),`<TId extends ${a}>`),_=I(u+ge,Vt(N+pe+j,"tableComponents?: {readonly [TId in "+a+`]?: ComponentType<${W}<TId>>;}`,`getTableComponentProps?: (tableId: ${a}) => ExtraProps`,tl,Wt),He(Be(1,1)));r(1,E,_,W,B,z,G),U(u+dl,"{"+N+", tableComponents, getTableComponentProps"+el+"}: "+_,[re+`(${M}(${N}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+O+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${oe}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",J,Bt,"/>;","}), separator)"],Fe(1,13)+le),R(((e,t,a)=>{const[n,o,d,s,I]=Z(k,e);r(null,A,n,o,d,s,I),F(t+$,$,n,et(e)+le,l,a);const c=F(t+C,C,i,_e(b,Xe(e))+le,l,a),u=F(t+h,h,i,_e(b,Xe(e),1)+le,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");F(t+b,b,d,tt(e)+le,ol,vt(a,Xt));const p=F(t+m,m,I+xe,_e(g,Ye(e))+le,ol,vt(a,Xt));F(Te+t+$+ae,Te+$+ae,Kt,et(e,9)+Ht,vt(Jt($)+_t+o,Jt($)+de),vt(a,zt($)),qt,vt(ll,`table: ${o})`+je,Ft),nl),F(ne+t+$+ae,ne+$+ae,ae,et(e,12),l,a,l,al,nl),F(Te+t+b+ae,Te+b+ae,Kt,tt(e,9)+Ht,vt(ol,Jt(b)+_t+s,Jt(b)+de),vt(a,Xt,zt(b)),qt,vt(ll,`row: ${s})`+je,Ft),nl),F("Add"+t+b+ae,"Add"+b+ae,Kt,tt(e,10)+Ht,vt(Jt(b)+_t+s,Jt(b)+de),vt(a,zt(b)),qt,"then?: ("+vt(ol+be,"store: Store","row: "+s+")"+je,"then"+de)+", reuseRowIds?: boolean",nl+", reuseRowIds"),F(Te+t+he+b+ae,Te+he+b+ae,Kt,tt(e,11)+Ht,vt(ol,Jt(he+b)+_t+s,Jt(he+b)+de),vt(a,Xt,zt(he+b)),qt,vt(ll,`partialRow: ${s})`+je,Ft),nl),F(ne+t+b+ae,ne+b+ae,ae,tt(e,12),ol,vt(a,Xt),l,al,nl);const f=U(t+b+dl,"{rowId, "+N+", cellComponents, getCellComponentProps"+el+`}: ${z}<'${e}'>`,[re+`(${p}(rowId, ${N}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+D+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${oe}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,Yt,"cellId={cellId}",J,Bt,"/>;","})"+el+", rowId)"],tt(e,13)+le);U(t+"Sorted"+$+dl,"{cellId, descending, offset, limit, ...props}: "+B+`<'${e}'>`,S+"(props, "+u+`(cellId, descending, offset, limit, props.${N}), ${a}, ${f});`,et(e,13)+", sorted"+le),U(t+$+dl,`props: ${W}<'${e}'>`,S+"(props, "+c+`(props.${N}), ${a}, ${f});`,et(e,13)+le),P(e,((n,o,d,s,I)=>{const c="Map"+ft(o,1);r(0,A,c),r(1,A,c);const i=F(t+I+g,g,o+(L(d)?be:l),lt(e,n)+le,ol,vt(a,Xt,s));F(Te+t+I+g+ae,Te+g+ae,Kt,lt(e,n,9)+Ht,vt(ol,Jt(g)+_t+o+" | "+c,Jt(g)+de),vt(a,Xt,s,zt(g)),qt,vt(ll,`cell: ${o} | ${c})`+je,Ft),nl),F(ne+t+I+g+ae,ne+g+ae,ae,lt(e,n,12),vt(ol,"forceDel?: boolean"),vt(a,Xt,s,"forceDel"),l,al,nl),U(t+I+g+dl,`{rowId, ${N}, debugIds}: `+G+`<'${e}', '${n}'>`,[re+`('' + ${i}(rowId, `+N+`) ?? '', undefined, debugIds, ${s})`],lt(e,n,13)+le)}))}));const H=gt(R((e=>{var t,a;return null!=(a=null==(t=Z(k,e))?void 0:t[4])?a:l}))," | ");F(u+s,u+s,De,Fe(1,8)+" changes",rl(d),sl()),F(p+s,p+s,De,Ke(2,0,1),rl(f),sl()),F($+s,$+s,De,Ke(3,0),rl(w,`tableId: ${a} | null`),sl("tableId")),F(C+s,C+s,De,Ke(4,3,1),rl(y,`tableId: ${a} | null`),sl("tableId")),F(h+s,h+s,De,Ke(13,3,1),rl(v,`tableId: ${a} | null`,"cellId: "+H+be,"descending: boolean","offset: number","limit: number"+be),sl("tableId","cellId","descending","offset","limit")),F(b+s,b+s,De,Ke(5,3),rl(T,`tableId: ${a} | null`,Xt+": IdOrNull"),sl("tableId",Xt)),F(m+s,m+s,De,Ke(6,5,1),rl(V,`tableId: ${a} | null`,Xt+": IdOrNull"),sl("tableId",Xt)),F(g+s,g+s,De,Ke(7,5),rl(x,`tableId: ${a} | null`,Xt+": IdOrNull",`cellId: ${H} | null`),sl("tableId",Xt,"cellId"))}if(!Ot(t)){const[e,t,a,n,d,i]=o;r(null,A,...o),r(1,A,j);const $=c("getDefaultValueComponent","valueId: Id",gt(k(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+se);F(w,w,e,Fe(2,0)+le);const u=F(y,y,a+xe,_e(f,Re)+le);F(Te+w+ae,Te+w+ae,Kt,Fe(2,9)+Ht,vt(Jt(w)+_t+t,Jt(w)+de),zt(w),qt,vt(ll,`values: ${t})`+je,Ft),nl),F(Te+he+w+ae,Te+he+w+ae,Kt,Fe(2,11)+Ht,vt(Jt(he+w)+_t+t,Jt(he+w)+de),zt(he+w),qt,vt(ll,`partialValues: ${t})`+je,Ft),nl),F(ne+w+ae,ne+w+ae,ae,Fe(2,12),l,l,l,al,nl);const p=I(f+ge,Vt("valueId?: VId",N+pe+j,Wt),He("a Value"),`<VId extends ${a}>`),b=I(w+ge,Vt(N+pe+j,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,tl,Wt),He(Be(2,1)));r(1,E,b,p),U(w+dl,"{"+N+", valueComponents, getValueComponentProps"+el+"}: "+b,[re+`(${u}(${N}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+$+"(valueId);","return <Value",`{...${oe}(getValueComponentProps, valueId)}`,"key={valueId}",J,Bt,"/>;","}), separator)"],Fe(2,13)+le),k(((e,t,a,n,o)=>{const d="Map"+ft(t,1);r(0,A,d),r(1,A,d);const s=F(o+f,f,t,at(e)+le,l,n);F(Te+o+f+ae,Te+f+ae,Kt,at(e,9)+Ht,vt(Jt(f)+_t+t+" | "+d,Jt(f)+de),vt(n,zt(f)),qt,vt(ll,`value: ${t} | ${d})`+je,Ft),nl),F(ne+o+f+ae,ne+f+ae,ae,at(e,12),l,n,l,al,nl),U(o+f+dl,`{${N}, debugIds}: ${p}<'${e}'>`,[re+`('' + ${s}(`+N+`) ?? '', undefined, debugIds, ${n})`],at(e,13)+le)})),F(w+s,w+s,De,Fe(2,8)+" changes",rl(n),sl()),F(y+s,y+s,De,Ke(10,0,1),rl(d),sl()),F(f+s,f+s,De,Ke(11,0),rl(i,`valueId: ${a} | null`),sl("valueId"))}return U(me,`{${N}, ${N}ById, children}: `+K+" & {children: React.ReactNode}",["{",Zt,"return (","<Context."+me,"value={useMemo(",`() => [${N} ?? contextValue[0], {...contextValue[1], ...${N}ById}],`,`[${N}, ${N}ById, contextValue],`,")}>","{children}",`</Context.${me}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[d(...T(0),...V(),...H(0)),d(...T(1),...x(),...H(1))]},cl=(e,t,a)=>{if(Ot(e)&&Ot(t))return[l,l,l,l];const[n,o,d,r]=Gt(e,t,a);return[n,o,...Il(e,t,a,d,r)]};var il=Object.defineProperty,$l=Object.defineProperties,ul=Object.getOwnPropertyDescriptors,pl=Object.getOwnPropertySymbols,bl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,hl=(e,t,l)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,gl=(e,t)=>{for(var l in t||(t={}))bl.call(t,l)&&hl(e,l,t[l]);if(pl)for(var l of pl(t))Cl.call(t,l)&&hl(e,l,t[l]);return e},ml=(e,t)=>$l(e,ul(t)),fl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const wl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},yl=Et((e=>{const t=()=>{const t=D(e.getTablesSchemaJson());return!Ot(t)||v(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=_();if(v(a,(t=>v(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=K(n,a,(()=>[z(o),_(),[0],0])),[r,s,[I]]=d,c=K(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),q(s,o,c),d[3]++,r==z(o)})))))return t[l]={},F(n,(([e,,[,n],o],s)=>{t[l][s]=gl({[d]:e},o==R(a)?{[r]:n}:{})})),1}))?t:{}},l=()=>{const t=D(e.getValuesSchemaJson());return Ot(t)&&e.forEachValue(((e,l)=>{t[e]={[d]:z(l)}})),t},a=e=>cl(t(),l(),e),n=e=>fl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return x(a(e),((e,a)=>Ct(l(e,ml(gl({},wl),{filepath:"_."+t[a]})))))}));return kt({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),gl({totalTables:l,totalRows:a,totalCells:n,totalValues:R(e.getValueIds()),jsonLength:ht(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=yl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
|
|
1
|
+
var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="",a=t(l),n=t(!0),o=t(0),d="type",r="default",s="Listener",I="get",c="add",i="Ids",$="Table",u=$+"s",p=$+i,b="Row",C=b+i,h="Sorted"+b+i,g="Cell",m=g+i,f="Value",w=f+"s",y=f+i,v=(e,t)=>e.every(t),T=(e,t)=>e.sort(t),V=(e,t)=>e.forEach(t),x=(e,t)=>e.map(t),R=e=>e.length,P=e=>0==R(e),k=(e,t)=>e.filter(t),S=(e,...t)=>e.push(...t),A=e=>e.pop(),O=(e,...t)=>e.unshift(...t),E=e=>e.shift(),D=JSON.parse,j=isFinite,N=(e,t)=>e instanceof t,L=e=>null==e,M=e=>e==a||e==n,G=e=>t(e)==a,J=e=>Array.isArray(e),z=e=>{const l=t(e);return M(l)||l==o&&j(e)?l:void 0},W=Object,B=W.keys,F=W.freeze,U=e=>N(e,W)&&e.constructor==W,_=(e,t)=>x(W.entries(e),(([e,l])=>t(l,e))),Z=e=>U(e)&&P(B(e)),H=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},Q=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},q=(e,t)=>null==e?void 0:e.forEach(t),K=(e,t)=>null==e?void 0:e.delete(t),X=e=>new Map(e),Y=(e,t)=>null==e?void 0:e.get(t),ee=(e,t)=>q(e,((e,l)=>t(l,e))),te=(e,t)=>{var l;return x([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},le=(e,t,l)=>L(l)?(K(e,t),e):null==e?void 0:e.set(t,l),ae=(e,t,l)=>(H(e,t)||le(e,t,l()),Y(e,t)),ne=e=>e.toUpperCase(),oe=e=>e.toLowerCase(),de="a ",re="A function for",se=", and registers a listener so that any changes to that result will cause a re-render",Ie="Callback",ce="Del",ie="Deps",$e=ie+"?: React.DependencyList",ue="doRollback?: DoRollback",pe="actions: () => Return, "+ue,be="export",Ce="Id",he="Invalid",ge="Json",me=oe(s),fe="?: ",we=" | undefined",ye="NonNullable",ve="Partial",Te="Props",Ve="Provider",xe=`Registers a ${me} that will be called`,Re="Represents",Pe="rowId: "+Ce,ke="Schema",Se="Set",Ae=", descending?: boolean, offset?: number, limit?: number",Oe="[]",Ee="the Store",De="Transaction",je=oe(De),Ne="Execute a "+je+" to make multiple mutations",Le="Explicitly starts a "+je,Me="Explicitly finishes a "+je,Ge="the end of the "+je,Je="void",ze=" => "+Je,We="WhenSet",Be=" when setting it",Fe=de+"string serialization of",Ue=" ",_e="Gets a callback that can ",Ze="the ",He=" the schema for",Qe=(e=0,t=0)=>`the ${ut[e]}content of`+(t?Ue+Ee:l),qe=(e=0,t,a=0)=>ct[t]+Ue+Qe(e,1)+(a?" when setting it":l),Ke=(e,t=0)=>Re+` a Row when ${t?"s":"g"}etting ${Qe()} the '${e}' `+$,Xe=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,Ye=(e,t)=>`Calls a function for each ${e} in `+t,et=e=>"The props passed to a component that renders "+e,tt=e=>"A function that takes "+e,lt=(e,t=0)=>re+" listening to changes to "+$t[e]+" in "+$t[t],at=(e,t,a=0)=>xe+" whenever "+$t[e]+" in "+$t[t]+" change"+(a?l:"s"),nt=e=>`the '${e}' `+$,ot=e=>"the specified Row in "+nt(e),dt=(e,t=0)=>ct[t]+` ${Qe()} `+nt(e),rt=(e,t=0)=>ct[t]+` ${Qe()} `+ot(e),st=(e,t,l=0)=>ct[l]+` the '${t}' Cell for `+ot(e),It=(e,t=0)=>ct[t]+` the '${e}' Value`,ct=["Gets","Checks existence of","Sets","Deletes","Sets part of",Re,"Gets "+Fe,"Sets "+Fe,xe+" whenever",_e+"set",_e+"add",_e+"set part of",_e+"delete","Renders","Gets "+Fe+He,"Sets"+He,"Deletes"+He],it=[I,"has","set","del","set","forEach",c,l],$t=[Ee,u,Ze+$+Ue+i,de+$,Ze+b+Ue+i,de+b,Ze+g+Ue+i,de+g,"invalid Cell changes",w,Ze+f+Ue+i,de+f,"invalid Value changes",Ze+"sorted "+b+Ue+i],ut=[l,"tabular ","keyed value "],pt=e=>new Set(J(e)||L(e)?e:[e]),bt=(e,t)=>null==e?void 0:e.add(t),Ct=/[^A-Za-z]+/,ht=/[^A-Za-z0-9]+/,gt=/^( *)\/\*\* *(.*?) *\*\/$/gm,mt=(e,t,l)=>e.substring(t,l),ft=e=>e.includes(","),wt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return H(e,n)?wt(e,t,l,a+1):(le(e,n,l),n)},yt=e=>e.replace(gt,((e,t,l)=>{const a=77-vt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),vt=e=>e.length,Tt=(e,t=l)=>e.join(t),Vt=e=>e.flat(1e3),xt=(e,t=0)=>Tt(x(e.split(ht),((e,l)=>(l>0||t?ne:oe)(mt(e,0,1))+mt(e,1)))),Rt=e=>ne(Tt((e&&!Ct.test(e[0])?e:" "+e).split(ht),"_")),Pt=e=>`/** ${e}. */`,kt=(...e)=>Tt(k(e,(e=>e)),", "),St=(...e)=>"{"+Tt(e,"; ")+"}",At=(...e)=>St(...x(e,(e=>"readonly "+e))),Ot=()=>{const e=[X(),X(),X(),X()],t=X(),a=X();return[(...e)=>Tt(Vt(e),"\n"),(t,l,...a)=>V(a,(a=>V([0,1],(n=>(null!=t?t:n)==n?bt(ae(e[n],l,pt),a):0)))),(e,a,n,o=l,d=1)=>wt(t,e,[a,n,o,d]),(e,t,l)=>wt(a,e,J(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>Y(a,e)===t?e:wt(a,e,t),(t=0)=>x([...T(te(e[t],((e,t)=>`import {${Tt(T(Q(e)),", ")}} from '${t}';`)),((e,t)=>ft(e)!=ft(t)?ft(e)?-1:1:e>t?1:-1)),l],(e=>e.replace("{React}","React"))),()=>te(t,(([e,t,a,n],o)=>[Pt(t),`${n?be+" ":l}type ${o}${a} = ${e};`,l])),()=>te(a,((e,t)=>(e=J(e)?e:[e],S(e,A(e)+";"),[`const ${t} = ${E(e)}`,e,l])))]},Et=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Dt=(e,t,l)=>[t=>_(e,((e,a)=>t(a,xt(a,1),l(Rt(a),`'${a}'`)))),(t,a)=>_(e[t],((e,t)=>a(t,e[d],e[r],l(Rt(t),`'${t}'`),xt(t,1)))),e=>_(t,((t,a)=>e(a,t[d],t[r],l(Rt(a),`'${a}'`),xt(a,1))))],jt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(u,St(...t((e=>`'${e}'?: {[rowId: Id]: `+St(...a(e,((e,t,a)=>`'${e}'${L(a)?"?":l}: ${t}`)))+"}"))),qe(1,5)),I=e(u+We,St(...t((e=>`'${e}'?: {[rowId: Id]: `+St(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),qe(1,5,1)),c=e($+Ce,"keyof "+r,"A "+$+" Id in "+Ee),i=`<TId extends ${c}>`,f=e($,ye+`<${r}[TId]>`,"A "+$+" in "+Ee,i),w=e($+We,ye+`<${I}[TId]>`,"A "+$+" in "+Ee+Be,i),y=e(b,f+"<TId>[Id]","A "+b+" in a "+$,i),v=e(b+We,w+"<TId>[Id]","A "+b+" in a "+$+Be,i),T=e(g+Ce,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+b,i),V=e(g,ye+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+b,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+b,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(g+Ie,`(...[cellId, cell]: ${x}<TId>)`+ze,tt(de+g+" Id, and "+g),i),P=e(b+Ie,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+ze+") "+ze,tt(de+b+" Id, and a "+g+" iterator"),i),k=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${P}<TId>)${ze}] : never`,$+" Ids and callback types",`<TId = ${c}>`,0),S=e($+Ie,`(...[tableId, forEachRow]: ${k})`+ze,tt(de+$+" Id, and a "+b+" iterator"),l),A=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),O=e("GetCellChange",`(...[tableId, rowId, cellId]: ${A}) => CellChange`,re+" returning information about any Cell's changes during a "+je),E=e(u+s,`(${d}, getCellChange: ${O}${we})`+ze,lt(1)),D=e(p+s,`(${d})`+ze,lt(2)),j=e($+s,`(${d}, tableId: ${c}, getCellChange: ${O}${we})`+ze,lt(3)),N=e(C+s,`(${d}, tableId: ${c})`+ze,lt(4,3)),M=e(h+s,"("+kt(d,"tableId: "+c,"cellId: Id"+we,"descending: boolean","offset: number","limit: number"+we,"sortedRowIds: Ids")+")"+ze,lt(13,3)),G=e(b+s,"("+kt(""+d,"tableId: "+c,Pe,`getCellChange: ${O}${we}`)+")"+ze,lt(5,3)),J=e(m+s,"("+kt(""+d,"tableId: "+c,Pe)+")"+ze,lt(6,5)),z=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Pe}, cellId: CId, newCell: ${V}<TId, CId> ${we}, oldCell: ${V}<TId, CId> ${we}, getCellChange: ${O} ${we}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${T}<TId>>`,0),W=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+z+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[r,I,c,f,w,y,v,T,V,R,P,S,E,D,j,N,M,G,J,e(g+s,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${W})`+ze,lt(7,5)),e(he+g+s,`(${d}, tableId: Id, ${Pe}, cellId: Id, invalidCells: any[])`+ze,lt(8))]},(t,a)=>{const o=t+": "+a,d=e(w,St(...n(((e,t,a)=>`'${e}'${L(a)?"?":l}: ${t}`))),qe(2,5)),r=e(w+We,St(...n(((e,t)=>`'${e}'?: ${t}`))),qe(2,5,1)),I=e(f+Ce,"keyof "+d,"A "+f+" Id in "+Ee),c=e(f,ye+`<${d}[VId]>`,"A "+f+" Id in "+Ee,`<VId extends ${I}>`),i=e("ValueIdValueArray",`VId extends ${I} ? [valueId: VId, value: ${c}<VId>] : never`,f+" Ids and types in "+Ee,`<VId = ${I}>`,0),$=e(f+Ie,`(...[valueId, value]: ${i})`+ze,tt(de+f+" Id, and "+f)),u=e("GetValueChange",`(valueId: ${I}) => ValueChange`,re+" returning information about any Value's changes during a "+je),p=e(w+s,`(${o}, getValueChange: ${u}${we})`+ze,lt(9)),b=e(y+s,`(${o})`+ze,lt(10)),C=e("ValueListenerArgsArray",`VId extends ${I} ? [${o}, valueId: VId, newValue: ${c}<VId> ${we}, oldValue: ${c}<VId> ${we}, getValueChange: ${u} ${we}] : never`,"Value args for ValueListener",`<VId = ${I}>`,0);return[d,r,I,c,$,p,b,e(f+s,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+ze,lt(11)),e(he+f+s,`(${o}, valueId: Id, invalidValues: any[])`+ze,lt(12))]},(t,l)=>e(De+s,`(${t}: ${l}, cellsTouched: boolean, valuesTouched: boolean)`+ze,re+" listening to the completion of a "+je)],Nt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Lt=(e,t=l)=>`fluent(() => ${Nt(e,t)})`,Mt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,Gt=(e,t,a)=>{const[o,I,v,T,x,R,P,k]=Ot(),[A,E,D]=Dt(e,t,x),[j,N,M]=jt(v,A,E,D),J=X(),z=(e=0)=>te(J,(([t,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${a} => ${n},`]:[r+d+`(${t}): ${a};`];return e||O(s,Pt(o)),S(s,l),s})),W=(e,t,a,n,o,d=l)=>wt(J,e,[t,a,n,o,d]),B=(e,t,a,n,o,d=l,r=l,s=l)=>W(it[e]+t+(4==e?ve:l)+a,d,n,(n==_?Lt:Nt)(it[e]+(4==e?ve:l)+a,r,e?void 0:n),o,s),F=(e,t,a,n=l,o=l,d=1,r=l)=>W(c+e+s,(n?n+", ":l)+me+": "+t+(d?", mutator?: boolean":l),Ce,Mt(c+e+s,o,d?"mutator":l),a,r),U=`./${xt(a)}.d`,_=xt(a,1),H=xt(_),q=[],K=X();let ae=[],ne=[];if(I(1,U,_,`create${_} as create${_}Decl`),!Z(e)){I(0,"tinybase","CellChange"),I(null,"tinybase",i);const[e,t,a,o,s,c,f,w,y,T,R,P,k,O,D,N,M,J,z,W,Z]=j(H,_),ee=X();A(((e,t)=>{const l=`<'${e}'>`,a=[v(t+$,o+l,Re+` the '${e}' `+$),v(t+$+We,s+l,Re+` the '${e}' `+$+Be),v(t+b,c+l,Ke(e)),v(t+b+We,f+l,Ke(e,1)),v(t+g+Ce,w+l,`A Cell Id for the '${e}' `+$),v(t+g+Ie,T+l,tt(`a Cell Id and value from a Row in the '${e}' `+$)),v(t+b+Ie,R+l,tt(`a Row Id from the '${e}' Table, and a Cell iterator`))];le(ee,e,a),I(1,U,...a)})),I(1,U,e,t,a,w,P,k,O,D,N,M,J,z,W,Z),ae=[e,t,a,w,k,O,D,N,M,J,z,W,ee],V([[e],[n],[_,"tables: "+t,"tables"],[_]],(([e,t,a],n)=>B(n,l,u,e,qe(1,n),t,a))),B(0,l,p,a+Oe,Xe($,Ee)),B(5,l,$,Je,Ye($,Ee),"tableCallback: "+P,"tableCallback as any"),A(((e,t,a)=>{const[o,d,r,s,I,c,u]=Y(ee,e);V([[o],[n],[_,"table: "+d,", table"],[_]],(([n,o,d=l],r)=>B(r,t,$,n,dt(e,r),o,a+d))),B(0,t,C,i,Xe(b,nt(e)),l,a),B(0,t,h,i,Xe(b,nt(e),1),"cellId?: "+I+Ae,a+", cellId, descending, offset, limit"),B(5,t,b,Je,Ye(b,nt(e)),"rowCallback: "+u,a+", rowCallback as any"),V([[r],[n],[_,", row: "+s,", row"],[_],[_,", partialRow: "+s,", partialRow"]],(([n,o=l,d=l],r)=>B(r,t,b,n,rt(e,r),Pe+o,a+", rowId"+d))),B(6,t,b,Ce+we,"Add a new Row to "+nt(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),B(0,t,m,I+Oe,Xe(g,ot(e)),Pe,a+", rowId"),B(5,t,g,Je,Ye(g,ot(e)),Pe+", cellCallback: "+c,a+", rowId, cellCallback as any"),E(e,((o,d,r,s,I)=>{const c="Map"+xt(d,1);le(K,d,c);const i=d+(L(r)?we:l);V([[i],[n],[_,`, cell: ${d} | `+c,", cell as any"],[_]],(([n,d=l,r=l],c)=>B(c,t+I,g,n,st(e,o,c),Pe+d,a+", rowId, "+s+r)))}))})),B(0,l,u+ge,ge,qe(1,6)),B(2,l,u+ge,_,qe(1,7),"tablesJson: "+ge,"tables"+ge),F(u,k,qe(1,8)+" changes"),F(p,O,at(2,0,1)),F($,D,at(3,0),`tableId: ${a} | null`,"tableId"),F(C,N,at(4,3,1),`tableId: ${a} | null`,"tableId"),F(h,M,at(13,3,1),kt("tableId: TId",`cellId: ${w}<TId>`+we,"descending: boolean","offset: number","limit: number"+we),kt("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),F(b,J,at(5,3),`tableId: ${a} | null, rowId: IdOrNull`,"tableId, rowId"),F(m,z,at(6,5,1),`tableId: ${a} | null, rowId: IdOrNull`,"tableId, rowId"),F(g,W,at(7,5),`tableId: ${a} | null, rowId: IdOrNull, cellId: ${Tt(A((e=>{var t,a;return null!=(a=null==(t=Y(ee,e))?void 0:t[4])?a:l}))," | ")} | null`,"tableId, rowId, cellId"),F(he+g,Z,xe+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),I(1,U,...Q(K)),S(q,".set"+u+ke+"({",Vt(A(((e,t,a)=>[`[${a}]: {`,...E(e,((e,t,a,n)=>`[${n}]: {[${x(Rt(d),`'${d}'`)}]: ${x(Rt(t),`'${t}'`)}${L(a)?l:`, [${x(Rt(r),`'${r}'`)}]: `+(G(a)?x(Rt(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!Z(t)){const[e,t,a,o,s,c,i,$,u]=N(H,_);I(1,U,e,t,a,s,c,i,$,u),ne=[e,t,a,c,i,$],V([[e],[n],[_,"values: "+t,"values"],[_],[_,"partialValues: "+t,"partialValues"]],(([e,t,a],n)=>B(n,l,w,e,qe(2,n),t,a))),B(0,l,y,a+Oe,Xe(f,Ee)),B(5,l,f,"void",Ye(f,Ee),"valueCallback: "+s,"valueCallback as any"),D(((e,t,a,o,d)=>{const r="Map"+xt(t,1);le(K,t,r),V([[t],[n],[_,`value: ${t} | `+r,", value as any"],[_]],(([t,a,n=l],r)=>B(r,d,f,t,It(e,r),a,o+n)))})),B(0,l,w+ge,ge,qe(2,6)),B(2,l,w+ge,_,qe(2,7),"valuesJson: "+ge,"values"+ge),F(w,c,qe(2,8)+" changes"),F(y,i,at(10,0,1)),F(f,$,at(11,0),`valueId: ${a} | null`,"valueId"),F(he+f,u,xe+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),I(1,U,...Q(K)),I(0,"tinybase","ValueChange"),S(q,".set"+w+ke+"({",D(((e,t,a,n)=>[`[${n}]: {[${x(Rt(d),`'${d}'`)}]: ${x(Rt(t),`'${t}'`)}${L(a)?l:`, [${x(Rt(r),`'${r}'`)}]: `+(G(a)?x(Rt(a),`'${a}'`):a)}},`])),"})")}ee(K,((e,t)=>v(t,`(cell: ${e}${we}) => `+e,`Takes a ${e} Cell value and returns another`))),I(null,"tinybase","DoRollback",Ce,"IdOrNull",ge,"Store"),B(0,l,ge,ge,qe(0,6)),B(2,l,ge,_,qe(0,7),"tablesAndValuesJson: "+ge,"tablesAndValuesJson"),B(7,l,je,"Return",Ne,pe,"actions, doRollback","<Return>"),B(7,l,"start"+De,_,Le),B(7,l,"finish"+De,_,Me,ue,"doRollback");const oe=M(H,_);return F("WillFinish"+De,oe,xe+" just before "+Ge,l,l,0),F("DidFinish"+De,oe,xe+" just after "+Ge,l,l,0),B(7,l,"call"+s,_,"Manually provoke a listener to be called","listenerId: Id","listenerId"),B(3,l,s,_,"Remove a listener that was previously added to "+Ee,"listenerId: Id","listenerId"),W("getStore",l,"Store","store",ct[0]+" the underlying Store object"),I(1,"tinybase","createStore"),I(1,U,_,`create${_} as create${_}Decl`,oe),x("store",["createStore()",...q]),T("fluent","actions: () => Store",["actions();",`return ${H};`]),T("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${H}, ...params)`),x(H,["{",...z(1),"}"]),[o(...R(0),...P(),be+" interface "+_+" {",...z(0),"}",l,Pt(`Creates a ${_} object`),be+" function create"+_+"(): "+_+";"),o(...R(1),be+" const create"+_+": typeof create"+_+"Decl = () => {",...k(),`return Object.freeze(${H});`,"};"),ae,ne]},Jt=e=>I+e,zt=e=>kt(Jt(e),Jt(e)+ie),Wt="debugIds?: boolean",Bt="debugIds={debugIds}",Ft="then"+$e,Ut="Parameter",_t=": (parameter: "+Ut+", store: Store) => ",Zt="const contextValue = useContext(Context);",Ht=", based on a parameter",Qt=": ",qt="<"+Ut+",>",Kt=Ut+"ized"+Ie+"<"+Ut+">",Xt="rowId",Yt="rowId={rowId}",el=", separator, debugIds",tl="separator?: ReactElement | string",ll="then?: (store: Store",al=kt(ll+")"+ze,Ft),nl="then, then"+ie,ol=Xt+Qt+Ce,dl="View",rl=(e,...t)=>kt(...t,me+": "+e,me+$e,"mutator?: boolean"),sl=(...e)=>kt(...e,me,me+ie,"mutator"),Il=(e,t,a,n,o)=>{const[d,r,I,c,v,T,V,x]=Ot(),[R,P,k]=Dt(e,t,v),A=`./${xt(a)}.d`,E=`./${xt(a)}-ui-react.d`,D="tinybase/ui-react",j=xt(a,1),N=xt(j),M=j+"Or"+j+Ce,G=N+"Or"+j+Ce,J=N+`={${N}}`,z=X(),W=(e,t,a,n,o,d=l)=>(r(1,E,e+" as "+e+"Decl"),wt(z,e,[t,a,n,o,d])),B=(e,t,a,n,o,d=l)=>W("use"+e,t,a,n,o,d),F=(e,t,a,n,o=l,d=l,s=l,I=l,c=l)=>(r(1,D,`use${t} as use${t}Core`),B(e,kt(o,q,I),a,ee+`(${G}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,s)),U=(e,t,l,a)=>W(e,t,1,l,a),_=(e=0)=>te(z,(([t,a,n,o,d],r)=>{const s=e?[be+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[be+` function ${r}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||O(s,Pt(o)),S(s,l),s}));r(null,"tinybase",Ce,"Store",Ie,Ut+"ized"+Ie),r(0,D,"ComponentReturnType"),r(null,D,"ExtraProps"),r(0,A,j);const H=I(M,j+" | "+Ce,`Used when you need to refer to a ${j} in a React hook or component`),Q=I(Ve+Te,At(N+fe+j,N+`ById?: {[${N}Id: Id]: ${j}}`),`Used with the ${Ve} component, so that a `+j+" can be passed into the context of an application");r(0,"react","ReactElement","ComponentType"),r(1,"react","React"),r(1,E,H,Q);const q=G+fe+H;v("{createContext, useContext, useMemo}","React"),v("Context",`createContext<[${j}?, {[${N}Id: Id]: ${j}}?]>([])`),B("Create"+j,`create: () => ${j}, create`+$e,j,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${j} within a React application with convenient memoization`);const K=B(j,"id?: Id",j+we,["{",Zt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${j} from within a ${Ve} component context`),ee=c("useHook",G+`: ${H} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${N} = ${K}(${G} as Id);`,`return hook(...preParams, ((${G} == null || typeof ${G} == 'string')`,`? ${N} : ${G})?.getStore(), ...postParams)`]),le=c("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),ae=c("wrap",kt("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),ne=v("NullComponent","() => null");if(!Z(e)){const[e,t,a,o,d,f,w,y,v,T,V,x,k]=n;r(null,A,e,t,a,d,f,w,y,v,T,V,x),r(0,A,o),r(1,A,j),r(null,"tinybase",i,"IdOrNull");const S=c("tableView",`{${N}, rowComponent, getRowComponentProps`+el+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${ae}(rowIds.map((rowId) => (`,"<Row","{..."+le+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",Yt,J,Bt,"/>","))",el,", tableId,",");"]),O=c("getDefaultTableComponent","tableId: Id",Tt(R(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+ne),D=c("getDefaultCellComponent","tableId: Id, cellId: Id",Tt(R(((e,t,l)=>`tableId == ${l} ? ${Tt(P(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+ne} : `)))+ne);F(u,u,e,qe(1,0)+se);const M=F(p,p,a+Oe,Xe($,Ee)+se);F(Se+u+Ie,Se+u+Ie,Kt,qe(1,9)+Ht,kt(Jt(u)+_t+t,Jt(u)+$e),zt(u),qt,kt(ll,`tables: ${t})`+ze,Ft),nl),F(ce+u+Ie,ce+u+Ie,Ie,qe(1,12),l,l,l,al,nl);const G=I(g+Te,At("tableId?: TId","rowId: Id","cellId?: CId",N+fe+j,Wt),et(de+g),`<TId extends ${a}, CId extends ${o}<TId>>`),z=I(b+Te,At("tableId?: TId","rowId: Id",N+fe+j,"cellComponents?: {readonly [CId in "+o+`<TId>]?: ComponentType<${G}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${o}<TId>) => ExtraProps`,tl,Wt),et(de+b),`<TId extends ${a}>`),W=I($+Te,At("tableId?: TId",N+fe+j,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",tl,Wt),et(de+$),`<TId extends ${a}>`),B=I("Sorted"+$+Te,At("tableId?: TId","cellId?: "+o+"<TId>","descending?: boolean","offset?: number","limit?: number",N+fe+j,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",tl,Wt),et(de+"sorted "+$),`<TId extends ${a}>`),_=I(u+Te,At(N+fe+j,"tableComponents?: {readonly [TId in "+a+`]?: ComponentType<${W}<TId>>;}`,`getTableComponentProps?: (tableId: ${a}) => ExtraProps`,tl,Wt),et(Qe(1,1)));r(1,E,_,W,B,z,G),U(u+dl,"{"+N+", tableComponents, getTableComponentProps"+el+"}: "+_,[ae+`(${M}(${N}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+O+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${le}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",J,Bt,"/>;","}), separator)"],qe(1,13)+se),R(((e,t,a)=>{const[n,o,d,s,I]=Y(k,e);r(null,A,n,o,d,s,I),F(t+$,$,n,dt(e)+se,l,a);const c=F(t+C,C,i,Xe(b,nt(e))+se,l,a),u=F(t+h,h,i,Xe(b,nt(e),1)+se,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");F(t+b,b,d,rt(e)+se,ol,kt(a,Xt));const p=F(t+m,m,I+Oe,Xe(g,ot(e))+se,ol,kt(a,Xt));F(Se+t+$+Ie,Se+$+Ie,Kt,dt(e,9)+Ht,kt(Jt($)+_t+o,Jt($)+$e),kt(a,zt($)),qt,kt(ll,`table: ${o})`+ze,Ft),nl),F(ce+t+$+Ie,ce+$+Ie,Ie,dt(e,12),l,a,l,al,nl),F(Se+t+b+Ie,Se+b+Ie,Kt,rt(e,9)+Ht,kt(ol,Jt(b)+_t+s,Jt(b)+$e),kt(a,Xt,zt(b)),qt,kt(ll,`row: ${s})`+ze,Ft),nl),F("Add"+t+b+Ie,"Add"+b+Ie,Kt,rt(e,10)+Ht,kt(Jt(b)+_t+s,Jt(b)+$e),kt(a,zt(b)),qt,"then?: ("+kt(ol+we,"store: Store","row: "+s+")"+ze,"then"+$e)+", reuseRowIds?: boolean",nl+", reuseRowIds"),F(Se+t+ve+b+Ie,Se+ve+b+Ie,Kt,rt(e,11)+Ht,kt(ol,Jt(ve+b)+_t+s,Jt(ve+b)+$e),kt(a,Xt,zt(ve+b)),qt,kt(ll,`partialRow: ${s})`+ze,Ft),nl),F(ce+t+b+Ie,ce+b+Ie,Ie,rt(e,12),ol,kt(a,Xt),l,al,nl);const f=U(t+b+dl,"{rowId, "+N+", cellComponents, getCellComponentProps"+el+`}: ${z}<'${e}'>`,[ae+`(${p}(rowId, ${N}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+D+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${le}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,Yt,"cellId={cellId}",J,Bt,"/>;","})"+el+", rowId)"],rt(e,13)+se);U(t+"Sorted"+$+dl,"{cellId, descending, offset, limit, ...props}: "+B+`<'${e}'>`,S+"(props, "+u+`(cellId, descending, offset, limit, props.${N}), ${a}, ${f});`,dt(e,13)+", sorted"+se),U(t+$+dl,`props: ${W}<'${e}'>`,S+"(props, "+c+`(props.${N}), ${a}, ${f});`,dt(e,13)+se),P(e,((n,o,d,s,I)=>{const c="Map"+xt(o,1);r(0,A,c),r(1,A,c);const i=F(t+I+g,g,o+(L(d)?we:l),st(e,n)+se,ol,kt(a,Xt,s));F(Se+t+I+g+Ie,Se+g+Ie,Kt,st(e,n,9)+Ht,kt(ol,Jt(g)+_t+o+" | "+c,Jt(g)+$e),kt(a,Xt,s,zt(g)),qt,kt(ll,`cell: ${o} | ${c})`+ze,Ft),nl),F(ce+t+I+g+Ie,ce+g+Ie,Ie,st(e,n,12),kt(ol,"forceDel?: boolean"),kt(a,Xt,s,"forceDel"),l,al,nl),U(t+I+g+dl,`{rowId, ${N}, debugIds}: `+G+`<'${e}', '${n}'>`,[ae+`('' + ${i}(rowId, `+N+`) ?? '', undefined, debugIds, ${s})`],st(e,n,13)+se)}))}));const Z=Tt(R((e=>{var t,a;return null!=(a=null==(t=Y(k,e))?void 0:t[4])?a:l}))," | ");F(u+s,u+s,Je,qe(1,8)+" changes",rl(d),sl()),F(p+s,p+s,Je,at(2,0,1),rl(f),sl()),F($+s,$+s,Je,at(3,0),rl(w,`tableId: ${a} | null`),sl("tableId")),F(C+s,C+s,Je,at(4,3,1),rl(y,`tableId: ${a} | null`),sl("tableId")),F(h+s,h+s,Je,at(13,3,1),rl(v,`tableId: ${a} | null`,"cellId: "+Z+we,"descending: boolean","offset: number","limit: number"+we),sl("tableId","cellId","descending","offset","limit")),F(b+s,b+s,Je,at(5,3),rl(T,`tableId: ${a} | null`,Xt+": IdOrNull"),sl("tableId",Xt)),F(m+s,m+s,Je,at(6,5,1),rl(V,`tableId: ${a} | null`,Xt+": IdOrNull"),sl("tableId",Xt)),F(g+s,g+s,Je,at(7,5),rl(x,`tableId: ${a} | null`,Xt+": IdOrNull",`cellId: ${Z} | null`),sl("tableId",Xt,"cellId"))}if(!Z(t)){const[e,t,a,n,d,i]=o;r(null,A,...o),r(1,A,j);const $=c("getDefaultValueComponent","valueId: Id",Tt(k(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+ne);F(w,w,e,qe(2,0)+se);const u=F(y,y,a+Oe,Xe(f,Ee)+se);F(Se+w+Ie,Se+w+Ie,Kt,qe(2,9)+Ht,kt(Jt(w)+_t+t,Jt(w)+$e),zt(w),qt,kt(ll,`values: ${t})`+ze,Ft),nl),F(Se+ve+w+Ie,Se+ve+w+Ie,Kt,qe(2,11)+Ht,kt(Jt(ve+w)+_t+t,Jt(ve+w)+$e),zt(ve+w),qt,kt(ll,`partialValues: ${t})`+ze,Ft),nl),F(ce+w+Ie,ce+w+Ie,Ie,qe(2,12),l,l,l,al,nl);const p=I(f+Te,At("valueId?: VId",N+fe+j,Wt),et("a Value"),`<VId extends ${a}>`),b=I(w+Te,At(N+fe+j,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,tl,Wt),et(Qe(2,1)));r(1,E,b,p),U(w+dl,"{"+N+", valueComponents, getValueComponentProps"+el+"}: "+b,[ae+`(${u}(${N}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+$+"(valueId);","return <Value",`{...${le}(getValueComponentProps, valueId)}`,"key={valueId}",J,Bt,"/>;","}), separator)"],qe(2,13)+se),k(((e,t,a,n,o)=>{const d="Map"+xt(t,1);r(0,A,d),r(1,A,d);const s=F(o+f,f,t,It(e)+se,l,n);F(Se+o+f+Ie,Se+f+Ie,Kt,It(e,9)+Ht,kt(Jt(f)+_t+t+" | "+d,Jt(f)+$e),kt(n,zt(f)),qt,kt(ll,`value: ${t} | ${d})`+ze,Ft),nl),F(ce+o+f+Ie,ce+f+Ie,Ie,It(e,12),l,n,l,al,nl),U(o+f+dl,`{${N}, debugIds}: ${p}<'${e}'>`,[ae+`('' + ${s}(`+N+`) ?? '', undefined, debugIds, ${n})`],It(e,13)+se)})),F(w+s,w+s,Je,qe(2,8)+" changes",rl(n),sl()),F(y+s,y+s,Je,at(10,0,1),rl(d),sl()),F(f+s,f+s,Je,at(11,0),rl(i,`valueId: ${a} | null`),sl("valueId"))}return U(Ve,`{${N}, ${N}ById, children}: `+Q+" & {children: React.ReactNode}",["{",Zt,"return (","<Context."+Ve,"value={useMemo(",`() => [${N} ?? contextValue[0], {...contextValue[1], ...${N}ById}],`,`[${N}, ${N}ById, contextValue],`,")}>","{children}",`</Context.${Ve}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[d(...T(0),...V(),..._(0)),d(...T(1),...x(),..._(1))]},cl=(e,t,a)=>{if(Z(e)&&Z(t))return[l,l,l,l];const[n,o,d,r]=Gt(e,t,a);return[n,o,...Il(e,t,a,d,r)]};var il=Object.defineProperty,$l=Object.defineProperties,ul=Object.getOwnPropertyDescriptors,pl=Object.getOwnPropertySymbols,bl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,hl=(e,t,l)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,gl=(e,t)=>{for(var l in t||(t={}))bl.call(t,l)&&hl(e,l,t[l]);if(pl)for(var l of pl(t))Cl.call(t,l)&&hl(e,l,t[l]);return e},ml=(e,t)=>$l(e,ul(t)),fl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const wl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},yl=Et((e=>{const t=()=>{const t=D(e.getTablesSchemaJson());return!Z(t)||v(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=X();if(v(a,(t=>v(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=ae(n,a,(()=>[z(o),X(),[0],0])),[r,s,[I]]=d,c=ae(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),le(s,o,c),d[3]++,r==z(o)})))))return t[l]={},q(n,(([e,,[,n],o],s)=>{t[l][s]=gl({[d]:e},o==R(a)?{[r]:n}:{})})),1}))?t:{}},l=()=>{const t=D(e.getValuesSchemaJson());return Z(t)&&e.forEachValue(((e,l)=>{t[e]={[d]:z(l)}})),t},a=e=>cl(t(),l(),e),n=e=>fl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return x(a(e),((e,a)=>yt(l(e,ml(gl({},wl),{filepath:"_."+t[a]})))))}));return F({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),gl({totalTables:l,totalRows:a,totalCells:n,totalValues:R(e.getValueIds()),jsonLength:vt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=yl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
|
package/lib/umd-es6/tools.js.gz
CHANGED
|
Binary file
|
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=[],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=>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": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -192,21 +192,21 @@
|
|
|
192
192
|
"@babel/preset-react": "^7.18.6",
|
|
193
193
|
"@babel/preset-typescript": "^7.21.5",
|
|
194
194
|
"@rollup/plugin-replace": "^5.0.2",
|
|
195
|
-
"@rollup/plugin-terser": "^0.4.
|
|
195
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
196
196
|
"@types/asciichart": "^1.5.6",
|
|
197
197
|
"@types/expect-puppeteer": "^5.0.3",
|
|
198
198
|
"@types/http-server": "^0.12.1",
|
|
199
199
|
"@types/jest": "^29.5.1",
|
|
200
200
|
"@types/jest-environment-puppeteer": "^5.0.3",
|
|
201
201
|
"@types/less": "^3.0.3",
|
|
202
|
-
"@types/node": "^
|
|
202
|
+
"@types/node": "^20.1.7",
|
|
203
203
|
"@types/puppeteer": "^5.4.7",
|
|
204
|
-
"@types/react": "^18.2.
|
|
205
|
-
"@types/react-dom": "^18.2.
|
|
204
|
+
"@types/react": "^18.2.6",
|
|
205
|
+
"@types/react-dom": "^18.2.4",
|
|
206
206
|
"@types/react-test-renderer": "^18.0.0",
|
|
207
207
|
"@types/tmp": "^0.2.3",
|
|
208
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
209
|
-
"@typescript-eslint/parser": "^5.59.
|
|
208
|
+
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
209
|
+
"@typescript-eslint/parser": "^5.59.6",
|
|
210
210
|
"asciichart": "^1.5.25",
|
|
211
211
|
"babel-eslint": "^10.1.0",
|
|
212
212
|
"babel-jest": "^29.5.0",
|
|
@@ -214,11 +214,11 @@
|
|
|
214
214
|
"buffer-replace": "^1.0.0",
|
|
215
215
|
"country-flag-emoji-json": "^2.0.0",
|
|
216
216
|
"cspell": "^6.31.1",
|
|
217
|
-
"esbuild": "^0.17.
|
|
218
|
-
"eslint": "^8.
|
|
217
|
+
"esbuild": "^0.17.19",
|
|
218
|
+
"eslint": "^8.40.0",
|
|
219
219
|
"eslint-config-prettier": "^8.8.0",
|
|
220
220
|
"eslint-plugin-jest": "^27.2.1",
|
|
221
|
-
"eslint-plugin-jsdoc": "^
|
|
221
|
+
"eslint-plugin-jsdoc": "^44.2.4",
|
|
222
222
|
"eslint-plugin-react": "^7.32.2",
|
|
223
223
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
224
224
|
"gulp": "^4.0.2",
|
|
@@ -230,11 +230,11 @@
|
|
|
230
230
|
"jest-puppeteer": "^8.0.6",
|
|
231
231
|
"less": "^4.1.3",
|
|
232
232
|
"prettier": "^2.8.8",
|
|
233
|
-
"puppeteer": "^20.1
|
|
233
|
+
"puppeteer": "^20.2.1",
|
|
234
234
|
"react": "^18.2.0",
|
|
235
235
|
"react-dom": "^18.2.0",
|
|
236
236
|
"react-test-renderer": "^18.2.0",
|
|
237
|
-
"rollup": "^3.
|
|
237
|
+
"rollup": "^3.22.0",
|
|
238
238
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
239
239
|
"rollup-plugin-gzip": "^3.1.0",
|
|
240
240
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
"tmp": "^0.2.1",
|
|
245
245
|
"ts-unused-exports": "^9.0.4",
|
|
246
246
|
"typescript": "5.0.4",
|
|
247
|
-
"yjs": "^13.6.
|
|
247
|
+
"yjs": "^13.6.1"
|
|
248
248
|
},
|
|
249
249
|
"peerDependencies": {
|
|
250
250
|
"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.5kB - 8.7kB</a> when compressed, and has zero dependencies. And of course it'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/#v3-1"><em>NEW!</em> v3.1 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><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://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/values/"><code>Values</code></a> in it by unique <a href="https://beta.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://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const store = createStore()
|
|
@@ -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://beta.tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>4.
|
|
269
|
+
<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'll only add a gzipped <em>4.5kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.7kB</em>.</p><p>The optional <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://beta.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://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.5kB</td><td>10.7kB</td><td>45.6kB</td><td>200.7kB</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.9kB</td><td>29.3kB</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.7kB</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.7kB</td><td>16.8kB</td><td>42.2kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>112.9kB</td></tr><tr><th class="right"><a href="https://beta.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://beta.tinybase.org/api/persisters/">persisters</a></th><td>0.4kB</td><td>0.8kB</td><td>2.7kB</td><td>24.6kB</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.2kB</td><td>92.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://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,768</td><td>1,768</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,908</td><td>1,908</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>763</td><td>763</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>645</td><td>645</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">2,712</td></tr><tr><th class="right">Assertions</th><td colspan="3">13,375</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>, <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://beta.tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/4.0.0-beta.2">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://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>
|