tinybase 4.6.2 → 4.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";const t=t=>null==t,e=(e,a,s)=>t(e)?s?.():a(e),a=Object,s=t=>a.getPrototypeOf(t),n=a.keys,o=a.freeze,c=(t,a)=>e(t,(t=>t[a])),r=(e,a)=>!t(c(e,a)),i=(t,e)=>(delete t[e],t),d=(t,e)=>((t,e)=>t.map(e))(a.entries(t),(([t,a])=>e(a,t))),y=t=>n(t).length,u=n=>(n=>!t(n)&&e(s(n),(e=>e==a.prototype||t(s(e))),(()=>!0)))(n)&&0==y(n),v=t=>new Map(t),h=(t,e)=>t?.get(e),l=(e,a,s)=>{return t(s)?(n=e,o=a,n?.delete(o),e):e?.set(a,s);var n,o},w=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||l(t,e,a()),h(t,e)},g=v(),p=v(),A=(t,e)=>[t[e].t,t[e].v],f=(e,a,s,n)=>{const o=t(a)?e:((t,e,a)=>(r(t,e)||(t[e]={}),t[e]))(e,a);let c;return d(s,((t,e)=>{n(o,e,t)&&(c=1)})),d(o,((t,e)=>{r(s,e)||(i(o,e),c=1)})),!t(a)&&u(o)&&i(e,a),c};exports.createAutomergePersister=(a,s,n="tinybase",r)=>(s.change((t=>t[n]={})),((a,s,n,c,r,i,[d,y]=[],v=[])=>{let A,f,L,S=0,C=0;w(g,v,(()=>0)),w(p,v,(()=>[]));const m=async t=>(2!=S&&(S=1,await b.schedule((async()=>{await t(),S=0}))),b),b={load:async(t,e)=>await m((async()=>{try{a.setContent(await s())}catch{a.setContent([t,e])}})),startAutoLoad:async(t={},e={})=>(b.stopAutoLoad(),await b.load(t,e),C=1,L=c((async(t,e)=>{if(e){const t=e();await m((async()=>a.setTransactionChanges(t)))}else await m((async()=>{try{a.setContent(t?.()??await s())}catch(t){i?.(t)}}))})),b),stopAutoLoad:()=>(C&&(r(L),L=void 0,C=0),b),save:async t=>(1!=S&&(S=2,await b.schedule((async()=>{try{await n(a.getContent,t)}catch(t){i?.(t)}S=0}))),b),startAutoSave:async()=>(await b.stopAutoSave().save(),A=a.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();u(a)&&u(s)||b.save((()=>[a,s]))})),b),stopAutoSave:()=>(e(A,a.delListener),A=void 0,b),schedule:async(...e)=>(((t,...e)=>{t.push(...e)})(h(p,v),...e),await(async()=>{if(!h(g,v)){for(l(g,v,1);!t((e=h(p,v),f=e.shift()));)try{await f()}catch(t){i?.(t)}l(g,v,0)}var e})(),b),getStore:()=>a,destroy:()=>b.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(b[d]=()=>y),o(b)})(a,(async()=>2==y(s.doc[n])?A(s.doc,n):void 0),(async(a,o)=>s.change((s=>((a,s,n,o)=>{((t,e)=>{u(t[e])&&(t[e]={t:{},v:{}})})(a,s);const[r,y]=A(a,s),v=()=>{h=1};let h=1;if(e(o?.(),(([a,s])=>{h=0,d(a,((a,s)=>h?0:t(a)?i(r,s):e(r[s],(s=>d(a,((a,n)=>h?0:t(a)?i(s,n):e(c(s,n),(e=>d(a,((a,s)=>t(a)?i(e,s):e[s]=a))),v)))),v))),d(s,((e,a)=>h?0:t(e)?i(y,a):y[a]=e))})),h){const[t,e]=n();f(r,void 0,t,((t,e,a)=>f(r,e,a,((t,e,a)=>f(t,e,a,((t,e,a)=>{if(c(t,e)!==a)return t[e]=a,1})))))),f(y,void 0,e,((t,e,a)=>{c(y,e)!==a&&(y[e]=a)}))}})(s,n,a,o)))),(t=>{const e=({doc:e})=>t((()=>A(e,n)));return s.on("change",e),e}),(t=>{s.removeListener("change",t)}),r,["getDocHandle",s]));
1
+ "use strict";const t=t=>null==t,e=(e,a,s)=>t(e)?s?.():a(e),a=Object,s=t=>a.getPrototypeOf(t),n=a.keys,o=a.freeze,c=(t,a)=>e(t,(t=>t[a])),r=(e,a)=>!t(c(e,a)),i=(t,e)=>(delete t[e],t),d=(t,e)=>((t,e)=>t.map(e))(a.entries(t),(([t,a])=>e(a,t))),y=t=>n(t).length,u=n=>(n=>!t(n)&&e(s(n),(e=>e==a.prototype||t(s(e))),(()=>!0)))(n)&&0==y(n),v=t=>new Map(t),h=(t,e)=>t?.get(e),l=(e,a,s)=>{return t(s)?(n=e,o=a,n?.delete(o),e):e?.set(a,s);var n,o},w=(t,e,a)=>{var s,n;return s=t,n=e,s?.has(n)||l(t,e,a()),h(t,e)},g=v(),p=v(),A=(t,e)=>[t[e].t,t[e].v],f=(e,a,s,n)=>{const o=t(a)?e:((t,e,a)=>(r(t,e)||(t[e]={}),t[e]))(e,a);let c;return d(s,((t,e)=>{n(o,e,t)&&(c=1)})),d(o,((t,e)=>{r(s,e)||(i(o,e),c=1)})),!t(a)&&u(o)&&i(e,a),c};exports.createAutomergePersister=(a,s,n="tinybase",r)=>(s.change((t=>t[n]={})),((a,s,n,c,r,i,[d,y]=[],v=[])=>{let A,f,L,S=0,C=0;w(g,v,(()=>0)),w(p,v,(()=>[]));const m=async t=>(2!=S&&(S=1,await b.schedule((async()=>{await t(),S=0}))),b),b={load:async(t,e)=>await m((async()=>{try{a.setContent(await s())}catch{a.setContent([t,e])}})),startAutoLoad:async(t={},e={})=>(b.stopAutoLoad(),await b.load(t,e),C=1,L=c((async(t,e)=>{if(e){const t=e();await m((async()=>a.setTransactionChanges(t)))}else await m((async()=>{try{a.setContent(t?.()??await s())}catch(t){i?.(t)}}))})),b),stopAutoLoad:()=>(C&&(r(L),L=void 0,C=0),b),save:async t=>(1!=S&&(S=2,await b.schedule((async()=>{try{await n(a.getContent,t)}catch(t){i?.(t)}S=0}))),b),startAutoSave:async()=>(await b.stopAutoSave().save(),A=a.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();u(a)&&u(s)||b.save((()=>[a,s]))})),b),stopAutoSave:()=>(e(A,a.delListener),A=void 0,b),schedule:async(...e)=>(((t,...e)=>{t.push(...e)})(h(p,v),...e),await(async()=>{if(!h(g,v)){for(l(g,v,1);!t((e=h(p,v),f=e.shift()));)try{await f()}catch(t){i?.(t)}l(g,v,0)}var e})(),b),getStore:()=>a,destroy:()=>b.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(b[d]=()=>y),o(b)})(a,(async()=>{const t=await s.doc();return 2==y(t[n])?A(t,n):void 0}),(async(a,o)=>s.change((s=>((a,s,n,o)=>{((t,e)=>{u(t[e])&&(t[e]={t:{},v:{}})})(a,s);const[r,y]=A(a,s),v=()=>{h=1};let h=1;if(e(o?.(),(([a,s])=>{h=0,d(a,((a,s)=>h?0:t(a)?i(r,s):e(r[s],(s=>d(a,((a,n)=>h?0:t(a)?i(s,n):e(c(s,n),(e=>d(a,((a,s)=>t(a)?i(e,s):e[s]=a))),v)))),v))),d(s,((e,a)=>h?0:t(e)?i(y,a):y[a]=e))})),h){const[t,e]=n();f(r,void 0,t,((t,e,a)=>f(r,e,a,((t,e,a)=>f(t,e,a,((t,e,a)=>{if(c(t,e)!==a)return t[e]=a,1})))))),f(y,void 0,e,((t,e,a)=>{c(y,e)!==a&&(y[e]=a)}))}})(s,n,a,o)))),(t=>{const e=({doc:e})=>t((()=>A(e,n)));return s.on("change",e),e}),(t=>{s.removeListener("change",t)}),r,["getDocHandle",s]));
@@ -1 +1 @@
1
- "use strict";const t=t=>null==t,e=(e,n,o)=>t(e)?null==o?void 0:o():n(e),n=Object,o=t=>n.getPrototypeOf(t),l=n.keys,i=n.freeze,r=(t,n)=>e(t,(t=>t[n])),u=(e,n)=>!t(r(e,n)),d=(t,e)=>(delete t[e],t),c=(t,e)=>((t,e)=>t.map(e))(n.entries(t),(([t,n])=>e(n,t))),s=t=>l(t).length,a=l=>(l=>!t(l)&&e(o(l),(e=>e==n.prototype||t(o(e))),(()=>!0)))(l)&&0==s(l),v=t=>new Map(t),y=(t,e)=>null==t?void 0:t.get(e),h=(e,n,o)=>{return t(o)?(i=n,null==(l=e)||l.delete(i),e):null==e?void 0:e.set(n,o);var l,i},f=(t,e,n)=>{var o,l,i;return l=e,null!=(i=null==(o=t)?void 0:o.has(l))&&i||h(t,e,n()),y(t,e)};var p=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{u(n.next(t))}catch(t){l(t)}},r=t=>{try{u(n.throw(t))}catch(t){l(t)}},u=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,r);u((n=n.apply(t,e)).next())}));const g=v(),A=v();var m=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{u(n.next(t))}catch(t){l(t)}},r=t=>{try{u(n.throw(t))}catch(t){l(t)}},u=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,r);u((n=n.apply(t,e)).next())}));const L=(t,e)=>[t[e].t,t[e].v],P=(e,n,o,l)=>{const i=t(n)?e:((t,e,n)=>(u(t,e)||(t[e]={}),t[e]))(e,n);let r;return c(o,((t,e)=>{l(i,e,t)&&(r=1)})),c(i,((t,e)=>{u(o,e)||(d(i,e),r=1)})),!t(n)&&a(i)&&d(e,n),r};exports.createAutomergePersister=(n,o,l="tinybase",u)=>(o.change((t=>t[l]={})),((n,o,l,r,u,d,[c,s]=[],v=[])=>{let m,L,P,S=0,w=0;f(g,v,(()=>0)),f(A,v,(()=>[]));const x=t=>p(void 0,null,(function*(){return 2!=S&&(S=1,yield C.schedule((()=>p(void 0,null,(function*(){yield t(),S=0}))))),C})),C={load:(t,e)=>p(void 0,null,(function*(){return yield x((()=>p(void 0,null,(function*(){try{n.setContent(yield o())}catch(o){n.setContent([t,e])}}))))})),startAutoLoad:(...t)=>p(void 0,[...t],(function*(t={},e={}){return C.stopAutoLoad(),yield C.load(t,e),w=1,P=r(((t,e)=>p(void 0,null,(function*(){if(e){const t=e();yield x((()=>p(void 0,null,(function*(){return n.setTransactionChanges(t)}))))}else yield x((()=>p(void 0,null,(function*(){var e;try{n.setContent(null!=(e=null==t?void 0:t())?e:yield o())}catch(t){null==d||d(t)}}))))})))),C})),stopAutoLoad:()=>(w&&(u(P),P=void 0,w=0),C),save:t=>p(void 0,null,(function*(){return 1!=S&&(S=2,yield C.schedule((()=>p(void 0,null,(function*(){try{yield l(n.getContent,t)}catch(t){null==d||d(t)}S=0}))))),C})),startAutoSave:()=>p(void 0,null,(function*(){return yield C.stopAutoSave().save(),m=n.addDidFinishTransactionListener(((t,e)=>{const[n,o]=e();a(n)&&a(o)||C.save((()=>[n,o]))})),C})),stopAutoSave:()=>(e(m,n.delListener),m=void 0,C),schedule:(...e)=>p(void 0,null,(function*(){return((t,...e)=>{t.push(...e)})(y(A,v),...e),yield p(void 0,null,(function*(){if(!y(g,v)){for(h(g,v,1);!t((e=y(A,v),L=e.shift()));)try{yield L()}catch(t){null==d||d(t)}h(g,v,0)}var e})),C})),getStore:()=>n,destroy:()=>C.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(C[c]=()=>s),i(C)})(n,(()=>m(void 0,null,(function*(){return 2==s(o.doc[l])?L(o.doc,l):void 0}))),((n,i)=>m(void 0,null,(function*(){return o.change((o=>((n,o,l,i)=>{((t,e)=>{a(t[e])&&(t[e]={t:{},v:{}})})(n,o);const[u,s]=L(n,o),v=()=>{y=1};let y=1;if(e(null==i?void 0:i(),(([n,o])=>{y=0,c(n,((n,o)=>y?0:t(n)?d(u,o):e(u[o],(o=>c(n,((n,l)=>y?0:t(n)?d(o,l):e(r(o,l),(e=>c(n,((n,o)=>t(n)?d(e,o):e[o]=n))),v)))),v))),c(o,((e,n)=>y?0:t(e)?d(s,n):s[n]=e))})),y){const[t,e]=l();P(u,void 0,t,((t,e,n)=>P(u,e,n,((t,e,n)=>P(t,e,n,((t,e,n)=>{if(r(t,e)!==n)return t[e]=n,1})))))),P(s,void 0,e,((t,e,n)=>{r(s,e)!==n&&(s[e]=n)}))}})(o,l,n,i)))}))),(t=>{const e=({doc:e})=>t((()=>L(e,l)));return o.on("change",e),e}),(t=>{o.removeListener("change",t)}),u,["getDocHandle",o]));
1
+ "use strict";const t=t=>null==t,e=(e,n,o)=>t(e)?null==o?void 0:o():n(e),n=Object,o=t=>n.getPrototypeOf(t),l=n.keys,i=n.freeze,r=(t,n)=>e(t,(t=>t[n])),u=(e,n)=>!t(r(e,n)),d=(t,e)=>(delete t[e],t),c=(t,e)=>((t,e)=>t.map(e))(n.entries(t),(([t,n])=>e(n,t))),s=t=>l(t).length,a=l=>(l=>!t(l)&&e(o(l),(e=>e==n.prototype||t(o(e))),(()=>!0)))(l)&&0==s(l),v=t=>new Map(t),y=(t,e)=>null==t?void 0:t.get(e),h=(e,n,o)=>{return t(o)?(i=n,null==(l=e)||l.delete(i),e):null==e?void 0:e.set(n,o);var l,i},f=(t,e,n)=>{var o,l,i;return l=e,null!=(i=null==(o=t)?void 0:o.has(l))&&i||h(t,e,n()),y(t,e)};var p=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{u(n.next(t))}catch(t){l(t)}},r=t=>{try{u(n.throw(t))}catch(t){l(t)}},u=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,r);u((n=n.apply(t,e)).next())}));const g=v(),A=v();var m=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{u(n.next(t))}catch(t){l(t)}},r=t=>{try{u(n.throw(t))}catch(t){l(t)}},u=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,r);u((n=n.apply(t,e)).next())}));const L=(t,e)=>[t[e].t,t[e].v],P=(e,n,o,l)=>{const i=t(n)?e:((t,e,n)=>(u(t,e)||(t[e]={}),t[e]))(e,n);let r;return c(o,((t,e)=>{l(i,e,t)&&(r=1)})),c(i,((t,e)=>{u(o,e)||(d(i,e),r=1)})),!t(n)&&a(i)&&d(e,n),r};exports.createAutomergePersister=(n,o,l="tinybase",u)=>(o.change((t=>t[l]={})),((n,o,l,r,u,d,[c,s]=[],v=[])=>{let m,L,P,S=0,w=0;f(g,v,(()=>0)),f(A,v,(()=>[]));const x=t=>p(void 0,null,(function*(){return 2!=S&&(S=1,yield C.schedule((()=>p(void 0,null,(function*(){yield t(),S=0}))))),C})),C={load:(t,e)=>p(void 0,null,(function*(){return yield x((()=>p(void 0,null,(function*(){try{n.setContent(yield o())}catch(o){n.setContent([t,e])}}))))})),startAutoLoad:(...t)=>p(void 0,[...t],(function*(t={},e={}){return C.stopAutoLoad(),yield C.load(t,e),w=1,P=r(((t,e)=>p(void 0,null,(function*(){if(e){const t=e();yield x((()=>p(void 0,null,(function*(){return n.setTransactionChanges(t)}))))}else yield x((()=>p(void 0,null,(function*(){var e;try{n.setContent(null!=(e=null==t?void 0:t())?e:yield o())}catch(t){null==d||d(t)}}))))})))),C})),stopAutoLoad:()=>(w&&(u(P),P=void 0,w=0),C),save:t=>p(void 0,null,(function*(){return 1!=S&&(S=2,yield C.schedule((()=>p(void 0,null,(function*(){try{yield l(n.getContent,t)}catch(t){null==d||d(t)}S=0}))))),C})),startAutoSave:()=>p(void 0,null,(function*(){return yield C.stopAutoSave().save(),m=n.addDidFinishTransactionListener(((t,e)=>{const[n,o]=e();a(n)&&a(o)||C.save((()=>[n,o]))})),C})),stopAutoSave:()=>(e(m,n.delListener),m=void 0,C),schedule:(...e)=>p(void 0,null,(function*(){return((t,...e)=>{t.push(...e)})(y(A,v),...e),yield p(void 0,null,(function*(){if(!y(g,v)){for(h(g,v,1);!t((e=y(A,v),L=e.shift()));)try{yield L()}catch(t){null==d||d(t)}h(g,v,0)}var e})),C})),getStore:()=>n,destroy:()=>C.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(C[c]=()=>s),i(C)})(n,(()=>m(void 0,null,(function*(){const t=yield o.doc();return 2==s(t[l])?L(t,l):void 0}))),((n,i)=>m(void 0,null,(function*(){return o.change((o=>((n,o,l,i)=>{((t,e)=>{a(t[e])&&(t[e]={t:{},v:{}})})(n,o);const[u,s]=L(n,o),v=()=>{y=1};let y=1;if(e(null==i?void 0:i(),(([n,o])=>{y=0,c(n,((n,o)=>y?0:t(n)?d(u,o):e(u[o],(o=>c(n,((n,l)=>y?0:t(n)?d(o,l):e(r(o,l),(e=>c(n,((n,o)=>t(n)?d(e,o):e[o]=n))),v)))),v))),c(o,((e,n)=>y?0:t(e)?d(s,n):s[n]=e))})),y){const[t,e]=l();P(u,void 0,t,((t,e,n)=>P(u,e,n,((t,e,n)=>P(t,e,n,((t,e,n)=>{if(r(t,e)!==n)return t[e]=n,1})))))),P(s,void 0,e,((t,e,n)=>{r(s,e)!==n&&(s[e]=n)}))}})(o,l,n,i)))}))),(t=>{const e=({doc:e})=>t((()=>L(e,l)));return o.on("change",e),e}),(t=>{o.removeListener("change",t)}),u,["getDocHandle",o]));
@@ -302,10 +302,12 @@ const createAutomergePersister = (
302
302
  onIgnoredError,
303
303
  ) => {
304
304
  docHandle.change((doc) => (doc[docObjName] = {}));
305
- const getPersisted = async () =>
306
- objSize(docHandle.doc[docObjName]) == 2
307
- ? getDocContent(docHandle.doc, docObjName)
305
+ const getPersisted = async () => {
306
+ const doc = await docHandle.doc();
307
+ return objSize(doc[docObjName]) == 2
308
+ ? getDocContent(doc, docObjName)
308
309
  : void 0;
310
+ };
309
311
  const setPersisted = async (getContent, getTransactionChanges) =>
310
312
  docHandle.change((doc) =>
311
313
  setTransactionChangesToDoc(
@@ -1 +1 @@
1
- const t=t=>null==t,e=(e,n,o)=>t(e)?null==o?void 0:o():n(e),n=Object,o=t=>n.getPrototypeOf(t),l=n.keys,i=n.freeze,u=(t,n)=>e(t,(t=>t[n])),r=(e,n)=>!t(u(e,n)),d=(t,e)=>(delete t[e],t),c=(t,e)=>((t,e)=>t.map(e))(n.entries(t),(([t,n])=>e(n,t))),a=t=>l(t).length,s=l=>(l=>!t(l)&&e(o(l),(e=>e==n.prototype||t(o(e))),(()=>!0)))(l)&&0==a(l),v=t=>new Map(t),y=(t,e)=>null==t?void 0:t.get(e),h=(e,n,o)=>{return t(o)?(i=n,null==(l=e)||l.delete(i),e):null==e?void 0:e.set(n,o);var l,i},f=(t,e,n)=>{var o,l,i;return l=e,null!=(i=null==(o=t)?void 0:o.has(l))&&i||h(t,e,n()),y(t,e)};var p=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{r(n.next(t))}catch(t){l(t)}},u=t=>{try{r(n.throw(t))}catch(t){l(t)}},r=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,u);r((n=n.apply(t,e)).next())}));const g=v(),A=v();var L=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{r(n.next(t))}catch(t){l(t)}},u=t=>{try{r(n.throw(t))}catch(t){l(t)}},r=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,u);r((n=n.apply(t,e)).next())}));const m=(t,e)=>[t[e].t,t[e].v],S=(e,n,o,l)=>{const i=t(n)?e:((t,e,n)=>(r(t,e)||(t[e]={}),t[e]))(e,n);let u;return c(o,((t,e)=>{l(i,e,t)&&(u=1)})),c(i,((t,e)=>{r(o,e)||(d(i,e),u=1)})),!t(n)&&s(i)&&d(e,n),u},w=(n,o,l="tinybase",r)=>(o.change((t=>t[l]={})),((n,o,l,u,r,d,[c,a]=[],v=[])=>{let L,m,S,w=0,x=0;f(g,v,(()=>0)),f(A,v,(()=>[]));const C=t=>p(void 0,null,(function*(){return 2!=w&&(w=1,yield P.schedule((()=>p(void 0,null,(function*(){yield t(),w=0}))))),P})),P={load:(t,e)=>p(void 0,null,(function*(){return yield C((()=>p(void 0,null,(function*(){try{n.setContent(yield o())}catch(o){n.setContent([t,e])}}))))})),startAutoLoad:(...t)=>p(void 0,[...t],(function*(t={},e={}){return P.stopAutoLoad(),yield P.load(t,e),x=1,S=u(((t,e)=>p(void 0,null,(function*(){if(e){const t=e();yield C((()=>p(void 0,null,(function*(){return n.setTransactionChanges(t)}))))}else yield C((()=>p(void 0,null,(function*(){var e;try{n.setContent(null!=(e=null==t?void 0:t())?e:yield o())}catch(t){null==d||d(t)}}))))})))),P})),stopAutoLoad:()=>(x&&(r(S),S=void 0,x=0),P),save:t=>p(void 0,null,(function*(){return 1!=w&&(w=2,yield P.schedule((()=>p(void 0,null,(function*(){try{yield l(n.getContent,t)}catch(t){null==d||d(t)}w=0}))))),P})),startAutoSave:()=>p(void 0,null,(function*(){return yield P.stopAutoSave().save(),L=n.addDidFinishTransactionListener(((t,e)=>{const[n,o]=e();s(n)&&s(o)||P.save((()=>[n,o]))})),P})),stopAutoSave:()=>(e(L,n.delListener),L=void 0,P),schedule:(...e)=>p(void 0,null,(function*(){return((t,...e)=>{t.push(...e)})(y(A,v),...e),yield p(void 0,null,(function*(){if(!y(g,v)){for(h(g,v,1);!t((e=y(A,v),m=e.shift()));)try{yield m()}catch(t){null==d||d(t)}h(g,v,0)}var e})),P})),getStore:()=>n,destroy:()=>P.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(P[c]=()=>a),i(P)})(n,(()=>L(void 0,null,(function*(){return 2==a(o.doc[l])?m(o.doc,l):void 0}))),((n,i)=>L(void 0,null,(function*(){return o.change((o=>((n,o,l,i)=>{((t,e)=>{s(t[e])&&(t[e]={t:{},v:{}})})(n,o);const[r,a]=m(n,o),v=()=>{y=1};let y=1;if(e(null==i?void 0:i(),(([n,o])=>{y=0,c(n,((n,o)=>y?0:t(n)?d(r,o):e(r[o],(o=>c(n,((n,l)=>y?0:t(n)?d(o,l):e(u(o,l),(e=>c(n,((n,o)=>t(n)?d(e,o):e[o]=n))),v)))),v))),c(o,((e,n)=>y?0:t(e)?d(a,n):a[n]=e))})),y){const[t,e]=l();S(r,void 0,t,((t,e,n)=>S(r,e,n,((t,e,n)=>S(t,e,n,((t,e,n)=>{if(u(t,e)!==n)return t[e]=n,1})))))),S(a,void 0,e,((t,e,n)=>{u(a,e)!==n&&(a[e]=n)}))}})(o,l,n,i)))}))),(t=>{const e=({doc:e})=>t((()=>m(e,l)));return o.on("change",e),e}),(t=>{o.removeListener("change",t)}),r,["getDocHandle",o]));export{w as createAutomergePersister};
1
+ const t=t=>null==t,e=(e,n,o)=>t(e)?null==o?void 0:o():n(e),n=Object,o=t=>n.getPrototypeOf(t),l=n.keys,i=n.freeze,u=(t,n)=>e(t,(t=>t[n])),r=(e,n)=>!t(u(e,n)),d=(t,e)=>(delete t[e],t),c=(t,e)=>((t,e)=>t.map(e))(n.entries(t),(([t,n])=>e(n,t))),a=t=>l(t).length,s=l=>(l=>!t(l)&&e(o(l),(e=>e==n.prototype||t(o(e))),(()=>!0)))(l)&&0==a(l),v=t=>new Map(t),y=(t,e)=>null==t?void 0:t.get(e),h=(e,n,o)=>{return t(o)?(i=n,null==(l=e)||l.delete(i),e):null==e?void 0:e.set(n,o);var l,i},f=(t,e,n)=>{var o,l,i;return l=e,null!=(i=null==(o=t)?void 0:o.has(l))&&i||h(t,e,n()),y(t,e)};var p=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{r(n.next(t))}catch(t){l(t)}},u=t=>{try{r(n.throw(t))}catch(t){l(t)}},r=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,u);r((n=n.apply(t,e)).next())}));const g=v(),A=v();var L=(t,e,n)=>new Promise(((o,l)=>{var i=t=>{try{r(n.next(t))}catch(t){l(t)}},u=t=>{try{r(n.throw(t))}catch(t){l(t)}},r=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,u);r((n=n.apply(t,e)).next())}));const m=(t,e)=>[t[e].t,t[e].v],S=(e,n,o,l)=>{const i=t(n)?e:((t,e,n)=>(r(t,e)||(t[e]={}),t[e]))(e,n);let u;return c(o,((t,e)=>{l(i,e,t)&&(u=1)})),c(i,((t,e)=>{r(o,e)||(d(i,e),u=1)})),!t(n)&&s(i)&&d(e,n),u},w=(n,o,l="tinybase",r)=>(o.change((t=>t[l]={})),((n,o,l,u,r,d,[c,a]=[],v=[])=>{let L,m,S,w=0,x=0;f(g,v,(()=>0)),f(A,v,(()=>[]));const C=t=>p(void 0,null,(function*(){return 2!=w&&(w=1,yield P.schedule((()=>p(void 0,null,(function*(){yield t(),w=0}))))),P})),P={load:(t,e)=>p(void 0,null,(function*(){return yield C((()=>p(void 0,null,(function*(){try{n.setContent(yield o())}catch(o){n.setContent([t,e])}}))))})),startAutoLoad:(...t)=>p(void 0,[...t],(function*(t={},e={}){return P.stopAutoLoad(),yield P.load(t,e),x=1,S=u(((t,e)=>p(void 0,null,(function*(){if(e){const t=e();yield C((()=>p(void 0,null,(function*(){return n.setTransactionChanges(t)}))))}else yield C((()=>p(void 0,null,(function*(){var e;try{n.setContent(null!=(e=null==t?void 0:t())?e:yield o())}catch(t){null==d||d(t)}}))))})))),P})),stopAutoLoad:()=>(x&&(r(S),S=void 0,x=0),P),save:t=>p(void 0,null,(function*(){return 1!=w&&(w=2,yield P.schedule((()=>p(void 0,null,(function*(){try{yield l(n.getContent,t)}catch(t){null==d||d(t)}w=0}))))),P})),startAutoSave:()=>p(void 0,null,(function*(){return yield P.stopAutoSave().save(),L=n.addDidFinishTransactionListener(((t,e)=>{const[n,o]=e();s(n)&&s(o)||P.save((()=>[n,o]))})),P})),stopAutoSave:()=>(e(L,n.delListener),L=void 0,P),schedule:(...e)=>p(void 0,null,(function*(){return((t,...e)=>{t.push(...e)})(y(A,v),...e),yield p(void 0,null,(function*(){if(!y(g,v)){for(h(g,v,1);!t((e=y(A,v),m=e.shift()));)try{yield m()}catch(t){null==d||d(t)}h(g,v,0)}var e})),P})),getStore:()=>n,destroy:()=>P.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c&&(P[c]=()=>a),i(P)})(n,(()=>L(void 0,null,(function*(){const t=yield o.doc();return 2==a(t[l])?m(t,l):void 0}))),((n,i)=>L(void 0,null,(function*(){return o.change((o=>((n,o,l,i)=>{((t,e)=>{s(t[e])&&(t[e]={t:{},v:{}})})(n,o);const[r,a]=m(n,o),v=()=>{y=1};let y=1;if(e(null==i?void 0:i(),(([n,o])=>{y=0,c(n,((n,o)=>y?0:t(n)?d(r,o):e(r[o],(o=>c(n,((n,l)=>y?0:t(n)?d(o,l):e(u(o,l),(e=>c(n,((n,o)=>t(n)?d(e,o):e[o]=n))),v)))),v))),c(o,((e,n)=>y?0:t(e)?d(a,n):a[n]=e))})),y){const[t,e]=l();S(r,void 0,t,((t,e,n)=>S(r,e,n,((t,e,n)=>S(t,e,n,((t,e,n)=>{if(u(t,e)!==n)return t[e]=n,1})))))),S(a,void 0,e,((t,e,n)=>{u(a,e)!==n&&(a[e]=n)}))}})(o,l,n,i)))}))),(t=>{const e=({doc:e})=>t((()=>m(e,l)));return o.on("change",e),e}),(t=>{o.removeListener("change",t)}),r,["getDocHandle",o]));export{w as createAutomergePersister};
@@ -1 +1 @@
1
- const t=t=>null==t,a=(a,e,s)=>t(a)?s?.():e(a),e=Object,s=t=>e.getPrototypeOf(t),n=e.keys,o=e.freeze,c=(t,e)=>a(t,(t=>t[e])),r=(a,e)=>!t(c(a,e)),i=(t,a)=>(delete t[a],t),d=(t,a)=>((t,a)=>t.map(a))(e.entries(t),(([t,e])=>a(e,t))),y=t=>n(t).length,u=n=>(n=>!t(n)&&a(s(n),(a=>a==e.prototype||t(s(a))),(()=>!0)))(n)&&0==y(n),v=t=>new Map(t),h=(t,a)=>t?.get(a),l=(a,e,s)=>{return t(s)?(n=a,o=e,n?.delete(o),a):a?.set(e,s);var n,o},w=(t,a,e)=>{var s,n;return s=t,n=a,s?.has(n)||l(t,a,e()),h(t,a)},p=v(),g=v(),f=(t,a)=>[t[a].t,t[a].v],A=(a,e,s,n)=>{const o=t(e)?a:((t,a,e)=>(r(t,a)||(t[a]={}),t[a]))(a,e);let c;return d(s,((t,a)=>{n(o,a,t)&&(c=1)})),d(o,((t,a)=>{r(s,a)||(i(o,a),c=1)})),!t(e)&&u(o)&&i(a,e),c},L=(e,s,n="tinybase",r)=>(s.change((t=>t[n]={})),((e,s,n,c,r,i,[d,y]=[],v=[])=>{let f,A,L,S=0,C=0;w(p,v,(()=>0)),w(g,v,(()=>[]));const b=async t=>(2!=S&&(S=1,await m.schedule((async()=>{await t(),S=0}))),m),m={load:async(t,a)=>await b((async()=>{try{e.setContent(await s())}catch{e.setContent([t,a])}})),startAutoLoad:async(t={},a={})=>(m.stopAutoLoad(),await m.load(t,a),C=1,L=c((async(t,a)=>{if(a){const t=a();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(t?.()??await s())}catch(t){i?.(t)}}))})),m),stopAutoLoad:()=>(C&&(r(L),L=void 0,C=0),m),save:async t=>(1!=S&&(S=2,await m.schedule((async()=>{try{await n(e.getContent,t)}catch(t){i?.(t)}S=0}))),m),startAutoSave:async()=>(await m.stopAutoSave().save(),f=e.addDidFinishTransactionListener(((t,a)=>{const[e,s]=a();u(e)&&u(s)||m.save((()=>[e,s]))})),m),stopAutoSave:()=>(a(f,e.delListener),f=void 0,m),schedule:async(...a)=>(((t,...a)=>{t.push(...a)})(h(g,v),...a),await(async()=>{if(!h(p,v)){for(l(p,v,1);!t((a=h(g,v),A=a.shift()));)try{await A()}catch(t){i?.(t)}l(p,v,0)}var a})(),m),getStore:()=>e,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(m[d]=()=>y),o(m)})(e,(async()=>2==y(s.doc[n])?f(s.doc,n):void 0),(async(e,o)=>s.change((s=>((e,s,n,o)=>{((t,a)=>{u(t[a])&&(t[a]={t:{},v:{}})})(e,s);const[r,y]=f(e,s),v=()=>{h=1};let h=1;if(a(o?.(),(([e,s])=>{h=0,d(e,((e,s)=>h?0:t(e)?i(r,s):a(r[s],(s=>d(e,((e,n)=>h?0:t(e)?i(s,n):a(c(s,n),(a=>d(e,((e,s)=>t(e)?i(a,s):a[s]=e))),v)))),v))),d(s,((a,e)=>h?0:t(a)?i(y,e):y[e]=a))})),h){const[t,a]=n();A(r,void 0,t,((t,a,e)=>A(r,a,e,((t,a,e)=>A(t,a,e,((t,a,e)=>{if(c(t,a)!==e)return t[a]=e,1})))))),A(y,void 0,a,((t,a,e)=>{c(y,a)!==e&&(y[a]=e)}))}})(s,n,e,o)))),(t=>{const a=({doc:a})=>t((()=>f(a,n)));return s.on("change",a),a}),(t=>{s.removeListener("change",t)}),r,["getDocHandle",s]));export{L as createAutomergePersister};
1
+ const t=t=>null==t,a=(a,e,n)=>t(a)?n?.():e(a),e=Object,n=t=>e.getPrototypeOf(t),s=e.keys,o=e.freeze,c=(t,e)=>a(t,(t=>t[e])),r=(a,e)=>!t(c(a,e)),i=(t,a)=>(delete t[a],t),d=(t,a)=>((t,a)=>t.map(a))(e.entries(t),(([t,e])=>a(e,t))),y=t=>s(t).length,u=s=>(s=>!t(s)&&a(n(s),(a=>a==e.prototype||t(n(a))),(()=>!0)))(s)&&0==y(s),v=t=>new Map(t),h=(t,a)=>t?.get(a),l=(a,e,n)=>{return t(n)?(s=a,o=e,s?.delete(o),a):a?.set(e,n);var s,o},w=(t,a,e)=>{var n,s;return n=t,s=a,n?.has(s)||l(t,a,e()),h(t,a)},p=v(),g=v(),f=(t,a)=>[t[a].t,t[a].v],A=(a,e,n,s)=>{const o=t(e)?a:((t,a,e)=>(r(t,a)||(t[a]={}),t[a]))(a,e);let c;return d(n,((t,a)=>{s(o,a,t)&&(c=1)})),d(o,((t,a)=>{r(n,a)||(i(o,a),c=1)})),!t(e)&&u(o)&&i(a,e),c},L=(e,n,s="tinybase",r)=>(n.change((t=>t[s]={})),((e,n,s,c,r,i,[d,y]=[],v=[])=>{let f,A,L,S=0,C=0;w(p,v,(()=>0)),w(g,v,(()=>[]));const b=async t=>(2!=S&&(S=1,await m.schedule((async()=>{await t(),S=0}))),m),m={load:async(t,a)=>await b((async()=>{try{e.setContent(await n())}catch{e.setContent([t,a])}})),startAutoLoad:async(t={},a={})=>(m.stopAutoLoad(),await m.load(t,a),C=1,L=c((async(t,a)=>{if(a){const t=a();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(t?.()??await n())}catch(t){i?.(t)}}))})),m),stopAutoLoad:()=>(C&&(r(L),L=void 0,C=0),m),save:async t=>(1!=S&&(S=2,await m.schedule((async()=>{try{await s(e.getContent,t)}catch(t){i?.(t)}S=0}))),m),startAutoSave:async()=>(await m.stopAutoSave().save(),f=e.addDidFinishTransactionListener(((t,a)=>{const[e,n]=a();u(e)&&u(n)||m.save((()=>[e,n]))})),m),stopAutoSave:()=>(a(f,e.delListener),f=void 0,m),schedule:async(...a)=>(((t,...a)=>{t.push(...a)})(h(g,v),...a),await(async()=>{if(!h(p,v)){for(l(p,v,1);!t((a=h(g,v),A=a.shift()));)try{await A()}catch(t){i?.(t)}l(p,v,0)}var a})(),m),getStore:()=>e,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(m[d]=()=>y),o(m)})(e,(async()=>{const t=await n.doc();return 2==y(t[s])?f(t,s):void 0}),(async(e,o)=>n.change((n=>((e,n,s,o)=>{((t,a)=>{u(t[a])&&(t[a]={t:{},v:{}})})(e,n);const[r,y]=f(e,n),v=()=>{h=1};let h=1;if(a(o?.(),(([e,n])=>{h=0,d(e,((e,n)=>h?0:t(e)?i(r,n):a(r[n],(n=>d(e,((e,s)=>h?0:t(e)?i(n,s):a(c(n,s),(a=>d(e,((e,n)=>t(e)?i(a,n):a[n]=e))),v)))),v))),d(n,((a,e)=>h?0:t(a)?i(y,e):y[e]=a))})),h){const[t,a]=s();A(r,void 0,t,((t,a,e)=>A(r,a,e,((t,a,e)=>A(t,a,e,((t,a,e)=>{if(c(t,a)!==e)return t[a]=e,1})))))),A(y,void 0,a,((t,a,e)=>{c(y,a)!==e&&(y[a]=e)}))}})(n,s,e,o)))),(t=>{const a=({doc:a})=>t((()=>f(a,s)));return n.on("change",a),a}),(t=>{n.removeListener("change",t)}),r,["getDocHandle",n]));export{L as createAutomergePersister};
@@ -11,7 +11,7 @@
11
11
  * @since v4.0.0
