tinybase 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/cjs/checkpoints.cjs +1 -1
- package/lib/cjs/checkpoints.cjs.gz +0 -0
- package/lib/cjs/indexes.cjs +1 -1
- package/lib/cjs/indexes.cjs.gz +0 -0
- package/lib/cjs/metrics.cjs +1 -1
- package/lib/cjs/metrics.cjs.gz +0 -0
- package/lib/cjs/persisters.cjs +1 -1
- package/lib/cjs/persisters.cjs.gz +0 -0
- package/lib/cjs/queries.cjs +1 -1
- package/lib/cjs/queries.cjs.gz +0 -0
- package/lib/cjs/relationships.cjs +1 -1
- package/lib/cjs/relationships.cjs.gz +0 -0
- package/lib/cjs/store.cjs +1 -1
- package/lib/cjs/store.cjs.gz +0 -0
- package/lib/cjs/tinybase.cjs +1 -1
- package/lib/cjs/tinybase.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/indexes.cjs +1 -1
- package/lib/cjs-es6/indexes.cjs.gz +0 -0
- package/lib/cjs-es6/metrics.cjs +1 -1
- package/lib/cjs-es6/metrics.cjs.gz +0 -0
- package/lib/cjs-es6/persisters.cjs +1 -1
- package/lib/cjs-es6/persisters.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/relationships.cjs +1 -1
- package/lib/cjs-es6/relationships.cjs.gz +0 -0
- package/lib/cjs-es6/store.cjs +1 -1
- package/lib/cjs-es6/store.cjs.gz +0 -0
- package/lib/cjs-es6/tinybase.cjs +1 -1
- package/lib/cjs-es6/tinybase.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/store.js +10 -17
- package/lib/debug/tinybase.js +10 -17
- package/lib/es6/indexes.js +1 -1
- package/lib/es6/indexes.js.gz +0 -0
- package/lib/es6/metrics.js +1 -1
- package/lib/es6/metrics.js.gz +0 -0
- package/lib/es6/persisters.js +1 -1
- package/lib/es6/persisters.js.gz +0 -0
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/relationships.js +1 -1
- package/lib/es6/relationships.js.gz +0 -0
- package/lib/es6/store.js +1 -1
- package/lib/es6/store.js.gz +0 -0
- package/lib/es6/tinybase.js +1 -1
- package/lib/es6/tinybase.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/types/store.d.ts +21 -20
- package/lib/types/with-schemas/store.d.ts +21 -20
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.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/store.js +1 -1
- package/lib/umd-es6/store.js.gz +0 -0
- package/lib/umd-es6/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +13 -13
- package/readme.md +2 -2
package/lib/umd-es6/queries.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,t=n(""),l=n(!0),r=n(0),o=n(n),s="Listener",i=(e,n)=>e.every(n),
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,t=n(""),l=n(!0),r=n(0),o=n(n),s="Listener",i="Result",a="Ids",d="Row",u=d+a,c="Sorted"+d+a,v="Cell",f=v+a,h=(e,n)=>e.every(n),y=(e,n)=>e.forEach(n),g=e=>b(e,((e,n)=>e+n),0),p=e=>e.length,w=e=>0==p(e),b=(e,n,t)=>e.reduce(n,t),L=(e,...n)=>e.push(...n),R=Math.max,T=Math.min,m=isFinite,O=e=>null==e,x=(e,n,t)=>O(e)?null==t?void 0:t():n(e),C=e=>n(e)==o,Q=e=>Array.isArray(e),S=()=>{},j=e=>e.size,I=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},E=e=>O(e)||0==j(e),M=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},D=e=>e.clear(),F=(e,n)=>null==e?void 0:e.forEach(n),k=(e,n)=>null==e?void 0:e.delete(n),z=e=>new Map(e),A=(e,n)=>null==e?void 0:e.get(n),P=(e,n)=>F(e,((e,t)=>n(t,e))),W=(e,n,t)=>O(t)?(k(e,n),e):null==e?void 0:e.set(n,t),B=(e,n,t)=>(I(e,n)||W(e,n,t()),A(e,n)),q=(e,n,t,l,r=0)=>x((t?B:A)(e,n[r],r>p(n)-2?t:z),(o=>{if(r>p(n)-2)return(null==l?void 0:l(o))&&W(e,n[r]),o;const s=q(o,n,t,l,r+1);return E(o)&&W(e,n[r]),s})),G=e=>new Set(Q(e)||O(e)?e:[e]),H=(e,n)=>null==e?void 0:e.add(n),J=z([["avg",[(e,n)=>g(e)/n,(e,n,t)=>e+(n-e)/(t+1),(e,n,t)=>e+(e-n)/(t-1),(e,n,t,l)=>e+(n-t)/l]],["max",[e=>R(...e),(e,n)=>R(n,e),(e,n)=>n==e?void 0:e,(e,n,t)=>t==e?void 0:R(n,e)]],["min",[e=>T(...e),(e,n)=>T(n,e),(e,n)=>n==e?void 0:e,(e,n,t)=>t==e?void 0:T(n,e)]],["sum",[e=>g(e),(e,n)=>e+n,(e,n)=>e-n,(e,n,t)=>e-t+n]]]),K=Object,N=K.freeze;var U=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;const Y=(e=>{const o=new WeakMap;return e=>(o.has(e)||o.set(e,(e=>{const o=e.createStore,[a,g,b,R,T,,,Y,,Z,$,_,ee]=((e,n,t)=>{const l=e.hasRow,r=z(),o=z(),s=z(),i=z(),a=z(),d=(n,t,...l)=>{const r=B(a,n,G);return y(l,(n=>H(r,n)&&t&&e.callListener(n))),l},u=(n,...t)=>x(A(a,n),(l=>{y(w(t)?M(l):t,(n=>{e.delListener(n),k(l,n)})),E(l)&&W(a,n)})),c=(e,n)=>{W(r,e,n),I(o,e)||(W(o,e,!0),W(s,e,z()),W(i,e,z()))},v=e=>{W(r,e),W(o,e),W(s,e),W(i,e),u(e)};return[()=>e,()=>{return[...null!=(n=null==(e=r)?void 0:e.keys())?n:[]];var e,n},e=>P(o,e),e=>I(o,e),e=>A(r,e),e=>A(o,e),(e,n)=>W(o,e,n),c,(n,r,o,a,v)=>{c(n,r);const f=z(),g=z(),w=A(s,n),b=A(i,n),L=n=>{const o=t=>e.getCell(r,n,t),s=A(w,n),i=l(r,n)?t(a(o,n)):void 0;var d,u;if(s===i||Q(s)&&Q(i)&&(u=i,p(d=s)===p(u)&&h(d,((e,n)=>u[n]===e)))||W(f,n,[s,i]),!O(v)){const e=A(b,n),t=l(r,n)?v(o,n):void 0;e!=t&&W(g,n,t)}},R=e=>{o((()=>{F(f,(([,e],n)=>W(w,n,e))),F(g,((e,n)=>W(b,n,e)))}),f,g,w,b,e),D(f),D(g)};P(w,L),e.hasTable(r)&&y(e.getRowIds(r),(e=>{I(w,e)||L(e)})),R(!0),u(n),d(n,0,e.addRowListener(r,null,((e,n,t)=>L(t))),e.addTableListener(r,(()=>R())))},v,()=>P(a,v),d,u]})(e,0,S),ne=o(),te=o(),le=z(),re=(e,n,...t)=>y(t,(t=>H(B(B(le,n,z),e,G),t))),oe=e=>{x(A(le,e),(e=>{P(e,((e,n)=>F(n,(n=>e.delListener(n))))),D(e)})),y([te,ne],(n=>n.delTable(e)))},se=(e,n,t)=>re(n,e,n.addWillFinishTransactionListener(t.startTransaction),n.addDidFinishTransactionListener((()=>t.finishTransaction()))),ie={setQueryDefinition:(o,s,i)=>{Y(o,s),oe(o);const a=[],d=[[null,[s,null,null,[],z()]]],u=[],c=[],v=[];i({select:(e,n)=>{const t=C(e)?[p(a)+"",e]:[O(n)?e:n,t=>t(e,n)];return L(a,t),{as:e=>t[0]=e}},join:(e,n,t)=>{const l=O(t)||C(n)?null:n,r=O(l)?n:t,o=[e,[e,l,C(r)?r:e=>e(r),[],z()]];return L(d,o),{as:e=>o[0]=e}},where:(e,n,t)=>L(u,C(e)?e:O(t)?t=>t(e)===n:l=>l(e,n)===t),group:(e,n,t,l,r)=>{var o;const s=[e,[e,C(n)?[n,t,l,r]:null!=(o=A(J,n))?o:[(e,n)=>n]]];return L(c,s),{as:e=>s[0]=e}},having:(e,n)=>L(v,C(e)?e:t=>t(e)===n)});const f=z(a);if(E(f))return ie;const g=z(d);P(g,((e,[,n])=>x(A(g,n),(({3:n})=>O(e)?0:L(n,e)))));const b=z(c);let R=ne;if(E(b)&&w(v))R=te;else{se(o,R,te);const e=z();P(b,((n,[t,l])=>H(B(e,t,G),[n,l])));const s=G();P(f,(n=>I(e,n)?0:H(s,n)));const i=z(),a=(s,i,a,d)=>x(s,(([u,c,f,y])=>{P(i,((o,[s])=>{const i=B(u,o,z),c=A(i,a),v=d?void 0:s;if(c!==v){const s=G([[c,v]]),d=j(i);W(i,a,v),F(A(e,o),(([e,o])=>{const a=((e,n,t,l,r,o=!1)=>{if(E(t))return;const[s,i,a,d]=r;return o||(o=O(e)),F(l,(([t,l])=>{o||(e=O(t)?null==i?void 0:i(e,l,n++):O(l)?null==a?void 0:a(e,t,n--):null==d?void 0:d(e,l,t,n),o||(o=O(e)))})),o?s(M(t),j(t)):e})(y[e],d,i,s,o);y[e]=O((e=>{const o=n(e);return(e=>e==t||e==l)(o)||o==r&&m(e)?o:void 0})(a))?null:a}))}})),E(c)||!h(v,(e=>e((e=>y[e]))))?te.delRow(o,f):O(f)?s[2]=te.addRow(o,y):te.setRow(o,f,y)}));re(R,o,R.addRowListener(o,null,((n,t,l,r)=>{const d=[],u=[],c=z(),v=R.hasRow(o,l);let f=!v;F(s,(e=>{const[n,t,s]=r(o,l,e);L(d,t),L(u,s),f||(f=n)})),P(e,(e=>{const[n,,t]=r(o,l,e);(f||n)&&W(c,e,[t])})),f&&a(q(i,d,void 0,(([,e])=>(k(e,l),E(e)))),c,l,1),v&&a(q(i,u,(()=>{const e={};return F(s,(n=>e[n]=R.getCell(o,l,n))),[z(),G(),void 0,e]}),(([,e])=>{H(e,l)})),c,l)})))}se(o,e,R);const T=(n,t,l,r)=>{const i=n=>e.getCell(t,l,n);y(r,(t=>{var l;const[r,,s,a,d]=A(g,t),u=null==s?void 0:s(i,n),[c,v]=null!=(l=A(d,n))?l:[];u!=c&&(O(v)||ee(o,v),W(d,n,O(u)?null:[u,..._(o,1,e.addRowListener(r,u,(()=>T(n,r,u,a))))]))})),(n=>{const t=(t,l)=>{var r,o,i;return e.getCell(...O(l)?[s,n,t]:t===s?[s,n,l]:[null==(r=A(g,t))?void 0:r[0],null==(i=A(null==(o=A(g,t))?void 0:o[4],n))?void 0:i[0],l])};R.transaction((()=>h(u,(e=>e(t)))?P(f,((e,l)=>((e,n,t,l,r)=>O(r)?e.delCell(n,t,l,!0):e.setCell(n,t,l,r))(R,o,n,e,l(t,n)))):R.delRow(o,n)))})(n)},{3:Q}=A(g,null);return R.transaction((()=>_(o,1,e.addRowListener(s,null,((n,t,l)=>{e.hasRow(s,l)?T(l,s,l,Q):(R.delRow(o,l),F(g,(({4:e})=>x(A(e,l),(([,n])=>{ee(o,n),W(e,l)})))))}))))),ie},delQueryDefinition:e=>(oe(e),Z(e),ie),getStore:a,getQueryIds:g,forEachQuery:b,hasQuery:R,getTableId:T,delListener:e=>(te.delListener(e),ie),destroy:$,getListenerStats:()=>((e,n)=>{var t={};for(var l in e)V.call(e,l)&&n.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&U)for(var l of U(e))n.indexOf(l)<0&&X.call(e,l)&&(t[l]=e[l]);return t})(te.getListenerStats(),["tables","tableIds","transaction"])};var ae,de;return ae={Table:[1,1],[u]:[0,1],[c]:[0,5],[d]:[1,2],[f]:[0,2],[v]:[1,3]},de=([e,n],t)=>{y(e?["get","has","forEach"]:["get"],(e=>ie[e+i+t]=(...n)=>te[e+t](...n))),ie["add"+i+t+s]=(...e)=>{return te["add"+t+s](...(l=e,0,r=n,l.slice(0,r)),((t,...l)=>e[n](ie,...l)));var l,r}},((e,n)=>{e.map(n)})(K.entries(ae),(([e,n])=>de(n,e))),N(ie)})(e)),o.get(e))})();e.createQueries=Y},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseQueries={});
|
|
Binary file
|
package/lib/umd-es6/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="",n=t(l),s=t(!0),r=t(0),a=t(t),o="type",u="default",i=e=>l+e,d=(e,t)=>e.forEach(t),c=(e,t)=>e.map(t),f=e=>e.length,v=(e,t,l)=>e.slice(t,l),h=(e,...t)=>e.push(...t),T=e=>JSON.stringify(e,((e,t)=>{return V(t,Map)?(l=(e,[t,l])=>(e[t]=l,e),n={},[...t].reduce(l,n)):t;var l,n})),g=JSON.parse,b=isFinite,V=(e,t)=>e instanceof t,y=e=>null==e,S=(e,t,l)=>y(e)?null==l?void 0:l():t(e),p=e=>e==n||e==s,w=e=>t(e)==a,m=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},I=e=>y(e)||0==(e=>e.size)(e),R=e=>e.clear(),C=(e,t)=>null==e?void 0:e.forEach(t),J=(e,t)=>null==e?void 0:e.delete(t),L=e=>new Map(e),E=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},F=(e,t)=>null==e?void 0:e.get(t),x=(e,t)=>C(e,((e,l)=>t(l,e))),z=(e,t,l)=>y(l)?(J(e,t),e):null==e?void 0:e.set(t,l),O=(e,t,l)=>(m(e,t)||z(e,t,l()),F(e,t)),j=(e,t,l)=>{const n={},s=null!=t?t:e=>e;return C(e,((e,t)=>S(s(e),(e=>(null==l?void 0:l(e))?0:n[t]=e)))),n},k=(e,t)=>{const l=L(),n=null!=t?t:e=>e;return C(e,((e,t)=>l.set(t,n(e)))),l},A=e=>k(e,k),M=(e,t,l,n,s=0)=>S((l?O:F)(e,t[s],s>f(t)-2?l:L),(r=>{if(s>f(t)-2)return(null==n?void 0:n(r))&&z(e,t[s]),r;const a=M(r,t,l,n,s+1);return I(r)&&z(e,t[s]),a})),N=e=>new Set(Array.isArray(e)||y(e)?e:[e]),P=(e,t)=>null==e?void 0:e.add(t),B=/^\d+$/,D=()=>{const e=[];let t=0;return[n=>{var s;return null!=(s=n?e.shift():null)?s:l+t++},t=>{B.test(t)&&f(e)<1e3&&h(e,t)}]},W=Object,$=W.keys,q=W.isFrozen,G=W.freeze,H=e=>V(e,W)&&e.constructor==W,K=(e,t)=>!y(((e,t)=>S(e,(e=>e[t])))(e,t)),Q=(e,t)=>delete e[t],U=(e,t)=>c(W.entries(e),(([e,l])=>t(l,e))),X=e=>{return H(e)&&(t=$(e),0==f(t));var t},Y=e=>[e,e],Z=()=>[L(),L()],_=e=>{const l=t(e);return p(l)||l==r&&b(e)?l:void 0},ee=(e,t,l,n=z)=>{const s=(r=e=>!K(t,e),E(e).filter(r));var r;return d($(t),(n=>l(e,n,t[n]))),d(s,(t=>n(e,t))),e},te=(e,t,l)=>y(e)||!H(e)||X(e)||q(e)?(null==l||l(),!1):(U(e,((l,n)=>{t(l,n)||Q(e,n)})),!X(e)),le=(e,t,l)=>z(e,t,F(e,t)==-l?void 0:l),ne=()=>{let e,t,n,s,a=0;const b=L(),V=L(),B=L(),W=L(),$=L(),q=L(),H=L(),se=L(),re=L(),ae=L(),oe=L(),ue=L(),ie=N(),de=L(),ce=L(),fe=L(),ve=Z(),he=Z(),Te=Z(),ge=Z(),be=Z(),Ve=Z(),ye=Z(),Se=Z(),pe=Z(),we=Z(),me=Z(),Ie=Z(),Re=Z(),Ce=Z(),[Je,Le,Ee,Fe]=(e=>{let t;const[n,s]=D(),r=L();return[(e,s,a,o=[],u=(()=>[]))=>{null!=t||(t=Pt);const i=n(1);return z(r,i,[e,s,a,o,u]),P(M(s,null!=a?a:[l],N),i),i},(e,n,...s)=>d(((e,t=[l])=>{const n=[],s=(e,l)=>l==f(t)?h(n,e):null===t[l]?C(e,(e=>s(e,l+1))):d([t[l],null],(t=>s(F(e,t),l+1)));return s(e,0),n})(e,n),(e=>C(e,(e=>F(r,e)[0](t,...null!=n?n:[],...s))))),e=>S(F(r,e),(([,t,n])=>(M(t,null!=n?n:[l],void 0,(t=>(J(t,e),I(t)?1:0))),z(r,e),s(e),n))),e=>S(F(r,e),(([e,,l=[],n,s])=>{const r=(...a)=>{var o,u;const i=f(a);i==f(l)?e(t,...a,...s(a)):y(l[i])?d(null!=(u=null==(o=n[i])?void 0:o.call(n,...a))?u:[],(e=>r(...a,e))):r(...a,l[i])};r()}))]})(),xe=e=>{if(!te(e,((e,t)=>[o,u].includes(t))))return!1;const t=e.type;return!(!p(t)&&t!=r||(_(e.default)!=t&&Q(e,u),0))},ze=(t,l)=>(!e||m(re,l)||ut(l))&&te(t,((e,t)=>Oe(l,t,e)),(()=>ut(l))),Oe=(e,t,l,n)=>te(n?l:Me(l,e,t),((n,s)=>S(je(e,t,s,n),(e=>(l[s]=e,!0)),(()=>!1))),(()=>ut(e,t))),je=(t,l,n,s)=>e?S(F(F(re,t),n),(e=>_(s)!=e.type?ut(t,l,n,s,e.default):s),(()=>ut(t,l,n,s))):y(_(s))?ut(t,l,n,s):s,ke=(e,t)=>te(t?e:Ne(e),((t,l)=>S(Ae(l,t),(t=>(e[l]=t,!0)),(()=>!1))),(()=>it())),Ae=(e,l)=>t?S(F(oe,e),(t=>_(l)!=t.type?it(e,l,t.default):l),(()=>it(e,l))):y(_(l))?it(e,l):l,Me=(e,t,l)=>(S(F(ae,t),(([n,s])=>{C(n,((t,l)=>{K(e,l)||(e[l]=t)})),C(s,(n=>{K(e,n)||ut(t,l,n)}))})),e),Ne=e=>(t&&(C(ue,((t,l)=>{K(e,l)||(e[l]=t)})),C(ie,(t=>{K(e,t)||it(t)}))),e),Pe=e=>ee(re,e,((e,t,l)=>{const n=L(),s=N();ee(O(re,t,L),l,((e,t,l)=>{z(e,t,l),S(l.default,(e=>z(n,t,e)),(()=>P(s,t)))})),z(ae,t,[n,s])}),((e,t)=>{z(re,t),z(ae,t)})),Be=e=>ee(oe,e,((e,t,l)=>{z(oe,t,l),S(l.default,(e=>z(ue,t,e)),(()=>P(ie,t)))}),((e,t)=>{z(oe,t),z(ue,t),J(ie,t)})),De=e=>X(e)?zt():Jt(e),We=e=>ee(ce,e,((e,t,l)=>$e(t,l)),((e,t)=>Ze(t))),$e=(e,t)=>ee(O(ce,e,(()=>(lt(e,1),L()))),t,((t,l,n)=>qe(e,t,l,n)),((t,l)=>_e(e,t,l))),qe=(e,t,l,n,s)=>ee(O(t,l,(()=>(nt(e,l,1),L()))),n,((t,n,s)=>Ge(e,l,t,n,s)),((n,r)=>et(e,t,l,n,r,s))),Ge=(e,t,l,n,s)=>{m(l,n)||st(e,t,n,1);const r=F(l,n);s!==r&&(rt(e,t,n,r,s),z(l,n,s))},He=(e,t,l,n,s)=>S(F(t,l),(t=>Ge(e,l,t,n,s)),(()=>qe(e,t,l,Me({[n]:s},e,l)))),Ke=e=>X(e)?Ot():Lt(e),Qe=e=>ee(fe,e,((e,t,l)=>Ue(t,l)),((e,t)=>tt(t))),Ue=(e,t)=>{m(fe,e)||at(e,1);const l=F(fe,e);t!==l&&(ot(e,l,t),z(fe,e,t))},Xe=(e,t)=>{const[l]=O(de,e,D),n=l(t);return m(F(ce,e),n)?Xe(e,t):n},Ye=e=>{var t;return null!=(t=F(ce,e))?t:$e(e,{})},Ze=e=>$e(e,{}),_e=(e,t,l)=>{const[,n]=O(de,e,D);n(l),qe(e,t,l,{},!0)},et=(e,t,l,n,s,r)=>{var a;const o=F(null==(a=F(ae,e))?void 0:a[0],s);if(!y(o)&&!r)return Ge(e,l,n,s,o);const u=t=>{rt(e,l,t,F(n,t)),st(e,l,t,-1),z(n,t)};y(o)?u(s):x(n,u),I(n)&&(nt(e,l,-1),I(z(t,l))&&(lt(e,-1),z(ce,e),z(de,e)))},tt=e=>{const t=F(ue,e);if(!y(t))return Ue(e,t);ot(e,F(fe,e)),at(e,-1),z(fe,e)},lt=(e,t)=>le(b,e,t),nt=(e,t,l)=>le(O(V,e,L),t,l),st=(e,t,l,n)=>le(O(O(B,e,L),t,L),l,n),rt=(e,t,l,n,s)=>O(O(O(W,e,L),t,L),l,(()=>[n,0]))[1]=s,at=(e,t)=>le($,e,t),ot=(e,t,l)=>O(q,e,(()=>[t,0]))[1]=l,ut=(e,t,l,n,s)=>(h(O(O(O(H,e,L),t,L),l,(()=>[])),n),s),it=(e,t,l)=>(h(O(se,e,(()=>[])),t),l),dt=(e,t,l)=>S(F(F(F(W,e),t),l),(([e,t])=>[!0,e,t]),(()=>[!1,...Y(mt(e,t,l))])),ct=e=>S(F(q,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Y(Ct(e))])),ft=e=>I(H)||I(pe[e])?0:C(e?k(H,A):H,((t,l)=>C(t,((t,n)=>C(t,((t,s)=>Le(pe[e],[l,n,s],t))))))),vt=e=>I(se)||I(we[e])?0:C(e?k(se):se,((t,l)=>Le(we[e],[l],t))),ht=(e,t,l)=>{if(!I(t))return Le(e,l),1},Tt=e=>{const t=I(be[e]),l=I(ye[e])&&I(ge[e])&&t&&I(he[e]),n=I(Se[e])&&I(Ve[e])&&I(Te[e])&&I(ve[e]);if(!l||!n){const s=e?[k(b),A(V),k(B,A),k(W,A)]:[b,V,B,W];if(!l){C(s[2],((t,l)=>C(t,((t,n)=>ht(ye[e],t,[l,n])))));const l=N();C(s[1],((n,s)=>{ht(ge[e],n,[s])&&!t&&(Le(be[e],[s,null]),P(l,s))})),t||C(s[3],((t,n)=>{if(!m(l,n)){const l=N();C(t,(e=>C(e,(([t,n],s)=>n!==t?P(l,s):J(e,s))))),C(l,(t=>Le(be[e],[n,t])))}})),ht(he[e],s[0])}if(!n){let t;C(s[3],((l,n)=>{let s;C(l,((l,r)=>{let a;C(l,(([l,o],u)=>{o!==l&&(Le(Se[e],[n,r,u],o,l,dt),t=s=a=1)})),a&&Le(Ve[e],[n,r],dt)})),s&&Le(Te[e],[n],dt)})),t&&Le(ve[e],void 0,dt)}}},gt=e=>{const t=I(Ie[e]),l=I(Re[e])&&I(me[e]);if(!t||!l){const n=e?[k($),k(q)]:[$,q];if(t||ht(Ie[e],n[0]),!l){let t;C(n[1],(([l,n],s)=>{n!==l&&(Le(Re[e],[s],n,l,ct),t=1)})),t&&Le(me[e],void 0,ct)}}},bt=(e,...t)=>(At((()=>e(...c(t,i)))),Pt),Vt=()=>j(ce,(e=>j(e,j))),yt=()=>E(ce),St=e=>E(F(ce,i(e))),pt=(e,t,l,n=0,s)=>{return c(v((a=F(ce,i(e)),o=(e,l)=>[y(t)?l:F(e,i(t)),l],r=([e],[t])=>(e<t?-1:1)*(l?-1:1),c([...null!=(u=null==a?void 0:a.entries())?u:[]],(([e,t])=>o(t,e))).sort(r)),n,y(s)?s:n+s),(([,e])=>e));var r,a,o,u},wt=(e,t)=>E(F(F(ce,i(e)),i(t))),mt=(e,t,l)=>F(F(F(ce,i(e)),i(t)),i(l)),It=()=>j(fe),Rt=()=>E(fe),Ct=e=>F(fe,i(e)),Jt=e=>bt((()=>(e=>te(e,ze,ut))(e)?We(e):0)),Lt=e=>bt((()=>ke(e)?Qe(e):0)),Et=e=>{try{De(g(e))}catch(e){}return Pt},Ft=t=>bt((()=>{if((e=te(t,(e=>te(e,xe))))&&(Pe(t),!I(ce))){const e=Vt();zt(),Jt(e)}})),xt=e=>bt((()=>{if(t=(e=>te(e,xe))(e)){const l=It();kt(),Ot(),t=!0,Be(e),Lt(l)}})),zt=()=>bt((()=>We({}))),Ot=()=>bt((()=>Qe({}))),jt=()=>bt((()=>{Pe({}),e=!1})),kt=()=>bt((()=>{Be({}),t=!1})),At=(e,t)=>{if(-1==a)return;Mt();const l=e();return Nt(t),l},Mt=()=>(a++,Pt),Nt=e=>(a>0&&(a--,0==a&&(n=!I(W),s=!I(q),a=1,ft(1),n&&Tt(1),vt(1),s&>(1),a=-1,(null==e?void 0:e(j(W,(e=>j(e,(e=>j(e,(e=>[...e]),(([e,t])=>e===t))),X)),X),j(H,(e=>j(e,j))),j(q,(e=>[...e]),(([e,t])=>e===t)),j(se)))&&(a=1,C(W,((e,t)=>C(e,((e,l)=>C(e,(([e],n)=>((e,t,l,n,s)=>y(s)?e.delCell(t,l,n,!0):e.setCell(t,l,n,s))(Pt,t,l,n,e))))))),C(q,(([e],t)=>((e,t,l)=>y(l)?e.delValue(t):e.setValue(t,l))(Pt,t,e))),a=-1,n=s=!1),Le(Ce[0],void 0,n,s),ft(0),n&&Tt(0),vt(0),s&>(0),Le(Ce[1],void 0,n,s),a=0,d([b,V,B,W,H,$,q,se],R))),Pt),Pt={getTables:Vt,getTableIds:yt,getTable:e=>j(F(ce,i(e)),j),getRowIds:St,getSortedRowIds:pt,getRow:(e,t)=>j(F(F(ce,i(e)),i(t))),getCellIds:wt,getCell:mt,getValues:It,getValueIds:Rt,getValue:Ct,hasTables:()=>!I(ce),hasTable:e=>m(ce,i(e)),hasRow:(e,t)=>m(F(ce,i(e)),i(t)),hasCell:(e,t,l)=>m(F(F(ce,i(e)),i(t)),i(l)),hasValues:()=>!I(fe),hasValue:e=>m(fe,i(e)),getTablesJson:()=>T(ce),getValuesJson:()=>T(fe),getJson:()=>T([ce,fe]),getTablesSchemaJson:()=>T(re),getValuesSchemaJson:()=>T(oe),getSchemaJson:()=>T([re,oe]),setTables:Jt,setTable:(e,t)=>bt((e=>ze(t,e)?$e(e,t):0),e),setRow:(e,t,l)=>bt(((e,t)=>Oe(e,t,l)?qe(e,Ye(e),t,l):0),e,t),addRow:(e,t,l=!0)=>At((()=>{let n;return Oe(e,n,t)&&(e=i(e),qe(e,Ye(e),n=Xe(e,l?1:0),t)),n})),setPartialRow:(e,t,l)=>bt(((e,t)=>{if(Oe(e,t,l,1)){const n=Ye(e);U(l,((l,s)=>He(e,n,t,s,l)))}}),e,t),setCell:(e,t,l,n)=>bt(((e,t,l)=>S(je(e,t,l,w(n)?n(mt(e,t,l)):n),(n=>He(e,Ye(e),t,l,n)))),e,t,l),setValues:Lt,setPartialValues:e=>bt((()=>ke(e,1)?U(e,((e,t)=>Ue(t,e))):0)),setValue:(e,t)=>bt((e=>S(Ae(e,w(t)?t(Ct(e)):t),(t=>Ue(e,t)))),e),setTablesJson:Et,setValuesJson:e=>{try{Ke(g(e))}catch(e){}return Pt},setJson:e=>{try{const[t,l]=g(e);De(t),Ke(l)}catch(t){Et(e)}return Pt},setTablesSchema:Ft,setValuesSchema:xt,setSchema:(e,t)=>bt((()=>{Ft(e),xt(t)})),delTables:zt,delTable:e=>bt((e=>m(ce,e)?Ze(e):0),e),delRow:(e,t)=>bt(((e,t)=>S(F(ce,e),(l=>m(l,t)?_e(e,l,t):0))),e,t),delCell:(e,t,l,n)=>bt(((e,t,l)=>S(F(ce,e),(s=>S(F(s,t),(r=>m(r,l)?et(e,s,t,r,l,n):0))))),e,t,l),delValues:Ot,delValue:e=>bt((e=>m(fe,e)?tt(e):0),e),delTablesSchema:jt,delValuesSchema:kt,delSchema:()=>bt((()=>{jt(),kt()})),transaction:At,startTransaction:Mt,finishTransaction:Nt,forEachTable:e=>C(ce,((t,l)=>e(l,(e=>C(t,((t,l)=>e(l,(e=>x(t,e))))))))),forEachRow:(e,t)=>C(F(ce,i(e)),((e,l)=>t(l,(t=>x(e,t))))),forEachCell:(e,t,l)=>x(F(F(ce,i(e)),i(t)),l),forEachValue:e=>x(fe,e),addSortedRowIdsListener:(e,t,l,n,s,r,a)=>{let o=pt(e,t,l,n,s);return Je((()=>{const a=pt(e,t,l,n,s);var u,i,d;i=o,f(u=a)===f(i)&&(d=(e,t)=>i[t]===e,u.every(d))||(o=a,r(Pt,e,t,l,n,s,o))}),be[a?1:0],[e,t],[yt])},addWillFinishTransactionListener:e=>Je(e,Ce[0]),addDidFinishTransactionListener:e=>Je(e,Ce[1]),callListener:e=>(Fe(e),Pt),delListener:e=>(Ee(e),Pt),getListenerStats:()=>({}),createStore:ne};return U({Tables:[0,ve],TableIds:[0,he],Table:[1,Te,[yt]],RowIds:[1,ge,[yt]],Row:[2,Ve,[yt,St]],CellIds:[2,ye,[yt,St]],Cell:[3,Se,[yt,St,wt],e=>Y(mt(...e))],InvalidCell:[3,pe],Values:[0,me],ValueIds:[0,Ie],Value:[1,Re,[Rt],e=>Y(Ct(e[0]))],InvalidValue:[1,we]},(([e,t,l,n],s)=>{Pt["add"+s+"Listener"]=(...s)=>Je(s[e],t[s[e+1]?1:0],e>0?v(s,0,e):void 0,l,n)})),G(Pt)};e.createStore=ne},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseStore={});
|
|
1
|
+
var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="",n=t(l),s=t(!0),r=t(0),a=t(t),o="type",u="default",i="Ids",c="Table",d=c+"s",f=c+i,v="Row"+i,h="Cell",g=h+i,T="Value",b=T+"s",V=T+i,S=e=>l+e,y=(e,t)=>e.forEach(t),p=(e,t)=>e.map(t),w=e=>e.length,m=(e,t,l)=>e.slice(t,l),R=(e,...t)=>e.push(...t),J=e=>JSON.stringify(e,((e,t)=>{return L(t,Map)?(l=(e,[t,l])=>(e[t]=l,e),n={},[...t].reduce(l,n)):t;var l,n})),C=JSON.parse,I=isFinite,L=(e,t)=>e instanceof t,E=e=>null==e,F=(e,t,l)=>E(e)?null==l?void 0:l():t(e),x=e=>e==n||e==s,z=e=>t(e)==a,O=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},j=e=>E(e)||0==(e=>e.size)(e),k=e=>e.clear(),A=(e,t)=>null==e?void 0:e.forEach(t),M=(e,t)=>null==e?void 0:e.delete(t),N=e=>new Map(e),P=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},B=(e,t)=>null==e?void 0:e.get(t),D=(e,t)=>A(e,((e,l)=>t(l,e))),W=(e,t,l)=>E(l)?(M(e,t),e):null==e?void 0:e.set(t,l),$=(e,t,l)=>(O(e,t)||W(e,t,l()),B(e,t)),q=(e,t,l)=>{const n={},s=null!=t?t:e=>e;return A(e,((e,t)=>F(s(e),(e=>(null==l?void 0:l(e))?0:n[t]=e)))),n},G=(e,t)=>{const l=N(),n=null!=t?t:e=>e;return A(e,((e,t)=>l.set(t,n(e)))),l},H=e=>G(e,G),K=(e,t,l,n,s=0)=>F((l?$:B)(e,t[s],s>w(t)-2?l:N),(r=>{if(s>w(t)-2)return(null==n?void 0:n(r))&&W(e,t[s]),r;const a=K(r,t,l,n,s+1);return j(r)&&W(e,t[s]),a})),Q=e=>new Set(Array.isArray(e)||E(e)?e:[e]),U=(e,t)=>null==e?void 0:e.add(t),X=/^\d+$/,Y=()=>{const e=[];let t=0;return[n=>{var s;return null!=(s=n?e.shift():null)?s:l+t++},t=>{X.test(t)&&w(e)<1e3&&R(e,t)}]},Z=Object,_=Z.keys,ee=Z.isFrozen,te=Z.freeze,le=e=>L(e,Z)&&e.constructor==Z,ne=(e,t)=>!E(((e,t)=>F(e,(e=>e[t])))(e,t)),se=(e,t)=>delete e[t],re=(e,t)=>p(Z.entries(e),(([e,l])=>t(l,e))),ae=e=>{return le(e)&&(t=_(e),0==w(t));var t},oe=e=>[e,e],ue=()=>[N(),N()],ie=e=>{const l=t(e);return x(l)||l==r&&I(e)?l:void 0},ce=(e,t,l,n=W)=>(re(t,((t,n)=>l(e,n,t))),D(e,(l=>ne(t,l)?0:n(e,l))),e),de=(e,t,l)=>E(e)||!le(e)||ae(e)||ee(e)?(null==l||l(),!1):(re(e,((l,n)=>{t(l,n)||se(e,n)})),!ae(e)),fe=(e,t,l)=>W(e,t,B(e,t)==-l?void 0:l),ve=()=>{let e,t,n,s,a=0;const i=N(),I=N(),L=N(),X=N(),Z=N(),_=N(),ee=N(),le=N(),he=N(),ge=N(),Te=N(),be=N(),Ve=Q(),Se=N(),ye=N(),pe=N(),we=ue(),me=ue(),Re=ue(),Je=ue(),Ce=ue(),Ie=ue(),Le=ue(),Ee=ue(),Fe=ue(),xe=ue(),ze=ue(),Oe=ue(),je=ue(),ke=ue(),[Ae,Me,Ne,Pe]=(e=>{let t;const[n,s]=Y(),r=N();return[(e,s,a,o=[],u=(()=>[]))=>{null!=t||(t=Qt);const i=n(1);return W(r,i,[e,s,a,o,u]),U(K(s,null!=a?a:[l],Q),i),i},(e,n,...s)=>y(((e,t=[l])=>{const n=[],s=(e,l)=>l==w(t)?R(n,e):null===t[l]?A(e,(e=>s(e,l+1))):y([t[l],null],(t=>s(B(e,t),l+1)));return s(e,0),n})(e,n),(e=>A(e,(e=>B(r,e)[0](t,...null!=n?n:[],...s))))),e=>F(B(r,e),(([,t,n])=>(K(t,null!=n?n:[l],void 0,(t=>(M(t,e),j(t)?1:0))),W(r,e),s(e),n))),e=>F(B(r,e),(([e,,l=[],n,s])=>{const r=(...a)=>{var o,u;const i=w(a);i==w(l)?e(t,...a,...s(a)):E(l[i])?y(null!=(u=null==(o=n[i])?void 0:o.call(n,...a))?u:[],(e=>r(...a,e))):r(...a,l[i])};r()}))]})(),Be=e=>{if(!de(e,((e,t)=>[o,u].includes(t))))return!1;const t=e[o];return!(!x(t)&&t!=r||(ie(e[u])!=t&&se(e,u),0))},De=(t,l)=>(!e||O(he,l)||bt(l))&&de(t,((e,t)=>We(l,t,e)),(()=>bt(l))),We=(e,t,l,n)=>de(n?l:He(l,e,t),((n,s)=>F($e(e,t,s,n),(e=>(l[s]=e,!0)),(()=>!1))),(()=>bt(e,t))),$e=(t,l,n,s)=>e?F(B(B(he,t),n),(e=>ie(s)!=e[o]?bt(t,l,n,s,e[u]):s),(()=>bt(t,l,n,s))):E(ie(s))?bt(t,l,n,s):s,qe=(e,t)=>de(t?e:Ke(e),((t,l)=>F(Ge(l,t),(t=>(e[l]=t,!0)),(()=>!1))),(()=>Vt())),Ge=(e,l)=>t?F(B(Te,e),(t=>ie(l)!=t[o]?Vt(e,l,t[u]):l),(()=>Vt(e,l))):E(ie(l))?Vt(e,l):l,He=(e,t,l)=>(F(B(ge,t),(([n,s])=>{A(n,((t,l)=>{ne(e,l)||(e[l]=t)})),A(s,(n=>{ne(e,n)||bt(t,l,n)}))})),e),Ke=e=>(t&&(A(be,((t,l)=>{ne(e,l)||(e[l]=t)})),A(Ve,(t=>{ne(e,t)||Vt(t)}))),e),Qe=e=>ce(he,e,((e,t,l)=>{const n=N(),s=Q();ce($(he,t,N),l,((e,t,l)=>{W(e,t,l),F(l[u],(e=>W(n,t,e)),(()=>U(s,t)))})),W(ge,t,[n,s])}),((e,t)=>{W(he,t),W(ge,t)})),Ue=e=>ce(Te,e,((e,t,l)=>{W(Te,t,l),F(l[u],(e=>W(be,t,e)),(()=>U(Ve,t)))}),((e,t)=>{W(Te,t),W(be,t),M(Ve,t)})),Xe=e=>ae(e)?Dt():At(e),Ye=e=>ce(ye,e,((e,t,l)=>Ze(t,l)),((e,t)=>ot(t))),Ze=(e,t)=>ce($(ye,e,(()=>(dt(e,1),N()))),t,((t,l,n)=>_e(e,t,l,n)),((t,l)=>ut(e,t,l))),_e=(e,t,l,n,s)=>ce($(t,l,(()=>(ft(e,l,1),N()))),n,((t,n,s)=>et(e,l,t,n,s)),((n,r)=>it(e,t,l,n,r,s))),et=(e,t,l,n,s)=>{O(l,n)||vt(e,t,n,1);const r=B(l,n);s!==r&&(ht(e,t,n,r,s),W(l,n,s))},tt=(e,t,l,n,s)=>F(B(t,l),(t=>et(e,l,t,n,s)),(()=>_e(e,t,l,He({[n]:s},e,l)))),lt=e=>ae(e)?Wt():Mt(e),nt=e=>ce(pe,e,((e,t,l)=>st(t,l)),((e,t)=>ct(t))),st=(e,t)=>{O(pe,e)||gt(e,1);const l=B(pe,e);t!==l&&(Tt(e,l,t),W(pe,e,t))},rt=(e,t)=>{const[l]=$(Se,e,Y),n=l(t);return O(B(ye,e),n)?rt(e,t):n},at=e=>{var t;return null!=(t=B(ye,e))?t:Ze(e,{})},ot=e=>Ze(e,{}),ut=(e,t,l)=>{const[,n]=$(Se,e,Y);n(l),_e(e,t,l,{},!0)},it=(e,t,l,n,s,r)=>{var a;const o=B(null==(a=B(ge,e))?void 0:a[0],s);if(!E(o)&&!r)return et(e,l,n,s,o);const u=t=>{ht(e,l,t,B(n,t)),vt(e,l,t,-1),W(n,t)};E(o)?u(s):D(n,u),j(n)&&(ft(e,l,-1),j(W(t,l))&&(dt(e,-1),W(ye,e),W(Se,e)))},ct=e=>{const t=B(be,e);if(!E(t))return st(e,t);Tt(e,B(pe,e)),gt(e,-1),W(pe,e)},dt=(e,t)=>fe(i,e,t),ft=(e,t,l)=>fe($(I,e,N),t,l),vt=(e,t,l,n)=>fe($($(L,e,N),t,N),l,n),ht=(e,t,l,n,s)=>$($($(X,e,N),t,N),l,(()=>[n,0]))[1]=s,gt=(e,t)=>fe(Z,e,t),Tt=(e,t,l)=>$(_,e,(()=>[t,0]))[1]=l,bt=(e,t,l,n,s)=>(R($($($(ee,e,N),t,N),l,(()=>[])),n),s),Vt=(e,t,l)=>(R($(le,e,(()=>[])),t),l),St=(e,t,l)=>F(B(B(B(X,e),t),l),(([e,t])=>[!0,e,t]),(()=>[!1,...oe(zt(e,t,l))])),yt=e=>F(B(_,e),(([e,t])=>[!0,e,t]),(()=>[!1,...oe(kt(e))])),pt=e=>j(ee)||j(Fe[e])?0:A(e?G(ee,H):ee,((t,l)=>A(t,((t,n)=>A(t,((t,s)=>Me(Fe[e],[l,n,s],t))))))),wt=e=>j(le)||j(xe[e])?0:A(e?G(le):le,((t,l)=>Me(xe[e],[l],t))),mt=(e,t,l)=>{if(!j(t))return Me(e,l),1},Rt=e=>{const t=j(Ce[e]),l=j(Le[e])&&j(Je[e])&&t&&j(me[e]),n=j(Ee[e])&&j(Ie[e])&&j(Re[e])&&j(we[e]);if(!l||!n){const s=e?[G(i),H(I),G(L,H),G(X,H)]:[i,I,L,X];if(!l){A(s[2],((t,l)=>A(t,((t,n)=>mt(Le[e],t,[l,n])))));const l=Q();A(s[1],((n,s)=>{mt(Je[e],n,[s])&&!t&&(Me(Ce[e],[s,null]),U(l,s))})),t||A(s[3],((t,n)=>{if(!O(l,n)){const l=Q();A(t,(e=>A(e,(([t,n],s)=>n!==t?U(l,s):M(e,s))))),A(l,(t=>Me(Ce[e],[n,t])))}})),mt(me[e],s[0])}if(!n){let t;A(s[3],((l,n)=>{let s;A(l,((l,r)=>{let a;A(l,(([l,o],u)=>{o!==l&&(Me(Ee[e],[n,r,u],o,l,St),t=s=a=1)})),a&&Me(Ie[e],[n,r],St)})),s&&Me(Re[e],[n],St)})),t&&Me(we[e],void 0,St)}}},Jt=e=>{const t=j(Oe[e]),l=j(je[e])&&j(ze[e]);if(!t||!l){const n=e?[G(Z),G(_)]:[Z,_];if(t||mt(Oe[e],n[0]),!l){let t;A(n[1],(([l,n],s)=>{n!==l&&(Me(je[e],[s],n,l,yt),t=1)})),t&&Me(ze[e],void 0,yt)}}},Ct=(e,...t)=>(Gt((()=>e(...p(t,S)))),Qt),It=()=>q(ye,(e=>q(e,q))),Lt=()=>P(ye),Et=e=>P(B(ye,S(e))),Ft=(e,t,l,n=0,s)=>{return p(m((a=B(ye,S(e)),o=(e,l)=>[E(t)?l:B(e,S(t)),l],r=([e],[t])=>(e<t?-1:1)*(l?-1:1),p([...null!=(u=null==a?void 0:a.entries())?u:[]],(([e,t])=>o(t,e))).sort(r)),n,E(s)?s:n+s),(([,e])=>e));var r,a,o,u},xt=(e,t)=>P(B(B(ye,S(e)),S(t))),zt=(e,t,l)=>B(B(B(ye,S(e)),S(t)),S(l)),Ot=()=>q(pe),jt=()=>P(pe),kt=e=>B(pe,S(e)),At=e=>Ct((()=>(e=>de(e,De,bt))(e)?Ye(e):0)),Mt=e=>Ct((()=>qe(e)?nt(e):0)),Nt=e=>{try{Xe(C(e))}catch(e){}return Qt},Pt=t=>Ct((()=>{if((e=de(t,(e=>de(e,Be))))&&(Qe(t),!j(ye))){const e=It();Dt(),At(e)}})),Bt=e=>Ct((()=>{if(t=(e=>de(e,Be))(e)){const l=Ot();qt(),Wt(),t=!0,Ue(e),Mt(l)}})),Dt=()=>Ct((()=>Ye({}))),Wt=()=>Ct((()=>nt({}))),$t=()=>Ct((()=>{Qe({}),e=!1})),qt=()=>Ct((()=>{Ue({}),t=!1})),Gt=(e,t)=>{if(-1==a)return;Ht();const l=e();return Kt(t),l},Ht=()=>(a++,Qt),Kt=e=>(a>0&&(a--,0==a&&(n=!j(X),s=!j(_),a=1,pt(1),n&&Rt(1),wt(1),s&&Jt(1),a=-1,(null==e?void 0:e(q(X,(e=>q(e,(e=>q(e,(e=>[...e]),(([e,t])=>e===t))),ae)),ae),q(ee,(e=>q(e,q))),q(_,(e=>[...e]),(([e,t])=>e===t)),q(le)))&&(a=1,A(X,((e,t)=>A(e,((e,l)=>A(e,(([e],n)=>((e,t,l,n,s)=>E(s)?e.delCell(t,l,n,!0):e.setCell(t,l,n,s))(Qt,t,l,n,e))))))),A(_,(([e],t)=>((e,t,l)=>E(l)?e.delValue(t):e.setValue(t,l))(Qt,t,e))),a=-1,n=s=!1),Me(ke[0],void 0,n,s),pt(0),n&&Rt(0),wt(0),s&&Jt(0),Me(ke[1],void 0,n,s),a=0,y([i,I,L,X,ee,Z,_,le],k))),Qt),Qt={getTables:It,getTableIds:Lt,getTable:e=>q(B(ye,S(e)),q),getRowIds:Et,getSortedRowIds:Ft,getRow:(e,t)=>q(B(B(ye,S(e)),S(t))),getCellIds:xt,getCell:zt,getValues:Ot,getValueIds:jt,getValue:kt,hasTables:()=>!j(ye),hasTable:e=>O(ye,S(e)),hasRow:(e,t)=>O(B(ye,S(e)),S(t)),hasCell:(e,t,l)=>O(B(B(ye,S(e)),S(t)),S(l)),hasValues:()=>!j(pe),hasValue:e=>O(pe,S(e)),getTablesJson:()=>J(ye),getValuesJson:()=>J(pe),getJson:()=>J([ye,pe]),getTablesSchemaJson:()=>J(he),getValuesSchemaJson:()=>J(Te),getSchemaJson:()=>J([he,Te]),setTables:At,setTable:(e,t)=>Ct((e=>De(t,e)?Ze(e,t):0),e),setRow:(e,t,l)=>Ct(((e,t)=>We(e,t,l)?_e(e,at(e),t,l):0),e,t),addRow:(e,t,l=!0)=>Gt((()=>{let n;return We(e,n,t)&&(e=S(e),_e(e,at(e),n=rt(e,l?1:0),t)),n})),setPartialRow:(e,t,l)=>Ct(((e,t)=>{if(We(e,t,l,1)){const n=at(e);re(l,((l,s)=>tt(e,n,t,s,l)))}}),e,t),setCell:(e,t,l,n)=>Ct(((e,t,l)=>F($e(e,t,l,z(n)?n(zt(e,t,l)):n),(n=>tt(e,at(e),t,l,n)))),e,t,l),setValues:Mt,setPartialValues:e=>Ct((()=>qe(e,1)?re(e,((e,t)=>st(t,e))):0)),setValue:(e,t)=>Ct((e=>F(Ge(e,z(t)?t(kt(e)):t),(t=>st(e,t)))),e),setTablesJson:Nt,setValuesJson:e=>{try{lt(C(e))}catch(e){}return Qt},setJson:e=>{try{const[t,l]=C(e);Xe(t),lt(l)}catch(t){Nt(e)}return Qt},setTablesSchema:Pt,setValuesSchema:Bt,setSchema:(e,t)=>Ct((()=>{Pt(e),Bt(t)})),delTables:Dt,delTable:e=>Ct((e=>O(ye,e)?ot(e):0),e),delRow:(e,t)=>Ct(((e,t)=>F(B(ye,e),(l=>O(l,t)?ut(e,l,t):0))),e,t),delCell:(e,t,l,n)=>Ct(((e,t,l)=>F(B(ye,e),(s=>F(B(s,t),(r=>O(r,l)?it(e,s,t,r,l,n):0))))),e,t,l),delValues:Wt,delValue:e=>Ct((e=>O(pe,e)?ct(e):0),e),delTablesSchema:$t,delValuesSchema:qt,delSchema:()=>Ct((()=>{$t(),qt()})),transaction:Gt,startTransaction:Ht,finishTransaction:Kt,forEachTable:e=>A(ye,((t,l)=>e(l,(e=>A(t,((t,l)=>e(l,(e=>D(t,e))))))))),forEachRow:(e,t)=>A(B(ye,S(e)),((e,l)=>t(l,(t=>D(e,t))))),forEachCell:(e,t,l)=>D(B(B(ye,S(e)),S(t)),l),forEachValue:e=>D(pe,e),addSortedRowIdsListener:(e,t,l,n,s,r,a)=>{let o=Ft(e,t,l,n,s);return Ae((()=>{const a=Ft(e,t,l,n,s);var u,i,c;i=o,w(u=a)===w(i)&&(c=(e,t)=>i[t]===e,u.every(c))||(o=a,r(Qt,e,t,l,n,s,o))}),Ce[a?1:0],[e,t],[Lt])},addWillFinishTransactionListener:e=>Ae(e,ke[0]),addDidFinishTransactionListener:e=>Ae(e,ke[1]),callListener:e=>(Pe(e),Qt),delListener:e=>(Ne(e),Qt),getListenerStats:()=>({}),createStore:ve};return re({[d]:[0,we],[f]:[0,me],[c]:[1,Re,[Lt]],[v]:[1,Je,[Lt]],Row:[2,Ie,[Lt,Et]],[g]:[2,Le,[Lt,Et]],[h]:[3,Ee,[Lt,Et,xt],e=>oe(zt(...e))],InvalidCell:[3,Fe],[b]:[0,ze],[V]:[0,Oe],[T]:[1,je,[jt],e=>oe(kt(e[0]))],InvalidValue:[1,xe]},(([e,t,l,n],s)=>{Qt["add"+s+"Listener"]=(...s)=>Ae(s[e],t[s[e+1]?1:0],e>0?m(s,0,e):void 0,l,n)})),te(Qt)};e.createStore=ve},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseStore={});
|
package/lib/umd-es6/store.js.gz
CHANGED
|
Binary file
|
package/lib/umd-es6/tinybase.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e,t){"use strict";const n=e=>typeof e,l="",s=n(l),o=n(!0),r=n(0),a=n(n),i="default",d="utf8",c="Listener",u="Result",v="add",h="Table",f="RowIds",g="Cell",p="CellIds",y=e=>l+e,L=(e,t)=>e.includes(t),w=(e,t)=>e.every(t),S=(e,t)=>C(e)===C(t)&&w(e,((e,n)=>t[n]===e)),I=(e,t)=>w(e,((n,l)=>0==l||t(e[l-1],n)<=0)),R=(e,t)=>e.sort(t),T=(e,t)=>e.forEach(t),b=(e,t)=>e.map(t),m=e=>x(e,((e,t)=>e+t),0),C=e=>e.length,V=e=>0==C(e),x=(e,t,n)=>e.reduce(t,n),E=(e,t,n)=>e.slice(t,n),P=(e,...t)=>e.push(...t),k=e=>e.pop(),J=e=>e.shift(),M=e=>JSON.stringify(e,((e,t)=>j(t,Map)?x([...t],((e,[t,n])=>(e[t]=n,e)),{}):t)),A=JSON.parse,D=Math.max,O=Math.min,F=isFinite,j=(e,t)=>e instanceof t,Q=e=>null==e,z=(e,t,n)=>Q(e)?null==n?void 0:n():t(e),N=e=>e==s||e==o,W=e=>n(e)==a,B=e=>Array.isArray(e),q=()=>{},H=e=>e.size,$=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},G=e=>Q(e)||0==H(e),K=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},U=e=>e.clear(),X=(e,t)=>null==e?void 0:e.forEach(t),Y=(e,t)=>null==e?void 0:e.delete(t),Z=e=>new Map(e),_=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},ee=(e,t)=>null==e?void 0:e.get(t),te=(e,t)=>X(e,((e,n)=>t(n,e))),ne=(e,t,n)=>Q(n)?(Y(e,t),e):null==e?void 0:e.set(t,n),le=(e,t,n)=>($(e,t)||ne(e,t,n()),ee(e,t)),se=(e,t,n)=>{const l={},s=null!=t?t:e=>e;return X(e,((e,t)=>z(s(e),(e=>(null==n?void 0:n(e))?0:l[t]=e)))),l},oe=(e,t)=>{const n=Z(),l=null!=t?t:e=>e;return X(e,((e,t)=>n.set(t,l(e)))),n},re=e=>oe(e,oe),ae=(e,t,n,l,s=0)=>z((n?le:ee)(e,t[s],s>C(t)-2?n:Z),(o=>{if(s>C(t)-2)return(null==l?void 0:l(o))&&ne(e,t[s]),o;const r=ae(o,t,n,l,s+1);return G(o)&&ne(e,t[s]),r})),ie=e=>{const t=n(e);return N(t)||t==r&&F(e)?t:void 0},de=(e,t,n,l,s)=>Q(s)?e.delCell(t,n,l,!0):e.setCell(t,n,l,s),ce=(e,t,n)=>Q(n)?e.delValue(t):e.setValue(t,n),ue=e=>new Set(B(e)||Q(e)?e:[e]),ve=(e,t)=>null==e?void 0:e.add(t),he=(e,t,n)=>{const l=e.hasRow,s=Z(),o=Z(),r=Z(),a=Z(),i=Z(),d=(t,n,...l)=>{const s=le(i,t,ue);return T(l,(t=>ve(s,t)&&n&&e.callListener(t))),l},c=(t,...n)=>z(ee(i,t),(l=>{T(V(n)?K(l):n,(t=>{e.delListener(t),Y(l,t)})),G(l)&&ne(i,t)})),u=(e,n)=>{ne(s,e,n),$(o,e)||(ne(o,e,t()),ne(r,e,Z()),ne(a,e,Z()))},v=e=>{ne(s,e),ne(o,e),ne(r,e),ne(a,e),c(e)};return[()=>e,()=>_(s),e=>te(o,e),e=>$(o,e),e=>ee(s,e),e=>ee(o,e),(e,t)=>ne(o,e,t),u,(t,s,o,i,v)=>{u(t,s);const h=Z(),f=Z(),g=ee(r,t),p=ee(a,t),y=t=>{const o=n=>e.getCell(s,t,n),r=ee(g,t),a=l(s,t)?n(i(o,t)):void 0;if(r===a||B(r)&&B(a)&&S(r,a)||ne(h,t,[r,a]),!Q(v)){const e=ee(p,t),n=l(s,t)?v(o,t):void 0;e!=n&&ne(f,t,n)}},L=e=>{o((()=>{X(h,(([,e],t)=>ne(g,t,e))),X(f,((e,t)=>ne(p,t,e)))}),h,f,g,p,e),U(h),U(f)};te(g,y),e.hasTable(s)&&T(e.getRowIds(s),(e=>{$(g,e)||y(e)})),L(!0),c(t),d(t,0,e.addRowListener(s,null,((e,t,n)=>y(n))),e.addTableListener(s,(()=>L())))},v,()=>te(i,v),d,c]},fe=(e,t)=>n(e)==s?t=>t(e):null!=e?e:()=>null!=t?t:l,ge=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},pe=/^\d+$/,ye=()=>{const e=[];let t=0;return[n=>{var s;return null!=(s=n?J(e):null)?s:l+t++},t=>{pe.test(t)&&C(e)<1e3&&P(e,t)}]},Le=e=>{let t;const[n,s]=ye(),o=Z();return[(s,r,a,i=[],d=(()=>[]))=>{null!=t||(t=e());const c=n(1);return ne(o,c,[s,r,a,i,d]),ve(ae(r,null!=a?a:[l],ue),c),c},(e,n,...s)=>T(((e,t=[l])=>{const n=[],s=(e,l)=>l==C(t)?P(n,e):null===t[l]?X(e,(e=>s(e,l+1))):T([t[l],null],(t=>s(ee(e,t),l+1)));return s(e,0),n})(e,n),(e=>X(e,(e=>ee(o,e)[0](t,...null!=n?n:[],...s))))),e=>z(ee(o,e),(([,t,n])=>(ae(t,null!=n?n:[l],void 0,(t=>(Y(t,e),G(t)?1:0))),ne(o,e),s(e),n))),e=>z(ee(o,e),(([e,,n=[],l,s])=>{const o=(...r)=>{var a,i;const d=C(r);d==C(n)?e(t,...r,...s(r)):Q(n[d])?T(null!=(i=null==(a=l[d])?void 0:a.call(l,...r))?i:[],(e=>o(...r,e))):o(...r,n[d])};o()}))]},we=Object,Se=we.keys,Ie=we.isFrozen,Re=we.freeze,Te=e=>j(e,we)&&e.constructor==we,be=(e,t)=>!Q(((e,t)=>z(e,(e=>e[t])))(e,t)),me=(e,t)=>delete e[t],Ce=(e,t)=>b(we.entries(e),(([e,n])=>t(n,e))),Ve=e=>Te(e)&&V(Se(e)),xe=ge((e=>{let t,n,s,o=100,r=Z(),a=Z(),i=1;const d=Z(),c=Z(),[u,v,h]=Le((()=>W)),f=Z(),g=Z(),p=[],y=[],w=(t,n)=>{i=0,e.transaction((()=>{const[l,s]=ee(f,n);X(l,((n,l)=>X(n,((n,s)=>X(n,((n,o)=>de(e,l,s,o,n[t]))))))),X(s,((n,l)=>ce(e,l,n[t])))})),i=1},S=e=>{ne(f,e),ne(g,e),v(c,[e])},I=(e,t)=>T(((e,t)=>e.splice(0,t))(e,null!=t?t:C(e)),S),R=()=>I(p,C(p)-o),b=()=>z(t,(()=>{P(p,t),R(),I(y),t=void 0,s=1})),m=()=>{t=k(p),s=1},x=e.addCellListener(null,null,null,((e,t,n,l,s,o)=>{if(i){b();const e=le(r,t,Z),a=le(e,n,Z),i=le(a,l,(()=>[o,void 0]));i[1]=s,i[0]===s&&G(ne(a,l))&&G(ne(e,n))&&G(ne(r,t))&&m(),O()}})),E=e.addValueListener(null,((e,t,n,l)=>{if(i){b();const e=le(a,t,(()=>[l,void 0]));e[1]=n,e[0]===n&&G(ne(a,t))&&m(),O()}})),M=(e="")=>(Q(t)&&(t=l+n++,ne(f,t,[r,a]),j(t,e),r=Z(),a=Z(),s=1),t),A=()=>{V(p)||(((e,...t)=>{e.unshift(...t)})(y,M()),w(0,t),t=k(p),s=1)},D=()=>{V(y)||(P(p,t),t=J(y),w(1,t),s=1)},O=()=>{s&&(v(d),s=0)},F=e=>{const t=M(e);return O(),t},j=(e,t)=>(N(e)&&ee(g,e)!==t&&(ne(g,e,t),v(c,[e])),W),N=e=>$(f,e),W={setSize:e=>(o=e,R(),W),addCheckpoint:F,setCheckpoint:j,getStore:()=>e,getCheckpointIds:()=>[[...p],t,[...y]],forEachCheckpoint:e=>te(g,e),hasCheckpoint:N,getCheckpoint:e=>ee(g,e),goBackward:()=>(A(),O(),W),goForward:()=>(D(),O(),W),goTo:e=>{const n=L(p,e)?A:L(y,e)?D:null;for(;!Q(n)&&e!=t;)n();return O(),W},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(h(e),W),clear:()=>(I(p),I(y),Q(t)||S(t),t=void 0,n=0,F(),W),destroy:()=>{e.delListener(x),e.delListener(E)},getListenerStats:()=>({})};return Re(W.clear())})),Ee=(e,t)=>e<t?-1:1,Pe=ge((e=>{const t=Z(),n=Z(),[s,o,r,a,i,d,c,,u,v,h]=he(e,Z,(e=>Q(e)?l:B(e)?b(e,y):y(e))),[f,g,p]=Le((()=>w)),L=(t,n,l)=>{const s=i(t);X(l,((t,l)=>n(l,(n=>X(t,(t=>n(t,(n=>e.forEachCell(s,t,n)))))))))},w={setIndexDefinition:(e,l,s,o,r,a=Ee)=>{const i=Q(r)?void 0:([e],[t])=>r(e,t);return u(e,l,((l,s,r,u,v,h)=>{let f=0;const p=ue(),y=ue(),L=d(e);if(X(s,(([e,t],n)=>{const l=ue(e),s=ue(t);X(l,(e=>Y(s,e)?Y(l,e):0)),X(l,(e=>{ve(p,e),z(ee(L,e),(t=>{Y(t,n),G(t)&&(ne(L,e),f=1)}))})),X(s,(e=>{ve(p,e),$(L,e)||(ne(L,e,ue()),f=1),ve(ee(L,e),n),Q(o)||ve(y,e)}))})),l(),G(v)||(h?te(L,(e=>ve(y,e))):te(r,(e=>z(ee(u,e),(e=>ve(y,e))))),X(y,(e=>{const t=(t,n)=>a(ee(v,t),ee(v,n),e),n=[...ee(L,e)];I(n,t)||(ne(L,e,ue(R(n,t))),ve(p,e))}))),(f||h)&&!Q(i)){const t=[...L];I(t,i)||(c(e,Z(R(t,i))),f=1)}f&&g(t,[e]),X(p,(t=>g(n,[e,t])))}),fe(s),z(o,fe)),w},delIndexDefinition:e=>(v(e),w),getStore:s,getIndexIds:o,forEachIndex:e=>r(((t,n)=>e(t,(e=>L(t,e,n))))),forEachSlice:(e,t)=>L(e,t,d(e)),hasIndex:a,hasSlice:(e,t)=>$(d(e),t),getTableId:i,getSliceIds:e=>_(d(e)),getSliceRowIds:(e,t)=>K(ee(d(e),t)),addSliceIdsListener:(e,n)=>f(n,t,[e]),addSliceRowIdsListener:(e,t,l)=>f(l,n,[e,t]),delListener:e=>(p(e),w),destroy:h,getListenerStats:()=>({})};return Re(w)})),ke=Z([["avg",[(e,t)=>m(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=>D(...e),(e,t)=>D(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:D(t,e)]],["min",[e=>O(...e),(e,t)=>O(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:O(t,e)]],["sum",[e=>m(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Je=(e,t,n,l,s,o=!1)=>{if(G(n))return;const[r,a,i,d]=s;return o||(o=Q(e)),X(l,(([n,l])=>{o||(e=Q(n)?null==a?void 0:a(e,l,t++):Q(l)?null==i?void 0:i(e,n,t--):null==d?void 0:d(e,l,n,t),o||(o=Q(e)))})),o?r(K(n),H(n)):e},Me=ge((e=>{const t=Z(),[n,s,o,r,a,i,d,,c,u,v]=he(e,q,(e=>isNaN(e)||Q(e)||!0===e||!1===e||e===l?void 0:1*e)),[h,f,g]=Le((()=>p)),p={setMetricDefinition:(e,n,l,s,o,r,a)=>{var u;const v=W(l)?[l,o,r,a]:null!=(u=ee(ke,l))?u:ee(ke,"sum");return c(e,n,((n,l,s,o,r,a)=>{const c=i(e),u=H(o);a||(a=Q(c)),n();let h=Je(c,u,o,l,v,a);F(h)||(h=void 0),h!=c&&(d(e,h),f(t,[e],h,c))}),fe(s,1)),p},delMetricDefinition:e=>(u(e),p),getStore:n,getMetricIds:s,forEachMetric:o,hasMetric:r,getTableId:a,getMetric:i,addMetricListener:(e,n)=>h(n,t,[e]),delListener:e=>(g(e),p),destroy:v,getListenerStats:()=>({})};return Re(p)}));var Ae=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{a(n.next(e))}catch(e){s(e)}},r=e=>{try{a(n.throw(e))}catch(e){s(e)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);a((n=n.apply(e,t)).next())}));const De=(e,t,n,s,o)=>{let r,a,i=0;const d={load:(n,s)=>Ae(void 0,null,(function*(){if(2!=i){i=1;const o=yield t();Q(o)||o==l?e.transaction((()=>e.setTables(n).setValues(s))):e.setJson(o),i=0}return d})),startAutoLoad:(e,t)=>Ae(void 0,null,(function*(){return d.stopAutoLoad(),yield d.load(e,t),s(d.load),d})),stopAutoLoad:()=>(o(),d),save:()=>Ae(void 0,null,(function*(){return 1!=i&&(i=2,yield n(e.getJson()),i=0),d})),startAutoSave:()=>Ae(void 0,null,(function*(){return yield d.stopAutoSave().save(),r=e.addTablesListener(d.save),a=e.addValuesListener(d.save),d})),stopAutoSave:()=>(z(r,e.delListener),z(a,e.delListener),d),getStore:()=>e,destroy:()=>d.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return Re(d)};var Oe=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{a(n.next(e))}catch(e){s(e)}},r=e=>{try{a(n.throw(e))}catch(e){s(e)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);a((n=n.apply(e,t)).next())}));const Fe="storage",je=globalThis.window,Qe=(e,t,n)=>{let l;return De(e,(()=>Oe(void 0,null,(function*(){return n.getItem(t)}))),(e=>Oe(void 0,null,(function*(){return n.setItem(t,e)}))),(e=>{l=l=>{l.storageArea===n&&l.key===t&&e()},je.addEventListener(Fe,l)}),(()=>{je.removeEventListener(Fe,l),l=void 0}))};var ze=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{a(n.next(e))}catch(e){s(e)}},r=e=>{try{a(n.throw(e))}catch(e){s(e)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);a((n=n.apply(e,t)).next())})),Ne=(e,t,n)=>new Promise(((l,s)=>{var o=e=>{try{a(n.next(e))}catch(e){s(e)}},r=e=>{try{a(n.throw(e))}catch(e){s(e)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(o,r);a((n=n.apply(e,t)).next())}));const We=e=>e.headers.get("ETag");var Be=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;const $e=ge((e=>{const t=e.createStore,[n,s,o,r,a,,,i,,d,y,L,S]=he(e,(()=>!0),q),I=t(),R=t(),b=Z(),m=(e,t,...n)=>T(n,(n=>ve(le(le(b,t,Z),e,ue),n))),x=e=>{z(ee(b,e),(e=>{te(e,((e,t)=>X(t,(t=>e.delListener(t))))),U(e)})),T([R,I],(t=>t.delTable(e)))},k=(e,t,n)=>m(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),J={setQueryDefinition:(t,n,s)=>{i(t,n),x(t);const o=[],r=[[null,[n,null,null,[],Z()]]],a=[],d=[],c=[];s({select:(e,t)=>{const n=W(e)?[C(o)+l,e]:[Q(t)?e:t,n=>n(e,t)];return P(o,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const l=Q(n)||W(t)?null:t,s=Q(l)?t:n,o=[e,[e,l,W(s)?s:e=>e(s),[],Z()]];return P(r,o),{as:e=>o[0]=e}},where:(e,t,n)=>P(a,W(e)?e:Q(n)?n=>n(e)===t:l=>l(e,t)===n),group:(e,t,n,l,s)=>{var o;const r=[e,[e,W(t)?[t,n,l,s]:null!=(o=ee(ke,t))?o:[(e,t)=>t]]];return P(d,r),{as:e=>r[0]=e}},having:(e,t)=>P(c,W(e)?e:n=>n(e)===t)});const u=Z(o);if(G(u))return J;const v=Z(r);te(v,((e,[,t])=>z(ee(v,t),(({3:t})=>Q(e)?0:P(t,e)))));const h=Z(d);let f=I;if(G(h)&&V(c))f=R;else{k(t,f,R);const e=Z();te(h,((t,[n,l])=>ve(le(e,n,ue),[t,l])));const n=ue();te(u,(t=>$(e,t)?0:ve(n,t)));const l=Z(),s=(n,l,s,o)=>z(n,(([r,a,i,d])=>{te(l,((t,[n])=>{const l=le(r,t,Z),a=ee(l,s),i=o?void 0:n;if(a!==i){const n=ue([[a,i]]),o=H(l);ne(l,s,i),X(ee(e,t),(([e,t])=>{const s=Je(d[e],o,l,n,t);d[e]=Q(ie(s))?null:s}))}})),G(a)||!w(c,(e=>e((e=>d[e]))))?R.delRow(t,i):Q(i)?n[2]=R.addRow(t,d):R.setRow(t,i,d)}));m(f,t,f.addRowListener(t,null,((o,r,a,i)=>{const d=[],c=[],u=Z(),v=f.hasRow(t,a);let h=!v;X(n,(e=>{const[n,l,s]=i(t,a,e);P(d,l),P(c,s),h||(h=n)})),te(e,(e=>{const[n,,l]=i(t,a,e);(h||n)&&ne(u,e,[l])})),h&&s(ae(l,d,void 0,(([,e])=>(Y(e,a),G(e)))),u,a,1),v&&s(ae(l,c,(()=>{const e={};return X(n,(n=>e[n]=f.getCell(t,a,n))),[Z(),ue(),void 0,e]}),(([,e])=>{ve(e,a)})),u,a)})))}k(t,e,f);const g=(l,s,o,r)=>{const i=t=>e.getCell(s,o,t);T(r,(n=>{var s;const[o,,r,a,d]=ee(v,n),c=null==r?void 0:r(i,l),[u,h]=null!=(s=ee(d,l))?s:[];c!=u&&(Q(h)||S(t,h),ne(d,l,Q(c)?null:[c,...L(t,1,e.addRowListener(o,c,(()=>g(l,o,c,a))))]))})),(l=>{const s=(t,s)=>{var o,r,a;return e.getCell(...Q(s)?[n,l,t]:t===n?[n,l,s]:[null==(o=ee(v,t))?void 0:o[0],null==(a=ee(null==(r=ee(v,t))?void 0:r[4],l))?void 0:a[0],s])};f.transaction((()=>w(a,(e=>e(s)))?te(u,((e,n)=>de(f,t,l,e,n(s,l)))):f.delRow(t,l)))})(l)},{3:p}=ee(v,null);return f.transaction((()=>L(t,1,e.addRowListener(n,null,((l,s,o)=>{e.hasRow(n,o)?g(o,n,o,p):(f.delRow(t,o),X(v,(({4:e})=>z(ee(e,o),(([,n])=>{S(t,n),ne(e,o)})))))}))))),J},delQueryDefinition:e=>(x(e),d(e),J),getStore:n,getQueryIds:s,forEachQuery:o,hasQuery:r,getTableId:a,delListener:e=>(R.delListener(e),J),destroy:y,getListenerStats:()=>((e,t)=>{var n={};for(var l in e)qe.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&Be)for(var l of Be(e))t.indexOf(l)<0&&He.call(e,l)&&(n[l]=e[l]);return n})(R.getListenerStats(),["tables","tableIds","transaction"])};return Ce({[h]:[1,1],[f]:[0,1],SortedRowIds:[0,5],Row:[1,2],[p]:[0,2],[g]:[1,3]},(([e,t],n)=>{T(e?["get","has","forEach"]:["get"],(e=>J[e+u+n]=(...t)=>R[e+n](...t))),J[v+u+n+c]=(...e)=>R[v+n+c](...E(e,0,t),((n,...l)=>e[t](J,...l)))})),Re(J)})),Ge=ge((e=>{const t=Z(),n=Z(),s=Z(),o=Z(),[r,a,i,d,c,u,,,v,h,f]=he(e,(()=>[Z(),Z(),Z(),Z()]),(e=>Q(e)?void 0:e+l)),[g,p,y]=Le((()=>I)),L=(e,t,n)=>z(u(e),(([l,,s])=>{if(!$(s,t)){const o=ue();if(c(e)!=S(e))ve(o,t);else{let e=t;for(;!Q(e)&&!$(o,e);)ve(o,e),e=ee(l,e)}if(n)return o;ne(s,t,o)}return ee(s,t)})),w=(e,t)=>z(u(e),(([,,e])=>ne(e,t))),S=e=>ee(t,e),I={setRelationshipDefinition:(e,l,r,a)=>(ne(t,e,r),v(e,l,((t,l)=>{const r=ue(),a=ue(),i=ue(),[d,c]=u(e);X(l,(([t,n],l)=>{Q(t)||(ve(a,t),z(ee(c,t),(e=>{Y(e,l),G(e)&&ne(c,t)}))),Q(n)||(ve(a,n),$(c,n)||ne(c,n,ue()),ve(ee(c,n),l)),ve(r,l),ne(d,l,n),te(ee(o,e),(t=>{$(L(e,t),l)&&ve(i,t)}))})),t(),X(r,(t=>p(n,[e,t]))),X(a,(t=>p(s,[e,t]))),X(i,(t=>{w(e,t),p(o,[e,t])}))}),fe(a)),I),delRelationshipDefinition:e=>(ne(t,e),h(e),I),getStore:r,getRelationshipIds:a,forEachRelationship:t=>i((n=>t(n,(t=>e.forEachRow(c(n),t))))),hasRelationship:d,getLocalTableId:c,getRemoteTableId:S,getRemoteRowId:(e,t)=>{var n;return ee(null==(n=u(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return K(ee(null==(n=u(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>Q(u(e))?[t]:K(L(e,t,!0)),addRemoteRowIdListener:(e,t,l)=>g(l,n,[e,t]),addLocalRowIdsListener:(e,t,n)=>g(n,s,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(L(e,t),g(n,o,[e,t])),delListener:e=>(w(...y(e)),I),destroy:f,getListenerStats:()=>({})};return Re(I)})),Ke=e=>[e,e],Ue=()=>[Z(),Z()],Xe=(e,t,n,l=ne)=>{const s=(o=e=>!be(t,e),_(e).filter(o));var o;return T(Se(t),(l=>n(e,l,t[l]))),T(s,(t=>l(e,t))),e},Ye=(e,t,n)=>Q(e)||!Te(e)||Ve(e)||Ie(e)?(null==n||n(),!1):(Ce(e,((n,l)=>{t(n,l)||me(e,l)})),!Ve(e)),Ze=(e,t,n)=>ne(e,t,ee(e,t)==-n?void 0:n),_e=()=>{let e,t,n,l,s=0;const o=Z(),a=Z(),d=Z(),u=Z(),w=Z(),I=Z(),m=Z(),C=Z(),V=Z(),x=Z(),k=Z(),J=Z(),D=ue(),O=Z(),F=Z(),j=Z(),B=Ue(),q=Ue(),H=Ue(),K=Ue(),ae=Ue(),he=Ue(),fe=Ue(),ge=Ue(),pe=Ue(),we=Ue(),Se=Ue(),Ie=Ue(),Te=Ue(),xe=Ue(),[Pe,ke,Je,Me]=Le((()=>Kt)),Ae=e=>{if(!Ye(e,((e,t)=>L(["type",i],t))))return!1;const t=e.type;return!(!N(t)&&t!=r||(ie(e.default)!=t&&me(e,i),0))},De=(t,n)=>(!e||$(V,n)||yt(n))&&Ye(t,((e,t)=>Oe(n,t,e)),(()=>yt(n))),Oe=(e,t,n,l)=>Ye(l?n:ze(n,e,t),((l,s)=>z(Fe(e,t,s,l),(e=>(n[s]=e,!0)),(()=>!1))),(()=>yt(e,t))),Fe=(t,n,l,s)=>e?z(ee(ee(V,t),l),(e=>ie(s)!=e.type?yt(t,n,l,s,e.default):s),(()=>yt(t,n,l,s))):Q(ie(s))?yt(t,n,l,s):s,je=(e,t)=>Ye(t?e:Ne(e),((t,n)=>z(Qe(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>Lt())),Qe=(e,n)=>t?z(ee(k,e),(t=>ie(n)!=t.type?Lt(e,n,t.default):n),(()=>Lt(e,n))):Q(ie(n))?Lt(e,n):n,ze=(e,t,n)=>(z(ee(x,t),(([l,s])=>{X(l,((t,n)=>{be(e,n)||(e[n]=t)})),X(s,(l=>{be(e,l)||yt(t,n,l)}))})),e),Ne=e=>(t&&(X(J,((t,n)=>{be(e,n)||(e[n]=t)})),X(D,(t=>{be(e,t)||Lt(t)}))),e),We=e=>Xe(V,e,((e,t,n)=>{const l=Z(),s=ue();Xe(le(V,t,Z),n,((e,t,n)=>{ne(e,t,n),z(n.default,(e=>ne(l,t,e)),(()=>ve(s,t)))})),ne(x,t,[l,s])}),((e,t)=>{ne(V,t),ne(x,t)})),Be=e=>Xe(k,e,((e,t,n)=>{ne(k,t,n),z(n.default,(e=>ne(J,t,e)),(()=>ve(D,t)))}),((e,t)=>{ne(k,t),ne(J,t),Y(D,t)})),qe=e=>Ve(e)?Nt():Ot(e),He=e=>Xe(F,e,((e,t,n)=>$e(t,n)),((e,t)=>at(t))),$e=(e,t)=>Xe(le(F,e,(()=>(ut(e,1),Z()))),t,((t,n,l)=>Ge(e,t,n,l)),((t,n)=>it(e,t,n))),Ge=(e,t,n,l,s)=>Xe(le(t,n,(()=>(vt(e,n,1),Z()))),l,((t,l,s)=>et(e,n,t,l,s)),((l,o)=>dt(e,t,n,l,o,s))),et=(e,t,n,l,s)=>{$(n,l)||ht(e,t,l,1);const o=ee(n,l);s!==o&&(ft(e,t,l,o,s),ne(n,l,s))},tt=(e,t,n,l,s)=>z(ee(t,n),(t=>et(e,n,t,l,s)),(()=>Ge(e,t,n,ze({[l]:s},e,n)))),nt=e=>Ve(e)?Wt():Ft(e),lt=e=>Xe(j,e,((e,t,n)=>st(t,n)),((e,t)=>ct(t))),st=(e,t)=>{$(j,e)||gt(e,1);const n=ee(j,e);t!==n&&(pt(e,n,t),ne(j,e,t))},ot=(e,t)=>{const[n]=le(O,e,ye),l=n(t);return $(ee(F,e),l)?ot(e,t):l},rt=e=>{var t;return null!=(t=ee(F,e))?t:$e(e,{})},at=e=>$e(e,{}),it=(e,t,n)=>{const[,l]=le(O,e,ye);l(n),Ge(e,t,n,{},!0)},dt=(e,t,n,l,s,o)=>{var r;const a=ee(null==(r=ee(x,e))?void 0:r[0],s);if(!Q(a)&&!o)return et(e,n,l,s,a);const i=t=>{ft(e,n,t,ee(l,t)),ht(e,n,t,-1),ne(l,t)};Q(a)?i(s):te(l,i),G(l)&&(vt(e,n,-1),G(ne(t,n))&&(ut(e,-1),ne(F,e),ne(O,e)))},ct=e=>{const t=ee(J,e);if(!Q(t))return st(e,t);pt(e,ee(j,e)),gt(e,-1),ne(j,e)},ut=(e,t)=>Ze(o,e,t),vt=(e,t,n)=>Ze(le(a,e,Z),t,n),ht=(e,t,n,l)=>Ze(le(le(d,e,Z),t,Z),n,l),ft=(e,t,n,l,s)=>le(le(le(u,e,Z),t,Z),n,(()=>[l,0]))[1]=s,gt=(e,t)=>Ze(w,e,t),pt=(e,t,n)=>le(I,e,(()=>[t,0]))[1]=n,yt=(e,t,n,l,s)=>(P(le(le(le(m,e,Z),t,Z),n,(()=>[])),l),s),Lt=(e,t,n)=>(P(le(C,e,(()=>[])),t),n),wt=(e,t,n)=>z(ee(ee(ee(u,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Ke(Jt(e,t,n))])),St=e=>z(ee(I,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Ke(Dt(e))])),It=e=>G(m)||G(pe[e])?0:X(e?oe(m,re):m,((t,n)=>X(t,((t,l)=>X(t,((t,s)=>ke(pe[e],[n,l,s],t))))))),Rt=e=>G(C)||G(we[e])?0:X(e?oe(C):C,((t,n)=>ke(we[e],[n],t))),Tt=(e,t,n)=>{if(!G(t))return ke(e,n),1},bt=e=>{const t=G(ae[e]),n=G(fe[e])&&G(K[e])&&t&&G(q[e]),l=G(ge[e])&&G(he[e])&&G(H[e])&&G(B[e]);if(!n||!l){const s=e?[oe(o),re(a),oe(d,re),oe(u,re)]:[o,a,d,u];if(!n){X(s[2],((t,n)=>X(t,((t,l)=>Tt(fe[e],t,[n,l])))));const n=ue();X(s[1],((l,s)=>{Tt(K[e],l,[s])&&!t&&(ke(ae[e],[s,null]),ve(n,s))})),t||X(s[3],((t,l)=>{if(!$(n,l)){const n=ue();X(t,(e=>X(e,(([t,l],s)=>l!==t?ve(n,s):Y(e,s))))),X(n,(t=>ke(ae[e],[l,t])))}})),Tt(q[e],s[0])}if(!l){let t;X(s[3],((n,l)=>{let s;X(n,((n,o)=>{let r;X(n,(([n,a],i)=>{a!==n&&(ke(ge[e],[l,o,i],a,n,wt),t=s=r=1)})),r&&ke(he[e],[l,o],wt)})),s&&ke(H[e],[l],wt)})),t&&ke(B[e],void 0,wt)}}},mt=e=>{const t=G(Ie[e]),n=G(Te[e])&&G(Se[e]);if(!t||!n){const l=e?[oe(w),oe(I)]:[w,I];if(t||Tt(Ie[e],l[0]),!n){let t;X(l[1],(([n,l],s)=>{l!==n&&(ke(Te[e],[s],l,n,St),t=1)})),t&&ke(Se[e],void 0,St)}}},Ct=(e,...t)=>(Ht((()=>e(...b(t,y)))),Kt),Vt=()=>se(F,(e=>se(e,se))),xt=()=>_(F),Et=e=>_(ee(F,y(e))),Pt=(e,t,n,l=0,s)=>{return b(E(R((o=ee(F,y(e)),r=(e,n)=>[Q(t)?n:ee(e,y(t)),n],b([...null!=(a=null==o?void 0:o.entries())?a:[]],(([e,t])=>r(t,e)))),(([e],[t])=>Ee(e,t)*(n?-1:1))),l,Q(s)?s:l+s),(([,e])=>e));var o,r,a},kt=(e,t)=>_(ee(ee(F,y(e)),y(t))),Jt=(e,t,n)=>ee(ee(ee(F,y(e)),y(t)),y(n)),Mt=()=>se(j),At=()=>_(j),Dt=e=>ee(j,y(e)),Ot=e=>Ct((()=>(e=>Ye(e,De,yt))(e)?He(e):0)),Ft=e=>Ct((()=>je(e)?lt(e):0)),jt=e=>{try{qe(A(e))}catch(e){}return Kt},Qt=t=>Ct((()=>{if((e=Ye(t,(e=>Ye(e,Ae))))&&(We(t),!G(F))){const e=Vt();Nt(),Ot(e)}})),zt=e=>Ct((()=>{if(t=(e=>Ye(e,Ae))(e)){const n=Mt();qt(),Wt(),t=!0,Be(e),Ft(n)}})),Nt=()=>Ct((()=>He({}))),Wt=()=>Ct((()=>lt({}))),Bt=()=>Ct((()=>{We({}),e=!1})),qt=()=>Ct((()=>{Be({}),t=!1})),Ht=(e,t)=>{if(-1==s)return;$t();const n=e();return Gt(t),n},$t=()=>(s++,Kt),Gt=e=>(s>0&&(s--,0==s&&(n=!G(u),l=!G(I),s=1,It(1),n&&bt(1),Rt(1),l&&mt(1),s=-1,(null==e?void 0:e(se(u,(e=>se(e,(e=>se(e,(e=>[...e]),(([e,t])=>e===t))),Ve)),Ve),se(m,(e=>se(e,se))),se(I,(e=>[...e]),(([e,t])=>e===t)),se(C)))&&(s=1,X(u,((e,t)=>X(e,((e,n)=>X(e,(([e],l)=>de(Kt,t,n,l,e))))))),X(I,(([e],t)=>ce(Kt,t,e))),s=-1,n=l=!1),ke(xe[0],void 0,n,l),It(0),n&&bt(0),Rt(0),l&&mt(0),ke(xe[1],void 0,n,l),s=0,T([o,a,d,u,m,w,I,C],U))),Kt),Kt={getTables:Vt,getTableIds:xt,getTable:e=>se(ee(F,y(e)),se),getRowIds:Et,getSortedRowIds:Pt,getRow:(e,t)=>se(ee(ee(F,y(e)),y(t))),getCellIds:kt,getCell:Jt,getValues:Mt,getValueIds:At,getValue:Dt,hasTables:()=>!G(F),hasTable:e=>$(F,y(e)),hasRow:(e,t)=>$(ee(F,y(e)),y(t)),hasCell:(e,t,n)=>$(ee(ee(F,y(e)),y(t)),y(n)),hasValues:()=>!G(j),hasValue:e=>$(j,y(e)),getTablesJson:()=>M(F),getValuesJson:()=>M(j),getJson:()=>M([F,j]),getTablesSchemaJson:()=>M(V),getValuesSchemaJson:()=>M(k),getSchemaJson:()=>M([V,k]),setTables:Ot,setTable:(e,t)=>Ct((e=>De(t,e)?$e(e,t):0),e),setRow:(e,t,n)=>Ct(((e,t)=>Oe(e,t,n)?Ge(e,rt(e),t,n):0),e,t),addRow:(e,t,n=!0)=>Ht((()=>{let l;return Oe(e,l,t)&&(e=y(e),Ge(e,rt(e),l=ot(e,n?1:0),t)),l})),setPartialRow:(e,t,n)=>Ct(((e,t)=>{if(Oe(e,t,n,1)){const l=rt(e);Ce(n,((n,s)=>tt(e,l,t,s,n)))}}),e,t),setCell:(e,t,n,l)=>Ct(((e,t,n)=>z(Fe(e,t,n,W(l)?l(Jt(e,t,n)):l),(l=>tt(e,rt(e),t,n,l)))),e,t,n),setValues:Ft,setPartialValues:e=>Ct((()=>je(e,1)?Ce(e,((e,t)=>st(t,e))):0)),setValue:(e,t)=>Ct((e=>z(Qe(e,W(t)?t(Dt(e)):t),(t=>st(e,t)))),e),setTablesJson:jt,setValuesJson:e=>{try{nt(A(e))}catch(e){}return Kt},setJson:e=>{try{const[t,n]=A(e);qe(t),nt(n)}catch(t){jt(e)}return Kt},setTablesSchema:Qt,setValuesSchema:zt,setSchema:(e,t)=>Ct((()=>{Qt(e),zt(t)})),delTables:Nt,delTable:e=>Ct((e=>$(F,e)?at(e):0),e),delRow:(e,t)=>Ct(((e,t)=>z(ee(F,e),(n=>$(n,t)?it(e,n,t):0))),e,t),delCell:(e,t,n,l)=>Ct(((e,t,n)=>z(ee(F,e),(s=>z(ee(s,t),(o=>$(o,n)?dt(e,s,t,o,n,l):0))))),e,t,n),delValues:Wt,delValue:e=>Ct((e=>$(j,e)?ct(e):0),e),delTablesSchema:Bt,delValuesSchema:qt,delSchema:()=>Ct((()=>{Bt(),qt()})),transaction:Ht,startTransaction:$t,finishTransaction:Gt,forEachTable:e=>X(F,((t,n)=>e(n,(e=>X(t,((t,n)=>e(n,(e=>te(t,e))))))))),forEachRow:(e,t)=>X(ee(F,y(e)),((e,n)=>t(n,(t=>te(e,t))))),forEachCell:(e,t,n)=>te(ee(ee(F,y(e)),y(t)),n),forEachValue:e=>te(j,e),addSortedRowIdsListener:(e,t,n,l,s,o,r)=>{let a=Pt(e,t,n,l,s);return Pe((()=>{const r=Pt(e,t,n,l,s);S(r,a)||(a=r,o(Kt,e,t,n,l,s,a))}),ae[r?1:0],[e,t],[xt])},addWillFinishTransactionListener:e=>Pe(e,xe[0]),addDidFinishTransactionListener:e=>Pe(e,xe[1]),callListener:e=>(Me(e),Kt),delListener:e=>(Je(e),Kt),getListenerStats:()=>({}),createStore:_e};return Ce({Tables:[0,B],TableIds:[0,q],[h]:[1,H,[xt]],[f]:[1,K,[xt]],Row:[2,he,[xt,Et]],[p]:[2,fe,[xt,Et]],[g]:[3,ge,[xt,Et,kt],e=>Ke(Jt(...e))],InvalidCell:[3,pe],Values:[0,Se],ValueIds:[0,Ie],Value:[1,Te,[At],e=>Ke(Dt(e[0]))],InvalidValue:[1,we]},(([e,t,n,l],s)=>{Kt[v+s+c]=(...s)=>Pe(s[e],t[s[e+1]?1:0],e>0?E(s,0,e):void 0,n,l)})),Re(Kt)};e.createCheckpoints=xe,e.createCustomPersister=De,e.createFilePersister=(e,n)=>{let l;return De(e,(()=>ze(void 0,null,(function*(){try{return yield t.promises.readFile(n,d)}catch(e){}}))),(e=>ze(void 0,null,(function*(){try{yield t.promises.writeFile(n,e,d)}catch(e){}}))),(e=>{l=t.watch(n,e)}),(()=>{null==l||l.close(),l=void 0}))},e.createIndexes=Pe,e.createLocalPersister=(e,t)=>Qe(e,t,localStorage),e.createMetrics=Me,e.createQueries=$e,e.createRelationships=Ge,e.createRemotePersister=(e,t,n,l)=>{let s,o;return De(e,(()=>Ne(void 0,null,(function*(){const e=yield fetch(t);return o=We(e),e.text()}))),(e=>Ne(void 0,null,(function*(){return yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}))),(e=>{s=setInterval((()=>Ne(void 0,null,(function*(){const n=yield fetch(t,{method:"HEAD"}),l=We(n);Q(o)||Q(l)||l==o||(o=l,e())}))),1e3*l)}),(()=>{z(s,clearInterval),s=void 0}))},e.createSessionPersister=(e,t)=>Qe(e,t,sessionStorage),e.createStore=_e,e.defaultSorter=Ee},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs")):"function"==typeof define&&define.amd?define(["exports","fs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={},e.fs);
|
|
1
|
+
var e,t;e=this,t=function(e,t){"use strict";const n=e=>typeof e,s="",o=n(s),r=n(!0),l=n(0),i=n(n),a="type",d="default",c="utf8",u="Listener",v="Result",h="add",f="Ids",g="Table",p=g+"s",y=g+f,L="Row",w=L+f,S="Sorted"+L+f,R="Cell",I=R+f,T="Value",m=T+"s",b=T+f,C=e=>s+e,V=(e,t)=>e.includes(t),x=(e,t)=>e.every(t),E=(e,t)=>D(e)===D(t)&&x(e,((e,n)=>t[n]===e)),P=(e,t)=>x(e,((n,s)=>0==s||t(e[s-1],n)<=0)),k=(e,t)=>e.sort(t),J=(e,t)=>e.forEach(t),M=(e,t)=>e.map(t),A=e=>F(e,((e,t)=>e+t),0),D=e=>e.length,O=e=>0==D(e),F=(e,t,n)=>e.reduce(t,n),j=(e,t,n)=>e.slice(t,n),Q=(e,...t)=>e.push(...t),z=e=>e.pop(),N=e=>e.shift(),W=e=>JSON.stringify(e,((e,t)=>G(t,Map)?F([...t],((e,[t,n])=>(e[t]=n,e)),{}):t)),B=JSON.parse,q=Math.max,H=Math.min,$=isFinite,G=(e,t)=>e instanceof t,K=e=>null==e,U=(e,t,n)=>K(e)?null==n?void 0:n():t(e),X=e=>e==o||e==r,Y=e=>n(e)==i,Z=e=>Array.isArray(e),_=()=>{},ee=e=>e.size,te=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},ne=e=>K(e)||0==ee(e),se=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},oe=e=>e.clear(),re=(e,t)=>null==e?void 0:e.forEach(t),le=(e,t)=>null==e?void 0:e.delete(t),ie=e=>new Map(e),ae=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},de=(e,t)=>null==e?void 0:e.get(t),ce=(e,t)=>re(e,((e,n)=>t(n,e))),ue=(e,t,n)=>K(n)?(le(e,t),e):null==e?void 0:e.set(t,n),ve=(e,t,n)=>(te(e,t)||ue(e,t,n()),de(e,t)),he=(e,t,n)=>{const s={},o=null!=t?t:e=>e;return re(e,((e,t)=>U(o(e),(e=>(null==n?void 0:n(e))?0:s[t]=e)))),s},fe=(e,t)=>{const n=ie(),s=null!=t?t:e=>e;return re(e,((e,t)=>n.set(t,s(e)))),n},ge=e=>fe(e,fe),pe=(e,t,n,s,o=0)=>U((n?ve:de)(e,t[o],o>D(t)-2?n:ie),(r=>{if(o>D(t)-2)return(null==s?void 0:s(r))&&ue(e,t[o]),r;const l=pe(r,t,n,s,o+1);return ne(r)&&ue(e,t[o]),l})),ye=e=>{const t=n(e);return X(t)||t==l&&$(e)?t:void 0},Le=(e,t,n,s,o)=>K(o)?e.delCell(t,n,s,!0):e.setCell(t,n,s,o),we=(e,t,n)=>K(n)?e.delValue(t):e.setValue(t,n),Se=e=>new Set(Z(e)||K(e)?e:[e]),Re=(e,t)=>null==e?void 0:e.add(t),Ie=(e,t,n)=>{const s=e.hasRow,o=ie(),r=ie(),l=ie(),i=ie(),a=ie(),d=(t,n,...s)=>{const o=ve(a,t,Se);return J(s,(t=>Re(o,t)&&n&&e.callListener(t))),s},c=(t,...n)=>U(de(a,t),(s=>{J(O(n)?se(s):n,(t=>{e.delListener(t),le(s,t)})),ne(s)&&ue(a,t)})),u=(e,n)=>{ue(o,e,n),te(r,e)||(ue(r,e,t()),ue(l,e,ie()),ue(i,e,ie()))},v=e=>{ue(o,e),ue(r,e),ue(l,e),ue(i,e),c(e)};return[()=>e,()=>ae(o),e=>ce(r,e),e=>te(r,e),e=>de(o,e),e=>de(r,e),(e,t)=>ue(r,e,t),u,(t,o,r,a,v)=>{u(t,o);const h=ie(),f=ie(),g=de(l,t),p=de(i,t),y=t=>{const r=n=>e.getCell(o,t,n),l=de(g,t),i=s(o,t)?n(a(r,t)):void 0;if(l===i||Z(l)&&Z(i)&&E(l,i)||ue(h,t,[l,i]),!K(v)){const e=de(p,t),n=s(o,t)?v(r,t):void 0;e!=n&&ue(f,t,n)}},L=e=>{r((()=>{re(h,(([,e],t)=>ue(g,t,e))),re(f,((e,t)=>ue(p,t,e)))}),h,f,g,p,e),oe(h),oe(f)};ce(g,y),e.hasTable(o)&&J(e.getRowIds(o),(e=>{te(g,e)||y(e)})),L(!0),c(t),d(t,0,e.addRowListener(o,null,((e,t,n)=>y(n))),e.addTableListener(o,(()=>L())))},v,()=>ce(a,v),d,c]},Te=(e,t)=>n(e)==o?t=>t(e):null!=e?e:()=>null!=t?t:s,me=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},be=/^\d+$/,Ce=()=>{const e=[];let t=0;return[n=>{var o;return null!=(o=n?N(e):null)?o:s+t++},t=>{be.test(t)&&D(e)<1e3&&Q(e,t)}]},Ve=e=>{let t;const[n,o]=Ce(),r=ie();return[(o,l,i,a=[],d=(()=>[]))=>{null!=t||(t=e());const c=n(1);return ue(r,c,[o,l,i,a,d]),Re(pe(l,null!=i?i:[s],Se),c),c},(e,n,...o)=>J(((e,t=[s])=>{const n=[],o=(e,s)=>s==D(t)?Q(n,e):null===t[s]?re(e,(e=>o(e,s+1))):J([t[s],null],(t=>o(de(e,t),s+1)));return o(e,0),n})(e,n),(e=>re(e,(e=>de(r,e)[0](t,...null!=n?n:[],...o))))),e=>U(de(r,e),(([,t,n])=>(pe(t,null!=n?n:[s],void 0,(t=>(le(t,e),ne(t)?1:0))),ue(r,e),o(e),n))),e=>U(de(r,e),(([e,,n=[],s,o])=>{const r=(...l)=>{var i,a;const d=D(l);d==D(n)?e(t,...l,...o(l)):K(n[d])?J(null!=(a=null==(i=s[d])?void 0:i.call(s,...l))?a:[],(e=>r(...l,e))):r(...l,n[d])};r()}))]},xe=Object,Ee=xe.keys,Pe=xe.isFrozen,ke=xe.freeze,Je=e=>G(e,xe)&&e.constructor==xe,Me=(e,t)=>!K(((e,t)=>U(e,(e=>e[t])))(e,t)),Ae=(e,t)=>delete e[t],De=(e,t)=>M(xe.entries(e),(([e,n])=>t(n,e))),Oe=e=>Je(e)&&O(Ee(e)),Fe=me((e=>{let t,n,o,r=100,l=ie(),i=ie(),a=1;const d=ie(),c=ie(),[u,v,h]=Ve((()=>F)),f=ie(),g=ie(),p=[],y=[],L=(t,n)=>{a=0,e.transaction((()=>{const[s,o]=de(f,n);re(s,((n,s)=>re(n,((n,o)=>re(n,((n,r)=>Le(e,s,o,r,n[t]))))))),re(o,((n,s)=>we(e,s,n[t])))})),a=1},w=e=>{ue(f,e),ue(g,e),v(c,[e])},S=(e,t)=>J(((e,t)=>e.splice(0,t))(e,null!=t?t:D(e)),w),R=()=>S(p,D(p)-r),I=()=>U(t,(()=>{Q(p,t),R(),S(y),t=void 0,o=1})),T=()=>{t=z(p),o=1},m=e.addCellListener(null,null,null,((e,t,n,s,o,r)=>{if(a){I();const e=ve(l,t,ie),i=ve(e,n,ie),a=ve(i,s,(()=>[r,void 0]));a[1]=o,a[0]===o&&ne(ue(i,s))&&ne(ue(e,n))&&ne(ue(l,t))&&T(),P()}})),b=e.addValueListener(null,((e,t,n,s)=>{if(a){I();const e=ve(i,t,(()=>[s,void 0]));e[1]=n,e[0]===n&&ne(ue(i,t))&&T(),P()}})),C=(e="")=>(K(t)&&(t=s+n++,ue(f,t,[l,i]),M(t,e),l=ie(),i=ie(),o=1),t),x=()=>{O(p)||(((e,...t)=>{e.unshift(...t)})(y,C()),L(0,t),t=z(p),o=1)},E=()=>{O(y)||(Q(p,t),t=N(y),L(1,t),o=1)},P=()=>{o&&(v(d),o=0)},k=e=>{const t=C(e);return P(),t},M=(e,t)=>(A(e)&&de(g,e)!==t&&(ue(g,e,t),v(c,[e])),F),A=e=>te(f,e),F={setSize:e=>(r=e,R(),F),addCheckpoint:k,setCheckpoint:M,getStore:()=>e,getCheckpointIds:()=>[[...p],t,[...y]],forEachCheckpoint:e=>ce(g,e),hasCheckpoint:A,getCheckpoint:e=>de(g,e),goBackward:()=>(x(),P(),F),goForward:()=>(E(),P(),F),goTo:e=>{const n=V(p,e)?x:V(y,e)?E:null;for(;!K(n)&&e!=t;)n();return P(),F},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(h(e),F),clear:()=>(S(p),S(y),K(t)||w(t),t=void 0,n=0,k(),F),destroy:()=>{e.delListener(m),e.delListener(b)},getListenerStats:()=>({})};return ke(F.clear())})),je=(e,t)=>e<t?-1:1,Qe=me((e=>{const t=ie(),n=ie(),[o,r,l,i,a,d,c,,u,v,h]=Ie(e,ie,(e=>K(e)?s:Z(e)?M(e,C):C(e))),[f,g,p]=Ve((()=>L)),y=(t,n,s)=>{const o=a(t);re(s,((t,s)=>n(s,(n=>re(t,(t=>n(t,(n=>e.forEachCell(o,t,n)))))))))},L={setIndexDefinition:(e,s,o,r,l,i=je)=>{const a=K(l)?void 0:([e],[t])=>l(e,t);return u(e,s,((s,o,l,u,v,h)=>{let f=0;const p=Se(),y=Se(),L=d(e);if(re(o,(([e,t],n)=>{const s=Se(e),o=Se(t);re(s,(e=>le(o,e)?le(s,e):0)),re(s,(e=>{Re(p,e),U(de(L,e),(t=>{le(t,n),ne(t)&&(ue(L,e),f=1)}))})),re(o,(e=>{Re(p,e),te(L,e)||(ue(L,e,Se()),f=1),Re(de(L,e),n),K(r)||Re(y,e)}))})),s(),ne(v)||(h?ce(L,(e=>Re(y,e))):ce(l,(e=>U(de(u,e),(e=>Re(y,e))))),re(y,(e=>{const t=(t,n)=>i(de(v,t),de(v,n),e),n=[...de(L,e)];P(n,t)||(ue(L,e,Se(k(n,t))),Re(p,e))}))),(f||h)&&!K(a)){const t=[...L];P(t,a)||(c(e,ie(k(t,a))),f=1)}f&&g(t,[e]),re(p,(t=>g(n,[e,t])))}),Te(o),U(r,Te)),L},delIndexDefinition:e=>(v(e),L),getStore:o,getIndexIds:r,forEachIndex:e=>l(((t,n)=>e(t,(e=>y(t,e,n))))),forEachSlice:(e,t)=>y(e,t,d(e)),hasIndex:i,hasSlice:(e,t)=>te(d(e),t),getTableId:a,getSliceIds:e=>ae(d(e)),getSliceRowIds:(e,t)=>se(de(d(e),t)),addSliceIdsListener:(e,n)=>f(n,t,[e]),addSliceRowIdsListener:(e,t,s)=>f(s,n,[e,t]),delListener:e=>(p(e),L),destroy:h,getListenerStats:()=>({})};return ke(L)})),ze=ie([["avg",[(e,t)=>A(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=>q(...e),(e,t)=>q(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:q(t,e)]],["min",[e=>H(...e),(e,t)=>H(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:H(t,e)]],["sum",[e=>A(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Ne=(e,t,n,s,o,r=!1)=>{if(ne(n))return;const[l,i,a,d]=o;return r||(r=K(e)),re(s,(([n,s])=>{r||(e=K(n)?null==i?void 0:i(e,s,t++):K(s)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,s,n,t),r||(r=K(e)))})),r?l(se(n),ee(n)):e},We=me((e=>{const t=ie(),[n,o,r,l,i,a,d,,c,u,v]=Ie(e,_,(e=>isNaN(e)||K(e)||!0===e||!1===e||e===s?void 0:1*e)),[h,f,g]=Ve((()=>p)),p={setMetricDefinition:(e,n,s,o,r,l,i)=>{var u;const v=Y(s)?[s,r,l,i]:null!=(u=de(ze,s))?u:de(ze,"sum");return c(e,n,((n,s,o,r,l,i)=>{const c=a(e),u=ee(r);i||(i=K(c)),n();let h=Ne(c,u,r,s,v,i);$(h)||(h=void 0),h!=c&&(d(e,h),f(t,[e],h,c))}),Te(o,1)),p},delMetricDefinition:e=>(u(e),p),getStore:n,getMetricIds:o,forEachMetric:r,hasMetric:l,getTableId:i,getMetric:a,addMetricListener:(e,n)=>h(n,t,[e]),delListener:e=>(g(e),p),destroy:v,getListenerStats:()=>({})};return ke(p)}));var Be=(e,t,n)=>new Promise(((s,o)=>{var r=e=>{try{i(n.next(e))}catch(e){o(e)}},l=e=>{try{i(n.throw(e))}catch(e){o(e)}},i=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,l);i((n=n.apply(e,t)).next())}));const qe=(e,t,n,o,r)=>{let l,i,a=0;const d={load:(n,o)=>Be(void 0,null,(function*(){if(2!=a){a=1;const r=yield t();K(r)||r==s?e.transaction((()=>e.setTables(n).setValues(o))):e.setJson(r),a=0}return d})),startAutoLoad:(e,t)=>Be(void 0,null,(function*(){return d.stopAutoLoad(),yield d.load(e,t),o(d.load),d})),stopAutoLoad:()=>(r(),d),save:()=>Be(void 0,null,(function*(){return 1!=a&&(a=2,yield n(e.getJson()),a=0),d})),startAutoSave:()=>Be(void 0,null,(function*(){return yield d.stopAutoSave().save(),l=e.addTablesListener(d.save),i=e.addValuesListener(d.save),d})),stopAutoSave:()=>(U(l,e.delListener),U(i,e.delListener),d),getStore:()=>e,destroy:()=>d.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return ke(d)};var He=(e,t,n)=>new Promise(((s,o)=>{var r=e=>{try{i(n.next(e))}catch(e){o(e)}},l=e=>{try{i(n.throw(e))}catch(e){o(e)}},i=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,l);i((n=n.apply(e,t)).next())}));const $e="storage",Ge=globalThis.window,Ke=(e,t,n)=>{let s;return qe(e,(()=>He(void 0,null,(function*(){return n.getItem(t)}))),(e=>He(void 0,null,(function*(){return n.setItem(t,e)}))),(e=>{s=s=>{s.storageArea===n&&s.key===t&&e()},Ge.addEventListener($e,s)}),(()=>{Ge.removeEventListener($e,s),s=void 0}))};var Ue=(e,t,n)=>new Promise(((s,o)=>{var r=e=>{try{i(n.next(e))}catch(e){o(e)}},l=e=>{try{i(n.throw(e))}catch(e){o(e)}},i=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,l);i((n=n.apply(e,t)).next())})),Xe=(e,t,n)=>new Promise(((s,o)=>{var r=e=>{try{i(n.next(e))}catch(e){o(e)}},l=e=>{try{i(n.throw(e))}catch(e){o(e)}},i=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,l);i((n=n.apply(e,t)).next())}));const Ye=e=>e.headers.get("ETag");var Ze=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;const tt=me((e=>{const t=e.createStore,[n,o,r,l,i,,,a,,d,c,f,p]=Ie(e,(()=>!0),_),y=t(),T=t(),m=ie(),b=(e,t,...n)=>J(n,(n=>Re(ve(ve(m,t,ie),e,Se),n))),C=e=>{U(de(m,e),(e=>{ce(e,((e,t)=>re(t,(t=>e.delListener(t))))),oe(e)})),J([T,y],(t=>t.delTable(e)))},V=(e,t,n)=>b(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),E={setQueryDefinition:(t,n,o)=>{a(t,n),C(t);const r=[],l=[[null,[n,null,null,[],ie()]]],i=[],d=[],c=[];o({select:(e,t)=>{const n=Y(e)?[D(r)+s,e]:[K(t)?e:t,n=>n(e,t)];return Q(r,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const s=K(n)||Y(t)?null:t,o=K(s)?t:n,r=[e,[e,s,Y(o)?o:e=>e(o),[],ie()]];return Q(l,r),{as:e=>r[0]=e}},where:(e,t,n)=>Q(i,Y(e)?e:K(n)?n=>n(e)===t:s=>s(e,t)===n),group:(e,t,n,s,o)=>{var r;const l=[e,[e,Y(t)?[t,n,s,o]:null!=(r=de(ze,t))?r:[(e,t)=>t]]];return Q(d,l),{as:e=>l[0]=e}},having:(e,t)=>Q(c,Y(e)?e:n=>n(e)===t)});const u=ie(r);if(ne(u))return E;const v=ie(l);ce(v,((e,[,t])=>U(de(v,t),(({3:t})=>K(e)?0:Q(t,e)))));const h=ie(d);let g=y;if(ne(h)&&O(c))g=T;else{V(t,g,T);const e=ie();ce(h,((t,[n,s])=>Re(ve(e,n,Se),[t,s])));const n=Se();ce(u,(t=>te(e,t)?0:Re(n,t)));const s=ie(),o=(n,s,o,r)=>U(n,(([l,i,a,d])=>{ce(s,((t,[n])=>{const s=ve(l,t,ie),i=de(s,o),a=r?void 0:n;if(i!==a){const n=Se([[i,a]]),r=ee(s);ue(s,o,a),re(de(e,t),(([e,t])=>{const o=Ne(d[e],r,s,n,t);d[e]=K(ye(o))?null:o}))}})),ne(i)||!x(c,(e=>e((e=>d[e]))))?T.delRow(t,a):K(a)?n[2]=T.addRow(t,d):T.setRow(t,a,d)}));b(g,t,g.addRowListener(t,null,((r,l,i,a)=>{const d=[],c=[],u=ie(),v=g.hasRow(t,i);let h=!v;re(n,(e=>{const[n,s,o]=a(t,i,e);Q(d,s),Q(c,o),h||(h=n)})),ce(e,(e=>{const[n,,s]=a(t,i,e);(h||n)&&ue(u,e,[s])})),h&&o(pe(s,d,void 0,(([,e])=>(le(e,i),ne(e)))),u,i,1),v&&o(pe(s,c,(()=>{const e={};return re(n,(n=>e[n]=g.getCell(t,i,n))),[ie(),Se(),void 0,e]}),(([,e])=>{Re(e,i)})),u,i)})))}V(t,e,g);const L=(s,o,r,l)=>{const a=t=>e.getCell(o,r,t);J(l,(n=>{var o;const[r,,l,i,d]=de(v,n),c=null==l?void 0:l(a,s),[u,h]=null!=(o=de(d,s))?o:[];c!=u&&(K(h)||p(t,h),ue(d,s,K(c)?null:[c,...f(t,1,e.addRowListener(r,c,(()=>L(s,r,c,i))))]))})),(s=>{const o=(t,o)=>{var r,l,i;return e.getCell(...K(o)?[n,s,t]:t===n?[n,s,o]:[null==(r=de(v,t))?void 0:r[0],null==(i=de(null==(l=de(v,t))?void 0:l[4],s))?void 0:i[0],o])};g.transaction((()=>x(i,(e=>e(o)))?ce(u,((e,n)=>Le(g,t,s,e,n(o,s)))):g.delRow(t,s)))})(s)},{3:w}=de(v,null);return g.transaction((()=>f(t,1,e.addRowListener(n,null,((s,o,r)=>{e.hasRow(n,r)?L(r,n,r,w):(g.delRow(t,r),re(v,(({4:e})=>U(de(e,r),(([,n])=>{p(t,n),ue(e,r)})))))}))))),E},delQueryDefinition:e=>(C(e),d(e),E),getStore:n,getQueryIds:o,forEachQuery:r,hasQuery:l,getTableId:i,delListener:e=>(T.delListener(e),E),destroy:c,getListenerStats:()=>((e,t)=>{var n={};for(var s in e)_e.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&Ze)for(var s of Ze(e))t.indexOf(s)<0&&et.call(e,s)&&(n[s]=e[s]);return n})(T.getListenerStats(),["tables","tableIds","transaction"])};return De({[g]:[1,1],[w]:[0,1],[S]:[0,5],[L]:[1,2],[I]:[0,2],[R]:[1,3]},(([e,t],n)=>{J(e?["get","has","forEach"]:["get"],(e=>E[e+v+n]=(...t)=>T[e+n](...t))),E[h+v+n+u]=(...e)=>T[h+n+u](...j(e,0,t),((n,...s)=>e[t](E,...s)))})),ke(E)})),nt=me((e=>{const t=ie(),n=ie(),o=ie(),r=ie(),[l,i,a,d,c,u,,,v,h,f]=Ie(e,(()=>[ie(),ie(),ie(),ie()]),(e=>K(e)?void 0:e+s)),[g,p,y]=Ve((()=>R)),L=(e,t,n)=>U(u(e),(([s,,o])=>{if(!te(o,t)){const r=Se();if(c(e)!=S(e))Re(r,t);else{let e=t;for(;!K(e)&&!te(r,e);)Re(r,e),e=de(s,e)}if(n)return r;ue(o,t,r)}return de(o,t)})),w=(e,t)=>U(u(e),(([,,e])=>ue(e,t))),S=e=>de(t,e),R={setRelationshipDefinition:(e,s,l,i)=>(ue(t,e,l),v(e,s,((t,s)=>{const l=Se(),i=Se(),a=Se(),[d,c]=u(e);re(s,(([t,n],s)=>{K(t)||(Re(i,t),U(de(c,t),(e=>{le(e,s),ne(e)&&ue(c,t)}))),K(n)||(Re(i,n),te(c,n)||ue(c,n,Se()),Re(de(c,n),s)),Re(l,s),ue(d,s,n),ce(de(r,e),(t=>{te(L(e,t),s)&&Re(a,t)}))})),t(),re(l,(t=>p(n,[e,t]))),re(i,(t=>p(o,[e,t]))),re(a,(t=>{w(e,t),p(r,[e,t])}))}),Te(i)),R),delRelationshipDefinition:e=>(ue(t,e),h(e),R),getStore:l,getRelationshipIds:i,forEachRelationship:t=>a((n=>t(n,(t=>e.forEachRow(c(n),t))))),hasRelationship:d,getLocalTableId:c,getRemoteTableId:S,getRemoteRowId:(e,t)=>{var n;return de(null==(n=u(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return se(de(null==(n=u(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>K(u(e))?[t]:se(L(e,t,!0)),addRemoteRowIdListener:(e,t,s)=>g(s,n,[e,t]),addLocalRowIdsListener:(e,t,n)=>g(n,o,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(L(e,t),g(n,r,[e,t])),delListener:e=>(w(...y(e)),R),destroy:f,getListenerStats:()=>({})};return ke(R)})),st=e=>[e,e],ot=()=>[ie(),ie()],rt=(e,t,n,s=ue)=>(De(t,((t,s)=>n(e,s,t))),ce(e,(n=>Me(t,n)?0:s(e,n))),e),lt=(e,t,n)=>K(e)||!Je(e)||Oe(e)||Pe(e)?(null==n||n(),!1):(De(e,((n,s)=>{t(n,s)||Ae(e,s)})),!Oe(e)),it=(e,t,n)=>ue(e,t,de(e,t)==-n?void 0:n),at=()=>{let e,t,n,s,o=0;const r=ie(),i=ie(),c=ie(),v=ie(),f=ie(),S=ie(),x=ie(),P=ie(),A=ie(),D=ie(),O=ie(),F=ie(),z=Se(),N=ie(),q=ie(),H=ie(),$=ot(),G=ot(),Z=ot(),_=ot(),ee=ot(),se=ot(),pe=ot(),Ie=ot(),Te=ot(),me=ot(),be=ot(),xe=ot(),Ee=ot(),Pe=ot(),[Je,Fe,Qe,ze]=Ve((()=>tn)),Ne=e=>{if(!lt(e,((e,t)=>V([a,d],t))))return!1;const t=e[a];return!(!X(t)&&t!=l||(ye(e[d])!=t&&Ae(e,d),0))},We=(t,n)=>(!e||te(A,n)||mt(n))&<(t,((e,t)=>Be(n,t,e)),(()=>mt(n))),Be=(e,t,n,s)=>lt(s?n:Ge(n,e,t),((s,o)=>U(qe(e,t,o,s),(e=>(n[o]=e,!0)),(()=>!1))),(()=>mt(e,t))),qe=(t,n,s,o)=>e?U(de(de(A,t),s),(e=>ye(o)!=e[a]?mt(t,n,s,o,e[d]):o),(()=>mt(t,n,s,o))):K(ye(o))?mt(t,n,s,o):o,He=(e,t)=>lt(t?e:Ke(e),((t,n)=>U($e(n,t),(t=>(e[n]=t,!0)),(()=>!1))),(()=>bt())),$e=(e,n)=>t?U(de(O,e),(t=>ye(n)!=t[a]?bt(e,n,t[d]):n),(()=>bt(e,n))):K(ye(n))?bt(e,n):n,Ge=(e,t,n)=>(U(de(D,t),(([s,o])=>{re(s,((t,n)=>{Me(e,n)||(e[n]=t)})),re(o,(s=>{Me(e,s)||mt(t,n,s)}))})),e),Ke=e=>(t&&(re(F,((t,n)=>{Me(e,n)||(e[n]=t)})),re(z,(t=>{Me(e,t)||bt(t)}))),e),Ue=e=>rt(A,e,((e,t,n)=>{const s=ie(),o=Se();rt(ve(A,t,ie),n,((e,t,n)=>{ue(e,t,n),U(n[d],(e=>ue(s,t,e)),(()=>Re(o,t)))})),ue(D,t,[s,o])}),((e,t)=>{ue(A,t),ue(D,t)})),Xe=e=>rt(O,e,((e,t,n)=>{ue(O,t,n),U(n[d],(e=>ue(F,t,e)),(()=>Re(z,t)))}),((e,t)=>{ue(O,t),ue(F,t),le(z,t)})),Ye=e=>Oe(e)?Kt():Bt(e),Ze=e=>rt(q,e,((e,t,n)=>_e(t,n)),((e,t)=>ft(t))),_e=(e,t)=>rt(ve(q,e,(()=>(Lt(e,1),ie()))),t,((t,n,s)=>et(e,t,n,s)),((t,n)=>gt(e,t,n))),et=(e,t,n,s,o)=>rt(ve(t,n,(()=>(wt(e,n,1),ie()))),s,((t,s,o)=>tt(e,n,t,s,o)),((s,r)=>pt(e,t,n,s,r,o))),tt=(e,t,n,s,o)=>{te(n,s)||St(e,t,s,1);const r=de(n,s);o!==r&&(Rt(e,t,s,r,o),ue(n,s,o))},nt=(e,t,n,s,o)=>U(de(t,n),(t=>tt(e,n,t,s,o)),(()=>et(e,t,n,Ge({[s]:o},e,n)))),dt=e=>Oe(e)?Ut():qt(e),ct=e=>rt(H,e,((e,t,n)=>ut(t,n)),((e,t)=>yt(t))),ut=(e,t)=>{te(H,e)||It(e,1);const n=de(H,e);t!==n&&(Tt(e,n,t),ue(H,e,t))},vt=(e,t)=>{const[n]=ve(N,e,Ce),s=n(t);return te(de(q,e),s)?vt(e,t):s},ht=e=>{var t;return null!=(t=de(q,e))?t:_e(e,{})},ft=e=>_e(e,{}),gt=(e,t,n)=>{const[,s]=ve(N,e,Ce);s(n),et(e,t,n,{},!0)},pt=(e,t,n,s,o,r)=>{var l;const i=de(null==(l=de(D,e))?void 0:l[0],o);if(!K(i)&&!r)return tt(e,n,s,o,i);const a=t=>{Rt(e,n,t,de(s,t)),St(e,n,t,-1),ue(s,t)};K(i)?a(o):ce(s,a),ne(s)&&(wt(e,n,-1),ne(ue(t,n))&&(Lt(e,-1),ue(q,e),ue(N,e)))},yt=e=>{const t=de(F,e);if(!K(t))return ut(e,t);Tt(e,de(H,e)),It(e,-1),ue(H,e)},Lt=(e,t)=>it(r,e,t),wt=(e,t,n)=>it(ve(i,e,ie),t,n),St=(e,t,n,s)=>it(ve(ve(c,e,ie),t,ie),n,s),Rt=(e,t,n,s,o)=>ve(ve(ve(v,e,ie),t,ie),n,(()=>[s,0]))[1]=o,It=(e,t)=>it(f,e,t),Tt=(e,t,n)=>ve(S,e,(()=>[t,0]))[1]=n,mt=(e,t,n,s,o)=>(Q(ve(ve(ve(x,e,ie),t,ie),n,(()=>[])),s),o),bt=(e,t,n)=>(Q(ve(P,e,(()=>[])),t),n),Ct=(e,t,n)=>U(de(de(de(v,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...st(Qt(e,t,n))])),Vt=e=>U(de(S,e),(([e,t])=>[!0,e,t]),(()=>[!1,...st(Wt(e))])),xt=e=>ne(x)||ne(Te[e])?0:re(e?fe(x,ge):x,((t,n)=>re(t,((t,s)=>re(t,((t,o)=>Fe(Te[e],[n,s,o],t))))))),Et=e=>ne(P)||ne(me[e])?0:re(e?fe(P):P,((t,n)=>Fe(me[e],[n],t))),Pt=(e,t,n)=>{if(!ne(t))return Fe(e,n),1},kt=e=>{const t=ne(ee[e]),n=ne(pe[e])&&ne(_[e])&&t&&ne(G[e]),s=ne(Ie[e])&&ne(se[e])&&ne(Z[e])&&ne($[e]);if(!n||!s){const o=e?[fe(r),ge(i),fe(c,ge),fe(v,ge)]:[r,i,c,v];if(!n){re(o[2],((t,n)=>re(t,((t,s)=>Pt(pe[e],t,[n,s])))));const n=Se();re(o[1],((s,o)=>{Pt(_[e],s,[o])&&!t&&(Fe(ee[e],[o,null]),Re(n,o))})),t||re(o[3],((t,s)=>{if(!te(n,s)){const n=Se();re(t,(e=>re(e,(([t,s],o)=>s!==t?Re(n,o):le(e,o))))),re(n,(t=>Fe(ee[e],[s,t])))}})),Pt(G[e],o[0])}if(!s){let t;re(o[3],((n,s)=>{let o;re(n,((n,r)=>{let l;re(n,(([n,i],a)=>{i!==n&&(Fe(Ie[e],[s,r,a],i,n,Ct),t=o=l=1)})),l&&Fe(se[e],[s,r],Ct)})),o&&Fe(Z[e],[s],Ct)})),t&&Fe($[e],void 0,Ct)}}},Jt=e=>{const t=ne(xe[e]),n=ne(Ee[e])&&ne(be[e]);if(!t||!n){const s=e?[fe(f),fe(S)]:[f,S];if(t||Pt(xe[e],s[0]),!n){let t;re(s[1],(([n,s],o)=>{s!==n&&(Fe(Ee[e],[o],s,n,Vt),t=1)})),t&&Fe(be[e],void 0,Vt)}}},Mt=(e,...t)=>(Zt((()=>e(...M(t,C)))),tn),At=()=>he(q,(e=>he(e,he))),Dt=()=>ae(q),Ot=e=>ae(de(q,C(e))),Ft=(e,t,n,s=0,o)=>{return M(j(k((r=de(q,C(e)),l=(e,n)=>[K(t)?n:de(e,C(t)),n],M([...null!=(i=null==r?void 0:r.entries())?i:[]],(([e,t])=>l(t,e)))),(([e],[t])=>je(e,t)*(n?-1:1))),s,K(o)?o:s+o),(([,e])=>e));var r,l,i},jt=(e,t)=>ae(de(de(q,C(e)),C(t))),Qt=(e,t,n)=>de(de(de(q,C(e)),C(t)),C(n)),zt=()=>he(H),Nt=()=>ae(H),Wt=e=>de(H,C(e)),Bt=e=>Mt((()=>(e=>lt(e,We,mt))(e)?Ze(e):0)),qt=e=>Mt((()=>He(e)?ct(e):0)),Ht=e=>{try{Ye(B(e))}catch(e){}return tn},$t=t=>Mt((()=>{if((e=lt(t,(e=>lt(e,Ne))))&&(Ue(t),!ne(q))){const e=At();Kt(),Bt(e)}})),Gt=e=>Mt((()=>{if(t=(e=>lt(e,Ne))(e)){const n=zt();Yt(),Ut(),t=!0,Xe(e),qt(n)}})),Kt=()=>Mt((()=>Ze({}))),Ut=()=>Mt((()=>ct({}))),Xt=()=>Mt((()=>{Ue({}),e=!1})),Yt=()=>Mt((()=>{Xe({}),t=!1})),Zt=(e,t)=>{if(-1==o)return;_t();const n=e();return en(t),n},_t=()=>(o++,tn),en=e=>(o>0&&(o--,0==o&&(n=!ne(v),s=!ne(S),o=1,xt(1),n&&kt(1),Et(1),s&&Jt(1),o=-1,(null==e?void 0:e(he(v,(e=>he(e,(e=>he(e,(e=>[...e]),(([e,t])=>e===t))),Oe)),Oe),he(x,(e=>he(e,he))),he(S,(e=>[...e]),(([e,t])=>e===t)),he(P)))&&(o=1,re(v,((e,t)=>re(e,((e,n)=>re(e,(([e],s)=>Le(tn,t,n,s,e))))))),re(S,(([e],t)=>we(tn,t,e))),o=-1,n=s=!1),Fe(Pe[0],void 0,n,s),xt(0),n&&kt(0),Et(0),s&&Jt(0),Fe(Pe[1],void 0,n,s),o=0,J([r,i,c,v,x,f,S,P],oe))),tn),tn={getTables:At,getTableIds:Dt,getTable:e=>he(de(q,C(e)),he),getRowIds:Ot,getSortedRowIds:Ft,getRow:(e,t)=>he(de(de(q,C(e)),C(t))),getCellIds:jt,getCell:Qt,getValues:zt,getValueIds:Nt,getValue:Wt,hasTables:()=>!ne(q),hasTable:e=>te(q,C(e)),hasRow:(e,t)=>te(de(q,C(e)),C(t)),hasCell:(e,t,n)=>te(de(de(q,C(e)),C(t)),C(n)),hasValues:()=>!ne(H),hasValue:e=>te(H,C(e)),getTablesJson:()=>W(q),getValuesJson:()=>W(H),getJson:()=>W([q,H]),getTablesSchemaJson:()=>W(A),getValuesSchemaJson:()=>W(O),getSchemaJson:()=>W([A,O]),setTables:Bt,setTable:(e,t)=>Mt((e=>We(t,e)?_e(e,t):0),e),setRow:(e,t,n)=>Mt(((e,t)=>Be(e,t,n)?et(e,ht(e),t,n):0),e,t),addRow:(e,t,n=!0)=>Zt((()=>{let s;return Be(e,s,t)&&(e=C(e),et(e,ht(e),s=vt(e,n?1:0),t)),s})),setPartialRow:(e,t,n)=>Mt(((e,t)=>{if(Be(e,t,n,1)){const s=ht(e);De(n,((n,o)=>nt(e,s,t,o,n)))}}),e,t),setCell:(e,t,n,s)=>Mt(((e,t,n)=>U(qe(e,t,n,Y(s)?s(Qt(e,t,n)):s),(s=>nt(e,ht(e),t,n,s)))),e,t,n),setValues:qt,setPartialValues:e=>Mt((()=>He(e,1)?De(e,((e,t)=>ut(t,e))):0)),setValue:(e,t)=>Mt((e=>U($e(e,Y(t)?t(Wt(e)):t),(t=>ut(e,t)))),e),setTablesJson:Ht,setValuesJson:e=>{try{dt(B(e))}catch(e){}return tn},setJson:e=>{try{const[t,n]=B(e);Ye(t),dt(n)}catch(t){Ht(e)}return tn},setTablesSchema:$t,setValuesSchema:Gt,setSchema:(e,t)=>Mt((()=>{$t(e),Gt(t)})),delTables:Kt,delTable:e=>Mt((e=>te(q,e)?ft(e):0),e),delRow:(e,t)=>Mt(((e,t)=>U(de(q,e),(n=>te(n,t)?gt(e,n,t):0))),e,t),delCell:(e,t,n,s)=>Mt(((e,t,n)=>U(de(q,e),(o=>U(de(o,t),(r=>te(r,n)?pt(e,o,t,r,n,s):0))))),e,t,n),delValues:Ut,delValue:e=>Mt((e=>te(H,e)?yt(e):0),e),delTablesSchema:Xt,delValuesSchema:Yt,delSchema:()=>Mt((()=>{Xt(),Yt()})),transaction:Zt,startTransaction:_t,finishTransaction:en,forEachTable:e=>re(q,((t,n)=>e(n,(e=>re(t,((t,n)=>e(n,(e=>ce(t,e))))))))),forEachRow:(e,t)=>re(de(q,C(e)),((e,n)=>t(n,(t=>ce(e,t))))),forEachCell:(e,t,n)=>ce(de(de(q,C(e)),C(t)),n),forEachValue:e=>ce(H,e),addSortedRowIdsListener:(e,t,n,s,o,r,l)=>{let i=Ft(e,t,n,s,o);return Je((()=>{const l=Ft(e,t,n,s,o);E(l,i)||(i=l,r(tn,e,t,n,s,o,i))}),ee[l?1:0],[e,t],[Dt])},addWillFinishTransactionListener:e=>Je(e,Pe[0]),addDidFinishTransactionListener:e=>Je(e,Pe[1]),callListener:e=>(ze(e),tn),delListener:e=>(Qe(e),tn),getListenerStats:()=>({}),createStore:at};return De({[p]:[0,$],[y]:[0,G],[g]:[1,Z,[Dt]],[w]:[1,_,[Dt]],[L]:[2,se,[Dt,Ot]],[I]:[2,pe,[Dt,Ot]],[R]:[3,Ie,[Dt,Ot,jt],e=>st(Qt(...e))],InvalidCell:[3,Te],[m]:[0,be],[b]:[0,xe],[T]:[1,Ee,[Nt],e=>st(Wt(e[0]))],InvalidValue:[1,me]},(([e,t,n,s],o)=>{tn[h+o+u]=(...o)=>Je(o[e],t[o[e+1]?1:0],e>0?j(o,0,e):void 0,n,s)})),ke(tn)};e.createCheckpoints=Fe,e.createCustomPersister=qe,e.createFilePersister=(e,n)=>{let s;return qe(e,(()=>Ue(void 0,null,(function*(){try{return yield t.promises.readFile(n,c)}catch(e){}}))),(e=>Ue(void 0,null,(function*(){try{yield t.promises.writeFile(n,e,c)}catch(e){}}))),(e=>{s=t.watch(n,e)}),(()=>{null==s||s.close(),s=void 0}))},e.createIndexes=Qe,e.createLocalPersister=(e,t)=>Ke(e,t,localStorage),e.createMetrics=We,e.createQueries=tt,e.createRelationships=nt,e.createRemotePersister=(e,t,n,s)=>{let o,r;return qe(e,(()=>Xe(void 0,null,(function*(){const e=yield fetch(t);return r=Ye(e),e.text()}))),(e=>Xe(void 0,null,(function*(){return yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}))),(e=>{o=setInterval((()=>Xe(void 0,null,(function*(){const n=yield fetch(t,{method:"HEAD"}),s=Ye(n);K(r)||K(s)||s==r||(r=s,e())}))),1e3*s)}),(()=>{U(o,clearInterval),o=void 0}))},e.createSessionPersister=(e,t)=>Ke(e,t,sessionStorage),e.createStore=at,e.defaultSorter=je},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs")):"function"==typeof define&&define.amd?define(["exports","fs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBase={},e.fs);
|
|
Binary file
|
package/lib/umd-es6/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",l=t(o),r="Ids",u="Table",n="Tables",d=u+r,i="Row",a=i+r,c="SortedRowIds",I="Cell",w=I+r,p="Value",b="Values",R=p+r,C=(e,s)=>e.map(s),k=e=>null==e,v=(e,s,t)=>k(e)?null==t?void 0:t():s(e),g=e=>t(e)==l,m=()=>{},{createContext:y,useContext:h}=s,f=y([]),V=(e,s)=>{const t=h(f);return k(e)?t[s]:g(e)?((e,s)=>v(e,(e=>e[s])))(t[s+1],e):e},L=(e,s)=>{const t=V(e,s);return k(e)||g(e)?t:e},S=e=>L(e,0),T=e=>L(e,2),P=e=>L(e,4),x=e=>L(e,6),q=e=>L(e,8),O=e=>L(e,10),{useCallback:B,useEffect:M,useMemo:j,useRef:D,useState:A}=s,E=(e,s,t=[])=>{const o=j((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},F=(e,s,t,o=[],l)=>{const[,r]=A(),u=B((()=>{var l,r;return null!=(r=null==(l=null==s?void 0:s["get"+e])?void 0:l.call(s,...o))?r:t}),[s,...o]),[n]=A(u),d=D(n);return j((()=>d.current=u()),[u]),G(e,s,((...e)=>{d.current=k(l)?u():e[l],r([])}),[],o),d.current},G=(e,s,t,o=[],l=[],...r)=>M((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...l,t,...r);return()=>null==s?void 0:s.delListener(u)}),[s,...l,...o,...r]),Q=(e,s,t,o=[],l=m,r=[],...u)=>{const n=S(e);return B((e=>v(n,(o=>v(t(e,o),(e=>l(o["set"+s](...u,e),e)))))),[n,s,...o,...r,...u])},U=(e,s,t=m,o=[],...l)=>{const r=S(e);return B((()=>t(null==r?void 0:r["del"+s](...l))),[r,s,...o,...l])},z=(e,s,t)=>{const o=O(e);return B((()=>null==o?void 0:o[s](t)),[o,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(a,S(s),[],[e]),K=(e,s,t,o=0,l,r)=>F(c,S(r),[],[e,s,t,o,l],6),N=(e,s,t)=>F(w,S(t),[],[e,s]),W=(e,s,t,o)=>F(I,S(o),void 0,[e,s,t],4),X=e=>F(R,S(e),[],[]),Y=(e,s)=>F(p,S(s),void 0,[e]),Z=(e,s)=>F("Metric",T(s),void 0,[e]),$=(e,s)=>F("SliceIds",P(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",P(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",x(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",x(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",x(t),[],[e,s]),oe=(e,s)=>F("ResultRowIds",q(s),[],[e]),le=(e,s,t,o=0,l,r)=>F("ResultSortedRowIds",q(r),[],[e,s,t,o,l],6),re=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,o)=>F("ResultCell",q(o),void 0,[e,s,t]),ne=e=>F("CheckpointIds",O(e),[[],void 0,[]]),de=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var ce=Object.defineProperty,Ie=Object.defineProperties,we=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,Ce=(e,s,t)=>s in e?ce(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ke=(e,s)=>{for(var t in s||(s={}))be.call(s,t)&&Ce(e,t,s[t]);if(pe)for(var t of pe(s))Re.call(s,t)&&Ce(e,t,s[t]);return e},ve=(e,s)=>Ie(e,we(s)),ge=(e,s)=>{var t={};for(var o in e)be.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&pe)for(var o of pe(e))s.indexOf(o)<0&&Re.call(e,o)&&(t[o]=e[o]);return t};const{createElement:me,useMemo:ye}=s,he=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,tableId:e,rowId:l,store:s,debugIds:r})))),l,r,e),fe=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,queryId:e,rowId:l,queries:s,debugIds:r})))),l,r,e),Ve=e=>{const s=x(e);return[s,null==s?void 0:s.getStore()]},Le=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u,n)=>{const[d,i]=Ve(s),a=null==d?void 0:d.getLocalTableId(e),c=u(e,n,d);return Pe(C(c,(e=>me(t,ve(ke({},Te(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),l,r,n)},Se=e=>({checkpoints:s,checkpointComponent:t=Ae,getCheckpointComponentProps:o,separator:l,debugIds:r})=>{const u=O(s);return Pe(C(e(ne(u)),(e=>me(t,ve(ke({},Te(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),l)},Te=(e,s)=>k(e)?{}:e(s),Pe=(e,s,t,o)=>{const l=k(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",l,"}"]:l},xe=({tableId:e,rowId:s,cellId:t,store:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=W(e,s,t,l))?u:o),void 0,r,t)},qe=({tableId:e,rowId:s,store:t,cellComponent:o=xe,getCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(N(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:u})))),r,u,s),Oe=e=>he(e,J(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>{var l;return Pe(o+(null!=(l=Y(e,s))?l:o),void 0,t,e)},Me=({indexId:e,sliceId:s,indexes:t,rowComponent:o=qe,getRowComponentProps:l,separator:r,debugIds:u})=>{const n=P(t),d=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),a=_(e,s,n);return Pe(C(a,(e=>me(o,ve(ke({},Te(l,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},je=({queryId:e,rowId:s,cellId:t,queries:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=ue(e,s,t,l))?u:o),void 0,r,t)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=je,getResultCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(re(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ae=({checkpoints:e,checkpointId:s,debugIds:t})=>{var l;return Pe(null!=(l=de(s,e))?l:o,void 0,t,s)},Ee=Se((e=>e[0])),Fe=Se((e=>k(e[1])?[]:[e[1]])),Ge=Se((e=>e[2]));e.BackwardCheckpointsView=Ee,e.CellView=xe,e.CheckpointView=Ae,e.CurrentCheckpointView=Fe,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:o,separator:l,debugIds:r})=>Pe(C($(e,s),(l=>me(t,ve(ke({},Te(o,l)),{key:l,indexId:e,sliceId:l,indexes:s,debugIds:r})))),l,r,e),e.LinkedRowsView=e=>Le(e,te,e.firstRowId),e.LocalRowsView=e=>Le(e,se,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var l;return Pe(null!=(l=Z(e,s))?l:o,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:o,metricsById:l,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(f);return me(f.Provider,{value:ye((()=>[null!=e?e:p[0],ke(ke({},p[1]),t),null!=o?o:p[2],ke(ke({},p[3]),l),null!=r?r:p[4],ke(ke({},p[5]),u),null!=n?n:p[6],ke(ke({},p[7]),d),null!=i?i:p[8],ke(ke({},p[9]),a),null!=c?c:p[10],ke(ke({},p[11]),I)]),[e,t,o,l,r,u,n,d,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=qe,getRowComponentProps:l,debugIds:r})=>{const[u,n]=Ve(t),d=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return Pe(k(d)||k(i)?null:me(o,ve(ke({},Te(l,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=je,e.ResultRowView=De,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return fe(u,le(u.queryId,t,o,l,r,u.queries))},e.ResultTableView=e=>fe(e,oe(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Me,e.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,o,l,r,u.store))},e.TableView=Oe,e.TablesView=({store:e,tableComponent:s=Oe,getTableComponentProps:t,separator:o,debugIds:l})=>Pe(C(H(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),o),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:o,debugIds:l})=>Pe(C(X(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),o),e.tableView=he,e.useAddRowCallback=(e,s,t=[],o,l=m,r=[],u=!0)=>{const n=S(o);return B((t=>v(n,(o=>v(s(t,o),(s=>l(o.addRow(e,s,u),o,s)))))),[n,e,...t,...r,u])},e.useCell=W,e.useCellIds=N,e.useCellIdsListener=(e,s,t,o,l,r)=>G(w,S(r),t,o,[e,s],l),e.useCellListener=(e,s,t,o,l,r,u)=>G(I,S(u),o,l,[e,s,t],r),e.useCheckpoint=de,e.useCheckpointIds=ne,e.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),e.useCheckpointListener=(e,s,t,o)=>G("Checkpoint",O(o),s,t,[e]),e.useCheckpoints=e=>V(e,10),e.useCreateCheckpoints=(e,s,t)=>E(e,s,t),e.useCreateIndexes=(e,s,t)=>E(e,s,t),e.useCreateMetrics=(e,s,t)=>E(e,s,t),e.useCreatePersister=(e,s,t=[],o,l=[])=>{const[,r]=A(),u=j((()=>s(e)),[e,...t]);return M((()=>{var e;return e=function*(){yield null==o?void 0:o(u),r(1)},new Promise(((s,t)=>{var o=s=>{try{r(e.next(s))}catch(e){t(e)}},l=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,l);r((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...l]),u},e.useCreateQueries=(e,s,t)=>E(e,s,t),e.useCreateRelationships=(e,s,t)=>E(e,s,t),e.useCreateStore=(e,s=[])=>j(e,s),e.useDelCellCallback=(e,s,t,o,l,r,u)=>U(l,I,r,u,e,s,t,o),e.useDelRowCallback=(e,s,t,o,l)=>U(t,i,o,l,e,s),e.useDelTableCallback=(e,s,t,o)=>U(s,u,t,o,e),e.useDelTablesCallback=(e,s,t)=>U(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>U(s,p,t,o,e),e.useDelValuesCallback=(e,s,t)=>U(e,b,s,t),e.useGoBackwardCallback=ie,e.useGoForwardCallback=ae,e.useGoToCallback=(e,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>v(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...l])},e.useIndexes=e=>V(e,4),e.useLinkedRowIds=te,e.useLinkedRowIdsListener=(e,s,t,o,l)=>G("LinkedRowIds",x(l),t,o,[e,s]),e.useLocalRowIds=se,e.useLocalRowIdsListener=(e,s,t,o,l)=>G("LocalRowIds",x(l),t,o,[e,s]),e.useMetric=Z,e.useMetricListener=(e,s,t,o)=>G("Metric",T(o),s,t,[e]),e.useMetrics=e=>V(e,2),e.useQueries=e=>V(e,8),e.useRedoInformation=e=>{var s;const t=O(e),[,,[l]]=ne(t);return[!k(l),ae(t),l,null!=(s=v(l,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o]},e.useRelationships=e=>V(e,6),e.useRemoteRowId=ee,e.useRemoteRowIdListener=(e,s,t,o,l)=>G("RemoteRowId",x(l),t,o,[e,s]),e.useResultCell=ue,e.useResultCellIds=re,e.useResultCellIdsListener=(e,s,t,o,l)=>G("ResultCellIds",q(l),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,l,r)=>G("ResultCell",q(r),o,l,[e,s,t]),e.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),e.useResultRowIds=oe,e.useResultRowIdsListener=(e,s,t,o)=>G("ResultRowIds",q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,l)=>G("ResultRow",q(l),t,o,[e,s]),e.useResultSortedRowIds=le,e.useResultSortedRowIdsListener=(e,s,t,o,l,r,u,n)=>G("ResultSortedRowIds",q(n),r,u,[e,s,t,o,l]),e.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),e.useResultTableListener=(e,s,t,o)=>G("ResultTable",q(o),s,t,[e]),e.useRow=(e,s,t)=>F(i,S(t),{},[e,s]),e.useRowIds=J,e.useRowIdsListener=(e,s,t,o,l)=>G(a,S(l),s,t,[e],o),e.useRowListener=(e,s,t,o,l,r)=>G(i,S(r),t,o,[e,s],l),e.useSetCellCallback=(e,s,t,o,l,r,u,n)=>Q(r,I,o,l,u,n,e,s,t),e.useSetCheckpointCallback=(e=m,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>{const l=e(s);o(t.addCheckpoint(l),t,l)}))),[r,...s,...l])},e.useSetPartialRowCallback=(e,s,t,o,l,r,u)=>Q(l,"PartialRow",t,o,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,o,l)=>Q(t,"PartialValues",e,s,o,l),e.useSetRowCallback=(e,s,t,o,l,r,u)=>Q(l,i,t,o,r,u,e,s),e.useSetTableCallback=(e,s,t,o,l,r)=>Q(o,u,s,t,l,r,e),e.useSetTablesCallback=(e,s,t,o,l)=>Q(t,n,e,s,o,l),e.useSetValueCallback=(e,s,t,o,l,r)=>Q(o,p,s,t,l,r,e),e.useSetValuesCallback=(e,s,t,o,l)=>Q(t,b,e,s,o,l),e.useSliceIds=$,e.useSliceIdsListener=(e,s,t,o)=>G("SliceIds",P(o),s,t,[e]),e.useSliceRowIds=_,e.useSliceRowIdsListener=(e,s,t,o,l)=>G("SliceRowIds",P(l),t,o,[e,s]),e.useSortedRowIds=K,e.useSortedRowIdsListener=(e,s,t,o,l,r,u,n,d)=>G(c,S(d),r,u,[e,s,t,o,l],n),e.useStore=e=>V(e,0),e.useTable=(e,s)=>F(u,S(s),{},[e]),e.useTableIds=H,e.useTableIdsListener=(e,s,t,o)=>G(d,S(o),e,s,[],t),e.useTableListener=(e,s,t,o,l)=>G(u,S(l),s,t,[e],o),e.useTables=e=>F(n,S(e),{}),e.useTablesListener=(e,s,t,o)=>G(n,S(o),e,s,[],t),e.useUndoInformation=e=>{var s;const t=O(e),[l,r]=ne(t);return[(u=l,!(0==(e=>e.length)(u))),ie(t),r,null!=(s=v(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o];var u},e.useValue=Y,e.useValueIds=X,e.useValueIdsListener=(e,s,t,o)=>G(R,S(o),e,s,[],t),e.useValueListener=(e,s,t,o,l)=>G(p,S(l),s,t,[e],o),e.useValues=e=>F(b,S(e),{}),e.useValuesListener=(e,s,t,o)=>G(b,S(o),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
|
1
|
+
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",l=t(o),r="Ids",u="Table",n=u+"s",d=u+r,i="Row",a=i+r,c="Sorted"+i+r,I="Cell",w=I+r,p="Value",b=p+"s",R=p+r,C=(e,s)=>e.map(s),k=e=>null==e,v=(e,s,t)=>k(e)?null==t?void 0:t():s(e),g=e=>t(e)==l,m=()=>{},{createContext:y,useContext:h}=s,f=y([]),L=(e,s)=>{const t=h(f);return k(e)?t[s]:g(e)?((e,s)=>v(e,(e=>e[s])))(t[s+1],e):e},V=(e,s)=>{const t=L(e,s);return k(e)||g(e)?t:e},S=e=>V(e,0),T=e=>V(e,2),P=e=>V(e,4),x=e=>V(e,6),q=e=>V(e,8),O=e=>V(e,10),{useCallback:B,useEffect:M,useMemo:j,useRef:D,useState:A}=s,E=(e,s,t=[])=>{const o=j((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},F=(e,s,t,o=[],l)=>{const[,r]=A(),u=B((()=>{var l,r;return null!=(r=null==(l=null==s?void 0:s["get"+e])?void 0:l.call(s,...o))?r:t}),[s,...o]),[n]=A(u),d=D(n);return j((()=>d.current=u()),[u]),G(e,s,((...e)=>{d.current=k(l)?u():e[l],r([])}),[],o),d.current},G=(e,s,t,o=[],l=[],...r)=>M((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...l,t,...r);return()=>null==s?void 0:s.delListener(u)}),[s,...l,...o,...r]),Q=(e,s,t,o=[],l=m,r=[],...u)=>{const n=S(e);return B((e=>v(n,(o=>v(t(e,o),(e=>l(o["set"+s](...u,e),e)))))),[n,s,...o,...r,...u])},U=(e,s,t=m,o=[],...l)=>{const r=S(e);return B((()=>t(null==r?void 0:r["del"+s](...l))),[r,s,...o,...l])},z=(e,s,t)=>{const o=O(e);return B((()=>null==o?void 0:o[s](t)),[o,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(a,S(s),[],[e]),K=(e,s,t,o=0,l,r)=>F(c,S(r),[],[e,s,t,o,l],6),N=(e,s,t)=>F(w,S(t),[],[e,s]),W=(e,s,t,o)=>F(I,S(o),void 0,[e,s,t],4),X=e=>F(R,S(e),[],[]),Y=(e,s)=>F(p,S(s),void 0,[e]),Z=(e,s)=>F("Metric",T(s),void 0,[e]),$=(e,s)=>F("SliceIds",P(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",P(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",x(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",x(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",x(t),[],[e,s]),oe=(e,s)=>F("ResultRowIds",q(s),[],[e]),le=(e,s,t,o=0,l,r)=>F("ResultSortedRowIds",q(r),[],[e,s,t,o,l],6),re=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,o)=>F("ResultCell",q(o),void 0,[e,s,t]),ne=e=>F("CheckpointIds",O(e),[[],void 0,[]]),de=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var ce=Object.defineProperty,Ie=Object.defineProperties,we=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,Ce=(e,s,t)=>s in e?ce(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ke=(e,s)=>{for(var t in s||(s={}))be.call(s,t)&&Ce(e,t,s[t]);if(pe)for(var t of pe(s))Re.call(s,t)&&Ce(e,t,s[t]);return e},ve=(e,s)=>Ie(e,we(s)),ge=(e,s)=>{var t={};for(var o in e)be.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&pe)for(var o of pe(e))s.indexOf(o)<0&&Re.call(e,o)&&(t[o]=e[o]);return t};const{createElement:me,useMemo:ye}=s,he=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,tableId:e,rowId:l,store:s,debugIds:r})))),l,r,e),fe=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:l,debugIds:r},u)=>Pe(C(u,(l=>me(t,ve(ke({},Te(o,l)),{key:l,queryId:e,rowId:l,queries:s,debugIds:r})))),l,r,e),Le=e=>{const s=x(e);return[s,null==s?void 0:s.getStore()]},Ve=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:o,separator:l,debugIds:r},u,n)=>{const[d,i]=Le(s),a=null==d?void 0:d.getLocalTableId(e),c=u(e,n,d);return Pe(C(c,(e=>me(t,ve(ke({},Te(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),l,r,n)},Se=e=>({checkpoints:s,checkpointComponent:t=Ae,getCheckpointComponentProps:o,separator:l,debugIds:r})=>{const u=O(s);return Pe(C(e(ne(u)),(e=>me(t,ve(ke({},Te(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),l)},Te=(e,s)=>k(e)?{}:e(s),Pe=(e,s,t,o)=>{const l=k(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",l,"}"]:l},xe=({tableId:e,rowId:s,cellId:t,store:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=W(e,s,t,l))?u:o),void 0,r,t)},qe=({tableId:e,rowId:s,store:t,cellComponent:o=xe,getCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(N(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:u})))),r,u,s),Oe=e=>he(e,J(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>{var l;return Pe(o+(null!=(l=Y(e,s))?l:o),void 0,t,e)},Me=({indexId:e,sliceId:s,indexes:t,rowComponent:o=qe,getRowComponentProps:l,separator:r,debugIds:u})=>{const n=P(t),d=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),a=_(e,s,n);return Pe(C(a,(e=>me(o,ve(ke({},Te(l,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},je=({queryId:e,rowId:s,cellId:t,queries:l,debugIds:r})=>{var u;return Pe(o+(null!=(u=ue(e,s,t,l))?u:o),void 0,r,t)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=je,getResultCellComponentProps:l,separator:r,debugIds:u})=>Pe(C(re(e,s,t),(r=>me(o,ve(ke({},Te(l,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ae=({checkpoints:e,checkpointId:s,debugIds:t})=>{var l;return Pe(null!=(l=de(s,e))?l:o,void 0,t,s)},Ee=Se((e=>e[0])),Fe=Se((e=>k(e[1])?[]:[e[1]])),Ge=Se((e=>e[2]));e.BackwardCheckpointsView=Ee,e.CellView=xe,e.CheckpointView=Ae,e.CurrentCheckpointView=Fe,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:o,separator:l,debugIds:r})=>Pe(C($(e,s),(l=>me(t,ve(ke({},Te(o,l)),{key:l,indexId:e,sliceId:l,indexes:s,debugIds:r})))),l,r,e),e.LinkedRowsView=e=>Ve(e,te,e.firstRowId),e.LocalRowsView=e=>Ve(e,se,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var l;return Pe(null!=(l=Z(e,s))?l:o,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:o,metricsById:l,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(f);return me(f.Provider,{value:ye((()=>[null!=e?e:p[0],ke(ke({},p[1]),t),null!=o?o:p[2],ke(ke({},p[3]),l),null!=r?r:p[4],ke(ke({},p[5]),u),null!=n?n:p[6],ke(ke({},p[7]),d),null!=i?i:p[8],ke(ke({},p[9]),a),null!=c?c:p[10],ke(ke({},p[11]),I)]),[e,t,o,l,r,u,n,d,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=qe,getRowComponentProps:l,debugIds:r})=>{const[u,n]=Le(t),d=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return Pe(k(d)||k(i)?null:me(o,ve(ke({},Te(l,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=je,e.ResultRowView=De,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return fe(u,le(u.queryId,t,o,l,r,u.queries))},e.ResultTableView=e=>fe(e,oe(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Me,e.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:l,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,o,l,r,u.store))},e.TableView=Oe,e.TablesView=({store:e,tableComponent:s=Oe,getTableComponentProps:t,separator:o,debugIds:l})=>Pe(C(H(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,tableId:o,store:e,debugIds:l})))),o),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:o,debugIds:l})=>Pe(C(X(e),(o=>me(s,ve(ke({},Te(t,o)),{key:o,valueId:o,store:e,debugIds:l})))),o),e.tableView=he,e.useAddRowCallback=(e,s,t=[],o,l=m,r=[],u=!0)=>{const n=S(o);return B((t=>v(n,(o=>v(s(t,o),(s=>l(o.addRow(e,s,u),o,s)))))),[n,e,...t,...r,u])},e.useCell=W,e.useCellIds=N,e.useCellIdsListener=(e,s,t,o,l,r)=>G(w,S(r),t,o,[e,s],l),e.useCellListener=(e,s,t,o,l,r,u)=>G(I,S(u),o,l,[e,s,t],r),e.useCheckpoint=de,e.useCheckpointIds=ne,e.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),e.useCheckpointListener=(e,s,t,o)=>G("Checkpoint",O(o),s,t,[e]),e.useCheckpoints=e=>L(e,10),e.useCreateCheckpoints=(e,s,t)=>E(e,s,t),e.useCreateIndexes=(e,s,t)=>E(e,s,t),e.useCreateMetrics=(e,s,t)=>E(e,s,t),e.useCreatePersister=(e,s,t=[],o,l=[])=>{const[,r]=A(),u=j((()=>s(e)),[e,...t]);return M((()=>{var e;return e=function*(){yield null==o?void 0:o(u),r(1)},new Promise(((s,t)=>{var o=s=>{try{r(e.next(s))}catch(e){t(e)}},l=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,l);r((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...l]),u},e.useCreateQueries=(e,s,t)=>E(e,s,t),e.useCreateRelationships=(e,s,t)=>E(e,s,t),e.useCreateStore=(e,s=[])=>j(e,s),e.useDelCellCallback=(e,s,t,o,l,r,u)=>U(l,I,r,u,e,s,t,o),e.useDelRowCallback=(e,s,t,o,l)=>U(t,i,o,l,e,s),e.useDelTableCallback=(e,s,t,o)=>U(s,u,t,o,e),e.useDelTablesCallback=(e,s,t)=>U(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>U(s,p,t,o,e),e.useDelValuesCallback=(e,s,t)=>U(e,b,s,t),e.useGoBackwardCallback=ie,e.useGoForwardCallback=ae,e.useGoToCallback=(e,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>v(e(s),(e=>o(t.goTo(e),e)))))),[r,...s,...l])},e.useIndexes=e=>L(e,4),e.useLinkedRowIds=te,e.useLinkedRowIdsListener=(e,s,t,o,l)=>G("LinkedRowIds",x(l),t,o,[e,s]),e.useLocalRowIds=se,e.useLocalRowIdsListener=(e,s,t,o,l)=>G("LocalRowIds",x(l),t,o,[e,s]),e.useMetric=Z,e.useMetricListener=(e,s,t,o)=>G("Metric",T(o),s,t,[e]),e.useMetrics=e=>L(e,2),e.useQueries=e=>L(e,8),e.useRedoInformation=e=>{var s;const t=O(e),[,,[l]]=ne(t);return[!k(l),ae(t),l,null!=(s=v(l,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o]},e.useRelationships=e=>L(e,6),e.useRemoteRowId=ee,e.useRemoteRowIdListener=(e,s,t,o,l)=>G("RemoteRowId",x(l),t,o,[e,s]),e.useResultCell=ue,e.useResultCellIds=re,e.useResultCellIdsListener=(e,s,t,o,l)=>G("ResultCellIds",q(l),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,l,r)=>G("ResultCell",q(r),o,l,[e,s,t]),e.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),e.useResultRowIds=oe,e.useResultRowIdsListener=(e,s,t,o)=>G("ResultRowIds",q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,l)=>G("ResultRow",q(l),t,o,[e,s]),e.useResultSortedRowIds=le,e.useResultSortedRowIdsListener=(e,s,t,o,l,r,u,n)=>G("ResultSortedRowIds",q(n),r,u,[e,s,t,o,l]),e.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),e.useResultTableListener=(e,s,t,o)=>G("ResultTable",q(o),s,t,[e]),e.useRow=(e,s,t)=>F(i,S(t),{},[e,s]),e.useRowIds=J,e.useRowIdsListener=(e,s,t,o,l)=>G(a,S(l),s,t,[e],o),e.useRowListener=(e,s,t,o,l,r)=>G(i,S(r),t,o,[e,s],l),e.useSetCellCallback=(e,s,t,o,l,r,u,n)=>Q(r,I,o,l,u,n,e,s,t),e.useSetCheckpointCallback=(e=m,s=[],t,o=m,l=[])=>{const r=O(t);return B((s=>v(r,(t=>{const l=e(s);o(t.addCheckpoint(l),t,l)}))),[r,...s,...l])},e.useSetPartialRowCallback=(e,s,t,o,l,r,u)=>Q(l,"PartialRow",t,o,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,o,l)=>Q(t,"PartialValues",e,s,o,l),e.useSetRowCallback=(e,s,t,o,l,r,u)=>Q(l,i,t,o,r,u,e,s),e.useSetTableCallback=(e,s,t,o,l,r)=>Q(o,u,s,t,l,r,e),e.useSetTablesCallback=(e,s,t,o,l)=>Q(t,n,e,s,o,l),e.useSetValueCallback=(e,s,t,o,l,r)=>Q(o,p,s,t,l,r,e),e.useSetValuesCallback=(e,s,t,o,l)=>Q(t,b,e,s,o,l),e.useSliceIds=$,e.useSliceIdsListener=(e,s,t,o)=>G("SliceIds",P(o),s,t,[e]),e.useSliceRowIds=_,e.useSliceRowIdsListener=(e,s,t,o,l)=>G("SliceRowIds",P(l),t,o,[e,s]),e.useSortedRowIds=K,e.useSortedRowIdsListener=(e,s,t,o,l,r,u,n,d)=>G(c,S(d),r,u,[e,s,t,o,l],n),e.useStore=e=>L(e,0),e.useTable=(e,s)=>F(u,S(s),{},[e]),e.useTableIds=H,e.useTableIdsListener=(e,s,t,o)=>G(d,S(o),e,s,[],t),e.useTableListener=(e,s,t,o,l)=>G(u,S(l),s,t,[e],o),e.useTables=e=>F(n,S(e),{}),e.useTablesListener=(e,s,t,o)=>G(n,S(o),e,s,[],t),e.useUndoInformation=e=>{var s;const t=O(e),[l,r]=ne(t);return[(u=l,!(0==(e=>e.length)(u))),ie(t),r,null!=(s=v(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:o];var u},e.useValue=Y,e.useValueIds=X,e.useValueIdsListener=(e,s,t,o)=>G(R,S(o),e,s,[],t),e.useValueListener=(e,s,t,o,l)=>G(p,S(l),s,t,[e],o),e.useValues=e=>F(b,S(e),{}),e.useValuesListener=(e,s,t,o)=>G(b,S(o),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -187,26 +187,26 @@
|
|
|
187
187
|
},
|
|
188
188
|
"devDependencies": {
|
|
189
189
|
"@babel/cli": "^7.21.5",
|
|
190
|
-
"@babel/core": "^7.21.
|
|
190
|
+
"@babel/core": "^7.21.8",
|
|
191
191
|
"@babel/preset-env": "^7.21.5",
|
|
192
192
|
"@babel/preset-react": "^7.18.6",
|
|
193
193
|
"@babel/preset-typescript": "^7.21.5",
|
|
194
194
|
"@rollup/plugin-replace": "^5.0.2",
|
|
195
|
-
"@rollup/plugin-terser": "^0.4.
|
|
195
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
196
196
|
"@types/asciichart": "^1.5.6",
|
|
197
197
|
"@types/expect-puppeteer": "^5.0.3",
|
|
198
198
|
"@types/http-server": "^0.12.1",
|
|
199
199
|
"@types/jest": "^29.5.1",
|
|
200
200
|
"@types/jest-environment-puppeteer": "^5.0.3",
|
|
201
201
|
"@types/less": "^3.0.3",
|
|
202
|
-
"@types/node": "^
|
|
202
|
+
"@types/node": "^20.1.7",
|
|
203
203
|
"@types/puppeteer": "^5.4.7",
|
|
204
|
-
"@types/react": "^18.2.
|
|
205
|
-
"@types/react-dom": "^18.2.
|
|
204
|
+
"@types/react": "^18.2.6",
|
|
205
|
+
"@types/react-dom": "^18.2.4",
|
|
206
206
|
"@types/react-test-renderer": "^18.0.0",
|
|
207
207
|
"@types/tmp": "^0.2.3",
|
|
208
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
209
|
-
"@typescript-eslint/parser": "^5.59.
|
|
208
|
+
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
209
|
+
"@typescript-eslint/parser": "^5.59.6",
|
|
210
210
|
"asciichart": "^1.5.25",
|
|
211
211
|
"babel-eslint": "^10.1.0",
|
|
212
212
|
"babel-jest": "^29.5.0",
|
|
@@ -214,11 +214,11 @@
|
|
|
214
214
|
"buffer-replace": "^1.0.0",
|
|
215
215
|
"country-flag-emoji-json": "^2.0.0",
|
|
216
216
|
"cspell": "^6.31.1",
|
|
217
|
-
"esbuild": "^0.17.
|
|
218
|
-
"eslint": "^8.
|
|
217
|
+
"esbuild": "^0.17.19",
|
|
218
|
+
"eslint": "^8.40.0",
|
|
219
219
|
"eslint-config-prettier": "^8.8.0",
|
|
220
220
|
"eslint-plugin-jest": "^27.2.1",
|
|
221
|
-
"eslint-plugin-jsdoc": "^
|
|
221
|
+
"eslint-plugin-jsdoc": "^44.2.4",
|
|
222
222
|
"eslint-plugin-react": "^7.32.2",
|
|
223
223
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
224
224
|
"gulp": "^4.0.2",
|
|
@@ -230,11 +230,11 @@
|
|
|
230
230
|
"jest-puppeteer": "^8.0.6",
|
|
231
231
|
"less": "^4.1.3",
|
|
232
232
|
"prettier": "^2.8.8",
|
|
233
|
-
"puppeteer": "^
|
|
233
|
+
"puppeteer": "^20.2.1",
|
|
234
234
|
"react": "^18.2.0",
|
|
235
235
|
"react-dom": "^18.2.0",
|
|
236
236
|
"react-test-renderer": "^18.2.0",
|
|
237
|
-
"rollup": "^3.
|
|
237
|
+
"rollup": "^3.22.0",
|
|
238
238
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
239
239
|
"rollup-plugin-gzip": "^3.1.0",
|
|
240
240
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Why sacrifice store features for bundle size? And why should the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a> (<em>new!</em>), <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-and-values">schematization</a> to model it.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so your UI only spends cycles on the data that changes.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#configure-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state! - out of the box.</li><li>Easily <a href="#persist-data-to-browser-file-or-server">sync your data</a> to local or remote storage, and use <a href="#call-hooks-to-bind-to-data">idiomatic bindings</a> to your UI.</li><li><a href="#type-definitions-orm-like-apis">Type definitions & ORM-like APIs</a> (<em>new!</em>), based on a schema or inferred from actual data.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">4.3kB - 8.8kB</a> when compressed, and has zero dependencies. And of course it's <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>. Other <a href="https://tinybase.org/guides/faq/">FAQs</a>?</p></section><p><a id="new" href="https://tinybase.org/guides/releases/#v3-1"><em>NEW!</em> v3.1 release</a></p><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><h3 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h3><p><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></p></section><section><h3 id="excited-to-be-used-by">Excited to be used by:</h3><p><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a></p></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://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>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Why sacrifice store features for bundle size? And why should the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a> (<em>new!</em>), <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-and-values">schematization</a> to model it.</li><li><a href="#register-listeners-at-any-granularity">Flexibly reactive</a> to reconciled updates, so your UI only spends cycles on the data that changes.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively.</li><li><a href="#create-indexes-for-fast-lookups">Indexing</a>, <a href="#define-metrics-and-aggregations">metrics</a>, <a href="#configure-relationships-between-tables">relationships</a> - and even an <a href="#use-checkpoints-for-an-easy-undo-stack">undo stack</a> for your app state! - out of the box.</li><li>Easily <a href="#persist-data-to-browser-file-or-server">sync your data</a> to local or remote storage, and use <a href="#call-hooks-to-bind-to-data">idiomatic bindings</a> to your UI.</li><li><a href="#type-definitions-orm-like-apis">Type definitions & ORM-like APIs</a> (<em>new!</em>), based on a schema or inferred from actual data.</li></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">4.3kB - 8.8kB</a> when compressed, and has zero dependencies. And of course it's <a href="#well-tested-and-documented">well tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and <a href="https://github.com/tinyplex/tinybase">open source</a>. Other <a href="https://tinybase.org/guides/faq/">FAQs</a>?</p></section><p><a id="new" href="https://tinybase.org/guides/releases/#v3-1"><em>NEW!</em> v3.1 release</a></p><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><h3 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h3><p><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></p></section><section><h3 id="excited-to-be-used-by">Excited to be used by:</h3><p><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a></p></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://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()
|
|
@@ -266,4 +266,4 @@ export const createShop: typeof createShopDecl = () => {
|
|
|
266
266
|
};
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>4.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.8kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>9.9kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://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.3kB</td><td>10.
|
|
269
|
+
<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.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.8kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>9.9kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://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.3kB</td><td>10.1kB</td><td>43.8kB</td><td>186.4kB</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>14.9kB</td><td>29.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.7kB</td><td>33.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.8kB</td><td>3.7kB</td><td>16.8kB</td><td>42.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>113.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>33.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.7kB</td><td>5.2kB</td><td>27.3kB</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>8.8kB</td><td>21.5kB</td><td>92.7kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible to get up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://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,790</td><td>1,790</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,928</td><td>1,928</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>766</td><td>766</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>638</td><td>638</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">2,602</td></tr><tr><th class="right">Assertions</th><td colspan="3">13,096</td></tr></tbody></table></div><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><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a>, <a href="https://discord.com/invite/mGz3mevwP8">Discord</a>, and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/discussions">Discussions</a> and <a href="https://github.com/tinyplex/tinybase/issues">issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li><li><a href="https://tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/3.1.3">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://hachyderm.io/@jamesgpearce">me</a> in API design, minification, and documentation. It could not have been built without these great <a href="https://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!</p></section>
|