tinybase 3.1.0-beta.1 → 3.1.0-beta.3

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 CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- import{resolve as e,dirname as t}from"path";import{writeFileSync as r,readFileSync as s}from"fs";import{createStore as o}from"tinybase";import{createTools as a}from"tinybase/tools";import{fileURLToPath as i}from"url";const n=JSON.parse,m=Object,p=(...e)=>{return t=e=>process.stdout.write(e+"\n"),e.forEach(t);var t},c=e=>n(s(e,"utf8")),f=()=>{var e,t;p("","tinybase <command>","","Usage:",""),e=l,t=([,e,t],r)=>p(` tinybase ${r} ${e}`," - "+t,""),((e,t)=>{e.map(t)})(m.entries(e),(([e,r])=>t(r,e))),p("See also http://tinybase.org/guides/developer-tools/command-line/","")},l={help:[f,"","print this message"],version:[()=>p(c(e(t(i(import.meta.url)),"../package.json")).version),"","get the current TinyBase version"],getStoreApi:[async(t,s,i)=>{try{const m=c(t),f=a(o().setSchema(...(n=m,Array.isArray(n)?m:[m]))),[l,u]=await f.getPrettyStoreApi(s),d=e(i,s+".d.ts"),h=e(i,s+".ts");r(d,l,"utf8"),r(h,u,"utf8"),p(" Definition: "+d,"Implementation: "+h)}catch{process.stderr.write("ERROR: provide a valid schemaFile, storeName, and outputDir\n")}var n},"<schemaFile> <storeName> <outputDir>","generate .d.ts and .ts files from a schema file"]};(()=>{const[,,e,...t]=process.argv;(l[e]?.[0]??f)(...t)})();
2
+ import{resolve as e,dirname as t}from"path";import{readFileSync as r,writeFileSync as i}from"fs";import{createStore as a}from"tinybase";import{createTools as s}from"tinybase/tools";import{fileURLToPath as n}from"url";const o=JSON.parse,m=Object,c="provide a valid schemaFile, storeName, and outputDir",p=(...e)=>{return t=e=>process.stdout.write(e+"\n"),e.forEach(t);var t},f=e=>process.stderr.write(`ERROR: ${e}\n`),d=e=>o(r(e,"utf8")),l=(t,r,a,s)=>{const n=e(t,r);p(s.padStart(23)+": "+n),i(n,a,"utf8")},u=e=>{const t=d(e);return s(a().setSchema(...(r=t,Array.isArray(r)?t:[t])));var r},h=()=>{var e,t;p("","tinybase <command>","","Usage:",""),e=y,t=([,e,t],r)=>p(` tinybase ${r} ${e}`," - "+t,""),((e,t)=>{e.map(t)})(m.entries(e),(([e,r])=>t(r,e))),p("See also http://tinybase.org/guides/developer-tools/command-line/","")},y={help:[h,"","print this message"],version:[()=>p(d(e(t(n(import.meta.url)),"../package.json")).version),"","get the current TinyBase version"],getStoreApi:[async(e,t,r)=>{try{const[i,a,s,n]=await u(e).getPrettyStoreApi(t);l(r,t+".d.ts",i,"Definition"),l(r,t+".ts",a,"Implementation"),l(r,t+"-ui-react.d.ts",s,"UI React definition"),l(r,t+"-ui-react.tsx",n,"UI React implementation")}catch{f(c)}},"<schemaFile> <storeName> <outputDir>","generate .d.ts, .ts, and .tsx API files from a schema file"],getStoreRefinement:[async(e,t,r)=>{try{const[i,a]=await u(e).getPrettyStoreRefinement(t);l(r,t+"-refinement.d.ts",i,"Definition"),l(r,t+"-ui-react-refinement.d.ts",a,"UI React definition")}catch{f(c)}},"<schemaFile> <storeName> <outputDir>","generate .d.ts refinement files from a schema file"]};(()=>{const[,,e,...t]=process.argv;(y[e]?.[0]??h)(...t)})();
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",r="default",s="Listener",d="get",$="add",c="Ids",i="Table",u=i+"s",I=i+c,b="Row",h=b+c,p="Sorted"+b+c,g="Cell",f=g+c,w="Value",C=w+"s",m=w+c,v=(e,t)=>e.every(t),y=(e,t)=>e.sort(t),R=(e,t)=>e.forEach(t),S=(e,t)=>e.map(t),k=e=>e.length,V=e=>0==k(e),x=(e,t)=>e.filter(t),O=(e,...t)=>e.push(...t),D=e=>e.pop(),T=(e,...t)=>e.unshift(...t),A=e=>e.shift(),N=JSON.parse,P=isFinite,j=(e,t)=>e instanceof t,E=e=>null==e,M=e=>e==l||e==a,z=t=>e(t)==l,G=e=>Array.isArray(e),J=t=>{const l=e(t);return M(l)||l==n&&P(t)?l:void 0},L=(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)=>S([...e?.entries()??[]],(([e,l])=>t(l,e))),Q=(e,t,l)=>E(l)?(F(e,t),e):e?.set(t,l),q=(e,t,l)=>(L(e,t)||Q(e,t,l()),_(e,t)),K=e=>e.toUpperCase(),X=e=>e.toLowerCase(),Y="a ",ee="A function for",te="Callback",le="Del",ae="export",ne="Id",oe="Invalid",re="Json",se=X(s),de=" | undefined",$e="Partial",ce=`Registers a ${se} that will be called`,ie="Represents",ue="Set",Ie="[]",be="the Store",he="Transaction",pe=X(he),ge="the end of the "+pe,fe="void",we=" => "+fe,Ce=Y+"string serialization of",me=" ",ve="Gets a callback that can ",ye="the ",Re=(e=0,l=0)=>`the ${Je[e]}content of`+(l?me+be:t),Se=(e=0,l,a=0)=>ze[l]+me+Re(e,1)+(a?" when set":t),ke=(e,t=0)=>ie+` a Row when ${t?"s":"g"}etting ${Re()} the '${e}' `+i,Ve=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,xe=(e,t)=>`Calls a function for each ${e} in `+t,Oe=e=>"A function that takes "+e,De=(e,t=0)=>ee+" listening to changes to "+Ge[e]+" in "+Ge[t],Te=(e,l,a=0)=>ce+" whenever "+Ge[e]+" in "+Ge[l]+" change"+(a?t:"s"),Ae=e=>`the '${e}' `+i,Ne=e=>"the specified Row in "+Ae(e),Pe=(e,t=0)=>ze[t]+` ${Re()} `+Ae(e),je=(e,t=0)=>ze[t]+` ${Re()} `+Ne(e),Ee=(e,t,l=0)=>ze[l]+` the '${t}' Cell for `+Ne(e),Me=(e,t=0)=>ze[t]+` the '${e}' Value`,ze=["Gets","Checks existence of","Sets","Deletes","Sets part of",ie,"Gets "+Ce,"Sets "+Ce,ce+" whenever",ve+"set",ve+"add",ve+"set part of",ve+"delete"],Ge=[be,u,ye+i+me+c,Y+i,ye+b+me+c,Y+b,ye+g+me+c,Y+g,"invalid Cell changes",C,ye+w+me+c,Y+w,"invalid Value changes",ye+"sorted "+b+me+c],Je=[t,"tabular ","keyed value "],Le=e=>new Set(G(e)||E(e)?e:[e]),We=(e,t)=>e?.add(t),Be=/[^A-Za-z]+/,Fe=/[^A-Za-z0-9]+/,Ue=/^( *)\/\*\* *(.*?) *\*\/$/gm,_e=(e,t,l)=>e.substring(t,l),Ze=e=>e.includes(","),He=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return L(e,n)?He(e,t,l,a+1):(Q(e,n,l),n)},Qe=e=>e.replace(Ue,((e,t,l)=>{const a=77-qe(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),qe=e=>e.length,Ke=(e,l=t)=>e.join(l),Xe=e=>e.flat(1e3),Ye=(e,t=0)=>Ke(S(e.split(Fe),((e,l)=>(l>0||t?K:X)(_e(e,0,1))+_e(e,1)))),et=e=>K(Ke((e&&!Be.test(e[0])?e:" "+e).split(Fe),"_")),tt=e=>`/** ${e}. */`,lt=(...e)=>Ke(x(e,(e=>e)),", "),at=()=>{const e=[U(),U(),U(),U()],l=U(),a=U();return[(...e)=>Ke(Xe(e),"\n"),(t,l,...a)=>R(a,(a=>R([0,1],(n=>(t??n)==n?We(q(e[n],l,Le),a):0)))),(e,t,a)=>He(l,e,[t,a]),(e,t,l)=>He(a,e,G(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>_(a,e)===t?e:He(a,e,t),(l=0)=>S([...y(H(e[l],((e,t)=>`import {${Ke(y(W(e)),", ")}} from '${t}';`)),((e,t)=>Ze(e)!=Ze(t)?Ze(e)?-1:1:e>t?1:-1)),t],(e=>e.replace("{React}","React"))),()=>H(l,(([e,l],a)=>[tt(l),`${ae} type ${a} = ${e};`,t])),()=>H(a,((e,l)=>(e=G(e)?e:[e],O(e,D(e)+";"),[`const ${l} = ${A(e)}`,e,t])))]},nt=Object,ot=nt.keys,rt=nt.freeze,st=e=>j(e,nt)&&e.constructor==nt,dt=(e,t)=>S(nt.entries(e),(([e,l])=>t(l,e))),$t=e=>st(e)&&V(ot(e)),ct=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},it=(e,t,l)=>[t=>dt(e,((e,a)=>t(a,Ye(a,1),l(et(a),`'${a}'`)))),(t,a)=>dt(e[t],((e,t)=>a(t,e[o],e[r],l(et(t),`'${t}'`),Ye(t,1)))),e=>dt(t,((t,a)=>e(a,t[o],t[r],l(et(a),`'${a}'`),Ye(a,1))))],ut=[d,"has","set","del","set","forEach",$,t],It=(e,l=t,a=t)=>`store.${e}(${l})`+(a?" as "+a:t),bt=(e,l=t)=>`fluent(() => ${It(e,l)})`,ht=(e,l=t,a=t)=>`store.${e}(${l?l+", ":t}proxy(listener)${a?", "+a:t})`,pt=(e,l,n)=>{const[d,v,y,S,k,V,x,D]=at(),[A,N,P]=it(e,l,k),j=U(),M=(e=0)=>H(j,(([l,a,n,o,r],s)=>{const d=e?[s+`: ${r}(${l}): ${a} => ${n},`]:[s+r+`(${l}): ${a};`];return e||T(d,tt(o)),O(d,t),d})),G=(e,l,a,n,o,r=t)=>He(j,e,[l,a,n,o,r]),J=(e,l,a,n,o,r=t,s=t,d=t)=>G(ut[e]+l+(4==e?$e:t)+a,r,n,(n==F?bt:It)(ut[e]+(4==e?$e:t)+a,s,e?void 0:n),o,d),L=(e,l,a,n=t,o=t,r=1)=>G($+e+s,(n?n+", ":t)+se+": "+l+(r?", mutator?: boolean":t),ne,ht($+e+s,o,r?"mutator":t),a),B=`./${Ye(n)}.d`,F=Ye(n,1),q=Ye(F),K=[],X=U();let le=[],ue=[];if(v(1,B,F,`create${F} as create${F}Decl`),!$t(e)){const e=U();A(((l,a)=>{const n=[y(a+i,`{[rowId: Id]: ${a}Row}`,ie+` the '${l}' `+i),y(a+b,`{${Ke(N(l,((e,l,a)=>`'${e}'${E(a)?"?":t}: ${l};`))," ")}}`,ke(l)),y(a+b+"WhenSet",`{${Ke(N(l,((e,t)=>`'${e}'?: ${t};`))," ")}}`,ke(l,1)),y(a+g+ne,Ke(N(l,(e=>`'${e}'`))," | "),`A Cell Id for the '${l}' `+i),y(a+g+te,`(...[cellId, cell]: ${Ke(N(l,((e,t)=>`[cellId: '${e}', cell: ${t}]`))," | ")})`+we,Oe(`a Cell Id and value from a Row in the '${l}' `+i)),y(a+b+te,`(rowId: Id, forEachCell: (cellCallback: ${a}CellCallback)`+we+")"+we,Oe(`a Row Id from the '${l}' Table, and a Cell iterator`))];Q(e,l,n),v(1,B,...n)}));const l=y(u,`{${Ke(A((t=>`'${t}'?: ${_(e,t)?.[0]};`))," ")}}`,Se(1,5)),n=y(i+ne,Ke(A((e=>`'${e}'`))," | "),"A "+i+" Id in "+be),d=y(i+te,`(...[tableId, rowCallback]: ${Ke(A((t=>`[tableId: '${t}', forEachRow: (rowCallback: ${_(e,t)?.[5]})${we}]`))," | ")})`+we,Oe(Y+i+" Id, and a Row iterator")),$=y("GetCellChange",`(...[tableId, rowId, cellId]: ${Ke(A((t=>`[tableId: '${t}', rowId: Id, cellId: ${_(e,t)?.[3]}]`))," | ")}) => CellChange`,ee+" returning information about any Cell's changes during a "+pe),w=y(u+s,`(${q}: ${F}, getCellChange: ${$}${de})`+we,De(1)),C=y(I+s,`(${q}: ${F})`+we,De(2)),m=y(i+s,`(${q}: ${F}, tableId: ${n}, getCellChange: ${$}${de})`+we,De(3)),S=y(h+s,`(${q}: ${F}, tableId: ${n})`+we,De(4,3)),V=y(p+s,"("+lt(q+": "+F,"tableId: "+n,"cellId: Id"+de,"descending: boolean","offset: number","limit: number"+de,"sortedRowIds: Ids")+")"+we,De(13,3)),x=y(b+s,`(${q}: ${F}, tableId: ${n}, rowId: Id, getCellChange: ${$}${de})`+we,De(5,3)),D=y(f+s,`(${q}: ${F}, tableId: ${n}, rowId: Id)`+we,De(6,5)),T=y(g+s,`(...[${q}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${Ke(Xe(A((e=>N(e,((t,l)=>`[${q}: ${F}, tableId: '${e}', rowId: Id, cellId: '${t}', newCell: ${l}${de}, oldCell: ${l}${de}, getCellChange: ${$} | undefined]`)))))," | ")})`+we,De(7,5)),P=y(oe+g+s,`(${q}: ${F}, tableId: Id, rowId: Id, cellId: Id, invalidCells: any[])`+we,De(8));le=[l,n,w,C,m,S,V,x,D,T,e],R([[l],[a],[F,"tables: "+l,"tables"],[F]],(([e,l,a],n)=>J(n,t,u,e,Se(1,n),l,a))),J(0,t,I,n+Ie,Ve(i,be)),J(5,t,i,fe,xe(i,be),"tableCallback: "+d,"tableCallback as any"),A(((l,n,o)=>{const[r,s,d,$,u,I]=_(e,l);R([[r],[a],[F,"table: "+r,", table"],[F]],(([e,a,r=t],s)=>J(s,n,i,e,Pe(l,s),a,o+r))),J(0,n,h,c,Ve(b,Ae(l)),t,o),J(0,n,p,c,Ve(b,Ae(l),1),"cellId?: "+$+", descending?: boolean, offset?: number, limit?: number",o+", cellId, descending, offset, limit"),J(5,n,b,fe,xe(b,Ae(l)),"rowCallback: "+I,o+", rowCallback as any"),R([[s],[a],[F,", row: "+d,", row"],[F],[F,", partialRow: "+d,", partialRow"]],(([e,a=t,r=t],s)=>J(s,n,b,e,je(l,s),"rowId: Id"+a,o+", rowId"+r))),J(6,n,b,ne+de,"Adds a new Row to "+Ae(l),"row: "+d,o+", row"),J(0,n,f,$+Ie,Ve(g,Ne(l)),"rowId: "+ne,o+", rowId"),J(5,n,g,fe,xe(g,Ne(l)),"rowId: Id, cellCallback: "+u,o+", rowId, cellCallback as any"),N(l,((e,r,s,d,$)=>{const c="Map"+Ye(r,1);Q(X,r,c);const i=r+(E(s)?de:t);R([[i],[a],[F,`, cell: ${r} | `+c,", cell as any"],[F]],(([a,r=t,s=t],c)=>J(c,n+$,g,a,Ee(l,e,c),"rowId: Id"+r,o+", rowId, "+d+s)))}))})),J(0,t,u+re,re,Se(1,6)),J(2,t,u+re,F,Se(1,7),"tablesJson: "+re,"tables"+re),L(u,w,Se(1,8)+" changes"),L(I,C,Te(2,0,1)),L(i,m,Te(3,0),`tableId: ${n} | null`,"tableId"),L(h,S,Te(4,3,1),`tableId: ${n} | null`,"tableId"),L(p,V,Te(13,3,1),lt("tableId: "+n,"cellId: Id"+de,"descending: boolean","offset: number","limit: number"+de),lt("tableId","cellId","descending","offset","limit")),L(b,x,Te(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),L(f,D,Te(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),L(g,T,Te(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${Ke(A((l=>_(e,l)?.[3]??t))," | ")} | null`,"tableId, rowId, cellId"),L(oe+g,P,ce+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),v(1,B,l,n,d,w,C,m,S,V,x,D,T,P,...W(X)),v(0,"tinybase","CellChange"),O(K,".setTablesSchema({",Xe(A(((e,l,a)=>[`[${a}]: {`,...N(e,((e,l,a,n)=>`[${n}]: {[${k(et(o),`'${o}'`)}]: ${k(et(l),`'${l}'`)}${E(a)?t:`, [${k(et(r),`'${r}'`)}]: `+(z(a)?k(et(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!$t(l)){const e=y(C,"{"+Ke(P(((e,l,a)=>`'${e}'${E(a)?"?":t}: ${l};`))," ")+"}",Se(2,5)),l=y(C+"WhenSet","{"+Ke(P(((e,t)=>`'${e}'?: ${t};`))," ")+"}",Se(2,5,1)),n=y(w+ne,Ke(P((e=>`'${e}'`))," | "),"A Value Id in "+be),d=y(w+te,`(...[valueId, rowCallback]: ${Ke(P(((e,t)=>`[valueId: '${e}', value: ${t}]`))," | ")})`+we,Oe("a Value Id, and value")),$=y("GetValueChange",`(valueId: ${n}) => ValueChange`,ee+" returning information about any Value's changes during a "+pe),c=y(C+s,`(${q}: ${F}, getValueChange: ${$}${de})`+we,De(9)),i=y(m+s,`(${q}: ${F})`+we,De(10)),u=y(w+s,`(...[${q}, valueId, newValue, oldValue, getValueChange]: ${Ke(P(((e,t)=>`[${q}: ${F}, valueId: '${e}', newValue: ${t}${de}, oldValue: ${t}${de}, getValueChange: ${$} | undefined]`))," | ")})`+we,De(11)),I=y(oe+w+s,`(${q}: ${F}, valueId: Id, invalidValues: any[])`+we,De(12));ue=[e,l,n,c,i,u],R([[e],[a],[F,"values: "+l,"values"],[F],[F,"partialValues: "+l,"partialValues"]],(([e,l,a],n)=>J(n,t,C,e,Se(2,n),l,a))),J(0,t,m,n+Ie,Ve(w,be)),J(5,t,w,"void",xe(w,be),"valueCallback: "+d,"valueCallback as any"),P(((e,l,n,o,r)=>{const s="Map"+Ye(l,1);Q(X,l,s),R([[l],[a],[F,`value: ${l} | `+s,", value as any"],[F]],(([l,a,n=t],s)=>J(s,r,w,l,Me(e,s),a,o+n)))})),J(0,t,C+re,re,Se(2,6)),J(2,t,C+re,F,Se(2,7),"valuesJson: "+re,"values"+re),L(C,c,Se(2,8)+" changes"),L(m,i,Te(10,0,1)),L(w,u,Te(11,0),`valueId: ${n} | null`,"valueId"),L(oe+w,I,ce+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),v(1,B,e,l,n,d,c,i,u,I),v(0,"tinybase","ValueChange"),O(K,".setValuesSchema({",P(((e,l,a,n)=>[`[${n}]: {[${k(et(o),`'${o}'`)}]: ${k(et(l),`'${l}'`)}${E(a)?t:`, [${k(et(r),`'${r}'`)}]: `+(z(a)?k(et(a),`'${a}'`):a)}},`])),"})")}Z(X,((e,t)=>y(t,`(cell: ${e}${de}) => `+e,`Takes a ${e} Cell value and returns another`))),v(null,"tinybase","DoRollback",ne,"IdOrNull",c,re,"Store");const Ce=y(he+s,`(${q}: ${F}, cellsTouched: boolean, valuesTouched: boolean)`+we,ee+" listening to the completion of a "+pe);return J(0,t,re,re,Se(0,6)),J(2,t,re,F,Se(0,7),"json: "+re,"json"),J(7,t,pe,"Return","Execute a "+pe+" to make multiple mutations","actions: () => Return, doRollback?: DoRollback","actions, doRollback","<Return>"),J(7,t,"start"+he,F,"Explicitly starts a "+pe),J(7,t,"finish"+he,F,"Explicitly finishes a "+pe,"doRollback?: DoRollback,","doRollback"),L("WillFinish"+he,Ce,ce+" just before "+ge,t,t,0),L("DidFinish"+he,Ce,ce+" just after "+ge,t,t,0),J(7,t,"call"+s,F,"Manually provoke a listener to be called","listenerId: Id","listenerId"),J(3,t,s,F,"Remove a listener that was previously added to "+be,"listenerId: Id","listenerId"),G("getStore",t,"Store","store",ze[0]+" the underlying Store object"),v(1,"tinybase","createStore"),v(1,B,F,`create${F} as create${F}Decl`,Ce),k("store",["createStore()",...K]),S("fluent","actions: () => Store",["actions();",`return ${q};`]),S("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),k(q,["{",...M(1),"}"]),[d(...V(0),...x(),ae+" interface "+F+" {",...M(0),"}",t,tt(`Creates a ${F} object`),ae+" function create"+F+"(): "+F+";"),d(...V(1),ae+" const create"+F+": typeof create"+F+"Decl = () => {",...D(),`return Object.freeze(${q});`,"};"),le,ue]},gt="Deps",ft=e=>d+e,wt=e=>lt(ft(e),ft(e)+gt),Ct="Parameter",mt=": (parameter: "+Ct+", store: Store) => ",vt="const contextValue = useContext(Context);",yt=", and registers a listener so that any changes to that result will cause a re-render",Rt=", based on a parameter",St=": ",kt=Ct+"ized"+te+"<"+Ct+">",Vt="<"+Ct+",>",xt=gt+"?: React.DependencyList",Ot="then"+xt,Dt="then?: (store: Store",Tt=lt(Dt+")"+we,Ot),At="then, then"+gt,Nt="rowId",Pt=Nt+St+ne,jt=(e,...t)=>lt(...t,se+": "+e,se+xt,"mutator?: boolean"),Et=(...e)=>lt(...e,se,se+gt,"mutator"),Mt=(e,l,a,n,o)=>{const[r,d,$,v,y,R,S,k]=at(),[V,x,D]=it(e,l,y),A=`./${Ye(a)}.d`,N=`./${Ye(a)}-ui-react.d`,P="tinybase/ui-react",j=Ye(a,1),M=Ye(j),z=j+"Or"+j+ne,J=M+"Or"+j+ne,L=U(),W=(e,l,a,n,o,r=t)=>(d(1,N,e+" as "+e+"Decl"),He(L,e,[l,a,G(n)?["{",n,"}"]:n,o,r])),B=(e,l,a,n,o,r=t)=>W("use"+e,l,a,n,o,r),F=(e,l,a,n,o=t,r=t,s=t,$=t,c=t)=>{d(1,P,`use${l} as use${l}Core`),B(e,lt(o,X,$),a,ee+`(${J}, use${l}Core, [`+(r||t)+(c?"], ["+c:t)+"])",n,s)},Z=(e,t,l,a)=>W(e,t,1,l,a),Q=(e=0)=>H(L,(([l,a,n,o,r],s)=>{const d=e?[ae+` const ${s}: typeof ${s}Decl = ${r}(${l}): ${1==a?"any":a} =>`,n]:[ae+` function ${s}${r}(${l}): ${1==a?"ComponentReturnType":a};`];return e||T(d,tt(o)),O(d,t),d}));d(null,"tinybase",ne,c,"IdOrNull","Store",te,Ct+"ized"+te),d(0,P,"ComponentReturnType"),d(0,A,j);const q=$(z,j+" | "+ne,`Used when you need to refer to a ${j} in a React hook or component`),K=$("ProviderProps",`{readonly ${M}?: ${j}; readonly ${M}ById?: {[${M}Id: Id]: ${j}}}`,`Used with the Provider component, so that a ${j} can be passed into the context of an application`);d(1,"react","React"),d(1,N,q,K);const X=J+"?: "+q;y("{createContext, useContext, useMemo}","React"),y("Context",`createContext<[${j}?, {[${M}Id: Id]: ${j}}?]>([])`),B("Create"+j,`create: () => ${j}, create`+xt,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+de,[vt,"return id == null ? contextValue[0] : contextValue[1]?.[id];"],`Get a reference to a ${j} from within a Provider component context`),ee=v("useHook",J+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${M} = ${Y}(${J} as Id);`,`return hook(...preParams, ((${J} == null || typeof ${J} == 'string')`,`? ${M} : ${J})?.getStore(), ...postParams)`]);if(!$t(e)){const[e,l,a,o,r,$,w,C,m,v,y]=n;d(null,A,e,l,a,o,r,$,w,C,m,v),d(1,P),d(1,A,j),F(u,u,e,Se(1,0)+yt),F(I,I,l+Ie,Ve(i,be)+yt),F(ue+u+te,ue+u+te,kt,Se(1,9)+Rt,lt(ft(u)+mt+e,ft(u)+xt),wt(u),Vt,lt(Dt,`tables: ${e})`+we,Ot),At),F(le+u+te,le+u+te,te,Se(1,12),t,t,t,Tt,At),V(((e,l,a)=>{const[n,o,r,s]=_(y,e);d(0,A,n,o,r,s),d(1,A,n,o,r,s),F(l+i,i,n,Pe(e)+yt,t,a),F(l+h,h,c,Ve(b,Ae(e))+yt,t,a),F(l+p,p,c,Ve(b,Ae(e),1)+yt,"cellId?: "+s+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit"),F(l+b,b,o,je(e)+yt,Pt,lt(a,Nt)),F(l+f,f,s+Ie,Ve(g,Ne(e))+yt,Pt,lt(a,Nt)),F(ue+l+i+te,ue+i+te,kt,Pe(e,9)+Rt,lt(ft(i)+mt+n,ft(i)+xt),lt(a,wt(i)),Vt,lt(Dt,`table: ${n})`+we,Ot),At),F(le+l+i+te,le+i+te,te,Pe(e,12),t,a,t,Tt,At),F(ue+l+b+te,ue+b+te,kt,je(e,9)+Rt,lt(Pt,ft(b)+mt+r,ft(b)+xt),lt(a,Nt,wt(b)),Vt,lt(Dt,`row: ${r})`+we,Ot),At),F("Add"+l+b+te,"Add"+b+te,kt,je(e,10)+Rt,lt(ft(b)+mt+r,ft(b)+xt),lt(a,wt(b)),Vt,"then?: ("+lt(Pt+de,"store: Store","row: "+r+")"+we,"then"+xt),At),F(ue+l+$e+b+te,ue+$e+b+te,kt,je(e,11)+Rt,lt(Pt,ft($e+b)+mt+r,ft($e+b)+xt),lt(a,Nt,wt($e+b)),Vt,lt(Dt,`partialRow: ${r})`+we,Ot),At),F(le+l+b+te,le+b+te,te,je(e,12),Pt,lt(a,Nt),t,Tt,At),x(e,((n,o,r,s,$)=>{const c="Map"+Ye(o,1);d(0,A,c),d(1,A,c),F(l+$+g,g,o+(E(r)?de:t),Ee(e,n)+yt,Pt,lt(a,Nt,s)),F(ue+l+$+g+te,ue+g+te,kt,Ee(e,n,9)+Rt,lt(Pt,ft(g)+mt+o+" | "+c,ft(g)+xt),lt(a,Nt,s,wt(g)),Vt,lt(Dt,`cell: ${o} | ${c})`+we,Ot),At),F(le+l+$+g+te,le+g+te,te,Ee(e,n,12),lt(Pt,"forceDel?: boolean"),lt(a,Nt,s,"forceDel"),t,Tt,At)}))}));const R=Ke(V((e=>_(y,e)?.[3]??t))," | ");F(u+s,u+s,fe,Se(1,8)+" changes",jt(a),Et()),F(I+s,I+s,fe,Te(2,0,1),jt(o),Et()),F(i+s,i+s,fe,Te(3,0),jt(r,`tableId: ${l} | null`),Et("tableId")),F(h+s,h+s,fe,Te(4,3,1),jt($,`tableId: ${l} | null`),Et("tableId")),F(p+s,p+s,fe,Te(13,3,1),jt(w,`tableId: ${l} | null`,"cellId: "+R+de,"descending: boolean","offset: number","limit: number"+de),Et("tableId","cellId","descending","offset","limit")),F(b+s,b+s,fe,Te(5,3),jt(C,`tableId: ${l} | null`,Nt+": IdOrNull"),Et("tableId",Nt)),F(f+s,f+s,fe,Te(6,5,1),jt(m,`tableId: ${l} | null`,Nt+": IdOrNull"),Et("tableId",Nt)),F(g+s,g+s,fe,Te(7,5),jt(v,`tableId: ${l} | null`,Nt+": IdOrNull",`cellId: ${R} | null`),Et("tableId",Nt,"cellId"))}if(!$t(l)){const[e,l,a,n,r,$]=o;d(null,A,...o),F(C,C,e,Se(2,0)+yt),F(m,m,a+Ie,Ve(w,be)+yt),F(ue+C+te,ue+C+te,kt,Se(2,9)+Rt,lt(ft(C)+mt+l,ft(C)+xt),wt(C),Vt,lt(Dt,`values: ${l})`+we,Ot),At),F(ue+$e+C+te,ue+$e+C+te,kt,Se(2,11)+Rt,lt(ft($e+C)+mt+l,ft($e+C)+xt),wt($e+C),Vt,lt(Dt,`partialValues: ${l})`+we,Ot),At),F(le+C+te,le+C+te,te,Se(2,12),t,t,t,Tt,At),D(((e,l,a,n,o)=>{const r="Map"+Ye(l,1);d(0,A,r),d(1,A,r),F(o+w,w,l,Me(e)+yt,t,n),F(ue+o+w+te,ue+w+te,kt,Me(e,9)+Rt,lt(ft(w)+mt+l+" | "+r,ft(w)+xt),lt(n,wt(w)),Vt,lt(Dt,`value: ${l} | ${r})`+we,Ot),At),F(le+o+w+te,le+w+te,te,Me(e,12),t,n,t,Tt,At)})),F(C+s,C+s,fe,Se(2,8)+" changes",jt(n),Et()),F(m+s,m+s,fe,Te(10,0,1),jt(r),Et()),F(w+s,w+s,fe,Te(11,0),jt($,`valueId: ${a} | null`),Et("valueId"))}return Z("Provider",`{${M}, ${M}ById, children}: `+K+" & {children: React.ReactNode}",[vt,"return (","<Context.Provider","value={useMemo(",`() => [${M} ?? contextValue[0], {...contextValue[1], ...${M}ById}],`,`[${M}, ${M}ById, contextValue],`,")}>","{children}","</Context.Provider>",");"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...R(0),...S(),...Q(0)),r(...R(1),...k(),...Q(1))]},zt=(e,l,a)=>{if($t(e)&&$t(l))return[t,t,t,t];const[n,o,r,s]=pt(e,l,a);return[n,o,...Mt(e,l,a,r,s)]},Gt={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Jt=ct((e=>{const t=()=>{const t=N(e.getTablesSchemaJson());return!$t(t)||v(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=U();if(v(a,(t=>v(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),r=q(n,a,(()=>[J(o),U(),[0],0])),[s,d,[$]]=r,c=q(d,o,(()=>0))+1;return c>$&&(r[2]=[c,o]),Q(d,o,c),r[3]++,s==J(o)})))))return t[l]={},B(n,(([e,,[,n],s],d)=>{t[l][d]={[o]:e,...s==k(a)?{[r]:n}:{}}})),1}))?t:{}},l=()=>{const t=N(e.getValuesSchemaJson());return $t(t)&&e.forEachValue(((e,l)=>{t[e]={[o]:J(l)}})),t},a=e=>zt(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 S(a(e),((e,a)=>Qe(l(e,{...Gt,filepath:"_."+t[a]}))))};return rt({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,r)=>{l++;let s=0,d=0;const $={};r(((e,l)=>{s++;let a=0;l((()=>a++)),d+=a,t&&($[e]={rowCells:a})})),a+=s,n+=d,t&&(o[e]={tableRows:s,tableCells:d,rows:$})})),{totalTables:l,totalRows:a,totalCells:n,totalValues:k(e.getValueIds()),jsonLength:qe(e.getJson()),...t?{detail:{tables:o}}:{}}},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=Jt;
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;
Binary file
@@ -272,9 +272,9 @@ export interface Tools {
272
272
  getStoreValuesSchema(): ValuesSchema;
273
273
 
274
274
  /**
275
- * The getStoreApi method returns code-generated .d.ts and .ts(x) files that
276
- * describe the schema of a Store and React bindings (since v3.1.0) in an ORM
277
- * style.
275
+ * The getStoreApi method returns code-generated `.d.ts` and `.ts(x)` files
276
+ * that describe the schema of a Store and React bindings (since v3.1.0) in an
277
+ * ORM style.
278
278
  *
279
279
  * If the Store does not already have an explicit TablesSchema or ValuesSchema
280
280
  * associated with it, the data in the Store will be scanned to attempt to
@@ -290,12 +290,12 @@ export interface Tools {
290
290
  * - `[storeName]-ui-react.d.ts`
291
291
  * - `[storeName]-ui-react.tsx`
292
292
  *
293
- * Also you should save these alongside each other so that the .ts(x) files
294
- * can import types from the .d.ts files.
293
+ * Also you should save these alongside each other so that the `.ts(x)` files
294
+ * can import types from the `.d.ts` files.
295
295
  *
296
- * The .d.ts and .ts(x) files that are generated are designed to resemble the
297
- * main TinyBase Store and React binding files, but provide named types and
298
- * methods that describe the domain of the schema in the store.
296
+ * The `.d.ts` and `.ts(x)` files that are generated are designed to resemble
297
+ * the main TinyBase Store and React binding files, but provide named types
298
+ * and methods that describe the domain of the schema in the Store.
299
299
  *
300
300
  * For example, from a Store that has a `pets` Table, you will get methods
301
301
  * like `getPetsTable`, types like `PetsRow`, and hooks and components that
@@ -342,14 +342,12 @@ export interface Tools {
342
342
  * price: {type: 'number'},
343
343
  * },
344
344
  * });
345
- * const [dTs, ts, dTsUiReact, tsUiReact] =
345
+ * const [dTs, ts, uiReactDTs, uiReactTsx] =
346
346
  * createTools(store).getStoreApi('shop');
347
347
  *
348
348
  * const dTsLines = dTs.split('\n');
349
349
  * console.log(dTsLines[3]);
350
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
351
- * console.log(dTsLines[6]);
352
- * // -> 'export type PetsRow = {\'price\'?: number;};'
350
+ * // -> `export type Tables = {'pets'?: {[rowId: Id]: {'price'?: number}}};`
353
351
  *
354
352
  * const tsLines = ts.split('\n');
355
353
  * console.log(tsLines[39]);
@@ -363,14 +361,12 @@ export interface Tools {
363
361
  * fido: {price: 5},
364
362
  * felix: {price: 4},
365
363
  * });
366
- * const [dTs, ts, dTsUiReact, tsUiReact] =
364
+ * const [dTs, ts, uiReactDTs, uiReactTsx] =
367
365
  * createTools(store).getStoreApi('shop');
368
366
  *
369
367
  * const dTsLines = dTs.split('\n');
370
368
  * console.log(dTsLines[3]);
371
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
372
- * console.log(dTsLines[6]);
373
- * // -> 'export type PetsRow = {\'price\': number;};'
369
+ * // -> `export type Tables = {'pets'?: {[rowId: Id]: {'price': number}}};`
374
370
  *
375
371
  * const tsLines = ts.split('\n');
376
372
  * console.log(tsLines[41]);
@@ -382,9 +378,9 @@ export interface Tools {
382
378
  getStoreApi(storeName: string): [string, string, string, string];
383
379
 
384
380
  /**
385
- * The getPrettyStoreApi method attempts to returns a prettified
386
- * code-generated .d.ts and .ts(x) files that describe the schema of a Store
387
- * and React bindings (since v3.1.0) in an ORM style.
381
+ * The getPrettyStoreApi method attempts to return prettified code-generated
382
+ * `.d.ts` and `.ts(x)` files that describe the schema of a Store and React
383
+ * bindings (since v3.1.0) in an ORM style.
388
384
  *
389
385
  * This is simply a wrapper around the getStoreApi method that attempts to
390
386
  * invoke the `prettier` module (which it hopes you have installed) to format
@@ -403,8 +399,8 @@ export interface Tools {
403
399
  * - `[storeName]-ui-react.d.ts`
404
400
  * - `[storeName]-ui-react.tsx`
405
401
  *
406
- * Also you should save these alongside each other so that the .ts(x) files
407
- * can import types from the .d.ts files.
402
+ * Also you should save these alongside each other so that the `.ts(x)` files
403
+ * can import types from the `.d.ts` files.
408
404
  *
409
405
  * See the documentation for the getStoreApi method for details of the content
410
406
  * of the generated files.
@@ -423,18 +419,16 @@ export interface Tools {
423
419
  * },
424
420
  * });
425
421
  * const tools = createTools(store);
426
- * const [dTs, ts, dTsUiReact, tsUiReact] = await createTools(
422
+ * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
427
423
  * store,
428
424
  * ).getPrettyStoreApi('shop');
429
425
  *
430
426
  * const dTsLines = dTs.split('\n');
431
427
  * console.log(dTsLines[5]);
432
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
433
- * console.log(dTsLines[10]);
434
- * // -> 'export type PetsRow = {price?: number};'
428
+ * // -> `export type Tables = {pets?: {[rowId: Id]: {price?: number}}};`
435
429
  *
436
430
  * const tsLines = ts.split('\n');
437
- * console.log(tsLines[75]);
431
+ * console.log(tsLines[79]);
438
432
  * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
439
433
  * ```
