Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chore/update-wa-s…
Browse files Browse the repository at this point in the history
…qlite
  • Loading branch information
mugikhan committed Apr 17, 2024
2 parents ccbe0f6 + ca2084c commit 5307f6e
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 62 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ CFILES = \
libvfs.c \
$(CFILES_EXTRA)

JSFILES = \
src/libauthorizer.js \
src/libfunction.js \
src/libmodule.js \
src/libprogress.js \
src/libvfs.js

vpath %.c src
vpath %.c deps
vpath %.c deps/$(SQLITE_VERSION)
Expand Down Expand Up @@ -56,7 +63,7 @@ EMFLAGS_COMMON = \

EMFLAGS_DEBUG = \
-s ASSERTIONS=1 \
-g -Oz \
-g -Oz -Oz \
$(EMFLAGS_COMMON)

EMFLAGS_DIST = \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Here are the build steps:
* `git clone [email protected]:rhashimoto/wa-sqlite.git`
* `cd wa-sqlite`
* `yarn install`
* `make` (or `yarn prepack`)
* `make`

The default build produces ES6 modules + WASM, [synchronous and asynchronous](https://github.com/rhashimoto/wa-sqlite/issues/7) (using Asyncify) in `dist/`.

Expand Down
12 changes: 6 additions & 6 deletions dist/wa-sqlite-async.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function pb(a){for(var b;;){if(a===a.parent)return a=a.Jf.ng,b?"/"!==a[a.length-
function eb(a,b){var c=P(a.mode)?(c=sb(a,"x"))?c:a.Af.Sf?0:2:54;if(c)throw new N(c);for(c=Q[qb(a.id,b)];c;c=c.Qf){var e=c.name;if(c.parent.id===a.id&&e===b)return c}return a.Af.Sf(a,b)}function cb(a,b,c,e){a=new nb(a,b,c,e);b=qb(a.parent.id,a.name);a.Qf=Q[b];return Q[b]=a}function P(a){return 16384===(a&61440)}function tb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}
function sb(a,b){if(lb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0}function ub(a,b){try{return eb(a,b),20}catch(c){}return sb(a,"wx")}function vb(a,b,c){try{var e=eb(a,b)}catch(f){return f.Df}if(a=sb(a,"wx"))return a;if(c){if(!P(e.mode))return 54;if(e===e.parent||"/"===pb(e))return 10}else if(P(e.mode))return 31;return 0}function S(a){a=jb[a];if(!a)throw new N(8);return a}
function wb(a,b=-1){a=Object.assign(new mb,a);if(-1==b)a:{for(b=0;4096>=b;b++)if(!jb[b])break a;throw new N(33);}a.Lf=b;return jb[b]=a}function xb(a,b=-1){a=wb(a,b);a.Bf?.Kg?.(a);return a}var bb={open(a){a.Bf=ib[a.node.Uf].Bf;a.Bf.open?.(a)},Of(){throw new N(70);}};function Xa(a,b){ib[a]={Bf:b}}
function yb(a,b){var c="/"===b;if(c&&hb)throw new N(10);if(!c&&b){var e=R(b,{kg:!1});b=e.path;e=e.node;if(e.Pf)throw new N(10);if(!P(e.mode))throw new N(54);}b={type:a,Qg:{},ng:b,zg:[]};a=a.Jf(b);a.Jf=b;b.root=a;c?hb=a:e&&(e.Pf=b,e.Jf&&e.Jf.zg.push(b))}function zb(a,b,c){var e=R(a,{parent:!0}).node;a=Oa(a);if(!a||"."===a||".."===a)throw new N(28);var f=ub(e,a);if(f)throw new N(f);if(!e.Af.Yf)throw new N(63);return e.Af.Yf(e,a,b,c)}function T(a,b){return zb(a,(void 0!==b?b:511)&1023|16384,0)}
function yb(a,b){var c="/"===b;if(c&&hb)throw new N(10);if(!c&&b){var e=R(b,{kg:!1});b=e.path;e=e.node;if(e.Pf)throw new N(10);if(!P(e.mode))throw new N(54);}b={type:a,Pg:{},ng:b,zg:[]};a=a.Jf(b);a.Jf=b;b.root=a;c?hb=a:e&&(e.Pf=b,e.Jf&&e.Jf.zg.push(b))}function zb(a,b,c){var e=R(a,{parent:!0}).node;a=Oa(a);if(!a||"."===a||".."===a)throw new N(28);var f=ub(e,a);if(f)throw new N(f);if(!e.Af.Yf)throw new N(63);return e.Af.Yf(e,a,b,c)}function T(a,b){return zb(a,(void 0!==b?b:511)&1023|16384,0)}
function Ab(a,b,c){"undefined"==typeof c&&(c=b,b=438);zb(a,b|8192,c)}function Bb(a,b){if(!Ra(a))throw new N(44);var c=R(b,{parent:!0}).node;if(!c)throw new N(44);b=Oa(b);var e=ub(c,b);if(e)throw new N(e);if(!c.Af.bg)throw new N(63);c.Af.bg(c,b,a)}function Cb(a){var b=R(a,{parent:!0}).node;a=Oa(a);var c=eb(b,a),e=vb(b,a,!0);if(e)throw new N(e);if(!b.Af.ag)throw new N(63);if(c.Pf)throw new N(10);b.Af.ag(b,a);rb(c)}
function ob(a){a=R(a).node;if(!a)throw new N(44);if(!a.Af.Vf)throw new N(28);return Ra(pb(a.parent),a.Af.Vf(a))}function Db(a,b){a=R(a,{Nf:!b}).node;if(!a)throw new N(44);if(!a.Af.If)throw new N(63);return a.Af.If(a)}function Eb(a){return Db(a,!0)}function Fb(a,b){a="string"==typeof a?R(a,{Nf:!0}).node:a;if(!a.Af.Ff)throw new N(63);a.Af.Ff(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})}
function Gb(a,b){if(0>b)throw new N(28);a="string"==typeof a?R(a,{Nf:!0}).node:a;if(!a.Af.Ff)throw new N(63);if(P(a.mode))throw new N(31);if(32768!==(a.mode&61440))throw new N(28);var c=sb(a,"w");if(c)throw new N(c);a.Af.Ff(a,{size:b,timestamp:Date.now()})}
Expand All @@ -48,7 +48,7 @@ function Ob(a,b,c){a=a(b);z[c>>2]=a.vg;z[c+4>>2]=a.mode;B[c+8>>2]=a.Bg;z[c+12>>2
var Rb=(a,b)=>b+2097152>>>0<4194305-!!a?(a>>>0)+4294967296*b:NaN,Sb=[0,31,60,91,121,152,182,213,244,274,305,335],Tb=[0,31,59,90,120,151,181,212,243,273,304,334],Ub={},Wb=()=>{if(!Vb){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:da||"./this.program"},b;for(b in Ub)void 0===Ub[b]?delete a[b]:a[b]=Ub[b];var c=[];for(b in a)c.push(`${b}=${a[b]}`);Vb=c}return Vb},
Vb;function Xb(){}function Yb(){}function Zb(){}function $b(){}function ac(){}function bc(){}function cc(){}function dc(){}function ec(){}function fc(){}function gc(){}function hc(){}function ic(){}function jc(){}function kc(){}function lc(){}function mc(){}function nc(){}function oc(){}function pc(){}function qc(){}function rc(){}function sc(){}function tc(){}function uc(){}function vc(){}function wc(){}function xc(){}function yc(){}function zc(){}function Ac(){}function Bc(){}function Cc(){}
function Dc(){}function Ec(){}function Fc(){}function Gc(){}function Hc(){}function Ic(){}var Jc=0,Kc=a=>{na=a;Ja||0<Jc||(d.onExit?.(a),u=!0);ea(a,new Ha(a))},Lc=a=>{a instanceof Ha||"unwind"==a||ea(1,a)},Mc=a=>{try{a()}catch(b){C(b)}},Nc=a=>{if(!u)try{if(a(),!(Ja||0<Jc))try{na=a=na,Kc(a)}catch(b){Lc(b)}}catch(b){Lc(b)}};
function Oc(){var a=V,b={};for(let [c,e]of Object.entries(a))b[c]="function"==typeof e?(...f)=>{Pc.push(c);try{return e(...f)}finally{u||(Pc.pop(),W&&1===Y&&0===Pc.length&&(Y=0,Mc(Qc),"undefined"!=typeof Fibers&&Fibers.Rg()))}}:e;return b}var Y=0,W=null,Rc=0,Pc=[],Sc={},Tc={},Uc=0,Vc=null,Wc=[];function Xc(){return new Promise((a,b)=>{Vc={resolve:a,reject:b}})}
function Oc(){var a=V,b={};for(let [c,e]of Object.entries(a))b[c]="function"==typeof e?(...f)=>{Pc.push(c);try{return e(...f)}finally{u||(Pc.pop(),W&&1===Y&&0===Pc.length&&(Y=0,Mc(Qc),"undefined"!=typeof Fibers&&Fibers.Qg()))}}:e;return b}var Y=0,W=null,Rc=0,Pc=[],Sc={},Tc={},Uc=0,Vc=null,Wc=[];function Xc(){return new Promise((a,b)=>{Vc={resolve:a,reject:b}})}
function Yc(){var a=Zc(16396),b=a+12;B[a>>2]=b;B[a+4>>2]=b+16384;b=Pc[0];var c=Sc[b];void 0===c&&(c=Uc++,Sc[b]=c,Tc[c]=b);z[a+8>>2]=c;return a}
function $c(a){if(!u){if(0===Y){var b=!1,c=!1;a((e=0)=>{if(!u&&(Rc=e,b=!0,c)){Y=2;Mc(()=>ad(W));"undefined"!=typeof Browser&&Browser.eg.xg&&Browser.eg.resume();e=!1;try{var f=(0,V[Tc[z[W+8>>2]]])()}catch(n){f=n,e=!0}var h=!1;if(!W){var k=Vc;k&&(Vc=null,(e?k.reject:k.resolve)(f),h=!0)}if(e&&!h)throw f;}});c=!0;b||(Y=1,W=Yc(),"undefined"!=typeof Browser&&Browser.eg.xg&&Browser.eg.pause(),Mc(()=>bd(W)))}else 2===Y?(Y=0,Mc(cd),dd(W),W=null,Wc.forEach(Nc)):C(`invalid state: ${Y}`);return Rc}}
function ed(a){return $c(b=>{a().then(b)})}
Expand All @@ -68,10 +68,10 @@ t.estimatedCost,"double");I(m+p[10],t.estimatedRows,"i32");I(m+p[11],t.idxFlags,
1:0};lc=function(l,m,p,q,t){const y=f.get(l);p=p?p?J(w,p):"":null;t=new Uint32Array(w.buffer,t,q);return y.module.xFilter(l,m,p,t)};mc=function(l){return f.get(l).module.xNext(l)};ec=function(l,m,p){return f.get(l).module.xColumn(l,m,p)};qc=function(l,m){return f.get(l).module.xRowid(l,a("BigInt64",m))};tc=function(l,m,p,q){const t=e.get(l);p=new Uint32Array(w.buffer,p,m);return t.module.xUpdate(l,p,a("BigInt64",q))};bc=function(l){return e.get(l).module.xBegin(l)};sc=function(l){return e.get(l).module.xSync(l)};
fc=function(l){return e.get(l).module.xCommit(l)};pc=function(l){return e.get(l).module.xRollback(l)};oc=function(l,m){const p=e.get(l);m=m?J(w,m):"";return p.module.xRename(l,m)}})();
(function(){function a(h,k){const n=`get${h}`,l=`set${h}`;return new Proxy(new DataView(w.buffer,k,"Int32"===h?4:8),{get(m,p){if(p===n)return function(q,t){if(!t)throw Error("must be little endian");return m[p](q,t)};if(p===l)return function(q,t,y){if(!y)throw Error("must be little endian");return m[p](q,t,y)};if("string"===typeof p&&p.match(/^(get)|(set)/))throw Error("invalid type");return m[p]}})}const b="object"===typeof fd;b&&(d.handleAsync=ed);const c=new Map,e=new Map;d.registerVFS=function(h,
k){if(Z("sqlite3_vfs_find","number",["string"],[h.name]))throw Error(`VFS '${h.name}' already registered`);b&&(h.handleAsync=ed);var n=h.Pg??64;const l=d._malloc(4);k=Z("register_vfs","number",["string","number","number","number"],[h.name,n,k?1:0,l]);k||(n=H(l,"*"),c.set(n,h));d._free(l);return k};const f=b?new Set:null;wc=function(h){const k=e.get(h);b?f.add(h):e.delete(h);return k.xClose(h)};Dc=function(h,k,n,l,m){return e.get(h).xRead(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};Ic=function(h,
k,n,l,m){return e.get(h).xWrite(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};Gc=function(h,k,n){return e.get(h).xTruncate(h,4294967296*n+k+(0>k?2**32:0))};Fc=function(h,k){return e.get(h).xSync(h,k)};Ac=function(h,k){const n=e.get(h);k=a("BigInt64",k);return n.xFileSize(h,k)};Bc=function(h,k){return e.get(h).xLock(h,k)};Hc=function(h,k){return e.get(h).xUnlock(h,k)};vc=function(h,k){const n=e.get(h);k=a("Int32",k);return n.xCheckReservedLock(h,k)};zc=function(h,k,n){const l=e.get(h);n=new DataView(w.buffer,
n);return l.xFileControl(h,k,n)};Ec=function(h){return e.get(h).xSectorSize(h)};yc=function(h){return e.get(h).xDeviceCharacteristics(h)};Cc=function(h,k,n,l,m){h=c.get(h);e.set(n,h);if(b){f.delete(n);for(var p of f)e.delete(p)}p=null;if(l&64){p=1;const q=[];for(;p;){const t=w[k++];if(t)q.push(t);else switch(w[k]||(p=null),p){case 1:q.push(63);p=2;break;case 2:q.push(61);p=3;break;case 3:q.push(38),p=2}}p=(new TextDecoder).decode(new Uint8Array(q))}else k&&(p=k?J(w,k):"");m=a("Int32",m);return h.xOpen(p,
n,l,m)};xc=function(h,k,n){return c.get(h).xDelete(k?J(w,k):"",n)};uc=function(h,k,n,l){h=c.get(h);l=a("Int32",l);return h.xAccess(k?J(w,k):"",n,l)}})();
k){if(Z("sqlite3_vfs_find","number",["string"],[h.name]))throw Error(`VFS '${h.name}' already registered`);b&&(h.handleAsync=ed);var n=h.mxPathName??64;const l=d._malloc(4);k=Z("register_vfs","number",["string","number","number","number"],[h.name,n,k?1:0,l]);k||(n=H(l,"*"),c.set(n,h));d._free(l);return k};const f=b?new Set:null;wc=function(h){const k=e.get(h);b?f.add(h):e.delete(h);return k.xClose(h)};Dc=function(h,k,n,l,m){return e.get(h).xRead(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};
Ic=function(h,k,n,l,m){return e.get(h).xWrite(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};Gc=function(h,k,n){return e.get(h).xTruncate(h,4294967296*n+k+(0>k?2**32:0))};Fc=function(h,k){return e.get(h).xSync(h,k)};Ac=function(h,k){const n=e.get(h);k=a("BigInt64",k);return n.xFileSize(h,k)};Bc=function(h,k){return e.get(h).xLock(h,k)};Hc=function(h,k){return e.get(h).xUnlock(h,k)};vc=function(h,k){const n=e.get(h);k=a("Int32",k);return n.xCheckReservedLock(h,k)};zc=function(h,k,n){const l=e.get(h);
n=new DataView(w.buffer,n);return l.xFileControl(h,k,n)};Ec=function(h){return e.get(h).xSectorSize(h)};yc=function(h){return e.get(h).xDeviceCharacteristics(h)};Cc=function(h,k,n,l,m){h=c.get(h);e.set(n,h);if(b){f.delete(n);for(var p of f)e.delete(p)}p=null;if(l&64){p=1;const q=[];for(;p;){const t=w[k++];if(t)q.push(t);else switch(w[k]||(p=null),p){case 1:q.push(63);p=2;break;case 2:q.push(61);p=3;break;case 3:q.push(38),p=2}}p=(new TextDecoder).decode(new Uint8Array(q))}else k&&(p=k?J(w,k):"");
m=a("Int32",m);return h.xOpen(p,n,l,m)};xc=function(h,k,n){return c.get(h).xDelete(k?J(w,k):"",n)};uc=function(h,k,n,l){h=c.get(h);l=a("Int32",l);return h.xAccess(k?J(w,k):"",n,l)}})();
var od={a:(a,b,c,e)=>{C(`Assertion failed: ${a?J(w,a):""}, at: `+[b?b?J(w,b):"":"unknown filename",c,e?e?J(w,e):"":"unknown function"])},N:function(a,b){try{return a=a?J(w,a):"",Fb(a,b),0}catch(c){if("undefined"==typeof U||"ErrnoError"!==c.name)throw c;return-c.Df}},Q:function(a,b,c){try{b=b?J(w,b):"";b=Nb(a,b);if(c&-8)return-28;var e=R(b,{Nf:!0}).node;if(!e)return-44;a="";c&4&&(a+="r");c&2&&(a+="w");c&1&&(a+="x");return a&&sb(e,a)?-2:0}catch(f){if("undefined"==typeof U||"ErrnoError"!==f.name)throw f;
return-f.Df}},O:function(a,b){try{var c=S(a);Fb(c.node,b);return 0}catch(e){if("undefined"==typeof U||"ErrnoError"!==e.name)throw e;return-e.Df}},M:function(a){try{var b=S(a).node;var c="string"==typeof b?R(b,{Nf:!0}).node:b;if(!c.Af.Ff)throw new N(63);c.Af.Ff(c,{timestamp:Date.now()});return 0}catch(e){if("undefined"==typeof U||"ErrnoError"!==e.name)throw e;return-e.Df}},b:function(a,b,c){Pb=c;try{var e=S(a);switch(b){case 0:var f=Qb();if(0>f)break;for(;jb[f];)f++;return xb(e,f).Lf;case 1:case 2:return 0;
case 3:return e.flags;case 4:return f=Qb(),e.flags|=f,0;case 12:return f=Qb(),x[f+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(h){if("undefined"==typeof U||"ErrnoError"!==h.name)throw h;return-h.Df}},L:function(a,b){try{var c=S(a);return Ob(Db,c.path,b)}catch(e){if("undefined"==typeof U||"ErrnoError"!==e.name)throw e;return-e.Df}},n:function(a,b,c){b=Rb(b,c);try{if(isNaN(b))return 61;var e=S(a);if(0===(e.flags&2097155))throw new N(28);Gb(e.node,b);return 0}catch(f){if("undefined"==typeof U||
Expand Down
Loading

0 comments on commit 5307f6e

Please sign in to comment.