tinybase 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/cjs/checkpoints.cjs +1 -0
  2. package/lib/cjs/checkpoints.cjs.gz +0 -0
  3. package/lib/cjs/checkpoints.d.ts +959 -0
  4. package/lib/cjs/common.cjs +1 -0
  5. package/lib/cjs/common.cjs.gz +0 -0
  6. package/lib/cjs/common.d.ts +115 -0
  7. package/lib/cjs/indexes.cjs +1 -0
  8. package/lib/cjs/indexes.cjs.gz +0 -0
  9. package/lib/cjs/indexes.d.ts +966 -0
  10. package/lib/cjs/metrics.cjs +1 -0
  11. package/lib/cjs/metrics.cjs.gz +0 -0
  12. package/lib/cjs/metrics.d.ts +827 -0
  13. package/lib/cjs/persisters.cjs +1 -0
  14. package/lib/cjs/persisters.cjs.gz +0 -0
  15. package/lib/cjs/persisters.d.ts +727 -0
  16. package/lib/cjs/queries.cjs +1 -0
  17. package/lib/cjs/queries.cjs.gz +0 -0
  18. package/lib/cjs/queries.d.ts +3024 -0
  19. package/lib/cjs/relationships.cjs +1 -0
  20. package/lib/cjs/relationships.cjs.gz +0 -0
  21. package/lib/cjs/relationships.d.ts +1201 -0
  22. package/lib/cjs/store.cjs +1 -0
  23. package/lib/cjs/store.cjs.gz +0 -0
  24. package/lib/cjs/store.d.ts +5244 -0
  25. package/lib/cjs/tinybase.cjs +1 -0
  26. package/lib/cjs/tinybase.cjs.gz +0 -0
  27. package/lib/cjs/tinybase.d.ts +14 -0
  28. package/lib/cjs/tools.cjs +1 -0
  29. package/lib/cjs/tools.cjs.gz +0 -0
  30. package/lib/cjs/tools.d.ts +512 -0
  31. package/lib/cjs/ui-react.cjs +1 -0
  32. package/lib/cjs/ui-react.cjs.gz +0 -0
  33. package/lib/cjs/ui-react.d.ts +10921 -0
  34. package/lib/cjs-es6/checkpoints.cjs +1 -0
  35. package/lib/cjs-es6/checkpoints.cjs.gz +0 -0
  36. package/lib/cjs-es6/checkpoints.d.ts +959 -0
  37. package/lib/cjs-es6/common.cjs +1 -0
  38. package/lib/cjs-es6/common.cjs.gz +0 -0
  39. package/lib/cjs-es6/common.d.ts +115 -0
  40. package/lib/cjs-es6/indexes.cjs +1 -0
  41. package/lib/cjs-es6/indexes.cjs.gz +0 -0
  42. package/lib/cjs-es6/indexes.d.ts +966 -0
  43. package/lib/cjs-es6/metrics.cjs +1 -0
  44. package/lib/cjs-es6/metrics.cjs.gz +0 -0
  45. package/lib/cjs-es6/metrics.d.ts +827 -0
  46. package/lib/cjs-es6/persisters.cjs +1 -0
  47. package/lib/cjs-es6/persisters.cjs.gz +0 -0
  48. package/lib/cjs-es6/persisters.d.ts +727 -0
  49. package/lib/cjs-es6/queries.cjs +1 -0
  50. package/lib/cjs-es6/queries.cjs.gz +0 -0
  51. package/lib/cjs-es6/queries.d.ts +3024 -0
  52. package/lib/cjs-es6/relationships.cjs +1 -0
  53. package/lib/cjs-es6/relationships.cjs.gz +0 -0
  54. package/lib/cjs-es6/relationships.d.ts +1201 -0
  55. package/lib/cjs-es6/store.cjs +1 -0
  56. package/lib/cjs-es6/store.cjs.gz +0 -0
  57. package/lib/cjs-es6/store.d.ts +5244 -0
  58. package/lib/cjs-es6/tinybase.cjs +1 -0
  59. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  60. package/lib/cjs-es6/tinybase.d.ts +14 -0
  61. package/lib/cjs-es6/tools.cjs +1 -0
  62. package/lib/cjs-es6/tools.cjs.gz +0 -0
  63. package/lib/cjs-es6/tools.d.ts +512 -0
  64. package/lib/cjs-es6/ui-react.cjs +1 -0
  65. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  66. package/lib/cjs-es6/ui-react.d.ts +10921 -0
  67. package/package.json +27 -19
  68. package/readme.md +1 -1
