tinybase 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/debug/checkpoints.js +7 -1
- package/lib/debug/indexes.d.ts +37 -10
- package/lib/debug/indexes.js +57 -25
- package/lib/debug/metrics.js +19 -2
- package/lib/debug/queries.js +18 -2
- package/lib/debug/relationships.js +19 -2
- package/lib/debug/store.js +7 -1
- package/lib/debug/tinybase.js +52 -25
- package/lib/debug/ui-react.js +2 -1
- package/lib/es6/checkpoints.js +1 -1
- package/lib/es6/checkpoints.js.gz +0 -0
- package/lib/es6/indexes.d.ts +37 -10
- 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/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/indexes.d.ts +37 -10
- 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/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/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.d.ts +37 -10
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.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-es6/checkpoints.js +1 -1
- package/lib/umd-es6/checkpoints.js.gz +0 -0
- package/lib/umd-es6/indexes.d.ts +37 -10
- package/lib/umd-es6/indexes.js +1 -1
- package/lib/umd-es6/indexes.js.gz +0 -0
- package/lib/umd-es6/metrics.js +1 -1
- package/lib/umd-es6/metrics.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/relationships.js +1 -1
- package/lib/umd-es6/relationships.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/package.json +17 -16
- package/readme.md +2 -2
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,o="",r=n(o),l=n(!0),s=n(0),i=n(n),a="type",d="default",c="utf8",u="Listener",v="Result",f="add",h="Table",g="RowIds",p="CellIds",y="Cell",w=e=>o+e,L=(e,t)=>e.includes(t),R=(e,t)=>e.every(t),I=(e,t)=>R(e,((n,o)=>0==o||t(e[o-1],n)<=0)),S=(e,t)=>e.sort(t),T=(e,t)=>e.forEach(t),b=(e,t)=>e.map(t),m=e=>E(e,((e,t)=>e+t),0),C=e=>e.length,x=e=>0==C(e),E=(e,t,n)=>e.reduce(t,n),P=(e,t,n)=>e.slice(t,n),k=(e,...t)=>e.push(...t),M=e=>e.pop(),O=e=>e.shift(),D=e=>JSON.stringify(e,((e,t)=>Q(t,Map)?E([...t],((e,[t,n])=>(e[t]=n,e)),{}):t)),A=JSON.parse,F=Math.max,j=Math.min,J=isFinite,Q=(e,t)=>e instanceof t,z=e=>null==e,N=(e,t,n)=>z(e)?null==n?void 0:n():t(e),W=e=>e==r||e==l,B=e=>n(e)==i,_=()=>{},q=e=>e.size,H=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},$=e=>z(e)||0==q(e),G=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},K=e=>e.clear(),U=(e,t)=>null==e?void 0:e.forEach(t),V=(e,t)=>null==e?void 0:e.delete(t),X=e=>new Map(e),Y=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},Z=(e,t)=>null==e?void 0:e.get(t),ee=(e,t)=>U(e,((e,n)=>t(n,e))),te=(e,t,n)=>z(n)?(V(e,t),e):null==e?void 0:e.set(t,n),ne=(e,t,n)=>(H(e,t)||te(e,t,n()),Z(e,t)),oe=(e,t,n)=>{const o={},r=null!=t?t:e=>e;return U(e,((e,t)=>N(r(e),(e=>(null==n?void 0:n(e))?0:o[t]=e)))),o},re=(e,t)=>{const n=X(),o=null!=t?t:e=>e;return U(e,((e,t)=>n.set(t,o(e)))),n},le=e=>re(e,re),se=(e,t,n,o,r=0)=>N((n?ne:Z)(e,t[r],r>C(t)-2?n:X),(l=>{if(r>C(t)-2)return(null==o?void 0:o(l))&&te(e,t[r]),l;const s=se(l,t,n,o,r+1);return $(l)&&te(e,t[r]),s})),ie=e=>new Set(e),ae=(e,t)=>null==e?void 0:e.add(t),de=(e,t,n)=>{const o=e.hasRow,r=X(),l=X(),s=X(),i=X(),a=X(),d=(t,n,...o)=>{const r=ne(a,t,ie);return T(o,(t=>ae(r,t)&&n&&e.callListener(t))),o},c=(t,...n)=>N(Z(a,t),(o=>{T(x(n)?G(o):n,(t=>{e.delListener(t),V(o,t)})),$(o)&&te(a,t)})),u=(e,n)=>{te(r,e,n),H(l,e)||(te(l,e,t()),te(s,e,X()),te(i,e,X()))},v=e=>{te(r,e),te(l,e),te(s,e),te(i,e),c(e)};return[()=>e,()=>Y(r),e=>ee(l,e),e=>H(l,e),e=>Z(r,e),e=>Z(l,e),(e,t)=>te(l,e,t),u,(t,r,l,a,v)=>{u(t,r);const f=X(),h=X(),g=Z(s,t),p=Z(i,t),y=t=>{const l=n=>e.getCell(r,t,n),s=Z(g,t),i=o(r,t)?n(a(l,t)):void 0;if(s!=i&&te(f,t,[s,i]),!z(v)){const e=Z(p,t),n=o(r,t)?v(l,t):void 0;e!=n&&te(h,t,n)}},w=e=>{l((()=>{U(f,(([,e],t)=>te(g,t,e))),U(h,((e,t)=>te(p,t,e)))}),f,h,g,p,e),K(f),K(h)};ee(g,y),e.hasTable(r)&&T(e.getRowIds(r),(e=>{H(g,e)||y(e)})),w(!0),c(t),d(t,0,e.addRowListener(r,null,((e,t,n)=>y(n))),e.addTableListener(r,(()=>w())))},v,()=>ee(a,v),d,c]},ce=(e,t)=>n(e)==r?t=>t(e):null!=e?e:()=>null!=t?t:o,ue=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},ve=/^\d+$/,fe=()=>{const e=[];let t=0;return[()=>{var n;return null!=(n=O(e))?n:o+t++},t=>{ve.test(t)&&C(e)<1e3&&k(e,t)}]},he=e=>{let t;const[n,r]=fe(),l=X();return[(r,s,i)=>{null!=t||(t=e());const a=n();return te(l,a,[r,s,i]),ae(se(s,null!=i?i:[o],ie),a),a},(e,n,...r)=>T(((e,t=[o])=>{const n=[],r=(e,o)=>o==C(t)?k(n,e):null===t[o]?U(e,(e=>r(e,o+1))):T([t[o],null],(t=>r(Z(e,t),o+1)));return r(e,0),n})(e,n),(e=>U(e,(e=>Z(l,e)[0](t,...null!=n?n:[],...r))))),e=>N(Z(l,e),(([,t,n])=>(se(t,null!=n?n:[o],void 0,(t=>(V(t,e),$(t)?1:0))),te(l,e),r(e),n))),(e,n,o)=>N(Z(l,e),(([e,,r=[]])=>{const l=(...s)=>{const i=C(s);i==C(r)?e(t,...s,...o(s)):z(r[i])?T(n[i](...s),(e=>l(...s,e))):l(...s,r[i])};l()}))]},ge=Object,pe=ge.keys,ye=ge.isFrozen,we=ge.freeze,Le=(e,t)=>!z(((e,t)=>N(e,(e=>e[t])))(e,t)),Re=(e,t)=>delete e[t],Ie=(e,t)=>T(ge.entries(e),(([e,n])=>t(n,e))),Se=e=>x(pe(e)),Te=e=>{const t=n(e);return W(t)||t==s&&J(e)?t:void 0},be=(e,t,n,o,r)=>z(r)?e.delCell(t,n,o,!0):e.setCell(t,n,o,r),me=ue((e=>{let t,n,r,l=100,s=X(),i=1;const a=X(),d=X(),[c,u,v]=he((()=>j)),f=X(),h=X(),g=[],p=[],y=(t,n)=>{i=0,e.transaction((()=>U(Z(f,n),((n,o)=>U(n,((n,r)=>U(n,((n,l)=>be(e,o,r,l,n[t]))))))))),i=1},w=e=>{te(f,e),te(h,e),u(d,[e])},R=(e,t)=>T(((e,t)=>e.splice(0,t))(e,null!=t?t:C(e)),w),I=()=>R(g,C(g)-l),S=e.addCellListener(null,null,null,((e,n,o,l,a,d)=>{if(i){N(t,(()=>{k(g,t),I(),R(p),t=void 0,r=1}));const e=ne(s,n,X),i=ne(e,o,X),c=ne(i,l,(()=>[d,void 0]));c[1]=a,c[0]===a&&$(te(i,l))&&$(te(e,o))&&$(te(s,n))&&(t=M(g),r=1),P()}})),b=(e="")=>(z(t)&&(t=o+n++,te(f,t,s),A(t,e),s=X(),r=1),t),m=()=>{x(g)||(p.unshift(b()),y(0,t),t=M(g),r=1)},E=()=>{x(p)||(k(g,t),t=O(p),y(1,t),r=1)},P=()=>{r&&(u(a),r=0)},D=e=>{const t=b(e);return P(),t},A=(e,t)=>(F(e)&&Z(h,e)!==t&&(te(h,e,t),u(d,[e])),j),F=e=>H(f,e),j={setSize:e=>(l=e,I(),j),addCheckpoint:D,setCheckpoint:A,getStore:()=>e,getCheckpointIds:()=>[[...g],t,[...p]],forEachCheckpoint:e=>ee(h,e),hasCheckpoint:F,getCheckpoint:e=>Z(h,e),goBackward:()=>(m(),P(),j),goForward:()=>(E(),P(),j),goTo:e=>{const n=L(g,e)?m:L(p,e)?E:null;for(;!z(n)&&e!=t;)n();return P(),j},addCheckpointIdsListener:e=>c(e,a),addCheckpointListener:(e,t)=>c(t,d,[e]),delListener:e=>(v(e),j),clear:()=>(R(g),R(p),z(t)||w(t),t=void 0,n=0,D(),j),destroy:()=>{e.delListener(S)},getListenerStats:()=>({})};return we(j.clear())})),Ce=(e,t)=>e<t?-1:1,xe=ue((e=>{const t=X(),n=X(),[r,l,s,i,a,d,c,,u,v,f]=de(e,X,(e=>z(e)?o:e+o)),[h,g,p]=he((()=>w)),y=(t,n,o)=>{const r=a(t);U(o,((t,o)=>n(o,(n=>U(t,(t=>n(t,(n=>e.forEachCell(r,t,n)))))))))},w={setIndexDefinition:(e,o,r,l,s,i=Ce)=>{const a=z(s)?void 0:([e],[t])=>s(e,t);return u(e,o,((o,r,s,u,v,f)=>{let h=0;const p=ie(),y=ie(),w=d(e);if(U(r,(([e,t],n)=>{z(e)||(ae(p,e),N(Z(w,e),(t=>{V(t,n),$(t)&&(te(w,e),h=1)}))),z(t)||(ae(p,t),H(w,t)||(te(w,t,ie()),h=1),ae(Z(w,t),n),z(l)||ae(y,t))})),o(),$(v)||(f?ee(w,(e=>ae(y,e))):ee(s,(e=>N(Z(u,e),(e=>ae(y,e))))),U(y,(e=>{const t=(t,n)=>i(Z(v,t),Z(v,n),e),n=[...Z(w,e)];I(n,t)||(te(w,e,ie(S(n,t))),ae(p,e))}))),(h||f)&&!z(a)){const t=[...w];I(t,a)||(c(e,X(S(t,a))),h=1)}h&&g(t,[e]),U(p,(t=>g(n,[e,t])))}),ce(r),N(l,ce)),w},delIndexDefinition:e=>(v(e),w),getStore:r,getIndexIds:l,forEachIndex:e=>s(((t,n)=>e(t,(e=>y(t,e,n))))),forEachSlice:(e,t)=>y(e,t,d(e)),hasIndex:i,hasSlice:(e,t)=>H(d(e),t),getTableId:a,getSliceIds:e=>Y(d(e)),getSliceRowIds:(e,t)=>G(Z(d(e),t)),addSliceIdsListener:(e,n)=>h(n,t,[e]),addSliceRowIdsListener:(e,t,o)=>h(o,n,[e,t]),delListener:e=>(p(e),w),destroy:f,getListenerStats:()=>({})};return we(w)})),Ee=X([["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,o)=>e+(t-n)/o]],["max",[e=>F(...e),(e,t)=>F(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:F(t,e)]],["min",[e=>j(...e),(e,t)=>j(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:j(t,e)]],["sum",[e=>m(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Pe=(e,t,n,o,r,l=!1)=>{if($(n))return;const[s,i,a,d]=r;return l||(l=z(e)),U(o,(([n,o])=>{l||(e=z(n)?null==i?void 0:i(e,o,t++):z(o)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,o,n,t),l||(l=z(e)))})),l?s(G(n),q(n)):e},ke=ue((e=>{const t=X(),[n,r,l,s,i,a,d,,c,u,v]=de(e,_,(e=>isNaN(e)||z(e)||!0===e||!1===e||e===o?void 0:1*e)),[f,h,g]=he((()=>p)),p={setMetricDefinition:(e,n,o,r,l,s,i)=>{var u;const v=B(o)?[o,l,s,i]:null!=(u=Z(Ee,o))?u:Z(Ee,"sum");return c(e,n,((n,o,r,l,s,i)=>{const c=a(e),u=q(l);i||(i=z(c)),n();let f=Pe(c,u,l,o,v,i);J(f)||(f=void 0),f!=c&&(d(e,f),h(t,[e],f,c))}),ce(r,1)),p},delMetricDefinition:e=>(u(e),p),getStore:n,getMetricIds:r,forEachMetric:l,hasMetric:s,getTableId:i,getMetric:a,addMetricListener:(e,n)=>f(n,t,[e]),delListener:e=>(g(e),p),destroy:v,getListenerStats:()=>({})};return we(p)}));var Me=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())}));const Oe=(e,t,n,r,l)=>{let s,i=0;const a={load:n=>Me(void 0,null,(function*(){if(2!=i){i=1;const r=yield t();z(r)||r==o?e.setTables(n):e.setJson(r),i=0}return a})),startAutoLoad:e=>Me(void 0,null,(function*(){return a.stopAutoLoad(),yield a.load(e),r(a.load),a})),stopAutoLoad:()=>(l(),a),save:()=>Me(void 0,null,(function*(){return 1!=i&&(i=2,yield n(e.getJson()),i=0),a})),startAutoSave:()=>Me(void 0,null,(function*(){return yield a.stopAutoSave().save(),s=e.addTablesListener((()=>a.save())),a})),stopAutoSave:()=>(N(s,e.delListener),a),getStore:()=>e,destroy:()=>a.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return we(a)};var De=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())}));const Ae="storage",Fe=globalThis.window,je=(e,t,n)=>{let o;return Oe(e,(()=>De(void 0,null,(function*(){return n.getItem(t)}))),(e=>De(void 0,null,(function*(){return n.setItem(t,e)}))),(e=>{o=o=>{o.storageArea===n&&o.key===t&&e()},Fe.addEventListener(Ae,o)}),(()=>{Fe.removeEventListener(Ae,o),o=void 0}))};var Je=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())})),Qe=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())}));const ze=e=>e.headers.get("ETag");var Ne=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable;const _e=ue((e=>{const t=e.createStore,[n,r,l,s,i,,,a,,d,c,w,L]=de(e,(()=>!0),_),I=t(),S=t(),b=X(),m=(e,t,...n)=>T(n,(n=>ae(ne(ne(b,t,X),e,ie),n))),E=e=>{N(Z(b,e),(e=>{ee(e,((e,t)=>U(t,(t=>e.delListener(t))))),K(e)})),T([S,I],(t=>t.delTable(e)))},M=(e,t,n)=>m(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),O={setQueryDefinition:(t,n,r)=>{a(t,n),E(t);const l=[],s=[[null,[n,null,null,[],X()]]],i=[],d=[],c=[];r({select:(e,t)=>{const n=B(e)?[C(l)+o,e]:[z(t)?e:t,n=>n(e,t)];return k(l,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const o=z(n)||B(t)?null:t,r=z(o)?t:n,l=[e,[e,o,B(r)?r:e=>e(r),[],X()]];return k(s,l),{as:e=>l[0]=e}},where:(e,t,n)=>k(i,B(e)?e:z(n)?n=>n(e)===t:o=>o(e,t)===n),group:(e,t,n,o,r)=>{var l;const s=[e,[e,B(t)?[t,n,o,r]:null!=(l=Z(Ee,t))?l:[(e,t)=>t]]];return k(d,s),{as:e=>s[0]=e}},having:(e,t)=>k(c,B(e)?e:n=>n(e)===t)});const u=X(l);if($(u))return O;const v=X(s);ee(v,((e,[,t])=>N(Z(v,t),(({3:t})=>z(e)?0:k(t,e)))));const f=X(d);let h=I;if($(f)&&x(c))h=S;else{M(t,h,S);const e=X();ee(f,((t,[n,o])=>ae(ne(e,n,ie),[t,o])));const n=ie();ee(u,(t=>H(e,t)?0:ae(n,t)));const o=X(),r=(n,o,r,l)=>N(n,(([s,i,a,d])=>{ee(o,((t,[n])=>{const o=ne(s,t,X),i=Z(o,r),a=l?void 0:n;if(i!==a){const n=ie([[i,a]]),l=q(o);te(o,r,a),U(Z(e,t),(([e,t])=>{const r=Pe(d[e],l,o,n,t);d[e]=z(Te(r))?null:r}))}})),$(i)||!R(c,(e=>e((e=>d[e]))))?S.delRow(t,a):z(a)?n[2]=S.addRow(t,d):S.setRow(t,a,d)}));m(h,t,h.addRowListener(t,null,((l,s,i,a)=>{const d=[],c=[],u=X(),v=h.hasRow(t,i);let f=!v;U(n,(e=>{const[n,o,r]=a(t,i,e);k(d,o),k(c,r),f||(f=n)})),ee(e,(e=>{const[n,,o]=a(t,i,e);(f||n)&&te(u,e,[o])})),f&&r(se(o,d,void 0,(([,e])=>(V(e,i),$(e)))),u,i,1),v&&r(se(o,c,(()=>{const e={};return U(n,(n=>e[n]=h.getCell(t,i,n))),[X(),ie(),void 0,e]}),(([,e])=>{ae(e,i)})),u,i)})))}M(t,e,h);const g=(o,r,l,s)=>{const a=t=>e.getCell(r,l,t);T(s,(n=>{var r;const[l,,s,i,d]=Z(v,n),c=null==s?void 0:s(a,o),[u,f]=null!=(r=Z(d,o))?r:[];c!=u&&(z(f)||L(t,f),te(d,o,z(c)?null:[c,...w(t,1,e.addRowListener(l,c,(()=>g(o,l,c,i))))]))})),(o=>{const r=(t,r)=>{var l,s,i;return e.getCell(...z(r)?[n,o,t]:t===n?[n,o,r]:[null==(l=Z(v,t))?void 0:l[0],null==(i=Z(null==(s=Z(v,t))?void 0:s[4],o))?void 0:i[0],r])};h.transaction((()=>R(i,(e=>e(r)))?ee(u,((e,n)=>be(h,t,o,e,n(r,o)))):h.delRow(t,o)))})(o)},{3:p}=Z(v,null);return h.transaction((()=>w(t,1,e.addRowListener(n,null,((o,r,l)=>{e.hasRow(n,l)?g(l,n,l,p):(h.delRow(t,l),U(v,(({4:e})=>N(Z(e,l),(([,n])=>{L(t,n),te(e,l)})))))}))))),O},delQueryDefinition:e=>(E(e),d(e),O),getStore:n,getQueryIds:r,forEachQuery:l,hasQuery:s,getTableId:i,delListener:e=>(S.delListener(e),O),destroy:c,getListenerStats:()=>((e,t)=>{var n={};for(var o in e)We.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&Ne)for(var o of Ne(e))t.indexOf(o)<0&&Be.call(e,o)&&(n[o]=e[o]);return n})(S.getListenerStats(),["tables","tableIds","transaction"])};return Ie({[h]:[1,1],[g]:[0,1],SortedRowIds:[0,5],Row:[1,2],[p]:[0,2],[y]:[1,3]},(([e,t],n)=>{T(e?["get","has","forEach"]:["get"],(e=>O[e+v+n]=(...t)=>S[e+n](...t))),O[f+v+n+u]=(...e)=>S[f+n+u](...P(e,0,t),((n,...o)=>e[t](O,...o)))})),we(O)})),qe=ue((e=>{const t=X(),n=X(),r=X(),l=X(),[s,i,a,d,c,u,,,v,f,h]=de(e,(()=>[X(),X(),X(),X()]),(e=>z(e)?void 0:e+o)),[g,p,y]=he((()=>I)),w=(e,t,n)=>N(u(e),(([o,,r])=>{if(!H(r,t)){const l=ie();if(c(e)!=R(e))ae(l,t);else{let e=t;for(;!z(e)&&!H(l,e);)ae(l,e),e=Z(o,e)}if(n)return l;te(r,t,l)}return Z(r,t)})),L=(e,t)=>N(u(e),(([,,e])=>te(e,t))),R=e=>Z(t,e),I={setRelationshipDefinition:(e,o,s,i)=>(te(t,e,s),v(e,o,((t,o)=>{const s=ie(),i=ie(),a=ie(),[d,c]=u(e);U(o,(([t,n],o)=>{z(t)||(ae(i,t),N(Z(c,t),(e=>{V(e,o),$(e)&&te(c,t)}))),z(n)||(ae(i,n),H(c,n)||te(c,n,ie()),ae(Z(c,n),o)),ae(s,o),te(d,o,n),ee(Z(l,e),(t=>{H(w(e,t),o)&&ae(a,t)}))})),t(),U(s,(t=>p(n,[e,t]))),U(i,(t=>p(r,[e,t]))),U(a,(t=>{L(e,t),p(l,[e,t])}))}),ce(i)),I),delRelationshipDefinition:e=>(te(t,e),f(e),I),getStore:s,getRelationshipIds:i,forEachRelationship:t=>a((n=>t(n,(t=>e.forEachRow(c(n),t))))),hasRelationship:d,getLocalTableId:c,getRemoteTableId:R,getRemoteRowId:(e,t)=>{var n;return Z(null==(n=u(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return G(Z(null==(n=u(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>z(u(e))?[t]:G(w(e,t,!0)),addRemoteRowIdListener:(e,t,o)=>g(o,n,[e,t]),addLocalRowIdsListener:(e,t,n)=>g(n,r,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(w(e,t),g(n,l,[e,t])),delListener:e=>(L(...y(e)),I),destroy:h,getListenerStats:()=>({})};return we(I)})),He=e=>[e,e],$e=()=>[X(),X()],Ge=(e,t,n,o=te)=>{const r=(l=Y(e),s=e=>!Le(t,e),l.filter(s));var l,s;return T(pe(t),(o=>n(e,o,t[o]))),T(r,(t=>o(e,t))),e},Ke=(e,t,n)=>z(e)||!(e=>Q(e,ge)&&e.constructor==ge)(e)||Se(e)||ye(e)?(null==n||n(),!1):(Ie(e,((n,o)=>{t(n,o)||Re(e,o)})),!Se(e)),Ue=(e,t,n)=>te(e,t,Z(e,t)==-n?void 0:n),Ve=()=>{let e,t,n=0;const o=X(),r=X(),l=X(),i=X(),c=X(),v=X(),I=X(),m=X(),x=X(),E=$e(),M=$e(),O=$e(),F=$e(),j=$e(),J=$e(),Q=$e(),_=$e(),q=$e(),G=$e(),[se,de,ce,ue]=he((()=>ct)),ve=(t,n)=>(!e||H(v,n)||We(n))&&Ke(t,((e,t)=>ge(n,t,e)),(()=>We(n))),ge=(e,t,n,o)=>Ke(o?n:ye(n,e,t),((o,r)=>N(pe(e,t,r,o),(e=>(n[r]=e,!0)),(()=>!1))),(()=>We(e,t))),pe=(t,n,o,r)=>e?N(Z(Z(v,t),o),(e=>Te(r)!=e.type?We(t,n,o,r,e.default):r),(()=>We(t,n,o,r))):z(Te(r))?We(t,n,o,r):r,ye=(e,t,n)=>(N(Z(I,t),(([o,r])=>{U(o,((t,n)=>{Le(e,n)||(e[n]=t)})),U(r,(o=>{Le(e,o)||We(t,n,o)}))})),e),me=e=>Ge(v,e,((e,t,n)=>{const o=X(),r=ie();Ge(ne(v,t,X),n,((e,t,n)=>{te(e,t,n),N(n.default,(e=>te(o,t,e)),(()=>ae(r,t)))})),te(I,t,[o,r])}),((e,t)=>{te(v,t),te(I,t)})),xe=e=>Ge(x,e,((e,t,n)=>Ee(t,n)),((e,t)=>Ae(t))),Ee=(e,t)=>Ge(ne(x,e,(()=>(Je(e,1),X()))),t,((t,n,o)=>Pe(e,t,n,o)),((t,n)=>Fe(e,t,n))),Pe=(e,t,n,o,r)=>Ge(ne(t,n,(()=>(Qe(e,n,1),X()))),o,((t,o,r)=>ke(e,n,t,o,r)),((o,l)=>je(e,t,n,o,l,r))),ke=(e,t,n,o,r)=>{H(n,o)||ze(e,t,o,1);const l=Z(n,o);r!==l&&(Ne(e,t,o,l,r),te(n,o,r))},Me=(e,t,n,o,r)=>N(Z(t,n),(t=>ke(e,n,t,o,r)),(()=>Pe(e,t,n,ye({[o]:r},e,n)))),Oe=e=>{const[t]=ne(m,e,fe),n=t();return H(Z(x,e),n)?Oe(e):n},De=e=>{var t;return null!=(t=Z(x,e))?t:Ee(e,{})},Ae=e=>Ee(e,{}),Fe=(e,t,n)=>{const[,o]=ne(m,e,fe);o(n),Pe(e,t,n,{},!0)},je=(e,t,n,o,r,l)=>{var s;const i=Z(null==(s=Z(I,e))?void 0:s[0],r);if(!z(i)&&!l)return ke(e,n,o,r,i);const a=t=>{Ne(e,n,t,Z(o,t)),ze(e,n,t,-1),te(o,t)};z(i)?a(r):ee(o,a),$(o)&&(Qe(e,n,-1),$(te(t,n))&&(Je(e,-1),te(x,e)))},Je=(e,t)=>Ue(o,e,t),Qe=(e,t,n)=>Ue(ne(r,e,X),t,n),ze=(e,t,n,o)=>Ue(ne(ne(l,e,X),t,X),n,o),Ne=(e,t,n,o,r)=>ne(ne(ne(i,e,X),t,X),n,(()=>[o,0]))[1]=r,We=(e,t,n,o,r)=>(k(ne(ne(ne(c,e,X),t,X),n,(()=>[])),o),r),Be=(e,t,n)=>N(Z(Z(Z(i,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...He(rt(e,t,n))])),_e=e=>$(c)||$(q[e])?0:U(e?re(c,le):c,((t,n)=>U(t,((t,o)=>U(t,((t,r)=>de(q[e],[n,o,r],t))))))),qe=(e,t,n)=>{if(!$(t))return de(e,n),1},Xe=e=>{const t=$(j[e]),n=$(Q[e])&&$(F[e])&&t&&$(M[e]),s=$(_[e])&&$(J[e])&&$(O[e])&&$(E[e]);if(!n||!s){const a=e?[re(o),le(r),re(l,le),re(i,le)]:[o,r,l,i];if(!n){U(a[2],((t,n)=>U(t,((t,o)=>qe(Q[e],t,[n,o])))));const n=ie();U(a[1],((o,r)=>{qe(F[e],o,[r])&&!t&&(de(j[e],[r,null]),ae(n,r))})),t||U(a[3],((t,o)=>{if(!H(n,o)){const n=ie();U(t,(e=>U(e,(([t,o],r)=>o!==t?ae(n,r):V(e,r))))),U(n,(t=>de(j[e],[o,t])))}})),qe(M[e],a[0])}if(!s){let t;U(a[3],((n,o)=>{let r;U(n,((n,l)=>{let s;U(n,(([n,i],a)=>{i!==n&&(de(_[e],[o,l,a],i,n,Be),t=r=s=1)})),s&&de(J[e],[o,l],Be)})),r&&de(O[e],[o],Be)})),t&&de(E[e],void 0,Be)}}},Ye=(e,...t)=>(it((()=>e(...b(t,w)))),ct),Ze=()=>oe(x,(e=>oe(e,oe))),et=()=>Y(x),tt=e=>Y(Z(x,w(e))),nt=(e,t,n,o=0,r)=>{const l=[];return ee(Z(x,w(e)),((e,n)=>k(l,[z(t)?e:Z(n,w(t)),e]))),b(P(S(l,(([e],[t])=>Ce(e,t)*(n?-1:1))),o,z(r)?r:o+r),(([,e])=>e))},ot=(e,t)=>Y(Z(Z(x,w(e)),w(t))),rt=(e,t,n)=>Z(Z(Z(x,w(e)),w(t)),w(n)),lt=e=>Ye((()=>(e=>Ke(e,ve,We))(e)?xe(e):0)),st=()=>Ye((()=>xe({}))),it=(e,t)=>{if(-1==n)return;at();const o=null==e?void 0:e();return dt(t),o},at=()=>(n++,ct),dt=e=>(n>0&&(n--,0==n&&(t=!$(i),n=1,_e(1),t&&Xe(1),n=-1,(null==e?void 0:e(oe(i,(e=>oe(e,(e=>oe(e,(e=>[...e]),(([e,t])=>e===t))),Se)),Se),oe(c,(e=>oe(e,oe)))))&&(n=1,U(i,((e,t)=>U(e,((e,n)=>U(e,(([e],o)=>be(ct,t,n,o,e))))))),n=-1,t=!1),de(G[0],void 0,t),_e(0),t&&Xe(0),de(G[1],void 0,t),n=0,T([i,c,o,r,l],K))),ct),ct={getTables:Ze,getTableIds:et,getTable:e=>oe(Z(x,w(e)),oe),getRowIds:tt,getSortedRowIds:nt,getRow:(e,t)=>oe(Z(Z(x,w(e)),w(t))),getCellIds:ot,getCell:rt,hasTables:()=>!$(x),hasTable:e=>H(x,w(e)),hasRow:(e,t)=>H(Z(x,w(e)),w(t)),hasCell:(e,t,n)=>H(Z(Z(x,w(e)),w(t)),w(n)),getJson:()=>D(x),getSchemaJson:()=>D(v),setTables:lt,setTable:(e,t)=>Ye((e=>ve(t,e)?Ee(e,t):0),e),setRow:(e,t,n)=>Ye(((e,t)=>ge(w(e),w(t),n)?Pe(w(e),De(w(e)),w(t),n):0),e,t),addRow:(e,t)=>it((()=>{let n;return ge(e,n,t)&&(e=w(e),Pe(e,De(e),n=Oe(e),t)),n})),setPartialRow:(e,t,n)=>Ye(((e,t)=>{if(ge(e,t,n,1)){const o=De(e);Ie(n,((n,r)=>Me(e,o,t,r,n)))}}),e,t),setCell:(e,t,n,o)=>Ye(((e,t,n)=>N(pe(e,t,n,B(o)?o(rt(e,t,n)):o),(o=>Me(e,De(e),t,n,o)))),e,t,n),setJson:e=>{try{"{}"===e?st():lt(A(e))}catch(e){}return ct},setSchema:t=>Ye((()=>{if((e=(e=>Ke(e,(e=>Ke(e,(e=>{if(!Ke(e,((e,t)=>L([a,d],t))))return!1;const t=e.type;return!(!W(t)&&t!=s||(Te(e.default)!=t&&Re(e,d),0))})))))(t))&&(me(t),!$(x))){const e=Ze();st(),lt(e)}})),delTables:st,delTable:e=>Ye((e=>H(x,e)?Ae(e):0),e),delRow:(e,t)=>Ye(((e,t)=>N(Z(x,e),(n=>H(n,t)?Fe(e,n,t):0))),e,t),delCell:(e,t,n,o)=>Ye(((e,t,n)=>N(Z(x,e),(r=>N(Z(r,t),(l=>H(l,n)?je(e,r,t,l,n,o):0))))),e,t,n),delSchema:()=>Ye((()=>{me({}),e=!1})),transaction:it,startTransaction:at,finishTransaction:dt,forEachTable:e=>U(x,((t,n)=>e(n,(e=>U(t,((t,n)=>e(n,(e=>ee(t,e))))))))),forEachRow:(e,t)=>U(Z(x,w(e)),((e,n)=>t(n,(t=>ee(e,t))))),forEachCell:(e,t,n)=>ee(Z(Z(x,w(e)),w(t)),n),addSortedRowIdsListener:(e,t,n,o,r,l,s)=>{let i=nt(e,t,n,o,r);return se((()=>{const s=nt(e,t,n,o,r);var a,d;d=i,C(a=s)===C(d)&&R(a,((e,t)=>d[t]===e))||(i=s,l(ct,e,t,n,o,r,i))}),j[s?1:0],[e,t])},addWillFinishTransactionListener:e=>se(e,G[0]),addDidFinishTransactionListener:e=>se(e,G[1]),callListener:e=>(ue(e,[et,tt,ot],(e=>z(e[2])?[]:He(rt(...e)))),ct),delListener:e=>(ce(e),ct),getListenerStats:()=>({}),createStore:Ve};return Ie({Tables:[0,E],TableIds:[0,M],[h]:[1,O],[g]:[1,F],Row:[2,J],[p]:[2,Q],[y]:[3,_],InvalidCell:[3,q]},(([e,t],n)=>{ct[f+n+u]=(...n)=>se(n[e],t[n[e+1]?1:0],e>0?P(n,0,e):void 0)})),we(ct)};e.createCheckpoints=me,e.createCustomPersister=Oe,e.createFilePersister=(e,n)=>{let o;return Oe(e,(()=>Je(void 0,null,(function*(){try{return yield t.promises.readFile(n,c)}catch(e){}}))),(e=>Je(void 0,null,(function*(){try{yield t.promises.writeFile(n,e,c)}catch(e){}}))),(e=>{o=t.watch(n,e)}),(()=>{null==o||o.close(),o=void 0}))},e.createIndexes=xe,e.createLocalPersister=(e,t)=>je(e,t,localStorage),e.createMetrics=ke,e.createQueries=_e,e.createRelationships=qe,e.createRemotePersister=(e,t,n,o)=>{let r,l;return Oe(e,(()=>Qe(void 0,null,(function*(){const e=yield fetch(t);return l=ze(e),e.text()}))),(e=>Qe(void 0,null,(function*(){return yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}))),(e=>{r=setInterval((()=>Qe(void 0,null,(function*(){const n=yield fetch(t,{method:"HEAD"}),o=ze(n);z(l)||z(o)||o==l||(l=o,e())}))),1e3*o)}),(()=>{N(r,clearInterval),r=void 0}))},e.createSessionPersister=(e,t)=>je(e,t,sessionStorage),e.createStore=Ve,e.defaultSorter=Ce,Object.defineProperty(e,"__esModule",{value:!0})},"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,o="",r=n(o),l=n(!0),s=n(0),i=n(n),a="type",d="default",c="utf8",u="Listener",v="Result",f="add",h="Table",g="RowIds",p="CellIds",y="Cell",w=e=>o+e,L=(e,t)=>e.includes(t),R=(e,t)=>e.every(t),I=(e,t)=>x(e)===x(t)&&R(e,((e,n)=>t[n]===e)),S=(e,t)=>R(e,((n,o)=>0==o||t(e[o-1],n)<=0)),T=(e,t)=>e.sort(t),b=(e,t)=>e.forEach(t),m=(e,t)=>e.map(t),C=e=>P(e,((e,t)=>e+t),0),x=e=>e.length,E=e=>0==x(e),P=(e,t,n)=>e.reduce(t,n),k=(e,t,n)=>e.slice(t,n),M=(e,...t)=>e.push(...t),A=e=>e.pop(),O=e=>e.shift(),D=e=>JSON.stringify(e,((e,t)=>z(t,Map)?P([...t],((e,[t,n])=>(e[t]=n,e)),{}):t)),F=JSON.parse,j=Math.max,J=Math.min,Q=isFinite,z=(e,t)=>e instanceof t,N=e=>null==e,W=(e,t,n)=>N(e)?null==n?void 0:n():t(e),B=e=>e==r||e==l,_=e=>n(e)==i,q=e=>Array.isArray(e),H=()=>{},$=e=>e.size,G=(e,t)=>{var n;return null!=(n=null==e?void 0:e.has(t))&&n},K=e=>N(e)||0==$(e),U=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},V=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),ee=e=>{var t;return[...null!=(t=null==e?void 0:e.keys())?t:[]]},te=(e,t)=>null==e?void 0:e.get(t),ne=(e,t)=>X(e,((e,n)=>t(n,e))),oe=(e,t,n)=>N(n)?(Y(e,t),e):null==e?void 0:e.set(t,n),re=(e,t,n)=>(G(e,t)||oe(e,t,n()),te(e,t)),le=(e,t,n)=>{const o={},r=null!=t?t:e=>e;return X(e,((e,t)=>W(r(e),(e=>(null==n?void 0:n(e))?0:o[t]=e)))),o},se=(e,t)=>{const n=Z(),o=null!=t?t:e=>e;return X(e,((e,t)=>n.set(t,o(e)))),n},ie=e=>se(e,se),ae=(e,t,n,o,r=0)=>W((n?re:te)(e,t[r],r>x(t)-2?n:Z),(l=>{if(r>x(t)-2)return(null==o?void 0:o(l))&&oe(e,t[r]),l;const s=ae(l,t,n,o,r+1);return K(l)&&oe(e,t[r]),s})),de=e=>new Set(q(e)||N(e)?e:[e]),ce=(e,t)=>null==e?void 0:e.add(t),ue=(e,t,n)=>{const o=e.hasRow,r=Z(),l=Z(),s=Z(),i=Z(),a=Z(),d=(t,n,...o)=>{const r=re(a,t,de);return b(o,(t=>ce(r,t)&&n&&e.callListener(t))),o},c=(t,...n)=>W(te(a,t),(o=>{b(E(n)?U(o):n,(t=>{e.delListener(t),Y(o,t)})),K(o)&&oe(a,t)})),u=(e,n)=>{oe(r,e,n),G(l,e)||(oe(l,e,t()),oe(s,e,Z()),oe(i,e,Z()))},v=e=>{oe(r,e),oe(l,e),oe(s,e),oe(i,e),c(e)};return[()=>e,()=>ee(r),e=>ne(l,e),e=>G(l,e),e=>te(r,e),e=>te(l,e),(e,t)=>oe(l,e,t),u,(t,r,l,a,v)=>{u(t,r);const f=Z(),h=Z(),g=te(s,t),p=te(i,t),y=t=>{const l=n=>e.getCell(r,t,n),s=te(g,t),i=o(r,t)?n(a(l,t)):void 0;if(s===i||q(s)&&q(i)&&I(s,i)||oe(f,t,[s,i]),!N(v)){const e=te(p,t),n=o(r,t)?v(l,t):void 0;e!=n&&oe(h,t,n)}},w=e=>{l((()=>{X(f,(([,e],t)=>oe(g,t,e))),X(h,((e,t)=>oe(p,t,e)))}),f,h,g,p,e),V(f),V(h)};ne(g,y),e.hasTable(r)&&b(e.getRowIds(r),(e=>{G(g,e)||y(e)})),w(!0),c(t),d(t,0,e.addRowListener(r,null,((e,t,n)=>y(n))),e.addTableListener(r,(()=>w())))},v,()=>ne(a,v),d,c]},ve=(e,t)=>n(e)==r?t=>t(e):null!=e?e:()=>null!=t?t:o,fe=e=>{const t=new WeakMap;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))},he=/^\d+$/,ge=()=>{const e=[];let t=0;return[()=>{var n;return null!=(n=O(e))?n:o+t++},t=>{he.test(t)&&x(e)<1e3&&M(e,t)}]},pe=e=>{let t;const[n,r]=ge(),l=Z();return[(r,s,i)=>{null!=t||(t=e());const a=n();return oe(l,a,[r,s,i]),ce(ae(s,null!=i?i:[o],de),a),a},(e,n,...r)=>b(((e,t=[o])=>{const n=[],r=(e,o)=>o==x(t)?M(n,e):null===t[o]?X(e,(e=>r(e,o+1))):b([t[o],null],(t=>r(te(e,t),o+1)));return r(e,0),n})(e,n),(e=>X(e,(e=>te(l,e)[0](t,...null!=n?n:[],...r))))),e=>W(te(l,e),(([,t,n])=>(ae(t,null!=n?n:[o],void 0,(t=>(Y(t,e),K(t)?1:0))),oe(l,e),r(e),n))),(e,n,o)=>W(te(l,e),(([e,,r=[]])=>{const l=(...s)=>{const i=x(s);i==x(r)?e(t,...s,...o(s)):N(r[i])?b(n[i](...s),(e=>l(...s,e))):l(...s,r[i])};l()}))]},ye=Object,we=ye.keys,Le=ye.isFrozen,Re=ye.freeze,Ie=(e,t)=>!N(((e,t)=>W(e,(e=>e[t])))(e,t)),Se=(e,t)=>delete e[t],Te=(e,t)=>b(ye.entries(e),(([e,n])=>t(n,e))),be=e=>E(we(e)),me=e=>{const t=n(e);return B(t)||t==s&&Q(e)?t:void 0},Ce=(e,t,n,o,r)=>N(r)?e.delCell(t,n,o,!0):e.setCell(t,n,o,r),xe=fe((e=>{let t,n,r,l=100,s=Z(),i=1;const a=Z(),d=Z(),[c,u,v]=pe((()=>j)),f=Z(),h=Z(),g=[],p=[],y=(t,n)=>{i=0,e.transaction((()=>X(te(f,n),((n,o)=>X(n,((n,r)=>X(n,((n,l)=>Ce(e,o,r,l,n[t]))))))))),i=1},w=e=>{oe(f,e),oe(h,e),u(d,[e])},R=(e,t)=>b(((e,t)=>e.splice(0,t))(e,null!=t?t:x(e)),w),I=()=>R(g,x(g)-l),S=e.addCellListener(null,null,null,((e,n,o,l,a,d)=>{if(i){W(t,(()=>{M(g,t),I(),R(p),t=void 0,r=1}));const e=re(s,n,Z),i=re(e,o,Z),c=re(i,l,(()=>[d,void 0]));c[1]=a,c[0]===a&&K(oe(i,l))&&K(oe(e,o))&&K(oe(s,n))&&(t=A(g),r=1),P()}})),T=(e="")=>(N(t)&&(t=o+n++,oe(f,t,s),D(t,e),s=Z(),r=1),t),m=()=>{E(g)||(p.unshift(T()),y(0,t),t=A(g),r=1)},C=()=>{E(p)||(M(g,t),t=O(p),y(1,t),r=1)},P=()=>{r&&(u(a),r=0)},k=e=>{const t=T(e);return P(),t},D=(e,t)=>(F(e)&&te(h,e)!==t&&(oe(h,e,t),u(d,[e])),j),F=e=>G(f,e),j={setSize:e=>(l=e,I(),j),addCheckpoint:k,setCheckpoint:D,getStore:()=>e,getCheckpointIds:()=>[[...g],t,[...p]],forEachCheckpoint:e=>ne(h,e),hasCheckpoint:F,getCheckpoint:e=>te(h,e),goBackward:()=>(m(),P(),j),goForward:()=>(C(),P(),j),goTo:e=>{const n=L(g,e)?m:L(p,e)?C:null;for(;!N(n)&&e!=t;)n();return P(),j},addCheckpointIdsListener:e=>c(e,a),addCheckpointListener:(e,t)=>c(t,d,[e]),delListener:e=>(v(e),j),clear:()=>(R(g),R(p),N(t)||w(t),t=void 0,n=0,k(),j),destroy:()=>{e.delListener(S)},getListenerStats:()=>({})};return Re(j.clear())})),Ee=(e,t)=>e<t?-1:1,Pe=fe((e=>{const t=Z(),n=Z(),[r,l,s,i,a,d,c,,u,v,f]=ue(e,Z,(e=>N(e)?o:q(e)?m(e,w):w(e))),[h,g,p]=pe((()=>L)),y=(t,n,o)=>{const r=a(t);X(o,((t,o)=>n(o,(n=>X(t,(t=>n(t,(n=>e.forEachCell(r,t,n)))))))))},L={setIndexDefinition:(e,o,r,l,s,i=Ee)=>{const a=N(s)?void 0:([e],[t])=>s(e,t);return u(e,o,((o,r,s,u,v,f)=>{let h=0;const p=de(),y=de(),w=d(e);if(X(r,(([e,t],n)=>{const o=de(e),r=de(t);X(o,(e=>Y(r,e)?Y(o,e):0)),X(o,(e=>{ce(p,e),W(te(w,e),(t=>{Y(t,n),K(t)&&(oe(w,e),h=1)}))})),X(r,(e=>{ce(p,e),G(w,e)||(oe(w,e,de()),h=1),ce(te(w,e),n),N(l)||ce(y,e)}))})),o(),K(v)||(f?ne(w,(e=>ce(y,e))):ne(s,(e=>W(te(u,e),(e=>ce(y,e))))),X(y,(e=>{const t=(t,n)=>i(te(v,t),te(v,n),e),n=[...te(w,e)];S(n,t)||(oe(w,e,de(T(n,t))),ce(p,e))}))),(h||f)&&!N(a)){const t=[...w];S(t,a)||(c(e,Z(T(t,a))),h=1)}h&&g(t,[e]),X(p,(t=>g(n,[e,t])))}),ve(r),W(l,ve)),L},delIndexDefinition:e=>(v(e),L),getStore:r,getIndexIds:l,forEachIndex:e=>s(((t,n)=>e(t,(e=>y(t,e,n))))),forEachSlice:(e,t)=>y(e,t,d(e)),hasIndex:i,hasSlice:(e,t)=>G(d(e),t),getTableId:a,getSliceIds:e=>ee(d(e)),getSliceRowIds:(e,t)=>U(te(d(e),t)),addSliceIdsListener:(e,n)=>h(n,t,[e]),addSliceRowIdsListener:(e,t,o)=>h(o,n,[e,t]),delListener:e=>(p(e),L),destroy:f,getListenerStats:()=>({})};return Re(L)})),ke=Z([["avg",[(e,t)=>C(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,o)=>e+(t-n)/o]],["max",[e=>j(...e),(e,t)=>j(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:j(t,e)]],["min",[e=>J(...e),(e,t)=>J(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:J(t,e)]],["sum",[e=>C(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Me=(e,t,n,o,r,l=!1)=>{if(K(n))return;const[s,i,a,d]=r;return l||(l=N(e)),X(o,(([n,o])=>{l||(e=N(n)?null==i?void 0:i(e,o,t++):N(o)?null==a?void 0:a(e,n,t--):null==d?void 0:d(e,o,n,t),l||(l=N(e)))})),l?s(U(n),$(n)):e},Ae=fe((e=>{const t=Z(),[n,r,l,s,i,a,d,,c,u,v]=ue(e,H,(e=>isNaN(e)||N(e)||!0===e||!1===e||e===o?void 0:1*e)),[f,h,g]=pe((()=>p)),p={setMetricDefinition:(e,n,o,r,l,s,i)=>{var u;const v=_(o)?[o,l,s,i]:null!=(u=te(ke,o))?u:te(ke,"sum");return c(e,n,((n,o,r,l,s,i)=>{const c=a(e),u=$(l);i||(i=N(c)),n();let f=Me(c,u,l,o,v,i);Q(f)||(f=void 0),f!=c&&(d(e,f),h(t,[e],f,c))}),ve(r,1)),p},delMetricDefinition:e=>(u(e),p),getStore:n,getMetricIds:r,forEachMetric:l,hasMetric:s,getTableId:i,getMetric:a,addMetricListener:(e,n)=>f(n,t,[e]),delListener:e=>(g(e),p),destroy:v,getListenerStats:()=>({})};return Re(p)}));var Oe=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())}));const De=(e,t,n,r,l)=>{let s,i=0;const a={load:n=>Oe(void 0,null,(function*(){if(2!=i){i=1;const r=yield t();N(r)||r==o?e.setTables(n):e.setJson(r),i=0}return a})),startAutoLoad:e=>Oe(void 0,null,(function*(){return a.stopAutoLoad(),yield a.load(e),r(a.load),a})),stopAutoLoad:()=>(l(),a),save:()=>Oe(void 0,null,(function*(){return 1!=i&&(i=2,yield n(e.getJson()),i=0),a})),startAutoSave:()=>Oe(void 0,null,(function*(){return yield a.stopAutoSave().save(),s=e.addTablesListener((()=>a.save())),a})),stopAutoSave:()=>(W(s,e.delListener),a),getStore:()=>e,destroy:()=>a.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return Re(a)};var Fe=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())}));const je="storage",Je=globalThis.window,Qe=(e,t,n)=>{let o;return De(e,(()=>Fe(void 0,null,(function*(){return n.getItem(t)}))),(e=>Fe(void 0,null,(function*(){return n.setItem(t,e)}))),(e=>{o=o=>{o.storageArea===n&&o.key===t&&e()},Je.addEventListener(je,o)}),(()=>{Je.removeEventListener(je,o),o=void 0}))};var ze=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())})),Ne=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{i(n.next(e))}catch(e){r(e)}},s=e=>{try{i(n.throw(e))}catch(e){r(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,s);i((n=n.apply(e,t)).next())}));const We=e=>e.headers.get("ETag");var Be=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable;const He=fe((e=>{const t=e.createStore,[n,r,l,s,i,,,a,,d,c,w,L]=ue(e,(()=>!0),H),I=t(),S=t(),T=Z(),m=(e,t,...n)=>b(n,(n=>ce(re(re(T,t,Z),e,de),n))),C=e=>{W(te(T,e),(e=>{ne(e,((e,t)=>X(t,(t=>e.delListener(t))))),V(e)})),b([S,I],(t=>t.delTable(e)))},P=(e,t,n)=>m(t,e,t.addWillFinishTransactionListener(n.startTransaction),t.addDidFinishTransactionListener((()=>n.finishTransaction()))),A={setQueryDefinition:(t,n,r)=>{a(t,n),C(t);const l=[],s=[[null,[n,null,null,[],Z()]]],i=[],d=[],c=[];r({select:(e,t)=>{const n=_(e)?[x(l)+o,e]:[N(t)?e:t,n=>n(e,t)];return M(l,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const o=N(n)||_(t)?null:t,r=N(o)?t:n,l=[e,[e,o,_(r)?r:e=>e(r),[],Z()]];return M(s,l),{as:e=>l[0]=e}},where:(e,t,n)=>M(i,_(e)?e:N(n)?n=>n(e)===t:o=>o(e,t)===n),group:(e,t,n,o,r)=>{var l;const s=[e,[e,_(t)?[t,n,o,r]:null!=(l=te(ke,t))?l:[(e,t)=>t]]];return M(d,s),{as:e=>s[0]=e}},having:(e,t)=>M(c,_(e)?e:n=>n(e)===t)});const u=Z(l);if(K(u))return A;const v=Z(s);ne(v,((e,[,t])=>W(te(v,t),(({3:t})=>N(e)?0:M(t,e)))));const f=Z(d);let h=I;if(K(f)&&E(c))h=S;else{P(t,h,S);const e=Z();ne(f,((t,[n,o])=>ce(re(e,n,de),[t,o])));const n=de();ne(u,(t=>G(e,t)?0:ce(n,t)));const o=Z(),r=(n,o,r,l)=>W(n,(([s,i,a,d])=>{ne(o,((t,[n])=>{const o=re(s,t,Z),i=te(o,r),a=l?void 0:n;if(i!==a){const n=de([[i,a]]),l=$(o);oe(o,r,a),X(te(e,t),(([e,t])=>{const r=Me(d[e],l,o,n,t);d[e]=N(me(r))?null:r}))}})),K(i)||!R(c,(e=>e((e=>d[e]))))?S.delRow(t,a):N(a)?n[2]=S.addRow(t,d):S.setRow(t,a,d)}));m(h,t,h.addRowListener(t,null,((l,s,i,a)=>{const d=[],c=[],u=Z(),v=h.hasRow(t,i);let f=!v;X(n,(e=>{const[n,o,r]=a(t,i,e);M(d,o),M(c,r),f||(f=n)})),ne(e,(e=>{const[n,,o]=a(t,i,e);(f||n)&&oe(u,e,[o])})),f&&r(ae(o,d,void 0,(([,e])=>(Y(e,i),K(e)))),u,i,1),v&&r(ae(o,c,(()=>{const e={};return X(n,(n=>e[n]=h.getCell(t,i,n))),[Z(),de(),void 0,e]}),(([,e])=>{ce(e,i)})),u,i)})))}P(t,e,h);const g=(o,r,l,s)=>{const a=t=>e.getCell(r,l,t);b(s,(n=>{var r;const[l,,s,i,d]=te(v,n),c=null==s?void 0:s(a,o),[u,f]=null!=(r=te(d,o))?r:[];c!=u&&(N(f)||L(t,f),oe(d,o,N(c)?null:[c,...w(t,1,e.addRowListener(l,c,(()=>g(o,l,c,i))))]))})),(o=>{const r=(t,r)=>{var l,s,i;return e.getCell(...N(r)?[n,o,t]:t===n?[n,o,r]:[null==(l=te(v,t))?void 0:l[0],null==(i=te(null==(s=te(v,t))?void 0:s[4],o))?void 0:i[0],r])};h.transaction((()=>R(i,(e=>e(r)))?ne(u,((e,n)=>Ce(h,t,o,e,n(r,o)))):h.delRow(t,o)))})(o)},{3:p}=te(v,null);return h.transaction((()=>w(t,1,e.addRowListener(n,null,((o,r,l)=>{e.hasRow(n,l)?g(l,n,l,p):(h.delRow(t,l),X(v,(({4:e})=>W(te(e,l),(([,n])=>{L(t,n),oe(e,l)})))))}))))),A},delQueryDefinition:e=>(C(e),d(e),A),getStore:n,getQueryIds:r,forEachQuery:l,hasQuery:s,getTableId:i,delListener:e=>(S.delListener(e),A),destroy:c,getListenerStats:()=>((e,t)=>{var n={};for(var o in e)_e.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&Be)for(var o of Be(e))t.indexOf(o)<0&&qe.call(e,o)&&(n[o]=e[o]);return n})(S.getListenerStats(),["tables","tableIds","transaction"])};return Te({[h]:[1,1],[g]:[0,1],SortedRowIds:[0,5],Row:[1,2],[p]:[0,2],[y]:[1,3]},(([e,t],n)=>{b(e?["get","has","forEach"]:["get"],(e=>A[e+v+n]=(...t)=>S[e+n](...t))),A[f+v+n+u]=(...e)=>S[f+n+u](...k(e,0,t),((n,...o)=>e[t](A,...o)))})),Re(A)})),$e=fe((e=>{const t=Z(),n=Z(),r=Z(),l=Z(),[s,i,a,d,c,u,,,v,f,h]=ue(e,(()=>[Z(),Z(),Z(),Z()]),(e=>N(e)?void 0:e+o)),[g,p,y]=pe((()=>I)),w=(e,t,n)=>W(u(e),(([o,,r])=>{if(!G(r,t)){const l=de();if(c(e)!=R(e))ce(l,t);else{let e=t;for(;!N(e)&&!G(l,e);)ce(l,e),e=te(o,e)}if(n)return l;oe(r,t,l)}return te(r,t)})),L=(e,t)=>W(u(e),(([,,e])=>oe(e,t))),R=e=>te(t,e),I={setRelationshipDefinition:(e,o,s,i)=>(oe(t,e,s),v(e,o,((t,o)=>{const s=de(),i=de(),a=de(),[d,c]=u(e);X(o,(([t,n],o)=>{N(t)||(ce(i,t),W(te(c,t),(e=>{Y(e,o),K(e)&&oe(c,t)}))),N(n)||(ce(i,n),G(c,n)||oe(c,n,de()),ce(te(c,n),o)),ce(s,o),oe(d,o,n),ne(te(l,e),(t=>{G(w(e,t),o)&&ce(a,t)}))})),t(),X(s,(t=>p(n,[e,t]))),X(i,(t=>p(r,[e,t]))),X(a,(t=>{L(e,t),p(l,[e,t])}))}),ve(i)),I),delRelationshipDefinition:e=>(oe(t,e),f(e),I),getStore:s,getRelationshipIds:i,forEachRelationship:t=>a((n=>t(n,(t=>e.forEachRow(c(n),t))))),hasRelationship:d,getLocalTableId:c,getRemoteTableId:R,getRemoteRowId:(e,t)=>{var n;return te(null==(n=u(e))?void 0:n[0],t)},getLocalRowIds:(e,t)=>{var n;return U(te(null==(n=u(e))?void 0:n[1],t))},getLinkedRowIds:(e,t)=>N(u(e))?[t]:U(w(e,t,!0)),addRemoteRowIdListener:(e,t,o)=>g(o,n,[e,t]),addLocalRowIdsListener:(e,t,n)=>g(n,r,[e,t]),addLinkedRowIdsListener:(e,t,n)=>(w(e,t),g(n,l,[e,t])),delListener:e=>(L(...y(e)),I),destroy:h,getListenerStats:()=>({})};return Re(I)})),Ge=e=>[e,e],Ke=()=>[Z(),Z()],Ue=(e,t,n,o=oe)=>{const r=(l=ee(e),s=e=>!Ie(t,e),l.filter(s));var l,s;return b(we(t),(o=>n(e,o,t[o]))),b(r,(t=>o(e,t))),e},Ve=(e,t,n)=>N(e)||!(e=>z(e,ye)&&e.constructor==ye)(e)||be(e)||Le(e)?(null==n||n(),!1):(Te(e,((n,o)=>{t(n,o)||Se(e,o)})),!be(e)),Xe=(e,t,n)=>oe(e,t,te(e,t)==-n?void 0:n),Ye=()=>{let e,t,n=0;const o=Z(),r=Z(),l=Z(),i=Z(),c=Z(),v=Z(),R=Z(),S=Z(),C=Z(),x=Ke(),E=Ke(),P=Ke(),A=Ke(),O=Ke(),j=Ke(),J=Ke(),Q=Ke(),z=Ke(),q=Ke(),[H,$,U,ae]=pe((()=>dt)),ue=(t,n)=>(!e||G(v,n)||Ne(n))&&Ve(t,((e,t)=>ve(n,t,e)),(()=>Ne(n))),ve=(e,t,n,o)=>Ve(o?n:he(n,e,t),((o,r)=>W(fe(e,t,r,o),(e=>(n[r]=e,!0)),(()=>!1))),(()=>Ne(e,t))),fe=(t,n,o,r)=>e?W(te(te(v,t),o),(e=>me(r)!=e.type?Ne(t,n,o,r,e.default):r),(()=>Ne(t,n,o,r))):N(me(r))?Ne(t,n,o,r):r,he=(e,t,n)=>(W(te(R,t),(([o,r])=>{X(o,((t,n)=>{Ie(e,n)||(e[n]=t)})),X(r,(o=>{Ie(e,o)||Ne(t,n,o)}))})),e),ye=e=>Ue(v,e,((e,t,n)=>{const o=Z(),r=de();Ue(re(v,t,Z),n,((e,t,n)=>{oe(e,t,n),W(n.default,(e=>oe(o,t,e)),(()=>ce(r,t)))})),oe(R,t,[o,r])}),((e,t)=>{oe(v,t),oe(R,t)})),we=e=>Ue(C,e,((e,t,n)=>Le(t,n)),((e,t)=>Oe(t))),Le=(e,t)=>Ue(re(C,e,(()=>(je(e,1),Z()))),t,((t,n,o)=>xe(e,t,n,o)),((t,n)=>De(e,t,n))),xe=(e,t,n,o,r)=>Ue(re(t,n,(()=>(Je(e,n,1),Z()))),o,((t,o,r)=>Pe(e,n,t,o,r)),((o,l)=>Fe(e,t,n,o,l,r))),Pe=(e,t,n,o,r)=>{G(n,o)||Qe(e,t,o,1);const l=te(n,o);r!==l&&(ze(e,t,o,l,r),oe(n,o,r))},ke=(e,t,n,o,r)=>W(te(t,n),(t=>Pe(e,n,t,o,r)),(()=>xe(e,t,n,he({[o]:r},e,n)))),Me=e=>{const[t]=re(S,e,ge),n=t();return G(te(C,e),n)?Me(e):n},Ae=e=>{var t;return null!=(t=te(C,e))?t:Le(e,{})},Oe=e=>Le(e,{}),De=(e,t,n)=>{const[,o]=re(S,e,ge);o(n),xe(e,t,n,{},!0)},Fe=(e,t,n,o,r,l)=>{var s;const i=te(null==(s=te(R,e))?void 0:s[0],r);if(!N(i)&&!l)return Pe(e,n,o,r,i);const a=t=>{ze(e,n,t,te(o,t)),Qe(e,n,t,-1),oe(o,t)};N(i)?a(r):ne(o,a),K(o)&&(Je(e,n,-1),K(oe(t,n))&&(je(e,-1),oe(C,e)))},je=(e,t)=>Xe(o,e,t),Je=(e,t,n)=>Xe(re(r,e,Z),t,n),Qe=(e,t,n,o)=>Xe(re(re(l,e,Z),t,Z),n,o),ze=(e,t,n,o,r)=>re(re(re(i,e,Z),t,Z),n,(()=>[o,0]))[1]=r,Ne=(e,t,n,o,r)=>(M(re(re(re(c,e,Z),t,Z),n,(()=>[])),o),r),We=(e,t,n)=>W(te(te(te(i,e),t),n),(([e,t])=>[!0,e,t]),(()=>[!1,...Ge(ot(e,t,n))])),Be=e=>K(c)||K(z[e])?0:X(e?se(c,ie):c,((t,n)=>X(t,((t,o)=>X(t,((t,r)=>$(z[e],[n,o,r],t))))))),_e=(e,t,n)=>{if(!K(t))return $(e,n),1},qe=e=>{const t=K(O[e]),n=K(J[e])&&K(A[e])&&t&&K(E[e]),s=K(Q[e])&&K(j[e])&&K(P[e])&&K(x[e]);if(!n||!s){const a=e?[se(o),ie(r),se(l,ie),se(i,ie)]:[o,r,l,i];if(!n){X(a[2],((t,n)=>X(t,((t,o)=>_e(J[e],t,[n,o])))));const n=de();X(a[1],((o,r)=>{_e(A[e],o,[r])&&!t&&($(O[e],[r,null]),ce(n,r))})),t||X(a[3],((t,o)=>{if(!G(n,o)){const n=de();X(t,(e=>X(e,(([t,o],r)=>o!==t?ce(n,r):Y(e,r))))),X(n,(t=>$(O[e],[o,t])))}})),_e(E[e],a[0])}if(!s){let t;X(a[3],((n,o)=>{let r;X(n,((n,l)=>{let s;X(n,(([n,i],a)=>{i!==n&&($(Q[e],[o,l,a],i,n,We),t=r=s=1)})),s&&$(j[e],[o,l],We)})),r&&$(P[e],[o],We)})),t&&$(x[e],void 0,We)}}},He=(e,...t)=>(st((()=>e(...m(t,w)))),dt),$e=()=>le(C,(e=>le(e,le))),Ze=()=>ee(C),et=e=>ee(te(C,w(e))),tt=(e,t,n,o=0,r)=>{const l=[];return ne(te(C,w(e)),((e,n)=>M(l,[N(t)?e:te(n,w(t)),e]))),m(k(T(l,(([e],[t])=>Ee(e,t)*(n?-1:1))),o,N(r)?r:o+r),(([,e])=>e))},nt=(e,t)=>ee(te(te(C,w(e)),w(t))),ot=(e,t,n)=>te(te(te(C,w(e)),w(t)),w(n)),rt=e=>He((()=>(e=>Ve(e,ue,Ne))(e)?we(e):0)),lt=()=>He((()=>we({}))),st=(e,t)=>{if(-1==n)return;it();const o=null==e?void 0:e();return at(t),o},it=()=>(n++,dt),at=e=>(n>0&&(n--,0==n&&(t=!K(i),n=1,Be(1),t&&qe(1),n=-1,(null==e?void 0:e(le(i,(e=>le(e,(e=>le(e,(e=>[...e]),(([e,t])=>e===t))),be)),be),le(c,(e=>le(e,le)))))&&(n=1,X(i,((e,t)=>X(e,((e,n)=>X(e,(([e],o)=>Ce(dt,t,n,o,e))))))),n=-1,t=!1),$(q[0],void 0,t),Be(0),t&&qe(0),$(q[1],void 0,t),n=0,b([i,c,o,r,l],V))),dt),dt={getTables:$e,getTableIds:Ze,getTable:e=>le(te(C,w(e)),le),getRowIds:et,getSortedRowIds:tt,getRow:(e,t)=>le(te(te(C,w(e)),w(t))),getCellIds:nt,getCell:ot,hasTables:()=>!K(C),hasTable:e=>G(C,w(e)),hasRow:(e,t)=>G(te(C,w(e)),w(t)),hasCell:(e,t,n)=>G(te(te(C,w(e)),w(t)),w(n)),getJson:()=>D(C),getSchemaJson:()=>D(v),setTables:rt,setTable:(e,t)=>He((e=>ue(t,e)?Le(e,t):0),e),setRow:(e,t,n)=>He(((e,t)=>ve(w(e),w(t),n)?xe(w(e),Ae(w(e)),w(t),n):0),e,t),addRow:(e,t)=>st((()=>{let n;return ve(e,n,t)&&(e=w(e),xe(e,Ae(e),n=Me(e),t)),n})),setPartialRow:(e,t,n)=>He(((e,t)=>{if(ve(e,t,n,1)){const o=Ae(e);Te(n,((n,r)=>ke(e,o,t,r,n)))}}),e,t),setCell:(e,t,n,o)=>He(((e,t,n)=>W(fe(e,t,n,_(o)?o(ot(e,t,n)):o),(o=>ke(e,Ae(e),t,n,o)))),e,t,n),setJson:e=>{try{"{}"===e?lt():rt(F(e))}catch(e){}return dt},setSchema:t=>He((()=>{if((e=(e=>Ve(e,(e=>Ve(e,(e=>{if(!Ve(e,((e,t)=>L([a,d],t))))return!1;const t=e.type;return!(!B(t)&&t!=s||(me(e.default)!=t&&Se(e,d),0))})))))(t))&&(ye(t),!K(C))){const e=$e();lt(),rt(e)}})),delTables:lt,delTable:e=>He((e=>G(C,e)?Oe(e):0),e),delRow:(e,t)=>He(((e,t)=>W(te(C,e),(n=>G(n,t)?De(e,n,t):0))),e,t),delCell:(e,t,n,o)=>He(((e,t,n)=>W(te(C,e),(r=>W(te(r,t),(l=>G(l,n)?Fe(e,r,t,l,n,o):0))))),e,t,n),delSchema:()=>He((()=>{ye({}),e=!1})),transaction:st,startTransaction:it,finishTransaction:at,forEachTable:e=>X(C,((t,n)=>e(n,(e=>X(t,((t,n)=>e(n,(e=>ne(t,e))))))))),forEachRow:(e,t)=>X(te(C,w(e)),((e,n)=>t(n,(t=>ne(e,t))))),forEachCell:(e,t,n)=>ne(te(te(C,w(e)),w(t)),n),addSortedRowIdsListener:(e,t,n,o,r,l,s)=>{let i=tt(e,t,n,o,r);return H((()=>{const s=tt(e,t,n,o,r);I(s,i)||(i=s,l(dt,e,t,n,o,r,i))}),O[s?1:0],[e,t])},addWillFinishTransactionListener:e=>H(e,q[0]),addDidFinishTransactionListener:e=>H(e,q[1]),callListener:e=>(ae(e,[Ze,et,nt],(e=>N(e[2])?[]:Ge(ot(...e)))),dt),delListener:e=>(U(e),dt),getListenerStats:()=>({}),createStore:Ye};return Te({Tables:[0,x],TableIds:[0,E],[h]:[1,P],[g]:[1,A],Row:[2,j],[p]:[2,J],[y]:[3,Q],InvalidCell:[3,z]},(([e,t],n)=>{dt[f+n+u]=(...n)=>H(n[e],t[n[e+1]?1:0],e>0?k(n,0,e):void 0)})),Re(dt)};e.createCheckpoints=xe,e.createCustomPersister=De,e.createFilePersister=(e,n)=>{let o;return De(e,(()=>ze(void 0,null,(function*(){try{return yield t.promises.readFile(n,c)}catch(e){}}))),(e=>ze(void 0,null,(function*(){try{yield t.promises.writeFile(n,e,c)}catch(e){}}))),(e=>{o=t.watch(n,e)}),(()=>{null==o||o.close(),o=void 0}))},e.createIndexes=Pe,e.createLocalPersister=(e,t)=>Qe(e,t,localStorage),e.createMetrics=Ae,e.createQueries=He,e.createRelationships=$e,e.createRemotePersister=(e,t,n,o)=>{let r,l;return De(e,(()=>Ne(void 0,null,(function*(){const e=yield fetch(t);return l=We(e),e.text()}))),(e=>Ne(void 0,null,(function*(){return yield fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e})}))),(e=>{r=setInterval((()=>Ne(void 0,null,(function*(){const n=yield fetch(t,{method:"HEAD"}),o=We(n);N(l)||N(o)||o==l||(l=o,e())}))),1e3*o)}),(()=>{W(r,clearInterval),r=void 0}))},e.createSessionPersister=(e,t)=>Qe(e,t,sessionStorage),e.createStore=Ye,e.defaultSorter=Ee,Object.defineProperty(e,"__esModule",{value:!0})},"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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,34 +58,35 @@
|
|
|
58
58
|
"publishPackage": "gulp publishPackage"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/cli": "^7.
|
|
62
|
-
"@babel/core": "^7.19.
|
|
63
|
-
"@babel/preset-env": "^7.19.
|
|
61
|
+
"@babel/cli": "^7.19.3",
|
|
62
|
+
"@babel/core": "^7.19.3",
|
|
63
|
+
"@babel/preset-env": "^7.19.3",
|
|
64
64
|
"@babel/preset-react": "^7.18.6",
|
|
65
65
|
"@babel/preset-typescript": "^7.18.6",
|
|
66
66
|
"@rollup/plugin-replace": "^4.0.0",
|
|
67
67
|
"@types/asciichart": "^1.5.6",
|
|
68
68
|
"@types/expect-puppeteer": "^5.0.1",
|
|
69
69
|
"@types/http-server": "^0.12.1",
|
|
70
|
-
"@types/jest": "^29.
|
|
70
|
+
"@types/jest": "^29.1.1",
|
|
71
71
|
"@types/jest-environment-puppeteer": "^5.0.2",
|
|
72
72
|
"@types/less": "^3.0.3",
|
|
73
|
-
"@types/node": "^18.7.
|
|
73
|
+
"@types/node": "^18.7.23",
|
|
74
74
|
"@types/puppeteer": "^5.4.6",
|
|
75
75
|
"@types/react": "^17.0.41",
|
|
76
76
|
"@types/react-dom": "^17.0.14",
|
|
77
77
|
"@types/react-test-renderer": "^17.0.1",
|
|
78
78
|
"@types/tmp": "^0.2.3",
|
|
79
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
80
|
-
"@typescript-eslint/parser": "^5.
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
80
|
+
"@typescript-eslint/parser": "^5.38.1",
|
|
81
81
|
"asciichart": "^1.5.25",
|
|
82
82
|
"babel-eslint": "^10.1.0",
|
|
83
|
-
"babel-jest": "^29.
|
|
83
|
+
"babel-jest": "^29.1.2",
|
|
84
84
|
"babel-preset-minify": "^0.5.2",
|
|
85
|
+
"buffer-replace": "^1.0.0",
|
|
85
86
|
"country-flag-emoji-json": "^2.0.0",
|
|
86
|
-
"cspell": "^6.
|
|
87
|
-
"esbuild": "^0.15.
|
|
88
|
-
"eslint": "^8.
|
|
87
|
+
"cspell": "^6.12.0",
|
|
88
|
+
"esbuild": "^0.15.10",
|
|
89
|
+
"eslint": "^8.24.0",
|
|
89
90
|
"eslint-config-prettier": "^8.5.0",
|
|
90
91
|
"eslint-plugin-jest": "^27.0.4",
|
|
91
92
|
"eslint-plugin-jsdoc": "^39.3.6",
|
|
@@ -94,8 +95,8 @@
|
|
|
94
95
|
"gulp": "^4.0.2",
|
|
95
96
|
"gulp-gzip": "^1.4.2",
|
|
96
97
|
"http-server": "^14.1.1",
|
|
97
|
-
"jest": "^29.
|
|
98
|
-
"jest-environment-jsdom": "^29.
|
|
98
|
+
"jest": "^29.1.2",
|
|
99
|
+
"jest-environment-jsdom": "^29.1.2",
|
|
99
100
|
"jest-fetch-mock": "^3.0.3",
|
|
100
101
|
"jest-puppeteer": "^6.1.1",
|
|
101
102
|
"less": "^4.1.3",
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
"react": "^17.0.2",
|
|
105
106
|
"react-dom": "^17.0.2",
|
|
106
107
|
"react-test-renderer": "^17.0.2",
|
|
107
|
-
"rollup": "^2.79.
|
|
108
|
+
"rollup": "^2.79.1",
|
|
108
109
|
"rollup-plugin-esbuild": "^4.10.1",
|
|
109
110
|
"rollup-plugin-gzip": "^3.0.1",
|
|
110
111
|
"rollup-plugin-prettier": "^2.2.2",
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
"tinydocs": "^0.1.15",
|
|
113
114
|
"tmp": "^0.2.1",
|
|
114
115
|
"ts-unused-exports": "^8.0.0",
|
|
115
|
-
"typescript": "4.8.
|
|
116
|
+
"typescript": "4.8.4"
|
|
116
117
|
},
|
|
117
118
|
"peerDependencies": {
|
|
118
119
|
"react": "^17.0.0"
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for local‑first apps.</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://www.inkandswitch.com/local-first/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Familiar concepts of <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>, and <a href="#apply-schemas-to-tables">schematization</a> to model your data domain.</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><em>NEW!</em> <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></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">3.5kB - 7.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/#v2-
|
|
1
|
+
<section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for local‑first apps.</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://www.inkandswitch.com/local-first/" target="_blank">anyway</a>?</p><p><em>TinyBase is a smart new way to structure your local app data:</em></p><ul><li>Familiar concepts of <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>, and <a href="#apply-schemas-to-tables">schematization</a> to model your data domain.</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><em>NEW!</em> <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></ul><p><em>Tiny by name, tiny by nature</em>, TinyBase only costs <a href="#did-we-say-tiny">3.5kB - 7.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/#v2-1"><em>NEW!</em> v2.1 release</a></p><hr><p><a id="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="set-and-get-tables-rows-and-cells">Set and get tables, rows, and cells.</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/table"><code>Table</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a>, or <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values by their <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a>. And of course you can easily get the values back out again.</p><p>Read more about setting and changing 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()
|
|
@@ -235,4 +235,4 @@ console.log(store.getCell('pets', 'felix', 'sold'));
|
|
|
235
235
|
// -> false
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
<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>3.5kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>7.8kB</em>.</p><p>The <code>ui-react</code> adaptor is just another <em>3.2kB</em>, and everything is fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured 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>3.5kB</td><td>7.7kB</td><td>33.
|
|
238
|
+
<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>3.5kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>7.8kB</em>.</p><p>The <code>ui-react</code> adaptor is just another <em>3.2kB</em>, and everything is fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured 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>3.5kB</td><td>7.7kB</td><td>33.1kB</td><td>127.2kB</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.6kB</td><td>29.2kB</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.4kB</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.6kB</td><td>16.6kB</td><td>42.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries">queries</a></th><td>2.6kB</td><td>5.5kB</td><td>24.9kB</td><td>106.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints">checkpoints</a></th><td>1.4kB</td><td>2.8kB</td><td>11.2kB</td><td>33.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters">persisters</a></th><td>0.8kB</td><td>1.6kB</td><td>5.0kB</td><td>26.8kB</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>7.8kB</td><td>18.4kB</td><td>80.8kB</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,246</td><td>1,246</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,347</td><td>1,347</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>507</td><td>507</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>469</td><td>469</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">2,134</td></tr><tr><th class="right">Assertions</th><td colspan="3">11,009</td></tr></tbody></table></div><hr><p><a id="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> and <a href="https://facebook.com/tinybasejs">Facebook</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/2.1.0">NPM</a>.</li><li><a href="https://github.com/tinyplex/tinybase/issues">Issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was an interesting exercise 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 we hope you enjoy using it!</p></section>
|