12
12
  */
13
13
 
14
- import {DocHandle} from 'automerge-repo';
14
+ import {DocHandle} from '@automerge/automerge-repo';
15
15
  import {Persister} from '../persisters';
16
16
  import {Store} from '../store';
17
17
 
@@ -74,7 +74,7 @@ export interface AutomergePersister extends Persister {
74
74
  * await persister.save();
75
75
  * // Store will be saved to the document.
76
76
  *
77
- * console.log(docHandler.doc);
77
+ * console.log(await docHandler.doc());
78
78
  * // -> {tinybase: {t: {pets: {fido: {species: 'dog'}}}, v: {}}}
79
79
  *
80
80
  * persister.destroy();
@@ -90,7 +90,7 @@ export interface AutomergePersister extends Persister {
90
90
  * network: [new BroadcastChannelNetworkAdapter()],
91
91
  * });
92
92
  * const docHandler1 = repo1.create();
93
- * await docHandler1.value();
93
+ * await docHandler1.doc();
94
94
  * const store1 = createStore();
95
95
  * const persister1 = createAutomergePersister(store1, docHandler1);
96
96
  * await persister1.startAutoLoad();
@@ -101,7 +101,7 @@ export interface AutomergePersister extends Persister {
101
101
  * network: [new BroadcastChannelNetworkAdapter()],
102
102
  * });
