tinybase 3.1.0-beta.3 → 3.1.0-beta.4
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.d.ts +13 -11
- package/lib/cjs/checkpoints.d.ts +13 -11
- package/lib/cjs/indexes.d.ts +15 -7
- package/lib/cjs/metrics.d.ts +9 -7
- package/lib/cjs/persisters.d.ts +30 -24
- package/lib/cjs/queries.d.ts +10 -6
- package/lib/cjs/relationships.d.ts +15 -7
- package/lib/cjs/store.d.ts +1190 -291
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/tools.d.ts +12 -178
- package/lib/cjs-es6/checkpoints.d.ts +13 -11
- package/lib/cjs-es6/indexes.d.ts +15 -7
- package/lib/cjs-es6/metrics.d.ts +9 -7
- package/lib/cjs-es6/persisters.d.ts +30 -24
- package/lib/cjs-es6/queries.d.ts +10 -6
- package/lib/cjs-es6/relationships.d.ts +15 -7
- package/lib/cjs-es6/store.d.ts +1190 -291
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/tools.d.ts +12 -178
- package/lib/debug/checkpoints.d.ts +13 -11
- package/lib/debug/indexes.d.ts +15 -7
- package/lib/debug/metrics.d.ts +9 -7
- package/lib/debug/persisters.d.ts +30 -24
- package/lib/debug/queries.d.ts +10 -6
- package/lib/debug/relationships.d.ts +15 -7
- package/lib/debug/store.d.ts +1190 -291
- package/lib/debug/tools.d.ts +12 -178
- package/lib/debug/tools.js +14 -621
- package/lib/es6/checkpoints.d.ts +13 -11
- package/lib/es6/indexes.d.ts +15 -7
- package/lib/es6/metrics.d.ts +9 -7
- package/lib/es6/persisters.d.ts +30 -24
- package/lib/es6/queries.d.ts +10 -6
- package/lib/es6/relationships.d.ts +15 -7
- package/lib/es6/store.d.ts +1190 -291
- package/lib/es6/tools.d.ts +12 -178
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/indexes.d.ts +15 -7
- package/lib/metrics.d.ts +9 -7
- package/lib/persisters.d.ts +30 -24
- package/lib/queries.d.ts +10 -6
- package/lib/relationships.d.ts +15 -7
- package/lib/store.d.ts +1190 -291
- package/lib/tools.d.ts +12 -178
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/umd/checkpoints.d.ts +13 -11
- package/lib/umd/indexes.d.ts +15 -7
- package/lib/umd/metrics.d.ts +9 -7
- package/lib/umd/persisters.d.ts +30 -24
- package/lib/umd/queries.d.ts +10 -6
- package/lib/umd/relationships.d.ts +15 -7
- package/lib/umd/store.d.ts +1190 -291
- package/lib/umd/tools.d.ts +12 -178
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd-es6/checkpoints.d.ts +13 -11
- package/lib/umd-es6/indexes.d.ts +15 -7
- package/lib/umd-es6/metrics.d.ts +9 -7
- package/lib/umd-es6/persisters.d.ts +30 -24
- package/lib/umd-es6/queries.d.ts +10 -6
- package/lib/umd-es6/relationships.d.ts +15 -7
- package/lib/umd-es6/store.d.ts +1190 -291
- package/lib/umd-es6/tools.d.ts +12 -178
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/package.json +20 -20
- package/readme.md +1 -1
package/lib/cjs/tools.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=e=>typeof e,t="",l=e(t),a=e(!0),n=e(0),o="type",d="default",r="Listener",s="get",I="add",c="Ids",i="Table",$=i+"s",u=i+c,b="Row",p=b+c,C="Sorted"+b+c,m="Cell",h=m+c,g="Value",f=g+"s",w=g+c,y=(e,t)=>e.every(t),T=(e,t)=>e.sort(t),v=(e,t)=>e.forEach(t),V=(e,t)=>e.map(t),x=e=>e.length,R=e=>0==x(e),S=(e,t)=>e.filter(t),k=(e,...t)=>e.push(...t),A=e=>e.pop(),P=(e,...t)=>e.unshift(...t),E=e=>e.shift(),D=JSON.parse,N=isFinite,O=(e,t)=>e instanceof t,j=e=>null==e,L=e=>e==l||e==a,M=t=>e(t)==l,G=e=>Array.isArray(e),J=t=>{const l=e(t);return L(l)||l==n&&N(t)?l:void 0},z=(e,t)=>e?.has(t)??!1,W=e=>[...e?.values()??[]],F=(e,t)=>e?.forEach(t),B=(e,t)=>e?.delete(t),_=e=>new Map(e),U=(e,t)=>e?.get(t),Z=(e,t)=>F(e,((e,l)=>t(l,e))),H=(e,t)=>V([...e?.entries()??[]],(([e,l])=>t(l,e))),Q=(e,t,l)=>j(l)?(B(e,t),e):e?.set(t,l),q=(e,t,l)=>(z(e,t)||Q(e,t,l()),U(e,t)),K=e=>e.toUpperCase(),X=e=>e.toLowerCase(),Y="a ",ee="A function for",te="Callback",le="Del",ae="doRollback?: DoRollback",ne="actions: () => Return, "+ae,oe="export",de="Id",re="IdOrNull",se="Invalid",Ie="Json",ce=X(r),ie=" | undefined",$e="NonNullable",ue="Partial",be=`Registers a ${ce} that will be called`,pe="Represents",Ce="rowId: "+de,me="rowId: "+re,he="Schema",ge="Set",fe=", descending?: boolean, offset?: number, limit?: number",we="[]",ye="Store",Te="the "+ye,ve="Transaction",Ve=X(ve),xe="Execute a "+Ve+" to make multiple mutations",Re="Explicitly starts a "+Ve,Se="Explicitly finishes a "+Ve,ke="the end of the "+Ve,Ae="void",Pe=" => "+Ae,Ee="WhenSet",De=" when setting it",Ne=Y+"string serialization of",Oe=" ",je="Gets a callback that can ",Le="the ",Me=" the schema for",Ge=(e=0,l=0)=>`the ${nt[e]}content of`+(l?Oe+Te:t),Je=(e=0,l,a=0)=>tt[l]+Oe+Ge(e,1)+(a?" when setting it":t),ze=(e,t=0)=>pe+` a Row when ${t?"s":"g"}etting ${Ge()} the '${e}' `+i,We=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,Fe=(e,t)=>`Calls a function for each ${e} in `+t,Be=e=>"The props passed to a component that renders "+e,_e=e=>"A function that takes "+e,Ue=(e,t=0)=>ee+" listening to changes to "+at[e]+" in "+at[t],Ze=(e,l,a=0)=>be+" whenever "+at[e]+" in "+at[l]+" change"+(a?t:"s"),He=e=>`the '${e}' `+i,Qe=e=>"the specified Row in "+He(e),qe=(e=0,t=0)=>tt[e]+Oe+at[t],Ke=(e,t=0)=>tt[t]+` ${Ge()} `+He(e),Xe=(e,t=0)=>tt[t]+` ${Ge()} `+Qe(e),Ye=(e,t,l=0)=>tt[l]+` the '${t}' Cell for `+Qe(e),et=(e,t=0)=>tt[t]+` the '${e}' Value`,tt=["Gets","Checks existence of","Sets","Deletes","Sets part of",pe,"Gets "+Ne,"Sets "+Ne,be+" whenever",je+"set",je+"add",je+"set part of",je+"delete","Renders","Gets "+Ne+Me,"Sets"+Me,"Deletes"+Me],lt=[s,"has","set","del","set","forEach",I,t],at=[Te,$,Le+i+Oe+c,Y+i,Le+b+Oe+c,Y+b,Le+m+Oe+c,Y+m,"invalid Cell changes",f,Le+g+Oe+c,Y+g,"invalid Value changes",Le+"sorted "+b+Oe+c],nt=[t,"tabular ","keyed value "],ot=e=>new Set(G(e)||j(e)?e:[e]),dt=(e,t)=>e?.add(t),rt=/[^A-Za-z]+/,st=/[^A-Za-z0-9]+/,It=/^( *)\/\*\* *(.*?) *\*\/$/gm,ct=(e,t,l)=>e.substring(t,l),it=e=>e.includes(","),$t=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return z(e,n)?$t(e,t,l,a+1):(Q(e,n,l),n)},ut=e=>e.replace(It,((e,t,l)=>{const a=77-bt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),bt=e=>e.length,pt=(e,l=t)=>e.join(l),Ct=e=>e.flat(1e3),mt=(e,t=0)=>pt(V(e.split(st),((e,l)=>(l>0||t?K:X)(ct(e,0,1))+ct(e,1)))),ht=e=>K(pt((e&&!rt.test(e[0])?e:" "+e).split(st),"_")),gt=e=>`/** ${e}. */`,ft=(...e)=>pt(S(e,(e=>e)),", "),wt=(...e)=>"{"+pt(e,"; ")+"}",yt=(...e)=>wt(...V(e,(e=>"readonly "+e))),Tt=()=>{const e=[_(),_(),_(),_()],l=_(),a=_();return[(...e)=>pt(Ct(e),"\n"),(t,l,...a)=>v(a,(a=>v([0,1],(n=>(t??n)==n?dt(q(e[n],l,ot),a):0)))),(e,a,n,o=t,d=1)=>$t(l,e,[a,n,o,d]),(e,t,l)=>$t(a,e,G(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>U(a,e)===t?e:$t(a,e,t),(l=0)=>V([...T(H(e[l],((e,t)=>`import {${pt(T(W(e)),", ")}} from '${t}';`)),((e,t)=>it(e)!=it(t)?it(e)?-1:1:e>t?1:-1)),t],(e=>e.replace("{React}","React"))),()=>H(l,(([e,l,a,n],o)=>[gt(l),`${n?oe+" ":t}type ${o}${a} = ${e};`,t])),()=>H(a,((e,l)=>(e=G(e)?e:[e],k(e,A(e)+";"),[`const ${l} = ${E(e)}`,e,t])))]},vt=Object,Vt=vt.keys,xt=vt.freeze,Rt=e=>O(e,vt)&&e.constructor==vt,St=(e,t)=>V(vt.entries(e),(([e,l])=>t(l,e))),kt=e=>Rt(e)&&R(Vt(e)),At=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Pt=(e,t,l)=>[t=>St(e,((e,a)=>t(a,mt(a,1),l(ht(a),`'${a}'`)))),(t,a)=>St(e[t],((e,t)=>a(t,e[o],e[d],l(ht(t),`'${t}'`),mt(t,1)))),e=>St(t,((t,a)=>e(a,t[o],t[d],l(ht(a),`'${a}'`),mt(a,1))))],Et=(e,l,a,n)=>[(n,o)=>{const d=n+": "+o,s=e($,wt(...l((e=>`'${e}'?: {[rowId: Id]: `+wt(...a(e,((e,l,a)=>`'${e}'${j(a)?"?":t}: ${l}`)))+"}"))),Je(1,5)),I=e($+Ee,wt(...l((e=>`'${e}'?: {[rowId: Id]: `+wt(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Je(1,5,1)),c=e(i+de,"keyof "+s,"A "+i+" Id in "+Te),g=`<TId extends ${c}>`,f=e(i,$e+`<${s}[TId]>`,"A "+i+" in "+Te,g),w=e(i+Ee,$e+`<${I}[TId]>`,"A "+i+" in "+Te+De,g),y=e(b,f+"<TId>[Id]","A "+b+" in a "+i,g),T=e(b+Ee,w+"<TId>[Id]","A "+b+" in a "+i+De,g),v=e(m+de,`Extract<keyof ${y}<TId>, Id>`,"A "+m+" Id in a "+b,g),V=e(m,$e+`<${s}[TId]>[Id][CId]`,"A "+m+" in a "+b,`<TId extends ${c}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,m+" Ids and types in a "+b,`<TId extends ${c}, CId = ${v}<TId>>`,0),R=e(m+te,`(...[cellId, cell]: ${x}<TId>)`+Pe,_e(Y+m+" Id, and "+m),g),S=e(b+te,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Pe+") "+Pe,_e(Y+b+" Id, and a "+m+" iterator"),g),k=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${S}<TId>)${Pe}] : never`,i+" Ids and callback types",`<TId = ${c}>`,0),A=e(i+te,`(...[tableId, forEachRow]: ${k})`+Pe,_e(Y+i+" Id, and a "+b+" iterator"),t),P=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${P}) => CellChange`,ee+" returning information about any Cell's changes during a "+Ve),D=e($+r,`(${d}, getCellChange: ${E}${ie})`+Pe,Ue(1)),N=e(u+r,`(${d})`+Pe,Ue(2)),O=e(i+r,`(${d}, tableId: ${c}, getCellChange: ${E}${ie})`+Pe,Ue(3)),L=e(p+r,`(${d}, tableId: ${c})`+Pe,Ue(4,3)),M=e(C+r,"("+ft(d,"tableId: "+c,"cellId: Id"+ie,"descending: boolean","offset: number","limit: number"+ie,"sortedRowIds: Ids")+")"+Pe,Ue(13,3)),G=e(b+r,"("+ft(""+d,"tableId: "+c,Ce,`getCellChange: ${E}${ie}`)+")"+Pe,Ue(5,3)),J=e(h+r,"("+ft(""+d,"tableId: "+c,Ce)+")"+Pe,Ue(6,5)),z=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Ce}, cellId: CId, newCell: ${V}<TId, CId> ${ie}, oldCell: ${V}<TId, CId> ${ie}, getCellChange: ${E} ${ie}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${v}<TId>>`,0),W=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+z+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[s,I,c,f,w,y,T,v,V,R,S,A,D,N,O,L,M,G,J,e(m+r,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${W})`+Pe,Ue(7,5)),e(se+m+r,`(${d}, tableId: Id, ${Ce}, cellId: Id, invalidCells: any[])`+Pe,Ue(8))]},(l,a)=>{const o=l+": "+a,d=e(f,wt(...n(((e,l,a)=>`'${e}'${j(a)?"?":t}: ${l}`))),Je(2,5)),s=e(f+Ee,wt(...n(((e,t)=>`'${e}'?: ${t}`))),Je(2,5,1)),I=e(g+de,"keyof "+d,"A "+g+" Id in "+Te),c=e(g,$e+`<${d}[VId]>`,"A "+g+" Id in "+Te,`<VId extends ${I}>`),i=e("ValueIdValueArray",`VId extends ${I} ? [valueId: VId, value: ${c}<VId>] : never`,g+" Ids and types in "+Te,`<VId = ${I}>`,0),$=e(g+te,`(...[valueId, value]: ${i})`+Pe,_e(Y+g+" Id, and "+g)),u=e("GetValueChange",`(valueId: ${I}) => ValueChange`,ee+" returning information about any Value's changes during a "+Ve),b=e(f+r,`(${o}, getValueChange: ${u}${ie})`+Pe,Ue(9)),p=e(w+r,`(${o})`+Pe,Ue(10)),C=e("ValueListenerArgsArray",`VId extends ${I} ? [${o}, valueId: VId, newValue: ${c}<VId> ${ie}, oldValue: ${c}<VId> ${ie}, getValueChange: ${u} ${ie}] : never`,"Value args for ValueListener",`<VId = ${I}>`,0);return[d,s,I,c,$,b,p,e(g+r,`(...[${l}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Pe,Ue(11)),e(se+g+r,`(${o}, valueId: Id, invalidValues: any[])`+Pe,Ue(12))]},(t,l)=>e(ve+r,`(${t}: ${l}, cellsTouched: boolean, valuesTouched: boolean)`+Pe,ee+" listening to the completion of a "+Ve)],Dt=(e,l=t,a=t)=>`store.${e}(${l})`+(a?" as "+a:t),Nt=(e,l=t)=>`fluent(() => ${Dt(e,l)})`,Ot=(e,l=t,a=t)=>`store.${e}(${l?l+", ":t}proxy(listener)${a?", "+a:t})`,jt=(e,l,n)=>{const[s,y,T,V,x,R,S,A]=Tt(),[E,D,N]=Pt(e,l,x),[O,L,G]=Et(T,E,D,N),J=_(),z=(e=0)=>H(J,(([l,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${l}): ${a} => ${n},`]:[r+d+`(${l}): ${a};`];return e||P(s,gt(o)),k(s,t),s})),F=(e,l,a,n,o,d=t)=>$t(J,e,[l,a,n,o,d]),B=(e,l,a,n,o,d=t,r=t,s=t)=>F(lt[e]+l+(4==e?ue:t)+a,d,n,(n==X?Nt:Dt)(lt[e]+(4==e?ue:t)+a,r,e?void 0:n),o,s),q=(e,l,a,n=t,o=t,d=1,s=t)=>F(I+e+r,(n?n+", ":t)+ce+": "+l+(d?", mutator?: boolean":t),de,Ot(I+e+r,o,d?"mutator":t),a,s),K=`./${mt(n)}.d`,X=mt(n,1),Y=mt(X),ee=[],le=_();let re=[],$e=[];if(y(1,K,X,`create${X} as create${X}Decl`),!kt(e)){y(0,"tinybase","CellChange"),y(null,"tinybase",c);const[e,l,n,r,s,I,g,f,w,V,R,S,A,P,N,L,G,J,z,F,Z]=O(Y,X),H=_();E(((e,t)=>{const l=`<'${e}'>`,a=[T(t+i,r+l,pe+` the '${e}' `+i),T(t+i+Ee,s+l,pe+` the '${e}' `+i+De),T(t+b,I+l,ze(e)),T(t+b+Ee,g+l,ze(e,1)),T(t+m+de,f+l,`A Cell Id for the '${e}' `+i),T(t+m+te,V+l,_e(`a Cell Id and value from a Row in the '${e}' `+i)),T(t+b+te,R+l,_e(`a Row Id from the '${e}' Table, and a Cell iterator`))];Q(H,e,a),y(1,K,...a)})),y(1,K,e,l,n,f,S,A,P,N,L,G,J,z,F,Z),re=[e,l,n,f,A,P,N,L,G,J,z,F,H],v([[e],[a],[X,"tables: "+l,"tables"],[X]],(([e,l,a],n)=>B(n,t,$,e,Je(1,n),l,a))),B(0,t,u,n+we,We(i,Te)),B(5,t,i,Ae,Fe(i,Te),"tableCallback: "+S,"tableCallback as any"),E(((e,l,n)=>{const[o,d,r,s,I,$,u]=U(H,e);v([[o],[a],[X,"table: "+d,", table"],[X]],(([a,o,d=t],r)=>B(r,l,i,a,Ke(e,r),o,n+d))),B(0,l,p,c,We(b,He(e)),t,n),B(0,l,C,c,We(b,He(e),1),"cellId?: "+I+fe,n+", cellId, descending, offset, limit"),B(5,l,b,Ae,Fe(b,He(e)),"rowCallback: "+u,n+", rowCallback as any"),v([[r],[a],[X,", row: "+s,", row"],[X],[X,", partialRow: "+s,", partialRow"]],(([a,o=t,d=t],r)=>B(r,l,b,a,Xe(e,r),Ce+o,n+", rowId"+d))),B(6,l,b,de+ie,"Add a new Row to "+He(e),"row: "+s,n+", row"),B(0,l,h,I+we,We(m,Qe(e)),Ce,n+", rowId"),B(5,l,m,Ae,Fe(m,Qe(e)),Ce+", cellCallback: "+$,n+", rowId, cellCallback as any"),D(e,((o,d,r,s,I)=>{const c="Map"+mt(d,1);Q(le,d,c);const i=d+(j(r)?ie:t);v([[i],[a],[X,`, cell: ${d} | `+c,", cell as any"],[X]],(([a,d=t,r=t],c)=>B(c,l+I,m,a,Ye(e,o,c),Ce+d,n+", rowId, "+s+r)))}))})),B(0,t,$+Ie,Ie,Je(1,6)),B(2,t,$+Ie,X,Je(1,7),"tablesJson: "+Ie,"tables"+Ie),q($,A,Je(1,8)+" changes"),q(u,P,Ze(2,0,1)),q(i,N,Ze(3,0),`tableId: ${n} | null`,"tableId"),q(p,L,Ze(4,3,1),`tableId: ${n} | null`,"tableId"),q(C,G,Ze(13,3,1),ft("tableId: TId",`cellId: ${f}<TId>`+ie,"descending: boolean","offset: number","limit: number"+ie),ft("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),q(b,J,Ze(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),q(h,z,Ze(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),q(m,F,Ze(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${pt(E((e=>U(H,e)?.[4]??t))," | ")} | null`,"tableId, rowId, cellId"),q(se+m,Z,be+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),y(1,K,...W(le)),k(ee,".set"+$+he+"({",Ct(E(((e,l,a)=>[`[${a}]: {`,...D(e,((e,l,a,n)=>`[${n}]: {[${x(ht(o),`'${o}'`)}]: ${x(ht(l),`'${l}'`)}${j(a)?t:`, [${x(ht(d),`'${d}'`)}]: `+(M(a)?x(ht(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!kt(l)){const[e,l,n,r,s,I,c,i,$]=L(Y,X);y(1,K,e,l,n,s,I,c,i,$),$e=[e,l,n,I,c,i],v([[e],[a],[X,"values: "+l,"values"],[X],[X,"partialValues: "+l,"partialValues"]],(([e,l,a],n)=>B(n,t,f,e,Je(2,n),l,a))),B(0,t,w,n+we,We(g,Te)),B(5,t,g,"void",Fe(g,Te),"valueCallback: "+s,"valueCallback as any"),N(((e,l,n,o,d)=>{const r="Map"+mt(l,1);Q(le,l,r),v([[l],[a],[X,`value: ${l} | `+r,", value as any"],[X]],(([l,a,n=t],r)=>B(r,d,g,l,et(e,r),a,o+n)))})),B(0,t,f+Ie,Ie,Je(2,6)),B(2,t,f+Ie,X,Je(2,7),"valuesJson: "+Ie,"values"+Ie),q(f,I,Je(2,8)+" changes"),q(w,c,Ze(10,0,1)),q(g,i,Ze(11,0),`valueId: ${n} | null`,"valueId"),q(se+g,$,be+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),y(1,K,...W(le)),y(0,"tinybase","ValueChange"),k(ee,".set"+f+he+"({",N(((e,l,a,n)=>[`[${n}]: {[${x(ht(o),`'${o}'`)}]: ${x(ht(l),`'${l}'`)}${j(a)?t:`, [${x(ht(d),`'${d}'`)}]: `+(M(a)?x(ht(a),`'${a}'`):a)}},`])),"})")}Z(le,((e,t)=>T(t,`(cell: ${e}${ie}) => `+e,`Takes a ${e} Cell value and returns another`))),y(null,"tinybase","DoRollback",de,"IdOrNull",Ie,"Store"),B(0,t,Ie,Ie,Je(0,6)),B(2,t,Ie,X,Je(0,7),"tablesAndValuesJson: "+Ie,"tablesAndValuesJson"),B(7,t,Ve,"Return",xe,ne,"actions, doRollback","<Return>"),B(7,t,"start"+ve,X,Re),B(7,t,"finish"+ve,X,Se,ae,"doRollback");const me=G(Y,X);return q("WillFinish"+ve,me,be+" just before "+ke,t,t,0),q("DidFinish"+ve,me,be+" just after "+ke,t,t,0),B(7,t,"call"+r,X,"Manually provoke a listener to be called","listenerId: Id","listenerId"),B(3,t,r,X,"Remove a listener that was previously added to "+Te,"listenerId: Id","listenerId"),F("getStore",t,"Store","store",tt[0]+" the underlying Store object"),y(1,"tinybase","createStore"),y(1,K,X,`create${X} as create${X}Decl`,me),x("store",["createStore()",...ee]),V("fluent","actions: () => Store",["actions();",`return ${Y};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Y}, ...params)`),x(Y,["{",...z(1),"}"]),[s(...R(0),...S(),oe+" interface "+X+" {",...z(0),"}",t,gt(`Creates a ${X} object`),oe+" function create"+X+"(): "+X+";"),s(...R(1),oe+" const create"+X+": typeof create"+X+"Decl = () => {",...A(),`return Object.freeze(${Y});`,"};"),re,$e]},Lt="Deps",Mt=e=>s+e,Gt=e=>ft(Mt(e),Mt(e)+Lt),Jt="debugIds?: boolean",zt="debugIds={debugIds}",Wt=Lt+"?: React.DependencyList",Ft="then"+Wt,Bt="Parameter",_t=": (parameter: "+Bt+", store: Store) => ",Ut="Provider",Zt="const contextValue = useContext(Context);",Ht=", and registers a listener so that any changes to that result will cause a re-render",Qt=", based on a parameter",qt=": ",Kt="?: ",Xt="<"+Bt+",>",Yt=Bt+"ized"+te+"<"+Bt+">",el="Props",tl="rowId",ll="rowId={rowId}",al=", separator, debugIds",nl="separator?: ReactElement | string",ol="then?: (store: Store",dl=ft(ol+")"+Pe,Ft),rl="then, then"+Lt,sl=tl+qt+de,Il="View",cl=(e,...t)=>ft(...t,ce+": "+e,ce+Wt,"mutator?: boolean"),il=(...e)=>ft(...e,ce,ce+Lt,"mutator"),$l=(e,l,a,n,o)=>{const[d,s,I,y,T,v,V,x]=Tt(),[R,S,A]=Pt(e,l,T),E=`./${mt(a)}.d`,D=`./${mt(a)}-ui-react.d`,N="tinybase/ui-react",O=mt(a,1),L=mt(O),M=O+"Or"+O+de,G=L+"Or"+O+de,J=L+`={${L}}`,z=_(),W=(e,l,a,n,o,d=t)=>(s(1,D,e+" as "+e+"Decl"),$t(z,e,[l,a,n,o,d])),F=(e,l,a,n,o,d=t)=>W("use"+e,l,a,n,o,d),B=(e,l,a,n,o=t,d=t,r=t,I=t,c=t)=>(s(1,N,`use${l} as use${l}Core`),F(e,ft(o,X,I),a,ae+`(${G}, use${l}Core, [`+(d||t)+(c?"], ["+c:t)+"]);",n,r)),Z=(e,t,l,a)=>W(e,t,1,l,a),Q=(e=0)=>H(z,(([l,a,n,o,d],r)=>{const s=e?[oe+` const ${r}: typeof ${r}Decl = ${d}(${l}): ${1==a?"any":a} =>`,n]:[oe+` function ${r}${d}(${l}): ${1==a?"ComponentReturnType":a};`];return e||P(s,gt(o)),k(s,t),s}));s(null,"tinybase",de,"Store",te,Bt+"ized"+te),s(0,N,"ComponentReturnType"),s(null,N,"ExtraProps"),s(0,E,O);const q=I(M,O+" | "+de,`Used when you need to refer to a ${O} in a React hook or component`),K=I(Ut+el,yt(L+Kt+O,L+`ById?: {[${L}Id: Id]: ${O}}`),`Used with the ${Ut} component, so that a `+O+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,D,q,K);const X=G+Kt+q;T("{createContext, useContext, useMemo}","React"),T("Context",`createContext<[${O}?, {[${L}Id: Id]: ${O}}?]>([])`),F("Create"+O,`create: () => ${O}, create`+Wt,O,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${O} within a React application with convenient memoization`);const ee=F(O,"id?: Id",O+ie,["{",Zt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${O} from within a ${Ut} component context`),ae=y("useHook",G+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${L} = ${ee}(${G} as Id);`,`return hook(...preParams, ((${G} == null || typeof ${G} == 'string')`,`? ${L} : ${G})?.getStore(), ...postParams)`]),ne=y("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),re=y("wrap",ft("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=T("NullComponent","() => null");if(!kt(e)){const[e,l,a,o,d,g,f,w,T,v,V,x,k]=n;s(null,E,e,l,a,d,g,f,w,T,v,V,x),s(0,E,o),s(1,E,O),s(null,"tinybase",c,"IdOrNull");const A=y("tableView",`{${L}, rowComponent, getRowComponentProps`+al+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${re}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",ll,J,zt,"/>","))",al,", tableId,",");"]),P=y("getDefaultTableComponent","tableId: Id",pt(R(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+se),N=y("getDefaultCellComponent","tableId: Id, cellId: Id",pt(R(((e,t,l)=>`tableId == ${l} ? ${pt(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+se} : `)))+se);B($,$,e,Je(1,0)+Ht);const M=B(u,u,a+we,We(i,Te)+Ht);B(ge+$+te,ge+$+te,Yt,Je(1,9)+Qt,ft(Mt($)+_t+l,Mt($)+Wt),Gt($),Xt,ft(ol,`tables: ${l})`+Pe,Ft),rl),B(le+$+te,le+$+te,te,Je(1,12),t,t,t,dl,rl);const G=I(m+el,yt("tableId?: TId","rowId: Id","cellId?: CId",L+Kt+O,Jt),Be(Y+m),`<TId extends ${a}, CId extends ${o}<TId>>`),z=I(b+el,yt("tableId?: TId","rowId: Id",L+Kt+O,"cellComponents?: {readonly [CId in "+o+`<TId>]?: ComponentType<${G}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${o}<TId>) => ExtraProps`,nl,Jt),Be(Y+b),`<TId extends ${a}>`),W=I(i+el,yt("tableId?: TId",L+Kt+O,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",nl,Jt),Be(Y+i),`<TId extends ${a}>`),F=I("Sorted"+i+el,yt("tableId?: TId","cellId?: "+o+"<TId>","descending?: boolean","offset?: number","limit?: number",L+Kt+O,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",nl,Jt),Be(Y+"sorted "+i),`<TId extends ${a}>`),_=I($+el,yt(L+Kt+O,"tableComponents?: {readonly [TId in "+a+`]?: ComponentType<${W}<TId>>;}`,`getTableComponentProps?: (tableId: ${a}) => ExtraProps`,nl,Jt),Be(Ge(1,1)));s(1,D,_,W,F,z,G),Z($+Il,"{"+L+", tableComponents, getTableComponentProps"+al+"}: "+_,[re+`(${M}(${L}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+P+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",J,zt,"/>;","}), separator)"],Je(1,13)+Ht),R(((e,l,a)=>{const[n,o,d,r,I]=U(k,e);s(null,E,n,o,d,r,I),B(l+i,i,n,Ke(e)+Ht,t,a);const $=B(l+p,p,c,We(b,He(e))+Ht,t,a),u=B(l+C,C,c,We(b,He(e),1)+Ht,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");B(l+b,b,d,Xe(e)+Ht,sl,ft(a,tl));const g=B(l+h,h,I+we,We(m,Qe(e))+Ht,sl,ft(a,tl));B(ge+l+i+te,ge+i+te,Yt,Ke(e,9)+Qt,ft(Mt(i)+_t+o,Mt(i)+Wt),ft(a,Gt(i)),Xt,ft(ol,`table: ${o})`+Pe,Ft),rl),B(le+l+i+te,le+i+te,te,Ke(e,12),t,a,t,dl,rl),B(ge+l+b+te,ge+b+te,Yt,Xe(e,9)+Qt,ft(sl,Mt(b)+_t+r,Mt(b)+Wt),ft(a,tl,Gt(b)),Xt,ft(ol,`row: ${r})`+Pe,Ft),rl),B("Add"+l+b+te,"Add"+b+te,Yt,Xe(e,10)+Qt,ft(Mt(b)+_t+r,Mt(b)+Wt),ft(a,Gt(b)),Xt,"then?: ("+ft(sl+ie,"store: Store","row: "+r+")"+Pe,"then"+Wt),rl),B(ge+l+ue+b+te,ge+ue+b+te,Yt,Xe(e,11)+Qt,ft(sl,Mt(ue+b)+_t+r,Mt(ue+b)+Wt),ft(a,tl,Gt(ue+b)),Xt,ft(ol,`partialRow: ${r})`+Pe,Ft),rl),B(le+l+b+te,le+b+te,te,Xe(e,12),sl,ft(a,tl),t,dl,rl);const f=Z(l+b+Il,"{rowId, "+L+", cellComponents, getCellComponentProps"+al+`}: ${z}<'${e}'>`,[re+`(${g}(rowId, ${L}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+N+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,ll,"cellId={cellId}",J,zt,"/>;","})"+al+", rowId)"],Xe(e,13)+Ht);Z(l+"Sorted"+i+Il,"{cellId, descending, offset, limit, ...props}: "+F+`<'${e}'>`,A+"(props, "+u+`(cellId, descending, offset, limit, props.${L}), ${a}, ${f});`,Ke(e,13)+", sorted"+Ht),Z(l+i+Il,`props: ${W}<'${e}'>`,A+"(props, "+$+`(props.${L}), ${a}, ${f});`,Ke(e,13)+Ht),S(e,((n,o,d,r,I)=>{const c="Map"+mt(o,1);s(0,E,c),s(1,E,c);const i=B(l+I+m,m,o+(j(d)?ie:t),Ye(e,n)+Ht,sl,ft(a,tl,r));B(ge+l+I+m+te,ge+m+te,Yt,Ye(e,n,9)+Qt,ft(sl,Mt(m)+_t+o+" | "+c,Mt(m)+Wt),ft(a,tl,r,Gt(m)),Xt,ft(ol,`cell: ${o} | ${c})`+Pe,Ft),rl),B(le+l+I+m+te,le+m+te,te,Ye(e,n,12),ft(sl,"forceDel?: boolean"),ft(a,tl,r,"forceDel"),t,dl,rl),Z(l+I+m+Il,`{rowId, ${L}, debugIds}: `+G+`<'${e}', '${n}'>`,[re+`('' + ${i}(rowId, `+L+`) ?? '', undefined, debugIds, ${r})`],Ye(e,n,13)+Ht)}))}));const H=pt(R((e=>U(k,e)?.[4]??t))," | ");B($+r,$+r,Ae,Je(1,8)+" changes",cl(d),il()),B(u+r,u+r,Ae,Ze(2,0,1),cl(g),il()),B(i+r,i+r,Ae,Ze(3,0),cl(f,`tableId: ${a} | null`),il("tableId")),B(p+r,p+r,Ae,Ze(4,3,1),cl(w,`tableId: ${a} | null`),il("tableId")),B(C+r,C+r,Ae,Ze(13,3,1),cl(T,`tableId: ${a} | null`,"cellId: "+H+ie,"descending: boolean","offset: number","limit: number"+ie),il("tableId","cellId","descending","offset","limit")),B(b+r,b+r,Ae,Ze(5,3),cl(v,`tableId: ${a} | null`,tl+": IdOrNull"),il("tableId",tl)),B(h+r,h+r,Ae,Ze(6,5,1),cl(V,`tableId: ${a} | null`,tl+": IdOrNull"),il("tableId",tl)),B(m+r,m+r,Ae,Ze(7,5),cl(x,`tableId: ${a} | null`,tl+": IdOrNull",`cellId: ${H} | null`),il("tableId",tl,"cellId"))}if(!kt(l)){const[e,l,a,n,d,c]=o;s(null,E,...o),s(1,E,O);const i=y("getDefaultValueComponent","valueId: Id",pt(A(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+se);B(f,f,e,Je(2,0)+Ht);const $=B(w,w,a+we,We(g,Te)+Ht);B(ge+f+te,ge+f+te,Yt,Je(2,9)+Qt,ft(Mt(f)+_t+l,Mt(f)+Wt),Gt(f),Xt,ft(ol,`values: ${l})`+Pe,Ft),rl),B(ge+ue+f+te,ge+ue+f+te,Yt,Je(2,11)+Qt,ft(Mt(ue+f)+_t+l,Mt(ue+f)+Wt),Gt(ue+f),Xt,ft(ol,`partialValues: ${l})`+Pe,Ft),rl),B(le+f+te,le+f+te,te,Je(2,12),t,t,t,dl,rl);const u=I(g+el,yt("valueId?: VId",L+Kt+O,Jt),Be("a Value"),`<VId extends ${a}>`),b=I(f+el,yt(L+Kt+O,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${u}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,nl,Jt),Be(Ge(2,1)));s(1,D,b,u),Z(f+Il,"{"+L+", valueComponents, getValueComponentProps"+al+"}: "+b,[re+`(${$}(${L}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",J,zt,"/>;","}), separator)"],Je(2,13)+Ht),A(((e,l,a,n,o)=>{const d="Map"+mt(l,1);s(0,E,d),s(1,E,d);const r=B(o+g,g,l,et(e)+Ht,t,n);B(ge+o+g+te,ge+g+te,Yt,et(e,9)+Qt,ft(Mt(g)+_t+l+" | "+d,Mt(g)+Wt),ft(n,Gt(g)),Xt,ft(ol,`value: ${l} | ${d})`+Pe,Ft),rl),B(le+o+g+te,le+g+te,te,et(e,12),t,n,t,dl,rl),Z(o+g+Il,`{${L}, debugIds}: ${u}<'${e}'>`,[re+`('' + ${r}(`+L+`) ?? '', undefined, debugIds, ${n})`],et(e,13)+Ht)})),B(f+r,f+r,Ae,Je(2,8)+" changes",cl(n),il()),B(w+r,w+r,Ae,Ze(10,0,1),cl(d),il()),B(g+r,g+r,Ae,Ze(11,0),cl(c,`valueId: ${a} | null`),il("valueId"))}return Z(Ut,`{${L}, ${L}ById, children}: `+K+" & {children: React.ReactNode}",["{",Zt,"return (","<Context."+Ut,"value={useMemo(",`() => [${L} ?? contextValue[0], {...contextValue[1], ...${L}ById}],`,`[${L}, ${L}ById, contextValue],`,")}>","{children}",`</Context.${Ut}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[d(...v(0),...V(),...Q(0)),d(...v(1),...x(),...Q(1))]},ul=(e,l,a)=>{if(kt(e)&&kt(l))return[t,t,t,t];const[n,o,d,r]=jt(e,l,a);return[n,o,...$l(e,l,a,d,r)]},bl=". Note that this may contradict the generated type refinements",pl=(e,l,n)=>{const[o,d,y,T,V,x,R,S]=Tt(),[A,P,E]=Pt(e,l,(()=>t)),[D,N,O]=Et(y,A,P,E),j=_(),L=()=>H(j,(([e,l,a,n],o)=>[gt(a),o+n+`(${ft(...e)}): ${l};`,t])),M=(e,l,a,n,o=t)=>$t(j,e,[G(l)?l:[l],a,n,o]);let J;d(0,"tinybase",de,c,re,"StoreListenerStats",Ie,$+he,f+he,"DoRollback"),kt(e)?(J=[$,$,de,i,i,b,b,de,m,m+te,b+te,i+te,$+r,u+r,i+r,p+r,C+r,b+r,h+r,m+r,se+m+r],d(0,"tinybase",...J),k(J,de,re,de,t,de,t)):(d(0,"tinybase","CellChange"),J=D("store",ye),v([3,4,5,6,7,9,10],(e=>J[e]+="<TId>")),J[8]+="<TId, CId>",k(J,"TId","TId | null",pt(A((e=>`CellId<'${e}'>`))," | "),`<TId extends ${J[2]}>`,"CId",`<TId extends ${J[2]}, CId extends ${J[7]}>`));const[z,W,F,B,U,Z,Q,q,K,X,ee,le,oe,$e,pe,ge,Pe,Ee,De,Ne,Oe,je,Le,Me,Ge,ze,Be]=J,_e="tableId: "+je,Ue=ft(_e,Ce),He=ft(Ue,"cellId: "+ze),Qe="tableId: "+Le,Ke=ft(Qe,me),Xe=ft(Ke,"cellId: "+Me);let Ye;v([[z],[a],[ye,"tables: "+W],[ye]],(([e,l],a)=>M(lt[a]+$,l??t,e,Je(1,a)))),M(s+u,t,F+we,We(i,Te)),M(lt[5]+i,"tableCallback: "+le,Ae,Fe(i,Te)),v([[B,_e],[a,_e],[ye,[_e,"table: "+U]],[ye,_e]],(([e,l],a)=>M(lt[a]+i,l??t,e,qe(a,3),Ge))),M(s+p,_e,c,We(b,Y+i),Ge),M(s+C,[_e,"cellId?: "+q+fe],c,We(b,Y+i),Ge),M(lt[5]+b,[_e,"rowCallback: "+ee],Ae,Fe(b,Y+i),Ge),v([[Z,Ue],[a,Ue],[ye,[Ue,"row: "+Q]],[ye,Ue]],(([e,l],a)=>M(lt[a]+b,l??t,e,qe(a,5),Ge))),M("set"+ue+b,[_e,Ce,"partialRow: "+Q],ye,qe(4,5),Ge),M(I+b,[_e,"row: "+Q],de+ie,"Add a new "+b,Ge),M(s+h,[_e,Ce],q+we,We(m,Y+b),Ge),M(lt[5]+m,[_e,Ce,"cellCallback: "+X],Ae,Fe(m,Y+b),Ge),v([[K,He],[a,He],[ye,[He,"cell: "+K]],[ye,He]],(([e,l],a)=>M(lt[a]+m,l??t,e,qe(a,7),Be))),M(I+$+r,[ce+": "+oe,"mutator?: boolean"],de,Je(1,8)+" changes"),M(I+u+r,[ce+": "+$e,"mutator?: boolean"],de,Ze(2,0,1)),M(I+i+r,[Qe,ce+": "+pe,"mutator?: boolean"],de,Ze(3,0),Ge),M(I+p+r,[Qe,ce+": "+ge,"mutator?: boolean"],de,Ze(4,3,1),Ge),M(I+C+r,[_e,"cellId: "+q+ie,"descending: boolean","offset: number","limit: number"+ie,ce+": "+Pe,"mutator?: boolean"],de,Ze(13,3,1),Ge),M(I+b+r,[Ke,ce+": "+Ee,"mutator?: boolean"],de,Ze(5,3),Ge),M(I+h+r,[Ke,ce+": "+De,"mutator?: boolean"],de,Ze(6,5,1),Ge),M(I+m+r,[Xe,ce+": "+Ne,"mutator?: boolean"],de,Ze(7,5),Ge),M(I+se+m+r,["tableId: "+re,"rowId: "+re,"cellId: "+re,ce+": "+Oe,"mutator?: boolean"],de,be+" whenever an invalid Cell change was attempted"),kt(l)?(Ye=[f,f,de,g,g+te,f+r,w+r,g+r,se+g+r],d(0,"tinybase",...Ye),k(Ye,de,re,t)):(d(0,"tinybase","ValueChange"),Ye=N("store",ye),Ye[3]+="<VId>",k(Ye,"VId","VId | null",`<VId extends ${Ye[2]}>`));const[et,tt,at,nt,ot,dt,rt,st,It,ct,it,ut]=Ye,bt="valueId: "+ct;v([[et],[a],[ye,"values: "+tt],[ye]],(([e,l],a)=>M(lt[a]+f,l??t,e,Je(2,a)))),M("set"+ue+f,"partialValues: "+tt,ye,Je(2,4)),M(s+w,t,at+we,We(g,Te)),M(lt[5]+g,"valueCallback: "+ot,Ae,Fe(g,Te)),v([[nt,bt],[a,bt],[ye,[bt,"value: "+nt]],[ye,bt]],(([e,l],a)=>M(lt[a]+g,l??t,e,qe(a,11),ut))),M(I+f+r,[ce+": "+dt,"mutator?: boolean"],de,Je(2,8)+" changes"),M(I+w+r,[ce+": "+rt,"mutator?: boolean"],de,Ze(10,0,1)),M(I+g+r,["valueId: "+it,ce+": "+st,"mutator?: boolean"],de,Ze(11,0),ut),M(I+se+g+r,["valueId: "+re,ce+": "+It,"mutator?: boolean"],de,be+" whenever an invalid Value change was attempted"),v([[t,"tablesAndValues"],[$,"tables"],[f,"values"]],(([e,l],a)=>{M(s+e+Ie,t,Ie,Je(a,6)),M("set"+e+Ie,l+Ie+": "+Ie,ye,Je(a,7)),M(s+e+he+Ie,t,Ie,Je(a,14)),e&&M("set"+e+he,l+he+": "+e+he,ye,Je(a,15)+bl),M("del"+e+he,t,ye,Je(a,16))})),M("set"+he,[`tables${he}: `+$+he,`values${he}?: `+f+he],ye,Je(0,15)+bl),M(Ve,ne,"Return",xe,"<Return>"),M("start"+ve,t,ye,Re),M("finish"+ve,ae,ye,Se);const Ct=O("store",ye);return M(I+"WillFinish"+ve+r,ce+": "+Ct,de,be+" just before "+ke),M(I+"DidFinish"+ve+r,ce+": "+Ct,de,be+" just after "+ke),M("call"+r,"listenerId: Id",ye,"Manually provoke a listener to be called"),M("del"+r,"listenerId: Id",ye,"Remove a listener that was previously added to "+Te),M(s+r+"Stats",t,"StoreListenerStats","Get listener statistics"),[o("export * from 'tinybase';",...x(0),...R(),"export interface Store {",...L(),"}",t,gt("Creates a Store object"),"export function createStore(): Store")]},Cl=(e,t,l)=>["export * from 'tinybase/ui-react';"],ml=(e,l,a)=>{if(kt(e)&&kt(l))return[t,t];const[n]=pl(e,l);return[n,...Cl()]},hl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},gl=async()=>{try{return(await import("prettier")).format}catch(e){return e=>e}},fl=At((e=>{const t=()=>{const t=D(e.getTablesSchemaJson());return!kt(t)||y(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=_();if(y(a,(t=>y(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=q(n,a,(()=>[J(o),_(),[0],0])),[r,s,[I]]=d,c=q(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),Q(s,o,c),d[3]++,r==J(o)})))))return t[l]={},F(n,(([e,,[,n],r],s)=>{t[l][s]={[o]:e,...r==x(a)?{[d]:n}:{}}})),1}))?t:{}},l=()=>{const t=D(e.getValuesSchemaJson());return kt(t)&&e.forEachValue(((e,l)=>{t[e]={[o]:J(l)}})),t},a=e=>ul(t(),l(),e),n=async e=>{const t=["d.ts","ts","d.ts","tsx"],l=await gl();return V(a(e),((e,a)=>ut(l(e,{...hl,filepath:"_."+t[a]}))))},r=e=>ml(t(),l()),s=async e=>{const t=await gl();return V(r(),(e=>ut(t(e,{...hl,filepath:"_.d.ts"}))))};return xt({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})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:x(e.getValueIds()),jsonLength:bt(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStoreRefinement:r,getPrettyStoreRefinement:s,getStore:()=>e})}));exports.createTools=fl;
|
|
1
|
+
"use strict";const e=e=>typeof e,t="",l=e(t),a=e(!0),n=e(0),o="type",d="default",r="Listener",s="get",I="add",$="Ids",c="Table",i=c+"s",u=c+$,p="Row",b=p+$,C="Sorted"+p+$,h="Cell",g=h+$,m="Value",f=m+"s",w=m+$,y=(e,t)=>e.every(t),T=(e,t)=>e.sort(t),v=(e,t)=>e.forEach(t),V=(e,t)=>e.map(t),x=e=>e.length,R=e=>0==x(e),k=(e,t)=>e.filter(t),S=(e,...t)=>e.push(...t),P=e=>e.pop(),A=(e,...t)=>e.unshift(...t),E=e=>e.shift(),D=JSON.parse,O=isFinite,N=(e,t)=>e instanceof t,L=e=>null==e,j=e=>e==l||e==a,M=t=>e(t)==l,G=e=>Array.isArray(e),J=t=>{const l=e(t);return j(l)||l==n&&O(t)?l:void 0},z=(e,t)=>e?.has(t)??!1,W=e=>[...e?.values()??[]],B=(e,t)=>e?.forEach(t),F=(e,t)=>e?.delete(t),U=e=>new Map(e),_=(e,t)=>e?.get(t),Z=(e,t)=>B(e,((e,l)=>t(l,e))),H=(e,t)=>V([...e?.entries()??[]],(([e,l])=>t(l,e))),Q=(e,t,l)=>L(l)?(F(e,t),e):e?.set(t,l),q=(e,t,l)=>(z(e,t)||Q(e,t,l()),_(e,t)),K=e=>e.toUpperCase(),X=e=>e.toLowerCase(),Y="a ",ee="A function for",te=", and registers a listener so that any changes to that result will cause a re-render",le="Callback",ae="Del",ne="Deps",oe=ne+"?: React.DependencyList",de="doRollback?: DoRollback",re="actions: () => Return, "+de,se="export",Ie="Id",$e="Invalid",ce="Json",ie=X(r),ue="?: ",pe=" | undefined",be="NonNullable",Ce="Partial",he="Props",ge="Provider",me=`Registers a ${ie} that will be called`,fe="Represents",we="rowId: "+Ie,ye="Schema",Te="Set",ve=", descending?: boolean, offset?: number, limit?: number",Ve="[]",xe="the Store",Re="Transaction",ke=X(Re),Se="Execute a "+ke+" to make multiple mutations",Pe="Explicitly starts a "+ke,Ae="Explicitly finishes a "+ke,Ee="the end of the "+ke,De="void",Oe=" => "+De,Ne="WhenSet",Le=" when setting it",je=Y+"string serialization of",Me=" ",Ge="Gets a callback that can ",Je="the ",ze=" the schema for",We=(e=0,l=0)=>`the ${dt[e]}content of`+(l?Me+xe:t),Be=(e=0,l,a=0)=>at[l]+Me+We(e,1)+(a?" when setting it":t),Fe=(e,t=0)=>fe+` a Row when ${t?"s":"g"}etting ${We()} the '${e}' `+c,Ue=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,_e=(e,t)=>`Calls a function for each ${e} in `+t,Ze=e=>"The props passed to a component that renders "+e,He=e=>"A function that takes "+e,Qe=(e,t=0)=>ee+" listening to changes to "+ot[e]+" in "+ot[t],qe=(e,l,a=0)=>me+" whenever "+ot[e]+" in "+ot[l]+" change"+(a?t:"s"),Ke=e=>`the '${e}' `+c,Xe=e=>"the specified Row in "+Ke(e),Ye=(e,t=0)=>at[t]+` ${We()} `+Ke(e),et=(e,t=0)=>at[t]+` ${We()} `+Xe(e),tt=(e,t,l=0)=>at[l]+` the '${t}' Cell for `+Xe(e),lt=(e,t=0)=>at[t]+` the '${e}' Value`,at=["Gets","Checks existence of","Sets","Deletes","Sets part of",fe,"Gets "+je,"Sets "+je,me+" whenever",Ge+"set",Ge+"add",Ge+"set part of",Ge+"delete","Renders","Gets "+je+ze,"Sets"+ze,"Deletes"+ze],nt=[s,"has","set","del","set","forEach",I,t],ot=[xe,i,Je+c+Me+$,Y+c,Je+p+Me+$,Y+p,Je+h+Me+$,Y+h,"invalid Cell changes",f,Je+m+Me+$,Y+m,"invalid Value changes",Je+"sorted "+p+Me+$],dt=[t,"tabular ","keyed value "],rt=e=>new Set(G(e)||L(e)?e:[e]),st=(e,t)=>e?.add(t),It=/[^A-Za-z]+/,$t=/[^A-Za-z0-9]+/,ct=/^( *)\/\*\* *(.*?) *\*\/$/gm,it=(e,t,l)=>e.substring(t,l),ut=e=>e.includes(","),pt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return z(e,n)?pt(e,t,l,a+1):(Q(e,n,l),n)},bt=e=>e.replace(ct,((e,t,l)=>{const a=77-Ct(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),Ct=e=>e.length,ht=(e,l=t)=>e.join(l),gt=e=>e.flat(1e3),mt=(e,t=0)=>ht(V(e.split($t),((e,l)=>(l>0||t?K:X)(it(e,0,1))+it(e,1)))),ft=e=>K(ht((e&&!It.test(e[0])?e:" "+e).split($t),"_")),wt=e=>`/** ${e}. */`,yt=(...e)=>ht(k(e,(e=>e)),", "),Tt=(...e)=>"{"+ht(e,"; ")+"}",vt=(...e)=>Tt(...V(e,(e=>"readonly "+e))),Vt=()=>{const e=[U(),U(),U(),U()],l=U(),a=U();return[(...e)=>ht(gt(e),"\n"),(t,l,...a)=>v(a,(a=>v([0,1],(n=>(t??n)==n?st(q(e[n],l,rt),a):0)))),(e,a,n,o=t,d=1)=>pt(l,e,[a,n,o,d]),(e,t,l)=>pt(a,e,G(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>_(a,e)===t?e:pt(a,e,t),(l=0)=>V([...T(H(e[l],((e,t)=>`import {${ht(T(W(e)),", ")}} from '${t}';`)),((e,t)=>ut(e)!=ut(t)?ut(e)?-1:1:e>t?1:-1)),t],(e=>e.replace("{React}","React"))),()=>H(l,(([e,l,a,n],o)=>[wt(l),`${n?se+" ":t}type ${o}${a} = ${e};`,t])),()=>H(a,((e,l)=>(e=G(e)?e:[e],S(e,P(e)+";"),[`const ${l} = ${E(e)}`,e,t])))]},xt=Object,Rt=xt.keys,kt=xt.freeze,St=e=>N(e,xt)&&e.constructor==xt,Pt=(e,t)=>V(xt.entries(e),(([e,l])=>t(l,e))),At=e=>St(e)&&R(Rt(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=>Pt(e,((e,a)=>t(a,mt(a,1),l(ft(a),`'${a}'`)))),(t,a)=>Pt(e[t],((e,t)=>a(t,e[o],e[d],l(ft(t),`'${t}'`),mt(t,1)))),e=>Pt(t,((t,a)=>e(a,t[o],t[d],l(ft(a),`'${a}'`),mt(a,1))))],Ot=(e,l,a,n)=>[(n,o)=>{const d=n+": "+o,s=e(i,Tt(...l((e=>`'${e}'?: {[rowId: Id]: `+Tt(...a(e,((e,l,a)=>`'${e}'${L(a)?"?":t}: ${l}`)))+"}"))),Be(1,5)),I=e(i+Ne,Tt(...l((e=>`'${e}'?: {[rowId: Id]: `+Tt(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Be(1,5,1)),$=e(c+Ie,"keyof "+s,"A "+c+" Id in "+xe),m=`<TId extends ${$}>`,f=e(c,be+`<${s}[TId]>`,"A "+c+" in "+xe,m),w=e(c+Ne,be+`<${I}[TId]>`,"A "+c+" in "+xe+Le,m),y=e(p,f+"<TId>[Id]","A "+p+" in a "+c,m),T=e(p+Ne,w+"<TId>[Id]","A "+p+" in a "+c+Le,m),v=e(h+Ie,`Extract<keyof ${y}<TId>, Id>`,"A "+h+" Id in a "+p,m),V=e(h,be+`<${s}[TId]>[Id][CId]`,"A "+h+" in a "+p,`<TId extends ${$}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,h+" Ids and types in a "+p,`<TId extends ${$}, CId = ${v}<TId>>`,0),R=e(h+le,`(...[cellId, cell]: ${x}<TId>)`+Oe,He(Y+h+" Id, and "+h),m),k=e(p+le,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Oe+") "+Oe,He(Y+p+" Id, and a "+h+" iterator"),m),S=e("TableIdForEachRowArray",`TId extends ${$} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Oe}] : never`,c+" Ids and callback types",`<TId = ${$}>`,0),P=e(c+le,`(...[tableId, forEachRow]: ${S})`+Oe,He(Y+c+" Id, and a "+p+" iterator"),t),A=e("TableIdRowIdCellIdArray",`TId extends ${$} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${$}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${A}) => CellChange`,ee+" returning information about any Cell's changes during a "+ke),D=e(i+r,`(${d}, getCellChange: ${E}${pe})`+Oe,Qe(1)),O=e(u+r,`(${d})`+Oe,Qe(2)),N=e(c+r,`(${d}, tableId: ${$}, getCellChange: ${E}${pe})`+Oe,Qe(3)),j=e(b+r,`(${d}, tableId: ${$})`+Oe,Qe(4,3)),M=e(C+r,"("+yt(d,"tableId: "+$,"cellId: Id"+pe,"descending: boolean","offset: number","limit: number"+pe,"sortedRowIds: Ids")+")"+Oe,Qe(13,3)),G=e(p+r,"("+yt(""+d,"tableId: "+$,we,`getCellChange: ${E}${pe}`)+")"+Oe,Qe(5,3)),J=e(g+r,"("+yt(""+d,"tableId: "+$,we)+")"+Oe,Qe(6,5)),z=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${we}, cellId: CId, newCell: ${V}<TId, CId> ${pe}, oldCell: ${V}<TId, CId> ${pe}, getCellChange: ${E} ${pe}] : never`,"Cell args for CellListener",`<TId extends ${$}, CId = ${v}<TId>>`,0),W=e("CellListenerArgsArrayOuter",`TId extends ${$} ? `+z+"<TId> : never","Table args for CellListener",`<TId = ${$}>`,0);return[s,I,$,f,w,y,T,v,V,R,k,P,D,O,N,j,M,G,J,e(h+r,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${W})`+Oe,Qe(7,5)),e($e+h+r,`(${d}, tableId: Id, ${we}, cellId: Id, invalidCells: any[])`+Oe,Qe(8))]},(l,a)=>{const o=l+": "+a,d=e(f,Tt(...n(((e,l,a)=>`'${e}'${L(a)?"?":t}: ${l}`))),Be(2,5)),s=e(f+Ne,Tt(...n(((e,t)=>`'${e}'?: ${t}`))),Be(2,5,1)),I=e(m+Ie,"keyof "+d,"A "+m+" Id in "+xe),$=e(m,be+`<${d}[VId]>`,"A "+m+" Id in "+xe,`<VId extends ${I}>`),c=e("ValueIdValueArray",`VId extends ${I} ? [valueId: VId, value: ${$}<VId>] : never`,m+" Ids and types in "+xe,`<VId = ${I}>`,0),i=e(m+le,`(...[valueId, value]: ${c})`+Oe,He(Y+m+" Id, and "+m)),u=e("GetValueChange",`(valueId: ${I}) => ValueChange`,ee+" returning information about any Value's changes during a "+ke),p=e(f+r,`(${o}, getValueChange: ${u}${pe})`+Oe,Qe(9)),b=e(w+r,`(${o})`+Oe,Qe(10)),C=e("ValueListenerArgsArray",`VId extends ${I} ? [${o}, valueId: VId, newValue: ${$}<VId> ${pe}, oldValue: ${$}<VId> ${pe}, getValueChange: ${u} ${pe}] : never`,"Value args for ValueListener",`<VId = ${I}>`,0);return[d,s,I,$,i,p,b,e(m+r,`(...[${l}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Oe,Qe(11)),e($e+m+r,`(${o}, valueId: Id, invalidValues: any[])`+Oe,Qe(12))]},(t,l)=>e(Re+r,`(${t}: ${l}, cellsTouched: boolean, valuesTouched: boolean)`+Oe,ee+" listening to the completion of a "+ke)],Nt=(e,l=t,a=t)=>`store.${e}(${l})`+(a?" as "+a:t),Lt=(e,l=t)=>`fluent(() => ${Nt(e,l)})`,jt=(e,l=t,a=t)=>`store.${e}(${l?l+", ":t}proxy(listener)${a?", "+a:t})`,Mt=(e,l,n)=>{const[s,y,T,V,x,R,k,P]=Vt(),[E,D,O]=Dt(e,l,x),[N,j,G]=Ot(T,E,D,O),J=U(),z=(e=0)=>H(J,(([l,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${l}): ${a} => ${n},`]:[r+d+`(${l}): ${a};`];return e||A(s,wt(o)),S(s,t),s})),B=(e,l,a,n,o,d=t)=>pt(J,e,[l,a,n,o,d]),F=(e,l,a,n,o,d=t,r=t,s=t)=>B(nt[e]+l+(4==e?Ce:t)+a,d,n,(n==X?Lt:Nt)(nt[e]+(4==e?Ce:t)+a,r,e?void 0:n),o,s),q=(e,l,a,n=t,o=t,d=1,s=t)=>B(I+e+r,(n?n+", ":t)+ie+": "+l+(d?", mutator?: boolean":t),Ie,jt(I+e+r,o,d?"mutator":t),a,s),K=`./${mt(n)}.d`,X=mt(n,1),Y=mt(X),ee=[],te=U();let ae=[],ne=[];if(y(1,K,X,`create${X} as create${X}Decl`),!At(e)){y(0,"tinybase","CellChange"),y(null,"tinybase",$);const[e,l,n,r,s,I,m,f,w,V,R,k,P,A,O,j,G,J,z,B,Z]=N(Y,X),H=U();E(((e,t)=>{const l=`<'${e}'>`,a=[T(t+c,r+l,fe+` the '${e}' `+c),T(t+c+Ne,s+l,fe+` the '${e}' `+c+Le),T(t+p,I+l,Fe(e)),T(t+p+Ne,m+l,Fe(e,1)),T(t+h+Ie,f+l,`A Cell Id for the '${e}' `+c),T(t+h+le,V+l,He(`a Cell Id and value from a Row in the '${e}' `+c)),T(t+p+le,R+l,He(`a Row Id from the '${e}' Table, and a Cell iterator`))];Q(H,e,a),y(1,K,...a)})),y(1,K,e,l,n,f,k,P,A,O,j,G,J,z,B,Z),ae=[e,l,n,f,P,A,O,j,G,J,z,B,H],v([[e],[a],[X,"tables: "+l,"tables"],[X]],(([e,l,a],n)=>F(n,t,i,e,Be(1,n),l,a))),F(0,t,u,n+Ve,Ue(c,xe)),F(5,t,c,De,_e(c,xe),"tableCallback: "+k,"tableCallback as any"),E(((e,l,n)=>{const[o,d,r,s,I,i,u]=_(H,e);v([[o],[a],[X,"table: "+d,", table"],[X]],(([a,o,d=t],r)=>F(r,l,c,a,Ye(e,r),o,n+d))),F(0,l,b,$,Ue(p,Ke(e)),t,n),F(0,l,C,$,Ue(p,Ke(e),1),"cellId?: "+I+ve,n+", cellId, descending, offset, limit"),F(5,l,p,De,_e(p,Ke(e)),"rowCallback: "+u,n+", rowCallback as any"),v([[r],[a],[X,", row: "+s,", row"],[X],[X,", partialRow: "+s,", partialRow"]],(([a,o=t,d=t],r)=>F(r,l,p,a,et(e,r),we+o,n+", rowId"+d))),F(6,l,p,Ie+pe,"Add a new Row to "+Ke(e),"row: "+s,n+", row"),F(0,l,g,I+Ve,Ue(h,Xe(e)),we,n+", rowId"),F(5,l,h,De,_e(h,Xe(e)),we+", cellCallback: "+i,n+", rowId, cellCallback as any"),D(e,((o,d,r,s,I)=>{const $="Map"+mt(d,1);Q(te,d,$);const c=d+(L(r)?pe:t);v([[c],[a],[X,`, cell: ${d} | `+$,", cell as any"],[X]],(([a,d=t,r=t],$)=>F($,l+I,h,a,tt(e,o,$),we+d,n+", rowId, "+s+r)))}))})),F(0,t,i+ce,ce,Be(1,6)),F(2,t,i+ce,X,Be(1,7),"tablesJson: "+ce,"tables"+ce),q(i,P,Be(1,8)+" changes"),q(u,A,qe(2,0,1)),q(c,O,qe(3,0),`tableId: ${n} | null`,"tableId"),q(b,j,qe(4,3,1),`tableId: ${n} | null`,"tableId"),q(C,G,qe(13,3,1),yt("tableId: TId",`cellId: ${f}<TId>`+pe,"descending: boolean","offset: number","limit: number"+pe),yt("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),q(p,J,qe(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),q(g,z,qe(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),q(h,B,qe(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${ht(E((e=>_(H,e)?.[4]??t))," | ")} | null`,"tableId, rowId, cellId"),q($e+h,Z,me+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),y(1,K,...W(te)),S(ee,".set"+i+ye+"({",gt(E(((e,l,a)=>[`[${a}]: {`,...D(e,((e,l,a,n)=>`[${n}]: {[${x(ft(o),`'${o}'`)}]: ${x(ft(l),`'${l}'`)}${L(a)?t:`, [${x(ft(d),`'${d}'`)}]: `+(M(a)?x(ft(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!At(l)){const[e,l,n,r,s,I,$,c,i]=j(Y,X);y(1,K,e,l,n,s,I,$,c,i),ne=[e,l,n,I,$,c],v([[e],[a],[X,"values: "+l,"values"],[X],[X,"partialValues: "+l,"partialValues"]],(([e,l,a],n)=>F(n,t,f,e,Be(2,n),l,a))),F(0,t,w,n+Ve,Ue(m,xe)),F(5,t,m,"void",_e(m,xe),"valueCallback: "+s,"valueCallback as any"),O(((e,l,n,o,d)=>{const r="Map"+mt(l,1);Q(te,l,r),v([[l],[a],[X,`value: ${l} | `+r,", value as any"],[X]],(([l,a,n=t],r)=>F(r,d,m,l,lt(e,r),a,o+n)))})),F(0,t,f+ce,ce,Be(2,6)),F(2,t,f+ce,X,Be(2,7),"valuesJson: "+ce,"values"+ce),q(f,I,Be(2,8)+" changes"),q(w,$,qe(10,0,1)),q(m,c,qe(11,0),`valueId: ${n} | null`,"valueId"),q($e+m,i,me+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),y(1,K,...W(te)),y(0,"tinybase","ValueChange"),S(ee,".set"+f+ye+"({",O(((e,l,a,n)=>[`[${n}]: {[${x(ft(o),`'${o}'`)}]: ${x(ft(l),`'${l}'`)}${L(a)?t:`, [${x(ft(d),`'${d}'`)}]: `+(M(a)?x(ft(a),`'${a}'`):a)}},`])),"})")}Z(te,((e,t)=>T(t,`(cell: ${e}${pe}) => `+e,`Takes a ${e} Cell value and returns another`))),y(null,"tinybase","DoRollback",Ie,"IdOrNull",ce,"Store"),F(0,t,ce,ce,Be(0,6)),F(2,t,ce,X,Be(0,7),"tablesAndValuesJson: "+ce,"tablesAndValuesJson"),F(7,t,ke,"Return",Se,re,"actions, doRollback","<Return>"),F(7,t,"start"+Re,X,Pe),F(7,t,"finish"+Re,X,Ae,de,"doRollback");const oe=G(Y,X);return q("WillFinish"+Re,oe,me+" just before "+Ee,t,t,0),q("DidFinish"+Re,oe,me+" just after "+Ee,t,t,0),F(7,t,"call"+r,X,"Manually provoke a listener to be called","listenerId: Id","listenerId"),F(3,t,r,X,"Remove a listener that was previously added to "+xe,"listenerId: Id","listenerId"),B("getStore",t,"Store","store",at[0]+" the underlying Store object"),y(1,"tinybase","createStore"),y(1,K,X,`create${X} as create${X}Decl`,oe),x("store",["createStore()",...ee]),V("fluent","actions: () => Store",["actions();",`return ${Y};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Y}, ...params)`),x(Y,["{",...z(1),"}"]),[s(...R(0),...k(),se+" interface "+X+" {",...z(0),"}",t,wt(`Creates a ${X} object`),se+" function create"+X+"(): "+X+";"),s(...R(1),se+" const create"+X+": typeof create"+X+"Decl = () => {",...P(),`return Object.freeze(${Y});`,"};"),ae,ne]},Gt=e=>s+e,Jt=e=>yt(Gt(e),Gt(e)+ne),zt="debugIds?: boolean",Wt="debugIds={debugIds}",Bt="then"+oe,Ft="Parameter",Ut=": (parameter: "+Ft+", store: Store) => ",_t="const contextValue = useContext(Context);",Zt=", based on a parameter",Ht=": ",Qt="<"+Ft+",>",qt=Ft+"ized"+le+"<"+Ft+">",Kt="rowId",Xt="rowId={rowId}",Yt=", separator, debugIds",el="separator?: ReactElement | string",tl="then?: (store: Store",ll=yt(tl+")"+Oe,Bt),al="then, then"+ne,nl=Kt+Ht+Ie,ol="View",dl=(e,...t)=>yt(...t,ie+": "+e,ie+oe,"mutator?: boolean"),rl=(...e)=>yt(...e,ie,ie+ne,"mutator"),sl=(e,l,a,n,o)=>{const[d,s,I,y,T,v,V,x]=Vt(),[R,k,P]=Dt(e,l,T),E=`./${mt(a)}.d`,D=`./${mt(a)}-ui-react.d`,O="tinybase/ui-react",N=mt(a,1),j=mt(N),M=N+"Or"+N+Ie,G=j+"Or"+N+Ie,J=j+`={${j}}`,z=U(),W=(e,l,a,n,o,d=t)=>(s(1,D,e+" as "+e+"Decl"),pt(z,e,[l,a,n,o,d])),B=(e,l,a,n,o,d=t)=>W("use"+e,l,a,n,o,d),F=(e,l,a,n,o=t,d=t,r=t,I=t,$=t)=>(s(1,O,`use${l} as use${l}Core`),B(e,yt(o,X,I),a,ne+`(${G}, use${l}Core, [`+(d||t)+($?"], ["+$:t)+"]);",n,r)),Z=(e,t,l,a)=>W(e,t,1,l,a),Q=(e=0)=>H(z,(([l,a,n,o,d],r)=>{const s=e?[se+` const ${r}: typeof ${r}Decl = ${d}(${l}): ${1==a?"any":a} =>`,n]:[se+` function ${r}${d}(${l}): ${1==a?"ComponentReturnType":a};`];return e||A(s,wt(o)),S(s,t),s}));s(null,"tinybase",Ie,"Store",le,Ft+"ized"+le),s(0,O,"ComponentReturnType"),s(null,O,"ExtraProps"),s(0,E,N);const q=I(M,N+" | "+Ie,`Used when you need to refer to a ${N} in a React hook or component`),K=I(ge+he,vt(j+ue+N,j+`ById?: {[${j}Id: Id]: ${N}}`),`Used with the ${ge} component, so that a `+N+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,D,q,K);const X=G+ue+q;T("{createContext, useContext, useMemo}","React"),T("Context",`createContext<[${N}?, {[${j}Id: Id]: ${N}}?]>([])`),B("Create"+N,`create: () => ${N}, create`+oe,N,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${N} within a React application with convenient memoization`);const ee=B(N,"id?: Id",N+pe,["{",_t,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${N} from within a ${ge} component context`),ne=y("useHook",G+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${j} = ${ee}(${G} as Id);`,`return hook(...preParams, ((${G} == null || typeof ${G} == 'string')`,`? ${j} : ${G})?.getStore(), ...postParams)`]),de=y("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),re=y("wrap",yt("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;"]),$e=T("NullComponent","() => null");if(!At(e)){const[e,l,a,o,d,m,f,w,T,v,V,x,S]=n;s(null,E,e,l,a,d,m,f,w,T,v,V,x),s(0,E,o),s(1,E,N),s(null,"tinybase",$,"IdOrNull");const P=y("tableView",`{${j}, rowComponent, getRowComponentProps`+Yt+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${re}(rowIds.map((rowId) => (`,"<Row","{..."+de+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",Xt,J,Wt,"/>","))",Yt,", tableId,",");"]),A=y("getDefaultTableComponent","tableId: Id",ht(R(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+$e),O=y("getDefaultCellComponent","tableId: Id, cellId: Id",ht(R(((e,t,l)=>`tableId == ${l} ? ${ht(k(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+$e} : `)))+$e);F(i,i,e,Be(1,0)+te);const M=F(u,u,a+Ve,Ue(c,xe)+te);F(Te+i+le,Te+i+le,qt,Be(1,9)+Zt,yt(Gt(i)+Ut+l,Gt(i)+oe),Jt(i),Qt,yt(tl,`tables: ${l})`+Oe,Bt),al),F(ae+i+le,ae+i+le,le,Be(1,12),t,t,t,ll,al);const G=I(h+he,vt("tableId?: TId","rowId: Id","cellId?: CId",j+ue+N,zt),Ze(Y+h),`<TId extends ${a}, CId extends ${o}<TId>>`),z=I(p+he,vt("tableId?: TId","rowId: Id",j+ue+N,"cellComponents?: {readonly [CId in "+o+`<TId>]?: ComponentType<${G}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${o}<TId>) => ExtraProps`,el,zt),Ze(Y+p),`<TId extends ${a}>`),W=I(c+he,vt("tableId?: TId",j+ue+N,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",el,zt),Ze(Y+c),`<TId extends ${a}>`),B=I("Sorted"+c+he,vt("tableId?: TId","cellId?: "+o+"<TId>","descending?: boolean","offset?: number","limit?: number",j+ue+N,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",el,zt),Ze(Y+"sorted "+c),`<TId extends ${a}>`),U=I(i+he,vt(j+ue+N,"tableComponents?: {readonly [TId in "+a+`]?: ComponentType<${W}<TId>>;}`,`getTableComponentProps?: (tableId: ${a}) => ExtraProps`,el,zt),Ze(We(1,1)));s(1,D,U,W,B,z,G),Z(i+ol,"{"+j+", tableComponents, getTableComponentProps"+Yt+"}: "+U,[re+`(${M}(${j}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+A+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${de}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",J,Wt,"/>;","}), separator)"],Be(1,13)+te),R(((e,l,a)=>{const[n,o,d,r,I]=_(S,e);s(null,E,n,o,d,r,I),F(l+c,c,n,Ye(e)+te,t,a);const i=F(l+b,b,$,Ue(p,Ke(e))+te,t,a),u=F(l+C,C,$,Ue(p,Ke(e),1)+te,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");F(l+p,p,d,et(e)+te,nl,yt(a,Kt));const m=F(l+g,g,I+Ve,Ue(h,Xe(e))+te,nl,yt(a,Kt));F(Te+l+c+le,Te+c+le,qt,Ye(e,9)+Zt,yt(Gt(c)+Ut+o,Gt(c)+oe),yt(a,Jt(c)),Qt,yt(tl,`table: ${o})`+Oe,Bt),al),F(ae+l+c+le,ae+c+le,le,Ye(e,12),t,a,t,ll,al),F(Te+l+p+le,Te+p+le,qt,et(e,9)+Zt,yt(nl,Gt(p)+Ut+r,Gt(p)+oe),yt(a,Kt,Jt(p)),Qt,yt(tl,`row: ${r})`+Oe,Bt),al),F("Add"+l+p+le,"Add"+p+le,qt,et(e,10)+Zt,yt(Gt(p)+Ut+r,Gt(p)+oe),yt(a,Jt(p)),Qt,"then?: ("+yt(nl+pe,"store: Store","row: "+r+")"+Oe,"then"+oe),al),F(Te+l+Ce+p+le,Te+Ce+p+le,qt,et(e,11)+Zt,yt(nl,Gt(Ce+p)+Ut+r,Gt(Ce+p)+oe),yt(a,Kt,Jt(Ce+p)),Qt,yt(tl,`partialRow: ${r})`+Oe,Bt),al),F(ae+l+p+le,ae+p+le,le,et(e,12),nl,yt(a,Kt),t,ll,al);const f=Z(l+p+ol,"{rowId, "+j+", cellComponents, getCellComponentProps"+Yt+`}: ${z}<'${e}'>`,[re+`(${m}(rowId, ${j}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+O+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${de}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,Xt,"cellId={cellId}",J,Wt,"/>;","})"+Yt+", rowId)"],et(e,13)+te);Z(l+"Sorted"+c+ol,"{cellId, descending, offset, limit, ...props}: "+B+`<'${e}'>`,P+"(props, "+u+`(cellId, descending, offset, limit, props.${j}), ${a}, ${f});`,Ye(e,13)+", sorted"+te),Z(l+c+ol,`props: ${W}<'${e}'>`,P+"(props, "+i+`(props.${j}), ${a}, ${f});`,Ye(e,13)+te),k(e,((n,o,d,r,I)=>{const $="Map"+mt(o,1);s(0,E,$),s(1,E,$);const c=F(l+I+h,h,o+(L(d)?pe:t),tt(e,n)+te,nl,yt(a,Kt,r));F(Te+l+I+h+le,Te+h+le,qt,tt(e,n,9)+Zt,yt(nl,Gt(h)+Ut+o+" | "+$,Gt(h)+oe),yt(a,Kt,r,Jt(h)),Qt,yt(tl,`cell: ${o} | ${$})`+Oe,Bt),al),F(ae+l+I+h+le,ae+h+le,le,tt(e,n,12),yt(nl,"forceDel?: boolean"),yt(a,Kt,r,"forceDel"),t,ll,al),Z(l+I+h+ol,`{rowId, ${j}, debugIds}: `+G+`<'${e}', '${n}'>`,[re+`('' + ${c}(rowId, `+j+`) ?? '', undefined, debugIds, ${r})`],tt(e,n,13)+te)}))}));const H=ht(R((e=>_(S,e)?.[4]??t))," | ");F(i+r,i+r,De,Be(1,8)+" changes",dl(d),rl()),F(u+r,u+r,De,qe(2,0,1),dl(m),rl()),F(c+r,c+r,De,qe(3,0),dl(f,`tableId: ${a} | null`),rl("tableId")),F(b+r,b+r,De,qe(4,3,1),dl(w,`tableId: ${a} | null`),rl("tableId")),F(C+r,C+r,De,qe(13,3,1),dl(T,`tableId: ${a} | null`,"cellId: "+H+pe,"descending: boolean","offset: number","limit: number"+pe),rl("tableId","cellId","descending","offset","limit")),F(p+r,p+r,De,qe(5,3),dl(v,`tableId: ${a} | null`,Kt+": IdOrNull"),rl("tableId",Kt)),F(g+r,g+r,De,qe(6,5,1),dl(V,`tableId: ${a} | null`,Kt+": IdOrNull"),rl("tableId",Kt)),F(h+r,h+r,De,qe(7,5),dl(x,`tableId: ${a} | null`,Kt+": IdOrNull",`cellId: ${H} | null`),rl("tableId",Kt,"cellId"))}if(!At(l)){const[e,l,a,n,d,$]=o;s(null,E,...o),s(1,E,N);const c=y("getDefaultValueComponent","valueId: Id",ht(P(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+$e);F(f,f,e,Be(2,0)+te);const i=F(w,w,a+Ve,Ue(m,xe)+te);F(Te+f+le,Te+f+le,qt,Be(2,9)+Zt,yt(Gt(f)+Ut+l,Gt(f)+oe),Jt(f),Qt,yt(tl,`values: ${l})`+Oe,Bt),al),F(Te+Ce+f+le,Te+Ce+f+le,qt,Be(2,11)+Zt,yt(Gt(Ce+f)+Ut+l,Gt(Ce+f)+oe),Jt(Ce+f),Qt,yt(tl,`partialValues: ${l})`+Oe,Bt),al),F(ae+f+le,ae+f+le,le,Be(2,12),t,t,t,ll,al);const u=I(m+he,vt("valueId?: VId",j+ue+N,zt),Ze("a Value"),`<VId extends ${a}>`),p=I(f+he,vt(j+ue+N,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${u}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,el,zt),Ze(We(2,1)));s(1,D,p,u),Z(f+ol,"{"+j+", valueComponents, getValueComponentProps"+Yt+"}: "+p,[re+`(${i}(${j}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+c+"(valueId);","return <Value",`{...${de}(getValueComponentProps, valueId)}`,"key={valueId}",J,Wt,"/>;","}), separator)"],Be(2,13)+te),P(((e,l,a,n,o)=>{const d="Map"+mt(l,1);s(0,E,d),s(1,E,d);const r=F(o+m,m,l,lt(e)+te,t,n);F(Te+o+m+le,Te+m+le,qt,lt(e,9)+Zt,yt(Gt(m)+Ut+l+" | "+d,Gt(m)+oe),yt(n,Jt(m)),Qt,yt(tl,`value: ${l} | ${d})`+Oe,Bt),al),F(ae+o+m+le,ae+m+le,le,lt(e,12),t,n,t,ll,al),Z(o+m+ol,`{${j}, debugIds}: ${u}<'${e}'>`,[re+`('' + ${r}(`+j+`) ?? '', undefined, debugIds, ${n})`],lt(e,13)+te)})),F(f+r,f+r,De,Be(2,8)+" changes",dl(n),rl()),F(w+r,w+r,De,qe(10,0,1),dl(d),rl()),F(m+r,m+r,De,qe(11,0),dl($,`valueId: ${a} | null`),rl("valueId"))}return Z(ge,`{${j}, ${j}ById, children}: `+K+" & {children: React.ReactNode}",["{",_t,"return (","<Context."+ge,"value={useMemo(",`() => [${j} ?? contextValue[0], {...contextValue[1], ...${j}ById}],`,`[${j}, ${j}ById, contextValue],`,")}>","{children}",`</Context.${ge}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[d(...v(0),...V(),...Q(0)),d(...v(1),...x(),...Q(1))]},Il=(e,l,a)=>{if(At(e)&&At(l))return[t,t,t,t];const[n,o,d,r]=Mt(e,l,a);return[n,o,...sl(e,l,a,d,r)]},$l={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},cl=Et((e=>{const t=()=>{const t=D(e.getTablesSchemaJson());return!At(t)||y(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=U();if(y(a,(t=>y(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=q(n,a,(()=>[J(o),U(),[0],0])),[r,s,[I]]=d,$=q(s,o,(()=>0))+1;return $>I&&(d[2]=[$,o]),Q(s,o,$),d[3]++,r==J(o)})))))return t[l]={},B(n,(([e,,[,n],r],s)=>{t[l][s]={[o]:e,...r==x(a)?{[d]:n}:{}}})),1}))?t:{}},l=()=>{const t=D(e.getValuesSchemaJson());return At(t)&&e.forEachValue(((e,l)=>{t[e]={[o]:J(l)}})),t},a=e=>Il(t(),l(),e),n=async e=>{const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(await import("prettier")).format}catch(e){l=e=>e}return V(a(e),((e,a)=>bt(l(e,{...$l,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})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:x(e.getValueIds()),jsonLength:Ct(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=cl;
|
package/lib/cjs/tools.cjs.gz
CHANGED
|
Binary file
|
package/lib/cjs/tools.d.ts
CHANGED
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
* @since v2.2.0
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
NoSchemas,
|
|
15
|
+
OptionalSchemas,
|
|
16
|
+
Store,
|
|
17
|
+
TablesSchema,
|
|
18
|
+
ValuesSchema,
|
|
19
|
+
} from './store.d';
|
|
14
20
|
import {Id} from './common.d';
|
|
15
21
|
|
|
16
22
|
/**
|
|
@@ -109,7 +115,7 @@ export type StoreStatsRowDetail = {
|
|
|
109
115
|
* @category Tools
|
|
110
116
|
* @since v2.2.0
|
|
111
117
|
*/
|
|
112
|
-
export interface Tools {
|
|
118
|
+
export interface Tools<Schemas extends OptionalSchemas = NoSchemas> {
|
|
113
119
|
/* eslint-disable max-len */
|
|
114
120
|
/**
|
|
115
121
|
* The getStoreStats method provides a set of statistics about the Store, and
|
|
@@ -459,180 +465,6 @@ export interface Tools {
|
|
|
459
465
|
storeName: string,
|
|
460
466
|
): Promise<[string, string, string, string]>;
|
|
461
467
|
|
|
462
|
-
/**
|
|
463
|
-
* The getStoreRefinement method returns code-generated `.d.ts` files that
|
|
464
|
-
* refine the Store and React bindings to have schema-specific methods and
|
|
465
|
-
* types.
|
|
466
|
-
*
|
|
467
|
-
* If the Store does not already have an explicit TablesSchema or ValuesSchema
|
|
468
|
-
* associated with it, the data in the Store will be scanned to attempt to
|
|
469
|
-
* infer new schemas. The method returns two strings (which should be saved as
|
|
470
|
-
* files) though if no schema can be inferred, the strings will be empty.
|
|
471
|
-
*
|
|
472
|
-
* The method takes a single argument which represents the name you want the
|
|
473
|
-
* generated store object to have in code. You are expected to save the two
|
|
474
|
-
* files yourself, as, respectively:
|
|
475
|
-
*
|
|
476
|
-
* - `[storeName]-refinement.d.ts`
|
|
477
|
-
* - `[storeName]-ui-react-refinement.d.ts`
|
|
478
|
-
*
|
|
479
|
-
* You should save these alongside each other.
|
|
480
|
-
*
|
|
481
|
-
* The `.d.ts` files that are generated are designed to resemble the main
|
|
482
|
-
* TinyBase Store and React binding files. In your application you will need
|
|
483
|
-
* to coerce the Store to the refined interface to benefit from the type
|
|
484
|
-
* safety. One easy way to do this is to cast the TinyBase module to the
|
|
485
|
-
* refined module in bulk, and then destructure to get the refined imports:
|
|
486
|
-
*
|
|
487
|
-
* ```js yolo
|
|
488
|
-
* import * as tinybase from 'tinybase';
|
|
489
|
-
* import shopRefinement from './shop-refinement.d';
|
|
490
|
-
*
|
|
491
|
-
* const {createStore} = tinybase as typeof shopRefinement;
|
|
492
|
-
*
|
|
493
|
-
* const shop = createStore(); // shop is a refined Store
|
|
494
|
-
* // ...
|
|
495
|
-
* ```
|
|
496
|
-
*
|
|
497
|
-
* This is a particularly good approach for the React module which has many
|
|
498
|
-
* top-level hook and component functions. You don't need to refine them one
|
|
499
|
-
* by one:
|
|
500
|
-
*
|
|
501
|
-
* ```js yolo
|
|
502
|
-
* import * as tinybaseUiReact from 'tinybase/ui-react';
|
|
503
|
-
* import shopUiReactRefinement from './shop-ui-react-refinement.d';
|
|
504
|
-
*
|
|
505
|
-
* const {
|
|
506
|
-
* useTables, // a refined hook
|
|
507
|
-
* RowView, // a refined component
|
|
508
|
-
* // ...
|
|
509
|
-
* } = tinybaseUiReact as typeof shopUiReactRefinement;
|
|
510
|
-
*
|
|
511
|
-
* // ...
|
|
512
|
-
* ```
|
|
513
|
-
*
|
|
514
|
-
* If you need access to refined types from the generated module definition,
|
|
515
|
-
* you can access them as normal, in a separate import:
|
|
516
|
-
*
|
|
517
|
-
* ```js yolo
|
|
518
|
-
* import {Tables} from './shop-refinement.d';
|
|
519
|
-
* ```
|
|
520
|
-
*
|
|
521
|
-
* @param storeName The name you want to provide to the generated Store, which
|
|
522
|
-
* should also be used to save the `.d.ts` files.
|
|
523
|
-
* @returns A pair of strings representing the contents of the `.d.ts` files
|
|
524
|
-
* for the generated Store and React modules.
|
|
525
|
-
* @example
|
|
526
|
-
* This example creates a Tools object and generates type refinements for a
|
|
527
|
-
* Store that already has a TablesSchema.
|
|
528
|
-
* ```js
|
|
529
|
-
* const store = createStore().setTablesSchema({
|
|
530
|
-
* pets: {
|
|
531
|
-
* price: {type: 'number'},
|
|
532
|
-
* },
|
|
533
|
-
* });
|
|
534
|
-
* const [refinementDTs, uiReactRefinementDTs] =
|
|
535
|
-
* createTools(store).getStoreRefinement('shop');
|
|
536
|
-
*
|
|
537
|
-
* const dTsLines = refinementDTs.split('\n');
|
|
538
|
-
* // console.log(dTsLines[3]);
|
|
539
|
-
* // // -> ''
|
|
540
|
-
* // console.log(dTsLines[6]);
|
|
541
|
-
* // // -> ''
|
|
542
|
-
* ```
|
|
543
|
-
* @example
|
|
544
|
-
* This example creates a Tools object and generates code for a Store that
|
|
545
|
-
* doesn't already have a TablesSchema.
|
|
546
|
-
* ```js
|
|
547
|
-
* const store = createStore().setTable('pets', {
|
|
548
|
-
* fido: {price: 5},
|
|
549
|
-
* felix: {price: 4},
|
|
550
|
-
* });
|
|
551
|
-
* const [refinementDTs, uiReactRefinementDTs] =
|
|
552
|
-
* createTools(store).getStoreRefinement('shop');
|
|
553
|
-
*
|
|
554
|
-
* const dTsLines = refinementDTs.split('\n');
|
|
555
|
-
* // console.log(dTsLines[3]);
|
|
556
|
-
* // // -> ''
|
|
557
|
-
* // console.log(dTsLines[6]);
|
|
558
|
-
* // // -> ''
|
|
559
|
-
* ```
|
|
560
|
-
* @category Modelling
|
|
561
|
-
* @since v3.1.0
|
|
562
|
-
*/
|
|
563
|
-
getStoreRefinement(storeName: string): [string, string];
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* The getPrettyStoreRefinement method attempts to return prettified
|
|
567
|
-
* code-generated `.d.ts` files that refine the Store and React bindings to
|
|
568
|
-
* have schema-specific methods and types.
|
|
569
|
-
*
|
|
570
|
-
* This is simply a wrapper around the getStoreRefinement method that attempts
|
|
571
|
-
* to invoke the `prettier` module (which it hopes you have installed) to
|
|
572
|
-
* format the generated code. If `prettier` is not present, the output will
|
|
573
|
-
* resemble that of the underlying getStoreRefinement method.
|
|
574
|
-
*
|
|
575
|
-
* The method is asynchronous, so you should use the `await` keyword or handle
|
|
576
|
-
* the results as a promise.
|
|
577
|
-
*
|
|
578
|
-
* The method takes a single argument which represents the name you want the
|
|
579
|
-
* generated store object to have in code. You are expected to save the two
|
|
580
|
-
* files yourself, as, respectively:
|
|
581
|
-
*
|
|
582
|
-
* - `[storeName]-refinement.d.ts`
|
|
583
|
-
* - `[storeName]-ui-react-refinement.d.ts`
|
|
584
|
-
*
|
|
585
|
-
* You should save these alongside each other.
|
|
586
|
-
*
|
|
587
|
-
* See the documentation for the getStoreRefinement method for details of the
|
|
588
|
-
* content of the generated files.
|
|
589
|
-
*
|
|
590
|
-
* @param storeName The name you want to provide to the generated Store, which
|
|
591
|
-
* should also be used to save the `.d.ts` files.
|
|
592
|
-
* @returns A pair of strings representing the contents of the `.d.ts` files
|
|
593
|
-
* for the generated Store and React modules.
|
|
594
|
-
* @example
|
|
595
|
-
* This example creates a Tools object and generates type refinements for a
|
|
596
|
-
* Store that already has a TablesSchema.
|
|
597
|
-
* ```js
|
|
598
|
-
* const store = createStore().setTablesSchema({
|
|
599
|
-
* pets: {
|
|
600
|
-
* price: {type: 'number'},
|
|
601
|
-
* },
|
|
602
|
-
* });
|
|
603
|
-
* const [refinementDTs, uiReactRefinementDTs] = await createTools(
|
|
604
|
-
* store,
|
|
605
|
-
* ).getPrettyStoreRefinement('shop');
|
|
606
|
-
*
|
|
607
|
-
* const dTsLines = refinementDTs.split('\n');
|
|
608
|
-
* // console.log(dTsLines[3]);
|
|
609
|
-
* // // -> ''
|
|
610
|
-
* // console.log(dTsLines[6]);
|
|
611
|
-
* // // -> ''
|
|
612
|
-
* ```
|
|
613
|
-
* @example
|
|
614
|
-
* This example creates a Tools object and generates code for a Store that
|
|
615
|
-
* doesn't already have a TablesSchema.
|
|
616
|
-
* ```js
|
|
617
|
-
* const store = createStore().setTable('pets', {
|
|
618
|
-
* fido: {price: 5},
|
|
619
|
-
* felix: {price: 4},
|
|
620
|
-
* });
|
|
621
|
-
* const [refinementDTs, uiReactRefinementDTs] = await createTools(
|
|
622
|
-
* store,
|
|
623
|
-
* ).getPrettyStoreRefinement('shop');
|
|
624
|
-
*
|
|
625
|
-
* const dTsLines = refinementDTs.split('\n');
|
|
626
|
-
* // console.log(dTsLines[3]);
|
|
627
|
-
* // // -> ''
|
|
628
|
-
* // console.log(dTsLines[6]);
|
|
629
|
-
* // // -> ''
|
|
630
|
-
* ```
|
|
631
|
-
* @category Modelling
|
|
632
|
-
* @since v3.1.0
|
|
633
|
-
*/
|
|
634
|
-
getPrettyStoreRefinement(storeName: string): Promise<[string, string]>;
|
|
635
|
-
|
|
636
468
|
/**
|
|
637
469
|
* The getStore method returns a reference to the underlying Store that is
|
|
638
470
|
* backing this Tools object.
|
|
@@ -651,7 +483,7 @@ export interface Tools {
|
|
|
651
483
|
* @category Getter
|
|
652
484
|
* @since v3.0.0
|
|
653
485
|
*/
|
|
654
|
-
getStore(): Store
|
|
486
|
+
getStore(): Store<Schemas>;
|
|
655
487
|
}
|
|
656
488
|
|
|
657
489
|
/* eslint-disable max-len */
|
|
@@ -698,5 +530,7 @@ export interface Tools {
|
|
|
698
530
|
* @category Creation
|
|
699
531
|
* @since v2.2.0
|
|
700
532
|
*/
|
|
701
|
-
export function createTools
|
|
533
|
+
export function createTools<Schemas extends OptionalSchemas>(
|
|
534
|
+
store: Store<Schemas>,
|
|
535
|
+
): Tools<Schemas>;
|
|
702
536
|
/* eslint-enable max-len */
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
15
|
-
import {Store} from './store.d';
|
|
15
|
+
import {NoSchemas, OptionalSchemas, Store} from './store.d';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The CheckpointIds type is a representation of the list of checkpoint Ids
|
|
@@ -177,7 +177,7 @@ export type CheckpointsListenerStats = {
|
|
|
177
177
|
* @see Drawing demo
|
|
178
178
|
* @category Checkpoints
|
|
179
179
|
*/
|
|
180
|
-
export interface Checkpoints {
|
|
180
|
+
export interface Checkpoints<Schemas extends OptionalSchemas = NoSchemas> {
|
|
181
181
|
/**
|
|
182
182
|
* The setSize method lets you specify how many checkpoints the Checkpoints
|
|
183
183
|
* object will store.
|
|
@@ -220,7 +220,7 @@ export interface Checkpoints {
|
|
|
220
220
|
* ```
|
|
221
221
|
* @category Configuration
|
|
222
222
|
*/
|
|
223
|
-
setSize(size: number): Checkpoints
|
|
223
|
+
setSize(size: number): Checkpoints<Schemas>;
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* The addCheckpoint method records a checkpoint of the Store into the
|
|
@@ -320,7 +320,7 @@ export interface Checkpoints {
|
|
|
320
320
|
* ```
|
|
321
321
|
* @category Setter
|
|
322
322
|
*/
|
|
323
|
-
setCheckpoint(checkpointId: Id, label: string): Checkpoints
|
|
323
|
+
setCheckpoint(checkpointId: Id, label: string): Checkpoints<Schemas>;
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
326
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -341,7 +341,7 @@ export interface Checkpoints {
|
|
|
341
341
|
* ```
|
|
342
342
|
* @category Getter
|
|
343
343
|
*/
|
|
344
|
-
getStore(): Store
|
|
344
|
+
getStore(): Store<Schemas>;
|
|
345
345
|
|
|
346
346
|
/**
|
|
347
347
|
* The getCheckpointIds method returns an array of the checkpoint Ids being
|
|
@@ -637,7 +637,7 @@ export interface Checkpoints {
|
|
|
637
637
|
* ```
|
|
638
638
|
* @category Listener
|
|
639
639
|
*/
|
|
640
|
-
delListener(listenerId: Id): Checkpoints
|
|
640
|
+
delListener(listenerId: Id): Checkpoints<Schemas>;
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
643
|
* The goBackward method moves the state of the underlying Store back to the
|
|
@@ -670,7 +670,7 @@ export interface Checkpoints {
|
|
|
670
670
|
* ```
|
|
671
671
|
* @category Movement
|
|
672
672
|
*/
|
|
673
|
-
goBackward(): Checkpoints
|
|
673
|
+
goBackward(): Checkpoints<Schemas>;
|
|
674
674
|
|
|
675
675
|
/**
|
|
676
676
|
* The goForward method moves the state of the underlying Store forwards to a
|
|
@@ -750,7 +750,7 @@ export interface Checkpoints {
|
|
|
750
750
|
* ```
|
|
751
751
|
* @category Movement
|
|
752
752
|
*/
|
|
753
|
-
goForward(): Checkpoints
|
|
753
|
+
goForward(): Checkpoints<Schemas>;
|
|
754
754
|
|
|
755
755
|
/**
|
|
756
756
|
* The goTo method moves the state of the underlying Store backwards or
|
|
@@ -800,7 +800,7 @@ export interface Checkpoints {
|
|
|
800
800
|
* ```
|
|
801
801
|
* @category Movement
|
|
802
802
|
*/
|
|
803
|
-
goTo(checkpointId: Id): Checkpoints
|
|
803
|
+
goTo(checkpointId: Id): Checkpoints<Schemas>;
|
|
804
804
|
|
|
805
805
|
/**
|
|
806
806
|
* The clear method resets this Checkpoints object to its initial state,
|
|
@@ -858,7 +858,7 @@ export interface Checkpoints {
|
|
|
858
858
|
* ```
|
|
859
859
|
* @category Lifecycle
|
|
860
860
|
*/
|
|
861
|
-
clear(): Checkpoints
|
|
861
|
+
clear(): Checkpoints<Schemas>;
|
|
862
862
|
|
|
863
863
|
/**
|
|
864
864
|
* The destroy method should be called when this Checkpoints object is no
|
|
@@ -956,4 +956,6 @@ export interface Checkpoints {
|
|
|
956
956
|
* ```
|
|
957
957
|
* @category Creation
|
|
958
958
|
*/
|
|
959
|
-
export function createCheckpoints
|
|
959
|
+
export function createCheckpoints<Schemas extends OptionalSchemas>(
|
|
960
|
+
store: Store<Schemas>,
|
|
961
|
+
): Checkpoints<Schemas>;
|
package/lib/cjs-es6/indexes.d.ts
CHANGED
|
@@ -11,7 +11,13 @@
|
|
|
11
11
|
* @module indexes
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
GetCell,
|
|
16
|
+
NoSchemas,
|
|
17
|
+
OptionalSchemas,
|
|
18
|
+
RowCallback,
|
|
19
|
+
Store,
|
|
20
|
+
} from './store.d';
|
|
15
21
|
import {Id, IdOrNull, Ids, SortKey} from './common.d';
|
|
16
22
|
|
|
17
23
|
/**
|
|
@@ -195,7 +201,7 @@ export type IndexesListenerStats = {
|
|
|
195
201
|
* @see Word Frequencies demo
|
|
196
202
|
* @category Indexes
|
|
197
203
|
*/
|
|
198
|
-
export interface Indexes {
|
|
204
|
+
export interface Indexes<Schemas extends OptionalSchemas = NoSchemas> {
|
|
199
205
|
/**
|
|
200
206
|
* The setIndexDefinition method lets you set the definition of an Index.
|
|
201
207
|
*
|
|
@@ -355,7 +361,7 @@ export interface Indexes {
|
|
|
355
361
|
getSortKey?: Id | ((getCell: GetCell, rowId: Id) => SortKey),
|
|
356
362
|
sliceIdSorter?: (sliceId1: Id, sliceId2: Id) => number,
|
|
357
363
|
rowIdSorter?: (sortKey1: SortKey, sortKey2: SortKey, sliceId: Id) => number,
|
|
358
|
-
): Indexes
|
|
364
|
+
): Indexes<Schemas>;
|
|
359
365
|
|
|
360
366
|
/**
|
|
361
367
|
* The delIndexDefinition method removes an existing Index definition.
|
|
@@ -384,7 +390,7 @@ export interface Indexes {
|
|
|
384
390
|
* ```
|
|
385
391
|
* @category Configuration
|
|
386
392
|
*/
|
|
387
|
-
delIndexDefinition(indexId: Id): Indexes
|
|
393
|
+
delIndexDefinition(indexId: Id): Indexes<Schemas>;
|
|
388
394
|
|
|
389
395
|
/**
|
|
390
396
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -404,7 +410,7 @@ export interface Indexes {
|
|
|
404
410
|
* ```
|
|
405
411
|
* @category Getter
|
|
406
412
|
*/
|
|
407
|
-
getStore(): Store
|
|
413
|
+
getStore(): Store<Schemas>;
|
|
408
414
|
|
|
409
415
|
/**
|
|
410
416
|
* The getIndexIds method returns an array of the Index Ids registered with
|
|
@@ -860,7 +866,7 @@ export interface Indexes {
|
|
|
860
866
|
* ```
|
|
861
867
|
* @category Listener
|
|
862
868
|
*/
|
|
863
|
-
delListener(listenerId: Id): Indexes
|
|
869
|
+
delListener(listenerId: Id): Indexes<Schemas>;
|
|
864
870
|
|
|
865
871
|
/**
|
|
866
872
|
* The destroy method should be called when this Indexes object is no longer
|
|
@@ -963,4 +969,6 @@ export interface Indexes {
|
|
|
963
969
|
* ```
|
|
964
970
|
* @category Creation
|
|
965
971
|
*/
|
|
966
|
-
export function createIndexes
|
|
972
|
+
export function createIndexes<Schemas extends OptionalSchemas>(
|
|
973
|
+
store: Store<Schemas>,
|
|
974
|
+
): Indexes<Schemas>;
|
package/lib/cjs-es6/metrics.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @module metrics
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {GetCell, Store} from './store.d';
|
|
14
|
+
import {GetCell, NoSchemas, OptionalSchemas, Store} from './store.d';
|
|
15
15
|
import {Id, IdOrNull, Ids} from './common.d';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -246,7 +246,7 @@ export type MetricsListenerStats = {
|
|
|
246
246
|
* @see Todo App demos
|
|
247
247
|
* @category Metrics
|
|
248
248
|
*/
|
|
249
|
-
export interface Metrics {
|
|
249
|
+
export interface Metrics<Schemas extends OptionalSchemas = NoSchemas> {
|
|
250
250
|
/**
|
|
251
251
|
* The setMetricDefinition method lets you set the definition of a Metric.
|
|
252
252
|
*
|
|
@@ -420,7 +420,7 @@ export interface Metrics {
|
|
|
420
420
|
aggregateAdd?: AggregateAdd,
|
|
421
421
|
aggregateRemove?: AggregateRemove,
|
|
422
422
|
aggregateReplace?: AggregateReplace,
|
|
423
|
-
): Metrics
|
|
423
|
+
): Metrics<Schemas>;
|
|
424
424
|
|
|
425
425
|
/**
|
|
426
426
|
* The delMetricDefinition method removes an existing Metric definition.
|
|
@@ -449,7 +449,7 @@ export interface Metrics {
|
|
|
449
449
|
* ```
|
|
450
450
|
* @category Configuration
|
|
451
451
|
*/
|
|
452
|
-
delMetricDefinition(metricId: Id): Metrics
|
|
452
|
+
delMetricDefinition(metricId: Id): Metrics<Schemas>;
|
|
453
453
|
|
|
454
454
|
/**
|
|
455
455
|
* The getStore method returns a reference to the underlying Store that is
|
|
@@ -469,7 +469,7 @@ export interface Metrics {
|
|
|
469
469
|
* ```
|
|
470
470
|
* @category Getter
|
|
471
471
|
*/
|
|
472
|
-
getStore(): Store
|
|
472
|
+
getStore(): Store<Schemas>;
|
|
473
473
|
|
|
474
474
|
/**
|
|
475
475
|
* The getMetricIds method returns an array of the Metric Ids registered with
|
|
@@ -729,7 +729,7 @@ export interface Metrics {
|
|
|
729
729
|
* ```
|
|
730
730
|
* @category Listener
|
|
731
731
|
*/
|
|
732
|
-
delListener(listenerId: Id): Metrics
|
|
732
|
+
delListener(listenerId: Id): Metrics<Schemas>;
|
|
733
733
|
|
|
734
734
|
/**
|
|
735
735
|
* The destroy method should be called when this Metrics object is no longer
|
|
@@ -824,4 +824,6 @@ export interface Metrics {
|
|
|
824
824
|
* ```
|
|
825
825
|
* @category Creation
|
|
826
826
|
*/
|
|
827
|
-
export function createMetrics
|
|
827
|
+
export function createMetrics<Schemas extends OptionalSchemas>(
|
|
828
|
+
store: Store<Schemas>,
|
|
829
|
+
): Metrics<Schemas>;
|