tinybase 4.3.6 → 4.3.8
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/lib/cjs/queries.cjs +1 -1
- package/lib/cjs/queries.cjs.gz +0 -0
- package/lib/cjs/tinybase.cjs +1 -1
- package/lib/cjs/tinybase.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/tinybase.cjs +1 -1
- package/lib/cjs-es6/tinybase.cjs.gz +0 -0
- package/lib/debug/queries.js +1 -0
- package/lib/debug/tinybase.js +1 -0
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/tinybase.js +1 -1
- package/lib/es6/tinybase.js.gz +0 -0
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/types/persisters/persister-partykit-server.d.ts +2 -1
- package/lib/types/queries.d.ts +24 -0
- package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +2 -1
- package/lib/types/with-schemas/queries.d.ts +24 -0
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd-es6/queries.js +1 -1
- package/lib/umd-es6/queries.js.gz +0 -0
- package/lib/umd-es6/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/package.json +7 -7
- package/readme.md +2 -2
package/lib/umd-es6/tinybase.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",l=t(n),s=t(!0),o=t(0),r=t(t),i="type",a="default",d="Listener",u="Result",c="add",v="Ids",h="Table",f=h+"s",g=h+v,L="Row",y=L+"Count",p=L+v,I="Sorted"+L+v,S="Cell",T=S+v,R="Value",w=R+"s",C=R+v,b=e=>n+e,m=Math.max,V=Math.min,E=isFinite,x=(e,t)=>e instanceof t,k=e=>null==e,M=(e,t,n)=>k(e)?null==n?void 0:n():t(e),D=e=>e==l||e==s,J=e=>t(e)==r,A=e=>Array.isArray(e),O=(e,t,n)=>e.slice(t,n),F=()=>{},P=(e,t)=>e.includes(t),Q=(e,t)=>e.every(t),j=(e,t)=>q(e)===q(t)&&Q(e,((e,n)=>t[n]===e)),z=(e,t)=>Q(e,((n,l)=>0==l||t(e[l-1],n)<=0)),N=(e,t)=>e.sort(t),B=(e,t)=>e.forEach(t),W=(e,t)=>e.map(t),$=e=>H(e,((e,t)=>e+t),0),q=e=>e.length,G=e=>0==q(e),H=(e,t,n)=>e.reduce(t,n),K=(e,...t)=>e.push(...t),U=e=>e.pop(),X=e=>e.shift(),Y=Object,Z=Y.keys,_=Y.isFrozen,ee=Y.freeze,te=e=>x(e,Y)&&e.constructor==Y,ne=(e,t)=>!k(((e,t)=>M(e,(e=>e[t])))(e,t)),le=(e,t)=>(delete e[t],e),se=(e,t)=>W(Y.entries(e),(([e,n])=>t(n,e))),oe=e=>te(e)&&0==(e=>q(Z(e)))(e),re=e=>{var t;return null!=(t=null==e?void 0:e.size)?t:0},ie=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},ae=e=>k(e)||0==re(e),de=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},ue=e=>e.clear(),ce=(e,t)=>null==e?void 0:e.forEach(t),ve=(e,t)=>null==e?void 0:e.delete(t),he=e=>new Map(e),fe=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},ge=(e,t)=>null==e?void 0:e.get(t),Le=(e,t)=>ce(e,((e,n)=>t(n,e))),ye=(e,t,n)=>k(n)?(ve(e,t),e):null==e?void 0:e.set(t,n),pe=(e,t,n)=>(ie(e,t)||ye(e,t,n()),ge(e,t)),Ie=(e,t,n,l=ye)=>(se(t,((t,l)=>n(e,l,t))),Le(e,(n=>ne(t,n)?0:l(e,n))),e),Se=(e,t,n)=>{const l={};return ce(e,((e,s)=>{const o=t?t(e,s):e;!(null==n?void 0:n(o,e))&&(l[s]=o)})),l},Te=(e,t,n)=>Se(e,(e=>Se(e,t,n)),oe),Re=(e,t,n)=>Se(e,(e=>Te(e,t,n)),oe),we=(e,t)=>{const n=he();return ce(e,((e,l)=>{var s;return n.set(l,null!=(s=null==t?void 0:t(e))?s:e)})),n},Ce=e=>we(e,we),be=e=>we(e,Ce),me=(e,t,n,l,s=0)=>M((n?pe:ge)(e,t[s],s>q(t)-2?n:he),(o=>{if(s>q(t)-2)return(null==l?void 0:l(o))&&ye(e,t[s]),o;const r=me(o,t,n,l,s+1);return ae(o)&&ye(e,t[s]),r})),Ve=e=>{const n=t(e);return D(n)||n==o&&E(e)?n:void 0},Ee=(e,t,n,l,s)=>k(s)?e.delCell(t,n,l,!0):e.setCell(t,n,l,s),xe=(e,t,n)=>k(n)?e.delValue(t):e.setValue(t,n),ke=e=>new Set(A(e)||k(e)?e:[e]),Me=(e,t)=>null==e?void 0:e.add(t),De=(e,t,n,l,s)=>{const o=e.hasRow,r=he(),i=he(),a=he(),d=he(),u=he(),c=he(),v=(t,n,...l)=>{const s=pe(c,t,ke);return B(l,(t=>Me(s,t)&&n&&e.callListener(t))),l},h=(t,...n)=>M(ge(c,t),(l=>{B(G(n)?de(l):n,(t=>{e.delListener(t),ve(l,t)})),ae(l)&&ye(c,t)})),f=(e,n)=>{ye(r,e,n),ie(i,e)||(ye(i,e,t()),ye(d,e,he()),ye(u,e,he()),s(a))},g=e=>{ye(r,e),ye(i,e),ye(d,e),ye(u,e),h(e),s(a)};return[()=>e,()=>fe(r),e=>Le(i,e),e=>ie(i,e),e=>ge(r,e),e=>ge(i,e),(e,t)=>ye(i,e,t),f,(t,l,s,r,i)=>{f(t,l);const a=he(),c=he(),g=ge(d,t),L=ge(u,t),y=t=>{const s=n=>e.getCell(l,t,n),d=ge(g,t),u=o(l,t)?n(r(s,t)):void 0;if(d===u||A(d)&&A(u)&&j(d,u)||ye(a,t,[d,u]),!k(i)){const e=ge(L,t),n=o(l,t)?i(s,t):void 0;e!=n&&ye(c,t,n)}},p=e=>{s((()=>{ce(a,(([,e],t)=>ye(g,t,e))),ce(c,((e,t)=>ye(L,t,e)))}),a,c,g,L,e),ue(a),ue(c)};Le(g,y),e.hasTable(l)&&B(e.getRowIds(l),(e=>{ie(g,e)||y(e)})),p(!0),h(t),v(t,0,e.addRowListener(l,null,((e,t,n)=>y(n))),e.addTableListener(l,(()=>p())))},g,e=>l(e,a),()=>Le(c,g),v,h]},Je=(e,s)=>t(e)==l?t=>t(e):null!=e?e:()=>null!=s?s:n,Ae=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},Oe=/^\d+$/,Fe=()=>{const e=[];let t=0;return[l=>{var s;return null!=(s=l?X(e):null)?s:n+t++},t=>{Oe.test(t)&&q(e)<1e3&&K(e,t)}]},Pe=e=>{let t;const[l,s]=Fe(),o=he();return[(s,r,i,a=[],d=(()=>[]))=>{null!=t||(t=e());const u=l(1);return ye(o,u,[s,r,i,a,d]),Me(me(r,null!=i?i:[n],ke),u),u},(e,l,...s)=>B(((e,t=[n])=>{const l=[],s=(e,n)=>n==q(t)?K(l,e):null===t[n]?ce(e,(e=>s(e,n+1))):B([t[n],null],(t=>s(ge(e,t),n+1)));return s(e,0),l})(e,l),(e=>ce(e,(e=>ge(o,e)[0](t,...null!=l?l:[],...s))))),e=>M(ge(o,e),(([,t,l])=>(me(t,null!=l?l:[n],void 0,(t=>(ve(t,e),ae(t)?1:0))),ye(o,e),s(e),l))),e=>M(ge(o,e),(([e,,n=[],l,s])=>{const o=(...r)=>{var i,a;const d=q(r);d==q(n)?e(t,...r,...s(r)):k(n[d])?B(null!=(a=null==(i=l[d])?void 0:i.call(l,...r))?a:[],(e=>o(...r,e))):o(...r,n[d])};o()}))]},Qe=Ae((e=>{let t,l,s,o=100,r=he(),i=he(),a=1;const d=he(),u=he(),[c,v,h]=Pe((()=>O)),f=he(),g=he(),L=[],y=[],p=(t,n)=>{a=0,e.transaction((()=>{const[l,s]=ge(f,n);ce(l,((n,l)=>ce(n,((n,s)=>ce(n,((n,o)=>Ee(e,l,s,o,n[t]))))))),ce(s,((n,l)=>xe(e,l,n[t])))})),a=1},I=e=>{ye(f,e),ye(g,e),v(u,[e])},S=(e,t)=>B(((e,t)=>e.splice(0,t))(e,null!=t?t:q(e)),I),T=()=>S(L,q(L)-o),R=()=>M(t,(()=>{K(L,t),T(),S(y),t=void 0,s=1})),w=()=>{t=U(L),s=1},C=e.addCellListener(null,null,null,((e,t,n,l,s,o)=>{if(a){R();const e=pe(r,t,he),i=pe(e,n,he),a=pe(i,l,(()=>[o,void 0]));a[1]=s,a[0]===s&&ae(ye(i,l))&&ae(ye(e,n))&&ae(ye(r,t))&&w(),x()}})),b=e.addValueListener(null,((e,t,n,l)=>{if(a){R();const e=pe(i,t,(()=>[l,void 0]));e[1]=n,e[0]===n&&ae(ye(i,t))&&w(),x()}})),m=(e="")=>(k(t)&&(t=n+l++,ye(f,t,[r,i]),J(t,e),r=he(),i=he(),s=1),t),V=()=>{G(L)||(((e,...t)=>{e.unshift(...t)})(y,m()),p(0,t),t=U(L),s=1)},E=()=>{G(y)||(K(L,t),t=X(y),p(1,t),s=1)},x=()=>{s&&(v(d),s=0)},D=e=>{const t=m(e);return x(),t},J=(e,t)=>(A(e)&&ge(g,e)!==t&&(ye(g,e,t),v(u,[e])),O),A=e=>ie(f,e),O={setSize:e=>(o=e,T(),O),addCheckpoint:D,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...L],t,[...y]],forEachCheckpoint:e=>Le(g,e),hasCheckpoint:A,getCheckpoint:e=>ge(g,e),goBackward:()=>(V(),x(),O),goForward:()=>(E(),x(),O),goTo:e=>{const n=P(L,e)?V:P(y,e)?E:null;for(;!k(n)&&e!=t;)n();return x(),O},addCheckpointIdsListener:e=>c(e,d),addCheckpointListener:(e,t)=>c(t,u,[e]),delListener:e=>(h(e),O),clear:()=>(S(L),S(y),k(t)||I(t),t=void 0,l=0,D(),O),destroy:()=>{e.delListener(C),e.delListener(b)},getListenerStats:()=>({})};return ee(O.clear())})),je=(e,t)=>(null!=e?e:0)<(null!=t?t:0)?-1:1,ze=Ae((e=>{const t=he(),l=he(),[s,o,r]=Pe((()=>I)),[i,a,d,u,c,v,h,,f,g,L,y]=De(e,he,(e=>k(e)?n:A(e)?W(e,b):b(e)),s,o),p=(t,n,l)=>{const s=c(t);ce(l,((t,l)=>n(l,(n=>ce(t,(t=>n(t,(n=>e.forEachCell(s,t,n)))))))))},I={setIndexDefinition:(e,n,s,r,i,a=je)=>{const d=k(i)?void 0:([e],[t])=>i(e,t);return f(e,n,((n,s,i,u,c,f)=>{let g=0;const L=ke(),y=ke(),p=v(e);if(ce(s,(([e,t],n)=>{const l=ke(e),s=ke(t);ce(l,(e=>ve(s,e)?ve(l,e):0)),ce(l,(e=>{Me(L,e),M(ge(p,e),(t=>{ve(t,n),ae(t)&&(ye(p,e),g=1)}))})),ce(s,(e=>{Me(L,e),ie(p,e)||(ye(p,e,ke()),g=1),Me(ge(p,e),n),k(r)||Me(y,e)}))})),n(),ae(c)||(f?Le(p,(e=>Me(y,e))):Le(i,(e=>M(ge(u,e),(e=>Me(y,e))))),ce(y,(e=>{const t=(t,n)=>a(ge(c,t),ge(c,n),e),n=[...ge(p,e)];z(n,t)||(ye(p,e,ke(N(n,t))),Me(L,e))}))),(g||f)&&!k(d)){const t=[...p];z(t,d)||(h(e,he(N(t,d))),g=1)}g&&o(t,[e]),ce(L,(t=>o(l,[e,t])))}),Je(s),M(r,Je)),I},delIndexDefinition:e=>(g(e),I),getStore:i,getIndexIds:a,forEachIndex:e=>d(((t,n)=>e(t,(e=>p(t,e,n))))),forEachSlice:(e,t)=>p(e,t,v(e)),hasIndex:u,hasSlice:(e,t)=>ie(v(e),t),getTableId:c,getSliceIds:e=>fe(v(e)),getSliceRowIds:(e,t)=>de(ge(v(e),t)),addIndexIdsListener:L,addSliceIdsListener:(e,n)=>s(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>s(n,l,[e,t]),delListener:e=>(r(e),I),destroy:y,getListenerStats:()=>({})};return ee(I)})),Ne=he([["avg",[(e,t)=>$(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,l)=>e+(t-n)/l]],["max",[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)]],["min",[e=>V(...e),(e,t)=>V(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:V(t,e)]],["sum",[e=>$(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Be=(e,t,n,l,s,o=!1)=>{if(ae(n))return;const[r,i,a,d]=s;return o||(o=k(e)),ce(l,(([n,l])=>{o||(e=k(n)?null==i?void 0:i(e,l,t++):k(l)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,l,n,t),o||(o=k(e)))})),o?r(de(n),re(n)):e},We=Ae((e=>{const t=he(),[l,s,o]=Pe((()=>y)),[r,i,a,d,u,c,v,,h,f,g,L]=De(e,F,(e=>isNaN(e)||k(e)||!0===e||!1===e||e===n?void 0:1*e),l,s),y={setMetricDefinition:(e,n,l,o,r,i,a)=>{var d;const u=J(l)?[l,r,i,a]:null!=(d=ge(Ne,l))?d:ge(Ne,"sum");return h(e,n,((n,l,o,r,i,a)=>{const d=c(e),h=re(r);a||(a=k(d)),n();let f=Be(d,h,r,l,u,a);E(f)||(f=void 0),f!=d&&(v(e,f),s(t,[e],f,d))}),Je(o,1)),y},delMetricDefinition:e=>(f(e),y),getStore:r,getMetricIds:i,forEachMetric:a,hasMetric:d,getTableId:u,getMetric:c,addMetricIdsListener:g,addMetricListener:(e,n)=>l(n,t,[e]),delListener:e=>(o(e),y),destroy:L,getListenerStats:()=>({})};return ee(y)}));var $e=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{i(n.next(e))}catch(e){s(e)}},r=e=>{try{i(n.throw(e))}catch(e){s(e)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);i((n=n.apply(e,t)).next())}));const qe=he(),Ge=he();var He=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;const Xe=Ae((e=>{const t=e.createStore,l=t(),s=t(),o=he(),{addListener:r,callListeners:i,delListener:a}=s,[v,f,g,R,w,,,C,,b,m,V,E,x]=De(e,(()=>!0),F,r,i),D=(e,t,...n)=>B(n,(n=>Me(pe(pe(o,t,he),e,ke),n))),A=e=>{M(ge(o,e),(e=>{Le(e,((e,t)=>ce(t,(t=>e.delListener(t))))),ue(e)})),B([s,l],(t=>t.delTable(e)))},P=(e,t,n)=>D(t,e,t.addStartTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),j={setQueryDefinition:(t,o,r)=>{C(t,o),A(t);const i=[],a=[[null,[o,null,null,[],he()]]],d=[],u=[],c=[];r({select:(e,t)=>{const l=J(e)?[q(i)+n,e]:[k(t)?e:t,n=>n(e,t)];return K(i,l),{as:e=>l[0]=e}},join:(e,t,n)=>{const l=k(n)||J(t)?null:t,s=k(l)?t:n,o=[e,[e,l,J(s)?s:e=>e(s),[],he()]];return K(a,o),{as:e=>o[0]=e}},where:(e,t,n)=>K(d,J(e)?e:k(n)?n=>n(e)===t:l=>l(e,t)===n),group:(e,t,n,l,s)=>{var o;const r=[e,[e,J(t)?[t,n,l,s]:null!=(o=ge(Ne,t))?o:[(e,t)=>t]]];return K(u,r),{as:e=>r[0]=e}},having:(e,t)=>K(c,J(e)?e:n=>n(e)===t)});const v=he(i);if(ae(v))return j;const h=he(a);Le(h,((e,[,t])=>M(ge(h,t),(({3:t})=>k(e)?0:K(t,e)))));const f=he(u);let g=l;if(ae(f)&&G(c))g=s;else{P(t,g,s);const e=he();Le(f,((t,[n,l])=>Me(pe(e,n,ke),[t,l])));const n=ke();Le(v,(t=>ie(e,t)?0:Me(n,t)));const l=he(),o=(n,l,o,r)=>M(n,(([i,a,d,u])=>{Le(l,((t,[n])=>{const l=pe(i,t,he),s=ge(l,o),a=r?void 0:n;if(s!==a){const n=ke([[s,a]]),r=re(l);ye(l,o,a),ce(ge(e,t),(([e,t])=>{const s=Be(u[e],r,l,n,t);u[e]=k(Ve(s))?null:s}))}})),ae(a)||!Q(c,(e=>e((e=>u[e]))))?s.delRow(t,d):k(d)?n[2]=s.addRow(t,u):s.setRow(t,d,u)}));D(g,t,g.addRowListener(t,null,((s,r,i,a)=>{const d=[],u=[],c=he(),v=g.hasRow(t,i);let h=!v;ce(n,(e=>{const[n,l,s]=a(t,i,e);K(d,l),K(u,s),h||(h=n)})),Le(e,(e=>{const[n,,l]=a(t,i,e);(h||n)&&ye(c,e,[l])})),h&&o(me(l,d,void 0,(([,e])=>(ve(e,i),ae(e)))),c,i,1),v&&o(me(l,u,(()=>{const e={};return ce(n,(n=>e[n]=g.getCell(t,i,n))),[he(),ke(),void 0,e]}),(([,e])=>{Me(e,i)})),c,i)})))}P(t,e,g);const L=(n,l,s,r)=>{const i=t=>e.getCell(l,s,t);B(r,(l=>{var s;const[o,,r,a,d]=ge(h,l),u=null==r?void 0:r(i,n),[c,v]=null!=(s=ge(d,n))?s:[];u!=c&&(k(v)||x(t,v),ye(d,n,k(u)?null:[u,...E(t,1,e.addRowListener(o,u,(()=>L(n,o,u,a))))]))})),(n=>{const l=(t,l)=>{var s,r,i;return e.getCell(...k(l)?[o,n,t]:t===o?[o,n,l]:[null==(s=ge(h,t))?void 0:s[0],null==(i=ge(null==(r=ge(h,t))?void 0:r[4],n))?void 0:i[0],l])};g.transaction((()=>Q(d,(e=>e(l)))?Le(v,((e,s)=>Ee(g,t,n,e,s(l,n)))):g.delRow(t,n)))})(n)},{3:y}=ge(h,null);return g.transaction((()=>E(t,1,e.addRowListener(o,null,((n,l,s)=>{e.hasRow(o,s)?L(s,o,s,y):(g.delRow(t,s),ce(h,(({4:e})=>M(ge(e,s),(([,n])=>{x(t,n),ye(e,s)})))))}))))),j},delQueryDefinition:e=>(A(e),b(e),j),getStore:v,getQueryIds:f,forEachQuery:g,hasQuery:R,getTableId:w,addQueryIdsListener:e=>m((()=>e(j))),delListener:e=>(a(e),j),destroy:V,getListenerStats:()=>((e,t)=>{var n={};for(var l in e)Ke.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&He)for(var l of He(e))t.indexOf(l)<0&&Ue.call(e,l)&&(n[l]=e[l]);return n})(s.getListenerStats(),["tables","tableIds","transaction"])};return se({[h]:[1,1],[h+T]:[0,1],[y]:[0,1],[p]:[0,1],[I]:[0,5],[L]:[1,2],[T]:[0,2],[S]:[1,3]},(([e,t],n)=>{B(e?["get","has","forEach"]:["get"],(e=>j[e+u+n]=(...t)=>s[e+n](...t))),j[c+u+n+d]=(...e)=>s[c+n+d](...O(e,0,t),((n,...l)=>e[t](j,...l)))})),ee(j)})),Ye=Ae((e=>{const t=he(),l=he(),s=he(),o=he(),[r,i,a]=Pe((()=>R)),[d,u,c,v,h,f,,,g,L,y,p]=De(e,(()=>[he(),he(),he(),he()]),(e=>k(e)?void 0:e+n),r,i),I=(e,t,n)=>M(f(e),(([l,,s])=>{if(!ie(s,t)){const o=ke();if(h(e)!=T(e))Me(o,t);else{let e=t;for(;!k(e)&&!ie(o,e);)Me(o,e),e=ge(l,e)}if(n)return o;ye(s,t,o)}return ge(s,t)})),S=(e,t)=>M(f(e),(([,,e])=>ye(e,t))),T=e=>ge(t,e),R={setRelationshipDefinition:(e,n,r,a)=>(ye(t,e,r),g(e,n,((t,n)=>{const r=ke(),a=ke(),d=ke(),[u,c]=f(e);ce(n,(([t,n],l)=>{k(t)||(Me(a,t),M(ge(c,t),(e=>{ve(e,l),ae(e)&&ye(c,t)}))),k(n)||(Me(a,n),ie(c,n)||ye(c,n,ke()),Me(ge(c,n),l)),Me(r,l),ye(u,l,n),Le(ge(o,e),(t=>{ie(I(e,t),l)&&Me(d,t)}))})),t(),ce(r,(t=>i(l,[e,t]))),ce(a,(t=>i(s,[e,t]))),ce(d,(t=>{S(e,t),i(o,[e,t])}))}),Je(a)),R),delRelationshipDefinition:e=>(ye(t,e),L(e),R),getStore:d,getRelationshipIds:u,forEachRelationship:t=>c((n=>t(n,(t=>e.forEachRow(h(n),t))))),hasRelationship:v,getLocalTableId:h,getRemoteTableId:T,getRemoteRowId:(e,t)=>{var n;return ge(null==(n=f(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return de(ge(null==(n=f(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>k(f(e))?[t]:de(I(e,t,!0)),addRelationshipIdsListener:y,addRemoteRowIdListener:(e,t,n)=>r(n,l,[e,t]),addLocalRowIdsListener:(e,t,n)=>r(n,s,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(I(e,t),r(n,o,[e,t])),delListener:e=>{var t;return S(...null!=(t=a(e))?t:[]),R},destroy:p,getListenerStats:()=>({})};return ee(R)})),Ze=e=>[e,e],_e=()=>[he(),he()],et=e=>[...e],tt=([e,t])=>e===t,nt=e=>JSON.stringify(e,((e,t)=>x(t,Map)?Y.fromEntries([...t]):t)),lt=JSON.parse,st=(e,t,n)=>k(e)||!te(e)||oe(e)||_(e)?(null==n||n(),!1):(se(e,((n,l)=>{t(n,l)||le(e,l)})),!oe(e)),ot=(e,t,n)=>ye(e,t,ge(e,t)==-n?void 0:n),rt=()=>{let e,t,n=!1,l=!1,s=0;const r=he(),u=he(),v=he(),I=he(),m=he(),V=he(),E=he(),x=he(),A=he(),F=he(),Q=he(),z=he(),$=he(),q=he(),G=ke(),H=he(),U=he(),X=he(),Y=he(),Z=_e(),_=_e(),te=_e(),de=_e(),me=_e(),De=_e(),Je=_e(),Ae=_e(),Oe=_e(),Qe=_e(),ze=_e(),Ne=_e(),Be=_e(),We=_e(),$e=_e(),qe=he(),Ge=_e(),[He,Ke,Ue,Xe]=Pe((()=>Sn)),Ye=e=>{if(!st(e,((e,t)=>P([i,a],t))))return!1;const t=e[i];return!(!D(t)&&t!=o||(Ve(e[a])!=t&&le(e,a),0))},it=(t,n)=>(!e||ie(Q,n)||Pt(n))&&st(t,((e,t)=>at(n,t,e)),(()=>Pt(n))),at=(e,t,n,l)=>st(l?n:vt(n,e,t),((l,s)=>M(dt(e,t,s,l),(e=>(n[s]=e,!0)),(()=>!1))),(()=>Pt(e,t))),dt=(t,n,l,s)=>e?M(ge(ge(Q,t),l),(e=>Ve(s)!=e[i]?Pt(t,n,l,s,e[a]):s),(()=>Pt(t,n,l,s))):k(Ve(s))?Pt(t,n,l,s):s,ut=(e,t)=>st(t?e:ht(e),((t,n)=>M(ct(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>Qt())),ct=(e,n)=>t?M(ge($,e),(t=>Ve(n)!=t[i]?Qt(e,n,t[a]):n),(()=>Qt(e,n))):k(Ve(n))?Qt(e,n):n,vt=(e,t,n)=>(M(ge(z,t),(([l,s])=>{ce(l,((t,n)=>{ne(e,n)||(e[n]=t)})),ce(s,(l=>{ne(e,l)||Pt(t,n,l)}))})),e),ht=e=>(t&&(ce(q,((t,n)=>{ne(e,n)||(e[n]=t)})),ce(G,(t=>{ne(e,t)||Qt(t)}))),e),ft=e=>Ie(Q,e,((e,t,n)=>{const l=he(),s=ke();Ie(pe(Q,t,he),n,((e,t,n)=>{ye(e,t,n),M(n[a],(e=>ye(l,t,e)),(()=>Me(s,t)))})),ye(z,t,[l,s])}),((e,t)=>{ye(Q,t),ye(z,t)})),gt=e=>Ie($,e,((e,t,n)=>{ye($,t,n),M(n[a],(e=>ye(q,t,e)),(()=>Me(G,t)))}),((e,t)=>{ye($,t),ye(q,t),ve(G,t)})),Lt=e=>oe(e)?cn():on(e),yt=e=>Ie(X,e,((e,t,n)=>pt(t,n)),((e,t)=>Vt(t))),pt=(e,t)=>Ie(pe(X,e,(()=>(Mt(e,1),ye(H,e,Fe()),ye(U,e,he()),he()))),t,((t,n,l)=>It(e,t,n,l)),((t,n)=>Et(e,t,n))),It=(e,t,n,l,s)=>Ie(pe(t,n,(()=>(Dt(e,n,1),he()))),l,((t,l,s)=>St(e,n,t,l,s)),((l,o)=>xt(e,t,n,l,o,s))),St=(e,t,n,l,s)=>{ie(n,l)||Jt(e,t,l,1);const o=ge(n,l);s!==o&&(At(e,t,l,o,s),ye(n,l,s))},Tt=(e,t,n,l,s)=>M(ge(t,n),(t=>St(e,n,t,l,s)),(()=>It(e,t,n,vt({[l]:s},e,n)))),Rt=e=>oe(e)?fn():rn(e),wt=e=>Ie(Y,e,((e,t,n)=>Ct(t,n)),((e,t)=>kt(t))),Ct=(e,t)=>{ie(Y,e)||Ot(e,1);const n=ge(Y,e);t!==n&&(Ft(e,n,t),ye(Y,e,t))},bt=(e,t)=>{const[n]=ge(H,e),l=n(t);return ie(ge(X,e),l)?bt(e,t):l},mt=e=>{var t;return null!=(t=ge(X,e))?t:pt(e,{})},Vt=e=>pt(e,{}),Et=(e,t,n)=>{const[,l]=ge(H,e);l(n),It(e,t,n,{},!0)},xt=(e,t,n,l,s,o)=>{var r;const i=ge(null==(r=ge(z,e))?void 0:r[0],s);if(!k(i)&&!o)return St(e,n,l,s,i);const a=t=>{At(e,n,t,ge(l,t)),Jt(e,n,t,-1),ye(l,t)};k(i)?a(s):Le(l,a),ae(l)&&(Dt(e,n,-1),ae(ye(t,n))&&(Mt(e,-1),ye(X,e),ye(H,e),ye(U,e)))},kt=e=>{const t=ge(q,e);if(!k(t))return Ct(e,t);Ft(e,ge(Y,e)),Ot(e,-1),ye(Y,e)},Mt=(e,t)=>ot(r,e,t),Dt=(e,t,n)=>ot(pe(I,e,he),t,n)&&ye(v,e,pe(v,e,(()=>0))+n),Jt=(e,t,n,l)=>{var s;const o=ge(U,e),r=null!=(s=ge(o,n))?s:0;(0==r&&1==l||1==r&&-1==l)&&ot(pe(u,e,he),n,l),ye(o,n,r!=-l?r+l:null),ot(pe(pe(m,e,he),t,he),n,l)},At=(e,t,n,l,s)=>pe(pe(pe(V,e,he),t,he),n,(()=>[l,0]))[1]=s,Ot=(e,t)=>ot(E,e,t),Ft=(e,t,n)=>pe(x,e,(()=>[t,0]))[1]=n,Pt=(e,t,n,l,s)=>(K(pe(pe(pe(A,e,he),t,he),n,(()=>[])),l),s),Qt=(e,t,n)=>(K(pe(F,e,(()=>[])),t),n),jt=(e,t,n)=>M(ge(ge(ge(V,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Ze(tn(e,t,n))])),zt=e=>M(ge(x,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ze(sn(e))])),Nt=e=>ae(A)||ae(ze[e])?0:ce(e?be(A):A,((t,n)=>ce(t,((t,l)=>ce(t,((t,s)=>Ke(ze[e],[n,l,s],t))))))),Bt=e=>ae(F)||ae(Ne[e])?0:ce(e?we(F):F,((t,n)=>Ke(Ne[e],[n],t))),Wt=(e,t,n)=>{if(!ae(t))return Ke(e,n,(()=>Se(t))),1},$t=e=>{const t=ae(Je[e]),n=ae(Oe[e])&&ae(de[e])&&ae(me[e])&&ae(De[e])&&t&&ae(_[e]),l=ae(Qe[e])&&ae(Ae[e])&&ae(te[e])&&ae(Z[e]);if(!n||!l){const s=e?[we(r),Ce(u),we(v),Ce(I),be(m),be(V)]:[r,u,v,I,m,V];if(!n){Wt(_[e],s[0]),ce(s[1],((t,n)=>Wt(de[e],t,[n]))),ce(s[2],((t,n)=>{0!=t&&Ke(me[e],[n],Yt(n))}));const n=ke();ce(s[3],((l,s)=>{Wt(De[e],l,[s])&&!t&&(Ke(Je[e],[s,null]),Me(n,s))})),t||ce(s[5],((t,l)=>{if(!ie(n,l)){const n=ke();ce(t,(e=>ce(e,(([t,l],s)=>l!==t?Me(n,s):ve(e,s))))),ce(n,(t=>Ke(Je[e],[l,t])))}})),ce(s[4],((t,n)=>ce(t,((t,l)=>Wt(Oe[e],t,[n,l])))))}if(!l){let t;ce(s[5],((n,l)=>{let s;ce(n,((n,o)=>{let r;ce(n,(([n,i],a)=>{i!==n&&(Ke(Qe[e],[l,o,a],i,n,jt),t=s=r=1)})),r&&Ke(Ae[e],[l,o],jt)})),s&&Ke(te[e],[l],jt)})),t&&Ke(Z[e],void 0,jt)}}},qt=e=>{const t=ae(We[e]),n=ae($e[e])&&ae(Be[e]);if(!t||!n){const l=e?[we(E),we(x)]:[E,x];if(t||Wt(We[e],l[0]),!n){let t;ce(l[1],(([n,l],s)=>{l!==n&&(Ke($e[e],[s],l,n,zt),t=1)})),t&&Ke(Be[e],void 0,zt)}}},Gt=(e,...t)=>(yn((()=>e(...W(t,b)))),Sn),Ht=()=>[Se(V,((e,t)=>-1===ge(r,t)?null:Se(e,((e,n)=>-1===ge(ge(I,t),n)?null:Se(e,(([,e])=>null!=e?e:null),((e,t)=>tt(t)))),oe)),oe),Se(x,(([,e])=>null!=e?e:null),((e,t)=>tt(t)))],Kt=()=>({cellsTouched:n,valuesTouched:l,changedCells:Re(V,et,tt),invalidCells:Re(A),changedValues:Se(x,et,tt),invalidValues:Se(F),changedTableIds:Se(r),changedRowIds:Te(I),changedCellIds:Re(m),changedValueIds:Se(E)}),Ut=()=>Re(X),Xt=()=>fe(X),Yt=e=>re(ge(X,b(e))),Zt=e=>fe(ge(X,b(e))),_t=(e,t,n,l=0,s)=>{return W(O(N((o=ge(X,b(e)),r=(e,n)=>[k(t)?n:ge(e,b(t)),n],W([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,t])=>r(t,e)))),(([e],[t])=>je(e,t)*(n?-1:1))),l,k(s)?s:l+s),(([,e])=>e));var o,r,i},en=(e,t)=>fe(ge(ge(X,b(e)),b(t))),tn=(e,t,n)=>ge(ge(ge(X,b(e)),b(t)),b(n)),nn=()=>Se(Y),ln=()=>fe(Y),sn=e=>ge(Y,b(e)),on=e=>Gt((()=>(e=>st(e,it,Pt))(e)?yt(e):0)),rn=e=>Gt((()=>ut(e)?wt(e):0)),an=e=>{try{Lt(lt(e))}catch(e){}return Sn},dn=t=>Gt((()=>{if((e=st(t,(e=>st(e,Ye))))&&(ft(t),!ae(X))){const e=Ut();cn(),on(e)}})),un=e=>Gt((()=>{if(t=(e=>st(e,Ye))(e)){const n=nn();Ln(),fn(),t=!0,gt(e),rn(n)}})),cn=()=>Gt((()=>yt({}))),vn=e=>Gt((e=>ie(X,e)?Vt(e):0),e),hn=(e,t)=>Gt(((e,t)=>M(ge(X,e),(n=>ie(n,t)?Et(e,n,t):0))),e,t),fn=()=>Gt((()=>wt({}))),gn=()=>Gt((()=>{ft({}),e=!1})),Ln=()=>Gt((()=>{gt({}),t=!1})),yn=(e,t)=>{if(-1!=s){pn();const n=e();return In(t),n}},pn=()=>(-1!=s&&s++,1==s&&Ke(qe,void 0,Ht,Kt),Sn),In=e=>(s>0&&(s--,0==s&&(n=!ae(V),l=!ae(x),s=1,Nt(1),n&&$t(1),Bt(1),l&&qt(1),(null==e?void 0:e(Ht,Kt))&&(ce(V,((e,t)=>ce(e,((e,n)=>ce(e,(([e],l)=>Ee(Sn,t,n,l,e))))))),ce(x,(([e],t)=>xe(Sn,t,e))),n=l=!1),Ke(Ge[0],void 0,Ht,Kt),s=-1,Nt(0),n&&$t(0),Bt(0),l&&qt(0),Ke(Ge[1],void 0,Ht,Kt),s=0,n=l=!1,B([r,u,v,I,m,V,A,E,x,F],ue))),Sn),Sn={getContent:()=>[Ut(),nn()],getTables:Ut,getTableIds:Xt,getTable:e=>Te(ge(X,b(e))),getTableCellIds:e=>fe(ge(U,b(e))),getRowCount:Yt,getRowIds:Zt,getSortedRowIds:_t,getRow:(e,t)=>Se(ge(ge(X,b(e)),b(t))),getCellIds:en,getCell:tn,getValues:nn,getValueIds:ln,getValue:sn,hasTables:()=>!ae(X),hasTable:e=>ie(X,b(e)),hasTableCell:(e,t)=>ie(ge(U,b(e)),b(t)),hasRow:(e,t)=>ie(ge(X,b(e)),b(t)),hasCell:(e,t,n)=>ie(ge(ge(X,b(e)),b(t)),b(n)),hasValues:()=>!ae(Y),hasValue:e=>ie(Y,b(e)),getTablesJson:()=>nt(X),getValuesJson:()=>nt(Y),getJson:()=>nt([X,Y]),getTablesSchemaJson:()=>nt(Q),getValuesSchemaJson:()=>nt($),getSchemaJson:()=>nt([Q,$]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>Gt((()=>{(oe(e)?cn:on)(e),(oe(t)?fn:rn)(t)})),setTables:on,setTable:(e,t)=>Gt((e=>it(t,e)?pt(e,t):0),e),setRow:(e,t,n)=>Gt(((e,t)=>at(e,t,n)?It(e,mt(e),t,n):0),e,t),addRow:(e,t,n=!0)=>yn((()=>{let l;return at(e,l,t)&&(e=b(e),It(e,mt(e),l=bt(e,n?1:0),t)),l})),setPartialRow:(e,t,n)=>Gt(((e,t)=>{if(at(e,t,n,1)){const l=mt(e);se(n,((n,s)=>Tt(e,l,t,s,n)))}}),e,t),setCell:(e,t,n,l)=>Gt(((e,t,n)=>M(dt(e,t,n,J(l)?l(tn(e,t,n)):l),(l=>Tt(e,mt(e),t,n,l)))),e,t,n),setValues:rn,setPartialValues:e=>Gt((()=>ut(e,1)?se(e,((e,t)=>Ct(t,e))):0)),setValue:(e,t)=>Gt((e=>M(ct(e,J(t)?t(sn(e)):t),(t=>Ct(e,t)))),e),setTransactionChanges:e=>Gt((()=>{se(e[0],((e,t)=>k(e)?vn(t):se(e,((e,n)=>k(e)?hn(t,n):se(e,((e,l)=>Ee(Sn,t,n,l,e))))))),se(e[1],((e,t)=>xe(Sn,t,e)))})),setTablesJson:an,setValuesJson:e=>{try{Rt(lt(e))}catch(e){}return Sn},setJson:e=>Gt((()=>{try{const[t,n]=lt(e);Lt(t),Rt(n)}catch(t){an(e)}})),setTablesSchema:dn,setValuesSchema:un,setSchema:(e,t)=>Gt((()=>{dn(e),un(t)})),delTables:cn,delTable:vn,delRow:hn,delCell:(e,t,n,l)=>Gt(((e,t,n)=>M(ge(X,e),(s=>M(ge(s,t),(o=>ie(o,n)?xt(e,s,t,o,n,l):0))))),e,t,n),delValues:fn,delValue:e=>Gt((e=>ie(Y,e)?kt(e):0),e),delTablesSchema:gn,delValuesSchema:Ln,delSchema:()=>Gt((()=>{gn(),Ln()})),transaction:yn,startTransaction:pn,finishTransaction:In,forEachTable:e=>ce(X,((t,n)=>e(n,(e=>ce(t,((t,n)=>e(n,(e=>Le(t,e))))))))),forEachTableCell:(e,t)=>Le(ge(U,b(e)),t),forEachRow:(e,t)=>ce(ge(X,b(e)),((e,n)=>t(n,(t=>Le(e,t))))),forEachCell:(e,t,n)=>Le(ge(ge(X,b(e)),b(t)),n),forEachValue:e=>Le(Y,e),addSortedRowIdsListener:(e,t,n,l,s,o,r)=>{let i=_t(e,t,n,l,s);return He((()=>{const r=_t(e,t,n,l,s);j(r,i)||(i=r,o(Sn,e,t,n,l,s,i))}),Je[r?1:0],[e,t],[Xt])},addStartTransactionListener:e=>He(e,qe),addWillFinishTransactionListener:e=>He(e,Ge[0]),addDidFinishTransactionListener:e=>He(e,Ge[1]),callListener:e=>(Xe(e),Sn),delListener:e=>(Ue(e),Sn),getListenerStats:()=>({}),createStore:rt,addListener:He,callListeners:Ke};return se({[f]:[0,Z],[g]:[0,_],[h]:[1,te,[Xt]],[h+T]:[1,de,[Xt]],[y]:[1,me,[Xt]],[p]:[1,De,[Xt]],[L]:[2,Ae,[Xt,Zt]],[T]:[2,Oe,[Xt,Zt]],[S]:[3,Qe,[Xt,Zt,en],e=>Ze(tn(...e))],InvalidCell:[3,ze],[w]:[0,Be],[C]:[0,We],[R]:[1,$e,[ln],e=>Ze(sn(e[0]))],InvalidValue:[1,Ne]},(([e,t,n,l],s)=>{Sn[c+s+d]=(...s)=>He(s[e],t[s[e+1]?1:0],e>0?O(s,0,e):void 0,n,l)})),ee(Sn)};e.createCheckpoints=Qe,e.createCustomPersister=(e,t,n,l,s,o,r=[])=>{let i,a,d,u=0,c=0;pe(qe,r,(()=>0)),pe(Ge,r,(()=>[]));const v=e=>$e(void 0,null,(function*(){return 2!=u&&(u=1,yield h.schedule((()=>$e(void 0,null,(function*(){yield e(),u=0}))))),h})),h={load:(n,l)=>$e(void 0,null,(function*(){return yield v((()=>$e(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,l])}}))))})),startAutoLoad:(...n)=>$e(void 0,[...n],(function*(n={},s={}){return h.stopAutoLoad(),yield h.load(n,s),c=1,d=l(((n,l)=>$e(void 0,null,(function*(){if(l){const t=l();yield v((()=>$e(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield v((()=>$e(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==n?void 0:n())?l:yield t())}catch(e){null==o||o(e)}}))))})))),h})),stopAutoLoad:()=>(c&&(s(d),d=void 0,c=0),h),save:t=>$e(void 0,null,(function*(){return 1!=u&&(u=2,yield h.schedule((()=>$e(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==o||o(e)}u=0}))))),h})),startAutoSave:()=>$e(void 0,null,(function*(){return yield h.stopAutoSave().save(),i=e.addDidFinishTransactionListener(((e,t)=>{const[n,l]=t();oe(n)&&oe(l)||h.save((()=>[n,l]))})),h})),stopAutoSave:()=>(M(i,e.delListener),h),schedule:(...e)=>$e(void 0,null,(function*(){return K(ge(Ge,r),...e),yield $e(void 0,null,(function*(){if(!ge(qe,r)){for(ye(qe,r,1);!k(a=X(ge(Ge,r)));)try{yield a()}catch(e){null==o||o(e)}ye(qe,r,0)}})),h})),getStore:()=>e,destroy:()=>h.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return ee(h)},e.createIndexes=ze,e.createMetrics=We,e.createQueries=Xe,e.createRelationships=Ye,e.createStore=rt,e.defaultSorter=je},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={});
|
|
1
|
+
var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",l=t(n),s=t(!0),o=t(0),r=t(t),i="type",a="default",d="Listener",u="Result",c="add",v="Ids",h="Table",f=h+"s",g=h+v,L="Row",y=L+"Count",p=L+v,I="Sorted"+L+v,S="Cell",T=S+v,R="Value",w=R+"s",C=R+v,b=e=>n+e,m=Math.max,V=Math.min,E=isFinite,x=(e,t)=>e instanceof t,k=e=>null==e,M=(e,t,n)=>k(e)?null==n?void 0:n():t(e),D=e=>e==l||e==s,J=e=>t(e)==r,A=e=>Array.isArray(e),O=(e,t,n)=>e.slice(t,n),F=()=>{},P=(e,t)=>e.includes(t),Q=(e,t)=>e.every(t),j=(e,t)=>q(e)===q(t)&&Q(e,((e,n)=>t[n]===e)),z=(e,t)=>Q(e,((n,l)=>0==l||t(e[l-1],n)<=0)),N=(e,t)=>e.sort(t),B=(e,t)=>e.forEach(t),W=(e,t)=>e.map(t),$=e=>H(e,((e,t)=>e+t),0),q=e=>e.length,G=e=>0==q(e),H=(e,t,n)=>e.reduce(t,n),K=(e,...t)=>e.push(...t),U=e=>e.pop(),X=e=>e.shift(),Y=Object,Z=Y.keys,_=Y.isFrozen,ee=Y.freeze,te=e=>x(e,Y)&&e.constructor==Y,ne=(e,t)=>!k(((e,t)=>M(e,(e=>e[t])))(e,t)),le=(e,t)=>(delete e[t],e),se=(e,t)=>W(Y.entries(e),(([e,n])=>t(n,e))),oe=e=>te(e)&&0==(e=>q(Z(e)))(e),re=e=>{var t;return null!=(t=null==e?void 0:e.size)?t:0},ie=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},ae=e=>k(e)||0==re(e),de=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},ue=e=>e.clear(),ce=(e,t)=>null==e?void 0:e.forEach(t),ve=(e,t)=>null==e?void 0:e.delete(t),he=e=>new Map(e),fe=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},ge=(e,t)=>null==e?void 0:e.get(t),Le=(e,t)=>ce(e,((e,n)=>t(n,e))),ye=(e,t,n)=>k(n)?(ve(e,t),e):null==e?void 0:e.set(t,n),pe=(e,t,n)=>(ie(e,t)||ye(e,t,n()),ge(e,t)),Ie=(e,t,n,l=ye)=>(se(t,((t,l)=>n(e,l,t))),Le(e,(n=>ne(t,n)?0:l(e,n))),e),Se=(e,t,n)=>{const l={};return ce(e,((e,s)=>{const o=t?t(e,s):e;!(null==n?void 0:n(o,e))&&(l[s]=o)})),l},Te=(e,t,n)=>Se(e,(e=>Se(e,t,n)),oe),Re=(e,t,n)=>Se(e,(e=>Te(e,t,n)),oe),we=(e,t)=>{const n=he();return ce(e,((e,l)=>{var s;return n.set(l,null!=(s=null==t?void 0:t(e))?s:e)})),n},Ce=e=>we(e,we),be=e=>we(e,Ce),me=(e,t,n,l,s=0)=>M((n?pe:ge)(e,t[s],s>q(t)-2?n:he),(o=>{if(s>q(t)-2)return(null==l?void 0:l(o))&&ye(e,t[s]),o;const r=me(o,t,n,l,s+1);return ae(o)&&ye(e,t[s]),r})),Ve=e=>{const n=t(e);return D(n)||n==o&&E(e)?n:void 0},Ee=(e,t,n,l,s)=>k(s)?e.delCell(t,n,l,!0):e.setCell(t,n,l,s),xe=(e,t,n)=>k(n)?e.delValue(t):e.setValue(t,n),ke=e=>new Set(A(e)||k(e)?e:[e]),Me=(e,t)=>null==e?void 0:e.add(t),De=(e,t,n,l,s)=>{const o=e.hasRow,r=he(),i=he(),a=he(),d=he(),u=he(),c=he(),v=(t,n,...l)=>{const s=pe(c,t,ke);return B(l,(t=>Me(s,t)&&n&&e.callListener(t))),l},h=(t,...n)=>M(ge(c,t),(l=>{B(G(n)?de(l):n,(t=>{e.delListener(t),ve(l,t)})),ae(l)&&ye(c,t)})),f=(e,n)=>{ye(r,e,n),ie(i,e)||(ye(i,e,t()),ye(d,e,he()),ye(u,e,he()),s(a))},g=e=>{ye(r,e),ye(i,e),ye(d,e),ye(u,e),h(e),s(a)};return[()=>e,()=>fe(r),e=>Le(i,e),e=>ie(i,e),e=>ge(r,e),e=>ge(i,e),(e,t)=>ye(i,e,t),f,(t,l,s,r,i)=>{f(t,l);const a=he(),c=he(),g=ge(d,t),L=ge(u,t),y=t=>{const s=n=>e.getCell(l,t,n),d=ge(g,t),u=o(l,t)?n(r(s,t)):void 0;if(d===u||A(d)&&A(u)&&j(d,u)||ye(a,t,[d,u]),!k(i)){const e=ge(L,t),n=o(l,t)?i(s,t):void 0;e!=n&&ye(c,t,n)}},p=e=>{s((()=>{ce(a,(([,e],t)=>ye(g,t,e))),ce(c,((e,t)=>ye(L,t,e)))}),a,c,g,L,e),ue(a),ue(c)};Le(g,y),e.hasTable(l)&&B(e.getRowIds(l),(e=>{ie(g,e)||y(e)})),p(!0),h(t),v(t,0,e.addRowListener(l,null,((e,t,n)=>y(n))),e.addTableListener(l,(()=>p())))},g,e=>l(e,a),()=>Le(c,g),v,h]},Je=(e,s)=>t(e)==l?t=>t(e):null!=e?e:()=>null!=s?s:n,Ae=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},Oe=/^\d+$/,Fe=()=>{const e=[];let t=0;return[l=>{var s;return null!=(s=l?X(e):null)?s:n+t++},t=>{Oe.test(t)&&q(e)<1e3&&K(e,t)}]},Pe=e=>{let t;const[l,s]=Fe(),o=he();return[(s,r,i,a=[],d=(()=>[]))=>{null!=t||(t=e());const u=l(1);return ye(o,u,[s,r,i,a,d]),Me(me(r,null!=i?i:[n],ke),u),u},(e,l,...s)=>B(((e,t=[n])=>{const l=[],s=(e,n)=>n==q(t)?K(l,e):null===t[n]?ce(e,(e=>s(e,n+1))):B([t[n],null],(t=>s(ge(e,t),n+1)));return s(e,0),l})(e,l),(e=>ce(e,(e=>ge(o,e)[0](t,...null!=l?l:[],...s))))),e=>M(ge(o,e),(([,t,l])=>(me(t,null!=l?l:[n],void 0,(t=>(ve(t,e),ae(t)?1:0))),ye(o,e),s(e),l))),e=>M(ge(o,e),(([e,,n=[],l,s])=>{const o=(...r)=>{var i,a;const d=q(r);d==q(n)?e(t,...r,...s(r)):k(n[d])?B(null!=(a=null==(i=l[d])?void 0:i.call(l,...r))?a:[],(e=>o(...r,e))):o(...r,n[d])};o()}))]},Qe=Ae((e=>{let t,l,s,o=100,r=he(),i=he(),a=1;const d=he(),u=he(),[c,v,h]=Pe((()=>O)),f=he(),g=he(),L=[],y=[],p=(t,n)=>{a=0,e.transaction((()=>{const[l,s]=ge(f,n);ce(l,((n,l)=>ce(n,((n,s)=>ce(n,((n,o)=>Ee(e,l,s,o,n[t]))))))),ce(s,((n,l)=>xe(e,l,n[t])))})),a=1},I=e=>{ye(f,e),ye(g,e),v(u,[e])},S=(e,t)=>B(((e,t)=>e.splice(0,t))(e,null!=t?t:q(e)),I),T=()=>S(L,q(L)-o),R=()=>M(t,(()=>{K(L,t),T(),S(y),t=void 0,s=1})),w=()=>{t=U(L),s=1},C=e.addCellListener(null,null,null,((e,t,n,l,s,o)=>{if(a){R();const e=pe(r,t,he),i=pe(e,n,he),a=pe(i,l,(()=>[o,void 0]));a[1]=s,a[0]===s&&ae(ye(i,l))&&ae(ye(e,n))&&ae(ye(r,t))&&w(),x()}})),b=e.addValueListener(null,((e,t,n,l)=>{if(a){R();const e=pe(i,t,(()=>[l,void 0]));e[1]=n,e[0]===n&&ae(ye(i,t))&&w(),x()}})),m=(e="")=>(k(t)&&(t=n+l++,ye(f,t,[r,i]),J(t,e),r=he(),i=he(),s=1),t),V=()=>{G(L)||(((e,...t)=>{e.unshift(...t)})(y,m()),p(0,t),t=U(L),s=1)},E=()=>{G(y)||(K(L,t),t=X(y),p(1,t),s=1)},x=()=>{s&&(v(d),s=0)},D=e=>{const t=m(e);return x(),t},J=(e,t)=>(A(e)&&ge(g,e)!==t&&(ye(g,e,t),v(u,[e])),O),A=e=>ie(f,e),O={setSize:e=>(o=e,T(),O),addCheckpoint:D,setCheckpoint:J,getStore:()=>e,getCheckpointIds:()=>[[...L],t,[...y]],forEachCheckpoint:e=>Le(g,e),hasCheckpoint:A,getCheckpoint:e=>ge(g,e),goBackward:()=>(V(),x(),O),goForward:()=>(E(),x(),O),goTo:e=>{const n=P(L,e)?V:P(y,e)?E:null;for(;!k(n)&&e!=t;)n();return x(),O},addCheckpointIdsListener:e=>c(e,d),addCheckpointListener:(e,t)=>c(t,u,[e]),delListener:e=>(h(e),O),clear:()=>(S(L),S(y),k(t)||I(t),t=void 0,l=0,D(),O),destroy:()=>{e.delListener(C),e.delListener(b)},getListenerStats:()=>({})};return ee(O.clear())})),je=(e,t)=>(null!=e?e:0)<(null!=t?t:0)?-1:1,ze=Ae((e=>{const t=he(),l=he(),[s,o,r]=Pe((()=>I)),[i,a,d,u,c,v,h,,f,g,L,y]=De(e,he,(e=>k(e)?n:A(e)?W(e,b):b(e)),s,o),p=(t,n,l)=>{const s=c(t);ce(l,((t,l)=>n(l,(n=>ce(t,(t=>n(t,(n=>e.forEachCell(s,t,n)))))))))},I={setIndexDefinition:(e,n,s,r,i,a=je)=>{const d=k(i)?void 0:([e],[t])=>i(e,t);return f(e,n,((n,s,i,u,c,f)=>{let g=0;const L=ke(),y=ke(),p=v(e);if(ce(s,(([e,t],n)=>{const l=ke(e),s=ke(t);ce(l,(e=>ve(s,e)?ve(l,e):0)),ce(l,(e=>{Me(L,e),M(ge(p,e),(t=>{ve(t,n),ae(t)&&(ye(p,e),g=1)}))})),ce(s,(e=>{Me(L,e),ie(p,e)||(ye(p,e,ke()),g=1),Me(ge(p,e),n),k(r)||Me(y,e)}))})),n(),ae(c)||(f?Le(p,(e=>Me(y,e))):Le(i,(e=>M(ge(u,e),(e=>Me(y,e))))),ce(y,(e=>{const t=(t,n)=>a(ge(c,t),ge(c,n),e),n=[...ge(p,e)];z(n,t)||(ye(p,e,ke(N(n,t))),Me(L,e))}))),(g||f)&&!k(d)){const t=[...p];z(t,d)||(h(e,he(N(t,d))),g=1)}g&&o(t,[e]),ce(L,(t=>o(l,[e,t])))}),Je(s),M(r,Je)),I},delIndexDefinition:e=>(g(e),I),getStore:i,getIndexIds:a,forEachIndex:e=>d(((t,n)=>e(t,(e=>p(t,e,n))))),forEachSlice:(e,t)=>p(e,t,v(e)),hasIndex:u,hasSlice:(e,t)=>ie(v(e),t),getTableId:c,getSliceIds:e=>fe(v(e)),getSliceRowIds:(e,t)=>de(ge(v(e),t)),addIndexIdsListener:L,addSliceIdsListener:(e,n)=>s(n,t,[e]),addSliceRowIdsListener:(e,t,n)=>s(n,l,[e,t]),delListener:e=>(r(e),I),destroy:y,getListenerStats:()=>({})};return ee(I)})),Ne=he([["avg",[(e,t)=>$(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,l)=>e+(t-n)/l]],["max",[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)]],["min",[e=>V(...e),(e,t)=>V(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:V(t,e)]],["sum",[e=>$(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Be=(e,t,n,l,s,o=!1)=>{if(ae(n))return;const[r,i,a,d]=s;return o||(o=k(e)),ce(l,(([n,l])=>{o||(e=k(n)?null==i?void 0:i(e,l,t++):k(l)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,l,n,t),o||(o=k(e)))})),o?r(de(n),re(n)):e},We=Ae((e=>{const t=he(),[l,s,o]=Pe((()=>y)),[r,i,a,d,u,c,v,,h,f,g,L]=De(e,F,(e=>isNaN(e)||k(e)||!0===e||!1===e||e===n?void 0:1*e),l,s),y={setMetricDefinition:(e,n,l,o,r,i,a)=>{var d;const u=J(l)?[l,r,i,a]:null!=(d=ge(Ne,l))?d:ge(Ne,"sum");return h(e,n,((n,l,o,r,i,a)=>{const d=c(e),h=re(r);a||(a=k(d)),n();let f=Be(d,h,r,l,u,a);E(f)||(f=void 0),f!=d&&(v(e,f),s(t,[e],f,d))}),Je(o,1)),y},delMetricDefinition:e=>(f(e),y),getStore:r,getMetricIds:i,forEachMetric:a,hasMetric:d,getTableId:u,getMetric:c,addMetricIdsListener:g,addMetricListener:(e,n)=>l(n,t,[e]),delListener:e=>(o(e),y),destroy:L,getListenerStats:()=>({})};return ee(y)}));var $e=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{i(n.next(e))}catch(e){s(e)}},r=e=>{try{i(n.throw(e))}catch(e){s(e)}},i=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);i((n=n.apply(e,t)).next())}));const qe=he(),Ge=he();var He=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;const Xe=Ae((e=>{const t=e.createStore,l=t(),s=t(),o=he(),{addListener:r,callListeners:i,delListener:a}=s,[v,f,g,R,w,,,C,,b,m,V,E,x]=De(e,(()=>!0),F,r,i),D=(e,t,...n)=>B(n,(n=>Me(pe(pe(o,t,he),e,ke),n))),A=e=>{M(ge(o,e),(e=>{Le(e,((e,t)=>ce(t,(t=>e.delListener(t))))),ue(e)})),B([s,l],(t=>t.delTable(e)))},P=(e,t,n)=>D(t,e,t.addStartTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),j={setQueryDefinition:(t,o,r)=>{C(t,o),A(t);const i=[],a=[[null,[o,null,null,[],he()]]],d=[],u=[],c=[];r({select:(e,t)=>{const l=J(e)?[q(i)+n,e]:[k(t)?e:t,n=>n(e,t)];return K(i,l),{as:e=>l[0]=e}},join:(e,t,n)=>{const l=k(n)||J(t)?null:t,s=k(l)?t:n,o=[e,[e,l,J(s)?s:e=>e(s),[],he()]];return K(a,o),{as:e=>o[0]=e}},where:(e,t,n)=>K(d,J(e)?e:k(n)?n=>n(e)===t:l=>l(e,t)===n),group:(e,t,n,l,s)=>{var o;const r=[e,[e,J(t)?[t,n,l,s]:null!=(o=ge(Ne,t))?o:[(e,t)=>t]]];return K(u,r),{as:e=>r[0]=e}},having:(e,t)=>K(c,J(e)?e:n=>n(e)===t)});const v=he(i);if(ae(v))return j;const h=he(a);Le(h,((e,[,t])=>M(ge(h,t),(({3:t})=>k(e)?0:K(t,e)))));const f=he(u);let g=l;if(ae(f)&&G(c))g=s;else{P(t,g,s);const e=he();Le(f,((t,[n,l])=>Me(pe(e,n,ke),[t,l])));const n=ke();Le(v,(t=>ie(e,t)?0:Me(n,t)));const l=he(),o=(n,l,o,r)=>M(n,(([i,a,d,u])=>{Le(l,((t,[n])=>{const l=pe(i,t,he),s=ge(l,o),a=r?void 0:n;if(s!==a){const n=ke([[s,a]]),r=re(l);ye(l,o,a),ce(ge(e,t),(([e,t])=>{const s=Be(u[e],r,l,n,t);u[e]=k(Ve(s))?null:s}))}})),ae(a)||!Q(c,(e=>e((e=>u[e]))))?s.delRow(t,d):k(d)?n[2]=s.addRow(t,u):s.setRow(t,d,u)}));D(g,t,g.addRowListener(t,null,((s,r,i,a)=>{const d=[],u=[],c=he(),v=g.hasRow(t,i);let h=!v;ce(n,(e=>{const[n,l,s]=a(t,i,e);K(d,l),K(u,s),h||(h=n)})),Le(e,(e=>{const[n,,l]=a(t,i,e);(h||n)&&ye(c,e,[l])})),h&&o(me(l,d,void 0,(([,e])=>(ve(e,i),ae(e)))),c,i,1),v&&o(me(l,u,(()=>{const e={};return ce(n,(n=>e[n]=g.getCell(t,i,n))),[he(),ke(),void 0,e]}),(([,e])=>{Me(e,i)})),c,i)})))}P(t,e,g);const L=(n,l,s,r)=>{const i=t=>e.getCell(l,s,t);B(r,(l=>{var s;const[o,,r,a,d]=ge(h,l),u=null==r?void 0:r(i,n),[c,v]=null!=(s=ge(d,n))?s:[];u!=c&&(k(v)||x(t,v),ye(d,n,k(u)?null:[u,...E(t,1,e.addRowListener(o,u,(()=>L(n,o,u,a))))]))})),(n=>{const l=(t,l)=>{var s,r,i;return e.getCell(...k(l)?[o,n,t]:t===o?[o,n,l]:[null==(s=ge(h,t))?void 0:s[0],null==(i=ge(null==(r=ge(h,t))?void 0:r[4],n))?void 0:i[0],l])};g.transaction((()=>Q(d,(e=>e(l)))?Le(v,((e,s)=>Ee(g,t,n,e,s(l,n)))):g.delRow(t,n)))})(n)},{3:y}=ge(h,null);return g.transaction((()=>E(t,1,e.addRowListener(o,null,((n,l,s)=>{e.hasRow(o,s)?L(s,o,s,y):(g.delRow(t,s),ce(h,(({4:e})=>M(ge(e,s),(([,n])=>{x(t,n),ye(e,s)})))))}))))),j},delQueryDefinition:e=>(A(e),b(e),j),getStore:v,getQueryIds:f,forEachQuery:g,hasQuery:R,getTableId:w,addQueryIdsListener:e=>m((()=>e(j))),delListener:e=>(a(e),j),destroy:V,getListenerStats:()=>((e,t)=>{var n={};for(var l in e)Ke.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&He)for(var l of He(e))t.indexOf(l)<0&&Ue.call(e,l)&&(n[l]=e[l]);return n})(s.getListenerStats(),["tables","tableIds","transaction"])};return se({[h]:[1,1],[h+T]:[0,1],[y]:[0,1],[p]:[0,1],[I]:[0,5],[L]:[1,2],[T]:[0,2],[S]:[1,3]},(([e,t],n)=>{B(e?["get","has","forEach"]:["get"],(e=>j[e+u+n]=(...t)=>s[e+n](...t))),j[c+u+n+d]=(...e)=>s[c+n+d](...O(e,0,t),((n,...l)=>e[t](j,...l)),!0)})),ee(j)})),Ye=Ae((e=>{const t=he(),l=he(),s=he(),o=he(),[r,i,a]=Pe((()=>R)),[d,u,c,v,h,f,,,g,L,y,p]=De(e,(()=>[he(),he(),he(),he()]),(e=>k(e)?void 0:e+n),r,i),I=(e,t,n)=>M(f(e),(([l,,s])=>{if(!ie(s,t)){const o=ke();if(h(e)!=T(e))Me(o,t);else{let e=t;for(;!k(e)&&!ie(o,e);)Me(o,e),e=ge(l,e)}if(n)return o;ye(s,t,o)}return ge(s,t)})),S=(e,t)=>M(f(e),(([,,e])=>ye(e,t))),T=e=>ge(t,e),R={setRelationshipDefinition:(e,n,r,a)=>(ye(t,e,r),g(e,n,((t,n)=>{const r=ke(),a=ke(),d=ke(),[u,c]=f(e);ce(n,(([t,n],l)=>{k(t)||(Me(a,t),M(ge(c,t),(e=>{ve(e,l),ae(e)&&ye(c,t)}))),k(n)||(Me(a,n),ie(c,n)||ye(c,n,ke()),Me(ge(c,n),l)),Me(r,l),ye(u,l,n),Le(ge(o,e),(t=>{ie(I(e,t),l)&&Me(d,t)}))})),t(),ce(r,(t=>i(l,[e,t]))),ce(a,(t=>i(s,[e,t]))),ce(d,(t=>{S(e,t),i(o,[e,t])}))}),Je(a)),R),delRelationshipDefinition:e=>(ye(t,e),L(e),R),getStore:d,getRelationshipIds:u,forEachRelationship:t=>c((n=>t(n,(t=>e.forEachRow(h(n),t))))),hasRelationship:v,getLocalTableId:h,getRemoteTableId:T,getRemoteRowId:(e,t)=>{var n;return ge(null==(n=f(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return de(ge(null==(n=f(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>k(f(e))?[t]:de(I(e,t,!0)),addRelationshipIdsListener:y,addRemoteRowIdListener:(e,t,n)=>r(n,l,[e,t]),addLocalRowIdsListener:(e,t,n)=>r(n,s,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(I(e,t),r(n,o,[e,t])),delListener:e=>{var t;return S(...null!=(t=a(e))?t:[]),R},destroy:p,getListenerStats:()=>({})};return ee(R)})),Ze=e=>[e,e],_e=()=>[he(),he()],et=e=>[...e],tt=([e,t])=>e===t,nt=e=>JSON.stringify(e,((e,t)=>x(t,Map)?Y.fromEntries([...t]):t)),lt=JSON.parse,st=(e,t,n)=>k(e)||!te(e)||oe(e)||_(e)?(null==n||n(),!1):(se(e,((n,l)=>{t(n,l)||le(e,l)})),!oe(e)),ot=(e,t,n)=>ye(e,t,ge(e,t)==-n?void 0:n),rt=()=>{let e,t,n=!1,l=!1,s=0;const r=he(),u=he(),v=he(),I=he(),m=he(),V=he(),E=he(),x=he(),A=he(),F=he(),Q=he(),z=he(),$=he(),q=he(),G=ke(),H=he(),U=he(),X=he(),Y=he(),Z=_e(),_=_e(),te=_e(),de=_e(),me=_e(),De=_e(),Je=_e(),Ae=_e(),Oe=_e(),Qe=_e(),ze=_e(),Ne=_e(),Be=_e(),We=_e(),$e=_e(),qe=he(),Ge=_e(),[He,Ke,Ue,Xe]=Pe((()=>Sn)),Ye=e=>{if(!st(e,((e,t)=>P([i,a],t))))return!1;const t=e[i];return!(!D(t)&&t!=o||(Ve(e[a])!=t&&le(e,a),0))},it=(t,n)=>(!e||ie(Q,n)||Pt(n))&&st(t,((e,t)=>at(n,t,e)),(()=>Pt(n))),at=(e,t,n,l)=>st(l?n:vt(n,e,t),((l,s)=>M(dt(e,t,s,l),(e=>(n[s]=e,!0)),(()=>!1))),(()=>Pt(e,t))),dt=(t,n,l,s)=>e?M(ge(ge(Q,t),l),(e=>Ve(s)!=e[i]?Pt(t,n,l,s,e[a]):s),(()=>Pt(t,n,l,s))):k(Ve(s))?Pt(t,n,l,s):s,ut=(e,t)=>st(t?e:ht(e),((t,n)=>M(ct(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>Qt())),ct=(e,n)=>t?M(ge($,e),(t=>Ve(n)!=t[i]?Qt(e,n,t[a]):n),(()=>Qt(e,n))):k(Ve(n))?Qt(e,n):n,vt=(e,t,n)=>(M(ge(z,t),(([l,s])=>{ce(l,((t,n)=>{ne(e,n)||(e[n]=t)})),ce(s,(l=>{ne(e,l)||Pt(t,n,l)}))})),e),ht=e=>(t&&(ce(q,((t,n)=>{ne(e,n)||(e[n]=t)})),ce(G,(t=>{ne(e,t)||Qt(t)}))),e),ft=e=>Ie(Q,e,((e,t,n)=>{const l=he(),s=ke();Ie(pe(Q,t,he),n,((e,t,n)=>{ye(e,t,n),M(n[a],(e=>ye(l,t,e)),(()=>Me(s,t)))})),ye(z,t,[l,s])}),((e,t)=>{ye(Q,t),ye(z,t)})),gt=e=>Ie($,e,((e,t,n)=>{ye($,t,n),M(n[a],(e=>ye(q,t,e)),(()=>Me(G,t)))}),((e,t)=>{ye($,t),ye(q,t),ve(G,t)})),Lt=e=>oe(e)?cn():on(e),yt=e=>Ie(X,e,((e,t,n)=>pt(t,n)),((e,t)=>Vt(t))),pt=(e,t)=>Ie(pe(X,e,(()=>(Mt(e,1),ye(H,e,Fe()),ye(U,e,he()),he()))),t,((t,n,l)=>It(e,t,n,l)),((t,n)=>Et(e,t,n))),It=(e,t,n,l,s)=>Ie(pe(t,n,(()=>(Dt(e,n,1),he()))),l,((t,l,s)=>St(e,n,t,l,s)),((l,o)=>xt(e,t,n,l,o,s))),St=(e,t,n,l,s)=>{ie(n,l)||Jt(e,t,l,1);const o=ge(n,l);s!==o&&(At(e,t,l,o,s),ye(n,l,s))},Tt=(e,t,n,l,s)=>M(ge(t,n),(t=>St(e,n,t,l,s)),(()=>It(e,t,n,vt({[l]:s},e,n)))),Rt=e=>oe(e)?fn():rn(e),wt=e=>Ie(Y,e,((e,t,n)=>Ct(t,n)),((e,t)=>kt(t))),Ct=(e,t)=>{ie(Y,e)||Ot(e,1);const n=ge(Y,e);t!==n&&(Ft(e,n,t),ye(Y,e,t))},bt=(e,t)=>{const[n]=ge(H,e),l=n(t);return ie(ge(X,e),l)?bt(e,t):l},mt=e=>{var t;return null!=(t=ge(X,e))?t:pt(e,{})},Vt=e=>pt(e,{}),Et=(e,t,n)=>{const[,l]=ge(H,e);l(n),It(e,t,n,{},!0)},xt=(e,t,n,l,s,o)=>{var r;const i=ge(null==(r=ge(z,e))?void 0:r[0],s);if(!k(i)&&!o)return St(e,n,l,s,i);const a=t=>{At(e,n,t,ge(l,t)),Jt(e,n,t,-1),ye(l,t)};k(i)?a(s):Le(l,a),ae(l)&&(Dt(e,n,-1),ae(ye(t,n))&&(Mt(e,-1),ye(X,e),ye(H,e),ye(U,e)))},kt=e=>{const t=ge(q,e);if(!k(t))return Ct(e,t);Ft(e,ge(Y,e)),Ot(e,-1),ye(Y,e)},Mt=(e,t)=>ot(r,e,t),Dt=(e,t,n)=>ot(pe(I,e,he),t,n)&&ye(v,e,pe(v,e,(()=>0))+n),Jt=(e,t,n,l)=>{var s;const o=ge(U,e),r=null!=(s=ge(o,n))?s:0;(0==r&&1==l||1==r&&-1==l)&&ot(pe(u,e,he),n,l),ye(o,n,r!=-l?r+l:null),ot(pe(pe(m,e,he),t,he),n,l)},At=(e,t,n,l,s)=>pe(pe(pe(V,e,he),t,he),n,(()=>[l,0]))[1]=s,Ot=(e,t)=>ot(E,e,t),Ft=(e,t,n)=>pe(x,e,(()=>[t,0]))[1]=n,Pt=(e,t,n,l,s)=>(K(pe(pe(pe(A,e,he),t,he),n,(()=>[])),l),s),Qt=(e,t,n)=>(K(pe(F,e,(()=>[])),t),n),jt=(e,t,n)=>M(ge(ge(ge(V,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Ze(tn(e,t,n))])),zt=e=>M(ge(x,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ze(sn(e))])),Nt=e=>ae(A)||ae(ze[e])?0:ce(e?be(A):A,((t,n)=>ce(t,((t,l)=>ce(t,((t,s)=>Ke(ze[e],[n,l,s],t))))))),Bt=e=>ae(F)||ae(Ne[e])?0:ce(e?we(F):F,((t,n)=>Ke(Ne[e],[n],t))),Wt=(e,t,n)=>{if(!ae(t))return Ke(e,n,(()=>Se(t))),1},$t=e=>{const t=ae(Je[e]),n=ae(Oe[e])&&ae(de[e])&&ae(me[e])&&ae(De[e])&&t&&ae(_[e]),l=ae(Qe[e])&&ae(Ae[e])&&ae(te[e])&&ae(Z[e]);if(!n||!l){const s=e?[we(r),Ce(u),we(v),Ce(I),be(m),be(V)]:[r,u,v,I,m,V];if(!n){Wt(_[e],s[0]),ce(s[1],((t,n)=>Wt(de[e],t,[n]))),ce(s[2],((t,n)=>{0!=t&&Ke(me[e],[n],Yt(n))}));const n=ke();ce(s[3],((l,s)=>{Wt(De[e],l,[s])&&!t&&(Ke(Je[e],[s,null]),Me(n,s))})),t||ce(s[5],((t,l)=>{if(!ie(n,l)){const n=ke();ce(t,(e=>ce(e,(([t,l],s)=>l!==t?Me(n,s):ve(e,s))))),ce(n,(t=>Ke(Je[e],[l,t])))}})),ce(s[4],((t,n)=>ce(t,((t,l)=>Wt(Oe[e],t,[n,l])))))}if(!l){let t;ce(s[5],((n,l)=>{let s;ce(n,((n,o)=>{let r;ce(n,(([n,i],a)=>{i!==n&&(Ke(Qe[e],[l,o,a],i,n,jt),t=s=r=1)})),r&&Ke(Ae[e],[l,o],jt)})),s&&Ke(te[e],[l],jt)})),t&&Ke(Z[e],void 0,jt)}}},qt=e=>{const t=ae(We[e]),n=ae($e[e])&&ae(Be[e]);if(!t||!n){const l=e?[we(E),we(x)]:[E,x];if(t||Wt(We[e],l[0]),!n){let t;ce(l[1],(([n,l],s)=>{l!==n&&(Ke($e[e],[s],l,n,zt),t=1)})),t&&Ke(Be[e],void 0,zt)}}},Gt=(e,...t)=>(yn((()=>e(...W(t,b)))),Sn),Ht=()=>[Se(V,((e,t)=>-1===ge(r,t)?null:Se(e,((e,n)=>-1===ge(ge(I,t),n)?null:Se(e,(([,e])=>null!=e?e:null),((e,t)=>tt(t)))),oe)),oe),Se(x,(([,e])=>null!=e?e:null),((e,t)=>tt(t)))],Kt=()=>({cellsTouched:n,valuesTouched:l,changedCells:Re(V,et,tt),invalidCells:Re(A),changedValues:Se(x,et,tt),invalidValues:Se(F),changedTableIds:Se(r),changedRowIds:Te(I),changedCellIds:Re(m),changedValueIds:Se(E)}),Ut=()=>Re(X),Xt=()=>fe(X),Yt=e=>re(ge(X,b(e))),Zt=e=>fe(ge(X,b(e))),_t=(e,t,n,l=0,s)=>{return W(O(N((o=ge(X,b(e)),r=(e,n)=>[k(t)?n:ge(e,b(t)),n],W([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,t])=>r(t,e)))),(([e],[t])=>je(e,t)*(n?-1:1))),l,k(s)?s:l+s),(([,e])=>e));var o,r,i},en=(e,t)=>fe(ge(ge(X,b(e)),b(t))),tn=(e,t,n)=>ge(ge(ge(X,b(e)),b(t)),b(n)),nn=()=>Se(Y),ln=()=>fe(Y),sn=e=>ge(Y,b(e)),on=e=>Gt((()=>(e=>st(e,it,Pt))(e)?yt(e):0)),rn=e=>Gt((()=>ut(e)?wt(e):0)),an=e=>{try{Lt(lt(e))}catch(e){}return Sn},dn=t=>Gt((()=>{if((e=st(t,(e=>st(e,Ye))))&&(ft(t),!ae(X))){const e=Ut();cn(),on(e)}})),un=e=>Gt((()=>{if(t=(e=>st(e,Ye))(e)){const n=nn();Ln(),fn(),t=!0,gt(e),rn(n)}})),cn=()=>Gt((()=>yt({}))),vn=e=>Gt((e=>ie(X,e)?Vt(e):0),e),hn=(e,t)=>Gt(((e,t)=>M(ge(X,e),(n=>ie(n,t)?Et(e,n,t):0))),e,t),fn=()=>Gt((()=>wt({}))),gn=()=>Gt((()=>{ft({}),e=!1})),Ln=()=>Gt((()=>{gt({}),t=!1})),yn=(e,t)=>{if(-1!=s){pn();const n=e();return In(t),n}},pn=()=>(-1!=s&&s++,1==s&&Ke(qe,void 0,Ht,Kt),Sn),In=e=>(s>0&&(s--,0==s&&(n=!ae(V),l=!ae(x),s=1,Nt(1),n&&$t(1),Bt(1),l&&qt(1),(null==e?void 0:e(Ht,Kt))&&(ce(V,((e,t)=>ce(e,((e,n)=>ce(e,(([e],l)=>Ee(Sn,t,n,l,e))))))),ce(x,(([e],t)=>xe(Sn,t,e))),n=l=!1),Ke(Ge[0],void 0,Ht,Kt),s=-1,Nt(0),n&&$t(0),Bt(0),l&&qt(0),Ke(Ge[1],void 0,Ht,Kt),s=0,n=l=!1,B([r,u,v,I,m,V,A,E,x,F],ue))),Sn),Sn={getContent:()=>[Ut(),nn()],getTables:Ut,getTableIds:Xt,getTable:e=>Te(ge(X,b(e))),getTableCellIds:e=>fe(ge(U,b(e))),getRowCount:Yt,getRowIds:Zt,getSortedRowIds:_t,getRow:(e,t)=>Se(ge(ge(X,b(e)),b(t))),getCellIds:en,getCell:tn,getValues:nn,getValueIds:ln,getValue:sn,hasTables:()=>!ae(X),hasTable:e=>ie(X,b(e)),hasTableCell:(e,t)=>ie(ge(U,b(e)),b(t)),hasRow:(e,t)=>ie(ge(X,b(e)),b(t)),hasCell:(e,t,n)=>ie(ge(ge(X,b(e)),b(t)),b(n)),hasValues:()=>!ae(Y),hasValue:e=>ie(Y,b(e)),getTablesJson:()=>nt(X),getValuesJson:()=>nt(Y),getJson:()=>nt([X,Y]),getTablesSchemaJson:()=>nt(Q),getValuesSchemaJson:()=>nt($),getSchemaJson:()=>nt([Q,$]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>Gt((()=>{(oe(e)?cn:on)(e),(oe(t)?fn:rn)(t)})),setTables:on,setTable:(e,t)=>Gt((e=>it(t,e)?pt(e,t):0),e),setRow:(e,t,n)=>Gt(((e,t)=>at(e,t,n)?It(e,mt(e),t,n):0),e,t),addRow:(e,t,n=!0)=>yn((()=>{let l;return at(e,l,t)&&(e=b(e),It(e,mt(e),l=bt(e,n?1:0),t)),l})),setPartialRow:(e,t,n)=>Gt(((e,t)=>{if(at(e,t,n,1)){const l=mt(e);se(n,((n,s)=>Tt(e,l,t,s,n)))}}),e,t),setCell:(e,t,n,l)=>Gt(((e,t,n)=>M(dt(e,t,n,J(l)?l(tn(e,t,n)):l),(l=>Tt(e,mt(e),t,n,l)))),e,t,n),setValues:rn,setPartialValues:e=>Gt((()=>ut(e,1)?se(e,((e,t)=>Ct(t,e))):0)),setValue:(e,t)=>Gt((e=>M(ct(e,J(t)?t(sn(e)):t),(t=>Ct(e,t)))),e),setTransactionChanges:e=>Gt((()=>{se(e[0],((e,t)=>k(e)?vn(t):se(e,((e,n)=>k(e)?hn(t,n):se(e,((e,l)=>Ee(Sn,t,n,l,e))))))),se(e[1],((e,t)=>xe(Sn,t,e)))})),setTablesJson:an,setValuesJson:e=>{try{Rt(lt(e))}catch(e){}return Sn},setJson:e=>Gt((()=>{try{const[t,n]=lt(e);Lt(t),Rt(n)}catch(t){an(e)}})),setTablesSchema:dn,setValuesSchema:un,setSchema:(e,t)=>Gt((()=>{dn(e),un(t)})),delTables:cn,delTable:vn,delRow:hn,delCell:(e,t,n,l)=>Gt(((e,t,n)=>M(ge(X,e),(s=>M(ge(s,t),(o=>ie(o,n)?xt(e,s,t,o,n,l):0))))),e,t,n),delValues:fn,delValue:e=>Gt((e=>ie(Y,e)?kt(e):0),e),delTablesSchema:gn,delValuesSchema:Ln,delSchema:()=>Gt((()=>{gn(),Ln()})),transaction:yn,startTransaction:pn,finishTransaction:In,forEachTable:e=>ce(X,((t,n)=>e(n,(e=>ce(t,((t,n)=>e(n,(e=>Le(t,e))))))))),forEachTableCell:(e,t)=>Le(ge(U,b(e)),t),forEachRow:(e,t)=>ce(ge(X,b(e)),((e,n)=>t(n,(t=>Le(e,t))))),forEachCell:(e,t,n)=>Le(ge(ge(X,b(e)),b(t)),n),forEachValue:e=>Le(Y,e),addSortedRowIdsListener:(e,t,n,l,s,o,r)=>{let i=_t(e,t,n,l,s);return He((()=>{const r=_t(e,t,n,l,s);j(r,i)||(i=r,o(Sn,e,t,n,l,s,i))}),Je[r?1:0],[e,t],[Xt])},addStartTransactionListener:e=>He(e,qe),addWillFinishTransactionListener:e=>He(e,Ge[0]),addDidFinishTransactionListener:e=>He(e,Ge[1]),callListener:e=>(Xe(e),Sn),delListener:e=>(Ue(e),Sn),getListenerStats:()=>({}),createStore:rt,addListener:He,callListeners:Ke};return se({[f]:[0,Z],[g]:[0,_],[h]:[1,te,[Xt]],[h+T]:[1,de,[Xt]],[y]:[1,me,[Xt]],[p]:[1,De,[Xt]],[L]:[2,Ae,[Xt,Zt]],[T]:[2,Oe,[Xt,Zt]],[S]:[3,Qe,[Xt,Zt,en],e=>Ze(tn(...e))],InvalidCell:[3,ze],[w]:[0,Be],[C]:[0,We],[R]:[1,$e,[ln],e=>Ze(sn(e[0]))],InvalidValue:[1,Ne]},(([e,t,n,l],s)=>{Sn[c+s+d]=(...s)=>He(s[e],t[s[e+1]?1:0],e>0?O(s,0,e):void 0,n,l)})),ee(Sn)};e.createCheckpoints=Qe,e.createCustomPersister=(e,t,n,l,s,o,r=[])=>{let i,a,d,u=0,c=0;pe(qe,r,(()=>0)),pe(Ge,r,(()=>[]));const v=e=>$e(void 0,null,(function*(){return 2!=u&&(u=1,yield h.schedule((()=>$e(void 0,null,(function*(){yield e(),u=0}))))),h})),h={load:(n,l)=>$e(void 0,null,(function*(){return yield v((()=>$e(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,l])}}))))})),startAutoLoad:(...n)=>$e(void 0,[...n],(function*(n={},s={}){return h.stopAutoLoad(),yield h.load(n,s),c=1,d=l(((n,l)=>$e(void 0,null,(function*(){if(l){const t=l();yield v((()=>$e(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield v((()=>$e(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==n?void 0:n())?l:yield t())}catch(e){null==o||o(e)}}))))})))),h})),stopAutoLoad:()=>(c&&(s(d),d=void 0,c=0),h),save:t=>$e(void 0,null,(function*(){return 1!=u&&(u=2,yield h.schedule((()=>$e(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==o||o(e)}u=0}))))),h})),startAutoSave:()=>$e(void 0,null,(function*(){return yield h.stopAutoSave().save(),i=e.addDidFinishTransactionListener(((e,t)=>{const[n,l]=t();oe(n)&&oe(l)||h.save((()=>[n,l]))})),h})),stopAutoSave:()=>(M(i,e.delListener),h),schedule:(...e)=>$e(void 0,null,(function*(){return K(ge(Ge,r),...e),yield $e(void 0,null,(function*(){if(!ge(qe,r)){for(ye(qe,r,1);!k(a=X(ge(Ge,r)));)try{yield a()}catch(e){null==o||o(e)}ye(qe,r,0)}})),h})),getStore:()=>e,destroy:()=>h.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return ee(h)},e.createIndexes=ze,e.createMetrics=We,e.createQueries=Xe,e.createRelationships=Ye,e.createStore=rt,e.defaultSorter=je},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={});
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.8",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -228,14 +228,14 @@
|
|
|
228
228
|
"@types/jest": "^29.5.5",
|
|
229
229
|
"@types/jest-environment-puppeteer": "^5.0.4",
|
|
230
230
|
"@types/less": "^3.0.4",
|
|
231
|
-
"@types/node": "^20.
|
|
231
|
+
"@types/node": "^20.7.1",
|
|
232
232
|
"@types/puppeteer": "^5.4.7",
|
|
233
|
-
"@types/react": "^18.2.
|
|
234
|
-
"@types/react-dom": "^18.2.
|
|
235
|
-
"@types/react-test-renderer": "^18.0.
|
|
233
|
+
"@types/react": "^18.2.23",
|
|
234
|
+
"@types/react-dom": "^18.2.8",
|
|
235
|
+
"@types/react-test-renderer": "^18.0.3",
|
|
236
236
|
"@types/tmp": "^0.2.4",
|
|
237
|
-
"@typescript-eslint/eslint-plugin": "^6.7.
|
|
238
|
-
"@typescript-eslint/parser": "^6.7.
|
|
237
|
+
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
|
238
|
+
"@typescript-eslint/parser": "^6.7.3",
|
|
239
239
|
"@vlcn.io/crsqlite-wasm": "^0.15.2",
|
|
240
240
|
"asciichart": "^1.5.25",
|
|
241
241
|
"automerge-repo": "^0.1.0",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-3"><em>NEW!</em> v4.3 release</a> <span id="one-with">"The One With PartyKit"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">4.8kB - 9.2kB</a>, zero dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
1
|
+
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-3"><em>NEW!</em> v4.3 release</a> <span id="one-with">"The One With PartyKit"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">4.8kB - 9.2kB</a>, zero dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=GitHub&labelColor=%23d81b60&color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&logo=discord&logoColor=%23fff&label=Discord&labelColor=%233131e8&color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&logo=x&logoColor=%23fff&label=Twitter&labelColor=%23333&color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Ideas&labelColor=%23d81b60&color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Issues&labelColor=%23d81b60&color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&logo=jest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.3.8" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&logo=npm&logoColor=%23fff&labelColor=%23bd0005&color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const store = createStore()
|
|
@@ -247,4 +247,4 @@ export const createShop: typeof createShopDecl = () => {
|
|
|
247
247
|
};
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>4.8kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.2kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.9kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.5kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.8kB</td><td>11.4kB</td><td>48.7kB</td><td>220.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.1kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.2kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>
|
|
250
|
+
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>4.8kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.2kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.9kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.5kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.8kB</td><td>11.4kB</td><td>48.7kB</td><td>220.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.1kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.2kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>127.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.6kB</td><td>3.1kB</td><td>12.5kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.7kB</td><td>1.5kB</td><td>5.1kB</td><td>43.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.2kB</td><td>22.5kB</td><td>97.5kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,880</td><td>1,880</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,034</td><td>2,034</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>811</td><td>811</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>689</td><td>689</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,366</td></tr><tr><th class="right">Assertions</th><td colspan="3">15,257</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
|