103
103
  * const docHandler2 = repo2.find(docHandler1.documentId);
104
- * await docHandler2.value();
104
+ * await docHandler2.doc();
105
105
  * const store2 = createStore();
106
106
  * const persister2 = createAutomergePersister(store2, docHandler2);
107
107
  * await persister2.startAutoLoad();
@@ -110,9 +110,9 @@ export interface AutomergePersister extends Persister {
110
110
  * // A function that waits briefly and then for the documents to synchronize
111
111
  * // with each other, merely for the purposes of sequentiality in this example.
112
112
  * const syncDocsWait = async () => {
113
- * await new Promise((resolve) => setTimeout(() => resolve(0), 10));
114
- * await docHandler1.value();
115
- * await docHandler2.value();
113
+ * await new Promise((resolve) => setTimeout(() => resolve(0), 100));
114
+ * await docHandler1.doc();
115
+ * await docHandler2.doc();
116
116
  * };
117
117
  *
118
118
  * // Wait for the documents to synchronize in their initial state.
@@ -12,7 +12,7 @@
12
12
  */
13
13
 
14
14
  import {OptionalSchemas, Store} from '../store';
15
- import {DocHandle} from 'automerge-repo';
15
+ import {DocHandle} from '@automerge/automerge-repo';
16
16
  import {Persister} from '../persisters';
17
17
 
18
18
  /**
@@ -86,7 +86,7 @@ export interface AutomergePersister<Schemas extends OptionalSchemas>
86
86
  * await persister.save();
87
87
  * // Store will be saved to the document.
88
88
  *
89
- * console.log(docHandler.doc);
89
+ * console.log(await docHandler.doc());
90
90
  * // -> {tinybase: {t: {pets: {fido: {species: 'dog'}}}, v: {}}}
91
91
  *
92
92
  * persister.destroy();
@@ -102,7 +102,7 @@ export interface AutomergePersister<Schemas extends OptionalSchemas>
102
102
  * network: [new BroadcastChannelNetworkAdapter()],
103
103
  * });
104
104
  * const docHandler1 = repo1.create();
105
- * await docHandler1.value();
105
+ * await docHandler1.doc();
106
106
  * const store1 = createStore();
107
107
  * const persister1 = createAutomergePersister(store1, docHandler1);
108
108
  * await persister1.startAutoLoad();
@@ -113,7 +113,7 @@ export interface AutomergePersister<Schemas extends OptionalSchemas>
113
113
  * network: [new BroadcastChannelNetworkAdapter()],
114
114
  * });
115
115
  * const docHandler2 = repo2.find(docHandler1.documentId);
116
- * await docHandler2.value();
116
+ * await docHandler2.doc();
117
117
  * const store2 = createStore();
118
118
  * const persister2 = createAutomergePersister(store2, docHandler2);
119
119
  * await persister2.startAutoLoad();
@@ -122,9 +122,9 @@ export interface AutomergePersister<Schemas extends OptionalSchemas>
122
122
  * // A function that waits briefly and then for the documents to synchronize
123
123
  * // with each other, merely for the purposes of sequentiality in this example.
124
124
  * const syncDocsWait = async () => {
125
- * await new Promise((resolve) => setTimeout(() => resolve(0), 10));
126
- * await docHandler1.value();
127
- * await docHandler2.value();
125
+ * await new Promise((resolve) => setTimeout(() => resolve(0), 100));
126
+ * await docHandler1.doc();
127
+ * await docHandler2.doc();
128
128
  * };
129
129
  *
130
130
  * // Wait for the documents to synchronize in their initial state.
@@ -1 +1 @@
1
- var t,e;t=this,e=function(t){"use strict";const e=t=>null==t,a=(t,a,s)=>e(t)?s?.():a(t),s=Object,n=t=>s.getPrototypeOf(t),o=s.keys,c=s.freeze,i=(t,e)=>a(t,(t=>t[e])),r=(t,a)=>!e(i(t,a)),d=(t,e)=>(delete t[e],t),y=(t,e)=>((t,e)=>t.map(e))(s.entries(t),(([t,a])=>e(a,t))),u=t=>o(t).length,l=t=>(t=>!e(t)&&a(n(t),(t=>t==s.prototype||e(n(t))),(()=>!0)))(t)&&0==u(t),f=t=>new Map(t),h=(t,e)=>t?.get(e),p=(t,a,s)=>{return e(s)?(n=t,o=a,n?.delete(o),t):t?.set(a,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=f(),w=f(),A=(t,e)=>[t[e].t,t[e].v],L=(t,a,s,n)=>{const o=e(a)?t:((t,e,a)=>(r(t,e)||(t[e]={}),t[e]))(t,a);let c;return y(s,((t,e)=>{n(o,e,t)&&(c=1)})),y(o,((t,e)=>{r(s,e)||(d(o,e),c=1)})),!e(a)&&l(o)&&d(t,a),c};t.createAutomergePersister=(t,s,n="tinybase",o)=>(s.change((t=>t[n]={})),((t,s,n,o,i,r,[d,y]=[],u=[])=>{let f,A,L,m=0,S=0;v(g,u,(()=>0)),v(w,u,(()=>[]));const b=async t=>(2!=m&&(m=1,await C.schedule((async()=>{await t(),m=0}))),C),C={load:async(e,a)=>await b((async()=>{try{t.setContent(await s())}catch{t.setContent([e,a])}})),startAutoLoad:async(e={},a={})=>(C.stopAutoLoad(),await C.load(e,a),S=1,L=o((async(e,a)=>{if(a){const e=a();await b((async()=>t.setTransactionChanges(e)))}else await b((async()=>{try{t.setContent(e?.()??await s())}catch(t){r?.(t)}}))})),C),stopAutoLoad:()=>(S&&(i(L),L=void 0,S=0),C),save:async e=>(1!=m&&(m=2,await C.schedule((async()=>{try{await n(t.getContent,e)}catch(t){r?.(t)}m=0}))),C),startAutoSave:async()=>(await C.stopAutoSave().save(),f=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();l(a)&&l(s)||C.save((()=>[a,s]))})),C),stopAutoSave:()=>(a(f,t.delListener),f=void 0,C),schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(h(w,u),...t),await(async()=>{if(!h(g,u)){for(p(g,u,1);!e((t=h(w,u),A=t.shift()));)try{await A()}catch(t){r?.(t)}p(g,u,0)}var t})(),C),getStore:()=>t,destroy:()=>C.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(C[d]=()=>y),c(C)})(t,(async()=>2==u(s.doc[n])?A(s.doc,n):void 0),(async(t,o)=>s.change((s=>((t,s,n,o)=>{((t,e)=>{l(t[e])&&(t[e]={t:{},v:{}})})(t,s);const[c,r]=A(t,s),u=()=>{f=1};let f=1;if(a(o?.(),(([t,s])=>{f=0,y(t,((t,s)=>f?0:e(t)?d(c,s):a(c[s],(s=>y(t,((t,n)=>f?0:e(t)?d(s,n):a(i(s,n),(a=>y(t,((t,s)=>e(t)?d(a,s):a[s]=t))),u)))),u))),y(s,((t,a)=>f?0:e(t)?d(r,a):r[a]=t))})),f){const[t,e]=n();L(c,void 0,t,((t,e,a)=>L(c,e,a,((t,e,a)=>L(t,e,a,((t,e,a)=>{if(i(t,e)!==a)return t[e]=a,1})))))),L(r,void 0,e,((t,e,a)=>{i(r,e)!==a&&(r[e]=a)}))}})(s,n,t,o)))),(t=>{const e=({doc:e})=>t((()=>A(e,n)));return s.on("change",e),e}),(t=>{s.removeListener("change",t)}),o,["getDocHandle",s]))},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterAutomerge={});
1
+ var t,e;t=this,e=function(t){"use strict";const e=t=>null==t,a=(t,a,s)=>e(t)?s?.():a(t),s=Object,n=t=>s.getPrototypeOf(t),o=s.keys,c=s.freeze,i=(t,e)=>a(t,(t=>t[e])),r=(t,a)=>!e(i(t,a)),d=(t,e)=>(delete t[e],t),y=(t,e)=>((t,e)=>t.map(e))(s.entries(t),(([t,a])=>e(a,t))),u=t=>o(t).length,l=t=>(t=>!e(t)&&a(n(t),(t=>t==s.prototype||e(n(t))),(()=>!0)))(t)&&0==u(t),f=t=>new Map(t),h=(t,e)=>t?.get(e),p=(t,a,s)=>{return e(s)?(n=t,o=a,n?.delete(o),t):t?.set(a,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=f(),w=f(),A=(t,e)=>[t[e].t,t[e].v],L=(t,a,s,n)=>{const o=e(a)?t:((t,e,a)=>(r(t,e)||(t[e]={}),t[e]))(t,a);let c;return y(s,((t,e)=>{n(o,e,t)&&(c=1)})),y(o,((t,e)=>{r(s,e)||(d(o,e),c=1)})),!e(a)&&l(o)&&d(t,a),c};t.createAutomergePersister=(t,s,n="tinybase",o)=>(s.change((t=>t[n]={})),((t,s,n,o,i,r,[d,y]=[],u=[])=>{let f,A,L,m=0,S=0;v(g,u,(()=>0)),v(w,u,(()=>[]));const b=async t=>(2!=m&&(m=1,await C.schedule((async()=>{await t(),m=0}))),C),C={load:async(e,a)=>await b((async()=>{try{t.setContent(await s())}catch{t.setContent([e,a])}})),startAutoLoad:async(e={},a={})=>(C.stopAutoLoad(),await C.load(e,a),S=1,L=o((async(e,a)=>{if(a){const e=a();await b((async()=>t.setTransactionChanges(e)))}else await b((async()=>{try{t.setContent(e?.()??await s())}catch(t){r?.(t)}}))})),C),stopAutoLoad:()=>(S&&(i(L),L=void 0,S=0),C),save:async e=>(1!=m&&(m=2,await C.schedule((async()=>{try{await n(t.getContent,e)}catch(t){r?.(t)}m=0}))),C),startAutoSave:async()=>(await C.stopAutoSave().save(),f=t.addDidFinishTransactionListener(((t,e)=>{const[a,s]=e();l(a)&&l(s)||C.save((()=>[a,s]))})),C),stopAutoSave:()=>(a(f,t.delListener),f=void 0,C),schedule:async(...t)=>(((t,...e)=>{t.push(...e)})(h(w,u),...t),await(async()=>{if(!h(g,u)){for(p(g,u,1);!e((t=h(w,u),A=t.shift()));)try{await A()}catch(t){r?.(t)}p(g,u,0)}var t})(),C),getStore:()=>t,destroy:()=>C.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return d&&(C[d]=()=>y),c(C)})(t,(async()=>{const t=await s.doc();return 2==u(t[n])?A(t,n):void 0}),(async(t,o)=>s.change((s=>((t,s,n,o)=>{((t,e)=>{l(t[e])&&(t[e]={t:{},v:{}})})(t,s);const[c,r]=A(t,s),u=()=>{f=1};let f=1;if(a(o?.(),(([t,s])=>{f=0,y(t,((t,s)=>f?0:e(t)?d(c,s):a(c[s],(s=>y(t,((t,n)=>f?0:e(t)?d(s,n):a(i(s,n),(a=>y(t,((t,s)=>e(t)?d(a,s):a[s]=t))),u)))),u))),y(s,((t,a)=>f?0:e(t)?d(r,a):r[a]=t))})),f){const[t,e]=n();L(c,void 0,t,((t,e,a)=>L(c,e,a,((t,e,a)=>L(t,e,a,((t,e,a)=>{if(i(t,e)!==a)return t[e]=a,1})))))),L(r,void 0,e,((t,e,a)=>{i(r,e)!==a&&(r[e]=a)}))}})(s,n,t,o)))),(t=>{const e=({doc:e})=>t((()=>A(e,n)));return s.on("change",e),e}),(t=>{s.removeListener("change",t)}),o,["getDocHandle",s]))},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).TinyBasePersisterAutomerge={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,o)=>t(e)?null==o?void 0:o():n(e),o=Object,l=e=>o.getPrototypeOf(e),i=o.keys,r=o.freeze,u=(e,t)=>n(e,(e=>e[t])),d=(e,n)=>!t(u(e,n)),s=(e,t)=>(delete e[t],e),c=(e,t)=>((e,t)=>e.map(t))(o.entries(e),(([e,n])=>t(n,e))),a=e=>i(e).length,v=e=>(e=>!t(e)&&n(l(e),(e=>e==o.prototype||t(l(e))),(()=>!0)))(e)&&0==a(e),f=e=>new Map(e),y=(e,t)=>null==e?void 0:e.get(t),h=(e,n,o)=>{return t(o)?(i=n,null==(l=e)||l.delete(i),e):null==e?void 0:e.set(n,o);var l,i},p=(e,t,n)=>{var o,l,i;return l=t,null!=(i=null==(o=e)?void 0:o.has(l))&&i||h(e,t,n()),y(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const m=f(),A=f();var x=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const L=(e,t)=>[e[t].t,e[t].v],P=(e,n,o,l)=>{const i=t(n)?e:((e,t,n)=>(d(e,t)||(e[t]={}),e[t]))(e,n);let r;return c(o,((e,t)=>{l(i,t,e)&&(r=1)})),c(i,((e,t)=>{d(o,t)||(s(i,t),r=1)})),!t(n)&&v(i)&&s(e,n),r};e.createAutomergePersister=(e,o,l="tinybase",i)=>(o.change((e=>e[l]={})),((e,o,l,i,u,d,[s,c]=[],a=[])=>{let f,x,L,P=0,S=0;p(m,a,(()=>0)),p(A,a,(()=>[]));const b=e=>g(void 0,null,(function*(){return 2!=P&&(P=1,yield w.schedule((()=>g(void 0,null,(function*(){yield e(),P=0}))))),w})),w={load:(t,n)=>g(void 0,null,(function*(){return yield b((()=>g(void 0,null,(function*(){try{e.setContent(yield o())}catch(o){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>g(void 0,[...t],(function*(t={},n={}){return w.stopAutoLoad(),yield w.load(t,n),S=1,L=i(((t,n)=>g(void 0,null,(function*(){if(n){const t=n();yield b((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield b((()=>g(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield o())}catch(e){null==d||d(e)}}))))})))),w})),stopAutoLoad:()=>(S&&(u(L),L=void 0,S=0),w),save:t=>g(void 0,null,(function*(){return 1!=P&&(P=2,yield w.schedule((()=>g(void 0,null,(function*(){try{yield l(e.getContent,t)}catch(e){null==d||d(e)}P=0}))))),w})),startAutoSave:()=>g(void 0,null,(function*(){return yield w.stopAutoSave().save(),f=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||w.save((()=>[n,o]))})),w})),stopAutoSave:()=>(n(f,e.delListener),f=void 0,w),schedule:(...e)=>g(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(y(A,a),...e),yield g(void 0,null,(function*(){if(!y(m,a)){for(h(m,a,1);!t((e=y(A,a),x=e.shift()));)try{yield x()}catch(e){null==d||d(e)}h(m,a,0)}var e})),w})),getStore:()=>e,destroy:()=>w.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return s&&(w[s]=()=>c),r(w)})(e,(()=>x(void 0,null,(function*(){return 2==a(o.doc[l])?L(o.doc,l):void 0}))),((e,i)=>x(void 0,null,(function*(){return o.change((o=>((e,o,l,i)=>{((e,t)=>{v(e[t])&&(e[t]={t:{},v:{}})})(e,o);const[r,d]=L(e,o),a=()=>{f=1};let f=1;if(n(null==i?void 0:i(),(([e,o])=>{f=0,c(e,((e,o)=>f?0:t(e)?s(r,o):n(r[o],(o=>c(e,((e,l)=>f?0:t(e)?s(o,l):n(u(o,l),(n=>c(e,((e,o)=>t(e)?s(n,o):n[o]=e))),a)))),a))),c(o,((e,n)=>f?0:t(e)?s(d,n):d[n]=e))})),f){const[e,t]=l();P(r,void 0,e,((e,t,n)=>P(r,t,n,((e,t,n)=>P(e,t,n,((e,t,n)=>{if(u(e,t)!==n)return e[t]=n,1})))))),P(d,void 0,t,((e,t,n)=>{u(d,t)!==n&&(d[t]=n)}))}})(o,l,e,i)))}))),(e=>{const t=({doc:t})=>e((()=>L(t,l)));return o.on("change",t),t}),(e=>{o.removeListener("change",e)}),i,["getDocHandle",o]))},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterAutomerge={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>null==e,n=(e,n,o)=>t(e)?null==o?void 0:o():n(e),o=Object,l=e=>o.getPrototypeOf(e),i=o.keys,r=o.freeze,u=(e,t)=>n(e,(e=>e[t])),d=(e,n)=>!t(u(e,n)),s=(e,t)=>(delete e[t],e),c=(e,t)=>((e,t)=>e.map(t))(o.entries(e),(([e,n])=>t(n,e))),a=e=>i(e).length,v=e=>(e=>!t(e)&&n(l(e),(e=>e==o.prototype||t(l(e))),(()=>!0)))(e)&&0==a(e),f=e=>new Map(e),y=(e,t)=>null==e?void 0:e.get(t),h=(e,n,o)=>{return t(o)?(i=n,null==(l=e)||l.delete(i),e):null==e?void 0:e.set(n,o);var l,i},p=(e,t,n)=>{var o,l,i;return l=t,null!=(i=null==(o=e)?void 0:o.has(l))&&i||h(e,t,n()),y(e,t)};var g=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const m=f(),A=f();var x=(e,t,n)=>new Promise(((o,l)=>{var i=e=>{try{u(n.next(e))}catch(e){l(e)}},r=e=>{try{u(n.throw(e))}catch(e){l(e)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,r);u((n=n.apply(e,t)).next())}));const L=(e,t)=>[e[t].t,e[t].v],P=(e,n,o,l)=>{const i=t(n)?e:((e,t,n)=>(d(e,t)||(e[t]={}),e[t]))(e,n);let r;return c(o,((e,t)=>{l(i,t,e)&&(r=1)})),c(i,((e,t)=>{d(o,t)||(s(i,t),r=1)})),!t(n)&&v(i)&&s(e,n),r};e.createAutomergePersister=(e,o,l="tinybase",i)=>(o.change((e=>e[l]={})),((e,o,l,i,u,d,[s,c]=[],a=[])=>{let f,x,L,P=0,S=0;p(m,a,(()=>0)),p(A,a,(()=>[]));const b=e=>g(void 0,null,(function*(){return 2!=P&&(P=1,yield w.schedule((()=>g(void 0,null,(function*(){yield e(),P=0}))))),w})),w={load:(t,n)=>g(void 0,null,(function*(){return yield b((()=>g(void 0,null,(function*(){try{e.setContent(yield o())}catch(o){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>g(void 0,[...t],(function*(t={},n={}){return w.stopAutoLoad(),yield w.load(t,n),S=1,L=i(((t,n)=>g(void 0,null,(function*(){if(n){const t=n();yield b((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield b((()=>g(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield o())}catch(e){null==d||d(e)}}))))})))),w})),stopAutoLoad:()=>(S&&(u(L),L=void 0,S=0),w),save:t=>g(void 0,null,(function*(){return 1!=P&&(P=2,yield w.schedule((()=>g(void 0,null,(function*(){try{yield l(e.getContent,t)}catch(e){null==d||d(e)}P=0}))))),w})),startAutoSave:()=>g(void 0,null,(function*(){return yield w.stopAutoSave().save(),f=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||w.save((()=>[n,o]))})),w})),stopAutoSave:()=>(n(f,e.delListener),f=void 0,w),schedule:(...e)=>g(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(y(A,a),...e),yield g(void 0,null,(function*(){if(!y(m,a)){for(h(m,a,1);!t((e=y(A,a),x=e.shift()));)try{yield x()}catch(e){null==d||d(e)}h(m,a,0)}var e})),w})),getStore:()=>e,destroy:()=>w.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return s&&(w[s]=()=>c),r(w)})(e,(()=>x(void 0,null,(function*(){const e=yield o.doc();return 2==a(e[l])?L(e,l):void 0}))),((e,i)=>x(void 0,null,(function*(){return o.change((o=>((e,o,l,i)=>{((e,t)=>{v(e[t])&&(e[t]={t:{},v:{}})})(e,o);const[r,d]=L(e,o),a=()=>{f=1};let f=1;if(n(null==i?void 0:i(),(([e,o])=>{f=0,c(e,((e,o)=>f?0:t(e)?s(r,o):n(r[o],(o=>c(e,((e,l)=>f?0:t(e)?s(o,l):n(u(o,l),(n=>c(e,((e,o)=>t(e)?s(n,o):n[o]=e))),a)))),a))),c(o,((e,n)=>f?0:t(e)?s(d,n):d[n]=e))})),f){const[e,t]=l();P(r,void 0,e,((e,t,n)=>P(r,t,n,((e,t,n)=>P(e,t,n,((e,t,n)=>{if(u(e,t)!==n)return e[t]=n,1})))))),P(d,void 0,t,((e,t,n)=>{u(d,t)!==n&&(d[t]=n)}))}})(o,l,e,i)))}))),(e=>{const t=({doc:t})=>e((()=>L(t,l)));return o.on("change",t),t}),(e=>{o.removeListener("change",e)}),i,["getDocHandle",o]))},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterAutomerge={});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.6.2",
3
+ "version": "4.6.3",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -215,6 +215,7 @@
215
215
  },
216
216
  "devDependencies": {
217
217
  "@automerge/automerge": "^2.1.10",
218
+ "@automerge/automerge-repo": "^1.0.19",
218
219
  "@babel/cli": "^7.23.4",
219
220
  "@babel/core": "^7.23.7",
220
221
  "@babel/preset-env": "^7.23.8",
@@ -231,7 +232,7 @@
231
232
  "@types/jest": "^29.5.11",
232
233
  "@types/jest-environment-puppeteer": "^5.0.6",
233
234
  "@types/less": "^3.0.6",
234
- "@types/node": "^20.11.4",
235
+ "@types/node": "^20.11.5",
235
236
  "@types/puppeteer": "^5.4.7",
236
237
  "@types/react": "^18.2.48",
237
238
  "@types/react-dom": "^18.2.18",
@@ -241,7 +242,6 @@
241
242
  "@typescript-eslint/parser": "^6.19.0",
242
243
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
243
244
  "asciichart": "^1.5.25",
244
- "automerge-repo": "^0.1.0",
245
245
  "babel-eslint": "^10.1.0",
246
246
  "babel-jest": "^29.7.0",
247
247
  "babel-plugin-transform-import-meta": "^2.2.1",
@@ -250,7 +250,7 @@
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.8.2",
253
+ "electric-sql": "^0.9.0",
254
254
  "esbuild": "^0.19.11",
255
255
  "eslint": "^8.56.0",
256
256
  "eslint-config-prettier": "^9.1.0",
@@ -269,14 +269,14 @@
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.72",
273
- "partysocket": "^0.0.20",
274
- "prettier": "^3.2.2",
272
+ "partykit": "^0.0.74",
273
+ "partysocket": "^0.0.21",
274
+ "prettier": "^3.2.4",
275
275
  "puppeteer": "21.7.0",
276
276
  "react": "^18.2.0",
277
277
  "react-dom": "^18.2.0",
278
278
  "react-test-renderer": "^18.2.0",
279
- "rollup": "^4.9.5",
279
+ "rollup": "^4.9.6",
280
280
  "rollup-plugin-esbuild": "^6.1.0",
281
281
  "rollup-plugin-gzip": "^3.1.1",
282
282
  "rollup-plugin-preserve-shebang": "^1.0.1",
@@ -288,29 +288,29 @@
288
288
  "ts-unused-exports": "^10.0.1",
289
289
  "typescript": "5.3.3",
290
290
  "wa-sqlite": "github:rhashimoto/wa-sqlite",
291
- "yjs": "^13.6.10"
291
+ "yjs": "^13.6.11"
292
292
  },
293
293
  "peerDependencies": {
294
+ "@automerge/automerge-repo": "^1.0.19",
294
295
  "@sqlite.org/sqlite-wasm": "^3.44.2-build3",
295
296
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
296
- "automerge-repo": "^0.1.0",
297
- "electric-sql": "^0.8.2",
298
- "partykit": "^0.0.72",
299
- "partysocket": "^0.0.20",
300
- "prettier": "^3.2.2",
297
+ "electric-sql": "^0.9.0",
298
+ "partykit": "^0.0.74",
299
+ "partysocket": "^0.0.21",
300
+ "prettier": "^3.2.4",
301
301
  "react": "^18.2.0",
302
302
  "react-dom": "^18.2.0",
303
303
  "sqlite3": "^5.1.7",
304
- "yjs": "^13.6.10"
304
+ "yjs": "^13.6.11"
305
305
  },
306
306
  "peerDependenciesMeta": {
307
- "@sqlite.org/sqlite-wasm": {
307
+ "@automerge/automerge-repo": {
308
308
  "optional": true
309
309
  },
310
- "@vlcn.io/crsqlite-wasm": {
310
+ "@sqlite.org/sqlite-wasm": {
311
311
  "optional": true
312
312
  },
313
- "automerge-repo": {
313
+ "@vlcn.io/crsqlite-wasm": {
314
314
  "optional": true
315
315
  },
316
316
  "electric-sql": {
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.2" 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.3" 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()