tinybase 4.6.6 → 4.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";const t=Promise,e=clearInterval,a=t=>null==t,s=(t,e,s)=>a(t)?s?.():e(t),n=e=>new t(e),o=async e=>t.all(e),r=(t,e)=>t.map(e),c=(t,...e)=>t.push(...e),i=Object,y=t=>i.getPrototypeOf(t),l=i.keys,d=i.freeze,u=t=>(t=>!a(t)&&s(y(t),(t=>t==i.prototype||a(y(t))),(()=>!0)))(t)&&0==(t=>l(t).length)(t),w=t=>new Map(t),h=(t,e)=>t?.get(e),p=(t,e,s)=>{return a(s)?(n=t,o=e,n?.delete(o),t):t?.set(e,s);var n,o},v=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||p(t,e,a()),h(t,e)},g=w(),A=w(),S=globalThis.window,b=["t","v"],f={keyPath:"k"},L=async(t,e)=>{const n=((e,a)=>r(i.entries(e),(([e,a])=>j(t,"put",{k:e,v:a}))))(e);r(await j(t,"getAllKeys"),(o=>((t,e)=>!a(((t,e)=>s(t,(t=>t[e])))(t,e)))(e,o)?0:c(n,j(t,"delete",o)))),await o(n)},j=async(t,e,a)=>n(((s,n)=>{const o=t[e](a);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${e} error`)}));exports.createIndexedDbPersister=(t,y,l=1,w)=>{const k=async(t,e=[],a=0)=>n(((s,n)=>{const c=S.indexedDB.open(y,a?2:void 0);c.onupgradeneeded=()=>a&&r(b,(t=>{try{c.result.createObjectStore(t,f)}catch{}})),c.onsuccess=async()=>{try{const a=c.result.transaction(b,"readwrite"),n=await o(r(b,(async(s,n)=>await t(a.objectStore(s),e[n]))));c.result.close(),s(n)}catch(t){c.result.close(),n(t)}},c.onerror=()=>n("indexedDB.open error")}));return((t,e,n,o,r,i,[y,l]=[],w=[])=>{let S,b,f,L=0,j=0;v(g,w,(()=>0)),v(A,w,(()=>[]));const k=async t=>(2!=L&&(L=1,await x.schedule((async()=>{await t(),L=0}))),x),x={load:async(a,s)=>await k((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},s={})=>(x.stopAutoLoad(),await x.load(a,s),j=1,f=o((async(a,s)=>{if(s){const e=s();await k((async()=>t.setTransactionChanges(e)))}else await k((async()=>{try{t.setContent(a?.()??await e())}catch(t){i?.(t)}}))})),x),stopAutoLoad:()=>(j&&(r(f),f=void 0,j=0),x),save:async e=>(1!=L&&(L=2,await x.schedule((async()=>{try{await n(t.getContent,e)}catch(t){i?.(t)}L=0}))),x),startAutoSave:async()=>(await x.stopAutoSave().save(),S=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();u(a)&&u(s)||x.save((()=>[a,s]))})),x),stopAutoSave:()=>(s(S,t.delListener),S=void 0,x),schedule:async(...t)=>(c(h(A,w),...t),await(async()=>{if(!h(g,w)){for(p(g,w,1);!a((t=h(A,w),b=t.shift()));)try{await b()}catch(t){i?.(t)}p(g,w,0)}var t})(),x),getStore:()=>t,destroy:()=>x.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return y&&(x[y]=()=>l),d(x)})(t,(async()=>await k((async t=>((t=[])=>i.fromEntries(t))(r(await j(t,"getAll"),(({k:t,v:e})=>[t,e])))))),(async t=>await k((async(t,e)=>await L(t,e)),t(),1)),(t=>setInterval(t,1e3*l)),(t=>e(t)),w,["getDbName",y])},exports.objectStoreMatch=L;
1
+ "use strict";const t=Promise,e=clearInterval,a=t=>null==t,s=(t,e,s)=>a(t)?s?.():e(t),n=e=>new t(e),o=async e=>t.all(e),r=(t,e)=>t.map(e),c=(t,...e)=>t.push(...e),i=Object,y=t=>i.getPrototypeOf(t),d=i.keys,l=i.freeze,u=t=>(t=>!a(t)&&s(y(t),(t=>t==i.prototype||a(y(t))),(()=>!0)))(t)&&0==(t=>d(t).length)(t),w=t=>new Map(t),h=(t,e)=>t?.get(e),p=(t,e,s)=>{return a(s)?(n=t,o=e,n?.delete(o),t):t?.set(e,s);var n,o},v=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||p(t,e,a()),h(t,e)},g=w(),A=w(),S=globalThis.window,b=["t","v"],f={keyPath:"k"},x=async(t,e)=>{const n=((e,a)=>r(i.entries(e),(([e,a])=>D(t,"put",{k:e,v:a}))))(e);r(await D(t,"getAllKeys"),(o=>((t,e)=>!a(((t,e)=>s(t,(t=>t[e])))(t,e)))(e,o)?0:c(n,D(t,"delete",o)))),await o(n)},D=async(t,e,a)=>n(((s,n)=>{const o=t[e](a);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${e} error`)}));exports.createIndexedDbPersister=(t,y,d=1,w)=>{const L=async(t,e=[],a=0)=>n(((s,n)=>{const c=(S?S.indexedDB:indexedDB).open(y,a?2:void 0);c.onupgradeneeded=()=>a&&r(b,(t=>{try{c.result.createObjectStore(t,f)}catch{}})),c.onsuccess=async()=>{try{const a=c.result.transaction(b,"readwrite"),n=await o(r(b,(async(s,n)=>await t(a.objectStore(s),e[n]))));c.result.close(),s(n)}catch(t){c.result.close(),n(t)}},c.onerror=()=>n("indexedDB.open error")}));return((t,e,n,o,r,i,[y,d]=[],w=[])=>{let S,b,f,x=0,D=0;v(g,w,(()=>0)),v(A,w,(()=>[]));const L=async t=>(2!=x&&(x=1,await j.schedule((async()=>{await t(),x=0}))),j),j={load:async(a,s)=>await L((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},s={})=>(j.stopAutoLoad(),await j.load(a,s),D=1,f=o((async(a,s)=>{if(s){const e=s();await L((async()=>t.setTransactionChanges(e)))}else await L((async()=>{try{t.setContent(a?.()??await e())}catch(t){i?.(t)}}))})),j),stopAutoLoad:()=>(D&&(r(f),f=void 0,D=0),j),save:async e=>(1!=x&&(x=2,await j.schedule((async()=>{try{await n(t.getContent,e)}catch(t){i?.(t)}x=0}))),j),startAutoSave:async()=>(await j.stopAutoSave().save(),S=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();u(a)&&u(s)||j.save((()=>[a,s]))})),j),stopAutoSave:()=>(s(S,t.delListener),S=void 0,j),schedule:async(...t)=>(c(h(A,w),...t),await(async()=>{if(!h(g,w)){for(p(g,w,1);!a((t=h(A,w),b=t.shift()));)try{await b()}catch(t){i?.(t)}p(g,w,0)}var t})(),j),getStore:()=>t,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return y&&(j[y]=()=>d),l(j)})(t,(async()=>await L((async t=>((t=[])=>i.fromEntries(t))(r(await D(t,"getAll"),(({k:t,v:e})=>[t,e])))))),(async t=>await L((async(t,e)=>await x(t,e)),t(),1)),(t=>setInterval(t,1e3*d)),(t=>e(t)),w,["getDbName",y])},exports.objectStoreMatch=x;
@@ -1 +1 @@
1
- "use strict";const e=Promise,t=clearInterval,n=e=>null==e,o=(e,t,o)=>n(e)?null==o?void 0:o():t(e),l=t=>new e(t),r=t=>{return n=function*(){return e.all(t)},new Promise(((e,t)=>{var o=e=>{try{r(n.next(e))}catch(e){t(e)}},l=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((n=n.apply(void 0,null)).next())}));var n},u=(e,t)=>e.map(t),i=(e,...t)=>e.push(...t),d=Object,c=e=>d.getPrototypeOf(e),s=d.keys,a=d.freeze,v=e=>(e=>!n(e)&&o(c(e),(e=>e==d.prototype||n(c(e))),(()=>!0)))(e)&&0==(e=>s(e).length)(e),y=e=>new Map(e),f=(e,t)=>null==e?void 0:e.get(t),h=(e,t,o)=>{return n(o)?(r=t,null==(l=e)||l.delete(r),e):null==e?void 0:e.set(t,o);var l,r},p=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||h(e,t,n()),f(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const w=y(),x=y();var m=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const A=globalThis.window,P=["t","v"],S={keyPath:"k"},b=(e,t)=>m(void 0,null,(function*(){const l=((t,n)=>u(d.entries(t),(([t,n])=>L(e,"put",{k:t,v:n}))))(t);u(yield L(e,"getAllKeys"),(r=>((e,t)=>!n(((e,t)=>o(e,(e=>e[t])))(e,t)))(t,r)?0:i(l,L(e,"delete",r)))),yield r(l)})),L=(e,t,n)=>m(void 0,null,(function*(){return l(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))}));exports.createIndexedDbPersister=(e,c,s=1,y)=>{const j=(e,...t)=>m(void 0,[e,...t],(function*(e,t=[],n=0){return l(((o,l)=>{const i=A.indexedDB.open(c,n?2:void 0);i.onupgradeneeded=()=>n&&u(P,(e=>{try{i.result.createObjectStore(e,S)}catch(e){}})),i.onsuccess=()=>m(void 0,null,(function*(){try{const n=i.result.transaction(P,"readwrite"),l=yield r(u(P,((o,l)=>m(void 0,null,(function*(){return yield e(n.objectStore(o),t[l])})))));i.result.close(),o(l)}catch(e){i.result.close(),l(e)}})),i.onerror=()=>l("indexedDB.open error")}))}));return((e,t,l,r,u,d,[c,s]=[],y=[])=>{let m,A,P,S=0,b=0;p(w,y,(()=>0)),p(x,y,(()=>[]));const L=e=>g(void 0,null,(function*(){return 2!=S&&(S=1,yield j.schedule((()=>g(void 0,null,(function*(){yield e(),S=0}))))),j})),j={load:(n,o)=>g(void 0,null,(function*(){return yield L((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},o={}){return j.stopAutoLoad(),yield j.load(n,o),b=1,P=r(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield L((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield L((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==d||d(e)}}))))})))),j})),stopAutoLoad:()=>(b&&(u(P),P=void 0,b=0),j),save:t=>g(void 0,null,(function*(){return 1!=S&&(S=2,yield j.schedule((()=>g(void 0,null,(function*(){try{yield l(e.getContent,t)}catch(e){null==d||d(e)}S=0}))))),j})),startAutoSave:()=>g(void 0,null,(function*(){return yield j.stopAutoSave().save(),m=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||j.save((()=>[n,o]))})),j})),stopAutoSave:()=>(o(m,e.delListener),m=void 0,j),schedule:(...e)=>g(void 0,null,(function*(){return i(f(x,y),...e),yield g(void 0,null,(function*(){if(!f(w,y)){for(h(w,y,1);!n((e=f(x,y),A=e.shift()));)try{yield A()}catch(e){null==d||d(e)}h(w,y,0)}var e})),j})),getStore:()=>e,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(j[c]=()=>s),a(j)})(e,(()=>m(void 0,null,(function*(){return yield j((e=>m(void 0,null,(function*(){return((e=[])=>d.fromEntries(e))(u(yield L(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>m(void 0,null,(function*(){return yield j(((e,t)=>m(void 0,null,(function*(){return yield b(e,t)}))),e(),1)}))),(e=>setInterval(e,1e3*s)),(e=>t(e)),y,["getDbName",c])},exports.objectStoreMatch=b;
1
+ "use strict";const e=Promise,t=clearInterval,n=e=>null==e,o=(e,t,o)=>n(e)?null==o?void 0:o():t(e),l=t=>new e(t),r=t=>{return n=function*(){return e.all(t)},new Promise(((e,t)=>{var o=e=>{try{r(n.next(e))}catch(e){t(e)}},l=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((n=n.apply(void 0,null)).next())}));var n},u=(e,t)=>e.map(t),i=(e,...t)=>e.push(...t),d=Object,c=e=>d.getPrototypeOf(e),s=d.keys,a=d.freeze,v=e=>(e=>!n(e)&&o(c(e),(e=>e==d.prototype||n(c(e))),(()=>!0)))(e)&&0==(e=>s(e).length)(e),y=e=>new Map(e),f=(e,t)=>null==e?void 0:e.get(t),h=(e,t,o)=>{return n(o)?(r=t,null==(l=e)||l.delete(r),e):null==e?void 0:e.set(t,o);var l,r},p=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||h(e,t,n()),f(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const x=y(),w=y();var m=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const A=globalThis.window,P=["t","v"],S={keyPath:"k"},b=(e,t)=>m(void 0,null,(function*(){const l=((t,n)=>u(d.entries(t),(([t,n])=>D(e,"put",{k:t,v:n}))))(t);u(yield D(e,"getAllKeys"),(r=>((e,t)=>!n(((e,t)=>o(e,(e=>e[t])))(e,t)))(t,r)?0:i(l,D(e,"delete",r)))),yield r(l)})),D=(e,t,n)=>m(void 0,null,(function*(){return l(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))}));exports.createIndexedDbPersister=(e,c,s=1,y)=>{const L=(e,...t)=>m(void 0,[e,...t],(function*(e,t=[],n=0){return l(((o,l)=>{const i=(A?A.indexedDB:indexedDB).open(c,n?2:void 0);i.onupgradeneeded=()=>n&&u(P,(e=>{try{i.result.createObjectStore(e,S)}catch(e){}})),i.onsuccess=()=>m(void 0,null,(function*(){try{const n=i.result.transaction(P,"readwrite"),l=yield r(u(P,((o,l)=>m(void 0,null,(function*(){return yield e(n.objectStore(o),t[l])})))));i.result.close(),o(l)}catch(e){i.result.close(),l(e)}})),i.onerror=()=>l("indexedDB.open error")}))}));return((e,t,l,r,u,d,[c,s]=[],y=[])=>{let m,A,P,S=0,b=0;p(x,y,(()=>0)),p(w,y,(()=>[]));const D=e=>g(void 0,null,(function*(){return 2!=S&&(S=1,yield L.schedule((()=>g(void 0,null,(function*(){yield e(),S=0}))))),L})),L={load:(n,o)=>g(void 0,null,(function*(){return yield D((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},o={}){return L.stopAutoLoad(),yield L.load(n,o),b=1,P=r(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield D((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield D((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==d||d(e)}}))))})))),L})),stopAutoLoad:()=>(b&&(u(P),P=void 0,b=0),L),save:t=>g(void 0,null,(function*(){return 1!=S&&(S=2,yield L.schedule((()=>g(void 0,null,(function*(){try{yield l(e.getContent,t)}catch(e){null==d||d(e)}S=0}))))),L})),startAutoSave:()=>g(void 0,null,(function*(){return yield L.stopAutoSave().save(),m=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||L.save((()=>[n,o]))})),L})),stopAutoSave:()=>(o(m,e.delListener),m=void 0,L),schedule:(...e)=>g(void 0,null,(function*(){return i(f(w,y),...e),yield g(void 0,null,(function*(){if(!f(x,y)){for(h(x,y,1);!n((e=f(w,y),A=e.shift()));)try{yield A()}catch(e){null==d||d(e)}h(x,y,0)}var e})),L})),getStore:()=>e,destroy:()=>L.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(L[c]=()=>s),a(L)})(e,(()=>m(void 0,null,(function*(){return yield L((e=>m(void 0,null,(function*(){return((e=[])=>d.fromEntries(e))(u(yield D(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>m(void 0,null,(function*(){return yield L(((e,t)=>m(void 0,null,(function*(){return yield b(e,t)}))),e(),1)}))),(e=>setInterval(e,1e3*s)),(e=>t(e)),y,["getDbName",c])},exports.objectStoreMatch=b;
@@ -225,7 +225,10 @@ const createIndexedDbPersister = (
225
225
  ) => {
226
226
  const forObjectStores = async (forObjectStore, args = [], create = 0) =>
227
227
  promiseNew((resolve, reject) => {
228
- const request = WINDOW.indexedDB.open(dbName, create ? 2 : void 0);
228
+ const request = (WINDOW ? WINDOW.indexedDB : indexedDB).open(
229
+ dbName,
230
+ create ? 2 : void 0,
231
+ );
229
232
  request.onupgradeneeded = () =>
230
233
  create &&
231
234
  arrayMap(OBJECT_STORE_NAMES, (objectStoreName) => {
@@ -1 +1 @@
1
- const e=Promise,t=clearInterval,n=e=>null==e,o=(e,t,o)=>n(e)?null==o?void 0:o():t(e),l=t=>new e(t),r=t=>{return n=function*(){return e.all(t)},new Promise(((e,t)=>{var o=e=>{try{r(n.next(e))}catch(e){t(e)}},l=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((n=n.apply(void 0,null)).next())}));var n},u=(e,t)=>e.map(t),i=(e,...t)=>e.push(...t),d=Object,c=e=>d.getPrototypeOf(e),s=d.keys,a=d.freeze,v=e=>(e=>!n(e)&&o(c(e),(e=>e==d.prototype||n(c(e))),(()=>!0)))(e)&&0==(e=>s(e).length)(e),y=e=>new Map(e),f=(e,t)=>null==e?void 0:e.get(t),h=(e,t,o)=>{return n(o)?(r=t,null==(l=e)||l.delete(r),e):null==e?void 0:e.set(t,o);var l,r},p=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||h(e,t,n()),f(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const w=y(),m=y();var A=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const x=globalThis.window,P=["t","v"],S={keyPath:"k"},b=(e,t)=>A(void 0,null,(function*(){const l=((t,n)=>u(d.entries(t),(([t,n])=>L(e,"put",{k:t,v:n}))))(t);u(yield L(e,"getAllKeys"),(r=>((e,t)=>!n(((e,t)=>o(e,(e=>e[t])))(e,t)))(t,r)?0:i(l,L(e,"delete",r)))),yield r(l)})),L=(e,t,n)=>A(void 0,null,(function*(){return l(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))})),k=(e,c,s=1,y)=>{const k=(e,...t)=>A(void 0,[e,...t],(function*(e,t=[],n=0){return l(((o,l)=>{const i=x.indexedDB.open(c,n?2:void 0);i.onupgradeneeded=()=>n&&u(P,(e=>{try{i.result.createObjectStore(e,S)}catch(e){}})),i.onsuccess=()=>A(void 0,null,(function*(){try{const n=i.result.transaction(P,"readwrite"),l=yield r(u(P,((o,l)=>A(void 0,null,(function*(){return yield e(n.objectStore(o),t[l])})))));i.result.close(),o(l)}catch(e){i.result.close(),l(e)}})),i.onerror=()=>l("indexedDB.open error")}))}));return((e,t,l,r,u,d,[c,s]=[],y=[])=>{let A,x,P,S=0,b=0;p(w,y,(()=>0)),p(m,y,(()=>[]));const L=e=>g(void 0,null,(function*(){return 2!=S&&(S=1,yield k.schedule((()=>g(void 0,null,(function*(){yield e(),S=0}))))),k})),k={load:(n,o)=>g(void 0,null,(function*(){return yield L((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},o={}){return k.stopAutoLoad(),yield k.load(n,o),b=1,P=r(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield L((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield L((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==d||d(e)}}))))})))),k})),stopAutoLoad:()=>(b&&(u(P),P=void 0,b=0),k),save:t=>g(void 0,null,(function*(){return 1!=S&&(S=2,yield k.schedule((()=>g(void 0,null,(function*(){try{yield l(e.getContent,t)}catch(e){null==d||d(e)}S=0}))))),k})),startAutoSave:()=>g(void 0,null,(function*(){return yield k.stopAutoSave().save(),A=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||k.save((()=>[n,o]))})),k})),stopAutoSave:()=>(o(A,e.delListener),A=void 0,k),schedule:(...e)=>g(void 0,null,(function*(){return i(f(m,y),...e),yield g(void 0,null,(function*(){if(!f(w,y)){for(h(w,y,1);!n((e=f(m,y),x=e.shift()));)try{yield x()}catch(e){null==d||d(e)}h(w,y,0)}var e})),k})),getStore:()=>e,destroy:()=>k.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(k[c]=()=>s),a(k)})(e,(()=>A(void 0,null,(function*(){return yield k((e=>A(void 0,null,(function*(){return((e=[])=>d.fromEntries(e))(u(yield L(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>A(void 0,null,(function*(){return yield k(((e,t)=>A(void 0,null,(function*(){return yield b(e,t)}))),e(),1)}))),(e=>setInterval(e,1e3*s)),(e=>t(e)),y,["getDbName",c])};export{k as createIndexedDbPersister,b as objectStoreMatch};
1
+ const e=Promise,t=clearInterval,n=e=>null==e,o=(e,t,o)=>n(e)?null==o?void 0:o():t(e),l=t=>new e(t),r=t=>{return n=function*(){return e.all(t)},new Promise(((e,t)=>{var o=e=>{try{r(n.next(e))}catch(e){t(e)}},l=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((n=n.apply(void 0,null)).next())}));var n},u=(e,t)=>e.map(t),i=(e,...t)=>e.push(...t),d=Object,c=e=>d.getPrototypeOf(e),s=d.keys,a=d.freeze,v=e=>(e=>!n(e)&&o(c(e),(e=>e==d.prototype||n(c(e))),(()=>!0)))(e)&&0==(e=>s(e).length)(e),y=e=>new Map(e),f=(e,t)=>null==e?void 0:e.get(t),h=(e,t,o)=>{return n(o)?(r=t,null==(l=e)||l.delete(r),e):null==e?void 0:e.set(t,o);var l,r},p=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||h(e,t,n()),f(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const w=y(),m=y();var x=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{i(n.next(e))}catch(e){l(e)}},u=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,u);i((n=n.apply(e,t)).next())}));const A=globalThis.window,P=["t","v"],S={keyPath:"k"},b=(e,t)=>x(void 0,null,(function*(){const l=((t,n)=>u(d.entries(t),(([t,n])=>L(e,"put",{k:t,v:n}))))(t);u(yield L(e,"getAllKeys"),(r=>((e,t)=>!n(((e,t)=>o(e,(e=>e[t])))(e,t)))(t,r)?0:i(l,L(e,"delete",r)))),yield r(l)})),L=(e,t,n)=>x(void 0,null,(function*(){return l(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))})),k=(e,c,s=1,y)=>{const k=(e,...t)=>x(void 0,[e,...t],(function*(e,t=[],n=0){return l(((o,l)=>{const i=(A?A.indexedDB:indexedDB).open(c,n?2:void 0);i.onupgradeneeded=()=>n&&u(P,(e=>{try{i.result.createObjectStore(e,S)}catch(e){}})),i.onsuccess=()=>x(void 0,null,(function*(){try{const n=i.result.transaction(P,"readwrite"),l=yield r(u(P,((o,l)=>x(void 0,null,(function*(){return yield e(n.objectStore(o),t[l])})))));i.result.close(),o(l)}catch(e){i.result.close(),l(e)}})),i.onerror=()=>l("indexedDB.open error")}))}));return((e,t,l,r,u,d,[c,s]=[],y=[])=>{let x,A,P,S=0,b=0;p(w,y,(()=>0)),p(m,y,(()=>[]));const L=e=>g(void 0,null,(function*(){return 2!=S&&(S=1,yield k.schedule((()=>g(void 0,null,(function*(){yield e(),S=0}))))),k})),k={load:(n,o)=>g(void 0,null,(function*(){return yield L((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},o={}){return k.stopAutoLoad(),yield k.load(n,o),b=1,P=r(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield L((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield L((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==d||d(e)}}))))})))),k})),stopAutoLoad:()=>(b&&(u(P),P=void 0,b=0),k),save:t=>g(void 0,null,(function*(){return 1!=S&&(S=2,yield k.schedule((()=>g(void 0,null,(function*(){try{yield l(e.getContent,t)}catch(e){null==d||d(e)}S=0}))))),k})),startAutoSave:()=>g(void 0,null,(function*(){return yield k.stopAutoSave().save(),x=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||k.save((()=>[n,o]))})),k})),stopAutoSave:()=>(o(x,e.delListener),x=void 0,k),schedule:(...e)=>g(void 0,null,(function*(){return i(f(m,y),...e),yield g(void 0,null,(function*(){if(!f(w,y)){for(h(w,y,1);!n((e=f(m,y),A=e.shift()));)try{yield A()}catch(e){null==d||d(e)}h(w,y,0)}var e})),k})),getStore:()=>e,destroy:()=>k.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(k[c]=()=>s),a(k)})(e,(()=>x(void 0,null,(function*(){return yield k((e=>x(void 0,null,(function*(){return((e=[])=>d.fromEntries(e))(u(yield L(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>x(void 0,null,(function*(){return yield k(((e,t)=>x(void 0,null,(function*(){return yield b(e,t)}))),e(),1)}))),(e=>setInterval(e,1e3*s)),(e=>t(e)),y,["getDbName",c])};export{k as createIndexedDbPersister,b as objectStoreMatch};
@@ -1 +1 @@
1
- const t=Promise,a=clearInterval,e=t=>null==t,s=(t,a,s)=>e(t)?s?.():a(t),n=a=>new t(a),o=async a=>t.all(a),c=(t,a)=>t.map(a),r=(t,...a)=>t.push(...a),i=Object,y=t=>i.getPrototypeOf(t),l=i.keys,d=i.freeze,u=t=>(t=>!e(t)&&s(y(t),(t=>t==i.prototype||e(y(t))),(()=>!0)))(t)&&0==(t=>l(t).length)(t),w=t=>new Map(t),v=(t,a)=>t?.get(a),h=(t,a,s)=>{return e(s)?(n=t,o=a,n?.delete(o),t):t?.set(a,s);var n,o},p=(t,a,e)=>{var s,n;return s=t,n=a,s?.has(n)||h(t,a,e()),v(t,a)},g=w(),A=w(),S=globalThis.window,f=["t","v"],b={keyPath:"k"},L=async(t,a)=>{const n=((a,e)=>c(i.entries(a),(([a,e])=>k(t,"put",{k:a,v:e}))))(a);c(await k(t,"getAllKeys"),(o=>((t,a)=>!e(((t,a)=>s(t,(t=>t[a])))(t,a)))(a,o)?0:r(n,k(t,"delete",o)))),await o(n)},k=async(t,a,e)=>n(((s,n)=>{const o=t[a](e);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${a} error`)})),C=(t,y,l=1,w)=>{const C=async(t,a=[],e=0)=>n(((s,n)=>{const r=S.indexedDB.open(y,e?2:void 0);r.onupgradeneeded=()=>e&&c(f,(t=>{try{r.result.createObjectStore(t,b)}catch{}})),r.onsuccess=async()=>{try{const e=r.result.transaction(f,"readwrite"),n=await o(c(f,(async(s,n)=>await t(e.objectStore(s),a[n]))));r.result.close(),s(n)}catch(t){r.result.close(),n(t)}},r.onerror=()=>n("indexedDB.open error")}));return((t,a,n,o,c,i,[y,l]=[],w=[])=>{let S,f,b,L=0,k=0;p(g,w,(()=>0)),p(A,w,(()=>[]));const C=async t=>(2!=L&&(L=1,await j.schedule((async()=>{await t(),L=0}))),j),j={load:async(e,s)=>await C((async()=>{try{t.setContent(await a())}catch{t.setContent([e,s])}})),startAutoLoad:async(e={},s={})=>(j.stopAutoLoad(),await j.load(e,s),k=1,b=o((async(e,s)=>{if(s){const a=s();await C((async()=>t.setTransactionChanges(a)))}else await C((async()=>{try{t.setContent(e?.()??await a())}catch(t){i?.(t)}}))})),j),stopAutoLoad:()=>(k&&(c(b),b=void 0,k=0),j),save:async a=>(1!=L&&(L=2,await j.schedule((async()=>{try{await n(t.getContent,a)}catch(t){i?.(t)}L=0}))),j),startAutoSave:async()=>(await j.stopAutoSave().save(),S=t.addDidFinishTransactionListener(((t,a)=>{const[e,s]=a();u(e)&&u(s)||j.save((()=>[e,s]))})),j),stopAutoSave:()=>(s(S,t.delListener),S=void 0,j),schedule:async(...t)=>(r(v(A,w),...t),await(async()=>{if(!v(g,w)){for(h(g,w,1);!e((t=v(A,w),f=t.shift()));)try{await f()}catch(t){i?.(t)}h(g,w,0)}var t})(),j),getStore:()=>t,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return y&&(j[y]=()=>l),d(j)})(t,(async()=>await C((async t=>((t=[])=>i.fromEntries(t))(c(await k(t,"getAll"),(({k:t,v:a})=>[t,a])))))),(async t=>await C((async(t,a)=>await L(t,a)),t(),1)),(t=>setInterval(t,1e3*l)),(t=>a(t)),w,["getDbName",y])};export{C as createIndexedDbPersister,L as objectStoreMatch};
1
+ const t=Promise,a=clearInterval,e=t=>null==t,s=(t,a,s)=>e(t)?s?.():a(t),n=a=>new t(a),o=async a=>t.all(a),c=(t,a)=>t.map(a),r=(t,...a)=>t.push(...a),i=Object,y=t=>i.getPrototypeOf(t),l=i.keys,d=i.freeze,u=t=>(t=>!e(t)&&s(y(t),(t=>t==i.prototype||e(y(t))),(()=>!0)))(t)&&0==(t=>l(t).length)(t),w=t=>new Map(t),v=(t,a)=>t?.get(a),h=(t,a,s)=>{return e(s)?(n=t,o=a,n?.delete(o),t):t?.set(a,s);var n,o},p=(t,a,e)=>{var s,n;return s=t,n=a,s?.has(n)||h(t,a,e()),v(t,a)},g=w(),A=w(),S=globalThis.window,f=["t","v"],b={keyPath:"k"},L=async(t,a)=>{const n=((a,e)=>c(i.entries(a),(([a,e])=>k(t,"put",{k:a,v:e}))))(a);c(await k(t,"getAllKeys"),(o=>((t,a)=>!e(((t,a)=>s(t,(t=>t[a])))(t,a)))(a,o)?0:r(n,k(t,"delete",o)))),await o(n)},k=async(t,a,e)=>n(((s,n)=>{const o=t[a](e);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${a} error`)})),C=(t,y,l=1,w)=>{const C=async(t,a=[],e=0)=>n(((s,n)=>{const r=(S?S.indexedDB:indexedDB).open(y,e?2:void 0);r.onupgradeneeded=()=>e&&c(f,(t=>{try{r.result.createObjectStore(t,b)}catch{}})),r.onsuccess=async()=>{try{const e=r.result.transaction(f,"readwrite"),n=await o(c(f,(async(s,n)=>await t(e.objectStore(s),a[n]))));r.result.close(),s(n)}catch(t){r.result.close(),n(t)}},r.onerror=()=>n("indexedDB.open error")}));return((t,a,n,o,c,i,[y,l]=[],w=[])=>{let S,f,b,L=0,k=0;p(g,w,(()=>0)),p(A,w,(()=>[]));const C=async t=>(2!=L&&(L=1,await D.schedule((async()=>{await t(),L=0}))),D),D={load:async(e,s)=>await C((async()=>{try{t.setContent(await a())}catch{t.setContent([e,s])}})),startAutoLoad:async(e={},s={})=>(D.stopAutoLoad(),await D.load(e,s),k=1,b=o((async(e,s)=>{if(s){const a=s();await C((async()=>t.setTransactionChanges(a)))}else await C((async()=>{try{t.setContent(e?.()??await a())}catch(t){i?.(t)}}))})),D),stopAutoLoad:()=>(k&&(c(b),b=void 0,k=0),D),save:async a=>(1!=L&&(L=2,await D.schedule((async()=>{try{await n(t.getContent,a)}catch(t){i?.(t)}L=0}))),D),startAutoSave:async()=>(await D.stopAutoSave().save(),S=t.addDidFinishTransactionListener(((t,a)=>{const[e,s]=a();u(e)&&u(s)||D.save((()=>[e,s]))})),D),stopAutoSave:()=>(s(S,t.delListener),S=void 0,D),schedule:async(...t)=>(r(v(A,w),...t),await(async()=>{if(!v(g,w)){for(h(g,w,1);!e((t=v(A,w),f=t.shift()));)try{await f()}catch(t){i?.(t)}h(g,w,0)}var t})(),D),getStore:()=>t,destroy:()=>D.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return y&&(D[y]=()=>l),d(D)})(t,(async()=>await C((async t=>((t=[])=>i.fromEntries(t))(c(await k(t,"getAll"),(({k:t,v:a})=>[t,a])))))),(async t=>await C((async(t,a)=>await L(t,a)),t(),1)),(t=>setInterval(t,1e3*l)),(t=>a(t)),w,["getDbName",y])};export{C as createIndexedDbPersister,L as objectStoreMatch};
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";const e=Promise,a=clearInterval,s=t=>null==t,n=(t,e,a)=>s(t)?a?.():e(t),o=t=>new e(t),r=async t=>e.all(t),c=(t,e)=>t.map(e),i=(t,...e)=>t.push(...e),d=Object,y=t=>d.getPrototypeOf(t),l=d.keys,u=d.freeze,w=t=>(t=>!s(t)&&n(y(t),(t=>t==d.prototype||s(y(t))),(()=>!0)))(t)&&0==(t=>l(t).length)(t),p=t=>new Map(t),h=(t,e)=>t?.get(e),f=(t,e,a)=>{return s(a)?(n=t,o=e,n?.delete(o),t):t?.set(e,a);var n,o},v=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||f(t,e,a()),h(t,e)},g=p(),b=p(),A=globalThis.window,S=["t","v"],x={keyPath:"k"},j=async(t,e)=>{const a=((e,a)=>c(d.entries(e),(([e,a])=>m(t,"put",{k:e,v:a}))))(e);c(await m(t,"getAllKeys"),(o=>((t,e)=>!s(((t,e)=>n(t,(t=>t[e])))(t,e)))(e,o)?0:i(a,m(t,"delete",o)))),await r(a)},m=async(t,e,a)=>o(((s,n)=>{const o=t[e](a);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${e} error`)}));t.createIndexedDbPersister=(t,e,y=1,l)=>{const p=async(t,a=[],s=0)=>o(((n,o)=>{const i=A.indexedDB.open(e,s?2:void 0);i.onupgradeneeded=()=>s&&c(S,(t=>{try{i.result.createObjectStore(t,x)}catch{}})),i.onsuccess=async()=>{try{const e=i.result.transaction(S,"readwrite"),s=await r(c(S,(async(s,n)=>await t(e.objectStore(s),a[n]))));i.result.close(),n(s)}catch(t){i.result.close(),o(t)}},i.onerror=()=>o("indexedDB.open error")}));return((t,e,a,o,r,c,[d,y]=[],l=[])=>{let p,A,S,x=0,j=0;v(g,l,(()=>0)),v(b,l,(()=>[]));const m=async t=>(2!=x&&(x=1,await D.schedule((async()=>{await t(),x=0}))),D),D={load:async(a,s)=>await m((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},s={})=>(D.stopAutoLoad(),await D.load(a,s),j=1,S=o((async(a,s)=>{if(s){const e=s();await m((async()=>t.setTransactionChanges(e)))}else await m((async()=>{try{t.setContent(a?.()??await e())}catch(t){c?.(t)}}))})),D),stopAutoLoad:()=>(j&&(r(S),S=void 0,j=0),D),save:async e=>(1!=x&&(x=2,await D.schedule((async()=>{try{await a(t.getContent,e)}catch(t){c?.(t)}x=0}))),D),startAutoSave:async()=>(await D.stopAutoSave().save(),p=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();w(a)&&w(s)||D.save((()=>[a,s]))})),D),stopAutoSave:()=>(n(p,t.delListener),p=void 0,D),schedule:async(...t)=>(i(h(b,l),...t),await(async()=>{if(!h(g,l)){for(f(g,l,1);!s((t=h(b,l),A=t.shift()));)try{await A()}catch(t){c?.(t)}f(g,l,0)}var t})(),D),getStore:()=>t,destroy:()=>D.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(D[d]=()=>y),u(D)})(t,(async()=>await p((async t=>((t=[])=>d.fromEntries(t))(c(await m(t,"getAll"),(({k:t,v:e})=>[t,e])))))),(async t=>await p((async(t,e)=>await j(t,e)),t(),1)),(t=>setInterval(t,1e3*y)),(t=>a(t)),l,["getDbName",e])},t.objectStoreMatch=j},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterIndexedDb={});
1
+ var t,e;t=this,e=function(t){"use strict";const e=Promise,a=clearInterval,s=t=>null==t,n=(t,e,a)=>s(t)?a?.():e(t),o=t=>new e(t),r=async t=>e.all(t),c=(t,e)=>t.map(e),i=(t,...e)=>t.push(...e),d=Object,y=t=>d.getPrototypeOf(t),l=d.keys,u=d.freeze,w=t=>(t=>!s(t)&&n(y(t),(t=>t==d.prototype||s(y(t))),(()=>!0)))(t)&&0==(t=>l(t).length)(t),p=t=>new Map(t),h=(t,e)=>t?.get(e),f=(t,e,a)=>{return s(a)?(n=t,o=e,n?.delete(o),t):t?.set(e,a);var n,o},v=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||f(t,e,a()),h(t,e)},g=p(),b=p(),A=globalThis.window,S=["t","v"],x={keyPath:"k"},D=async(t,e)=>{const a=((e,a)=>c(d.entries(e),(([e,a])=>j(t,"put",{k:e,v:a}))))(e);c(await j(t,"getAllKeys"),(o=>((t,e)=>!s(((t,e)=>n(t,(t=>t[e])))(t,e)))(e,o)?0:i(a,j(t,"delete",o)))),await r(a)},j=async(t,e,a)=>o(((s,n)=>{const o=t[e](a);o.onsuccess=()=>s(o.result),o.onerror=()=>n(`objectStore.${e} error`)}));t.createIndexedDbPersister=(t,e,y=1,l)=>{const p=async(t,a=[],s=0)=>o(((n,o)=>{const i=(A?A.indexedDB:indexedDB).open(e,s?2:void 0);i.onupgradeneeded=()=>s&&c(S,(t=>{try{i.result.createObjectStore(t,x)}catch{}})),i.onsuccess=async()=>{try{const e=i.result.transaction(S,"readwrite"),s=await r(c(S,(async(s,n)=>await t(e.objectStore(s),a[n]))));i.result.close(),n(s)}catch(t){i.result.close(),o(t)}},i.onerror=()=>o("indexedDB.open error")}));return((t,e,a,o,r,c,[d,y]=[],l=[])=>{let p,A,S,x=0,D=0;v(g,l,(()=>0)),v(b,l,(()=>[]));const j=async t=>(2!=x&&(x=1,await m.schedule((async()=>{await t(),x=0}))),m),m={load:async(a,s)=>await j((async()=>{try{t.setContent(await e())}catch{t.setContent([a,s])}})),startAutoLoad:async(a={},s={})=>(m.stopAutoLoad(),await m.load(a,s),D=1,S=o((async(a,s)=>{if(s){const e=s();await j((async()=>t.setTransactionChanges(e)))}else await j((async()=>{try{t.setContent(a?.()??await e())}catch(t){c?.(t)}}))})),m),stopAutoLoad:()=>(D&&(r(S),S=void 0,D=0),m),save:async e=>(1!=x&&(x=2,await m.schedule((async()=>{try{await a(t.getContent,e)}catch(t){c?.(t)}x=0}))),m),startAutoSave:async()=>(await m.stopAutoSave().save(),p=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();w(a)&&w(s)||m.save((()=>[a,s]))})),m),stopAutoSave:()=>(n(p,t.delListener),p=void 0,m),schedule:async(...t)=>(i(h(b,l),...t),await(async()=>{if(!h(g,l)){for(f(g,l,1);!s((t=h(b,l),A=t.shift()));)try{await A()}catch(t){c?.(t)}f(g,l,0)}var t})(),m),getStore:()=>t,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(m[d]=()=>y),u(m)})(t,(async()=>await p((async t=>((t=[])=>d.fromEntries(t))(c(await j(t,"getAll"),(({k:t,v:e})=>[t,e])))))),(async t=>await p((async(t,e)=>await D(t,e)),t(),1)),(t=>setInterval(t,1e3*y)),(t=>a(t)),l,["getDbName",e])},t.objectStoreMatch=D},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterIndexedDb={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=Promise,n=clearInterval,o=e=>null==e,l=(e,t,n)=>o(e)?null==n?void 0:n():t(e),r=e=>new t(e),i=e=>{return n=function*(){return t.all(e)},new Promise(((e,t)=>{var o=e=>{try{r(n.next(e))}catch(e){t(e)}},l=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((n=n.apply(void 0,null)).next())}));var n},u=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),s=Object,c=e=>s.getPrototypeOf(e),a=s.keys,v=s.freeze,y=e=>(e=>!o(e)&&l(c(e),(e=>e==s.prototype||o(c(e))),(()=>!0)))(e)&&0==(e=>a(e).length)(e),f=e=>new Map(e),h=(e,t)=>null==e?void 0:e.get(t),p=(e,t,n)=>{return o(n)?(r=t,null==(l=e)||l.delete(r),e):null==e?void 0:e.set(t,n);var l,r},g=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||p(e,t,n()),h(e,t)};var x=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{u(n.next(e))}catch(e){l(e)}},i=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);u((n=n.apply(e,t)).next())}));const b=f(),m=f();var w=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{u(n.next(e))}catch(e){l(e)}},i=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);u((n=n.apply(e,t)).next())}));const P=globalThis.window,A=["t","v"],S={keyPath:"k"},j=(e,t)=>w(void 0,null,(function*(){const n=((t,n)=>u(s.entries(t),(([t,n])=>D(e,"put",{k:t,v:n}))))(t);u(yield D(e,"getAllKeys"),(r=>((e,t)=>!o(((e,t)=>l(e,(e=>e[t])))(e,t)))(t,r)?0:d(n,D(e,"delete",r)))),yield i(n)})),D=(e,t,n)=>w(void 0,null,(function*(){return r(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))}));e.createIndexedDbPersister=(e,t,c=1,a)=>{const f=(e,...n)=>w(void 0,[e,...n],(function*(e,n=[],o=0){return r(((l,r)=>{const d=P.indexedDB.open(t,o?2:void 0);d.onupgradeneeded=()=>o&&u(A,(e=>{try{d.result.createObjectStore(e,S)}catch(e){}})),d.onsuccess=()=>w(void 0,null,(function*(){try{const t=d.result.transaction(A,"readwrite"),o=yield i(u(A,((o,l)=>w(void 0,null,(function*(){return yield e(t.objectStore(o),n[l])})))));d.result.close(),l(o)}catch(e){d.result.close(),r(e)}})),d.onerror=()=>r("indexedDB.open error")}))}));return((e,t,n,r,i,u,[s,c]=[],a=[])=>{let f,w,P,A=0,S=0;g(b,a,(()=>0)),g(m,a,(()=>[]));const j=e=>x(void 0,null,(function*(){return 2!=A&&(A=1,yield D.schedule((()=>x(void 0,null,(function*(){yield e(),A=0}))))),D})),D={load:(n,o)=>x(void 0,null,(function*(){return yield j((()=>x(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>x(void 0,[...n],(function*(n={},o={}){return D.stopAutoLoad(),yield D.load(n,o),S=1,P=r(((n,o)=>x(void 0,null,(function*(){if(o){const t=o();yield j((()=>x(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield j((()=>x(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==u||u(e)}}))))})))),D})),stopAutoLoad:()=>(S&&(i(P),P=void 0,S=0),D),save:t=>x(void 0,null,(function*(){return 1!=A&&(A=2,yield D.schedule((()=>x(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==u||u(e)}A=0}))))),D})),startAutoSave:()=>x(void 0,null,(function*(){return yield D.stopAutoSave().save(),f=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();y(n)&&y(o)||D.save((()=>[n,o]))})),D})),stopAutoSave:()=>(l(f,e.delListener),f=void 0,D),schedule:(...e)=>x(void 0,null,(function*(){return d(h(m,a),...e),yield x(void 0,null,(function*(){if(!h(b,a)){for(p(b,a,1);!o((e=h(m,a),w=e.shift()));)try{yield w()}catch(e){null==u||u(e)}p(b,a,0)}var e})),D})),getStore:()=>e,destroy:()=>D.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return s&&(D[s]=()=>c),v(D)})(e,(()=>w(void 0,null,(function*(){return yield f((e=>w(void 0,null,(function*(){return((e=[])=>s.fromEntries(e))(u(yield D(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>w(void 0,null,(function*(){return yield f(((e,t)=>w(void 0,null,(function*(){return yield j(e,t)}))),e(),1)}))),(e=>setInterval(e,1e3*c)),(e=>n(e)),a,["getDbName",t])},e.objectStoreMatch=j},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterIndexedDb={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=Promise,n=clearInterval,o=e=>null==e,l=(e,t,n)=>o(e)?null==n?void 0:n():t(e),r=e=>new t(e),i=e=>{return n=function*(){return t.all(e)},new Promise(((e,t)=>{var o=e=>{try{r(n.next(e))}catch(e){t(e)}},l=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,l);r((n=n.apply(void 0,null)).next())}));var n},u=(e,t)=>e.map(t),d=(e,...t)=>e.push(...t),s=Object,c=e=>s.getPrototypeOf(e),a=s.keys,v=s.freeze,y=e=>(e=>!o(e)&&l(c(e),(e=>e==s.prototype||o(c(e))),(()=>!0)))(e)&&0==(e=>a(e).length)(e),f=e=>new Map(e),h=(e,t)=>null==e?void 0:e.get(t),p=(e,t,n)=>{return o(n)?(r=t,null==(l=e)||l.delete(r),e):null==e?void 0:e.set(t,n);var l,r},g=(e,t,n)=>{var o,l,r;return l=t,null!=(r=null==(o=e)?void 0:o.has(l))&&r||p(e,t,n()),h(e,t)};var x=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{u(n.next(e))}catch(e){l(e)}},i=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);u((n=n.apply(e,t)).next())}));const b=f(),m=f();var w=(e,t,n)=>new Promise(((o,l)=>{var r=e=>{try{u(n.next(e))}catch(e){l(e)}},i=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(r,i);u((n=n.apply(e,t)).next())}));const P=globalThis.window,A=["t","v"],S={keyPath:"k"},D=(e,t)=>w(void 0,null,(function*(){const n=((t,n)=>u(s.entries(t),(([t,n])=>j(e,"put",{k:t,v:n}))))(t);u(yield j(e,"getAllKeys"),(r=>((e,t)=>!o(((e,t)=>l(e,(e=>e[t])))(e,t)))(t,r)?0:d(n,j(e,"delete",r)))),yield i(n)})),j=(e,t,n)=>w(void 0,null,(function*(){return r(((o,l)=>{const r=e[t](n);r.onsuccess=()=>o(r.result),r.onerror=()=>l(`objectStore.${t} error`)}))}));e.createIndexedDbPersister=(e,t,c=1,a)=>{const f=(e,...n)=>w(void 0,[e,...n],(function*(e,n=[],o=0){return r(((l,r)=>{const d=(P?P.indexedDB:indexedDB).open(t,o?2:void 0);d.onupgradeneeded=()=>o&&u(A,(e=>{try{d.result.createObjectStore(e,S)}catch(e){}})),d.onsuccess=()=>w(void 0,null,(function*(){try{const t=d.result.transaction(A,"readwrite"),o=yield i(u(A,((o,l)=>w(void 0,null,(function*(){return yield e(t.objectStore(o),n[l])})))));d.result.close(),l(o)}catch(e){d.result.close(),r(e)}})),d.onerror=()=>r("indexedDB.open error")}))}));return((e,t,n,r,i,u,[s,c]=[],a=[])=>{let f,w,P,A=0,S=0;g(b,a,(()=>0)),g(m,a,(()=>[]));const D=e=>x(void 0,null,(function*(){return 2!=A&&(A=1,yield j.schedule((()=>x(void 0,null,(function*(){yield e(),A=0}))))),j})),j={load:(n,o)=>x(void 0,null,(function*(){return yield D((()=>x(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>x(void 0,[...n],(function*(n={},o={}){return j.stopAutoLoad(),yield j.load(n,o),S=1,P=r(((n,o)=>x(void 0,null,(function*(){if(o){const t=o();yield D((()=>x(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield D((()=>x(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==u||u(e)}}))))})))),j})),stopAutoLoad:()=>(S&&(i(P),P=void 0,S=0),j),save:t=>x(void 0,null,(function*(){return 1!=A&&(A=2,yield j.schedule((()=>x(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==u||u(e)}A=0}))))),j})),startAutoSave:()=>x(void 0,null,(function*(){return yield j.stopAutoSave().save(),f=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();y(n)&&y(o)||j.save((()=>[n,o]))})),j})),stopAutoSave:()=>(l(f,e.delListener),f=void 0,j),schedule:(...e)=>x(void 0,null,(function*(){return d(h(m,a),...e),yield x(void 0,null,(function*(){if(!h(b,a)){for(p(b,a,1);!o((e=h(m,a),w=e.shift()));)try{yield w()}catch(e){null==u||u(e)}p(b,a,0)}var e})),j})),getStore:()=>e,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return s&&(j[s]=()=>c),v(j)})(e,(()=>w(void 0,null,(function*(){return yield f((e=>w(void 0,null,(function*(){return((e=[])=>s.fromEntries(e))(u(yield j(e,"getAll"),(({k:e,v:t})=>[e,t])))}))))}))),(e=>w(void 0,null,(function*(){return yield f(((e,t)=>w(void 0,null,(function*(){return yield D(e,t)}))),e(),1)}))),(e=>setInterval(e,1e3*c)),(e=>n(e)),a,["getDbName",t])},e.objectStoreMatch=D},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterIndexedDb={});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.6.6",
3
+ "version": "4.6.8",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -215,13 +215,13 @@
215
215
  },
216
216
  "devDependencies": {
217
217
  "@automerge/automerge": "^2.1.10",
218
- "@automerge/automerge-repo": "^1.1.0",
218
+ "@automerge/automerge-repo": "^1.1.1",
219
219
  "@babel/cli": "^7.23.9",
220
220
  "@babel/core": "^7.23.9",
221
221
  "@babel/preset-env": "^7.23.9",
222
222
  "@babel/preset-react": "^7.23.3",
223
223
  "@babel/preset-typescript": "^7.23.3",
224
- "@prettier/sync": "^0.5.0",
224
+ "@prettier/sync": "^0.5.1",
225
225
  "@rollup/plugin-image": "^3.0.3",
226
226
  "@rollup/plugin-replace": "^5.0.5",
227
227
  "@rollup/plugin-terser": "^0.4.4",
@@ -232,14 +232,14 @@
232
232
  "@types/jest": "^29.5.12",
233
233
  "@types/jest-environment-puppeteer": "^5.0.6",
234
234
  "@types/less": "^3.0.6",
235
- "@types/node": "^20.11.16",
235
+ "@types/node": "^20.11.17",
236
236
  "@types/puppeteer": "^5.4.7",
237
- "@types/react": "^18.2.51",
238
- "@types/react-dom": "^18.2.18",
237
+ "@types/react": "^18.2.55",
238
+ "@types/react-dom": "^18.2.19",
239
239
  "@types/react-test-renderer": "^18.0.7",
240
240
  "@types/tmp": "^0.2.6",
241
- "@typescript-eslint/eslint-plugin": "^6.20.0",
242
- "@typescript-eslint/parser": "^6.20.0",
241
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
242
+ "@typescript-eslint/parser": "^6.21.0",
243
243
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
244
244
  "asciichart": "^1.5.25",
245
245
  "babel-eslint": "^10.1.0",
@@ -250,12 +250,12 @@
250
250
  "buffer-replace": "^1.0.0",
251
251
  "country-flag-emoji-json": "^2.0.0",
252
252
  "cspell": "^8.3.2",
253
- "electric-sql": "^0.9.1",
253
+ "electric-sql": "^0.9.2",
254
254
  "esbuild": "^0.20.0",
255
255
  "eslint": "^8.56.0",
256
256
  "eslint-config-prettier": "^9.1.0",
257
257
  "eslint-plugin-jest": "^27.6.3",
258
- "eslint-plugin-jsdoc": "^48.0.4",
258
+ "eslint-plugin-jsdoc": "^48.0.6",
259
259
  "eslint-plugin-react": "7.33.2",
260
260
  "eslint-plugin-react-hooks": "^4.6.0",
261
261
  "expo-sqlite": "^13.2.1",
@@ -269,10 +269,10 @@
269
269
  "jest-fetch-mock": "^3.0.3",
270
270
  "jest-puppeteer": "^9.0.2",
271
271
  "less": "^4.2.0",
272
- "partykit": "^0.0.81",
272
+ "partykit": "^0.0.85",
273
273
  "partysocket": "^0.0.25",
274
- "prettier": "^3.2.4",
275
- "puppeteer": "21.11.0",
274
+ "prettier": "^3.2.5",
275
+ "puppeteer": "22.0.0",
276
276
  "react": "^18.2.0",
277
277
  "react-dom": "^18.2.0",
278
278
  "react-test-renderer": "^18.2.0",
@@ -291,13 +291,14 @@
291
291
  "yjs": "^13.6.11"
292
292
  },
293
293
  "peerDependencies": {
294
- "@automerge/automerge-repo": "^1.0.19",
294
+ "@automerge/automerge-repo": "^1.1.1",
295
295
  "@sqlite.org/sqlite-wasm": "^3.45.1-build1",
296
296
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
297
- "electric-sql": "^0.9.1",
298
- "partykit": "^0.0.81",
297
+ "electric-sql": "^0.9.2",
298
+ "expo-sqlite": "^13.2.1",
299
+ "partykit": "^0.0.85",
299
300
  "partysocket": "^0.0.25",
300
- "prettier": "^3.2.4",
301
+ "prettier": "^3.2.5",
301
302
  "react": "^18.2.0",
302
303
  "react-dom": "^18.2.0",
303
304
  "sqlite3": "^5.1.7",
@@ -316,6 +317,9 @@
316
317
  "electric-sql": {
317
318
  "optional": true
318
319
  },
320
+ "expo-sqlite": {
321
+ "optional": true
322
+ },
319
323
  "partykit": {
320
324
  "optional": true
321
325
  },
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-6"><em>NEW!</em> v4.6 release</a> <span id="one-with">&quot;The One With ElectricSQL&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.6.6" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-6"><em>NEW!</em> v4.6 release</a> <span id="one-with">&quot;The One With ElectricSQL&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.0kB - 9.4kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.6.8" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()