440
434
  * @example
@@ -446,18 +440,16 @@ export interface Tools {
446
440
  * felix: {price: 4},
447
441
  * });
448
442
  * const tools = createTools(store);
449
- * const [dTs, ts, dTsUiReact, tsUiReact] = await createTools(
443
+ * const [dTs, ts, uiReactDTs, uiReactTsx] = await createTools(
450
444
  * store,
451
445
  * ).getPrettyStoreApi('shop');
452
446
  *
453
447
  * const dTsLines = dTs.split('\n');
454
448
  * console.log(dTsLines[5]);
455
- * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
456
- * console.log(dTsLines[10]);
457
- * // -> 'export type PetsRow = {price: number};'
449
+ * // -> 'export type Tables = {pets?: {[rowId: Id]: {price: number}}};'
458
450
  *
459
451
  * const tsLines = ts.split('\n');
460
- * console.log(tsLines[77]);
452
+ * console.log(tsLines[81]);
461
453
  * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
462
454
  * ```
463
455
  * @category Modelling
@@ -467,6 +459,180 @@ export interface Tools {
467
459
  storeName: string,
468
460
  ): Promise<[string, string, string, string]>;
469
461
 
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
+
470
636
  /**
471
637
  * The getStore method returns a reference to the underlying Store that is
472
638
  * backing this Tools object.
@@ -1 +1 @@
1
- "use strict";const e=e=>typeof e,t="",l=e(t),a=e(!0),n=e(0),o="type",r="default",s="Listener",d="get",c="add",i="Ids",$="Table",u=$+"s",I=$+i,b="Row",h=b+i,p="Sorted"+b+i,f="Cell",g=f+i,v="Value",w=v+"s",C=v+i,m=(e,t)=>e.every(t),y=(e,t)=>e.sort(t),R=(e,t)=>e.forEach(t),S=(e,t)=>e.map(t),k=e=>e.length,V=e=>0==k(e),x=(e,t)=>e.filter(t),O=(e,...t)=>e.push(...t),P=e=>e.pop(),j=(e,...t)=>e.unshift(...t),D=e=>e.shift(),T=JSON.parse,A=isFinite,N=(e,t)=>e instanceof t,E=e=>null==e,M=e=>e==l||e==a,z=t=>e(t)==l,G=e=>Array.isArray(e),J=t=>{const l=e(t);return M(l)||l==n&&A(t)?l:void 0},L=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},W=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},B=(e,t)=>null==e?void 0:e.forEach(t),F=(e,t)=>null==e?void 0:e.delete(t),U=e=>new Map(e),_=(e,t)=>null==e?void 0:e.get(t),Z=(e,t)=>B(e,((e,l)=>t(l,e))),H=(e,t)=>{var l;return S([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},Q=(e,t,l)=>E(l)?(F(e,t),e):null==e?void 0:e.set(t,l),q=(e,t,l)=>(L(e,t)||Q(e,t,l()),_(e,t)),K=e=>e.toUpperCase(),X=e=>e.toLowerCase(),Y="a ",ee="A function for",te="Callback",le="Del",ae="export",ne="Id",oe="Invalid",re="Json",se=X(s),de=" | undefined",ce="Partial",ie=`Registers a ${se} that will be called`,$e="Represents",ue="Set",Ie="[]",be="the Store",he="Transaction",pe=X(he),fe="the end of the "+pe,ge="void",ve=" => "+ge,we=Y+"string serialization of",Ce=" ",me="Gets a callback that can ",ye="the ",Re=(e=0,l=0)=>`the ${Je[e]}content of`+(l?Ce+be:t),Se=(e=0,l,a=0)=>ze[l]+Ce+Re(e,1)+(a?" when set":t),ke=(e,t=0)=>$e+` a Row when ${t?"s":"g"}etting ${Re()} the '${e}' `+$,Ve=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,xe=(e,t)=>`Calls a function for each ${e} in `+t,Oe=e=>"A function that takes "+e,Pe=(e,t=0)=>ee+" listening to changes to "+Ge[e]+" in "+Ge[t],je=(e,l,a=0)=>ie+" whenever "+Ge[e]+" in "+Ge[l]+" change"+(a?t:"s"),De=e=>`the '${e}' `+$,Te=e=>"the specified Row in "+De(e),Ae=(e,t=0)=>ze[t]+` ${Re()} `+De(e),Ne=(e,t=0)=>ze[t]+` ${Re()} `+Te(e),Ee=(e,t,l=0)=>ze[l]+` the '${t}' Cell for `+Te(e),Me=(e,t=0)=>ze[t]+` the '${e}' Value`,ze=["Gets","Checks existence of","Sets","Deletes","Sets part of",$e,"Gets "+we,"Sets "+we,ie+" whenever",me+"set",me+"add",me+"set part of",me+"delete"],Ge=[be,u,ye+$+Ce+i,Y+$,ye+b+Ce+i,Y+b,ye+f+Ce+i,Y+f,"invalid Cell changes",w,ye+v+Ce+i,Y+v,"invalid Value changes",ye+"sorted "+b+Ce+i],Je=[t,"tabular ","keyed value "],Le=e=>new Set(G(e)||E(e)?e:[e]),We=(e,t)=>null==e?void 0:e.add(t),Be=/[^A-Za-z]+/,Fe=/[^A-Za-z0-9]+/,Ue=/^( *)\/\*\* *(.*?) *\*\/$/gm,_e=(e,t,l)=>e.substring(t,l),Ze=e=>e.includes(","),He=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return L(e,n)?He(e,t,l,a+1):(Q(e,n,l),n)},Qe=e=>e.replace(Ue,((e,t,l)=>{const a=77-qe(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),qe=e=>e.length,Ke=(e,l=t)=>e.join(l),Xe=e=>e.flat(1e3),Ye=(e,t=0)=>Ke(S(e.split(Fe),((e,l)=>(l>0||t?K:X)(_e(e,0,1))+_e(e,1)))),et=e=>K(Ke((e&&!Be.test(e[0])?e:" "+e).split(Fe),"_")),tt=e=>`/** ${e}. */`,lt=(...e)=>Ke(x(e,(e=>e)),", "),at=()=>{const e=[U(),U(),U(),U()],l=U(),a=U();return[(...e)=>Ke(Xe(e),"\n"),(t,l,...a)=>R(a,(a=>R([0,1],(n=>(null!=t?t:n)==n?We(q(e[n],l,Le),a):0)))),(e,t,a)=>He(l,e,[t,a]),(e,t,l)=>He(a,e,G(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>_(a,e)===t?e:He(a,e,t),(l=0)=>S([...y(H(e[l],((e,t)=>`import {${Ke(y(W(e)),", ")}} from '${t}';`)),((e,t)=>Ze(e)!=Ze(t)?Ze(e)?-1:1:e>t?1:-1)),t],(e=>e.replace("{React}","React"))),()=>H(l,(([e,l],a)=>[tt(l),`${ae} type ${a} = ${e};`,t])),()=>H(a,((e,l)=>(e=G(e)?e:[e],O(e,P(e)+";"),[`const ${l} = ${D(e)}`,e,t])))]},nt=Object,ot=nt.keys,rt=nt.freeze,st=e=>N(e,nt)&&e.constructor==nt,dt=(e,t)=>S(nt.entries(e),(([e,l])=>t(l,e))),ct=e=>st(e)&&V(ot(e)),it=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},$t=(e,t,l)=>[t=>dt(e,((e,a)=>t(a,Ye(a,1),l(et(a),`'${a}'`)))),(t,a)=>dt(e[t],((e,t)=>a(t,e[o],e[r],l(et(t),`'${t}'`),Ye(t,1)))),e=>dt(t,((t,a)=>e(a,t[o],t[r],l(et(a),`'${a}'`),Ye(a,1))))],ut=[d,"has","set","del","set","forEach",c,t],It=(e,l=t,a=t)=>`store.${e}(${l})`+(a?" as "+a:t),bt=(e,l=t)=>`fluent(() => ${It(e,l)})`,ht=(e,l=t,a=t)=>`store.${e}(${l?l+", ":t}proxy(listener)${a?", "+a:t})`,pt=(e,l,n)=>{const[d,m,y,S,k,V,x,P]=at(),[D,T,A]=$t(e,l,k),N=U(),M=(e=0)=>H(N,(([l,a,n,o,r],s)=>{const d=e?[s+`: ${r}(${l}): ${a} => ${n},`]:[s+r+`(${l}): ${a};`];return e||j(d,tt(o)),O(d,t),d})),G=(e,l,a,n,o,r=t)=>He(N,e,[l,a,n,o,r]),J=(e,l,a,n,o,r=t,s=t,d=t)=>G(ut[e]+l+(4==e?ce:t)+a,r,n,(n==F?bt:It)(ut[e]+(4==e?ce:t)+a,s,e?void 0:n),o,d),L=(e,l,a,n=t,o=t,r=1)=>G(c+e+s,(n?n+", ":t)+se+": "+l+(r?", mutator?: boolean":t),ne,ht(c+e+s,o,r?"mutator":t),a),B=`./${Ye(n)}.d`,F=Ye(n,1),q=Ye(F),K=[],X=U();let le=[],ue=[];if(m(1,B,F,`create${F} as create${F}Decl`),!ct(e)){const e=U();D(((l,a)=>{const n=[y(a+$,`{[rowId: Id]: ${a}Row}`,$e+` the '${l}' `+$),y(a+b,`{${Ke(T(l,((e,l,a)=>`'${e}'${E(a)?"?":t}: ${l};`))," ")}}`,ke(l)),y(a+b+"WhenSet",`{${Ke(T(l,((e,t)=>`'${e}'?: ${t};`))," ")}}`,ke(l,1)),y(a+f+ne,Ke(T(l,(e=>`'${e}'`))," | "),`A Cell Id for the '${l}' `+$),y(a+f+te,`(...[cellId, cell]: ${Ke(T(l,((e,t)=>`[cellId: '${e}', cell: ${t}]`))," | ")})`+ve,Oe(`a Cell Id and value from a Row in the '${l}' `+$)),y(a+b+te,`(rowId: Id, forEachCell: (cellCallback: ${a}CellCallback)`+ve+")"+ve,Oe(`a Row Id from the '${l}' Table, and a Cell iterator`))];Q(e,l,n),m(1,B,...n)}));const l=y(u,`{${Ke(D((t=>{var l;return`'${t}'?: ${null==(l=_(e,t))?void 0:l[0]};`}))," ")}}`,Se(1,5)),n=y($+ne,Ke(D((e=>`'${e}'`))," | "),"A "+$+" Id in "+be),d=y($+te,`(...[tableId, rowCallback]: ${Ke(D((t=>{var l;return`[tableId: '${t}', forEachRow: (rowCallback: ${null==(l=_(e,t))?void 0:l[5]})${ve}]`}))," | ")})`+ve,Oe(Y+$+" Id, and a Row iterator")),c=y("GetCellChange",`(...[tableId, rowId, cellId]: ${Ke(D((t=>{var l;return`[tableId: '${t}', rowId: Id, cellId: ${null==(l=_(e,t))?void 0:l[3]}]`}))," | ")}) => CellChange`,ee+" returning information about any Cell's changes during a "+pe),v=y(u+s,`(${q}: ${F}, getCellChange: ${c}${de})`+ve,Pe(1)),w=y(I+s,`(${q}: ${F})`+ve,Pe(2)),C=y($+s,`(${q}: ${F}, tableId: ${n}, getCellChange: ${c}${de})`+ve,Pe(3)),S=y(h+s,`(${q}: ${F}, tableId: ${n})`+ve,Pe(4,3)),V=y(p+s,"("+lt(q+": "+F,"tableId: "+n,"cellId: Id"+de,"descending: boolean","offset: number","limit: number"+de,"sortedRowIds: Ids")+")"+ve,Pe(13,3)),x=y(b+s,`(${q}: ${F}, tableId: ${n}, rowId: Id, getCellChange: ${c}${de})`+ve,Pe(5,3)),P=y(g+s,`(${q}: ${F}, tableId: ${n}, rowId: Id)`+ve,Pe(6,5)),j=y(f+s,`(...[${q}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${Ke(Xe(D((e=>T(e,((t,l)=>`[${q}: ${F}, tableId: '${e}', rowId: Id, cellId: '${t}', newCell: ${l}${de}, oldCell: ${l}${de}, getCellChange: ${c} | undefined]`)))))," | ")})`+ve,Pe(7,5)),A=y(oe+f+s,`(${q}: ${F}, tableId: Id, rowId: Id, cellId: Id, invalidCells: any[])`+ve,Pe(8));le=[l,n,v,w,C,S,V,x,P,j,e],R([[l],[a],[F,"tables: "+l,"tables"],[F]],(([e,l,a],n)=>J(n,t,u,e,Se(1,n),l,a))),J(0,t,I,n+Ie,Ve($,be)),J(5,t,$,ge,xe($,be),"tableCallback: "+d,"tableCallback as any"),D(((l,n,o)=>{const[r,s,d,c,u,I]=_(e,l);R([[r],[a],[F,"table: "+r,", table"],[F]],(([e,a,r=t],s)=>J(s,n,$,e,Ae(l,s),a,o+r))),J(0,n,h,i,Ve(b,De(l)),t,o),J(0,n,p,i,Ve(b,De(l),1),"cellId?: "+c+", descending?: boolean, offset?: number, limit?: number",o+", cellId, descending, offset, limit"),J(5,n,b,ge,xe(b,De(l)),"rowCallback: "+I,o+", rowCallback as any"),R([[s],[a],[F,", row: "+d,", row"],[F],[F,", partialRow: "+d,", partialRow"]],(([e,a=t,r=t],s)=>J(s,n,b,e,Ne(l,s),"rowId: Id"+a,o+", rowId"+r))),J(6,n,b,ne+de,"Adds a new Row to "+De(l),"row: "+d,o+", row"),J(0,n,g,c+Ie,Ve(f,Te(l)),"rowId: "+ne,o+", rowId"),J(5,n,f,ge,xe(f,Te(l)),"rowId: Id, cellCallback: "+u,o+", rowId, cellCallback as any"),T(l,((e,r,s,d,c)=>{const i="Map"+Ye(r,1);Q(X,r,i);const $=r+(E(s)?de:t);R([[$],[a],[F,`, cell: ${r} | `+i,", cell as any"],[F]],(([a,r=t,s=t],i)=>J(i,n+c,f,a,Ee(l,e,i),"rowId: Id"+r,o+", rowId, "+d+s)))}))})),J(0,t,u+re,re,Se(1,6)),J(2,t,u+re,F,Se(1,7),"tablesJson: "+re,"tables"+re),L(u,v,Se(1,8)+" changes"),L(I,w,je(2,0,1)),L($,C,je(3,0),`tableId: ${n} | null`,"tableId"),L(h,S,je(4,3,1),`tableId: ${n} | null`,"tableId"),L(p,V,je(13,3,1),lt("tableId: "+n,"cellId: Id"+de,"descending: boolean","offset: number","limit: number"+de),lt("tableId","cellId","descending","offset","limit")),L(b,x,je(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),L(g,P,je(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),L(f,j,je(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${Ke(D((l=>{var a,n;return null!=(n=null==(a=_(e,l))?void 0:a[3])?n:t}))," | ")} | null`,"tableId, rowId, cellId"),L(oe+f,A,ie+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),m(1,B,l,n,d,v,w,C,S,V,x,P,j,A,...W(X)),m(0,"tinybase","CellChange"),O(K,".setTablesSchema({",Xe(D(((e,l,a)=>[`[${a}]: {`,...T(e,((e,l,a,n)=>`[${n}]: {[${k(et(o),`'${o}'`)}]: ${k(et(l),`'${l}'`)}${E(a)?t:`, [${k(et(r),`'${r}'`)}]: `+(z(a)?k(et(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!ct(l)){const e=y(w,"{"+Ke(A(((e,l,a)=>`'${e}'${E(a)?"?":t}: ${l};`))," ")+"}",Se(2,5)),l=y(w+"WhenSet","{"+Ke(A(((e,t)=>`'${e}'?: ${t};`))," ")+"}",Se(2,5,1)),n=y(v+ne,Ke(A((e=>`'${e}'`))," | "),"A Value Id in "+be),d=y(v+te,`(...[valueId, rowCallback]: ${Ke(A(((e,t)=>`[valueId: '${e}', value: ${t}]`))," | ")})`+ve,Oe("a Value Id, and value")),c=y("GetValueChange",`(valueId: ${n}) => ValueChange`,ee+" returning information about any Value's changes during a "+pe),i=y(w+s,`(${q}: ${F}, getValueChange: ${c}${de})`+ve,Pe(9)),$=y(C+s,`(${q}: ${F})`+ve,Pe(10)),u=y(v+s,`(...[${q}, valueId, newValue, oldValue, getValueChange]: ${Ke(A(((e,t)=>`[${q}: ${F}, valueId: '${e}', newValue: ${t}${de}, oldValue: ${t}${de}, getValueChange: ${c} | undefined]`))," | ")})`+ve,Pe(11)),I=y(oe+v+s,`(${q}: ${F}, valueId: Id, invalidValues: any[])`+ve,Pe(12));ue=[e,l,n,i,$,u],R([[e],[a],[F,"values: "+l,"values"],[F],[F,"partialValues: "+l,"partialValues"]],(([e,l,a],n)=>J(n,t,w,e,Se(2,n),l,a))),J(0,t,C,n+Ie,Ve(v,be)),J(5,t,v,"void",xe(v,be),"valueCallback: "+d,"valueCallback as any"),A(((e,l,n,o,r)=>{const s="Map"+Ye(l,1);Q(X,l,s),R([[l],[a],[F,`value: ${l} | `+s,", value as any"],[F]],(([l,a,n=t],s)=>J(s,r,v,l,Me(e,s),a,o+n)))})),J(0,t,w+re,re,Se(2,6)),J(2,t,w+re,F,Se(2,7),"valuesJson: "+re,"values"+re),L(w,i,Se(2,8)+" changes"),L(C,$,je(10,0,1)),L(v,u,je(11,0),`valueId: ${n} | null`,"valueId"),L(oe+v,I,ie+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),m(1,B,e,l,n,d,i,$,u,I),m(0,"tinybase","ValueChange"),O(K,".setValuesSchema({",A(((e,l,a,n)=>[`[${n}]: {[${k(et(o),`'${o}'`)}]: ${k(et(l),`'${l}'`)}${E(a)?t:`, [${k(et(r),`'${r}'`)}]: `+(z(a)?k(et(a),`'${a}'`):a)}},`])),"})")}Z(X,((e,t)=>y(t,`(cell: ${e}${de}) => `+e,`Takes a ${e} Cell value and returns another`))),m(null,"tinybase","DoRollback",ne,"IdOrNull",i,re,"Store");const we=y(he+s,`(${q}: ${F}, cellsTouched: boolean, valuesTouched: boolean)`+ve,ee+" listening to the completion of a "+pe);return J(0,t,re,re,Se(0,6)),J(2,t,re,F,Se(0,7),"json: "+re,"json"),J(7,t,pe,"Return","Execute a "+pe+" to make multiple mutations","actions: () => Return, doRollback?: DoRollback","actions, doRollback","<Return>"),J(7,t,"start"+he,F,"Explicitly starts a "+pe),J(7,t,"finish"+he,F,"Explicitly finishes a "+pe,"doRollback?: DoRollback,","doRollback"),L("WillFinish"+he,we,ie+" just before "+fe,t,t,0),L("DidFinish"+he,we,ie+" just after "+fe,t,t,0),J(7,t,"call"+s,F,"Manually provoke a listener to be called","listenerId: Id","listenerId"),J(3,t,s,F,"Remove a listener that was previously added to "+be,"listenerId: Id","listenerId"),G("getStore",t,"Store","store",ze[0]+" the underlying Store object"),m(1,"tinybase","createStore"),m(1,B,F,`create${F} as create${F}Decl`,we),k("store",["createStore()",...K]),S("fluent","actions: () => Store",["actions();",`return ${q};`]),S("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),k(q,["{",...M(1),"}"]),[d(...V(0),...x(),ae+" interface "+F+" {",...M(0),"}",t,tt(`Creates a ${F} object`),ae+" function create"+F+"(): "+F+";"),d(...V(1),ae+" const create"+F+": typeof create"+F+"Decl = () => {",...P(),`return Object.freeze(${q});`,"};"),le,ue]},ft="Deps",gt=e=>d+e,vt=e=>lt(gt(e),gt(e)+ft),wt="Parameter",Ct=": (parameter: "+wt+", store: Store) => ",mt="const contextValue = useContext(Context);",yt=", and registers a listener so that any changes to that result will cause a re-render",Rt=", based on a parameter",St=": ",kt=wt+"ized"+te+"<"+wt+">",Vt="<"+wt+",>",xt=ft+"?: React.DependencyList",Ot="then"+xt,Pt="then?: (store: Store",jt=lt(Pt+")"+ve,Ot),Dt="then, then"+ft,Tt="rowId",At=Tt+St+ne,Nt=(e,...t)=>lt(...t,se+": "+e,se+xt,"mutator?: boolean"),Et=(...e)=>lt(...e,se,se+ft,"mutator"),Mt=(e,l,a,n,o)=>{const[r,d,c,m,y,R,S,k]=at(),[V,x,P]=$t(e,l,y),D=`./${Ye(a)}.d`,T=`./${Ye(a)}-ui-react.d`,A="tinybase/ui-react",N=Ye(a,1),M=Ye(N),z=N+"Or"+N+ne,J=M+"Or"+N+ne,L=U(),W=(e,l,a,n,o,r=t)=>(d(1,T,e+" as "+e+"Decl"),He(L,e,[l,a,G(n)?["{",n,"}"]:n,o,r])),B=(e,l,a,n,o,r=t)=>W("use"+e,l,a,n,o,r),F=(e,l,a,n,o=t,r=t,s=t,c=t,i=t)=>{d(1,A,`use${l} as use${l}Core`),B(e,lt(o,X,c),a,ee+`(${J}, use${l}Core, [`+(r||t)+(i?"], ["+i:t)+"])",n,s)},Z=(e,t,l,a)=>W(e,t,1,l,a),Q=(e=0)=>H(L,(([l,a,n,o,r],s)=>{const d=e?[ae+` const ${s}: typeof ${s}Decl = ${r}(${l}): ${1==a?"any":a} =>`,n]:[ae+` function ${s}${r}(${l}): ${1==a?"ComponentReturnType":a};`];return e||j(d,tt(o)),O(d,t),d}));d(null,"tinybase",ne,i,"IdOrNull","Store",te,wt+"ized"+te),d(0,A,"ComponentReturnType"),d(0,D,N);const q=c(z,N+" | "+ne,`Used when you need to refer to a ${N} in a React hook or component`),K=c("ProviderProps",`{readonly ${M}?: ${N}; readonly ${M}ById?: {[${M}Id: Id]: ${N}}}`,`Used with the Provider component, so that a ${N} can be passed into the context of an application`);d(1,"react","React"),d(1,T,q,K);const X=J+"?: "+q;y("{createContext, useContext, useMemo}","React"),y("Context",`createContext<[${N}?, {[${M}Id: Id]: ${N}}?]>([])`),B("Create"+N,`create: () => ${N}, create`+xt,N,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${N} within a React application with convenient memoization`);const Y=B(N,"id?: Id",N+de,[mt,"return id == null ? contextValue[0] : contextValue[1]?.[id];"],`Get a reference to a ${N} from within a Provider component context`),ee=m("useHook",J+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${M} = ${Y}(${J} as Id);`,`return hook(...preParams, ((${J} == null || typeof ${J} == 'string')`,`? ${M} : ${J})?.getStore(), ...postParams)`]);if(!ct(e)){const[e,l,a,o,r,c,v,w,C,m,y]=n;d(null,D,e,l,a,o,r,c,v,w,C,m),d(1,A),d(1,D,N),F(u,u,e,Se(1,0)+yt),F(I,I,l+Ie,Ve($,be)+yt),F(ue+u+te,ue+u+te,kt,Se(1,9)+Rt,lt(gt(u)+Ct+e,gt(u)+xt),vt(u),Vt,lt(Pt,`tables: ${e})`+ve,Ot),Dt),F(le+u+te,le+u+te,te,Se(1,12),t,t,t,jt,Dt),V(((e,l,a)=>{const[n,o,r,s]=_(y,e);d(0,D,n,o,r,s),d(1,D,n,o,r,s),F(l+$,$,n,Ae(e)+yt,t,a),F(l+h,h,i,Ve(b,De(e))+yt,t,a),F(l+p,p,i,Ve(b,De(e),1)+yt,"cellId?: "+s+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit"),F(l+b,b,o,Ne(e)+yt,At,lt(a,Tt)),F(l+g,g,s+Ie,Ve(f,Te(e))+yt,At,lt(a,Tt)),F(ue+l+$+te,ue+$+te,kt,Ae(e,9)+Rt,lt(gt($)+Ct+n,gt($)+xt),lt(a,vt($)),Vt,lt(Pt,`table: ${n})`+ve,Ot),Dt),F(le+l+$+te,le+$+te,te,Ae(e,12),t,a,t,jt,Dt),F(ue+l+b+te,ue+b+te,kt,Ne(e,9)+Rt,lt(At,gt(b)+Ct+r,gt(b)+xt),lt(a,Tt,vt(b)),Vt,lt(Pt,`row: ${r})`+ve,Ot),Dt),F("Add"+l+b+te,"Add"+b+te,kt,Ne(e,10)+Rt,lt(gt(b)+Ct+r,gt(b)+xt),lt(a,vt(b)),Vt,"then?: ("+lt(At+de,"store: Store","row: "+r+")"+ve,"then"+xt),Dt),F(ue+l+ce+b+te,ue+ce+b+te,kt,Ne(e,11)+Rt,lt(At,gt(ce+b)+Ct+r,gt(ce+b)+xt),lt(a,Tt,vt(ce+b)),Vt,lt(Pt,`partialRow: ${r})`+ve,Ot),Dt),F(le+l+b+te,le+b+te,te,Ne(e,12),At,lt(a,Tt),t,jt,Dt),x(e,((n,o,r,s,c)=>{const i="Map"+Ye(o,1);d(0,D,i),d(1,D,i),F(l+c+f,f,o+(E(r)?de:t),Ee(e,n)+yt,At,lt(a,Tt,s)),F(ue+l+c+f+te,ue+f+te,kt,Ee(e,n,9)+Rt,lt(At,gt(f)+Ct+o+" | "+i,gt(f)+xt),lt(a,Tt,s,vt(f)),Vt,lt(Pt,`cell: ${o} | ${i})`+ve,Ot),Dt),F(le+l+c+f+te,le+f+te,te,Ee(e,n,12),lt(At,"forceDel?: boolean"),lt(a,Tt,s,"forceDel"),t,jt,Dt)}))}));const R=Ke(V((e=>{var l,a;return null!=(a=null==(l=_(y,e))?void 0:l[3])?a:t}))," | ");F(u+s,u+s,ge,Se(1,8)+" changes",Nt(a),Et()),F(I+s,I+s,ge,je(2,0,1),Nt(o),Et()),F($+s,$+s,ge,je(3,0),Nt(r,`tableId: ${l} | null`),Et("tableId")),F(h+s,h+s,ge,je(4,3,1),Nt(c,`tableId: ${l} | null`),Et("tableId")),F(p+s,p+s,ge,je(13,3,1),Nt(v,`tableId: ${l} | null`,"cellId: "+R+de,"descending: boolean","offset: number","limit: number"+de),Et("tableId","cellId","descending","offset","limit")),F(b+s,b+s,ge,je(5,3),Nt(w,`tableId: ${l} | null`,Tt+": IdOrNull"),Et("tableId",Tt)),F(g+s,g+s,ge,je(6,5,1),Nt(C,`tableId: ${l} | null`,Tt+": IdOrNull"),Et("tableId",Tt)),F(f+s,f+s,ge,je(7,5),Nt(m,`tableId: ${l} | null`,Tt+": IdOrNull",`cellId: ${R} | null`),Et("tableId",Tt,"cellId"))}if(!ct(l)){const[e,l,a,n,r,c]=o;d(null,D,...o),F(w,w,e,Se(2,0)+yt),F(C,C,a+Ie,Ve(v,be)+yt),F(ue+w+te,ue+w+te,kt,Se(2,9)+Rt,lt(gt(w)+Ct+l,gt(w)+xt),vt(w),Vt,lt(Pt,`values: ${l})`+ve,Ot),Dt),F(ue+ce+w+te,ue+ce+w+te,kt,Se(2,11)+Rt,lt(gt(ce+w)+Ct+l,gt(ce+w)+xt),vt(ce+w),Vt,lt(Pt,`partialValues: ${l})`+ve,Ot),Dt),F(le+w+te,le+w+te,te,Se(2,12),t,t,t,jt,Dt),P(((e,l,a,n,o)=>{const r="Map"+Ye(l,1);d(0,D,r),d(1,D,r),F(o+v,v,l,Me(e)+yt,t,n),F(ue+o+v+te,ue+v+te,kt,Me(e,9)+Rt,lt(gt(v)+Ct+l+" | "+r,gt(v)+xt),lt(n,vt(v)),Vt,lt(Pt,`value: ${l} | ${r})`+ve,Ot),Dt),F(le+o+v+te,le+v+te,te,Me(e,12),t,n,t,jt,Dt)})),F(w+s,w+s,ge,Se(2,8)+" changes",Nt(n),Et()),F(C+s,C+s,ge,je(10,0,1),Nt(r),Et()),F(v+s,v+s,ge,je(11,0),Nt(c,`valueId: ${a} | null`),Et("valueId"))}return Z("Provider",`{${M}, ${M}ById, children}: `+K+" & {children: React.ReactNode}",[mt,"return (","<Context.Provider","value={useMemo(",`() => [${M} ?? contextValue[0], {...contextValue[1], ...${M}ById}],`,`[${M}, ${M}ById, contextValue],`,")}>","{children}","</Context.Provider>",");"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...R(0),...S(),...Q(0)),r(...R(1),...k(),...Q(1))]},zt=(e,l,a)=>{if(ct(e)&&ct(l))return[t,t,t,t];const[n,o,r,s]=pt(e,l,a);return[n,o,...Mt(e,l,a,r,s)]};var Gt=Object.defineProperty,Jt=Object.defineProperties,Lt=Object.getOwnPropertyDescriptors,Wt=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Ut=(e,t,l)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,_t=(e,t)=>{for(var l in t||(t={}))Bt.call(t,l)&&Ut(e,l,t[l]);if(Wt)for(var l of Wt(t))Ft.call(t,l)&&Ut(e,l,t[l]);return e},Zt=(e,t)=>Jt(e,Lt(t)),Ht=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{s(l.next(e))}catch(e){n(e)}},r=e=>{try{s(l.throw(e))}catch(e){n(e)}},s=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,r);s((l=l.apply(e,t)).next())}));const Qt={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},qt=it((e=>{const t=()=>{const t=T(e.getTablesSchemaJson());return!ct(t)||m(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=U();if(m(a,(t=>m(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),r=q(n,a,(()=>[J(o),U(),[0],0])),[s,d,[c]]=r,i=q(d,o,(()=>0))+1;return i>c&&(r[2]=[i,o]),Q(d,o,i),r[3]++,s==J(o)})))))return t[l]={},B(n,(([e,,[,n],s],d)=>{t[l][d]=_t({[o]:e},s==k(a)?{[r]:n}:{})})),1}))?t:{}},l=()=>{const t=T(e.getValuesSchemaJson());return ct(t)&&e.forEachValue(((e,l)=>{t[e]={[o]:J(l)}})),t},a=e=>zt(t(),l(),e),n=e=>Ht(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 S(a(e),((e,a)=>Qe(l(e,Zt(_t({},Qt),{filepath:"_."+t[a]})))))}));return rt({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,r)=>{l++;let s=0,d=0;const c={};r(((e,l)=>{s++;let a=0;l((()=>a++)),d+=a,t&&(c[e]={rowCells:a})})),a+=s,n+=d,t&&(o[e]={tableRows:s,tableCells:d,rows:c})})),_t({totalTables:l,totalRows:a,totalCells:n,totalValues:k(e.getValueIds()),jsonLength:qe(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=qt;
1
+ "use strict";const e=e=>typeof e,t="",l=e(t),a=e(!0),n=e(0),o="type",r="default",d="Listener",s="get",I="add",c="Ids",i="Table",u=i+"s",$=i+c,p="Row",b=p+c,C="Sorted"+p+c,m="Cell",h=m+c,g="Value",f=g+"s",w=g+c,y=(e,t)=>e.every(t),v=(e,t)=>e.sort(t),T=(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),P=e=>e.pop(),A=(e,...t)=>e.unshift(...t),O=e=>e.shift(),E=JSON.parse,D=isFinite,j=(e,t)=>e instanceof t,N=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&&D(t)?l:void 0},z=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},W=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},F=(e,t)=>null==e?void 0:e.forEach(t),B=(e,t)=>null==e?void 0:e.delete(t),_=e=>new Map(e),U=(e,t)=>null==e?void 0:e.get(t),Z=(e,t)=>F(e,((e,l)=>t(l,e))),H=(e,t)=>{var l;return V([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},Q=(e,t,l)=>N(l)?(B(e,t),e):null==e?void 0: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",re="Id",de="IdOrNull",se="Invalid",Ie="Json",ce=X(d),ie=" | undefined",ue="NonNullable",$e="Partial",pe=`Registers a ${ce} that will be called`,be="Represents",Ce="rowId: "+re,me="rowId: "+de,he="Schema",ge="Set",fe=", descending?: boolean, offset?: number, limit?: number",we="[]",ye="Store",ve="the "+ye,Te="Transaction",Ve=X(Te),xe="Execute a "+Ve+" to make multiple mutations",Re="Explicitly starts a "+Ve,Se="Explicitly finishes a "+Ve,ke="the end of the "+Ve,Pe="void",Ae=" => "+Pe,Oe="WhenSet",Ee=" when setting it",De=Y+"string serialization of",je=" ",Ne="Gets a callback that can ",Le="the ",Me=" the schema for",Ge=(e=0,l=0)=>`the ${nt[e]}content of`+(l?je+ve:t),Je=(e=0,l,a=0)=>tt[l]+je+Ge(e,1)+(a?" when setting it":t),ze=(e,t=0)=>be+` 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)=>pe+" 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]+je+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",be,"Gets "+De,"Sets "+De,pe+" whenever",Ne+"set",Ne+"add",Ne+"set part of",Ne+"delete","Renders","Gets "+De+Me,"Sets"+Me,"Deletes"+Me],lt=[s,"has","set","del","set","forEach",I,t],at=[ve,u,Le+i+je+c,Y+i,Le+p+je+c,Y+p,Le+m+je+c,Y+m,"invalid Cell changes",f,Le+g+je+c,Y+g,"invalid Value changes",Le+"sorted "+p+je+c],nt=[t,"tabular ","keyed value "],ot=e=>new Set(G(e)||N(e)?e:[e]),rt=(e,t)=>null==e?void 0:e.add(t),dt=/[^A-Za-z]+/,st=/[^A-Za-z0-9]+/,It=/^( *)\/\*\* *(.*?) *\*\/$/gm,ct=(e,t,l)=>e.substring(t,l),it=e=>e.includes(","),ut=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return z(e,n)?ut(e,t,l,a+1):(Q(e,n,l),n)},$t=e=>e.replace(It,((e,t,l)=>{const a=77-pt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),pt=e=>e.length,bt=(e,l=t)=>e.join(l),Ct=e=>e.flat(1e3),mt=(e,t=0)=>bt(V(e.split(st),((e,l)=>(l>0||t?K:X)(ct(e,0,1))+ct(e,1)))),ht=e=>K(bt((e&&!dt.test(e[0])?e:" "+e).split(st),"_")),gt=e=>`/** ${e}. */`,ft=(...e)=>bt(S(e,(e=>e)),", "),wt=(...e)=>"{"+bt(e,"; ")+"}",yt=(...e)=>wt(...V(e,(e=>"readonly "+e))),vt=()=>{const e=[_(),_(),_(),_()],l=_(),a=_();return[(...e)=>bt(Ct(e),"\n"),(t,l,...a)=>T(a,(a=>T([0,1],(n=>(null!=t?t:n)==n?rt(q(e[n],l,ot),a):0)))),(e,a,n,o=t,r=1)=>ut(l,e,[a,n,o,r]),(e,t,l)=>ut(a,e,G(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>U(a,e)===t?e:ut(a,e,t),(l=0)=>V([...v(H(e[l],((e,t)=>`import {${bt(v(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,P(e)+";"),[`const ${l} = ${O(e)}`,e,t])))]},Tt=Object,Vt=Tt.keys,xt=Tt.freeze,Rt=e=>j(e,Tt)&&e.constructor==Tt,St=(e,t)=>V(Tt.entries(e),(([e,l])=>t(l,e))),kt=e=>Rt(e)&&R(Vt(e)),Pt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},At=(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[r],l(ht(t),`'${t}'`),mt(t,1)))),e=>St(t,((t,a)=>e(a,t[o],t[r],l(ht(a),`'${a}'`),mt(a,1))))],Ot=(e,l,a,n)=>[(n,o)=>{const r=n+": "+o,s=e(u,wt(...l((e=>`'${e}'?: {[rowId: Id]: `+wt(...a(e,((e,l,a)=>`'${e}'${N(a)?"?":t}: ${l}`)))+"}"))),Je(1,5)),I=e(u+Oe,wt(...l((e=>`'${e}'?: {[rowId: Id]: `+wt(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Je(1,5,1)),c=e(i+re,"keyof "+s,"A "+i+" Id in "+ve),g=`<TId extends ${c}>`,f=e(i,ue+`<${s}[TId]>`,"A "+i+" in "+ve,g),w=e(i+Oe,ue+`<${I}[TId]>`,"A "+i+" in "+ve+Ee,g),y=e(p,f+"<TId>[Id]","A "+p+" in a "+i,g),v=e(p+Oe,w+"<TId>[Id]","A "+p+" in a "+i+Ee,g),T=e(m+re,`Extract<keyof ${y}<TId>, Id>`,"A "+m+" Id in a "+p,g),V=e(m,ue+`<${s}[TId]>[Id][CId]`,"A "+m+" in a "+p,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,m+" Ids and types in a "+p,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(m+te,`(...[cellId, cell]: ${x}<TId>)`+Ae,_e(Y+m+" Id, and "+m),g),S=e(p+te,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Ae+") "+Ae,_e(Y+p+" Id, and a "+m+" iterator"),g),k=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${S}<TId>)${Ae}] : never`,i+" Ids and callback types",`<TId = ${c}>`,0),P=e(i+te,`(...[tableId, forEachRow]: ${k})`+Ae,_e(Y+i+" Id, and a "+p+" iterator"),t),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`,ee+" returning information about any Cell's changes during a "+Ve),E=e(u+d,`(${r}, getCellChange: ${O}${ie})`+Ae,Ue(1)),D=e($+d,`(${r})`+Ae,Ue(2)),j=e(i+d,`(${r}, tableId: ${c}, getCellChange: ${O}${ie})`+Ae,Ue(3)),L=e(b+d,`(${r}, tableId: ${c})`+Ae,Ue(4,3)),M=e(C+d,"("+ft(r,"tableId: "+c,"cellId: Id"+ie,"descending: boolean","offset: number","limit: number"+ie,"sortedRowIds: Ids")+")"+Ae,Ue(13,3)),G=e(p+d,"("+ft(""+r,"tableId: "+c,Ce,`getCellChange: ${O}${ie}`)+")"+Ae,Ue(5,3)),J=e(h+d,"("+ft(""+r,"tableId: "+c,Ce)+")"+Ae,Ue(6,5)),z=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${r}, tableId: TId, ${Ce}, cellId: CId, newCell: ${V}<TId, CId> ${ie}, oldCell: ${V}<TId, CId> ${ie}, getCellChange: ${O} ${ie}] : 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[s,I,c,f,w,y,v,T,V,R,S,P,E,D,j,L,M,G,J,e(m+d,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${W})`+Ae,Ue(7,5)),e(se+m+d,`(${r}, tableId: Id, ${Ce}, cellId: Id, invalidCells: any[])`+Ae,Ue(8))]},(l,a)=>{const o=l+": "+a,r=e(f,wt(...n(((e,l,a)=>`'${e}'${N(a)?"?":t}: ${l}`))),Je(2,5)),s=e(f+Oe,wt(...n(((e,t)=>`'${e}'?: ${t}`))),Je(2,5,1)),I=e(g+re,"keyof "+r,"A "+g+" Id in "+ve),c=e(g,ue+`<${r}[VId]>`,"A "+g+" Id in "+ve,`<VId extends ${I}>`),i=e("ValueIdValueArray",`VId extends ${I} ? [valueId: VId, value: ${c}<VId>] : never`,g+" Ids and types in "+ve,`<VId = ${I}>`,0),u=e(g+te,`(...[valueId, value]: ${i})`+Ae,_e(Y+g+" Id, and "+g)),$=e("GetValueChange",`(valueId: ${I}) => ValueChange`,ee+" returning information about any Value's changes during a "+Ve),p=e(f+d,`(${o}, getValueChange: ${$}${ie})`+Ae,Ue(9)),b=e(w+d,`(${o})`+Ae,Ue(10)),C=e("ValueListenerArgsArray",`VId extends ${I} ? [${o}, valueId: VId, newValue: ${c}<VId> ${ie}, oldValue: ${c}<VId> ${ie}, getValueChange: ${$} ${ie}] : never`,"Value args for ValueListener",`<VId = ${I}>`,0);return[r,s,I,c,u,p,b,e(g+d,`(...[${l}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Ae,Ue(11)),e(se+g+d,`(${o}, valueId: Id, invalidValues: any[])`+Ae,Ue(12))]},(t,l)=>e(Te+d,`(${t}: ${l}, cellsTouched: boolean, valuesTouched: boolean)`+Ae,ee+" listening to the completion of a "+Ve)],Et=(e,l=t,a=t)=>`store.${e}(${l})`+(a?" as "+a:t),Dt=(e,l=t)=>`fluent(() => ${Et(e,l)})`,jt=(e,l=t,a=t)=>`store.${e}(${l?l+", ":t}proxy(listener)${a?", "+a:t})`,Nt=(e,l,n)=>{const[s,y,v,V,x,R,S,P]=vt(),[O,E,D]=At(e,l,x),[j,L,G]=Ot(v,O,E,D),J=_(),z=(e=0)=>H(J,(([l,a,n,o,r],d)=>{const s=e?[d+`: ${r}(${l}): ${a} => ${n},`]:[d+r+`(${l}): ${a};`];return e||A(s,gt(o)),k(s,t),s})),F=(e,l,a,n,o,r=t)=>ut(J,e,[l,a,n,o,r]),B=(e,l,a,n,o,r=t,d=t,s=t)=>F(lt[e]+l+(4==e?$e:t)+a,r,n,(n==X?Dt:Et)(lt[e]+(4==e?$e:t)+a,d,e?void 0:n),o,s),q=(e,l,a,n=t,o=t,r=1,s=t)=>F(I+e+d,(n?n+", ":t)+ce+": "+l+(r?", mutator?: boolean":t),re,jt(I+e+d,o,r?"mutator":t),a,s),K=`./${mt(n)}.d`,X=mt(n,1),Y=mt(X),ee=[],le=_();let de=[],ue=[];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,d,s,I,g,f,w,V,R,S,P,A,D,L,G,J,z,F,Z]=j(Y,X),H=_();O(((e,t)=>{const l=`<'${e}'>`,a=[v(t+i,d+l,be+` the '${e}' `+i),v(t+i+Oe,s+l,be+` the '${e}' `+i+Ee),v(t+p,I+l,ze(e)),v(t+p+Oe,g+l,ze(e,1)),v(t+m+re,f+l,`A Cell Id for the '${e}' `+i),v(t+m+te,V+l,_e(`a Cell Id and value from a Row in the '${e}' `+i)),v(t+p+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,P,A,D,L,G,J,z,F,Z),de=[e,l,n,f,P,A,D,L,G,J,z,F,H],T([[e],[a],[X,"tables: "+l,"tables"],[X]],(([e,l,a],n)=>B(n,t,u,e,Je(1,n),l,a))),B(0,t,$,n+we,We(i,ve)),B(5,t,i,Pe,Fe(i,ve),"tableCallback: "+S,"tableCallback as any"),O(((e,l,n)=>{const[o,r,d,s,I,u,$]=U(H,e);T([[o],[a],[X,"table: "+r,", table"],[X]],(([a,o,r=t],d)=>B(d,l,i,a,Ke(e,d),o,n+r))),B(0,l,b,c,We(p,He(e)),t,n),B(0,l,C,c,We(p,He(e),1),"cellId?: "+I+fe,n+", cellId, descending, offset, limit"),B(5,l,p,Pe,Fe(p,He(e)),"rowCallback: "+$,n+", rowCallback as any"),T([[d],[a],[X,", row: "+s,", row"],[X],[X,", partialRow: "+s,", partialRow"]],(([a,o=t,r=t],d)=>B(d,l,p,a,Xe(e,d),Ce+o,n+", rowId"+r))),B(6,l,p,re+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,Pe,Fe(m,Qe(e)),Ce+", cellCallback: "+u,n+", rowId, cellCallback as any"),E(e,((o,r,d,s,I)=>{const c="Map"+mt(r,1);Q(le,r,c);const i=r+(N(d)?ie:t);T([[i],[a],[X,`, cell: ${r} | `+c,", cell as any"],[X]],(([a,r=t,d=t],c)=>B(c,l+I,m,a,Ye(e,o,c),Ce+r,n+", rowId, "+s+d)))}))})),B(0,t,u+Ie,Ie,Je(1,6)),B(2,t,u+Ie,X,Je(1,7),"tablesJson: "+Ie,"tables"+Ie),q(u,P,Je(1,8)+" changes"),q($,A,Ze(2,0,1)),q(i,D,Ze(3,0),`tableId: ${n} | null`,"tableId"),q(b,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(p,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: ${bt(O((e=>{var l,a;return null!=(a=null==(l=U(H,e))?void 0:l[4])?a:t}))," | ")} | null`,"tableId, rowId, cellId"),q(se+m,Z,pe+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),y(1,K,...W(le)),k(ee,".set"+u+he+"({",Ct(O(((e,l,a)=>[`[${a}]: {`,...E(e,((e,l,a,n)=>`[${n}]: {[${x(ht(o),`'${o}'`)}]: ${x(ht(l),`'${l}'`)}${N(a)?t:`, [${x(ht(r),`'${r}'`)}]: `+(M(a)?x(ht(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(!kt(l)){const[e,l,n,d,s,I,c,i,u]=L(Y,X);y(1,K,e,l,n,s,I,c,i,u),ue=[e,l,n,I,c,i],T([[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,ve)),B(5,t,g,"void",Fe(g,ve),"valueCallback: "+s,"valueCallback as any"),D(((e,l,n,o,r)=>{const d="Map"+mt(l,1);Q(le,l,d),T([[l],[a],[X,`value: ${l} | `+d,", value as any"],[X]],(([l,a,n=t],d)=>B(d,r,g,l,et(e,d),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,u,pe+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),y(1,K,...W(le)),y(0,"tinybase","ValueChange"),k(ee,".set"+f+he+"({",D(((e,l,a,n)=>[`[${n}]: {[${x(ht(o),`'${o}'`)}]: ${x(ht(l),`'${l}'`)}${N(a)?t:`, [${x(ht(r),`'${r}'`)}]: `+(M(a)?x(ht(a),`'${a}'`):a)}},`])),"})")}Z(le,((e,t)=>v(t,`(cell: ${e}${ie}) => `+e,`Takes a ${e} Cell value and returns another`))),y(null,"tinybase","DoRollback",re,"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"+Te,X,Re),B(7,t,"finish"+Te,X,Se,ae,"doRollback");const me=G(Y,X);return q("WillFinish"+Te,me,pe+" just before "+ke,t,t,0),q("DidFinish"+Te,me,pe+" just after "+ke,t,t,0),B(7,t,"call"+d,X,"Manually provoke a listener to be called","listenerId: Id","listenerId"),B(3,t,d,X,"Remove a listener that was previously added to "+ve,"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 = () => {",...P(),`return Object.freeze(${Y});`,"};"),de,ue]},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",rl=ft(ol+")"+Ae,Ft),dl="then, then"+Lt,sl=tl+qt+re,Il="View",cl=(e,...t)=>ft(...t,ce+": "+e,ce+Wt,"mutator?: boolean"),il=(...e)=>ft(...e,ce,ce+Lt,"mutator"),ul=(e,l,a,n,o)=>{const[r,s,I,y,v,T,V,x]=vt(),[R,S,P]=At(e,l,v),O=`./${mt(a)}.d`,E=`./${mt(a)}-ui-react.d`,D="tinybase/ui-react",j=mt(a,1),L=mt(j),M=j+"Or"+j+re,G=L+"Or"+j+re,J=L+`={${L}}`,z=_(),W=(e,l,a,n,o,r=t)=>(s(1,E,e+" as "+e+"Decl"),ut(z,e,[l,a,n,o,r])),F=(e,l,a,n,o,r=t)=>W("use"+e,l,a,n,o,r),B=(e,l,a,n,o=t,r=t,d=t,I=t,c=t)=>(s(1,D,`use${l} as use${l}Core`),F(e,ft(o,X,I),a,ae+`(${G}, use${l}Core, [`+(r||t)+(c?"], ["+c:t)+"]);",n,d)),Z=(e,t,l,a)=>W(e,t,1,l,a),Q=(e=0)=>H(z,(([l,a,n,o,r],d)=>{const s=e?[oe+` const ${d}: typeof ${d}Decl = ${r}(${l}): ${1==a?"any":a} =>`,n]:[oe+` function ${d}${r}(${l}): ${1==a?"ComponentReturnType":a};`];return e||A(s,gt(o)),k(s,t),s}));s(null,"tinybase",re,"Store",te,Bt+"ized"+te),s(0,D,"ComponentReturnType"),s(null,D,"ExtraProps"),s(0,O,j);const q=I(M,j+" | "+re,`Used when you need to refer to a ${j} in a React hook or component`),K=I(Ut+el,yt(L+Kt+j,L+`ById?: {[${L}Id: Id]: ${j}}`),`Used with the ${Ut} component, so that a `+j+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,E,q,K);const X=G+Kt+q;v("{createContext, useContext, useMemo}","React"),v("Context",`createContext<[${j}?, {[${L}Id: Id]: ${j}}?]>([])`),F("Create"+j,`create: () => ${j}, create`+Wt,j,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${j} within a React application with convenient memoization`);const ee=F(j,"id?: Id",j+ie,["{",Zt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${j} 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)"),de=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=v("NullComponent","() => null");if(!kt(e)){const[e,l,a,o,r,g,f,w,v,T,V,x,k]=n;s(null,O,e,l,a,r,g,f,w,v,T,V,x),s(0,O,o),s(1,O,j),s(null,"tinybase",c,"IdOrNull");const P=y("tableView",`{${L}, rowComponent, getRowComponentProps`+al+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${de}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",ll,J,zt,"/>","))",al,", tableId,",");"]),A=y("getDefaultTableComponent","tableId: Id",bt(R(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+se),D=y("getDefaultCellComponent","tableId: Id, cellId: Id",bt(R(((e,t,l)=>`tableId == ${l} ? ${bt(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+se} : `)))+se);B(u,u,e,Je(1,0)+Ht);const M=B($,$,a+we,We(i,ve)+Ht);B(ge+u+te,ge+u+te,Yt,Je(1,9)+Qt,ft(Mt(u)+_t+l,Mt(u)+Wt),Gt(u),Xt,ft(ol,`tables: ${l})`+Ae,Ft),dl),B(le+u+te,le+u+te,te,Je(1,12),t,t,t,rl,dl);const G=I(m+el,yt("tableId?: TId","rowId: Id","cellId?: CId",L+Kt+j,Jt),Be(Y+m),`<TId extends ${a}, CId extends ${o}<TId>>`),z=I(p+el,yt("tableId?: TId","rowId: Id",L+Kt+j,"cellComponents?: {readonly [CId in "+o+`<TId>]?: ComponentType<${G}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${o}<TId>) => ExtraProps`,nl,Jt),Be(Y+p),`<TId extends ${a}>`),W=I(i+el,yt("tableId?: TId",L+Kt+j,`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+j,`rowComponent?: ComponentType<${z}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",nl,Jt),Be(Y+"sorted "+i),`<TId extends ${a}>`),_=I(u+el,yt(L+Kt+j,"tableComponents?: {readonly [TId in "+a+`]?: ComponentType<${W}<TId>>;}`,`getTableComponentProps?: (tableId: ${a}) => ExtraProps`,nl,Jt),Be(Ge(1,1)));s(1,E,_,W,F,z,G),Z(u+Il,"{"+L+", tableComponents, getTableComponentProps"+al+"}: "+_,[de+`(${M}(${L}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+A+"(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,r,d,I]=U(k,e);s(null,O,n,o,r,d,I),B(l+i,i,n,Ke(e)+Ht,t,a);const u=B(l+b,b,c,We(p,He(e))+Ht,t,a),$=B(l+C,C,c,We(p,He(e),1)+Ht,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");B(l+p,p,r,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})`+Ae,Ft),dl),B(le+l+i+te,le+i+te,te,Ke(e,12),t,a,t,rl,dl),B(ge+l+p+te,ge+p+te,Yt,Xe(e,9)+Qt,ft(sl,Mt(p)+_t+d,Mt(p)+Wt),ft(a,tl,Gt(p)),Xt,ft(ol,`row: ${d})`+Ae,Ft),dl),B("Add"+l+p+te,"Add"+p+te,Yt,Xe(e,10)+Qt,ft(Mt(p)+_t+d,Mt(p)+Wt),ft(a,Gt(p)),Xt,"then?: ("+ft(sl+ie,"store: Store","row: "+d+")"+Ae,"then"+Wt),dl),B(ge+l+$e+p+te,ge+$e+p+te,Yt,Xe(e,11)+Qt,ft(sl,Mt($e+p)+_t+d,Mt($e+p)+Wt),ft(a,tl,Gt($e+p)),Xt,ft(ol,`partialRow: ${d})`+Ae,Ft),dl),B(le+l+p+te,le+p+te,te,Xe(e,12),sl,ft(a,tl),t,rl,dl);const f=Z(l+p+Il,"{rowId, "+L+", cellComponents, getCellComponentProps"+al+`}: ${z}<'${e}'>`,[de+`(${g}(rowId, ${L}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+D+`(${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}'>`,P+"(props, "+$+`(cellId, descending, offset, limit, props.${L}), ${a}, ${f});`,Ke(e,13)+", sorted"+Ht),Z(l+i+Il,`props: ${W}<'${e}'>`,P+"(props, "+u+`(props.${L}), ${a}, ${f});`,Ke(e,13)+Ht),S(e,((n,o,r,d,I)=>{const c="Map"+mt(o,1);s(0,O,c),s(1,O,c);const i=B(l+I+m,m,o+(N(r)?ie:t),Ye(e,n)+Ht,sl,ft(a,tl,d));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,d,Gt(m)),Xt,ft(ol,`cell: ${o} | ${c})`+Ae,Ft),dl),B(le+l+I+m+te,le+m+te,te,Ye(e,n,12),ft(sl,"forceDel?: boolean"),ft(a,tl,d,"forceDel"),t,rl,dl),Z(l+I+m+Il,`{rowId, ${L}, debugIds}: `+G+`<'${e}', '${n}'>`,[de+`('' + ${i}(rowId, `+L+`) ?? '', undefined, debugIds, ${d})`],Ye(e,n,13)+Ht)}))}));const H=bt(R((e=>{var l,a;return null!=(a=null==(l=U(k,e))?void 0:l[4])?a:t}))," | ");B(u+d,u+d,Pe,Je(1,8)+" changes",cl(r),il()),B($+d,$+d,Pe,Ze(2,0,1),cl(g),il()),B(i+d,i+d,Pe,Ze(3,0),cl(f,`tableId: ${a} | null`),il("tableId")),B(b+d,b+d,Pe,Ze(4,3,1),cl(w,`tableId: ${a} | null`),il("tableId")),B(C+d,C+d,Pe,Ze(13,3,1),cl(v,`tableId: ${a} | null`,"cellId: "+H+ie,"descending: boolean","offset: number","limit: number"+ie),il("tableId","cellId","descending","offset","limit")),B(p+d,p+d,Pe,Ze(5,3),cl(T,`tableId: ${a} | null`,tl+": IdOrNull"),il("tableId",tl)),B(h+d,h+d,Pe,Ze(6,5,1),cl(V,`tableId: ${a} | null`,tl+": IdOrNull"),il("tableId",tl)),B(m+d,m+d,Pe,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,r,c]=o;s(null,O,...o),s(1,O,j);const i=y("getDefaultValueComponent","valueId: Id",bt(P(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+se);B(f,f,e,Je(2,0)+Ht);const u=B(w,w,a+we,We(g,ve)+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})`+Ae,Ft),dl),B(ge+$e+f+te,ge+$e+f+te,Yt,Je(2,11)+Qt,ft(Mt($e+f)+_t+l,Mt($e+f)+Wt),Gt($e+f),Xt,ft(ol,`partialValues: ${l})`+Ae,Ft),dl),B(le+f+te,le+f+te,te,Je(2,12),t,t,t,rl,dl);const $=I(g+el,yt("valueId?: VId",L+Kt+j,Jt),Be("a Value"),`<VId extends ${a}>`),p=I(f+el,yt(L+Kt+j,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${$}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,nl,Jt),Be(Ge(2,1)));s(1,E,p,$),Z(f+Il,"{"+L+", valueComponents, getValueComponentProps"+al+"}: "+p,[de+`(${u}(${L}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",J,zt,"/>;","}), separator)"],Je(2,13)+Ht),P(((e,l,a,n,o)=>{const r="Map"+mt(l,1);s(0,O,r),s(1,O,r);const d=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+" | "+r,Mt(g)+Wt),ft(n,Gt(g)),Xt,ft(ol,`value: ${l} | ${r})`+Ae,Ft),dl),B(le+o+g+te,le+g+te,te,et(e,12),t,n,t,rl,dl),Z(o+g+Il,`{${L}, debugIds}: ${$}<'${e}'>`,[de+`('' + ${d}(`+L+`) ?? '', undefined, debugIds, ${n})`],et(e,13)+Ht)})),B(f+d,f+d,Pe,Je(2,8)+" changes",cl(n),il()),B(w+d,w+d,Pe,Ze(10,0,1),cl(r),il()),B(g+d,g+d,Pe,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"),[r(...T(0),...V(),...Q(0)),r(...T(1),...x(),...Q(1))]},$l=(e,l,a)=>{if(kt(e)&&kt(l))return[t,t,t,t];const[n,o,r,d]=Nt(e,l,a);return[n,o,...ul(e,l,a,r,d)]},pl=". Note that this may contradict the generated type refinements",bl=(e,l,n)=>{const[o,r,y,v,V,x,R,S]=vt(),[P,A,O]=At(e,l,(()=>t)),[E,D,j]=Ot(y,P,A,O),N=_(),L=()=>H(N,(([e,l,a,n],o)=>[gt(a),o+n+`(${ft(...e)}): ${l};`,t])),M=(e,l,a,n,o=t)=>ut(N,e,[G(l)?l:[l],a,n,o]);let J;r(0,"tinybase",re,c,de,"StoreListenerStats",Ie,u+he,f+he,"DoRollback"),kt(e)?(J=[u,u,re,i,i,p,p,re,m,m+te,p+te,i+te,u+d,$+d,i+d,b+d,C+d,p+d,h+d,m+d,se+m+d],r(0,"tinybase",...J),k(J,re,de,re,t,re,t)):(r(0,"tinybase","CellChange"),J=E("store",ye),T([3,4,5,6,7,9,10],(e=>J[e]+="<TId>")),J[8]+="<TId, CId>",k(J,"TId","TId | null",bt(P((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,ue,be,ge,Ae,Oe,Ee,De,je,Ne,Le,Me,Ge,ze,Be]=J,_e="tableId: "+Ne,Ue=ft(_e,Ce),He=ft(Ue,"cellId: "+ze),Qe="tableId: "+Le,Ke=ft(Qe,me),Xe=ft(Ke,"cellId: "+Me);let Ye;T([[z],[a],[ye,"tables: "+W],[ye]],(([e,l],a)=>M(lt[a]+u,null!=l?l:t,e,Je(1,a)))),M(s+$,t,F+we,We(i,ve)),M(lt[5]+i,"tableCallback: "+le,Pe,Fe(i,ve)),T([[B,_e],[a,_e],[ye,[_e,"table: "+U]],[ye,_e]],(([e,l],a)=>M(lt[a]+i,null!=l?l:t,e,qe(a,3),Ge))),M(s+b,_e,c,We(p,Y+i),Ge),M(s+C,[_e,"cellId?: "+q+fe],c,We(p,Y+i),Ge),M(lt[5]+p,[_e,"rowCallback: "+ee],Pe,Fe(p,Y+i),Ge),T([[Z,Ue],[a,Ue],[ye,[Ue,"row: "+Q]],[ye,Ue]],(([e,l],a)=>M(lt[a]+p,null!=l?l:t,e,qe(a,5),Ge))),M("set"+$e+p,[_e,Ce,"partialRow: "+Q],ye,qe(4,5),Ge),M(I+p,[_e,"row: "+Q],re+ie,"Add a new "+p,Ge),M(s+h,[_e,Ce],q+we,We(m,Y+p),Ge),M(lt[5]+m,[_e,Ce,"cellCallback: "+X],Pe,Fe(m,Y+p),Ge),T([[K,He],[a,He],[ye,[He,"cell: "+K]],[ye,He]],(([e,l],a)=>M(lt[a]+m,null!=l?l:t,e,qe(a,7),Be))),M(I+u+d,[ce+": "+oe,"mutator?: boolean"],re,Je(1,8)+" changes"),M(I+$+d,[ce+": "+ue,"mutator?: boolean"],re,Ze(2,0,1)),M(I+i+d,[Qe,ce+": "+be,"mutator?: boolean"],re,Ze(3,0),Ge),M(I+b+d,[Qe,ce+": "+ge,"mutator?: boolean"],re,Ze(4,3,1),Ge),M(I+C+d,[_e,"cellId: "+q+ie,"descending: boolean","offset: number","limit: number"+ie,ce+": "+Ae,"mutator?: boolean"],re,Ze(13,3,1),Ge),M(I+p+d,[Ke,ce+": "+Oe,"mutator?: boolean"],re,Ze(5,3),Ge),M(I+h+d,[Ke,ce+": "+Ee,"mutator?: boolean"],re,Ze(6,5,1),Ge),M(I+m+d,[Xe,ce+": "+De,"mutator?: boolean"],re,Ze(7,5),Ge),M(I+se+m+d,["tableId: "+de,"rowId: "+de,"cellId: "+de,ce+": "+je,"mutator?: boolean"],re,pe+" whenever an invalid Cell change was attempted"),kt(l)?(Ye=[f,f,re,g,g+te,f+d,w+d,g+d,se+g+d],r(0,"tinybase",...Ye),k(Ye,re,de,t)):(r(0,"tinybase","ValueChange"),Ye=D("store",ye),Ye[3]+="<VId>",k(Ye,"VId","VId | null",`<VId extends ${Ye[2]}>`));const[et,tt,at,nt,ot,rt,dt,st,It,ct,it,$t]=Ye,pt="valueId: "+ct;T([[et],[a],[ye,"values: "+tt],[ye]],(([e,l],a)=>M(lt[a]+f,null!=l?l:t,e,Je(2,a)))),M("set"+$e+f,"partialValues: "+tt,ye,Je(2,4)),M(s+w,t,at+we,We(g,ve)),M(lt[5]+g,"valueCallback: "+ot,Pe,Fe(g,ve)),T([[nt,pt],[a,pt],[ye,[pt,"value: "+nt]],[ye,pt]],(([e,l],a)=>M(lt[a]+g,null!=l?l:t,e,qe(a,11),$t))),M(I+f+d,[ce+": "+rt,"mutator?: boolean"],re,Je(2,8)+" changes"),M(I+w+d,[ce+": "+dt,"mutator?: boolean"],re,Ze(10,0,1)),M(I+g+d,["valueId: "+it,ce+": "+st,"mutator?: boolean"],re,Ze(11,0),$t),M(I+se+g+d,["valueId: "+de,ce+": "+It,"mutator?: boolean"],re,pe+" whenever an invalid Value change was attempted"),T([[t,"tablesAndValues"],[u,"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)+pl),M("del"+e+he,t,ye,Je(a,16))})),M("set"+he,[`tables${he}: `+u+he,`values${he}?: `+f+he],ye,Je(0,15)+pl),M(Ve,ne,"Return",xe,"<Return>"),M("start"+Te,t,ye,Re),M("finish"+Te,ae,ye,Se);const Ct=j("store",ye);return M(I+"WillFinish"+Te+d,ce+": "+Ct,re,pe+" just before "+ke),M(I+"DidFinish"+Te+d,ce+": "+Ct,re,pe+" just after "+ke),M("call"+d,"listenerId: Id",ye,"Manually provoke a listener to be called"),M("del"+d,"listenerId: Id",ye,"Remove a listener that was previously added to "+ve),M(s+d+"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]=bl(e,l);return[n,...Cl()]};var hl=Object.defineProperty,gl=Object.defineProperties,fl=Object.getOwnPropertyDescriptors,wl=Object.getOwnPropertySymbols,yl=Object.prototype.hasOwnProperty,vl=Object.prototype.propertyIsEnumerable,Tl=(e,t,l)=>t in e?hl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Vl=(e,t)=>{for(var l in t||(t={}))yl.call(t,l)&&Tl(e,l,t[l]);if(wl)for(var l of wl(t))vl.call(t,l)&&Tl(e,l,t[l]);return e},xl=(e,t)=>gl(e,fl(t)),Rl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{d(l.next(e))}catch(e){n(e)}},r=e=>{try{d(l.throw(e))}catch(e){n(e)}},d=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,r);d((l=l.apply(e,t)).next())}));const Sl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},kl=()=>Rl(void 0,null,(function*(){try{return(yield import("prettier")).format}catch(e){return e=>e}})),Pl=Pt((e=>{const t=()=>{const t=E(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),r=q(n,a,(()=>[J(o),_(),[0],0])),[d,s,[I]]=r,c=q(s,o,(()=>0))+1;return c>I&&(r[2]=[c,o]),Q(s,o,c),r[3]++,d==J(o)})))))return t[l]={},F(n,(([e,,[,n],d],s)=>{t[l][s]=Vl({[o]:e},d==x(a)?{[r]:n}:{})})),1}))?t:{}},l=()=>{const t=E(e.getValuesSchemaJson());return kt(t)&&e.forEachValue(((e,l)=>{t[e]={[o]:J(l)}})),t},a=e=>$l(t(),l(),e),n=e=>Rl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"],l=yield kl();return V(a(e),((e,a)=>$t(l(e,xl(Vl({},Sl),{filepath:"_."+t[a]})))))})),d=e=>ml(t(),l()),s=e=>Rl(void 0,null,(function*(){const e=yield kl();return V(d(),(t=>$t(e(t,xl(Vl({},Sl),{filepath:"_.d.ts"})))))}));return xt({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,r)=>{l++;let d=0,s=0;const I={};r(((e,l)=>{d++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=d,n+=s,t&&(o[e]={tableRows:d,tableCells:s,rows:I})})),Vl({totalTables:l,totalRows:a,totalCells:n,totalValues:x(e.getValueIds()),jsonLength:pt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStoreRefinement:d,getPrettyStoreRefinement:s,getStore:()=>e})}));exports.createTools=Pl;
Binary file