tinybase 4.0.1 → 4.0.2
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-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-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 +177 -117
- package/lib/debug/persisters/persister-sqlite-wasm.js +172 -116
- package/lib/debug/persisters/persister-sqlite3.js +172 -117
- 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-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-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.d.ts +7 -0
- package/lib/types/with-schemas/persisters.d.ts +7 -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-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-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 +19 -19
- package/readme.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,t="tinybase",l=",",o=n(""),r=(e,n)=>e.repeat(n),i=(e,n="")=>e.join(n),u=(e,n)=>e.map(n),a=e=>e.length,d=e=>0==a(e),s=(e,n)=>e.filter(n),c=(e,n,t)=>e.slice(n,t),v=(e,...n)=>e.push(...n),y=Promise,f=(e,n)=>e instanceof n,p=e=>null==e,h=(e,n,t)=>p(e)?null==t?void 0:t():n(e),m=e=>n(e)==o,E=e=>{return n=function*(){return y.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},b=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},O=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},T=(e,n)=>null==e?void 0:e.delete(n),P=Object,w=P.keys,A=P.freeze,L=(e=[])=>P.fromEntries(e),R=(...e)=>P.assign({},...e),S=(e,n)=>u(P.entries(e),(([e,t])=>n(t,e))),x=e=>P.values(e),g=e=>a(w(e)),N=e=>(e=>f(e,P)&&e.constructor==P)(e)&&0==g(e),C=e=>new Map(e),I=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},j=(e,n)=>null==e?void 0:e.get(n),D=(e,n)=>{var t;return u([...null!=(t=null==e?void 0:e.entries())?t:[]],(([e,t])=>n(t,e)))},_=(e,n,t)=>p(t)?(T(e,n),e):null==e?void 0:e.set(n,t),M=(e,n,t,l=_)=>(S(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)=>!p(((e,n)=>h(e,(e=>e[n])))(e,n)))(n,t)?0:l(e,t))),e),F=e=>new Set(Array.isArray(e)||p(e)?e:[e]),$=(e,n)=>null==e?void 0:e.add(n),W="_",B="_id",k=e=>`"${e.replace(/"/g,'""')}"`;var q=Object.defineProperty,H=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,V=(e,n,t)=>n in e?q(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Y=(e,n)=>{for(var t in n||(n={}))J.call(n,t)&&V(e,t,n[t]);if(H)for(var t of H(n))U.call(n,t)&&V(e,t,n[t]);return e},z=(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 K="FROM pragma_table_",G="WHERE",Q=(e,n)=>{const t=C();return[()=>z(void 0,null,(function*(){return M(t,L(yield E(u(yield e("SELECT name "+K+"list WHERE schema='main'AND type='table'AND name IN("+Z(n)+")",n),(n=>z(void 0,[n],(function*({name:n}){return[n,L(u(yield e("SELECT name,type "+K+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>{return _(t,n,M((i=C,b(o=t,r=n)||_(o,r,i()),j(o,r)),l,((e,n,t)=>{t!=j(e,n)&&_(e,n,t)}),((e,n)=>_(e,n))));var o,r,i}),((e,n)=>_(t,n)))})),(n,l)=>z(void 0,null,(function*(){return((e,n)=>!p(j(j(t,e),n)))(n,l)?L(s(u(yield e("SELECT*FROM"+k(n)),(e=>{return[e[l],(n=Y({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!p(e)&&!N(n)))):{}})),(n,o,r,a,c,y=!1)=>z(void 0,null,(function*(){const f=F();S(null!=r?r:{},(e=>u(w(null!=e?e:{}),(e=>$(f,e)))));const h=O(f);if(!y&&c&&d(h)&&b(t,n))return yield e("DROP TABLE"+k(n)),void _(t,n);if(d(h)||b(t,n)){const l=j(t,n),r=F(I(l));yield E([...u(h,(t=>z(void 0,null,(function*(){T(r,t)||(yield e(`ALTER TABLE${k(n)}ADD${k(t)}`),_(l,t,""))})))),...!y&&a?u(O(r),(t=>z(void 0,null,(function*(){t!=o&&(yield e(`ALTER TABLE${k(n)}DROP${k(t)}`),_(l,t))})))):[]])}else yield e(`CREATE TABLE${k(n)}(${k(o)} PRIMARY KEY ON CONFLICT REPLACE${i(u(h,(e=>l+k(e))))});`),_(t,n,C([[o,""],...u(h,(e=>[e,""]))]));if(y)p(r)?yield e("DELETE FROM"+k(n)+"WHERE 1"):yield E(S(r,((t,l)=>z(void 0,null,(function*(){p(t)?yield e("DELETE FROM"+k(n)+G+k(o)+"=?",[l]):d(h)||(yield X(e,n,o,w(t),[l,...x(t)]))})))));else if(d(h))b(t,n)&&(yield e("DELETE FROM"+k(n)+"WHERE 1"));else{const l=s(I(j(t,n)),(e=>e!=o)),i=[],a=[];S(null!=r?r:{},((e,n)=>{v(i,n,...u(l,(n=>null==e?void 0:e[n]))),v(a,n)})),yield X(e,n,o,l,i),yield e("DELETE FROM"+k(n)+G+k(o)+"NOT IN("+Z(a)+")",a)}}))]},X=(e,n,t,o,d)=>z(void 0,null,(function*(){return yield e("INSERT INTO"+k(n)+"("+k(t)+i(u(o,(e=>l+k(e))))+")VALUES"+r(`,(?${r(",?",a(o))})`,a(d)/(a(o)+1)).substring(1)+"ON CONFLICT("+k(t)+")DO UPDATE SET"+i(u(o,(e=>k(e)+"=excluded."+k(e))),l),d)})),Z=e=>i(u(e,(()=>"?")),l),ee=JSON.parse;var ne=(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 te=(e,n,t,l,o)=>{let r,i,u,a=0,d=0,s=0;const c=[],y=e=>ne(void 0,null,(function*(){return 2!=a&&(a=1,yield f.schedule((()=>ne(void 0,null,(function*(){yield e(),a=0}))))),f})),f={load:(t,l)=>ne(void 0,null,(function*(){return yield y((()=>ne(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([t,l])}}))))})),startAutoLoad:(...t)=>ne(void 0,[...t],(function*(t={},o={}){return f.stopAutoLoad(),yield f.load(t,o),s=1,u=l(((t,l)=>ne(void 0,null,(function*(){return yield y((()=>ne(void 0,null,(function*(){var o;if(l)e.setTransactionChanges(l());else try{e.setContent(null!=(o=null==t?void 0:t())?o:yield n())}catch(e){}}))))})))),f})),stopAutoLoad:()=>(s&&(o(u),u=void 0,s=0),f),save:n=>ne(void 0,null,(function*(){return 1!=a&&(a=2,yield f.schedule((()=>ne(void 0,null,(function*(){try{yield t(e.getContent,n)}catch(e){}a=0}))))),f})),startAutoSave:()=>ne(void 0,null,(function*(){return yield f.stopAutoSave().save(),r=e.addDidFinishTransactionListener(((e,n)=>{const[t,l]=n();N(t)&&N(l)||f.save((()=>[t,l]))})),f})),stopAutoSave:()=>(h(r,e.delListener),f),schedule:(...e)=>ne(void 0,null,(function*(){return v(c,...e),yield ne(void 0,null,(function*(){if(!d){for(d=1;!p((e=c,i=e.shift()));)try{yield i()}catch(e){}d=0}var e})),f})),getStore:()=>e,destroy:()=>f.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return A(f)};var le=(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 oe="store",re=(e,n,t,l,[o],r)=>{const[i,u,a]=Q(n,r),d=te(e,(()=>le(void 0,null,(function*(){var e;return yield i(),ee(null==(e=(yield u(o,B))[W])?void 0:e[oe])}))),(e=>le(void 0,null,(function*(){return d.schedule(i,(()=>le(void 0,null,(function*(){var n;yield a(o,B,{[W]:{[oe]:(n=e(),JSON.stringify(n,((e,n)=>f(n,Map)?P.fromEntries([...n]):n)))}},!0,!0)}))))}))),t,l);return d};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=(e,n,t,l,[o,r,[i,u,a]],d)=>{const[c,v,y]=Q(n,d),f=(e,n)=>ie(void 0,null,(function*(){return yield E(D(r,((t,l)=>ie(void 0,[t,l],(function*([t,l,o,r],i){const u=e[i];n&&void 0===u||(yield y(t,l,u,o,r,n))})))))})),h=(e,n)=>ie(void 0,null,(function*(){return u?yield y(a,B,{[W]:e},!0,!0,n):null}));return te(e,(()=>ie(void 0,null,(function*(){yield c();const e=yield ie(void 0,null,(function*(){return L(s(yield E(D(o,((e,n)=>ie(void 0,[e,n],(function*([e,n],t){return[e,yield v(t,n)]}))))),(e=>!N(e[1]))))})),n=yield ie(void 0,null,(function*(){return i?(yield v(a,B))[W]:{}}));return N(e)&&p(n)?void 0:[e,n]}))),((e,n)=>ie(void 0,null,(function*(){if(yield c(),p(n)){const[n,t]=e();yield f(n),yield h(t)}else{const[e,t]=n();yield f(e,!0),yield h(t,!0)}}))),t,l)},ae="json",de="autoLoadIntervalSeconds",se="rowIdColumnName",ce="tableId",ve="tableName",ye={mode:ae,[de]:1},fe={load:0,save:0,[ve]:t+"_values"},pe=(e,n,t,l)=>{const o=C();return S(e,((e,r)=>{const i=c(x(R(n,m(e)?{[t]:e}:e)),0,g(n));p(i[0])||l(r,i[0])||_(o,r,i)})),o};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="pragma ",Ee="data_version",be="schema_version",Oe=(e,n,l,o,r,i)=>{let u,a;const[d,s,v,y]=(e=>{const n=(e=>R(ye,m(e)?{storeTableName:e}:null!=e?e:{}))(e),l=n[de];if(n.mode==ae){const{storeTableName:e=t}=n;return[1,l,[e],F(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=c(x(R(fe,i)),0,g(fe)),a=u[2],d=F(a);return[0,l,[pe(o,{[ce]:null,[se]:B},ce,(e=>$(d,e)&&e==a)),pe(r,{[ve]:null,[se]:B,deleteEmptyColumns:0,deleteEmptyTable:0},ve,((e,n)=>$(d,n)&&n==a)),u],d]})(n);return(d?re:ue)(e,i?(e,n)=>he(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>[setInterval((()=>he(void 0,null,(function*(){try{const n=(yield l(me+Ee))[0][Ee],t=(yield l(me+be))[0][be];n==(null!=u?u:u=n)&&t==(null!=a?a:a=t)||(e(),u=n,a=t)}catch(e){}}))),1e3*s),o((n=>y.has(n)?e():0))]),(([e,n])=>{clearInterval(e),u=a=null,r(n)}),v,O(y))};var Te=Object.defineProperty,Pe=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,Le=(e,n,t)=>n in e?Te(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;e.createSqliteWasmPersister=(e,n,t,l,o)=>Oe(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={}))we.call(n,t)&&Le(e,t,n[t]);if(Pe)for(var t of Pe(n))Ae.call(n,t)&&Le(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)},"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,t="tinybase",l=",",
|
|
1
|
+
var e,n;e=this,n=function(e){"use strict";const n=e=>typeof e,t="tinybase",l=",",o=n(""),r=(e,n)=>e.repeat(n),i=(e,n="")=>e.join(n),u=(e,n)=>e.map(n),a=e=>e.length,d=e=>0==a(e),s=(e,n)=>e.filter(n),c=(e,n,t)=>e.slice(n,t),v=(e,...n)=>e.push(...n),y=Promise,f=(e,n)=>e instanceof n,p=e=>null==e,h=(e,n,t)=>p(e)?null==t?void 0:t():n(e),E=e=>n(e)==o,m=e=>{return n=function*(){return y.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},b=(e,n)=>{var t;return null!=(t=null==e?void 0:e.has(n))&&t},O=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},T=(e,n)=>null==e?void 0:e.delete(n),P=Object,A=P.keys,L=P.freeze,w=(e=[])=>P.fromEntries(e),S=(...e)=>P.assign({},...e),g=(e,n)=>u(P.entries(e),(([e,t])=>n(t,e))),R=e=>P.values(e),N=e=>a(A(e)),x=e=>(e=>f(e,P)&&e.constructor==P)(e)&&0==N(e),C=e=>new Map(e),I=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},D=(e,n)=>null==e?void 0:e.get(n),j=(e,n)=>{var t;return u([...null!=(t=null==e?void 0:e.entries())?t:[]],(([e,t])=>n(t,e)))},F=(e,n,t)=>p(t)?(T(e,n),e):null==e?void 0:e.set(n,t),M=(e,n,t,l=F)=>(g(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)=>!p(((e,n)=>h(e,(e=>e[n])))(e,n)))(n,t)?0:l(e,t))),e),$=e=>new Set(Array.isArray(e)||p(e)?e:[e]),_=(e,n)=>null==e?void 0:e.add(n),B="_",H="_id",W=e=>`"${e.replace(/"/g,'""')}"`;var k=Object.defineProperty,q=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,Y=(e,n,t)=>n in e?k(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,z=(e,n)=>{for(var t in n||(n={}))J.call(n,t)&&Y(e,t,n[t]);if(q)for(var t of q(n))U.call(n,t)&&Y(e,t,n[t]);return e},K=(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 V="FROM pragma_table_",G="WHERE",Q=(e,n)=>{const t=C();return[()=>K(void 0,null,(function*(){return M(t,w(yield m(u(yield e("SELECT name "+V+"list WHERE schema='main'AND type='table'AND name IN("+Z(n)+")",n),(n=>K(void 0,[n],(function*({name:n}){return[n,w(u(yield e("SELECT name,type "+V+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>{return F(t,n,M((i=C,b(o=t,r=n)||F(o,r,i()),D(o,r)),l,((e,n,t)=>{t!=D(e,n)&&F(e,n,t)}),((e,n)=>F(e,n))));var o,r,i}),((e,n)=>F(t,n)))})),(n,l)=>K(void 0,null,(function*(){return((e,n)=>!p(D(D(t,e),n)))(n,l)?w(s(u(yield e("SELECT*FROM"+W(n)),(e=>{return[e[l],(n=z({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!p(e)&&!x(n)))):{}})),(n,o,r,a,c,y=!1)=>K(void 0,null,(function*(){const f=$();g(null!=r?r:{},(e=>u(A(null!=e?e:{}),(e=>_(f,e)))));const h=O(f);if(!y&&c&&d(h)&&b(t,n))return yield e("DROP TABLE"+W(n)),void F(t,n);if(d(h)||b(t,n)){const l=D(t,n),r=$(I(l));yield m([...u(h,(t=>K(void 0,null,(function*(){T(r,t)||(yield e(`ALTER TABLE${W(n)}ADD${W(t)}`),F(l,t,""))})))),...!y&&a?u(O(r),(t=>K(void 0,null,(function*(){t!=o&&(yield e(`ALTER TABLE${W(n)}DROP${W(t)}`),F(l,t))})))):[]])}else yield e(`CREATE TABLE${W(n)}(${W(o)} PRIMARY KEY ON CONFLICT REPLACE${i(u(h,(e=>l+W(e))))});`),F(t,n,C([[o,""],...u(h,(e=>[e,""]))]));if(y)p(r)?yield e("DELETE FROM"+W(n)+"WHERE 1"):yield m(g(r,((t,l)=>K(void 0,null,(function*(){p(t)?yield e("DELETE FROM"+W(n)+G+W(o)+"=?",[l]):d(h)||(yield X(e,n,o,A(t),[l,...R(t)]))})))));else if(d(h))b(t,n)&&(yield e("DELETE FROM"+W(n)+"WHERE 1"));else{const l=s(I(D(t,n)),(e=>e!=o)),i=[],a=[];g(null!=r?r:{},((e,n)=>{v(i,n,...u(l,(n=>null==e?void 0:e[n]))),v(a,n)})),yield X(e,n,o,l,i),yield e("DELETE FROM"+W(n)+G+W(o)+"NOT IN("+Z(a)+")",a)}}))]},X=(e,n,t,o,d)=>K(void 0,null,(function*(){return yield e("INSERT INTO"+W(n)+"("+W(t)+i(u(o,(e=>l+W(e))))+")VALUES"+r(`,(?${r(",?",a(o))})`,a(d)/(a(o)+1)).substring(1)+"ON CONFLICT("+W(t)+")DO UPDATE SET"+i(u(o,(e=>W(e)+"=excluded."+W(e))),l),d)})),Z=e=>i(u(e,(()=>"?")),l),ee=JSON.parse;var ne=(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 te=(e,n,t,l,o)=>{let r,i,u,a=0,d=0,s=0;const c=[],y=e=>ne(void 0,null,(function*(){return 2!=a&&(a=1,yield f.schedule((()=>ne(void 0,null,(function*(){yield e(),a=0}))))),f})),f={load:(t,l)=>ne(void 0,null,(function*(){return yield y((()=>ne(void 0,null,(function*(){try{e.setContent(yield n())}catch(n){e.setContent([t,l])}}))))})),startAutoLoad:(...t)=>ne(void 0,[...t],(function*(t={},o={}){return f.stopAutoLoad(),yield f.load(t,o),s=1,u=l(((t,l)=>ne(void 0,null,(function*(){return yield y((()=>ne(void 0,null,(function*(){var o;if(l)e.setTransactionChanges(l());else try{e.setContent(null!=(o=null==t?void 0:t())?o:yield n())}catch(e){}}))))})))),f})),stopAutoLoad:()=>(s&&(o(u),u=void 0,s=0),f),save:n=>ne(void 0,null,(function*(){return 1!=a&&(a=2,yield f.schedule((()=>ne(void 0,null,(function*(){try{yield t(e.getContent,n)}catch(e){}a=0}))))),f})),startAutoSave:()=>ne(void 0,null,(function*(){return yield f.stopAutoSave().save(),r=e.addDidFinishTransactionListener(((e,n)=>{const[t,l]=n();x(t)&&x(l)||f.save((()=>[t,l]))})),f})),stopAutoSave:()=>(h(r,e.delListener),f),schedule:(...e)=>ne(void 0,null,(function*(){return v(c,...e),yield ne(void 0,null,(function*(){if(!d){for(d=1;!p((e=c,i=e.shift()));)try{yield i()}catch(e){}d=0}var e})),f})),getStore:()=>e,destroy:()=>f.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return L(f)};var le=(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 oe="store",re=(e,n,t,l,[o],r)=>{const[i,u,a]=Q(n,r),d=te(e,(()=>le(void 0,null,(function*(){var e;return yield i(),ee(null==(e=(yield u(o,H))[B])?void 0:e[oe])}))),(e=>le(void 0,null,(function*(){return d.schedule(i,(()=>le(void 0,null,(function*(){var n;yield a(o,H,{[B]:{[oe]:(n=e(),JSON.stringify(n,((e,n)=>f(n,Map)?P.fromEntries([...n]):n)))}},!0,!0)}))))}))),t,l);return d};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=(e,n,t,l,[o,r,[i,u,a]],d)=>{const[c,v,y]=Q(n,d),f=(e,n)=>ie(void 0,null,(function*(){return yield m(j(r,((t,l)=>ie(void 0,[t,l],(function*([t,l,o,r],i){const u=e[i];n&&void 0===u||(yield y(t,l,u,o,r,n))})))))})),h=(e,n)=>ie(void 0,null,(function*(){return u?yield y(a,H,{[B]:e},!0,!0,n):null}));return te(e,(()=>ie(void 0,null,(function*(){yield c();const e=yield ie(void 0,null,(function*(){return w(s(yield m(j(o,((e,n)=>ie(void 0,[e,n],(function*([e,n],t){return[e,yield v(t,n)]}))))),(e=>!x(e[1]))))})),n=yield ie(void 0,null,(function*(){return i?(yield v(a,H))[B]:{}}));return x(e)&&p(n)?void 0:[e,n]}))),((e,n)=>ie(void 0,null,(function*(){if(yield c(),p(n)){const[n,t]=e();yield f(n),yield h(t)}else{const[e,t]=n();yield f(e,!0),yield h(t,!0)}}))),t,l)},ae="json",de="autoLoadIntervalSeconds",se="rowIdColumnName",ce="tableId",ve="tableName",ye={mode:ae,[de]:1},fe={load:0,save:0,[ve]:t+"_values"},pe=(e,n,t,l)=>{const o=C();return g(e,((e,r)=>{const i=c(R(S(n,E(e)?{[t]:e}:e)),0,N(n));p(i[0])||l(r,i[0])||F(o,r,i)})),o};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 Ee="pragma ",me="data_version",be="schema_version",Oe=(e,n,l,o,r,i)=>{let u,a;const[d,s,v,y]=(e=>{const n=(e=>S(ye,E(e)?{storeTableName:e}:null!=e?e:{}))(e),l=n[de];if(n.mode==ae){const{storeTableName:e=t}=n;return[1,l,[e],$(e)]}const{tables:{load:o={},save:r={}}={},values:i={}}=n,u=c(R(S(fe,i)),0,N(fe)),a=u[2],d=$(a);return[0,l,[pe(o,{[ce]:null,[se]:H},ce,(e=>_(d,e)&&e==a)),pe(r,{[ve]:null,[se]:H,deleteEmptyColumns:0,deleteEmptyTable:0},ve,((e,n)=>_(d,n)&&n==a)),u],d]})(n);return(d?re:ue)(e,i?(e,n)=>he(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>[setInterval((()=>he(void 0,null,(function*(){try{const n=(yield l(Ee+me))[0][me],t=(yield l(Ee+be))[0][be];n==(null!=u?u:u=n)&&t==(null!=a?a:a=t)||(e(),u=n,a=t)}catch(e){}}))),1e3*s),o((n=>y.has(n)?e():0))]),(([e,n])=>{clearInterval(e),u=a=null,r(n)}),v,O(y))};var Te=Object.defineProperty,Pe=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,we=(e,n,t)=>n in e?Te(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;const Se="change";e.createSqlite3Persister=(e,n,t,l)=>Oe(e,t,((e,t=[])=>new y(((l,o)=>n.all(e,t,((e,n)=>e?o(e):l(n.map((e=>((e,n)=>{for(var t in n||(n={}))Ae.call(n,t)&&we(e,t,n[t]);if(Pe)for(var t of Pe(n))Le.call(n,t)&&we(e,t,n[t]);return e})({},e))))))))),(e=>{const t=(n,t,l)=>e(l);return n.on(Se,t),t}),(e=>n.off(Se,e)),l)},"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.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"author": "jamesgpearce",
|
|
5
5
|
"repository": "github:tinyplex/tinybase",
|
|
6
6
|
"license": "MIT",
|
|
@@ -211,43 +211,43 @@
|
|
|
211
211
|
},
|
|
212
212
|
"devDependencies": {
|
|
213
213
|
"@automerge/automerge": "^2.1.0-alpha.6",
|
|
214
|
-
"@babel/cli": "^7.22.
|
|
215
|
-
"@babel/core": "^7.22.
|
|
216
|
-
"@babel/preset-env": "^7.22.
|
|
214
|
+
"@babel/cli": "^7.22.10",
|
|
215
|
+
"@babel/core": "^7.22.10",
|
|
216
|
+
"@babel/preset-env": "^7.22.10",
|
|
217
217
|
"@babel/preset-react": "^7.22.5",
|
|
218
218
|
"@babel/preset-typescript": "^7.22.5",
|
|
219
219
|
"@rollup/plugin-replace": "^5.0.2",
|
|
220
220
|
"@rollup/plugin-terser": "^0.4.3",
|
|
221
|
-
"@sqlite.org/sqlite-wasm": "^3.42.0-
|
|
221
|
+
"@sqlite.org/sqlite-wasm": "^3.42.0-build7",
|
|
222
222
|
"@types/asciichart": "^1.5.6",
|
|
223
223
|
"@types/expect-puppeteer": "^5.0.3",
|
|
224
224
|
"@types/http-server": "^0.12.1",
|
|
225
225
|
"@types/jest": "^29.5.3",
|
|
226
226
|
"@types/jest-environment-puppeteer": "^5.0.3",
|
|
227
227
|
"@types/less": "^3.0.3",
|
|
228
|
-
"@types/node": "^20.4.
|
|
228
|
+
"@types/node": "^20.4.9",
|
|
229
229
|
"@types/puppeteer": "^5.4.7",
|
|
230
|
-
"@types/react": "^18.2.
|
|
230
|
+
"@types/react": "^18.2.20",
|
|
231
231
|
"@types/react-dom": "^18.2.7",
|
|
232
232
|
"@types/react-test-renderer": "^18.0.0",
|
|
233
233
|
"@types/tmp": "^0.2.3",
|
|
234
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
235
|
-
"@typescript-eslint/parser": "^6.
|
|
234
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
235
|
+
"@typescript-eslint/parser": "^6.3.0",
|
|
236
236
|
"@vlcn.io/crsqlite-wasm": "^0.14.0",
|
|
237
237
|
"asciichart": "^1.5.25",
|
|
238
238
|
"automerge-repo": "^0.1.0",
|
|
239
239
|
"babel-eslint": "^10.1.0",
|
|
240
240
|
"babel-jest": "^29.6.2",
|
|
241
|
-
"babel-plugin-transform-import-meta": "^2.2.
|
|
241
|
+
"babel-plugin-transform-import-meta": "^2.2.1",
|
|
242
242
|
"babel-preset-minify": "^0.5.2",
|
|
243
243
|
"buffer-replace": "^1.0.0",
|
|
244
244
|
"country-flag-emoji-json": "^2.0.0",
|
|
245
|
-
"cspell": "^
|
|
246
|
-
"esbuild": "^0.
|
|
247
|
-
"eslint": "^8.
|
|
248
|
-
"eslint-config-prettier": "^
|
|
245
|
+
"cspell": "^7.0.0",
|
|
246
|
+
"esbuild": "^0.19.0",
|
|
247
|
+
"eslint": "^8.46.0",
|
|
248
|
+
"eslint-config-prettier": "^9.0.0",
|
|
249
249
|
"eslint-plugin-jest": "^27.2.3",
|
|
250
|
-
"eslint-plugin-jsdoc": "^46.4.
|
|
250
|
+
"eslint-plugin-jsdoc": "^46.4.6",
|
|
251
251
|
"eslint-plugin-react": "7.32.2",
|
|
252
252
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
253
253
|
"fake-indexeddb": "^4.0.2",
|
|
@@ -258,13 +258,13 @@
|
|
|
258
258
|
"jest-environment-jsdom": "^29.6.2",
|
|
259
259
|
"jest-fetch-mock": "^3.0.3",
|
|
260
260
|
"jest-puppeteer": "^9.0.0",
|
|
261
|
-
"less": "^4.
|
|
261
|
+
"less": "^4.2.0",
|
|
262
262
|
"prettier": "^2.8.8",
|
|
263
|
-
"puppeteer": "^
|
|
263
|
+
"puppeteer": "^21.0.2",
|
|
264
264
|
"react": "^18.2.0",
|
|
265
265
|
"react-dom": "^18.2.0",
|
|
266
266
|
"react-test-renderer": "^18.2.0",
|
|
267
|
-
"rollup": "^3.
|
|
267
|
+
"rollup": "^3.28.0",
|
|
268
268
|
"rollup-plugin-esbuild": "^5.0.0",
|
|
269
269
|
"rollup-plugin-gzip": "^3.1.0",
|
|
270
270
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
"tinybase": "file:./",
|
|
274
274
|
"tinydocs": "^0.1.29",
|
|
275
275
|
"tmp": "^0.2.1",
|
|
276
|
-
"ts-unused-exports": "^
|
|
276
|
+
"ts-unused-exports": "^10.0.0",
|
|
277
277
|
"typescript": "5.1.6",
|
|
278
278
|
"yjs": "^13.6.7"
|
|
279
279
|
},
|
package/readme.md
CHANGED
|
@@ -266,4 +266,4 @@ export const createShop: typeof createShopDecl = () => {
|
|
|
266
266
|
};
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>4.7kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.9kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.2kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.7kB</td><td>11.1kB</td><td>47.6kB</td><td>212.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>14.9kB</td><td>29.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.7kB</td><td>33.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.8kB</td><td>3.7kB</td><td>16.8kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>112.7kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.6kB</td><td>1.2kB</td><td>3.9kB</td><td>
|
|
269
|
+
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you'll only add a gzipped <em>4.7kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>8.9kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.4kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.2kB</em>, and everything is super fast. Life's easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.7kB</td><td>11.1kB</td><td>47.6kB</td><td>212.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>14.9kB</td><td>29.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.7kB</td><td>16.7kB</td><td>33.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.8kB</td><td>3.7kB</td><td>16.8kB</td><td>42.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.7kB</td><td>5.5kB</td><td>25.0kB</td><td>112.7kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.5kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.6kB</td><td>1.2kB</td><td>3.9kB</td><td>42.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>8.9kB</td><td>21.9kB</td><td>94.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,815</td><td>1,815</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,957</td><td>1,957</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>776</td><td>776</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>669</td><td>669</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,138</td></tr><tr><th class="right">Assertions</th><td colspan="3">14,445</td></tr></tbody></table></div><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a>, <a href="https://discord.com/invite/mGz3mevwP8">Discord</a>, and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/discussions">Discussions</a> and <a href="https://github.com/tinyplex/tinybase/issues">issues</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a>.</li><li><a href="https://tinybase.org/guides/releases/">Release notes</a> for each version.</li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/4.0.2">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://hachyderm.io/@jamesgpearce">me</a> in API design, minification, and documentation. It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it!</p></section>
|