tinybase 4.7.3 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs +1 -1
- package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-electric-sql.cjs +1 -1
- package/lib/cjs/persisters/persister-electric-sql.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-expo-sqlite-next.cjs +1 -1
- package/lib/cjs/persisters/persister-expo-sqlite-next.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-expo-sqlite.cjs +1 -1
- package/lib/cjs/persisters/persister-expo-sqlite.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-libsql.cjs +1 -1
- package/lib/cjs/persisters/persister-libsql.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-powersync.cjs +1 -0
- package/lib/cjs/persisters/persister-powersync.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-sqlite-wasm.cjs +1 -1
- package/lib/cjs/persisters/persister-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs/persisters/persister-sqlite3.cjs +1 -1
- package/lib/cjs/persisters/persister-sqlite3.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-electric-sql.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-electric-sql.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-expo-sqlite-next.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-expo-sqlite-next.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-expo-sqlite.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-expo-sqlite.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-libsql.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-libsql.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-powersync.cjs +1 -0
- package/lib/cjs-es6/persisters/persister-powersync.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs.gz +0 -0
- package/lib/cjs-es6/persisters/persister-sqlite3.cjs +1 -1
- package/lib/cjs-es6/persisters/persister-sqlite3.cjs.gz +0 -0
- package/lib/debug/persisters/persister-cr-sqlite-wasm.js +24 -13
- package/lib/debug/persisters/persister-electric-sql.js +24 -13
- package/lib/debug/persisters/persister-expo-sqlite-next.js +24 -13
- package/lib/debug/persisters/persister-expo-sqlite.js +24 -13
- package/lib/debug/persisters/persister-libsql.js +24 -13
- package/lib/debug/persisters/persister-powersync.js +892 -0
- package/lib/debug/persisters/persister-sqlite-wasm.js +24 -13
- package/lib/debug/persisters/persister-sqlite3.js +24 -13
- package/lib/es6/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/es6/persisters/persister-electric-sql.js +1 -1
- package/lib/es6/persisters/persister-electric-sql.js.gz +0 -0
- package/lib/es6/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/es6/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/es6/persisters/persister-expo-sqlite.js +1 -1
- package/lib/es6/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/es6/persisters/persister-libsql.js +1 -1
- package/lib/es6/persisters/persister-libsql.js.gz +0 -0
- package/lib/es6/persisters/persister-powersync.js +1 -0
- package/lib/es6/persisters/persister-powersync.js.gz +0 -0
- package/lib/es6/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/es6/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/es6/persisters/persister-sqlite3.js +1 -1
- package/lib/es6/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/persisters/persister-electric-sql.js +1 -1
- package/lib/persisters/persister-electric-sql.js.gz +0 -0
- package/lib/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/persisters/persister-expo-sqlite.js +1 -1
- package/lib/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/persisters/persister-libsql.js +1 -1
- package/lib/persisters/persister-libsql.js.gz +0 -0
- package/lib/persisters/persister-powersync.js +1 -0
- package/lib/persisters/persister-powersync.js.gz +0 -0
- package/lib/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/persisters/persister-sqlite3.js +1 -1
- package/lib/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/types/persisters/persister-powersync.d.ts +154 -0
- package/lib/types/persisters.d.ts +1 -0
- package/lib/types/with-schemas/persisters/persister-automerge.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-browser.d.ts +2 -2
- package/lib/types/with-schemas/persisters/persister-cr-sqlite-wasm.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-electric-sql.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-expo-sqlite-next.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-expo-sqlite.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-file.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-libsql.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-partykit-client.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-powersync.d.ts +167 -0
- package/lib/types/with-schemas/persisters/persister-remote.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-sqlite-wasm.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-sqlite3.d.ts +1 -1
- package/lib/types/with-schemas/persisters/persister-yjs.d.ts +1 -1
- package/lib/types/with-schemas/persisters.d.ts +1 -0
- package/lib/umd/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/umd/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/umd/persisters/persister-electric-sql.js +1 -1
- package/lib/umd/persisters/persister-electric-sql.js.gz +0 -0
- package/lib/umd/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/umd/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/umd/persisters/persister-expo-sqlite.js +1 -1
- package/lib/umd/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/umd/persisters/persister-libsql.js +1 -1
- package/lib/umd/persisters/persister-libsql.js.gz +0 -0
- package/lib/umd/persisters/persister-powersync.js +1 -0
- package/lib/umd/persisters/persister-powersync.js.gz +0 -0
- package/lib/umd/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/umd/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/umd/persisters/persister-sqlite3.js +1 -1
- package/lib/umd/persisters/persister-sqlite3.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js +1 -1
- package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-electric-sql.js +1 -1
- package/lib/umd-es6/persisters/persister-electric-sql.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-expo-sqlite-next.js +1 -1
- package/lib/umd-es6/persisters/persister-expo-sqlite-next.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-expo-sqlite.js +1 -1
- package/lib/umd-es6/persisters/persister-expo-sqlite.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-libsql.js +1 -1
- package/lib/umd-es6/persisters/persister-libsql.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-powersync.js +1 -0
- package/lib/umd-es6/persisters/persister-powersync.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-sqlite-wasm.js +1 -1
- package/lib/umd-es6/persisters/persister-sqlite-wasm.js.gz +0 -0
- package/lib/umd-es6/persisters/persister-sqlite3.js +1 -1
- package/lib/umd-es6/persisters/persister-sqlite3.js.gz +0 -0
- package/package.json +21 -16
- package/readme.md +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,l="tinybase",t="",o=",",i=n(t),r=(e,n)=>e.repeat(n),u=Promise,d=clearInterval,a=e=>null==e,s=(e,n,l)=>a(e)?null==l?void 0:l():n(e),c=e=>n(e)==i,v=(e,n,l)=>e.slice(n,l),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,l)=>{var t=e=>{try{i(n.next(e))}catch(e){l(e)}},o=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,o);i((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,l="tinybase",t="",o=",",i=n(t),r=(e,n)=>e.repeat(n),u=Promise,d=clearInterval,a=e=>null==e,s=(e,n,l)=>a(e)?null==l?void 0:l():n(e),c=e=>n(e)==i,v=(e,n,l)=>e.slice(n,l),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,l)=>{var t=e=>{try{i(n.next(e))}catch(e){l(e)}},o=e=>{try{i(n.throw(e))}catch(e){l(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,o);i((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",m=e=>`"${e.replace(/"/g,'""')}"`,E="SELECT",P=(e,n="")=>e.join(n),O=(e,n)=>e.map(n),b=e=>0==y(e),A=(e,n)=>e.filter(n),T=(e,...n)=>e.push(...n),w=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},L=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},N=(e,n)=>null==e?void 0:e.delete(n),g=Object,x=e=>g.getPrototypeOf(e),C=g.keys,R=g.freeze,S=(e=[])=>g.fromEntries(e),I=(...e)=>g.assign({},...e),D=(e,n)=>O(g.entries(e),(([e,l])=>n(l,e))),j=e=>g.values(e),_=e=>y(C(e)),F=e=>(e=>!a(e)&&s(x(e),(e=>e==g.prototype||a(x(e))),(()=>!0)))(e)&&0==_(e),M=e=>new Map(e),B=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},q=(e,n)=>null==e?void 0:e.get(n),H=(e,n)=>{var l;return O([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},Y=(e,n,l)=>a(l)?(N(e,n),e):null==e?void 0:e.set(n,l),$=(e,n,l)=>(w(e,n)||Y(e,n,l()),q(e,n)),k=(e,n,l,t=Y)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>((e,n)=>!a(((e,n)=>s(e,(e=>e[n])))(e,n)))(n,l)?0:t(e,l))),e),G=e=>new Set(Array.isArray(e)||a(e)?e:[e]),J=(e,n)=>null==e?void 0:e.add(n);var U=Object.defineProperty,W=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(e,n,l)=>n in e?U(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,Q=(e,n)=>{for(var l in n||(n={}))z.call(n,l)&&V(e,l,n[l]);if(W)for(var l of W(n))K.call(n,l)&&V(e,l,n[l]);return e},X=(e,n,l)=>new Promise(((t,o)=>{var i=e=>{try{u(l.next(e))}catch(e){o(e)}},r=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,r);u((l=l.apply(e,n)).next())}));const Z="TABLE",ee="ALTER "+Z,ne="DELETE FROM",le=E+"*FROM",te="FROM pragma_table_",oe="WHERE",ie=(e,n,l,i)=>{const r=M();return[()=>X(void 0,null,(function*(){return k(r,S(yield f(O(yield e("SELECT name "+te+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ue(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,S(O(yield e(E+" name,type "+te+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>Y(r,n,k($(r,n,M),l,((e,n,l)=>{l!=q(e,n)&&Y(e,n,l)}),((e,n)=>Y(e,n))))),((e,n)=>Y(r,n)))})),(n,l)=>X(void 0,null,(function*(){return((e,n)=>!a(q(q(r,e),n)))(n,l)?S(A(O(yield e(le+m(n)),(e=>{return[e[l],(n=Q({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!a(e)&&!F(n)))):{}})),(n,l,u,d,s,c=!1)=>X(void 0,null,(function*(){const v=G();D(null!=u?u:{},(e=>O(C(null!=e?e:{}),(e=>J(v,e)))));const y=L(v);if(!c&&s&&b(y)&&w(r,n))return yield e("DROP "+Z+m(n)),void Y(r,n);if(b(y)||w(r,n)){const o=q(r,n),i=G(B(o));yield f([...O(y,(l=>X(void 0,null,(function*(){N(i,l)||(yield e(ee+m(n)+"ADD"+m(l)),Y(o,l,t))})))),...!c&&d?O(L(i),(t=>X(void 0,null,(function*(){t!=l&&(yield e(ee+m(n)+"DROP"+m(t)),Y(o,t))})))):[]])}else yield e("CREATE "+Z+m(n)+"("+m(l)+` PRIMARY KEY ON CONFLICT REPLACE${P(O(y,(e=>o+m(e))))});`),Y(r,n,M([[l,t],...O(y,(e=>[e,t]))]));if(c)a(u)?yield e(ne+m(n)+oe+" 1"):yield f(D(u,((t,o)=>X(void 0,null,(function*(){a(t)?yield e(ne+m(n)+oe+m(l)+"=?",[o]):b(y)||(yield re(e,n,l,C(t),[o,...j(t)],i))})))));else if(b(y))w(r,n)&&(yield e(ne+m(n)+oe+" 1"));else{const t=A(B(q(r,n)),(e=>e!=l)),o=[],d=[];D(null!=u?u:{},((e,n)=>{T(o,n,...O(t,(n=>null==e?void 0:e[n]))),T(d,n)})),yield re(e,n,l,t,o,i),yield e(ne+m(n)+oe+m(l)+"NOT IN("+ue(d)+")",d)}})),n=>X(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},re=(e,n,l,i,u,d=!0)=>X(void 0,null,(function*(){return yield e("INSERT "+(d?t:"OR REPLACE ")+"INTO"+m(n)+"("+m(l)+P(O(i,(e=>o+m(e))))+")VALUES"+v(r(`,(?${r(",?",y(i))})`,y(u)/(y(i)+1)),1)+(d?"ON CONFLICT("+m(l)+")DO UPDATE SET"+P(O(i,(e=>m(e)+"=excluded."+m(e))),o):t),O(u,(e=>null!=e?e:null)))})),ue=e=>P(O(e,(()=>"?")),o),de=JSON.parse;var ae=(e,n,l)=>new Promise(((t,o)=>{var i=e=>{try{u(l.next(e))}catch(e){o(e)}},r=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,r);u((l=l.apply(e,n)).next())}));const se=M(),ce=M(),ve=(e,n,l,t,o,i,[r,u]=[],d=[])=>{let c,v,y,f=0,p=0;$(se,d,(()=>0)),$(ce,d,(()=>[]));const h=e=>ae(void 0,null,(function*(){return 2!=f&&(f=1,yield m.schedule((()=>ae(void 0,null,(function*(){yield e(),f=0}))))),m})),m={load:(l,t)=>ae(void 0,null,(function*(){return yield h((()=>ae(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([l,t])}}))))})),startAutoLoad:(...l)=>ae(void 0,[...l],(function*(l={},o={}){return m.stopAutoLoad(),yield m.load(l,o),p=1,y=t(((l,t)=>ae(void 0,null,(function*(){if(t){const n=t();yield h((()=>ae(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>ae(void 0,null,(function*(){var t;try{e.setContent(null!=(t=null==l?void 0:l())?t:yield n())}catch(e){null==i||i(e)}}))))})))),m})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),m),save:n=>ae(void 0,null,(function*(){return 1!=f&&(f=2,yield m.schedule((()=>ae(void 0,null,(function*(){try{yield l(e.getContent,n)}catch(e){null==i||i(e)}f=0}))))),m})),startAutoSave:()=>ae(void 0,null,(function*(){return yield m.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,n)=>{const[l,t]=n();F(l)&&F(t)||m.save((()=>[l,t]))})),m})),stopAutoSave:()=>(s(c,e.delListener),c=void 0,m),schedule:(...e)=>ae(void 0,null,(function*(){return T(q(ce,d),...e),yield ae(void 0,null,(function*(){if(!q(se,d)){for(Y(se,d,1);!a((e=q(ce,d),v=e.shift()));)try{yield v()}catch(e){null==i||i(e)}Y(se,d,0)}var e})),m})),getStore:()=>e,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return r&&(m[r]=()=>u),R(m)};var ye=(e,n,l)=>new Promise(((t,o)=>{var i=e=>{try{u(l.next(e))}catch(e){o(e)}},r=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,r);u((l=l.apply(e,n)).next())}));const fe="store",pe=(e,n,l,t,o,[i],r,u,d,a)=>{const[s,c,v,y]=ie(n,r,o,a);return ve(e,(()=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var e,n;return yield s(),de(null!=(n=null==(e=(yield c(i,h))[p])?void 0:e[fe])?n:"null")}))))}))),(e=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var n,l;yield s(),yield v(i,h,{[p]:{[fe]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>n instanceof Map?g.fromEntries([...n]):n)))}},!0,!0)}))))}))),l,t,o,[d,u],u)};var he=(e,n,l)=>new Promise(((t,o)=>{var i=e=>{try{u(l.next(e))}catch(e){o(e)}},r=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,r);u((l=l.apply(e,n)).next())}));const me=(e,n,l,t,o,[i,r,[u,d,s]],c,v,y,m)=>{const[E,P,O,b]=ie(n,c,o,m),T=(e,n)=>he(void 0,null,(function*(){return yield f(H(r,((l,t)=>he(void 0,[l,t],(function*([l,t,o,i],r){const u=e[r];n&&void 0===u||(yield O(l,t,u,o,i,n))})))))})),w=(e,n)=>he(void 0,null,(function*(){return d?yield O(s,h,{[p]:e},!0,!0,n):null}));return ve(e,(()=>he(void 0,null,(function*(){return yield b((()=>he(void 0,null,(function*(){yield E();const e=yield he(void 0,null,(function*(){return S(A(yield f(H(i,((e,n)=>he(void 0,[e,n],(function*([e,n],l){return[e,yield P(l,n)]}))))),(e=>!F(e[1]))))})),n=yield he(void 0,null,(function*(){return u?(yield P(s,h))[p]:{}}));return F(e)&&a(n)?void 0:[e,n]}))))}))),((e,n)=>he(void 0,null,(function*(){return yield b((()=>he(void 0,null,(function*(){if(yield E(),a(n)){const[n,l]=e();yield T(n),yield w(l)}else{const[e,l]=n();yield T(e,!0),yield w(l,!0)}}))))}))),l,t,o,[y,v],v)},Ee="json",Pe="autoLoadIntervalSeconds",Oe="rowIdColumnName",be="tableId",Ae="tableName",Te={mode:Ee,[Pe]:1},we={load:0,save:0,[Ae]:l+"_values"},Le=(e,n,l,t)=>{const o=M();return D(e,((e,i)=>{const r=v(j(I(n,c(e)?{[l]:e}:e)),0,_(n));a(r[0])||t(i,r[0])||Y(o,i,r)})),o};var Ne=(e,n,l)=>new Promise(((t,o)=>{var i=e=>{try{u(l.next(e))}catch(e){o(e)}},r=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(i,r);u((l=l.apply(e,n)).next())}));const ge="pragma ",xe="data_version",Ce="schema_version",Re=(e,n,t,o,i,r,u,a,s="getDb",y)=>{let f,p,m;const[P,O,b,A]=(e=>{const n=(e=>I(Te,c(e)?{storeTableName:e}:null!=e?e:{}))(e),t=n[Pe];if(n.mode==Ee){const{storeTableName:e=l}=n;return[1,t,[e],G(e)]}const{tables:{load:o={},save:i={}}={},values:r={}}=n,u=v(j(I(we,r)),0,_(we)),d=u[2],a=G(d);return[0,t,[Le(o,{[be]:null,[Oe]:h},be,(e=>J(a,e)&&e==d)),Le(i,{[Ae]:null,[Oe]:h,deleteEmptyColumns:0,deleteEmptyTable:0},Ae,((e,n)=>J(a,n)&&n==d)),u],a]})(n);return(P?pe:me)(e,r?(e,n)=>Ne(void 0,null,(function*(){return r(e,n),yield t(e,n)})):t,(e=>{return[(n=()=>Ne(void 0,null,(function*(){try{const n=(yield t(ge+xe))[0][xe],l=(yield t(ge+Ce))[0][Ce],o=(yield t(E+" TOTAL_CHANGES() c"))[0].c;n==(null!=f?f:f=n)&&l==(null!=p?p:p=l)&&o==(null!=m?m:m=o)||(e(),f=n,p=l)}catch(e){}})),l=O,n(),setInterval(n,1e3*l)),o((n=>A.has(n)?e():0))];var n,l}),(([e,n])=>{d(e),f=p=null,i(n)}),u,b,L(A),a,s,y)};e.createLibSqlPersister=(e,n,l,t,o)=>Re(e,l,((e,...l)=>{return t=[e,...l],o=function*(e,l=[]){return(yield n.execute({sql:e,args:l})).rows},new Promise(((e,n)=>{var l=e=>{try{r(o.next(e))}catch(e){n(e)}},i=e=>{try{r(o.throw(e))}catch(e){n(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,i);r((o=o.apply(void 0,t)).next())}));var t,o}),(()=>()=>0),(e=>e()),t,o,n,"getClient")},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterLibsql={});
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,l="tinybase",t="",o=",",r=n(t),i=(e,n)=>e.repeat(n),u=Promise,a=clearInterval,d=e=>null==e,c=(e,n,l)=>d(e)?null==l?void 0:l():n(e),s=e=>n(e)==r,v=(e,n,l)=>e.slice(n,l),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,l)=>{var t=e=>{try{r(n.next(e))}catch(e){l(e)}},o=e=>{try{r(n.throw(e))}catch(e){l(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,o);r((n=n.apply(void 0,null)).next())}));var n},h="_",p="_id",m=e=>`"${e.replace(/"/g,'""')}"`,E="SELECT",P=(e,n="")=>e.join(n),b=(e,n)=>e.map(n),w=e=>0==y(e),O=(e,n)=>e.filter(n),T=(e,...n)=>e.push(...n),A=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},g=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},S=(e,n)=>null==e?void 0:e.delete(n),x=Object,N=e=>x.getPrototypeOf(e),C=x.keys,L=x.freeze,R=(e=[])=>x.fromEntries(e),I=(...e)=>x.assign({},...e),D=(e,n)=>b(x.entries(e),(([e,l])=>n(l,e))),_=e=>x.values(e),j=e=>y(C(e)),F=e=>(e=>!d(e)&&c(N(e),(e=>e==x.prototype||d(N(e))),(()=>!0)))(e)&&0==j(e),M=e=>new Map(e),B=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},H=(e,n)=>null==e?void 0:e.get(n),Y=(e,n)=>{var l;return b([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},$=(e,n,l)=>d(l)?(S(e,n),e):null==e?void 0:e.set(n,l),k=(e,n,l)=>(A(e,n)||$(e,n,l()),H(e,n)),G=(e,n,l,t=$)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>((e,n)=>!d(((e,n)=>c(e,(e=>e[n])))(e,n)))(n,l)?0:t(e,l))),e),J=e=>new Set(Array.isArray(e)||d(e)?e:[e]),U=(e,n)=>null==e?void 0:e.add(n);var W=Object.defineProperty,z=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,q=(e,n,l)=>n in e?W(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,Q=(e,n)=>{for(var l in n||(n={}))K.call(n,l)&&q(e,l,n[l]);if(z)for(var l of z(n))V.call(n,l)&&q(e,l,n[l]);return e},X=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const Z="TABLE",ee="ALTER "+Z,ne="DELETE FROM",le=E+"*FROM",te="FROM pragma_table_",oe="WHERE",re=(e,n,l,r)=>{const i=M();return[()=>X(void 0,null,(function*(){return G(i,R(yield f(b(yield e("SELECT name "+te+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ue(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,R(b(yield e(E+" name,type "+te+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>$(i,n,G(k(i,n,M),l,((e,n,l)=>{l!=H(e,n)&&$(e,n,l)}),((e,n)=>$(e,n))))),((e,n)=>$(i,n)))})),(n,l)=>X(void 0,null,(function*(){return((e,n)=>!d(H(H(i,e),n)))(n,l)?R(O(b(yield e(le+m(n)),(e=>{return[e[l],(n=Q({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!d(e)&&!F(n)))):{}})),(n,l,u,a,c,s=!1)=>X(void 0,null,(function*(){const v=J();D(null!=u?u:{},(e=>b(C(null!=e?e:{}),(e=>U(v,e)))));const y=g(v);if(!s&&c&&w(y)&&A(i,n))return yield e("DROP "+Z+m(n)),void $(i,n);if(w(y)||A(i,n)){const o=H(i,n),r=J(B(o));yield f([...b(y,(l=>X(void 0,null,(function*(){S(r,l)||(yield e(ee+m(n)+"ADD"+m(l)),$(o,l,t))})))),...!s&&a?b(g(r),(t=>X(void 0,null,(function*(){t!=l&&(yield e(ee+m(n)+"DROP"+m(t)),$(o,t))})))):[]])}else yield e("CREATE "+Z+m(n)+"("+m(l)+` PRIMARY KEY ON CONFLICT REPLACE${P(b(y,(e=>o+m(e))))});`),$(i,n,M([[l,t],...b(y,(e=>[e,t]))]));if(s)d(u)?yield e(ne+m(n)+oe+" 1"):yield f(D(u,((t,o)=>X(void 0,null,(function*(){d(t)?yield e(ne+m(n)+oe+m(l)+"=?",[o]):w(y)||(yield ie(e,n,l,C(t),[o,..._(t)],r))})))));else if(w(y))A(i,n)&&(yield e(ne+m(n)+oe+" 1"));else{const t=O(B(H(i,n)),(e=>e!=l)),o=[],a=[];D(null!=u?u:{},((e,n)=>{T(o,n,...b(t,(n=>null==e?void 0:e[n]))),T(a,n)})),yield ie(e,n,l,t,o,r),yield e(ne+m(n)+oe+m(l)+"NOT IN("+ue(a)+")",a)}})),n=>X(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},ie=(e,n,l,r,u,a=!0)=>X(void 0,null,(function*(){return yield e("INSERT "+(a?t:"OR REPLACE ")+"INTO"+m(n)+"("+m(l)+P(b(r,(e=>o+m(e))))+")VALUES"+v(i(`,(?${i(",?",y(r))})`,y(u)/(y(r)+1)),1)+(a?"ON CONFLICT("+m(l)+")DO UPDATE SET"+P(b(r,(e=>m(e)+"=excluded."+m(e))),o):t),b(u,(e=>null!=e?e:null)))})),ue=e=>P(b(e,(()=>"?")),o),ae=JSON.parse;var de=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const ce=M(),se=M(),ve=(e,n,l,t,o,r,[i,u]=[],a=[])=>{let s,v,y,f=0,h=0;k(ce,a,(()=>0)),k(se,a,(()=>[]));const p=e=>de(void 0,null,(function*(){return 2!=f&&(f=1,yield m.schedule((()=>de(void 0,null,(function*(){yield e(),f=0}))))),m})),m={load:(l,t)=>de(void 0,null,(function*(){return yield p((()=>de(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([l,t])}}))))})),startAutoLoad:(...l)=>de(void 0,[...l],(function*(l={},o={}){return m.stopAutoLoad(),yield m.load(l,o),h=1,y=t(((l,t)=>de(void 0,null,(function*(){if(t){const n=t();yield p((()=>de(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield p((()=>de(void 0,null,(function*(){var t;try{e.setContent(null!=(t=null==l?void 0:l())?t:yield n())}catch(e){null==r||r(e)}}))))})))),m})),stopAutoLoad:()=>(h&&(o(y),y=void 0,h=0),m),save:n=>de(void 0,null,(function*(){return 1!=f&&(f=2,yield m.schedule((()=>de(void 0,null,(function*(){try{yield l(e.getContent,n)}catch(e){null==r||r(e)}f=0}))))),m})),startAutoSave:()=>de(void 0,null,(function*(){return yield m.stopAutoSave().save(),s=e.addDidFinishTransactionListener(((e,n)=>{const[l,t]=n();F(l)&&F(t)||m.save((()=>[l,t]))})),m})),stopAutoSave:()=>(c(s,e.delListener),s=void 0,m),schedule:(...e)=>de(void 0,null,(function*(){return T(H(se,a),...e),yield de(void 0,null,(function*(){if(!H(ce,a)){for($(ce,a,1);!d((e=H(se,a),v=e.shift()));)try{yield v()}catch(e){null==r||r(e)}$(ce,a,0)}var e})),m})),getStore:()=>e,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return i&&(m[i]=()=>u),L(m)};var ye=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const fe="store",he=(e,n,l,t,o,[r],i,u,a,d)=>{const[c,s,v,y]=re(n,i,o,d);return ve(e,(()=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var e,n;return yield c(),ae(null!=(n=null==(e=(yield s(r,p))[h])?void 0:e[fe])?n:"null")}))))}))),(e=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var n,l;yield c(),yield v(r,p,{[h]:{[fe]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>n instanceof Map?x.fromEntries([...n]):n)))}},!0,!0)}))))}))),l,t,o,[a,u],u)};var pe=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const me=(e,n,l,t,o,[r,i,[u,a,c]],s,v,y,m)=>{const[E,P,b,w]=re(n,s,o,m),T=(e,n)=>pe(void 0,null,(function*(){return yield f(Y(i,((l,t)=>pe(void 0,[l,t],(function*([l,t,o,r],i){const u=e[i];n&&void 0===u||(yield b(l,t,u,o,r,n))})))))})),A=(e,n)=>pe(void 0,null,(function*(){return a?yield b(c,p,{[h]:e},!0,!0,n):null}));return ve(e,(()=>pe(void 0,null,(function*(){return yield w((()=>pe(void 0,null,(function*(){yield E();const e=yield pe(void 0,null,(function*(){return R(O(yield f(Y(r,((e,n)=>pe(void 0,[e,n],(function*([e,n],l){return[e,yield P(l,n)]}))))),(e=>!F(e[1]))))})),n=yield pe(void 0,null,(function*(){return u?(yield P(c,p))[h]:{}}));return F(e)&&d(n)?void 0:[e,n]}))))}))),((e,n)=>pe(void 0,null,(function*(){return yield w((()=>pe(void 0,null,(function*(){if(yield E(),d(n)){const[n,l]=e();yield T(n),yield A(l)}else{const[e,l]=n();yield T(e,!0),yield A(l,!0)}}))))}))),l,t,o,[y,v],v)},Ee="json",Pe="autoLoadIntervalSeconds",be="rowIdColumnName",we="tableId",Oe="tableName",Te={mode:Ee,[Pe]:1},Ae={load:0,save:0,[Oe]:l+"_values"},ge=(e,n,l,t)=>{const o=M();return D(e,((e,r)=>{const i=v(_(I(n,s(e)?{[l]:e}:e)),0,j(n));d(i[0])||t(r,i[0])||$(o,r,i)})),o};var Se=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const xe="pragma ",Ne="data_version",Ce="schema_version",Le=(e,n,t,o,r,i,u,d,c="getDb",y)=>{let f,h,m;const[P,b,w,O]=(e=>{const n=(e=>I(Te,s(e)?{storeTableName:e}:null!=e?e:{}))(e),t=n[Pe];if(n.mode==Ee){const{storeTableName:e=l}=n;return[1,t,[e],J(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=v(_(I(Ae,i)),0,j(Ae)),a=u[2],d=J(a);return[0,t,[ge(o,{[we]:null,[be]:p},we,(e=>U(d,e)&&e==a)),ge(r,{[Oe]:null,[be]:p,deleteEmptyColumns:0,deleteEmptyTable:0},Oe,((e,n)=>U(d,n)&&n==a)),u],d]})(n);return(P?he:me)(e,i?(e,n)=>Se(void 0,null,(function*(){return i(e,n),yield t(e,n)})):t,(e=>{return[(n=()=>Se(void 0,null,(function*(){try{const n=(yield t(xe+Ne))[0][Ne],l=(yield t(xe+Ce))[0][Ce],o=(yield t(E+" TOTAL_CHANGES() c"))[0].c;n==(null!=f?f:f=n)&&l==(null!=h?h:h=l)&&o==(null!=m?m:m=o)||(e(),f=n,h=l)}catch(e){}})),l=b,n(),setInterval(n,1e3*l)),o((n=>O.has(n)?e():0))];var n,l}),(([e,n])=>{a(e),f=h=null,r(n)}),u,w,g(O),d,c,y)};var Re=(e,n)=>(n=Symbol[e])?n:Symbol.for("Symbol."+e),Ie=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));e.createPowerSyncPersister=(e,n,l,t,o,r=!1)=>Le(e,l,((e,...l)=>Ie(void 0,[e,...l],(function*(e,l=[]){return n.execute(e,l).then((e=>{var n,l;return null!=(l=null==(n=e.rows)?void 0:n._array)?l:[]}))}))),(e=>{const l=new AbortController,t=n.onChange({rawTableNames:!0,signal:l.signal});return Ie(void 0,null,(function*(){try{for(var n,l,o,r=((e,n,l)=>(n=e[Re("asyncIterator")])?n.call(e):(e=e[Re("iterator")](),n={},(l=(l,t)=>(t=e[l])&&(n[l]=n=>new Promise(((l,o,r)=>(n=t.call(e,n),r=n.done,Promise.resolve(n.value).then((e=>l({value:e,done:r})),o))))))("next"),l("return"),n))(t);n=!(l=yield r.next()).done;n=!1){const n=l.value;b(n.changedTables,e)}}catch(l){o=[l]}finally{try{n&&(l=r.return)&&(yield l.call(r))}finally{if(o)throw o[0]}}})),l}),(e=>e.abort()),t,o,n,"getPowerSync",r)},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPowersync={});
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,t="tinybase",l="",o=",",r=n(l),i=(e,n)=>e.repeat(n),u=Promise,a=clearInterval,d=e=>null==e,c=(e,n,t)=>d(e)?null==t?void 0:t():n(e),s=e=>n(e)==r,v=(e,n,t)=>e.slice(n,t),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,t)=>{var l=e=>{try{r(n.next(e))}catch(e){t(e)}},o=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);r((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",E=e=>`"${e.replace(/"/g,'""')}"`,m="SELECT",O=(e,n="")=>e.join(n),b=(e,n)=>e.map(n),P=e=>0==y(e),T=(e,n)=>e.filter(n),A=(e,...n)=>e.push(...n),w=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},L=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},R=(e,n)=>null==e?void 0:e.delete(n),N=Object,S=e=>N.getPrototypeOf(e),g=N.keys,x=N.freeze,C=(e=[])=>N.fromEntries(e),D=(...e)=>N.assign({},...e),I=(e,n)=>b(N.entries(e),(([e,t])=>n(t,e))),j=e=>N.values(e),_=e=>y(g(e)),M=e=>(e=>!d(e)&&c(S(e),(e=>e==N.prototype||d(S(e))),(()=>!0)))(e)&&0==_(e),F=e=>new Map(e),$=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},B=(e,n)=>null==e?void 0:e.get(n),W=(e,n)=>{var t;return b([...null!=(t=null==e?void 0:e.entries())?t:[]],(([e,t])=>n(t,e)))},H=(e,n,t)=>d(t)?(R(e,n),e):null==e?void 0:e.set(n,t),k=(e,n,t)=>(w(e,n)||H(e,n,t()),B(e,n)),q=(e,n,t,l=H)=>(I(n,((n,l)=>t(e,l,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,t)=>n(t)))})(e,(t=>((e,n)=>!d(((e,n)=>c(e,(e=>e[n])))(e,n)))(n,t)?0:l(e,t))),e),Y=e=>new Set(Array.isArray(e)||d(e)?e:[e]),G=(e,n)=>null==e?void 0:e.add(n);var J=Object.defineProperty,U=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,K=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Q=(e,n)=>{for(var t in n||(n={}))V.call(n,t)&&K(e,t,n[t]);if(U)for(var t of U(n))z.call(n,t)&&K(e,t,n[t]);return e},X=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const Z=m+"*FROM",ee="FROM pragma_table_",ne="WHERE",te=(e,n,t,r)=>{const i=F();return[()=>X(void 0,null,(function*(){return q(i,C(yield f(b(yield e("SELECT name "+ee+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+oe(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,C(b(yield e(m+" name,type "+ee+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,t)=>H(i,n,q(k(i,n,F),t,((e,n,t)=>{t!=B(e,n)&&H(e,n,t)}),((e,n)=>H(e,n))))),((e,n)=>H(i,n)))})),(n,t)=>X(void 0,null,(function*(){return((e,n)=>!d(B(B(i,e),n)))(n,t)?C(T(b(yield e(Z+E(n)),(e=>{return[e[t],(n=Q({},e),l=t,delete n[l],n)];var n,l})),(([e,n])=>!d(e)&&!M(n)))):{}})),(n,t,u,a,c,s=!1)=>X(void 0,null,(function*(){const v=Y();I(null!=u?u:{},(e=>b(g(null!=e?e:{}),(e=>G(v,e)))));const y=L(v);if(!s&&c&&P(y)&&w(i,n))return yield e("DROP TABLE"+E(n)),void H(i,n);if(P(y)||w(i,n)){const o=B(i,n),r=Y($(o));yield f([...b(y,(t=>X(void 0,null,(function*(){R(r,t)||(yield e(`ALTER TABLE${E(n)}ADD${E(t)}`),H(o,t,l))})))),...!s&&a?b(L(r),(l=>X(void 0,null,(function*(){l!=t&&(yield e(`ALTER TABLE${E(n)}DROP${E(l)}`),H(o,l))})))):[]])}else yield e(`CREATE TABLE${E(n)}(${E(t)} PRIMARY KEY ON CONFLICT REPLACE${O(b(y,(e=>o+E(e))))});`),H(i,n,F([[t,l],...b(y,(e=>[e,l]))]));if(s)d(u)?yield e("DELETE FROM"+E(n)+"WHERE 1"):yield f(I(u,((l,o)=>X(void 0,null,(function*(){d(l)?yield e("DELETE FROM"+E(n)+ne+E(t)+"=?",[o]):P(y)||(yield le(e,n,t,g(l),[o,...j(l)],r))})))));else if(P(y))w(i,n)&&(yield e("DELETE FROM"+E(n)+"WHERE 1"));else{const l=T($(B(i,n)),(e=>e!=t)),o=[],r=[];I(null!=u?u:{},((e,n)=>{A(o,n,...b(l,(n=>null==e?void 0:e[n]))),A(r,n)})),yield le(e,n,t,l,o),yield e("DELETE FROM"+E(n)+ne+E(t)+"NOT IN("+oe(r)+")",r)}})),n=>X(void 0,null,(function*(){let l;yield e("BEGIN");try{l=yield n()}catch(e){null==t||t(e)}return yield e("END"),l}))]},le=(e,n,t,r,u,a=!0)=>X(void 0,null,(function*(){return yield e("INSERT "+(a?l:"OR REPLACE ")+"INTO"+E(n)+"("+E(t)+O(b(r,(e=>o+E(e))))+")VALUES"+v(i(`,(?${i(",?",y(r))})`,y(u)/(y(r)+1)),1)+(a?"ON CONFLICT("+E(t)+")DO UPDATE SET"+O(b(r,(e=>E(e)+"=excluded."+E(e))),o):l),b(u,(e=>null!=e?e:null)))})),oe=e=>O(b(e,(()=>"?")),o),re=JSON.parse;var ie=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const ue=F(),ae=F(),de=(e,n,t,l,o,r,[i,u]=[],a=[])=>{let s,v,y,f=0,p=0;k(ue,a,(()=>0)),k(ae,a,(()=>[]));const h=e=>ie(void 0,null,(function*(){return 2!=f&&(f=1,yield E.schedule((()=>ie(void 0,null,(function*(){yield e(),f=0}))))),E})),E={load:(t,l)=>ie(void 0,null,(function*(){return yield h((()=>ie(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([t,l])}}))))})),startAutoLoad:(...t)=>ie(void 0,[...t],(function*(t={},o={}){return E.stopAutoLoad(),yield E.load(t,o),p=1,y=l(((t,l)=>ie(void 0,null,(function*(){if(l){const n=l();yield h((()=>ie(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>ie(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==t?void 0:t())?l:yield n())}catch(e){null==r||r(e)}}))))})))),E})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),E),save:n=>ie(void 0,null,(function*(){return 1!=f&&(f=2,yield E.schedule((()=>ie(void 0,null,(function*(){try{yield t(e.getContent,n)}catch(e){null==r||r(e)}f=0}))))),E})),startAutoSave:()=>ie(void 0,null,(function*(){return yield E.stopAutoSave().save(),s=e.addDidFinishTransactionListener(((e,n)=>{const[t,l]=n();M(t)&&M(l)||E.save((()=>[t,l]))})),E})),stopAutoSave:()=>(c(s,e.delListener),s=void 0,E),schedule:(...e)=>ie(void 0,null,(function*(){return A(B(ae,a),...e),yield ie(void 0,null,(function*(){if(!B(ue,a)){for(H(ue,a,1);!d((e=B(ae,a),v=e.shift()));)try{yield v()}catch(e){null==r||r(e)}H(ue,a,0)}var e})),E})),getStore:()=>e,destroy:()=>E.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return i&&(E[i]=()=>u),x(E)};var ce=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const se="store",ve=(e,n,t,l,o,[r],i,u,a)=>{const[d,c,s,v]=te(n,i,o);return de(e,(()=>ce(void 0,null,(function*(){return yield v((()=>ce(void 0,null,(function*(){var e,n;return yield d(),re(null!=(n=null==(e=(yield c(r,h))[p])?void 0:e[se])?n:"null")}))))}))),(e=>ce(void 0,null,(function*(){return yield v((()=>ce(void 0,null,(function*(){var n,t;yield d(),yield s(r,h,{[p]:{[se]:(t=null!=(n=e())?n:null,JSON.stringify(t,((e,n)=>n instanceof Map?N.fromEntries([...n]):n)))}},!0,!0)}))))}))),t,l,o,[a,u],u)};var ye=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const fe=(e,n,t,l,o,[r,i,[u,a,c]],s,v,y,E)=>{const[m,O,b,P]=te(n,s,o,E),A=(e,n)=>ye(void 0,null,(function*(){return yield f(W(i,((t,l)=>ye(void 0,[t,l],(function*([t,l,o,r],i){const u=e[i];n&&void 0===u||(yield b(t,l,u,o,r,n))})))))})),w=(e,n)=>ye(void 0,null,(function*(){return a?yield b(c,h,{[p]:e},!0,!0,n):null}));return de(e,(()=>ye(void 0,null,(function*(){return yield P((()=>ye(void 0,null,(function*(){yield m();const e=yield ye(void 0,null,(function*(){return C(T(yield f(W(r,((e,n)=>ye(void 0,[e,n],(function*([e,n],t){return[e,yield O(t,n)]}))))),(e=>!M(e[1]))))})),n=yield ye(void 0,null,(function*(){return u?(yield O(c,h))[p]:{}}));return M(e)&&d(n)?void 0:[e,n]}))))}))),((e,n)=>ye(void 0,null,(function*(){return yield P((()=>ye(void 0,null,(function*(){if(yield m(),d(n)){const[n,t]=e();yield A(n),yield w(t)}else{const[e,t]=n();yield A(e,!0),yield w(t,!0)}}))))}))),t,l,o,[y,v],v)},pe="json",he="autoLoadIntervalSeconds",Ee="rowIdColumnName",me="tableId",Oe="tableName",be={mode:pe,[he]:1},Pe={load:0,save:0,[Oe]:t+"_values"},Te=(e,n,t,l)=>{const o=F();return I(e,((e,r)=>{const i=v(j(D(n,s(e)?{[t]:e}:e)),0,_(n));d(i[0])||l(r,i[0])||H(o,r,i)})),o};var Ae=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const we="pragma ",Le="data_version",Re="schema_version",Ne=(e,n,l,o,r,i,u,d,c="getDb",y)=>{let f,p,E;const[O,b,P,T]=(e=>{const n=(e=>D(be,s(e)?{storeTableName:e}:null!=e?e:{}))(e),l=n[he];if(n.mode==pe){const{storeTableName:e=t}=n;return[1,l,[e],Y(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=v(j(D(Pe,i)),0,_(Pe)),a=u[2],d=Y(a);return[0,l,[Te(o,{[me]:null,[Ee]:h},me,(e=>G(d,e)&&e==a)),Te(r,{[Oe]:null,[Ee]:h,deleteEmptyColumns:0,deleteEmptyTable:0},Oe,((e,n)=>G(d,n)&&n==a)),u],d]})(n);return(O?ve:fe)(e,i?(e,n)=>Ae(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>{return[(n=()=>Ae(void 0,null,(function*(){try{const n=(yield l(we+Le))[0][Le],t=(yield l(we+Re))[0][Re],o=(yield l(m+" TOTAL_CHANGES() c"))[0].c;n==(null!=f?f:f=n)&&t==(null!=p?p:p=t)&&o==(null!=E?E:E=o)||(e(),f=n,p=t)}catch(e){}})),t=b,n(),setInterval(n,1e3*t)),o((n=>T.has(n)?e():0))];var n,t}),(([e,n])=>{a(e),f=p=null,r(n)}),u,P,L(T),d,c,y)};var Se=Object.defineProperty,ge=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,De=(e,n,t)=>n in e?Se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;e.createSqliteWasmPersister=(e,n,t,l,o,r)=>Ne(e,l,((e,...n)=>{return l=[e,...n],o=function*(e,n=[]){return t.exec(e,{bind:n,rowMode:"object",returnValue:"resultRows"}).map((e=>((e,n)=>{for(var t in n||(n={}))xe.call(n,t)&&De(e,t,n[t]);if(ge)for(var t of ge(n))Ce.call(n,t)&&De(e,t,n[t]);return e})({},e)))},new Promise(((e,n)=>{var t=e=>{try{i(o.next(e))}catch(e){n(e)}},r=e=>{try{i(o.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,r);i((o=o.apply(void 0,l)).next())}));var l,o}),(e=>n.capi.sqlite3_update_hook(t,((n,t,l,o)=>e(o)),0)),(()=>n.capi.sqlite3_update_hook(t,(()=>0),0)),o,r,t)},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterSqliteWasm={});
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,t="tinybase",l="",o=",",r=n(l),i=(e,n)=>e.repeat(n),u=Promise,a=clearInterval,d=e=>null==e,c=(e,n,t)=>d(e)?null==t?void 0:t():n(e),s=e=>n(e)==r,v=(e,n,t)=>e.slice(n,t),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,t)=>{var l=e=>{try{r(n.next(e))}catch(e){t(e)}},o=e=>{try{r(n.throw(e))}catch(e){t(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);r((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",m=e=>`"${e.replace(/"/g,'""')}"`,E="SELECT",b=(e,n="")=>e.join(n),O=(e,n)=>e.map(n),P=e=>0==y(e),w=(e,n)=>e.filter(n),A=(e,...n)=>e.push(...n),T=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},N=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},S=(e,n)=>null==e?void 0:e.delete(n),g=Object,x=e=>g.getPrototypeOf(e),R=g.keys,L=g.freeze,C=(e=[])=>g.fromEntries(e),I=(...e)=>g.assign({},...e),j=(e,n)=>O(g.entries(e),(([e,t])=>n(t,e))),D=e=>g.values(e),_=e=>y(R(e)),M=e=>(e=>!d(e)&&c(x(e),(e=>e==g.prototype||d(x(e))),(()=>!0)))(e)&&0==_(e),F=e=>new Map(e),k=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},q=(e,n)=>null==e?void 0:e.get(n),B=(e,n)=>{var t;return O([...null!=(t=null==e?void 0:e.entries())?t:[]],(([e,t])=>n(t,e)))},W=(e,n,t)=>d(t)?(S(e,n),e):null==e?void 0:e.set(n,t),H=(e,n,t)=>(T(e,n)||W(e,n,t()),q(e,n)),Y=(e,n,t,l=W)=>(j(n,((n,l)=>t(e,l,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,t)=>n(t)))})(e,(t=>((e,n)=>!d(((e,n)=>c(e,(e=>e[n])))(e,n)))(n,t)?0:l(e,t))),e),$=e=>new Set(Array.isArray(e)||d(e)?e:[e]),G=(e,n)=>null==e?void 0:e.add(n);var J=Object.defineProperty,U=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,K=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Q=(e,n)=>{for(var t in n||(n={}))V.call(n,t)&&K(e,t,n[t]);if(U)for(var t of U(n))z.call(n,t)&&K(e,t,n[t]);return e},X=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const Z="TABLE",ee="ALTER "+Z,ne="DELETE FROM",te=E+"*FROM",le="FROM pragma_table_",oe="WHERE",re=(e,n,t,r)=>{const i=F();return[()=>X(void 0,null,(function*(){return Y(i,C(yield f(O(yield e("SELECT name "+le+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ue(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,C(O(yield e(E+" name,type "+le+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,t)=>W(i,n,Y(H(i,n,F),t,((e,n,t)=>{t!=q(e,n)&&W(e,n,t)}),((e,n)=>W(e,n))))),((e,n)=>W(i,n)))})),(n,t)=>X(void 0,null,(function*(){return((e,n)=>!d(q(q(i,e),n)))(n,t)?C(w(O(yield e(te+m(n)),(e=>{return[e[t],(n=Q({},e),l=t,delete n[l],n)];var n,l})),(([e,n])=>!d(e)&&!M(n)))):{}})),(n,t,u,a,c,s=!1)=>X(void 0,null,(function*(){const v=$();j(null!=u?u:{},(e=>O(R(null!=e?e:{}),(e=>G(v,e)))));const y=N(v);if(!s&&c&&P(y)&&T(i,n))return yield e("DROP "+Z+m(n)),void W(i,n);if(P(y)||T(i,n)){const o=q(i,n),r=$(k(o));yield f([...O(y,(t=>X(void 0,null,(function*(){S(r,t)||(yield e(ee+m(n)+"ADD"+m(t)),W(o,t,l))})))),...!s&&a?O(N(r),(l=>X(void 0,null,(function*(){l!=t&&(yield e(ee+m(n)+"DROP"+m(l)),W(o,l))})))):[]])}else yield e("CREATE "+Z+m(n)+"("+m(t)+` PRIMARY KEY ON CONFLICT REPLACE${b(O(y,(e=>o+m(e))))});`),W(i,n,F([[t,l],...O(y,(e=>[e,l]))]));if(s)d(u)?yield e(ne+m(n)+oe+" 1"):yield f(j(u,((l,o)=>X(void 0,null,(function*(){d(l)?yield e(ne+m(n)+oe+m(t)+"=?",[o]):P(y)||(yield ie(e,n,t,R(l),[o,...D(l)],r))})))));else if(P(y))T(i,n)&&(yield e(ne+m(n)+oe+" 1"));else{const l=w(k(q(i,n)),(e=>e!=t)),o=[],a=[];j(null!=u?u:{},((e,n)=>{A(o,n,...O(l,(n=>null==e?void 0:e[n]))),A(a,n)})),yield ie(e,n,t,l,o,r),yield e(ne+m(n)+oe+m(t)+"NOT IN("+ue(a)+")",a)}})),n=>X(void 0,null,(function*(){let l;yield e("BEGIN");try{l=yield n()}catch(e){null==t||t(e)}return yield e("END"),l}))]},ie=(e,n,t,r,u,a=!0)=>X(void 0,null,(function*(){return yield e("INSERT "+(a?l:"OR REPLACE ")+"INTO"+m(n)+"("+m(t)+b(O(r,(e=>o+m(e))))+")VALUES"+v(i(`,(?${i(",?",y(r))})`,y(u)/(y(r)+1)),1)+(a?"ON CONFLICT("+m(t)+")DO UPDATE SET"+b(O(r,(e=>m(e)+"=excluded."+m(e))),o):l),O(u,(e=>null!=e?e:null)))})),ue=e=>b(O(e,(()=>"?")),o),ae=JSON.parse;var de=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const ce=F(),se=F(),ve=(e,n,t,l,o,r,[i,u]=[],a=[])=>{let s,v,y,f=0,p=0;H(ce,a,(()=>0)),H(se,a,(()=>[]));const h=e=>de(void 0,null,(function*(){return 2!=f&&(f=1,yield m.schedule((()=>de(void 0,null,(function*(){yield e(),f=0}))))),m})),m={load:(t,l)=>de(void 0,null,(function*(){return yield h((()=>de(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([t,l])}}))))})),startAutoLoad:(...t)=>de(void 0,[...t],(function*(t={},o={}){return m.stopAutoLoad(),yield m.load(t,o),p=1,y=l(((t,l)=>de(void 0,null,(function*(){if(l){const n=l();yield h((()=>de(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>de(void 0,null,(function*(){var l;try{e.setContent(null!=(l=null==t?void 0:t())?l:yield n())}catch(e){null==r||r(e)}}))))})))),m})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),m),save:n=>de(void 0,null,(function*(){return 1!=f&&(f=2,yield m.schedule((()=>de(void 0,null,(function*(){try{yield t(e.getContent,n)}catch(e){null==r||r(e)}f=0}))))),m})),startAutoSave:()=>de(void 0,null,(function*(){return yield m.stopAutoSave().save(),s=e.addDidFinishTransactionListener(((e,n)=>{const[t,l]=n();M(t)&&M(l)||m.save((()=>[t,l]))})),m})),stopAutoSave:()=>(c(s,e.delListener),s=void 0,m),schedule:(...e)=>de(void 0,null,(function*(){return A(q(se,a),...e),yield de(void 0,null,(function*(){if(!q(ce,a)){for(W(ce,a,1);!d((e=q(se,a),v=e.shift()));)try{yield v()}catch(e){null==r||r(e)}W(ce,a,0)}var e})),m})),getStore:()=>e,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return i&&(m[i]=()=>u),L(m)};var ye=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const fe="store",pe=(e,n,t,l,o,[r],i,u,a,d)=>{const[c,s,v,y]=re(n,i,o,d);return ve(e,(()=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var e,n;return yield c(),ae(null!=(n=null==(e=(yield s(r,h))[p])?void 0:e[fe])?n:"null")}))))}))),(e=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var n,t;yield c(),yield v(r,h,{[p]:{[fe]:(t=null!=(n=e())?n:null,JSON.stringify(t,((e,n)=>n instanceof Map?g.fromEntries([...n]):n)))}},!0,!0)}))))}))),t,l,o,[a,u],u)};var he=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const me=(e,n,t,l,o,[r,i,[u,a,c]],s,v,y,m)=>{const[E,b,O,P]=re(n,s,o,m),A=(e,n)=>he(void 0,null,(function*(){return yield f(B(i,((t,l)=>he(void 0,[t,l],(function*([t,l,o,r],i){const u=e[i];n&&void 0===u||(yield O(t,l,u,o,r,n))})))))})),T=(e,n)=>he(void 0,null,(function*(){return a?yield O(c,h,{[p]:e},!0,!0,n):null}));return ve(e,(()=>he(void 0,null,(function*(){return yield P((()=>he(void 0,null,(function*(){yield E();const e=yield he(void 0,null,(function*(){return C(w(yield f(B(r,((e,n)=>he(void 0,[e,n],(function*([e,n],t){return[e,yield b(t,n)]}))))),(e=>!M(e[1]))))})),n=yield he(void 0,null,(function*(){return u?(yield b(c,h))[p]:{}}));return M(e)&&d(n)?void 0:[e,n]}))))}))),((e,n)=>he(void 0,null,(function*(){return yield P((()=>he(void 0,null,(function*(){if(yield E(),d(n)){const[n,t]=e();yield A(n),yield T(t)}else{const[e,t]=n();yield A(e,!0),yield T(t,!0)}}))))}))),t,l,o,[y,v],v)},Ee="json",be="autoLoadIntervalSeconds",Oe="rowIdColumnName",Pe="tableId",we="tableName",Ae={mode:Ee,[be]:1},Te={load:0,save:0,[we]:t+"_values"},Ne=(e,n,t,l)=>{const o=F();return j(e,((e,r)=>{const i=v(D(I(n,s(e)?{[t]:e}:e)),0,_(n));d(i[0])||l(r,i[0])||W(o,r,i)})),o};var Se=(e,n,t)=>new Promise(((l,o)=>{var r=e=>{try{u(t.next(e))}catch(e){o(e)}},i=e=>{try{u(t.throw(e))}catch(e){o(e)}},u=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,i);u((t=t.apply(e,n)).next())}));const ge="pragma ",xe="data_version",Re="schema_version",Le=(e,n,l,o,r,i,u,d,c="getDb",y)=>{let f,p,m;const[b,O,P,w]=(e=>{const n=(e=>I(Ae,s(e)?{storeTableName:e}:null!=e?e:{}))(e),l=n[be];if(n.mode==Ee){const{storeTableName:e=t}=n;return[1,l,[e],$(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=v(D(I(Te,i)),0,_(Te)),a=u[2],d=$(a);return[0,l,[Ne(o,{[Pe]:null,[Oe]:h},Pe,(e=>G(d,e)&&e==a)),Ne(r,{[we]:null,[Oe]:h,deleteEmptyColumns:0,deleteEmptyTable:0},we,((e,n)=>G(d,n)&&n==a)),u],d]})(n);return(b?pe:me)(e,i?(e,n)=>Se(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>{return[(n=()=>Se(void 0,null,(function*(){try{const n=(yield l(ge+xe))[0][xe],t=(yield l(ge+Re))[0][Re],o=(yield l(E+" TOTAL_CHANGES() c"))[0].c;n==(null!=f?f:f=n)&&t==(null!=p?p:p=t)&&o==(null!=m?m:m=o)||(e(),f=n,p=t)}catch(e){}})),t=O,n(),setInterval(n,1e3*t)),o((n=>w.has(n)?e():0))];var n,t}),(([e,n])=>{a(e),f=p=null,r(n)}),u,P,N(w),d,c,y)};var Ce=Object.defineProperty,Ie=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,_e=(e,n,t)=>n in e?Ce(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;e.createSqliteWasmPersister=(e,n,t,l,o,r)=>Le(e,l,((e,...n)=>{return l=[e,...n],o=function*(e,n=[]){return t.exec(e,{bind:n,rowMode:"object",returnValue:"resultRows"}).map((e=>((e,n)=>{for(var t in n||(n={}))je.call(n,t)&&_e(e,t,n[t]);if(Ie)for(var t of Ie(n))De.call(n,t)&&_e(e,t,n[t]);return e})({},e)))},new Promise(((e,n)=>{var t=e=>{try{i(o.next(e))}catch(e){n(e)}},r=e=>{try{i(o.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,r);i((o=o.apply(void 0,l)).next())}));var l,o}),(e=>n.capi.sqlite3_update_hook(t,((n,t,l,o)=>e(o)),0)),(()=>n.capi.sqlite3_update_hook(t,(()=>0),0)),o,r,t)},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterSqliteWasm={});
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,l="tinybase",t="",o=",",r=n(t),i=(e,n)=>e.repeat(n),u=Promise,d=clearInterval,a=e=>null==e,c=(e,n,l)=>a(e)?null==l?void 0:l():n(e),s=e=>n(e)==r,v=(e,n,l)=>e.slice(n,l),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,l)=>{var t=e=>{try{r(n.next(e))}catch(e){l(e)}},o=e=>{try{r(n.throw(e))}catch(e){l(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,o);r((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",E=e=>`"${e.replace(/"/g,'""')}"`,m="SELECT",T=(e,n="")=>e.join(n),O=(e,n)=>e.map(n),A=e=>0==y(e),P=(e,n)=>e.filter(n),L=(e,...n)=>e.push(...n),R=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},b=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},w=(e,n)=>null==e?void 0:e.delete(n),N=Object,S=e=>N.getPrototypeOf(e),g=N.keys,x=N.freeze,C=(e=[])=>N.fromEntries(e),D=(...e)=>N.assign({},...e),I=(e,n)=>O(N.entries(e),(([e,l])=>n(l,e))),F=e=>N.values(e),M=e=>y(g(e)),$=e=>(e=>!a(e)&&c(S(e),(e=>e==N.prototype||a(S(e))),(()=>!0)))(e)&&0==M(e),j=e=>new Map(e),_=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},B=(e,n)=>null==e?void 0:e.get(n),H=(e,n)=>{var l;return O([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},W=(e,n,l)=>a(l)?(w(e,n),e):null==e?void 0:e.set(n,l),Y=(e,n,l)=>(R(e,n)||W(e,n,l()),B(e,n)),k=(e,n,l,t=W)=>(I(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>((e,n)=>!a(((e,n)=>c(e,(e=>e[n])))(e,n)))(n,l)?0:t(e,l))),e),q=e=>new Set(Array.isArray(e)||a(e)?e:[e]),G=(e,n)=>null==e?void 0:e.add(n);var J=Object.defineProperty,U=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(e,n,l)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,Q=(e,n)=>{for(var l in n||(n={}))z.call(n,l)&&V(e,l,n[l]);if(U)for(var l of U(n))K.call(n,l)&&V(e,l,n[l]);return e},X=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const Z=m+"*FROM",ee="FROM pragma_table_",ne="WHERE",le=(e,n,l,r)=>{const i=j();return[()=>X(void 0,null,(function*(){return k(i,C(yield f(O(yield e("SELECT name "+ee+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+oe(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,C(O(yield e(m+" name,type "+ee+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>W(i,n,k(Y(i,n,j),l,((e,n,l)=>{l!=B(e,n)&&W(e,n,l)}),((e,n)=>W(e,n))))),((e,n)=>W(i,n)))})),(n,l)=>X(void 0,null,(function*(){return((e,n)=>!a(B(B(i,e),n)))(n,l)?C(P(O(yield e(Z+E(n)),(e=>{return[e[l],(n=Q({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!a(e)&&!$(n)))):{}})),(n,l,u,d,c,s=!1)=>X(void 0,null,(function*(){const v=q();I(null!=u?u:{},(e=>O(g(null!=e?e:{}),(e=>G(v,e)))));const y=b(v);if(!s&&c&&A(y)&&R(i,n))return yield e("DROP TABLE"+E(n)),void W(i,n);if(A(y)||R(i,n)){const o=B(i,n),r=q(_(o));yield f([...O(y,(l=>X(void 0,null,(function*(){w(r,l)||(yield e(`ALTER TABLE${E(n)}ADD${E(l)}`),W(o,l,t))})))),...!s&&d?O(b(r),(t=>X(void 0,null,(function*(){t!=l&&(yield e(`ALTER TABLE${E(n)}DROP${E(t)}`),W(o,t))})))):[]])}else yield e(`CREATE TABLE${E(n)}(${E(l)} PRIMARY KEY ON CONFLICT REPLACE${T(O(y,(e=>o+E(e))))});`),W(i,n,j([[l,t],...O(y,(e=>[e,t]))]));if(s)a(u)?yield e("DELETE FROM"+E(n)+"WHERE 1"):yield f(I(u,((t,o)=>X(void 0,null,(function*(){a(t)?yield e("DELETE FROM"+E(n)+ne+E(l)+"=?",[o]):A(y)||(yield te(e,n,l,g(t),[o,...F(t)],r))})))));else if(A(y))R(i,n)&&(yield e("DELETE FROM"+E(n)+"WHERE 1"));else{const t=P(_(B(i,n)),(e=>e!=l)),o=[],r=[];I(null!=u?u:{},((e,n)=>{L(o,n,...O(t,(n=>null==e?void 0:e[n]))),L(r,n)})),yield te(e,n,l,t,o),yield e("DELETE FROM"+E(n)+ne+E(l)+"NOT IN("+oe(r)+")",r)}})),n=>X(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},te=(e,n,l,r,u,d=!0)=>X(void 0,null,(function*(){return yield e("INSERT "+(d?t:"OR REPLACE ")+"INTO"+E(n)+"("+E(l)+T(O(r,(e=>o+E(e))))+")VALUES"+v(i(`,(?${i(",?",y(r))})`,y(u)/(y(r)+1)),1)+(d?"ON CONFLICT("+E(l)+")DO UPDATE SET"+T(O(r,(e=>E(e)+"=excluded."+E(e))),o):t),O(u,(e=>null!=e?e:null)))})),oe=e=>T(O(e,(()=>"?")),o),re=JSON.parse;var ie=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const ue=j(),de=j(),ae=(e,n,l,t,o,r,[i,u]=[],d=[])=>{let s,v,y,f=0,p=0;Y(ue,d,(()=>0)),Y(de,d,(()=>[]));const h=e=>ie(void 0,null,(function*(){return 2!=f&&(f=1,yield E.schedule((()=>ie(void 0,null,(function*(){yield e(),f=0}))))),E})),E={load:(l,t)=>ie(void 0,null,(function*(){return yield h((()=>ie(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([l,t])}}))))})),startAutoLoad:(...l)=>ie(void 0,[...l],(function*(l={},o={}){return E.stopAutoLoad(),yield E.load(l,o),p=1,y=t(((l,t)=>ie(void 0,null,(function*(){if(t){const n=t();yield h((()=>ie(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>ie(void 0,null,(function*(){var t;try{e.setContent(null!=(t=null==l?void 0:l())?t:yield n())}catch(e){null==r||r(e)}}))))})))),E})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),E),save:n=>ie(void 0,null,(function*(){return 1!=f&&(f=2,yield E.schedule((()=>ie(void 0,null,(function*(){try{yield l(e.getContent,n)}catch(e){null==r||r(e)}f=0}))))),E})),startAutoSave:()=>ie(void 0,null,(function*(){return yield E.stopAutoSave().save(),s=e.addDidFinishTransactionListener(((e,n)=>{const[l,t]=n();$(l)&&$(t)||E.save((()=>[l,t]))})),E})),stopAutoSave:()=>(c(s,e.delListener),s=void 0,E),schedule:(...e)=>ie(void 0,null,(function*(){return L(B(de,d),...e),yield ie(void 0,null,(function*(){if(!B(ue,d)){for(W(ue,d,1);!a((e=B(de,d),v=e.shift()));)try{yield v()}catch(e){null==r||r(e)}W(ue,d,0)}var e})),E})),getStore:()=>e,destroy:()=>E.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return i&&(E[i]=()=>u),x(E)};var ce=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const se="store",ve=(e,n,l,t,o,[r],i,u,d)=>{const[a,c,s,v]=le(n,i,o);return ae(e,(()=>ce(void 0,null,(function*(){return yield v((()=>ce(void 0,null,(function*(){var e,n;return yield a(),re(null!=(n=null==(e=(yield c(r,h))[p])?void 0:e[se])?n:"null")}))))}))),(e=>ce(void 0,null,(function*(){return yield v((()=>ce(void 0,null,(function*(){var n,l;yield a(),yield s(r,h,{[p]:{[se]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>n instanceof Map?N.fromEntries([...n]):n)))}},!0,!0)}))))}))),l,t,o,[d,u],u)};var ye=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const fe=(e,n,l,t,o,[r,i,[u,d,c]],s,v,y,E)=>{const[m,T,O,A]=le(n,s,o,E),L=(e,n)=>ye(void 0,null,(function*(){return yield f(H(i,((l,t)=>ye(void 0,[l,t],(function*([l,t,o,r],i){const u=e[i];n&&void 0===u||(yield O(l,t,u,o,r,n))})))))})),R=(e,n)=>ye(void 0,null,(function*(){return d?yield O(c,h,{[p]:e},!0,!0,n):null}));return ae(e,(()=>ye(void 0,null,(function*(){return yield A((()=>ye(void 0,null,(function*(){yield m();const e=yield ye(void 0,null,(function*(){return C(P(yield f(H(r,((e,n)=>ye(void 0,[e,n],(function*([e,n],l){return[e,yield T(l,n)]}))))),(e=>!$(e[1]))))})),n=yield ye(void 0,null,(function*(){return u?(yield T(c,h))[p]:{}}));return $(e)&&a(n)?void 0:[e,n]}))))}))),((e,n)=>ye(void 0,null,(function*(){return yield A((()=>ye(void 0,null,(function*(){if(yield m(),a(n)){const[n,l]=e();yield L(n),yield R(l)}else{const[e,l]=n();yield L(e,!0),yield R(l,!0)}}))))}))),l,t,o,[y,v],v)},pe="json",he="autoLoadIntervalSeconds",Ee="rowIdColumnName",me="tableId",Te="tableName",Oe={mode:pe,[he]:1},Ae={load:0,save:0,[Te]:l+"_values"},Pe=(e,n,l,t)=>{const o=j();return I(e,((e,r)=>{const i=v(F(D(n,s(e)?{[l]:e}:e)),0,M(n));a(i[0])||t(r,i[0])||W(o,r,i)})),o};var Le=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const Re="pragma ",be="data_version",we="schema_version",Ne=(e,n,t,o,r,i,u,a,c="getDb",y)=>{let f,p,E;const[T,O,A,P]=(e=>{const n=(e=>D(Oe,s(e)?{storeTableName:e}:null!=e?e:{}))(e),t=n[he];if(n.mode==pe){const{storeTableName:e=l}=n;return[1,t,[e],q(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=v(F(D(Ae,i)),0,M(Ae)),d=u[2],a=q(d);return[0,t,[Pe(o,{[me]:null,[Ee]:h},me,(e=>G(a,e)&&e==d)),Pe(r,{[Te]:null,[Ee]:h,deleteEmptyColumns:0,deleteEmptyTable:0},Te,((e,n)=>G(a,n)&&n==d)),u],a]})(n);return(T?ve:fe)(e,i?(e,n)=>Le(void 0,null,(function*(){return i(e,n),yield t(e,n)})):t,(e=>{return[(n=()=>Le(void 0,null,(function*(){try{const n=(yield t(Re+be))[0][be],l=(yield t(Re+we))[0][we],o=(yield t(m+" TOTAL_CHANGES() c"))[0].c;n==(null!=f?f:f=n)&&l==(null!=p?p:p=l)&&o==(null!=E?E:E=o)||(e(),f=n,p=l)}catch(e){}})),l=O,n(),setInterval(n,1e3*l)),o((n=>P.has(n)?e():0))];var n,l}),(([e,n])=>{d(e),f=p=null,r(n)}),u,A,b(P),a,c,y)},Se="change";e.createSqlite3Persister=(e,n,l,t,o)=>Ne(e,l,((e,...l)=>{return t=[e,...l],o=function*(e,l=[]){return yield(t=(t,o)=>n.all(e,l,((e,n)=>e?o(e):t(n))),new u(t));var t},new Promise(((e,n)=>{var l=e=>{try{i(o.next(e))}catch(e){n(e)}},r=e=>{try{i(o.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,r);i((o=o.apply(void 0,t)).next())}));var t,o}),(e=>{const l=(n,l,t)=>e(t);return n.on(Se,l),l}),(e=>n.off(Se,e)),t,o,n)},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterSqlite3={});
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,l="tinybase",t="",o=",",r=n(t),i=(e,n)=>e.repeat(n),u=Promise,d=clearInterval,a=e=>null==e,c=(e,n,l)=>a(e)?null==l?void 0:l():n(e),s=e=>n(e)==r,v=(e,n,l)=>e.slice(n,l),y=e=>e.length,f=e=>{return n=function*(){return u.all(e)},new Promise(((e,l)=>{var t=e=>{try{r(n.next(e))}catch(e){l(e)}},o=e=>{try{r(n.throw(e))}catch(e){l(e)}},r=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,o);r((n=n.apply(void 0,null)).next())}));var n},p="_",h="_id",m=e=>`"${e.replace(/"/g,'""')}"`,E="SELECT",P=(e,n="")=>e.join(n),O=(e,n)=>e.map(n),b=e=>0==y(e),A=(e,n)=>e.filter(n),T=(e,...n)=>e.push(...n),w=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},N=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},S=(e,n)=>null==e?void 0:e.delete(n),g=Object,x=e=>g.getPrototypeOf(e),L=g.keys,R=g.freeze,C=(e=[])=>g.fromEntries(e),I=(...e)=>g.assign({},...e),D=(e,n)=>O(g.entries(e),(([e,l])=>n(l,e))),j=e=>g.values(e),_=e=>y(L(e)),F=e=>(e=>!a(e)&&c(x(e),(e=>e==g.prototype||a(x(e))),(()=>!0)))(e)&&0==_(e),M=e=>new Map(e),B=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},H=(e,n)=>null==e?void 0:e.get(n),Y=(e,n)=>{var l;return O([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},$=(e,n,l)=>a(l)?(S(e,n),e):null==e?void 0:e.set(n,l),k=(e,n,l)=>(w(e,n)||$(e,n,l()),H(e,n)),q=(e,n,l,t=$)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>((e,n)=>!a(((e,n)=>c(e,(e=>e[n])))(e,n)))(n,l)?0:t(e,l))),e),G=e=>new Set(Array.isArray(e)||a(e)?e:[e]),J=(e,n)=>null==e?void 0:e.add(n);var U=Object.defineProperty,W=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(e,n,l)=>n in e?U(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,Q=(e,n)=>{for(var l in n||(n={}))z.call(n,l)&&V(e,l,n[l]);if(W)for(var l of W(n))K.call(n,l)&&V(e,l,n[l]);return e},X=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const Z="TABLE",ee="ALTER "+Z,ne="DELETE FROM",le=E+"*FROM",te="FROM pragma_table_",oe="WHERE",re=(e,n,l,r)=>{const i=M();return[()=>X(void 0,null,(function*(){return q(i,C(yield f(O(yield e("SELECT name "+te+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ue(n)+")ORDER BY name",n),(n=>X(void 0,[n],(function*({name:n}){return[n,C(O(yield e(E+" name,type "+te+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>$(i,n,q(k(i,n,M),l,((e,n,l)=>{l!=H(e,n)&&$(e,n,l)}),((e,n)=>$(e,n))))),((e,n)=>$(i,n)))})),(n,l)=>X(void 0,null,(function*(){return((e,n)=>!a(H(H(i,e),n)))(n,l)?C(A(O(yield e(le+m(n)),(e=>{return[e[l],(n=Q({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!a(e)&&!F(n)))):{}})),(n,l,u,d,c,s=!1)=>X(void 0,null,(function*(){const v=G();D(null!=u?u:{},(e=>O(L(null!=e?e:{}),(e=>J(v,e)))));const y=N(v);if(!s&&c&&b(y)&&w(i,n))return yield e("DROP "+Z+m(n)),void $(i,n);if(b(y)||w(i,n)){const o=H(i,n),r=G(B(o));yield f([...O(y,(l=>X(void 0,null,(function*(){S(r,l)||(yield e(ee+m(n)+"ADD"+m(l)),$(o,l,t))})))),...!s&&d?O(N(r),(t=>X(void 0,null,(function*(){t!=l&&(yield e(ee+m(n)+"DROP"+m(t)),$(o,t))})))):[]])}else yield e("CREATE "+Z+m(n)+"("+m(l)+` PRIMARY KEY ON CONFLICT REPLACE${P(O(y,(e=>o+m(e))))});`),$(i,n,M([[l,t],...O(y,(e=>[e,t]))]));if(s)a(u)?yield e(ne+m(n)+oe+" 1"):yield f(D(u,((t,o)=>X(void 0,null,(function*(){a(t)?yield e(ne+m(n)+oe+m(l)+"=?",[o]):b(y)||(yield ie(e,n,l,L(t),[o,...j(t)],r))})))));else if(b(y))w(i,n)&&(yield e(ne+m(n)+oe+" 1"));else{const t=A(B(H(i,n)),(e=>e!=l)),o=[],d=[];D(null!=u?u:{},((e,n)=>{T(o,n,...O(t,(n=>null==e?void 0:e[n]))),T(d,n)})),yield ie(e,n,l,t,o,r),yield e(ne+m(n)+oe+m(l)+"NOT IN("+ue(d)+")",d)}})),n=>X(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},ie=(e,n,l,r,u,d=!0)=>X(void 0,null,(function*(){return yield e("INSERT "+(d?t:"OR REPLACE ")+"INTO"+m(n)+"("+m(l)+P(O(r,(e=>o+m(e))))+")VALUES"+v(i(`,(?${i(",?",y(r))})`,y(u)/(y(r)+1)),1)+(d?"ON CONFLICT("+m(l)+")DO UPDATE SET"+P(O(r,(e=>m(e)+"=excluded."+m(e))),o):t),O(u,(e=>null!=e?e:null)))})),ue=e=>P(O(e,(()=>"?")),o),de=JSON.parse;var ae=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const ce=M(),se=M(),ve=(e,n,l,t,o,r,[i,u]=[],d=[])=>{let s,v,y,f=0,p=0;k(ce,d,(()=>0)),k(se,d,(()=>[]));const h=e=>ae(void 0,null,(function*(){return 2!=f&&(f=1,yield m.schedule((()=>ae(void 0,null,(function*(){yield e(),f=0}))))),m})),m={load:(l,t)=>ae(void 0,null,(function*(){return yield h((()=>ae(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([l,t])}}))))})),startAutoLoad:(...l)=>ae(void 0,[...l],(function*(l={},o={}){return m.stopAutoLoad(),yield m.load(l,o),p=1,y=t(((l,t)=>ae(void 0,null,(function*(){if(t){const n=t();yield h((()=>ae(void 0,null,(function*(){return e.setTransactionChanges(n)}))))}else yield h((()=>ae(void 0,null,(function*(){var t;try{e.setContent(null!=(t=null==l?void 0:l())?t:yield n())}catch(e){null==r||r(e)}}))))})))),m})),stopAutoLoad:()=>(p&&(o(y),y=void 0,p=0),m),save:n=>ae(void 0,null,(function*(){return 1!=f&&(f=2,yield m.schedule((()=>ae(void 0,null,(function*(){try{yield l(e.getContent,n)}catch(e){null==r||r(e)}f=0}))))),m})),startAutoSave:()=>ae(void 0,null,(function*(){return yield m.stopAutoSave().save(),s=e.addDidFinishTransactionListener(((e,n)=>{const[l,t]=n();F(l)&&F(t)||m.save((()=>[l,t]))})),m})),stopAutoSave:()=>(c(s,e.delListener),s=void 0,m),schedule:(...e)=>ae(void 0,null,(function*(){return T(H(se,d),...e),yield ae(void 0,null,(function*(){if(!H(ce,d)){for($(ce,d,1);!a((e=H(se,d),v=e.shift()));)try{yield v()}catch(e){null==r||r(e)}$(ce,d,0)}var e})),m})),getStore:()=>e,destroy:()=>m.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return i&&(m[i]=()=>u),R(m)};var ye=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const fe="store",pe=(e,n,l,t,o,[r],i,u,d,a)=>{const[c,s,v,y]=re(n,i,o,a);return ve(e,(()=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var e,n;return yield c(),de(null!=(n=null==(e=(yield s(r,h))[p])?void 0:e[fe])?n:"null")}))))}))),(e=>ye(void 0,null,(function*(){return yield y((()=>ye(void 0,null,(function*(){var n,l;yield c(),yield v(r,h,{[p]:{[fe]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>n instanceof Map?g.fromEntries([...n]):n)))}},!0,!0)}))))}))),l,t,o,[d,u],u)};var he=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const me=(e,n,l,t,o,[r,i,[u,d,c]],s,v,y,m)=>{const[E,P,O,b]=re(n,s,o,m),T=(e,n)=>he(void 0,null,(function*(){return yield f(Y(i,((l,t)=>he(void 0,[l,t],(function*([l,t,o,r],i){const u=e[i];n&&void 0===u||(yield O(l,t,u,o,r,n))})))))})),w=(e,n)=>he(void 0,null,(function*(){return d?yield O(c,h,{[p]:e},!0,!0,n):null}));return ve(e,(()=>he(void 0,null,(function*(){return yield b((()=>he(void 0,null,(function*(){yield E();const e=yield he(void 0,null,(function*(){return C(A(yield f(Y(r,((e,n)=>he(void 0,[e,n],(function*([e,n],l){return[e,yield P(l,n)]}))))),(e=>!F(e[1]))))})),n=yield he(void 0,null,(function*(){return u?(yield P(c,h))[p]:{}}));return F(e)&&a(n)?void 0:[e,n]}))))}))),((e,n)=>he(void 0,null,(function*(){return yield b((()=>he(void 0,null,(function*(){if(yield E(),a(n)){const[n,l]=e();yield T(n),yield w(l)}else{const[e,l]=n();yield T(e,!0),yield w(l,!0)}}))))}))),l,t,o,[y,v],v)},Ee="json",Pe="autoLoadIntervalSeconds",Oe="rowIdColumnName",be="tableId",Ae="tableName",Te={mode:Ee,[Pe]:1},we={load:0,save:0,[Ae]:l+"_values"},Ne=(e,n,l,t)=>{const o=M();return D(e,((e,r)=>{const i=v(j(I(n,s(e)?{[l]:e}:e)),0,_(n));a(i[0])||t(r,i[0])||$(o,r,i)})),o};var Se=(e,n,l)=>new Promise(((t,o)=>{var r=e=>{try{u(l.next(e))}catch(e){o(e)}},i=e=>{try{u(l.throw(e))}catch(e){o(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,i);u((l=l.apply(e,n)).next())}));const ge="pragma ",xe="data_version",Le="schema_version",Re=(e,n,t,o,r,i,u,a,c="getDb",y)=>{let f,p,m;const[P,O,b,A]=(e=>{const n=(e=>I(Te,s(e)?{storeTableName:e}:null!=e?e:{}))(e),t=n[Pe];if(n.mode==Ee){const{storeTableName:e=l}=n;return[1,t,[e],G(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=v(j(I(we,i)),0,_(we)),d=u[2],a=G(d);return[0,t,[Ne(o,{[be]:null,[Oe]:h},be,(e=>J(a,e)&&e==d)),Ne(r,{[Ae]:null,[Oe]:h,deleteEmptyColumns:0,deleteEmptyTable:0},Ae,((e,n)=>J(a,n)&&n==d)),u],a]})(n);return(P?pe:me)(e,i?(e,n)=>Se(void 0,null,(function*(){return i(e,n),yield t(e,n)})):t,(e=>{return[(n=()=>Se(void 0,null,(function*(){try{const n=(yield t(ge+xe))[0][xe],l=(yield t(ge+Le))[0][Le],o=(yield t(E+" TOTAL_CHANGES() c"))[0].c;n==(null!=f?f:f=n)&&l==(null!=p?p:p=l)&&o==(null!=m?m:m=o)||(e(),f=n,p=l)}catch(e){}})),l=O,n(),setInterval(n,1e3*l)),o((n=>A.has(n)?e():0))];var n,l}),(([e,n])=>{d(e),f=p=null,r(n)}),u,b,N(A),a,c,y)},Ce="change";e.createSqlite3Persister=(e,n,l,t,o)=>Re(e,l,((e,...l)=>{return t=[e,...l],o=function*(e,l=[]){return yield(t=(t,o)=>n.all(e,l,((e,n)=>e?o(e):t(n))),new u(t));var t},new Promise(((e,n)=>{var l=e=>{try{i(o.next(e))}catch(e){n(e)}},r=e=>{try{i(o.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,r);i((o=o.apply(void 0,t)).next())}));var t,o}),(e=>{const l=(n,l,t)=>e(t);return n.on(Ce,l),l}),(e=>n.off(Ce,e)),t,o,n)},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterSqlite3={});
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinybase",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -215,13 +215,14 @@
|
|
|
215
215
|
},
|
|
216
216
|
"devDependencies": {
|
|
217
217
|
"@automerge/automerge": "^2.1.13",
|
|
218
|
-
"@automerge/automerge-repo": "^1.1.
|
|
218
|
+
"@automerge/automerge-repo": "^1.1.5",
|
|
219
219
|
"@babel/cli": "^7.24.1",
|
|
220
|
-
"@babel/core": "^7.24.
|
|
221
|
-
"@babel/preset-env": "^7.24.
|
|
220
|
+
"@babel/core": "^7.24.4",
|
|
221
|
+
"@babel/preset-env": "^7.24.4",
|
|
222
222
|
"@babel/preset-react": "^7.24.1",
|
|
223
223
|
"@babel/preset-typescript": "^7.24.1",
|
|
224
224
|
"@libsql/client": "^0.6.0",
|
|
225
|
+
"@journeyapps/powersync-sdk-common": "^1.4.0",
|
|
225
226
|
"@prettier/sync": "^0.5.1",
|
|
226
227
|
"@rollup/plugin-image": "^3.0.3",
|
|
227
228
|
"@rollup/plugin-replace": "^5.0.5",
|
|
@@ -233,14 +234,14 @@
|
|
|
233
234
|
"@types/jest": "^29.5.12",
|
|
234
235
|
"@types/jest-environment-puppeteer": "^5.0.6",
|
|
235
236
|
"@types/less": "^3.0.6",
|
|
236
|
-
"@types/node": "^20.
|
|
237
|
+
"@types/node": "^20.12.4",
|
|
237
238
|
"@types/puppeteer": "^5.4.7",
|
|
238
|
-
"@types/react": "^18.2.
|
|
239
|
-
"@types/react-dom": "^18.2.
|
|
239
|
+
"@types/react": "^18.2.74",
|
|
240
|
+
"@types/react-dom": "^18.2.24",
|
|
240
241
|
"@types/react-test-renderer": "^18.0.7",
|
|
241
242
|
"@types/tmp": "^0.2.6",
|
|
242
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
243
|
-
"@typescript-eslint/parser": "^7.
|
|
243
|
+
"@typescript-eslint/eslint-plugin": "^7.5.0",
|
|
244
|
+
"@typescript-eslint/parser": "^7.5.0",
|
|
244
245
|
"@vlcn.io/crsqlite-wasm": "^0.16.0",
|
|
245
246
|
"asciichart": "^1.5.25",
|
|
246
247
|
"babel-eslint": "^10.1.0",
|
|
@@ -261,7 +262,7 @@
|
|
|
261
262
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
262
263
|
"expo-sqlite": "^13.2.1",
|
|
263
264
|
"fake-indexeddb": "^5.0.2",
|
|
264
|
-
"gulp": "^
|
|
265
|
+
"gulp": "^5.0.0",
|
|
265
266
|
"gulp-gzip": "^1.4.2",
|
|
266
267
|
"http-server": "^14.1.1",
|
|
267
268
|
"idb": "^8.0.0",
|
|
@@ -270,14 +271,14 @@
|
|
|
270
271
|
"jest-fetch-mock": "^3.0.3",
|
|
271
272
|
"jest-puppeteer": "^10.0.1",
|
|
272
273
|
"less": "^4.2.0",
|
|
273
|
-
"partykit": "^0.0.
|
|
274
|
+
"partykit": "^0.0.102",
|
|
274
275
|
"partysocket": "^1.0.1",
|
|
275
276
|
"prettier": "^3.2.5",
|
|
276
|
-
"puppeteer": "22.6.
|
|
277
|
+
"puppeteer": "22.6.2",
|
|
277
278
|
"react": "^18.2.0",
|
|
278
279
|
"react-dom": "^18.2.0",
|
|
279
280
|
"react-test-renderer": "^18.2.0",
|
|
280
|
-
"rollup": "^4.
|
|
281
|
+
"rollup": "^4.14.0",
|
|
281
282
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
282
283
|
"rollup-plugin-gzip": "^3.1.2",
|
|
283
284
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
@@ -287,18 +288,19 @@
|
|
|
287
288
|
"tinydocs": "^0.1.36",
|
|
288
289
|
"tmp": "^0.2.3",
|
|
289
290
|
"ts-unused-exports": "^10.0.1",
|
|
290
|
-
"typescript": "5.4.
|
|
291
|
+
"typescript": "5.4.4",
|
|
291
292
|
"wa-sqlite": "github:rhashimoto/wa-sqlite",
|
|
292
293
|
"yjs": "^13.6.14"
|
|
293
294
|
},
|
|
294
295
|
"peerDependencies": {
|
|
295
|
-
"@automerge/automerge-repo": "^1.1.
|
|
296
|
+
"@automerge/automerge-repo": "^1.1.5",
|
|
296
297
|
"@libsql/client": "^0.5.6",
|
|
298
|
+
"@journeyapps/powersync-sdk-common": "^1.3.2",
|
|
297
299
|
"@sqlite.org/sqlite-wasm": "^3.45.2-build1",
|
|
298
300
|
"@vlcn.io/crsqlite-wasm": "^0.16.0",
|
|
299
301
|
"electric-sql": "^0.9.6",
|
|
300
302
|
"expo-sqlite": "^13.2.1",
|
|
301
|
-
"partykit": "^0.0.
|
|
303
|
+
"partykit": "^0.0.102",
|
|
302
304
|
"partysocket": "^1.0.1",
|
|
303
305
|
"prettier": "^3.2.5",
|
|
304
306
|
"react": "^18.2.0",
|
|
@@ -313,6 +315,9 @@
|
|
|
313
315
|
"@libsql/client": {
|
|
314
316
|
"optional": true
|
|
315
317
|
},
|
|
318
|
+
"@journeyapps/powersync-sdk-common": {
|
|
319
|
+
"optional": true
|
|
320
|
+
},
|
|
316
321
|
"@sqlite.org/sqlite-wasm": {
|
|
317
322
|
"optional": true
|
|
318
323
|
},
|
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-
|
|
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-8"><em>NEW!</em> v4.8 release</a> <span id="one-with">"The One With PowerSync"</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app's data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions & ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a> 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/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/turso.svg">Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/powersync.svg">PowerSync</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=GitHub&labelColor=%23d81b60&color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&logo=discord&logoColor=%23fff&label=Discord&labelColor=%233131e8&color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&logo=x&logoColor=%23fff&label=Twitter&labelColor=%23333&color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Ideas&labelColor=%23d81b60&color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&logo=GitHub&logoColor=%23fff&label=Issues&labelColor=%23d81b60&color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&logo=jest&logoColor=%23fff&color=%23333&labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.8.0" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&logo=npm&logoColor=%23fff&labelColor=%23bd0005&color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const store = createStore()
|
|
@@ -247,4 +247,4 @@ export const createShop: typeof createShopDecl = () => {
|
|
|
247
247
|
};
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>5.0kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.4kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>4.3kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>11.1kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>5.0kB</td><td>12.0kB</td><td>51.6kB</td><td>252.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.0kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.1kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>126.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.6kB</td><td>3.1kB</td><td>12.7kB</td><td>35.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.5kB</td><td>5.3kB</td><td>44.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.4kB</td><td>23.2kB</td><td>100.8kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,968</td><td>1,968</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,127</td><td>2,127</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>848</td><td>848</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>719</td><td>719</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,975</td></tr><tr><th class="right">Assertions</th><td colspan="3">18,202</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img title="beekeeb" src="https://github.com/beekeeb.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img title="feychenie" src="https://github.com/feychenie.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img title="fostertheweb" src="https://github.com/fostertheweb.png?size=48" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img title="fostertheweb" src="https://github.com/fostertheweb.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img title="itsdevcoffee" src="https://github.com/itsdevcoffee.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img title="jbolda" src="https://github.com/jbolda.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img title="Kudo" src="https://github.com/Kudo.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img title="lluc" src="https://github.com/lluc.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img title="mjamesderocher" src="https://github.com/mjamesderocher.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img title="palerdot" src="https://github.com/palerdot.png?size=48" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img title="PorcoRosso85" src="https://github.com/PorcoRosso85.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img title="sudo-self" src="https://github.com/sudo-self.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
|
|
250
|
+
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>5.0kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.4kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>4.3kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>11.1kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>5.0kB</td><td>12.0kB</td><td>51.6kB</td><td>252.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.0kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.1kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>126.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.6kB</td><td>3.1kB</td><td>12.7kB</td><td>35.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.8kB</td><td>1.5kB</td><td>5.3kB</td><td>44.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.4kB</td><td>23.2kB</td><td>100.8kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,968</td><td>1,968</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,127</td><td>2,127</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>848</td><td>848</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>719</td><td>719</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">4,078</td></tr><tr><th class="right">Assertions</th><td colspan="3">18,366</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img title="beekeeb" src="https://github.com/beekeeb.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img title="feychenie" src="https://github.com/feychenie.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img title="fostertheweb" src="https://github.com/fostertheweb.png?size=48" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img title="fostertheweb" src="https://github.com/fostertheweb.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img title="itsdevcoffee" src="https://github.com/itsdevcoffee.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img title="jbolda" src="https://github.com/jbolda.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img title="Kudo" src="https://github.com/Kudo.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img title="lluc" src="https://github.com/lluc.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img title="mjamesderocher" src="https://github.com/mjamesderocher.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img title="palerdot" src="https://github.com/palerdot.png?size=48" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img title="PorcoRosso85" src="https://github.com/PorcoRosso85.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img title="sudo-self" src="https://github.com/sudo-self.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
|