@@ -0,0 +1 @@
1
+ "use strict";var e=require("fs");const t=e=>typeof e,n=t(""),s=t(!0),r=t(0),l=t(t),o=e=>""+e,a=(e,t)=>e.includes(t),i=(e,t)=>e.every(t),d=(e,t)=>g(e)===g(t)&&i(e,((e,n)=>t[n]===e)),c=(e,t)=>i(e,((n,s)=>0==s||t(e[s-1],n)<=0)),u=(e,t)=>e.sort(t),v=(e,t)=>e.forEach(t),h=(e,t)=>e.map(t),f=e=>L(e,((e,t)=>e+t),0),g=e=>e.length,p=e=>0==g(e),L=(e,t,n)=>e.reduce(t,n),w=(e,t,n)=>e.slice(t,n),y=(e,...t)=>e.push(...t),I=e=>e.pop(),R=e=>e.shift(),S=e=>JSON.stringify(e,((e,t)=>C(t,Map)?L([...t],((e,[t,n])=>(e[t]=n,e)),{}):t)),T=JSON.parse,b=Math.max,m=Math.min,x=isFinite,C=(e,t)=>e instanceof t,V=e=>null==e,E=(e,t,n)=>V(e)?null==n?void 0:n():t(e),P=e=>e==n||e==s,k=e=>t(e)==l,J=e=>Array.isArray(e),M=()=>{},A=e=>e.size,D=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},O=e=>V(e)||0==A(e),F=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},j=e=>e.clear(),Q=(e,t)=>null==e?void 0:e.forEach(t),z=(e,t)=>null==e?void 0:e.delete(t),N=e=>new Map(e),W=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},q=(e,t)=>null==e?void 0:e.get(t),B=(e,t)=>Q(e,((e,n)=>t(n,e))),H=(e,t,n)=>V(n)?(z(e,t),e):null==e?void 0:e.set(t,n),$=(e,t,n)=>(D(e,t)||H(e,t,n()),q(e,t)),G=(e,t,n)=>{const s={},r=null!=t?t:e=>e;return Q(e,((e,t)=>E(r(e),(e=>(null==n?void 0:n(e))?0:s[t]=e)))),s},K=(e,t)=>{const n=N(),s=null!=t?t:e=>e;return Q(e,((e,t)=>n.set(t,s(e)))),n},U=e=>K(e,K),X=(e,t,n,s,r=0)=>E((n?$:q)(e,t[r],r>g(t)-2?n:N),(l=>{if(r>g(t)-2)return(null==s?void 0:s(l))&&H(e,t[r]),l;const o=X(l,t,n,s,r+1);return O(l)&&H(e,t[r]),o})),Y=e=>{const n=t(e);return P(n)||n==r&&x(e)?n:void 0},Z=(e,t,n,s,r)=>V(r)?e.delCell(t,n,s,!0):e.setCell(t,n,s,r),_=(e,t,n)=>V(n)?e.delValue(t):e.setValue(t,n),ee=e=>new Set(J(e)||V(e)?e:[e]),te=(e,t)=>null==e?void 0:e.add(t),ne=(e,t,n)=>{const s=e.hasRow,r=N(),l=N(),o=N(),a=N(),i=N(),c=(t,n,...s)=>{const r=$(i,t,ee);return v(s,(t=>te(r,t)&&n&&e.callListener(t))),s},u=(t,...n)=>E(q(i,t),(s=>{v(p(n)?F(s):n,(t=>{e.delListener(t),z(s,t)})),O(s)&&H(i,t)})),h=(e,n)=>{H(r,e,n),D(l,e)||(H(l,e,t()),H(o,e,N()),H(a,e,N()))},f=e=>{H(r,e),H(l,e),H(o,e),H(a,e),u(e)};return[()=>e,()=>W(r),e=>B(l,e),e=>D(l,e),e=>q(r,e),e=>q(l,e),(e,t)=>H(l,e,t),h,(t,r,l,i,f)=>{h(t,r);const g=N(),p=N(),L=q(o,t),w=q(a,t),y=t=>{const l=n=>e.getCell(r,t,n),o=q(L,t),a=s(r,t)?n(i(l,t)):void 0;if(o===a||J(o)&&J(a)&&d(o,a)||H(g,t,[o,a]),!V(f)){const e=q(w,t),n=s(r,t)?f(l,t):void 0;e!=n&&H(p,t,n)}},I=e=>{l((()=>{Q(g,(([,e],t)=>H(L,t,e))),Q(p,((e,t)=>H(w,t,e)))}),g,p,L,w,e),j(g),j(p)};B(L,y),e.hasTable(r)&&v(e.getRowIds(r),(e=>{D(L,e)||y(e)})),I(!0),u(t),c(t,0,e.addRowListener(r,null,((e,t,n)=>y(n))),e.addTableListener(r,(()=>I())))},f,()=>B(i,f),c,u]},se=(e,s)=>t(e)==n?t=>t(e):null!=e?e:()=>null!=s?s:"",re=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},le=/^\d+$/,oe=()=>{const e=[];let t=0;return[()=>{var n;return null!=(n=R(e))?n:""+t++},t=>{le.test(t)&&g(e)<1e3&&y(e,t)}]},ae=e=>{let t;const[n,s]=oe(),r=N();return[(s,l,o,a=[],i=(()=>[]))=>{null!=t||(t=e());const d=n();return H(r,d,[s,l,o,a,i]),te(X(l,null!=o?o:[""],ee),d),d},(e,n,...s)=>v(((e,t=[""])=>{const n=[],s=(e,r)=>r==g(t)?y(n,e):null===t[r]?Q(e,(e=>s(e,r+1))):v([t[r],null],(t=>s(q(e,t),r+1)));return s(e,0),n})(e,n),(e=>Q(e,(e=>q(r,e)[0](t,...null!=n?n:[],...s))))),e=>E(q(r,e),(([,t,n])=>(X(t,null!=n?n:[""],void 0,(t=>(z(t,e),O(t)?1:0))),H(r,e),s(e),n))),e=>E(q(r,e),(([e,,n=[],s,r])=>{const l=(...o)=>{var a,i;const d=g(o);d==g(n)?e(t,...o,...r(o)):V(n[d])?v(null!=(i=null==(a=s[d])?void 0:a.call(s,...o))?i:[],(e=>l(...o,e))):l(...o,n[d])};l()}))]},ie=Object,de=ie.keys,ce=ie.isFrozen,ue=ie.freeze,ve=e=>C(e,ie)&&e.constructor==ie,he=(e,t)=>!V(((e,t)=>E(e,(e=>e[t])))(e,t)),fe=(e,t)=>delete e[t],ge=(e,t)=>h(ie.entries(e),(([e,n])=>t(n,e))),pe=e=>ve(e)&&p(de(e)),Le=re((e=>{let t,n,s,r=100,l=N(),o=N(),i=1;const d=N(),c=N(),[u,h,f]=ae((()=>U)),L=N(),w=N(),S=[],T=[],b=(t,n)=>{i=0,e.transaction((()=>{const[s,r]=q(L,n);Q(s,((n,s)=>Q(n,((n,r)=>Q(n,((n,l)=>Z(e,s,r,l,n[t]))))))),Q(r,((n,s)=>_(e,s,n[t])))})),i=1},m=e=>{H(L,e),H(w,e),h(c,[e])},x=(e,t)=>v(((e,t)=>e.splice(0,t))(e,null!=t?t:g(e)),m),C=()=>x(S,g(S)-r),P=()=>E(t,(()=>{y(S,t),C(),x(T),t=void 0,s=1})),k=()=>{t=I(S),s=1},J=e.addCellListener(null,null,null,((e,t,n,s,r,o)=>{if(i){P();const e=$(l,t,N),a=$(e,n,N),i=$(a,s,(()=>[o,void 0]));i[1]=r,i[0]===r&&O(H(a,s))&&O(H(e,n))&&O(H(l,t))&&k(),z()}})),M=e.addValueListener(null,((e,t,n,s)=>{if(i){P();const e=$(o,t,(()=>[s,void 0]));e[1]=n,e[0]===n&&O(H(o,t))&&k(),z()}})),A=(e="")=>(V(t)&&(t=""+n++,H(L,t,[l,o]),G(t,e),l=N(),o=N(),s=1),t),F=()=>{p(S)||(((e,...t)=>{e.unshift(...t)})(T,A()),b(0,t),t=I(S),s=1)},j=()=>{p(T)||(y(S,t),t=R(T),b(1,t),s=1)},z=()=>{s&&(h(d),s=0)},W=e=>{const t=A(e);return z(),t},G=(e,t)=>(K(e)&&q(w,e)!==t&&(H(w,e,t),h(c,[e])),U),K=e=>D(L,e),U={setSize:e=>(r=e,C(),U),addCheckpoint:W,setCheckpoint:G,getStore:()=>e,getCheckpointIds:()=>[[...S],t,[...T]],forEachCheckpoint:e=>B(w,e),hasCheckpoint:K,getCheckpoint:e=>q(w,e),goBackward:()=>(F(),z(),U),goForward:()=>(j(),z(),U),goTo:e=>{const n=a(S,e)?F:a(T,e)?j:null;for(;!V(n)&&e!=t;)n();return z(),U},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(f(e),U),clear:()=>(x(S),x(T),V(t)||m(t),t=void 0,n=0,W(),U),destroy:()=>{e.delListener(J),e.delListener(M)},getListenerStats:()=>({})};return ue(U.clear())})),we=(e,t)=>e<t?-1:1,ye=re((e=>{const t=N(),n=N(),[s,r,l,a,i,d,v,,f,g,p]=ne(e,N,(e=>V(e)?"":J(e)?h(e,o):o(e))),[L,w,y]=ae((()=>R)),I=(t,n,s)=>{const r=i(t);Q(s,((t,s)=>n(s,(n=>Q(t,(t=>n(t,(n=>e.forEachCell(r,t,n)))))))))},R={setIndexDefinition:(e,s,r,l,o,a=we)=>{const i=V(o)?void 0:([e],[t])=>o(e,t);return f(e,s,((s,r,o,h,f,g)=>{let p=0;const L=ee(),y=ee(),I=d(e);if(Q(r,(([e,t],n)=>{const s=ee(e),r=ee(t);Q(s,(e=>z(r,e)?z(s,e):0)),Q(s,(e=>{te(L,e),E(q(I,e),(t=>{z(t,n),O(t)&&(H(I,e),p=1)}))})),Q(r,(e=>{te(L,e),D(I,e)||(H(I,e,ee()),p=1),te(q(I,e),n),V(l)||te(y,e)}))})),s(),O(f)||(g?B(I,(e=>te(y,e))):B(o,(e=>E(q(h,e),(e=>te(y,e))))),Q(y,(e=>{const t=(t,n)=>a(q(f,t),q(f,n),e),n=[...q(I,e)];c(n,t)||(H(I,e,ee(u(n,t))),te(L,e))}))),(p||g)&&!V(i)){const t=[...I];c(t,i)||(v(e,N(u(t,i))),p=1)}p&&w(t,[e]),Q(L,(t=>w(n,[e,t])))}),se(r),E(l,se)),R},delIndexDefinition:e=>(g(e),R),getStore:s,getIndexIds:r,forEachIndex:e=>l(((t,n)=>e(t,(e=>I(t,e,n))))),forEachSlice:(e,t)=>I(e,t,d(e)),hasIndex:a,hasSlice:(e,t)=>D(d(e),t),getTableId:i,getSliceIds:e=>W(d(e)),getSliceRowIds:(e,t)=>F(q(d(e),t)),addSliceIdsListener:(e,n)=>L(n,t,[e]),addSliceRowIdsListener:(e,t,s)=>L(s,n,[e,t]),delListener:e=>(y(e),R),destroy:p,getListenerStats:()=>({})};return ue(R)})),Ie=N([["avg",[(e,t)=>f(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,s)=>e+(t-n)/s]],["max",[e=>b(...e),(e,t)=>b(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:b(t,e)]],["min",[e=>m(...e),(e,t)=>m(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:m(t,e)]],["sum",[e=>f(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Re=(e,t,n,s,r,l=!1)=>{if(O(n))return;const[o,a,i,d]=r;return l||(l=V(e)),Q(s,(([n,s])=>{l||(e=V(n)?null==a?void 0:a(e,s,t++):V(s)?null==i?void 0:i(e,n,t--):null==d?void 0:d(e,s,n,t),l||(l=V(e)))})),l?o(F(n),A(n)):e},Se=re((e=>{const t=N(),[n,s,r,l,o,a,i,,d,c,u]=ne(e,M,(e=>isNaN(e)||V(e)||!0===e||!1===e||""===e?void 0:1*e)),[v,h,f]=ae((()=>g)),g={setMetricDefinition:(e,n,s,r,l,o,c)=>{var u;const v=k(s)?[s,l,o,c]:null!=(u=q(Ie,s))?u:q(Ie,"sum");return d(e,n,((n,s,r,l,o,d)=>{const c=a(e),u=A(l);d||(d=V(c)),n();let f=Re(c,u,l,s,v,d);x(f)||(f=void 0),f!=c&&(i(e,f),h(t,[e],f,c))}),se(r,1)),g},delMetricDefinition:e=>(c(e),g),getStore:n,getMetricIds:s,forEachMetric:r,hasMetric:l,getTableId:o,getMetric:a,addMetricListener:(e,n)=>v(n,t,[e]),delListener:e=>(f(e),g),destroy:u,getListenerStats:()=>({})};return ue(g)}));var Te=(e,t,n)=>new Promise(((s,r)=>{var l=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);a((n=n.apply(e,t)).next())}));const be=(e,t,n,s,r)=>{let l,o,a=0;const i={load:(n,s)=>Te(void 0,null,(function*(){if(2!=a){a=1;const r=yield t();V(r)||""==r?e.transaction((()=>e.setTables(n).setValues(s))):e.setJson(r),a=0}return i})),startAutoLoad:(e,t)=>Te(void 0,null,(function*(){return i.stopAutoLoad(),yield i.load(e,t),s(i.load),i})),stopAutoLoad:()=>(r(),i),save:()=>Te(void 0,null,(function*(){return 1!=a&&(a=2,yield n(e.getJson()),a=0),i})),startAutoSave:()=>Te(void 0,null,(function*(){return yield i.stopAutoSave().save(),l=e.addTablesListener(i.save),o=e.addValuesListener(i.save),i})),stopAutoSave:()=>(E(l,e.delListener),E(o,e.delListener),i),getStore:()=>e,destroy:()=>i.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return ue(i)};var me=(e,t,n)=>new Promise(((s,r)=>{var l=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);a((n=n.apply(e,t)).next())}));const xe=globalThis.window,Ce=(e,t,n)=>{let s;return be(e,(()=>me(void 0,null,(function*(){return n.getItem(t)}))),(e=>me(void 0,null,(function*(){return n.setItem(t,e)}))),(e=>{s=s=>{s.storageArea===n&&s.key===t&&e()},xe.addEventListener("storage",s)}),(()=>{xe.removeEventListener("storage",s),s=void 0}))};var Ve=(e,t,n)=>new Promise(((s,r)=>{var l=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);a((n=n.apply(e,t)).next())})),Ee=(e,t,n)=>new Promise(((s,r)=>{var l=e=>{try{a(n.next(e))}catch(e){r(e)}},o=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);a((n=n.apply(e,t)).next())}));const Pe=e=>e.headers.get("ETag");var ke=Object.getOwnPropertySymbols,Je=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;const Ae=re((e=>{const t=e.createStore,[n,s,r,l,o,,,a,,d,c,u,h]=ne(e,(()=>!0),M),f=t(),L=t(),I=N(),R=(e,t,...n)=>v(n,(n=>te($($(I,t,N),e,ee),n))),S=e=>{E(q(I,e),(e=>{B(e,((e,t)=>Q(t,(t=>e.delListener(t))))),j(e)})),v([L,f],(t=>t.delTable(e)))},T=(e,t,n)=>R(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),b={setQueryDefinition:(t,n,s)=>{a(t,n),S(t);const r=[],l=[[null,[n,null,null,[],N()]]],o=[],d=[],c=[];s({select:(e,t)=>{const n=k(e)?[g(r)+"",e]:[V(t)?e:t,n=>n(e,t)];return y(r,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const s=V(n)||k(t)?null:t,r=V(s)?t:n,o=[e,[e,s,k(r)?r:e=>e(r),[],N()]];return y(l,o),{as:e=>o[0]=e}},where:(e,t,n)=>y(o,k(e)?e:V(n)?n=>n(e)===t:s=>s(e,t)===n),group:(e,t,n,s,r)=>{var l;const o=[e,[e,k(t)?[t,n,s,r]:null!=(l=q(Ie,t))?l:[(e,t)=>t]]];return y(d,o),{as:e=>o[0]=e}},having:(e,t)=>y(c,k(e)?e:n=>n(e)===t)});const w=N(r);if(O(w))return b;const I=N(l);B(I,((e,[,t])=>E(q(I,t),(({3:t})=>V(e)?0:y(t,e)))));const m=N(d);let x=f;if(O(m)&&p(c))x=L;else{T(t,x,L);const e=N();B(m,((t,[n,s])=>te($(e,n,ee),[t,s])));const n=ee();B(w,(t=>D(e,t)?0:te(n,t)));const s=N(),r=(n,s,r,l)=>E(n,(([o,a,d,u])=>{B(s,((t,[n])=>{const s=$(o,t,N),a=q(s,r),i=l?void 0:n;if(a!==i){const n=ee([[a,i]]),l=A(s);H(s,r,i),Q(q(e,t),(([e,t])=>{const r=Re(u[e],l,s,n,t);u[e]=V(Y(r))?null:r}))}})),O(a)||!i(c,(e=>e((e=>u[e]))))?L.delRow(t,d):V(d)?n[2]=L.addRow(t,u):L.setRow(t,d,u)}));R(x,t,x.addRowListener(t,null,((l,o,a,i)=>{const d=[],c=[],u=N(),v=x.hasRow(t,a);let h=!v;Q(n,(e=>{const[n,s,r]=i(t,a,e);y(d,s),y(c,r),h||(h=n)})),B(e,(e=>{const[n,,s]=i(t,a,e);(h||n)&&H(u,e,[s])})),h&&r(X(s,d,void 0,(([,e])=>(z(e,a),O(e)))),u,a,1),v&&r(X(s,c,(()=>{const e={};return Q(n,(n=>e[n]=x.getCell(t,a,n))),[N(),ee(),void 0,e]}),(([,e])=>{te(e,a)})),u,a)})))}T(t,e,x);const C=(s,r,l,a)=>{const d=t=>e.getCell(r,l,t);v(a,(n=>{var r;const[l,,o,a,i]=q(I,n),c=null==o?void 0:o(d,s),[v,f]=null!=(r=q(i,s))?r:[];c!=v&&(V(f)||h(t,f),H(i,s,V(c)?null:[c,...u(t,1,e.addRowListener(l,c,(()=>C(s,l,c,a))))]))})),(s=>{const r=(t,r)=>{var l,o,a;return e.getCell(...V(r)?[n,s,t]:t===n?[n,s,r]:[null==(l=q(I,t))?void 0:l[0],null==(a=q(null==(o=q(I,t))?void 0:o[4],s))?void 0:a[0],r])};x.transaction((()=>i(o,(e=>e(r)))?B(w,((e,n)=>Z(x,t,s,e,n(r,s)))):x.delRow(t,s)))})(s)},{3:P}=q(I,null);return x.transaction((()=>u(t,1,e.addRowListener(n,null,((s,r,l)=>{e.hasRow(n,l)?C(l,n,l,P):(x.delRow(t,l),Q(I,(({4:e})=>E(q(e,l),(([,n])=>{h(t,n),H(e,l)})))))}))))),b},delQueryDefinition:e=>(S(e),d(e),b),getStore:n,getQueryIds:s,forEachQuery:r,hasQuery:l,getTableId:o,delListener:e=>(L.delListener(e),b),destroy:c,getListenerStats:()=>((e,t)=>{var n={};for(var s in e)Je.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&ke)for(var s of ke(e))t.indexOf(s)<0&&Me.call(e,s)&&(n[s]=e[s]);return n})(L.getListenerStats(),["tables","tableIds","transaction"])};return ge({Table:[1,1],RowIds:[0,1],SortedRowIds:[0,5],Row:[1,2],CellIds:[0,2],Cell:[1,3]},(([e,t],n)=>{v(e?["get","has","forEach"]:["get"],(e=>b[e+"Result"+n]=(...t)=>L[e+n](...t))),b["addResult"+n+"Listener"]=(...e)=>L["add"+n+"Listener"](...w(e,0,t),((n,...s)=>e[t](b,...s)))})),ue(b)})),De=re((e=>{const t=N(),n=N(),s=N(),r=N(),[l,o,a,i,d,c,,,u,v,h]=ne(e,(()=>[N(),N(),N(),N()]),(e=>V(e)?void 0:e+"")),[f,g,p]=ae((()=>I)),L=(e,t,n)=>E(c(e),(([s,,r])=>{if(!D(r,t)){const l=ee();if(d(e)!=y(e))te(l,t);else{let e=t;for(;!V(e)&&!D(l,e);)te(l,e),e=q(s,e)}if(n)return l;H(r,t,l)}return q(r,t)})),w=(e,t)=>E(c(e),(([,,e])=>H(e,t))),y=e=>q(t,e),I={setRelationshipDefinition:(e,l,o,a)=>(H(t,e,o),u(e,l,((t,l)=>{const o=ee(),a=ee(),i=ee(),[d,u]=c(e);Q(l,(([t,n],s)=>{V(t)||(te(a,t),E(q(u,t),(e=>{z(e,s),O(e)&&H(u,t)}))),V(n)||(te(a,n),D(u,n)||H(u,n,ee()),te(q(u,n),s)),te(o,s),H(d,s,n),B(q(r,e),(t=>{D(L(e,t),s)&&te(i,t)}))})),t(),Q(o,(t=>g(n,[e,t]))),Q(a,(t=>g(s,[e,t]))),Q(i,(t=>{w(e,t),g(r,[e,t])}))}),se(a)),I),delRelationshipDefinition:e=>(H(t,e),v(e),I),getStore:l,getRelationshipIds:o,forEachRelationship:t=>a((n=>t(n,(t=>e.forEachRow(d(n),t))))),hasRelationship:i,getLocalTableId:d,getRemoteTableId:y,getRemoteRowId:(e,t)=>{var n;return q(null==(n=c(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return F(q(null==(n=c(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>V(c(e))?[t]:F(L(e,t,!0)),addRemoteRowIdListener:(e,t,s)=>f(s,n,[e,t]),addLocalRowIdsListener:(e,t,n)=>f(n,s,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(L(e,t),f(n,r,[e,t])),delListener:e=>(w(...p(e)),I),destroy:h,getListenerStats:()=>({})};return ue(I)})),Oe=e=>[e,e],Fe=()=>[N(),N()],je=(e,t,n,s=H)=>{const r=(l=e=>!he(t,e),W(e).filter(l));var l;return v(de(t),(s=>n(e,s,t[s]))),v(r,(t=>s(e,t))),e},Qe=(e,t,n)=>V(e)||!ve(e)||pe(e)||ce(e)?(null==n||n(),!1):(ge(e,((n,s)=>{t(n,s)||fe(e,s)})),!pe(e)),ze=(e,t,n)=>H(e,t,q(e,t)==-n?void 0:n),Ne=()=>{let e,t,n,s,l=0;const i=N(),c=N(),f=N(),g=N(),p=N(),L=N(),I=N(),R=N(),b=N(),m=N(),x=N(),C=N(),J=ee(),M=N(),A=N(),F=N(),X=Fe(),ne=Fe(),se=Fe(),re=Fe(),le=Fe(),ie=Fe(),de=Fe(),ce=Fe(),ve=Fe(),Le=Fe(),ye=Fe(),Ie=Fe(),Re=Fe(),Se=Fe(),[Te,be,me,xe]=ae((()=>Nt)),Ce=e=>{if(!Qe(e,((e,t)=>a(["type","default"],t))))return!1;const t=e.type;return!(!P(t)&&t!=r||(Y(e.default)!=t&&fe(e,"default"),0))},Ve=(t,n)=>(!e||D(b,n)||ct(n))&&Qe(t,((e,t)=>Ee(n,t,e)),(()=>ct(n))),Ee=(e,t,n,s)=>Qe(s?n:Me(n,e,t),((s,r)=>E(Pe(e,t,r,s),(e=>(n[r]=e,!0)),(()=>!1))),(()=>ct(e,t))),Pe=(t,n,s,r)=>e?E(q(q(b,t),s),(e=>Y(r)!=e.type?ct(t,n,s,r,e.default):r),(()=>ct(t,n,s,r))):V(Y(r))?ct(t,n,s,r):r,ke=(e,t)=>Qe(t?e:Ae(e),((t,n)=>E(Je(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>ut())),Je=(e,n)=>t?E(q(x,e),(t=>Y(n)!=t.type?ut(e,n,t.default):n),(()=>ut(e,n))):V(Y(n))?ut(e,n):n,Me=(e,t,n)=>(E(q(m,t),(([s,r])=>{Q(s,((t,n)=>{he(e,n)||(e[n]=t)})),Q(r,(s=>{he(e,s)||ct(t,n,s)}))})),e),Ae=e=>(t&&(Q(C,((t,n)=>{he(e,n)||(e[n]=t)})),Q(J,(t=>{he(e,t)||ut(t)}))),e),De=e=>je(b,e,((e,t,n)=>{const s=N(),r=ee();je($(b,t,N),n,((e,t,n)=>{H(e,t,n),E(n.default,(e=>H(s,t,e)),(()=>te(r,t)))})),H(m,t,[s,r])}),((e,t)=>{H(b,t),H(m,t)})),We=e=>je(x,e,((e,t,n)=>{H(x,t,n),E(n.default,(e=>H(C,t,e)),(()=>te(J,t)))}),((e,t)=>{H(x,t),H(C,t),z(J,t)})),qe=e=>pe(e)?At():Et(e),Be=e=>je(A,e,((e,t,n)=>He(t,n)),((e,t)=>et(t))),He=(e,t)=>je($(A,e,(()=>(rt(e,1),N()))),t,((t,n,s)=>$e(e,t,n,s)),((t,n)=>tt(e,t,n))),$e=(e,t,n,s,r)=>je($(t,n,(()=>(lt(e,n,1),N()))),s,((t,s,r)=>Ge(e,n,t,s,r)),((s,l)=>nt(e,t,n,s,l,r))),Ge=(e,t,n,s,r)=>{D(n,s)||ot(e,t,s,1);const l=q(n,s);r!==l&&(at(e,t,s,l,r),H(n,s,r))},Ke=(e,t,n,s,r)=>E(q(t,n),(t=>Ge(e,n,t,s,r)),(()=>$e(e,t,n,Me({[s]:r},e,n)))),Ue=e=>pe(e)?Dt():Pt(e),Xe=e=>je(F,e,((e,t,n)=>Ye(t,n)),((e,t)=>st(t))),Ye=(e,t)=>{D(F,e)||it(e,1);const n=q(F,e);t!==n&&(dt(e,n,t),H(F,e,t))},Ze=e=>{const[t]=$(M,e,oe),n=t();return D(q(A,e),n)?Ze(e):n},_e=e=>{var t;return null!=(t=q(A,e))?t:He(e,{})},et=e=>He(e,{}),tt=(e,t,n)=>{const[,s]=$(M,e,oe);s(n),$e(e,t,n,{},!0)},nt=(e,t,n,s,r,l)=>{var o;const a=q(null==(o=q(m,e))?void 0:o[0],r);if(!V(a)&&!l)return Ge(e,n,s,r,a);const i=t=>{at(e,n,t,q(s,t)),ot(e,n,t,-1),H(s,t)};V(a)?i(r):B(s,i),O(s)&&(lt(e,n,-1),O(H(t,n))&&(rt(e,-1),H(A,e),H(M,e)))},st=e=>{const t=q(C,e);if(!V(t))return Ye(e,t);dt(e,q(F,e)),it(e,-1),H(F,e)},rt=(e,t)=>ze(i,e,t),lt=(e,t,n)=>ze($(c,e,N),t,n),ot=(e,t,n,s)=>ze($($(f,e,N),t,N),n,s),at=(e,t,n,s,r)=>$($($(g,e,N),t,N),n,(()=>[s,0]))[1]=r,it=(e,t)=>ze(p,e,t),dt=(e,t,n)=>$(L,e,(()=>[t,0]))[1]=n,ct=(e,t,n,s,r)=>(y($($($(I,e,N),t,N),n,(()=>[])),s),r),ut=(e,t,n)=>(y($(R,e,(()=>[])),t),n),vt=(e,t,n)=>E(q(q(q(g,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Oe(mt(e,t,n))])),ht=e=>E(q(L,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Oe(Vt(e))])),ft=e=>O(I)||O(ve[e])?0:Q(e?K(I,U):I,((t,n)=>Q(t,((t,s)=>Q(t,((t,r)=>be(ve[e],[n,s,r],t))))))),gt=e=>O(R)||O(Le[e])?0:Q(e?K(R):R,((t,n)=>be(Le[e],[n],t))),pt=(e,t,n)=>{if(!O(t))return be(e,n),1},Lt=e=>{const t=O(le[e]),n=O(de[e])&&O(re[e])&&t&&O(ne[e]),s=O(ce[e])&&O(ie[e])&&O(se[e])&&O(X[e]);if(!n||!s){const r=e?[K(i),U(c),K(f,U),K(g,U)]:[i,c,f,g];if(!n){Q(r[2],((t,n)=>Q(t,((t,s)=>pt(de[e],t,[n,s])))));const n=ee();Q(r[1],((s,r)=>{pt(re[e],s,[r])&&!t&&(be(le[e],[r,null]),te(n,r))})),t||Q(r[3],((t,s)=>{if(!D(n,s)){const n=ee();Q(t,(e=>Q(e,(([t,s],r)=>s!==t?te(n,r):z(e,r))))),Q(n,(t=>be(le[e],[s,t])))}})),pt(ne[e],r[0])}if(!s){let t;Q(r[3],((n,s)=>{let r;Q(n,((n,l)=>{let o;Q(n,(([n,a],i)=>{a!==n&&(be(ce[e],[s,l,i],a,n,vt),t=r=o=1)})),o&&be(ie[e],[s,l],vt)})),r&&be(se[e],[s],vt)})),t&&be(X[e],void 0,vt)}}},wt=e=>{const t=O(Ie[e]),n=O(Re[e])&&O(ye[e]);if(!t||!n){const s=e?[K(p),K(L)]:[p,L];if(t||pt(Ie[e],s[0]),!n){let t;Q(s[1],(([n,s],r)=>{s!==n&&(be(Re[e],[r],s,n,ht),t=1)})),t&&be(ye[e],void 0,ht)}}},yt=(e,...t)=>(jt((()=>e(...h(t,o)))),Nt),It=()=>G(A,(e=>G(e,G))),Rt=()=>W(A),St=e=>W(q(A,o(e))),Tt=(e,t,n,s=0,r)=>{return h(w(u((l=q(A,o(e)),a=(e,n)=>[V(t)?n:q(e,o(t)),n],h([...null!=(i=null==l?void 0:l.entries())?i:[]],(([e,t])=>a(t,e)))),(([e],[t])=>we(e,t)*(n?-1:1))),s,V(r)?r:s+r),(([,e])=>e));var l,a,i},bt=(e,t)=>W(q(q(A,o(e)),o(t))),mt=(e,t,n)=>q(q(q(A,o(e)),o(t)),o(n)),xt=()=>G(F),Ct=()=>W(F),Vt=e=>q(F,o(e)),Et=e=>yt((()=>(e=>Qe(e,Ve,ct))(e)?Be(e):0)),Pt=e=>yt((()=>ke(e)?Xe(e):0)),kt=e=>{try{qe(T(e))}catch(e){}return Nt},Jt=t=>yt((()=>{if((e=Qe(t,(e=>Qe(e,Ce))))&&(De(t),!O(A))){const e=It();At(),Et(e)}})),Mt=e=>yt((()=>{if(t=(e=>Qe(e,Ce))(e)){const n=xt();Ft(),Dt(),t=!0,We(e),Pt(n)}})),At=()=>yt((()=>Be({}))),Dt=()=>yt((()=>Xe({}))),Ot=()=>yt((()=>{De({}),e=!1})),Ft=()=>yt((()=>{We({}),t=!1})),jt=(e,t)=>{if(-1==l)return;Qt();const n=e();return zt(t),n},Qt=()=>(l++,Nt),zt=e=>(l>0&&(l--,0==l&&(n=!O(g),s=!O(L),l=1,ft(1),n&&Lt(1),gt(1),s&&wt(1),l=-1,(null==e?void 0:e(G(g,(e=>G(e,(e=>G(e,(e=>[...e]),(([e,t])=>e===t))),pe)),pe),G(I,(e=>G(e,G))),G(L,(e=>[...e]),(([e,t])=>e===t)),G(R)))&&(l=1,Q(g,((e,t)=>Q(e,((e,n)=>Q(e,(([e],s)=>Z(Nt,t,n,s,e))))))),Q(L,(([e],t)=>_(Nt,t,e))),l=-1,n=s=!1),be(Se[0],void 0,n,s),ft(0),n&&Lt(0),gt(0),s&&wt(0),be(Se[1],void 0,n,s),l=0,v([i,c,f,g,I,p,L,R],j))),Nt),Nt={getTables:It,getTableIds:Rt,getTable:e=>G(q(A,o(e)),G),getRowIds:St,getSortedRowIds:Tt,getRow:(e,t)=>G(q(q(A,o(e)),o(t))),getCellIds:bt,getCell:mt,getValues:xt,getValueIds:Ct,getValue:Vt,hasTables:()=>!O(A),hasTable:e=>D(A,o(e)),hasRow:(e,t)=>D(q(A,o(e)),o(t)),hasCell:(e,t,n)=>D(q(q(A,o(e)),o(t)),o(n)),hasValues:()=>!O(F),hasValue:e=>D(F,o(e)),getTablesJson:()=>S(A),getValuesJson:()=>S(F),getJson:()=>S([A,F]),getTablesSchemaJson:()=>S(b),getValuesSchemaJson:()=>S(x),getSchemaJson:()=>S([b,x]),setTables:Et,setTable:(e,t)=>yt((e=>Ve(t,e)?He(e,t):0),e),setRow:(e,t,n)=>yt(((e,t)=>Ee(e,t,n)?$e(e,_e(e),t,n):0),e,t),addRow:(e,t)=>jt((()=>{let n;return Ee(e,n,t)&&(e=o(e),$e(e,_e(e),n=Ze(e),t)),n})),setPartialRow:(e,t,n)=>yt(((e,t)=>{if(Ee(e,t,n,1)){const s=_e(e);ge(n,((n,r)=>Ke(e,s,t,r,n)))}}),e,t),setCell:(e,t,n,s)=>yt(((e,t,n)=>E(Pe(e,t,n,k(s)?s(mt(e,t,n)):s),(s=>Ke(e,_e(e),t,n,s)))),e,t,n),setValues:Pt,setPartialValues:e=>yt((()=>ke(e,1)?ge(e,((e,t)=>Ye(t,e))):0)),setValue:(e,t)=>yt((e=>E(Je(e,k(t)?t(Vt(e)):t),(t=>Ye(e,t)))),e),setTablesJson:kt,setValuesJson:e=>{try{Ue(T(e))}catch(e){}return Nt},setJson:e=>{try{const[t,n]=T(e);qe(t),Ue(n)}catch(t){kt(e)}return Nt},setTablesSchema:Jt,setValuesSchema:Mt,setSchema:(e,t)=>yt((()=>{Jt(e),Mt(t)})),delTables:At,delTable:e=>yt((e=>D(A,e)?et(e):0),e),delRow:(e,t)=>yt(((e,t)=>E(q(A,e),(n=>D(n,t)?tt(e,n,t):0))),e,t),delCell:(e,t,n,s)=>yt(((e,t,n)=>E(q(A,e),(r=>E(q(r,t),(l=>D(l,n)?nt(e,r,t,l,n,s):0))))),e,t,n),delValues:Dt,delValue:e=>yt((e=>D(F,e)?st(e):0),e),delTablesSchema:Ot,delValuesSchema:Ft,delSchema:()=>yt((()=>{Ot(),Ft()})),transaction:jt,startTransaction:Qt,finishTransaction:zt,forEachTable:e=>Q(A,((t,n)=>e(n,(e=>Q(t,((t,n)=>e(n,(e=>B(t,e))))))))),forEachRow:(e,t)=>Q(q(A,o(e)),((e,n)=>t(n,(t=>B(e,t))))),forEachCell:(e,t,n)=>B(q(q(A,o(e)),o(t)),n),forEachValue:e=>B(F,e),addSortedRowIdsListener:(e,t,n,s,r,l,o)=>{let a=Tt(e,t,n,s,r);return Te((()=>{const o=Tt(e,t,n,s,r);d(o,a)||(a=o,l(Nt,e,t,n,s,r,a))}),le[o?1:0],[e,t],[Rt])},addWillFinishTransactionListener:e=>Te(e,Se[0]),addDidFinishTransactionListener:e=>Te(e,Se[1]),callListener:e=>(xe(e),Nt),delListener:e=>(me(e),Nt),getListenerStats:()=>({}),createStore:Ne};return ge({Tables:[0,X],TableIds:[0,ne],Table:[1,se,[Rt]],RowIds:[1,re,[Rt]],Row:[2,ie,[Rt,St]],CellIds:[2,de,[Rt,St]],Cell:[3,ce,[Rt,St,bt],e=>Oe(mt(...e))],InvalidCell:[3,ve],Values:[0,ye],ValueIds:[0,Ie],Value:[1,Re,[Ct],e=>Oe(Vt(e[0]))],InvalidValue:[1,Le]},(([e,t,n,s],r)=>{Nt["add"+r+"Listener"]=(...r)=>Te(r[e],t[r[e+1]?1:0],e>0?w(r,0,e):void 0,n,s)})),ue(Nt)};exports.createCheckpoints=Le,exports.createCustomPersister=be,exports.createFilePersister=(t,n)=>{let s;return be(t,(()=>Ve(void 0,null,(function*(){try{return yield e.promises.readFile(n,"utf8")}catch(e){}}))),(t=>Ve(void 0,null,(function*(){try{yield e.promises.writeFile(n,t,"utf8")}catch(e){}}))),(t=>{s=e.watch(n,t)}),(()=>{null==s||s.close(),s=void 0}))},exports.createIndexes=ye,exports.createLocalPersister=(e,t)=>Ce(e,t,localStorage),exports.createMetrics=Se,exports.createQueries=Ae,exports.createRelationships=De,exports.createRemotePersister=(e,t,n,s)=>{let r,l;return be(e,(()=>Ee(void 0,null,(function*(){const e=yield fetch(t);return l=Pe(e),e.text()}))),(e=>Ee(void 0,null,(function*(){return yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}))),(e=>{r=setInterval((()=>Ee(void 0,null,(function*(){const n=yield fetch(t,{method:"HEAD"}),s=Pe(n);V(l)||V(s)||s==l||(l=s,e())}))),1e3*s)}),(()=>{E(r,clearInterval),r=void 0}))},exports.createSessionPersister=(e,t)=>Ce(e,t,sessionStorage),exports.createStore=Ne,exports.defaultSorter=we;
Binary file
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This is everything.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ export * from './checkpoints';
8
+ export * from './common';
9
+ export * from './indexes';
10
+ export * from './metrics';
11
+ export * from './persisters';
12
+ export * from './queries';
13
+ export * from './relationships';
14
+ export * from './store';
@@ -0,0 +1 @@
1
+ "use strict";const e=e=>typeof e,a="",l=e(a),t=e(!0),o=e(0),s="type",n="default",r=(e,a)=>e.every(a),d=(e,a)=>e.sort(a),$=(e,a)=>e.forEach(a),i=(e,a)=>e.map(a),u=e=>e.length,I=e=>0==u(e),c=(e,...a)=>e.push(...a),b=e=>e.pop(),w=(e,...a)=>e.unshift(...a),h=e=>e.shift(),g=JSON.parse,C=isFinite,T=(e,a)=>e instanceof a,V=e=>null==e,v=e=>e==l||e==t,f=a=>e(a)==l,R=e=>Array.isArray(e),m=a=>{const l=e(a);return v(l)||l==o&&C(a)?l:void 0},p=(e,a)=>{var l;return null!=(l=null==e?void 0:e.has(a))&&l},L=e=>{var a;return[...null!=(a=null==e?void 0:e.values())?a:[]]},y=(e,a)=>null==e?void 0:e.forEach(a),S=(e,a)=>null==e?void 0:e.delete(a),k=e=>new Map(e),J=(e,a)=>null==e?void 0:e.get(a),E=(e,a)=>y(e,((e,l)=>a(l,e))),O=(e,a)=>{var l;return i([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>a(l,e)))},j=(e,a,l)=>V(l)?(S(e,a),e):null==e?void 0:e.set(a,l),x=(e,a,l)=>(p(e,a)||j(e,a,l()),J(e,a)),A=e=>new Set(R(e)||V(e)?e:[e]),P=(e,a)=>null==e?void 0:e.add(a),D=e=>[e,e],N=()=>[k(),k()],G=/[^A-Za-z]+/,z=/[^A-Za-z0-9]+/,F=/^( *)\/\*\* *(.*?) *\*\/$/gm,W=(e,a,l)=>e.substring(a,l),M=e=>e.toUpperCase(),Z=e=>e.toLowerCase(),_=(e,a,l,t=1)=>{const o=`${a}${1==t?"":t}`;return p(e,o)?_(e,a,l,t+1):(j(e,o,l),o)},Q=e=>e.replace(F,((e,a,l)=>{const t=77-U(a);return`${a}/**\n${l.replace(RegExp(`([^\\n]{1,${t}})(\\s|$)`,"g"),a+" * $1\n")}${a} */`})),U=e=>e.length,q=(e,l=a)=>e.join(l),B=e=>e.flat(1e3),H=(e,a=0)=>q(i(e.split(z),((e,l)=>(l>0||a?M:Z)(W(e,0,1))+W(e,1)))),K=e=>M(q((e&&!G.test(e[0])?e:" "+e).split(z),"_")),X=e=>`/** ${e}. */`,Y=()=>{const e=N(),l=k(),t=k(),o=k();return[(...e)=>q(B(e),"\n"),(a,l,...t)=>$(t,(t=>P(x(e[a],l,A),t))),(e,a,t)=>_(l,e,[a,t]),(e,a,l,o,s,n="")=>_(t,e,[a,l,o,s,n]),(e,a,l)=>_(o,e,R(l)?[`(${a}) => {`,l,"}"]:[`(${a}) => ${l}`]),(e,a)=>J(o,e)===a?e:_(o,e,a),l=>[...d(O(e[l],((e,a)=>`import {${q(d(L(e)),", ")}} from '${a}';`))),a],()=>O(l,(([e,l],t)=>[X(l),`export type ${t} = ${e};`,a])),e=>O(t,(([l,t,o,s,n],r)=>{const d=e?[`${r}: ${n}(${l}): ${t} => ${o},`]:[`${r}${n}(${l}): ${t};`];return e||w(d,X(s)),c(d,a),d})),()=>O(o,((e,l)=>(e=R(e)?e:[e],c(e,b(e)+";"),[`const ${l} = ${h(e)}`,e,a])))]},ee=Object,ae=ee.keys,le=ee.freeze,te=e=>T(e,ee)&&e.constructor==ee,oe=(e,a)=>i(ee.entries(e),(([e,l])=>a(l,e))),se=e=>te(e)&&I(ae(e)),ne=e=>{const a=new WeakMap;return l=>(a.has(l)||a.set(l,e(l)),a.get(l))},re="the Store",de="A function for",$e="export",ie="listener",ue=" | undefined",Ie=`Registers a ${ie} that will be called`,ce="Represents",be=" => void",we="the end of the transaction",he="the specified Row",ge="a string serialization of",Ce=(e=0,a=0)=>`the ${De[e]}content of${a?" "+re:""}`,Te=(e,a=0,l=0)=>`${Ae[e]} ${Ce(a,1)}${l?" when set":""}`,Ve=(e,a=0)=>`${ce} a Row when ${a?"s":"g"}etting ${Ce()} the '${e}' Table`,ve=(e,a,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in ${a}`,fe=(e,a)=>`Calls a function for each ${e} in ${a}`,Re=(e,a=re)=>`Gets whether ${e} exists in ${a}`,me=e=>"A function that takes "+e,pe=(e,a=0)=>`${de} listening to changes to ${Pe[e]} in ${Pe[a]}`,Le=(e,l,t=0)=>`${Ie} whenever ${e} in ${l} change`+(t?a:"s"),ye=e=>`the '${e}' Table`,Se=e=>`${he} in ${ye(e)}`,ke=e=>`the '${e}' Cell`,Je=e=>`the '${e}' Value`,Ee=(e,a=0)=>`${Ae[a]} ${Ce()} ${ye(e)}`,Oe=(e,a=0)=>`${Ae[a]} ${Ce()} ${Se(e)}`,je=(e,a,l=0)=>`${Ae[l]} ${ke(a)} for ${Se(e)}`,xe=(e,a=0)=>`${Ae[a]} ${Je(e)}`,Ae=["Gets","Sets","Sets part of","Deletes",ce,"Gets "+ge,"Sets "+ge,Ie+" whenever"],Pe=[re,"Tables","Table Ids","a Table","Row Ids","a Row","Cell Ids","a Cell","invalid Cell changes","Values","Value Ids","a Value","invalid Value changes"],De=["","tabular ","keyed value "],Ne=["DoRollback","Id","IdOrNull","Ids","Json","Store"],Ge=(e,l=a,t=a)=>`store.${e}(${l})${t?" as "+t:a}`,ze=(e,l=a)=>`fluent(() => ${Ge(e,l)})`,Fe=(e,l=a,t=a)=>`store.${e}(${l?l+", ":a}proxy(${ie})${t?", "+t:a})`,We=(e,l,o)=>{if(se(e)&&se(l))return D(a);const[r,d,$,i,u,I,b,w,h,g]=Y(),C=`./${H(o)}.d`,T=H(o,1),v=H(T),R=[],m=k(),p=l=>oe(e,((e,t)=>l(t,x(m,t,(()=>{const e=H(t,1);return[$(e+"Table",`{[rowId: Id]: ${e}Row}`,`${ce} the '${t}' Table`),$(e+"Row",`{${q(y(t,((e,l,t)=>`'${e}'${V(t)?"?":a}: ${l};`))," ")}}`,Ve(t)),$(e+"RowWhenSet",`{${q(y(t,((e,a)=>`'${e}'?: ${a};`))," ")}}`,Ve(t,1)),$(e+"CellId",q(y(t,(e=>`'${e}'`))," | "),`A Cell Id for the '${t}' Table`),$(e+"CellCallback",`(...[cellId, cell]: ${q(y(t,((e,a)=>`[cellId: '${e}', cell: ${a}]`))," | ")})${be}`,me(`a Cell Id and value from a Row in the '${t}' Table`)),$(e+"RowCallback",`(rowId: Id, forEachCell: (cellCallback: ${e}CellCallback)${be})${be}`,me(`a Row Id from the '${t}' Table, and a Cell iterator`))]})),H(t,1),I(K(t),`'${t}'`)))),y=(a,l)=>oe(e[a],((e,a)=>l(a,e[s],e[n],I(K(a),`'${a}'`),H(a,1)))),S=e=>oe(l,((a,l)=>e(l,a[s],a[n],I(K(l),`'${l}'`),H(l,1))));if(d(1,C,T,`create${T} as create${T}Decl`),!se(e)){const e=$("Tables",`{${q(p(((e,a)=>`'${e}'?: ${a[0]};`))," ")}}`,Te(4,1)),l=$("TableId",q(p((e=>`'${e}'`))," | "),"A Table Id in "+re),o=$("TableCallback",`(...[tableId, rowCallback]: ${q(p(((e,a)=>`[tableId: '${e}', forEachRow: (rowCallback: ${a[5]})${be}]`))," | ")})${be}`,me("a Table Id, and a Row iterator")),r=$("GetCellChange",`(...[tableId, rowId, cellId]: ${q(p(((e,a)=>`[tableId: '${e}', rowId: Id, cellId: ${a[3]}]`))," | ")}) => CellChange`,de+" returning information about any Cell's changes during a transaction"),u=$("TablesListener",`(${v}: ${T}, getCellChange: ${r}${ue})${be}`,pe(1)),b=$("TableIdsListener",`(${v}: ${T})${be}`,pe(2)),w=$("TableListener",`(${v}: ${T}, tableId: ${l}, getCellChange: ${r}${ue})${be}`,pe(3)),h=$("RowIdsListener",`(${v}: ${T}, tableId: ${l})`+be,pe(4,3)),g=$("RowListener",`(${v}: ${T}, tableId: ${l}, rowId: Id, getCellChange: ${r}${ue})${be}`,pe(5,3)),m=$("CellIdsListener",`(${v}: ${T}, tableId: ${l}, rowId: Id)`+be,pe(6,5)),S=$("CellListener",`(...[${v}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${q(B(p((e=>y(e,((a,l)=>`[${v}: ${T}, tableId: '${e}', rowId: Id, cellId: '${a}', newCell: ${l}${ue}, oldCell: ${l}${ue}, getCellChange: ${r} | undefined]`)))))," | ")})${be}`,pe(7,5)),J=$("InvalidCellListener",`(${v}: ${T}, tableId: Id, rowId: Id, cellId: Id, invalidCells: any[])${be}`,pe(8));i("hasTables",a,t,Ge("hasTables"),Re("any Table")),i("getTables",a,e,Ge("getTables"),Te(0,1)),i("setTables","tables: "+e,T,ze("setTables","tables"),Te(1,1)),i("delTables",a,T,ze("delTables"),Te(3,1)),i("getTableIds",a,l+"[]",Ge("getTableIds",a,l+"[]"),ve("Table",re)),i("forEachTable","tableCallback: "+o,"void",Ge("forEachTable","tableCallback as any"),fe("Table",re));const O=k();p(((e,[l,o,s,n,r,$],u,I)=>{d(1,C,l,o,s,n,r,$),i(`has${u}Table`,a,t,Ge("hasTable",I),Re(ye(e))),i(`get${u}Table`,a,l,Ge("getTable",I,l),Ee(e)),i(`set${u}Table`,"table: "+l,T,ze("setTable",I+", table"),Ee(e,1)),i(`del${u}Table`,a,T,ze("delTable",I),Ee(e,3)),i(`get${u}RowIds`,a,"Ids",Ge("getRowIds",I),ve("Row",ye(e))),i(`get${u}SortedRowIds`,`cellId?: ${n}, descending?: boolean, offset?: number, limit?: number`,"Ids",Ge("getSortedRowIds",I+", cellId, descending, offset, limit"),ve("Row",ye(e),1)),i(`forEach${u}Row`,"rowCallback: "+$,"void",Ge("forEachRow",I+", rowCallback as any"),fe("Row",ye(e))),i(`has${u}Row`,"rowId: Id",t,Ge("hasRow",I+", rowId"),Re(he,ye(e))),i(`get${u}Row`,"rowId: Id",o,Ge("getRow",I+", rowId",o),Oe(e)),i(`set${u}Row`,"rowId: Id, row: "+s,T,ze("setRow",I+", rowId, row"),Oe(e,1)),i(`add${u}Row`,"row: "+s,"Id"+ue,Ge("addRow",I+", row"),"Adds a new Row to "+ye(e)),i(`set${u}PartialRow`,"rowId: Id, partialRow: "+s,T,ze("setPartialRow",I+", rowId, partialRow"),Oe(e,2)),i(`del${u}Row`,"rowId: Id",T,ze("delRow",I+", rowId"),Oe(e,3)),i(`get${u}CellIds`,"rowId: Id",n+"[]",Ge("getCellIds",I+", rowId",n+"[]"),ve("Cell",Se(e))),i(`forEach${u}Cell`,"rowId: Id, cellCallback: "+r,"void",Ge("forEachCell",I+", rowId, cellCallback as any"),fe("Cell",Se(e))),y(e,((l,o,s,n,r)=>{const d="Map"+H(o,1);j(O,o,d),i(`has${u}${r}Cell`,"rowId: Id",t,Ge("hasCell",`${I}, rowId, ${n}`),Re(ke(l),Se(e)));const $=`${o}${V(s)?ue:a}`;i(`get${u}${r}Cell`,"rowId: Id",$,Ge("getCell",`${I}, rowId, ${n}`,$),je(e,l)),i(`set${u}${r}Cell`,`rowId: Id, cell: ${o} | ${d}`,T,ze("setCell",`${I}, rowId, ${n}, cell as any`),je(e,l,1)),i(`del${u}${r}Cell`,"rowId: Id",T,ze("delCell",`${I}, rowId, ${n}`),je(e,l,3))}))})),i("getTablesJson",a,"Json",Ge("getTablesJson"),Te(5,1)),i("setTablesJson","tablesJson: Json",T,ze("setTablesJson","tablesJson"),Te(6,1)),i("addTablesListener",`${ie}: ${u}, mutator?: boolean`,"Id",Fe("addTablesListener",a,"mutator"),Te(7,1)+" changes"),i("addTableIdsListener",`${ie}: ${b}, mutator?: boolean`,"Id",Fe("addTableIdsListener",a,"mutator"),Le("the Table Ids",re,1)),i("addTableListener",`tableId: ${l} | null, ${ie}: ${w}, mutator?: boolean`,"Id",Fe("addTableListener","tableId","mutator"),Le("a Table",re)),i("addRowIdsListener",`tableId: ${l} | null, ${ie}: ${h}, mutator?: boolean`,"Id",Fe("addRowIdsListener","tableId","mutator"),Le("the Row Ids","a Table",1)),i("addRowListener",`tableId: ${l} | null, rowId: IdOrNull, ${ie}: ${g}, mutator?: boolean`,"Id",Fe("addRowListener","tableId, rowId","mutator"),Le("a Row","a Table")),i("addCellIdsListener",`tableId: ${l} | null, rowId: IdOrNull, ${ie}: ${m}, mutator?: boolean`,"Id",Fe("addCellIdsListener","tableId, rowId","mutator"),Le("the Cell Ids","a Row",1)),i("addCellListener",`tableId: ${l} | null, rowId: IdOrNull, cellId: ${q(p(((e,a)=>a[3]))," | ")} | null, ${ie}: ${S}, mutator?: boolean`,"Id",Fe("addCellListener","tableId, rowId, cellId","mutator"),Le("a Cell","a Row")),i("addInvalidCellListener",`tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull, ${ie}: ${J}, mutator?: boolean`,"Id",Fe("addInvalidCellListener","tableId, rowId, cellId","mutator"),Ie+" whenever an invalid Cell change was attempted"),E(O,((e,a)=>$(a,`(cell: ${e}${ue}) => ${e}`,`Takes a ${e} Cell value and returns another`))),d(1,C,e,l,o,u,b,w,h,g,m,S,J,...L(O)),d(0,"tinybase","CellChange"),c(R,".setTablesSchema({",B(p(((e,l,t,o)=>[`[${o}]: {`,...y(e,((e,l,t,o)=>`[${o}]: {[${I(K(s),`'${s}'`)}]: ${I(K(l),`'${l}'`)}${V(t)?a:`, [${I(K(n),`'${n}'`)}]: ${f(t)?I(K(t),`'${t}'`):t}`}},`)),"},"]))),"})")}if(!se(l)){const e=$("Values",`{${q(S(((e,l,t)=>`'${e}'${V(t)?"?":a}: ${l};`))," ")}}`,Te(4,2)),l=$("ValuesWhenSet",`{${q(S(((e,a)=>`'${e}'?: ${a};`))," ")}}`,Te(4,2,1)),o=$("ValueId",q(S((e=>`'${e}'`))," | "),"A Value Id in "+re),r=$("ValueCallback",`(...[valueId, rowCallback]: ${q(S(((e,a)=>`[valueId: '${e}', value: ${a}]`))," | ")})${be}`,me("a Value Id, and value")),u=$("GetValueChange",`(valueId: ${o}) => ValueChange`,de+" returning information about any Value's changes during a transaction"),b=$("ValuesListener",`(${v}: ${T}, getValueChange: ${u}${ue})`+be,pe(9)),w=$("ValueIdsListener",`(${v}: ${T})${be}`,pe(10)),h=$("ValueListener",`(...[${v}, valueId, newValue, oldValue, getValueChange]: ${q(S(((e,a)=>`[${v}: ${T}, valueId: '${e}', newValue: ${a}${ue}, oldValue: ${a}${ue}, getValueChange: ${u} | undefined]`))," | ")})${be}`,pe(11)),g=$("InvalidValueListener",`(${v}: ${T}, valueId: Id, invalidValues: any[])${be}`,pe(12));i("hasValues",a,t,Ge("hasValues"),Re("any Value")),i("getValues",a,e,Ge("getValues",a,e),Te(0,2)),i("setValues","values: "+l,T,ze("setValues","values"),Te(1,2)),i("setPartialValues","partialValues: "+l,T,ze("setPartialValues","partialValues"),Te(2,2)),i("delValues",a,T,ze("delValues"),Te(3,2)),i("getValueIds",a,o+"[]",Ge("getValueIds",a,o+"[]"),ve("Value",re)),i("forEachValue","valueCallback: "+r,"void",Ge("forEachValue","valueCallback as any"),fe("Value",re)),S(((e,l,o,s,n)=>{i(`has${n}Value`,a,t,Ge("hasValue",s),Re(Je(e))),i(`get${n}Value`,a,l,Ge("getValue",s,l),xe(e)),i(`set${n}Value`,"value: "+l,T,ze("setValue",s+", value"),xe(e,1)),i(`del${n}Value`,a,T,ze("delValue",s),xe(e,3))})),i("getValuesJson",a,"Json",Ge("getValuesJson"),Te(5,2)),i("setValuesJson","valuesJson: Json",T,ze("setValuesJson","valuesJson"),Te(6,2)),i("addValuesListener",`${ie}: ${b}, mutator?: boolean`,"Id",Fe("addValuesListener",a,"mutator"),Te(7,2)+" changes"),i("addValueIdsListener",`${ie}: ${w}, mutator?: boolean`,"Id",Fe("addValueIdsListener",a,"mutator"),Le("the Value Ids",re,1)),i("addValueListener",`valueId: ${o} | null, ${ie}: ${h}, mutator?: boolean`,"Id",Fe("addValueListener","valueId","mutator"),Le("a Value",re)),i("addInvalidValueListener",`valueId: IdOrNull, ${ie}: ${g}, mutator?: boolean`,"Id",Fe("addInvalidValueListener","valueId","mutator"),Ie+" whenever an invalid Cell change was attempted"),d(1,C,e,l,o,r,b,w,h,g),d(0,"tinybase","ValueChange"),c(R,".setValuesSchema({",S(((e,l,t,o)=>[`[${o}]: {[${I(K(s),`'${s}'`)}]: ${I(K(l),`'${l}'`)}${V(t)?a:`, [${I(K(n),`'${n}'`)}]: ${f(t)?I(K(t),`'${t}'`):t}`}},`])),"})")}d(0,"tinybase",...Ne);const J=$("TransactionListener",`(${v}: ${T}, cellsTouched: boolean, valuesTouched: boolean)${be}`,de+" listening to the completion of a transaction");return i("getJson",a,"Json",Ge("getJson"),Te(5)),i("setJson","json: Json",T,ze("setJson","json"),Te(6)),i("transaction","actions: () => Return, doRollback?: DoRollback","Return",Ge("transaction","actions, doRollback"),"Execute a transaction to make multiple mutations","<Return>"),i("startTransaction",a,T,ze("startTransaction"),"Explicitly starts a transaction"),i("finishTransaction","doRollback?: DoRollback,",T,ze("finishTransaction","doRollback"),"Explicitly finishes a transaction"),i("addWillFinishTransactionListener",`${ie}: ${J}`,"Id",Fe("addWillFinishTransactionListener"),`${Ie} just before ${we}`),i("addDidFinishTransactionListener",`${ie}: ${J}`,"Id",Fe("addDidFinishTransactionListener"),`${Ie} just after ${we}`),i("callListener",ie+"Id: Id",T,ze("callListener",ie+"Id"),`Manually provoke a ${ie} to be called`),i("delListener",ie+"Id: Id",T,ze("delListener",ie+"Id"),`Remove a ${ie} that was previously added to ${re}`),i("getStore",a,"Store","store",Ae[0]+" the underlying Store object"),d(1,"tinybase","createStore",...Ne),d(1,C,T,`create${T} as create${T}Decl`,J),I("store",["createStore()",...R]),u("fluent","actions: () => Store",["actions();",`return ${v};`]),u("proxy",ie+": any",`(_: Store, ...args: any[]) => ${ie}(${v}, ...args)`),I(v,["{",...h(1),"}"]),[r(...b(0),...w(),`${$e} interface ${T} {`,...h(0),"}",a,X(`Creates a ${T} object`),`${$e} function create${T}(): ${T};`),r(...b(1),`${$e} const create${T}: typeof create${T}Decl = () => {`,...g(),`return Object.freeze(${v});`,"};")]};var Me=Object.defineProperty,Ze=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable,Ue=(e,a,l)=>a in e?Me(e,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[a]=l,qe=(e,a)=>{for(var l in a||(a={}))_e.call(a,l)&&Ue(e,l,a[l]);if(Ze)for(var l of Ze(a))Qe.call(a,l)&&Ue(e,l,a[l]);return e},Be=(e,a,l)=>new Promise(((t,o)=>{var s=e=>{try{r(l.next(e))}catch(e){o(e)}},n=e=>{try{r(l.throw(e))}catch(e){o(e)}},r=e=>e.done?t(e.value):Promise.resolve(e.value).then(s,n);r((l=l.apply(e,a)).next())}));const He={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Ke=ne((e=>{const a=()=>{const a=g(e.getTablesSchemaJson());return!se(a)||r(e.getTableIds(),(l=>{const t=e.getRowIds(l),o=k();if(r(t,(a=>r(e.getCellIds(l,a),(t=>{const s=e.getCell(l,a,t),n=x(o,t,(()=>[m(s),k(),[0],0])),[r,d,[$]]=n,i=x(d,s,(()=>0))+1;return i>$&&(n[2]=[i,s]),j(d,s,i),n[3]++,r==m(s)})))))return a[l]={},y(o,(([e,,[,o],r],d)=>{a[l][d]=qe({[s]:e},r==u(t)?{[n]:o}:{})})),1}))?a:{}},l=()=>{const a=g(e.getValuesSchemaJson());return se(a)&&e.forEachValue(((e,l)=>{a[e]={[s]:m(l)}})),a},t=e=>We(a(),l(),e),o=e=>Be(void 0,null,(function*(){let a;try{a=(yield import("prettier")).format}catch(e){a=e=>e}return i(t(e),(e=>Q(a(e,He))))}));return le({getStoreStats:a=>{let l=0,t=0,o=0;const s={};return e.forEachTable(((e,n)=>{l++;let r=0,d=0;const $={};n(((e,l)=>{r++;let t=0;l((()=>t++)),d+=t,a&&($[e]={rowCells:t})})),t+=r,o+=d,a&&(s[e]={tableRows:r,tableCells:d,rows:$})})),qe({totalTables:l,totalRows:t,totalCells:o,totalValues:u(e.getValueIds()),jsonLength:U(e.getJson())},a?{detail:{tables:s}}:{})},getStoreTablesSchema:a,getStoreValuesSchema:l,getStoreApi:t,getPrettyStoreApi:o,getStore:()=>e})}));exports.createTools=Ke;
Binary file
@@ -0,0 +1,512 @@
1
+ /**
2
+ * The tools module of the TinyBase project provides utilities for working with
3
+ * TinyBase during development.
4
+ *
5
+ * This module is not intended to be directly used at runtime in a production
6
+ * environment.
7
+ *
8
+ * @packageDocumentation
9
+ * @module tools
10
+ * @since v2.2.0
11
+ */
12
+
13
+ import {Store, TablesSchema, ValuesSchema} from './store.d';
14
+ import {Id} from './common.d';
15
+
16
+ /**
17
+ * The StoreStats type describes a set of statistics about the Store, and
18
+ * is used for debugging purposes.
19
+ *
20
+ * A StoreStats object is returned from the getStoreStats method.
21
+ *
22
+ * @category Statistics
23
+ * @since v2.2.0
24
+ */
25
+ export type StoreStats = {
26
+ /**
27
+ * The number of Table objects in the Store.
28
+ */
29
+ totalTables: number;
30
+ /**
31
+ * The number of Row objects in the Store, across all Table objects.
32
+ */
33
+ totalRows: number;
34
+ /**
35
+ * The number of Cell objects in the Store, across all Row objects, across all
36
+ * Table objects.
37
+ */
38
+ totalCells: number;
39
+ /**
40
+ * The number of Value objects in the Store, since v3.0.0.
41
+ */
42
+ totalValues: number;
43
+ /**
44
+ * The string length of the Store when serialized to JSON.
45
+ */
46
+ jsonLength: number;
47
+ /**
48
+ * Additional detailed statistics about the Store if the `detail` flag is
49
+ * specified in the getStoreStats method.
50
+ */
51
+ detail?: StoreStatsDetail;
52
+ };
53
+
54
+ /**
55
+ * The StoreStatsDetail type describes a more detailed set of statistics about
56
+ * the Store, and is used for debugging purposes.
57
+ *
58
+ * A StoreStatsDetail object is added to the StoreStats object (returned from
59
+ * the getStoreStats method) when the `detail` flag is specified.
60
+ *
61
+ * @category Statistics
62
+ * @since v2.2.0
63
+ */
64
+ export type StoreStatsDetail = {
65
+ /**
66
+ * Information about each Table in the Store.
67
+ */
68
+ tables: {[tableId: Id]: StoreStatsTableDetail};
69
+ };
70
+
71
+ /**
72
+ * The StoreStatsTableDetail type describes a detailed set of statistics about a
73
+ * single Table in the Store, and is used for debugging purposes.
74
+ *
75
+ * @category Statistics
76
+ * @since v2.2.0
77
+ */
78
+ export type StoreStatsTableDetail = {
79
+ /**
80
+ * The number of Row objects in the Table.
81
+ */
82
+ tableRows: number;
83
+ /**
84
+ * The number of Cell objects in the Table, across all Row objects.
85
+ */
86
+ tableCells: number;
87
+ rows: {[rowId: Id]: StoreStatsRowDetail};
88
+ };
89
+
90
+ /**
91
+ * The StoreStatsRowDetail type describes statistics about a single Row in the
92
+ * Store, and is used for debugging purposes.
93
+ *
94
+ * @category Statistics
95
+ * @since v2.2.0
96
+ */
97
+ export type StoreStatsRowDetail = {
98
+ /**
99
+ * The number of Cell objects in the Row.
100
+ */
101
+ rowCells: number;
102
+ };
103
+
104
+ /**
105
+ * A Tools object lets you run various utilities on, and get certain information
106
+ * about, Store objects in development.
107
+ *
108
+ * @see Developer Tools guides
109
+ * @category Tools
110
+ * @since v2.2.0
111
+ */
112
+ export interface Tools {
113
+ /* eslint-disable max-len */
114
+ /**
115
+ * The getStoreStats method provides a set of statistics about the Store, and
116
+ * is used for debugging purposes.
117
+ *
118
+ * @param detail An optional boolean that indicates more detailed stats about
119
+ * the inner structure of the Store should be returned.
120
+ * @returns A StoreStats object containing statistics about the Store.
121
+ * @example
122
+ * This example creates a Tools object and gets basic statistics about it.
123
+ * ```js
124
+ * const store = createStore()
125
+ * .setTable('pets', {
126
+ * fido: {species: 'dog', color: 'brown'},
127
+ * felix: {species: 'cat', color: 'black'},
128
+ * cujo: {species: 'dog', color: 'black'},
129
+ * })
130
+ * .setTable('species', {
131
+ * dog: {price: 5},
132
+ * cat: {price: 4},
133
+ * })
134
+ * .setValues({open: true, employees: 3});
135
+ * const tools = createTools(store);
136
+ * console.log(tools.getStoreStats());
137
+ * // -> {totalTables: 2, totalRows: 5, totalCells: 8, totalValues: 2, jsonLength: 212}
138
+ * ```
139
+ * @example
140
+ * This example creates a Tools object and gets detailed statistics about it.
141
+ * ```js
142
+ * const store = createStore()
143
+ * .setTable('pets', {
144
+ * fido: {species: 'dog', color: 'brown'},
145
+ * felix: {species: 'cat', color: 'black'},
146
+ * cujo: {species: 'dog', color: 'black'},
147
+ * })
148
+ * .setTable('species', {
149
+ * dog: {price: 5},
150
+ * cat: {price: 4},
151
+ * });
152
+ * const stats = createTools(store).getStoreStats(true);
153
+ *
154
+ * console.log(stats.totalTables);
155
+ * // -> 2
156
+ * console.log(stats.totalRows);
157
+ * // -> 5
158
+ * console.log(stats.totalCells);
159
+ * // -> 8
160
+ * console.log(stats.detail.tables.pets.tableRows);
161
+ * // -> 3
162
+ * console.log(stats.detail.tables.pets.tableCells);
163
+ * // -> 6
164
+ * console.log(stats.detail.tables.pets.rows);
165
+ * // -> {fido: {rowCells: 2}, felix: {rowCells: 2}, cujo: {rowCells: 2}}
166
+ * ```
167
+ * @category Statistics
168
+ * @since v2.2.0
169
+ */
170
+ getStoreStats(detail?: boolean): StoreStats;
171
+ /* eslint-enable max-len */
172
+
173
+ /**
174
+ * The getStoreTablesSchema method returns the TablesSchema of the Store as an
175
+ * object.
176
+ *
177
+ * If the Store does not already have an explicit TablesSchema associated with
178
+ * it, the data in the Store will be scanned to attempt to infer a new
179
+ * TablesSchema.
180
+ *
181
+ * To be successful, this requires all the values of a given Cell across a
182
+ * Table object's Row objects to have a consistent type. If a given Cell Id
183
+ * appears in every Row, then a `default` for that Cell is specified in the
184
+ * TablesSchema, based on the most common value found.
185
+ *
186
+ * @returns A TablesSchema object for the Store.
187
+ * @example
188
+ * This example creates a Tools object and gets the schema of a Store that
189
+ * already has a TablesSchema.
190
+ * ```js
191
+ * const store = createStore().setTablesSchema({
192
+ * pets: {
193
+ * species: {type: 'string'},
194
+ * color: {type: 'string'},
195
+ * },
196
+ * species: {
197
+ * price: {type: 'number'},
198
+ * },
199
+ * });
200
+ * const schema = createTools(store).getStoreTablesSchema();
201
+ * console.log(schema.pets);
202
+ * // -> {species: {type: 'string'}, color: {type: 'string'}}
203
+ * ```
204
+ * @example
205
+ * This example creates a Tools object and infers the schema of a Store that
206
+ * doesn't already have a TablesSchema.
207
+ * ```js
208
+ * const store = createStore()
209
+ * .setTable('pets', {
210
+ * fido: {species: 'dog', color: 'brown'},
211
+ * felix: {species: 'cat', color: 'black'},
212
+ * cujo: {species: 'dog', color: 'black'},
213
+ * })
214
+ * .setTable('species', {
215
+ * dog: {price: 5, barks: true},
216
+ * cat: {price: 4, purrs: true},
217
+ * });
218
+ * const schema = createTools(store).getStoreTablesSchema();
219
+ * console.log(schema.pets.species);
220
+ * // -> {type: 'string', default: 'dog'}
221
+ * console.log(schema.pets.color);
222
+ * // -> {type: 'string', default: 'black'}
223
+ * console.log(schema.species.price);
224
+ * // -> {type: 'number', default: 5}
225
+ * console.log(schema.species.barks);
226
+ * // -> {type: 'boolean'}
227
+ * console.log(schema.species.purrs);
228
+ * // -> {type: 'boolean'}
229
+ * ```
230
+ * @category Modelling
231
+ * @since v3.0.0
232
+ */
233
+ getStoreTablesSchema(): TablesSchema;
234
+
235
+ /**
236
+ * The getStoreValuesSchema method returns the ValuesSchema of the Store as an
237
+ * object.
238
+ *
239
+ * If the Store does not already have an explicit ValuesSchema associated with
240
+ * it, the data in the Store will be scanned to infer a new ValuesSchema,
241
+ * based on the types of the Values present. Note that, unlike the inference
242
+ * of Cell values in the TablesSchema, it is not able to determine whether a
243
+ * Value should have a default or not.
244
+ *
245
+ * @returns A ValuesSchema object for the Store.
246
+ * @example
247
+ * This example creates a Tools object and gets the schema of a Store that
248
+ * already has a ValuesSchema.
249
+ * ```js
250
+ * const store = createStore().setValuesSchema({
251
+ * open: {type: 'boolean', default: true},
252
+ * employees: {type: 'number'},
253
+ * });
254
+ *
255
+ * const schema = createTools(store).getStoreValuesSchema();
256
+ * console.log(schema);
257
+ * // -> {open: {type: 'boolean', default: true}, employees: {type: 'number'}}
258
+ * ```
259
+ * @example
260
+ * This example creates a Tools object and infers the schema of a Store that
261
+ * doesn't already have a ValuesSchema.
262
+ * ```js
263
+ * const store = createStore().setValues({open: true, employees: 3});
264
+ * const schema = createTools(store).getStoreValuesSchema();
265
+ *
266
+ * console.log(schema);
267
+ * // -> {open: {type: 'boolean'}, employees: {type: 'number'}}
268
+ * ```
269
+ * @category Modelling
270
+ * @since v3.0.0
271
+ */
272
+ getStoreValuesSchema(): ValuesSchema;
273
+
274
+ /**
275
+ * The getStoreApi method returns a code-generated .d.ts file and a .ts file
276
+ * that describe the schema of a Store in an ORM style.
277
+ *
278
+ * If the Store does not already have an explicit TablesSchema associated with
279
+ * it, the data in the Store will be scanned to attempt to infer a new
280
+ * TablesSchema. The method returns two strings (which should be saved as
281
+ * files) though if no schema can be inferred, the strings will be empty.
282
+ *
283
+ * The method takes a single argument which represents the name you want the
284
+ * generated store object to have in code. You are expected to save the files
285
+ * as `[storeName].d.ts` and `[storeName].ts`, and alongside each other so
286
+ * that the latter can import types from the former.
287
+ *
288
+ * The .d.ts and .ts files that are generated are designed to resemble the
289
+ * main TinyBase `store.d.ts` and `store.ts` files, but provide named types
290
+ * and methods that describe the domain of the schema in the store.
291
+ *
292
+ * For example, from a Store that has a `pets` Table, you will get methods
293
+ * like `getPetsTable`, and types like `PetsRow`, that are more specific
294
+ * versions of the underlying getTable method or the Row type. For example:
295
+ *
296
+ * |Store type|Equivalent generated type|
297
+ * |-|-|
298
+ * |Table|[Table]Table|
299
+ * |Row|[Table]Row|
300
+ * |(Cell) Id|[Table]CellId|
301
+ * |CellCallback|[Table]CellCallback|
302
+ * |...|...|
303
+ *
304
+ * |Store method|Equivalent generated method|
305
+ * |-|-|
306
+ * |setTable|set[Table]Table|
307
+ * |hasRow|has[Table]Row|
308
+ * |getCell|get[Table][Cell]Cell|
309
+ * |...|...|
310
+ *
311
+ * Equivalent to the TinyBase createStore function, a `create[StoreName]`
312
+ * function will also be created. This acts as the main entry point to the
313
+ * generated implementation.
314
+ *
315
+ * Each method is refined correctly to take, or return, the types specified by
316
+ * the schema. For example, if the `pets` Table has a numeric `price` Cell in
317
+ * the schema, the `getPetsPriceCell` method will be typed to return a number.
318
+ *
319
+ * The tables above include just a sample of the generated output. For the
320
+ * full set of methods and types generated by this method, inspect the output
321
+ * directly.
322
+ *
323
+ * @param storeName The name you want to provide to the generated Store, which
324
+ * should also be used to save the `.d.ts` and `.ts` files.
325
+ * @returns A pair of strings representing the contents of the `.d.ts` and
326
+ * `.ts` files.
327
+ * @example
328
+ * This example creates a Tools object and generates code for a Store that
329
+ * already has a TablesSchema.
330
+ * ```js
331
+ * const store = createStore().setTablesSchema({
332
+ * pets: {
333
+ * price: {type: 'number'},
334
+ * },
335
+ * });
336
+ * const [dTs, ts] = createTools(store).getStoreApi('shop');
337
+ *
338
+ * const dTsLines = dTs.split('\n');
339
+ * console.log(dTsLines[3]);
340
+ * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
341
+ * console.log(dTsLines[6]);
342
+ * // -> 'export type PetsRow = {\'price\'?: number;};'
343
+ *
344
+ * const tsLines = ts.split('\n');
345
+ * console.log(tsLines[41]);
346
+ * // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
347
+ * ```
348
+ * @example
349
+ * This example creates a Tools object and generates code for a Store that
350
+ * doesn't already have a TablesSchema.
351
+ * ```js
352
+ * const store = createStore().setTable('pets', {
353
+ * fido: {price: 5},
354
+ * felix: {price: 4},
355
+ * });
356
+ * const [dTs, ts] = createTools(store).getStoreApi('shop');
357
+ *
358
+ * const dTsLines = dTs.split('\n');
359
+ * console.log(dTsLines[3]);
360
+ * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
361
+ * console.log(dTsLines[6]);
362
+ * // -> 'export type PetsRow = {\'price\': number;};'
363
+ *
364
+ * const tsLines = ts.split('\n');
365
+ * console.log(tsLines[43]);
366
+ * // -> 'getPetsTable: (): PetsTable => store.getTable(PETS) as PetsTable,'
367
+ * ```
368
+ * @category Modelling
369
+ * @since v2.2.0
370
+ */
371
+ getStoreApi(storeName: string): [string, string];
372
+
373
+ /**
374
+ * The getPrettyStoreApi method attempts to returns a prettified
375
+ * code-generated .d.ts file and a .ts file that describe the schema of a
376
+ * Store in an ORM style.
377
+ *
378
+ * This is simply a wrapper around the getStoreApi method that attempts to
379
+ * invoke the `prettier` module (which it hopes you have installed) to format
380
+ * the generated code. If `prettier` is not present, the output will resemble
381
+ * that of the underlying getStoreApi method.
382
+ *
383
+ * The method is asynchronous, so you should use the `await` keyword or handle
384
+ * the results as a promise.
385
+ *
386
+ * The method takes a single argument which represents the name you want the
387
+ * generated store object to have in code. You are expected to save the files
388
+ * as `[storeName].d.ts` and `[storeName].ts`, and alongside each other so
389
+ * that the latter can import types from the former.
390
+ *
391
+ * See the documentation for the getStoreApi method for details of the content
392
+ * of the generated files.
393
+ *
394
+ * @param storeName The name you want to provide to the generated Store, which
395
+ * should also be used to save the `.d.ts` and `.ts` files.
396
+ * @returns A pair of strings representing the contents of the `.d.ts` and
397
+ * `.ts` files.
398
+ * @example
399
+ * This example creates a Tools object and generates code for a Store that
400
+ * already has a TablesSchema.
401
+ * ```js
402
+ * const store = createStore().setTablesSchema({
403
+ * pets: {
404
+ * price: {type: 'number'},
405
+ * },
406
+ * });
407
+ * const tools = createTools(store);
408
+ * const [dTs, ts] = await tools.getPrettyStoreApi('shop');
409
+ *
410
+ * const dTsLines = dTs.split('\n');
411
+ * console.log(dTsLines[5]);
412
+ * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
413
+ * console.log(dTsLines[10]);
414
+ * // -> 'export type PetsRow = {price?: number};'
415
+ *
416
+ * const tsLines = ts.split('\n');
417
+ * console.log(tsLines[72]);
418
+ * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
419
+ * ```
420
+ * @example
421
+ * This example creates a Tools object and generates code for a Store that
422
+ * doesn't already have a TablesSchema.
423
+ * ```js
424
+ * const store = createStore().setTable('pets', {
425
+ * fido: {price: 5},
426
+ * felix: {price: 4},
427
+ * });
428
+ * const tools = createTools(store);
429
+ * const [dTs, ts] = await tools.getPrettyStoreApi('shop');
430
+ *
431
+ * const dTsLines = dTs.split('\n');
432
+ * console.log(dTsLines[5]);
433
+ * // -> 'export type PetsTable = {[rowId: Id]: PetsRow};'
434
+ * console.log(dTsLines[10]);
435
+ * // -> 'export type PetsRow = {price: number};'
436
+ *
437
+ * const tsLines = ts.split('\n');
438
+ * console.log(tsLines[74]);
439
+ * // -> ' hasPetsTable: (): boolean => store.hasTable(PETS),'
440
+ * ```
441
+ * @category Modelling
442
+ * @since v2.2.0
443
+ */
444
+ getPrettyStoreApi(storeName: string): Promise<[string, string]>;
445
+
446
+ /**
447
+ * The getStore method returns a reference to the underlying Store that is
448
+ * backing this Tools object.
449
+ *
450
+ * @returns A reference to the Store.
451
+ * @example
452
+ * This example creates a Tools object against a newly-created Store and
453
+ * then gets its reference in order to update its data.
454
+ *
455
+ * ```js
456
+ * const tools = createTools(createStore());
457
+ * tools.getStore().setCell('species', 'dog', 'price', 5);
458
+ * console.log(tools.getStoreStats().totalCells);
459
+ * // -> 1
460
+ * ```
461
+ * @category Getter
462
+ * @since v3.0.0
463
+ */
464
+ getStore(): Store;
465
+ }
466
+
467
+ /* eslint-disable max-len */
468
+ /**
469
+ * The createTools function creates a Tools object, and is the main entry point
470
+ * into the tools module.
471
+ *
472
+ * A given Store can only have one Tools object associated with it. If you call
473
+ * this function twice on the same Store, your second call will return a
474
+ * reference to the Tools object created by the first.
475
+ *
476
+ * @param store The Store for which to register tools.
477
+ * @returns A reference to the new Tools object.
478
+ * @example
479
+ * This example creates a Tools object.
480
+ *
481
+ * ```js
482
+ * const store = createStore()
483
+ * .setTable('pets', {
484
+ * fido: {species: 'dog', color: 'brown'},
485
+ * felix: {species: 'cat', color: 'black'},
486
+ * cujo: {species: 'dog', color: 'black'},
487
+ * })
488
+ * .setTable('species', {
489
+ * dog: {price: 5},
490
+ * cat: {price: 4},
491
+ * })
492
+ * .setValues({open: true, employees: 3});
493
+ * const tools = createTools(store);
494
+ * console.log(tools.getStoreStats());
495
+ * // -> {totalTables: 2, totalRows: 5, totalCells: 8, totalValues: 2, jsonLength: 212}
496
+ * ```
497
+ * @example
498
+ * This example creates a Tools object, and calls the method a second time
499
+ * for the same Store to return the same object.
500
+ *
501
+ * ```js
502
+ * const store = createStore();
503
+ * const tools1 = createTools(store);
504
+ * const tools2 = createTools(store);
505
+ * console.log(tools1 === tools2);
506
+ * // -> true
507
+ * ```
508
+ * @category Creation
509
+ * @since v2.2.0
510
+ */
511
+ export function createTools(store: Store): Tools;
512
+ /* eslint-enable max-len */
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react");const s=e=>typeof e,t=s(""),o=(e,s)=>e.map(s),r=e=>null==e,l=(e,s,t)=>r(e)?null==t?void 0:t():s(e),u=()=>{},{createContext:d,useContext:n}=e,a=d([]),i=(e,s)=>{const t=n(a);return r(e)?t[s]:((e,s)=>l(e,(e=>e[s])))(t[s+1],e)},p=(e,o)=>{const l=i(e,o);return r(e)||(e=>s(e)==t)(e)?l:e},c=e=>p(e,0),I=e=>p(e,2),x=e=>p(e,4),w=e=>p(e,6),b=e=>p(e,8),R=e=>p(e,10),{useCallback:C,useEffect:k,useMemo:v,useRef:g,useState:m}=e,V=(e,s,t=[])=>{const o=v((()=>s(e)),[e,...t]);return k((()=>()=>o.destroy()),[o]),o},h=(e,s,t,o=[],l)=>{const[,u]=m(),d=C((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[n]=m(d),a=g(n);return v((()=>a.current=d()),[d]),y(e,s,((...e)=>{a.current=r(l)?d():e[l],u([])}),[],o),a.current},y=(e,s,t,o=[],r=[],...l)=>k((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),L=(e,s,t,o=[],r=u,d=[],...n)=>{const a=c(e);return C((e=>l(a,(o=>l(t(e,o),(e=>r(o["set"+s](...n,e),e)))))),[a,s,...o,...d,...n])},S=(e,s,t=u,o=[],...r)=>{const l=c(e);return C((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},T=(e,s,t)=>{const o=R(e);return C((()=>null==o?void 0:o[s](t)),[o,s,t])},f=e=>h("TableIds",c(e),[],[]),P=(e,s)=>h("RowIds",c(s),[],[e]),q=(e,s,t,o=0,r,l)=>h("SortedRowIds",c(l),[],[e,s,t,o,r],6),O=(e,s,t)=>h("CellIds",c(t),[],[e,s]),B=(e,s,t,o)=>h("Cell",c(o),void 0,[e,s,t],4),M=e=>h("ValueIds",c(e),[],[]),D=(e,s)=>h("Value",c(s),void 0,[e]),j=(e,s)=>h("Metric",I(s),void 0,[e]),A=(e,s)=>h("SliceIds",x(s),[],[e]),E=(e,s,t)=>h("SliceRowIds",x(t),[],[e,s]),F=(e,s,t)=>h("RemoteRowId",w(t),void 0,[e,s]),G=(e,s,t)=>h("LocalRowIds",w(t),[],[e,s]),Q=(e,s,t)=>h("LinkedRowIds",w(t),[],[e,s]),U=(e,s)=>h("ResultRowIds",b(s),[],[e]),z=(e,s,t,o=0,r,l)=>h("ResultSortedRowIds",b(l),[],[e,s,t,o,r],6),H=(e,s,t)=>h("ResultCellIds",b(t),[],[e,s]),J=(e,s,t,o)=>h("ResultCell",b(o),void 0,[e,s,t]),K=e=>h("CheckpointIds",R(e),[[],void 0,[]]),N=(e,s)=>h("Checkpoint",R(s),void 0,[e]),W=e=>T(e,"goBackward"),X=e=>T(e,"goForward");var Y=Object.defineProperty,Z=Object.defineProperties,$=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,te=(e,s,t)=>s in e?Y(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,oe=(e,s)=>{for(var t in s||(s={}))ee.call(s,t)&&te(e,t,s[t]);if(_)for(var t of _(s))se.call(s,t)&&te(e,t,s[t]);return e},re=(e,s)=>Z(e,$(s)),le=(e,s)=>{var t={};for(var o in e)ee.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&_)for(var o of _(e))s.indexOf(o)<0&&se.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ue,useMemo:de}=e,ne=({tableId:e,store:s,rowComponent:t=be,getRowComponentProps:r,separator:l,debugIds:u},d)=>xe(o(d,(o=>ue(t,re(oe({},Ie(r,o)),{key:o,tableId:e,rowId:o,store:s,debugIds:u})))),l,u,e),ae=({queryId:e,queries:s,resultRowComponent:t=ge,getResultRowComponentProps:r,separator:l,debugIds:u},d)=>xe(o(d,(o=>ue(t,re(oe({},Ie(r,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:u})))),l,u,e),ie=e=>{const s=w(e);return[s,null==s?void 0:s.getStore()]},pe=({relationshipId:e,relationships:s,rowComponent:t=be,getRowComponentProps:r,separator:l,debugIds:u},d,n)=>{const[a,i]=ie(s),p=null==a?void 0:a.getLocalTableId(e),c=d(e,n,a);return xe(o(c,(e=>ue(t,re(oe({},Ie(r,e)),{key:e,tableId:p,rowId:e,store:i,debugIds:u})))),l,u,n)},ce=e=>({checkpoints:s,checkpointComponent:t=me,getCheckpointComponentProps:r,separator:l,debugIds:u})=>{const d=R(s);return xe(o(e(K(d)),(e=>ue(t,re(oe({},Ie(r,e)),{key:e,checkpoints:d,checkpointId:e,debugIds:u})))),l)},Ie=(e,s)=>r(e)?{}:e(s),xe=(e,s,t,l)=>{const u=r(s)||!Array.isArray(e)?e:o(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",u,"}"]:u},we=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var l;return xe(""+(null!=(l=B(e,s,t,o))?l:""),void 0,r,t)},be=({tableId:e,rowId:s,store:t,cellComponent:r=we,getCellComponentProps:l,separator:u,debugIds:d})=>xe(o(O(e,s,t),(o=>ue(r,re(oe({},Ie(l,o)),{key:o,tableId:e,rowId:s,cellId:o,store:t,debugIds:d})))),u,d,s),Re=e=>ne(e,P(e.tableId,e.store)),Ce=({valueId:e,store:s,debugIds:t})=>{var o;return xe(""+(null!=(o=D(e,s))?o:""),void 0,t,e)},ke=({indexId:e,sliceId:s,indexes:t,rowComponent:r=be,getRowComponentProps:l,separator:u,debugIds:d})=>{const n=x(t),a=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),p=E(e,s,n);return xe(o(p,(e=>ue(r,re(oe({},Ie(l,e)),{key:e,tableId:i,rowId:e,store:a,debugIds:d})))),u,d,s)},ve=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var l;return xe(""+(null!=(l=J(e,s,t,o))?l:""),void 0,r,t)},ge=({queryId:e,rowId:s,queries:t,resultCellComponent:r=ve,getResultCellComponentProps:l,separator:u,debugIds:d})=>xe(o(H(e,s,t),(o=>ue(r,re(oe({},Ie(l,o)),{key:o,queryId:e,rowId:s,cellId:o,queries:t,debugIds:d})))),u,d,s),me=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return xe(null!=(o=N(s,e))?o:"",void 0,t,s)},Ve=ce((e=>e[0])),he=ce((e=>r(e[1])?[]:[e[1]])),ye=ce((e=>e[2]));exports.BackwardCheckpointsView=Ve,exports.CellView=we,exports.CheckpointView=me,exports.CurrentCheckpointView=he,exports.ForwardCheckpointsView=ye,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=ke,getSliceComponentProps:r,separator:l,debugIds:u})=>xe(o(A(e,s),(o=>ue(t,re(oe({},Ie(r,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:u})))),l,u,e),exports.LinkedRowsView=e=>pe(e,Q,e.firstRowId),exports.LocalRowsView=e=>pe(e,G,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return xe(null!=(o=j(e,s))?o:"",void 0,t,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:p,checkpoints:c,checkpointsById:I,children:x})=>{const w=e.useContext(a);return ue(a.Provider,{value:de((()=>[null!=s?s:w[0],oe(oe({},w[1]),t),null!=o?o:w[2],oe(oe({},w[3]),r),null!=l?l:w[4],oe(oe({},w[5]),u),null!=d?d:w[6],oe(oe({},w[7]),n),null!=i?i:w[8],oe(oe({},w[9]),p),null!=c?c:w[10],oe(oe({},w[11]),I)]),[s,t,o,r,l,u,d,n,i,p,c,I,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=be,getRowComponentProps:l,debugIds:u})=>{const[d,n]=ie(t),a=null==d?void 0:d.getRemoteTableId(e),i=F(e,s,d);return xe(r(a)||r(i)?null:ue(o,re(oe({},Ie(l,i)),{key:i,tableId:a,rowId:i,store:n,debugIds:u})),void 0,u,s)},exports.ResultCellView=ve,exports.ResultRowView=ge,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=le(s,["cellId","descending","offset","limit"]);return ae(u,z(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>ae(e,U(e.queryId,e.queries)),exports.RowView=be,exports.SliceView=ke,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=le(s,["cellId","descending","offset","limit"]);return ne(u,q(u.tableId,t,o,r,l,u.store))},exports.TableView=Re,exports.TablesView=({store:e,tableComponent:s=Re,getTableComponentProps:t,separator:r,debugIds:l})=>xe(o(f(e),(o=>ue(s,re(oe({},Ie(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),r),exports.ValueView=Ce,exports.ValuesView=({store:e,valueComponent:s=Ce,getValueComponentProps:t,separator:r,debugIds:l})=>xe(o(M(e),(o=>ue(s,re(oe({},Ie(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),r),exports.tableView=ne,exports.useAddRowCallback=(e,s,t=[],o,r=u,d=[])=>{const n=c(o);return C((t=>l(n,(o=>l(s(t,o),(s=>r(o.addRow(e,s),o,s)))))),[n,e,...t,...d])},exports.useCell=B,exports.useCellIds=O,exports.useCellIdsListener=(e,s,t,o,r,l)=>y("CellIds",c(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>y("Cell",c(u),o,r,[e,s,t],l),exports.useCheckpoint=N,exports.useCheckpointIds=K,exports.useCheckpointIdsListener=(e,s,t)=>y("CheckpointIds",R(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>y("Checkpoint",R(o),s,t,[e]),exports.useCheckpoints=e=>i(e,10),exports.useCreateCheckpoints=(e,s,t)=>V(e,s,t),exports.useCreateIndexes=(e,s,t)=>V(e,s,t),exports.useCreateMetrics=(e,s,t)=>V(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=m(),u=v((()=>s(e)),[e,...t]);return k((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>V(e,s,t),exports.useCreateRelationships=(e,s,t)=>V(e,s,t),exports.useCreateStore=(e,s=[])=>v(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>S(r,"Cell",l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>S(t,"Row",o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>S(s,"Table",t,o,e),exports.useDelTablesCallback=(e,s,t)=>S(e,"Tables",s,t),exports.useDelValueCallback=(e,s,t,o)=>S(s,"Value",t,o,e),exports.useDelValuesCallback=(e,s,t)=>S(e,"Values",s,t),exports.useGoBackwardCallback=W,exports.useGoForwardCallback=X,exports.useGoToCallback=(e,s=[],t,o=u,r=[])=>{const d=R(t);return C((s=>l(d,(t=>l(e(s),(e=>o(t.goTo(e),e)))))),[d,...s,...r])},exports.useIndexes=e=>i(e,4),exports.useLinkedRowIds=Q,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>y("LinkedRowIds",w(r),t,o,[e,s]),exports.useLocalRowIds=G,exports.useLocalRowIdsListener=(e,s,t,o,r)=>y("LocalRowIds",w(r),t,o,[e,s]),exports.useMetric=j,exports.useMetricListener=(e,s,t,o)=>y("Metric",I(o),s,t,[e]),exports.useMetrics=e=>i(e,2),exports.useQueries=e=>i(e,8),exports.useRedoInformation=e=>{var s;const t=R(e),[,,[o]]=K(t);return[!r(o),X(t),o,null!=(s=l(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:""]},exports.useRelationships=e=>i(e,6),exports.useRemoteRowId=F,exports.useRemoteRowIdListener=(e,s,t,o,r)=>y("RemoteRowId",w(r),t,o,[e,s]),exports.useResultCell=J,exports.useResultCellIds=H,exports.useResultCellIdsListener=(e,s,t,o,r)=>y("ResultCellIds",b(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>y("ResultCell",b(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>h("ResultRow",b(t),{},[e,s]),exports.useResultRowIds=U,exports.useResultRowIdsListener=(e,s,t,o)=>y("ResultRowIds",b(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>y("ResultRow",b(r),t,o,[e,s]),exports.useResultSortedRowIds=z,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>y("ResultSortedRowIds",b(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>h("ResultTable",b(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>y("ResultTable",b(o),s,t,[e]),exports.useRow=(e,s,t)=>h("Row",c(t),{},[e,s]),exports.useRowIds=P,exports.useRowIdsListener=(e,s,t,o,r)=>y("RowIds",c(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>y("Row",c(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>L(l,"Cell",o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=u,s=[],t,o=u,r=[])=>{const d=R(t);return C((s=>l(d,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[d,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>L(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>L(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>L(r,"Row",t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,l)=>L(o,"Table",s,t,r,l,e),exports.useSetTablesCallback=(e,s,t,o,r)=>L(t,"Tables",e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>L(o,"Value",s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>L(t,"Values",e,s,o,r),exports.useSliceIds=A,exports.useSliceIdsListener=(e,s,t,o)=>y("SliceIds",x(o),s,t,[e]),exports.useSliceRowIds=E,exports.useSliceRowIdsListener=(e,s,t,o,r)=>y("SliceRowIds",x(r),t,o,[e,s]),exports.useSortedRowIds=q,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>y("SortedRowIds",c(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>i(e,0),exports.useTable=(e,s)=>h("Table",c(s),{},[e]),exports.useTableIds=f,exports.useTableIdsListener=(e,s,t,o)=>y("TableIds",c(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>y("Table",c(r),s,t,[e],o),exports.useTables=e=>h("Tables",c(e),{}),exports.useTablesListener=(e,s,t,o)=>y("Tables",c(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const t=R(e),[o,r]=K(t);return[(u=o,!(0==(e=>e.length)(u))),W(t),r,null!=(s=l(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:""];var u},exports.useValue=D,exports.useValueIds=M,exports.useValueIdsListener=(e,s,t,o)=>y("ValueIds",c(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>y("Value",c(r),s,t,[e],o),exports.useValues=e=>h("Values",c(e),{}),exports.useValuesListener=(e,s,t,o)=>y("Values",c(o),e,s,[],t);