@wonderlandlabs/rxjs-sqlite
Version:
A reactive adapter for SQLite using RxJS, with RxDB adapter support
4 lines (3 loc) • 20.6 kB
JavaScript
(function(p,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("better-sqlite3"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","better-sqlite3","rxjs"],y):(p=typeof globalThis<"u"?globalThis:p||self,y(p.RxJSSQLite={},p.BetterSQLite3,p.rxjs))})(this,function(p,y,w){"use strict";var Ze=Object.defineProperty;var He=(p,y,w)=>y in p?Ze(p,y,{enumerable:!0,configurable:!0,writable:!0,value:w}):p[y]=w;var T=(p,y,w)=>He(p,typeof y!="symbol"?y+"":y,w);function v(t){return typeof t=="function"}function ue(t){return v(t==null?void 0:t.lift)}function z(t){return function(r){if(ue(r))return r.lift(function(e){try{return t(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}var W=function(t,r){return W=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},W(t,r)};function _(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");W(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function ce(t,r,e,n){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(f){try{u(n.next(f))}catch(d){s(d)}}function a(f){try{u(n.throw(f))}catch(d){s(d)}}function u(f){f.done?o(f.value):i(f.value).then(c,a)}u((n=n.apply(t,r||[])).next())})}function D(t,r){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=c(0),s.throw=c(1),s.return=c(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(u){return function(f){return a([u,f])}}function a(u){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(e=0)),e;)try{if(n=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,i=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=r.call(t,e)}catch(f){u=[6,f],i=0}finally{n=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function E(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),i,o=[],s;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o}function P(t,r,e){if(e||arguments.length===2)for(var n=0,i=r.length,o;n<i;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return t.concat(o||Array.prototype.slice.call(r))}function O(t){return this instanceof O?(this.v=t,this):new O(t)}function ae(t,r,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(t,r||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(l){return function(b){return Promise.resolve(b).then(l,d)}}function c(l,b){n[l]&&(i[l]=function(h){return new Promise(function(g,I){o.push([l,h,g,I])>1||a(l,h)})},b&&(i[l]=b(i[l])))}function a(l,b){try{u(n[l](b))}catch(h){m(o[0][3],h)}}function u(l){l.value instanceof O?Promise.resolve(l.value.v).then(f,d):m(o[0][2],l)}function f(l){a("next",l)}function d(l){a("throw",l)}function m(l,b){l(b),o.shift(),o.length&&a(o[0][0],o[0][1])}}function fe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],e;return r?r.call(t):(t=typeof E=="function"?E(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=t[o]&&function(s){return new Promise(function(c,a){s=t[o](s),i(c,a,s.done,s.value)})}}function i(o,s,c,a){Promise.resolve(a).then(function(u){o({value:u,done:c})},s)}}typeof SuppressedError=="function"&&SuppressedError;var le=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function he(t){return v(t==null?void 0:t.then)}function G(t){var r=function(n){Error.call(n),n.stack=new Error().stack},e=t(r);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var B=G(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
`+e.map(function(n,i){return i+1+") "+n.toString()}).join(`
`):"",this.name="UnsubscriptionError",this.errors=e}});function F(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var R=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,n,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=E(s),a=c.next();!a.done;a=c.next()){var u=a.value;u.remove(this)}}catch(h){r={error:h}}finally{try{a&&!a.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else s.remove(this);var f=this.initialTeardown;if(v(f))try{f()}catch(h){o=h instanceof B?h.errors:[h]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var m=E(d),l=m.next();!l.done;l=m.next()){var b=l.value;try{H(b)}catch(h){o=o??[],h instanceof B?o=P(P([],A(o)),A(h.errors)):o.push(h)}}}catch(h){n={error:h}}finally{try{l&&!l.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}}if(o)throw new B(o)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)H(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&F(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&F(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),V=R.EMPTY;function Z(t){return t instanceof R||t&&"closed"in t&&v(t.remove)&&v(t.add)&&v(t.unsubscribe)}function H(t){v(t)?t():t.unsubscribe()}var pe={Promise:void 0},de={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,P([t,r],A(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function J(t){de.setTimeout(function(){throw t})}function K(){}function C(t){t()}var M=function(t){_(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,Z(e)&&e.add(n)):n.destination=ye,n}return r.create=function(e,n,i){return new x(e,n,i)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(R),ve=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){U(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){U(n)}else U(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){U(e)}},t}(),x=function(t){_(r,t);function r(e,n,i){var o=t.call(this)||this,s;return v(e)||!e?s={next:e??void 0,error:n??void 0,complete:i??void 0}:s=e,o.destination=new ve(s),o}return r}(M);function U(t){J(t)}function be(t){throw t}var ye={closed:!0,next:K,error:be,complete:K},Y=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function me(t){return t}function Se(t){return t.length===0?me:t.length===1?t[0]:function(e){return t.reduce(function(n,i){return i(n)},e)}}var S=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var i=this,o=_e(r)?r:new x(r,e,n);return C(function(){var s=i,c=s.operator,a=s.source;o.add(c?c.call(o,a):a?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=X(e),new e(function(i,o){var s=new x({next:function(c){try{r(c)}catch(a){o(a),s.unsubscribe()}},error:o,complete:i});n.subscribe(s)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[Y]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Se(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=X(r),new r(function(n,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return n(o)})})},t.create=function(r){return new t(r)},t}();function X(t){var r;return(r=t??pe.Promise)!==null&&r!==void 0?r:Promise}function we(t){return t&&v(t.next)&&v(t.error)&&v(t.complete)}function _e(t){return t&&t instanceof M||we(t)&&Z(t)}function Ee(t){return v(t[Y])}function Oe(t){return Symbol.asyncIterator&&v(t==null?void 0:t[Symbol.asyncIterator])}function ge(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Te(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var xe=Te();function Ie(t){return v(t==null?void 0:t[xe])}function je(t){return ae(this,arguments,function(){var e,n,i,o;return D(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,O(e.read())];case 3:return n=s.sent(),i=n.value,o=n.done,o?[4,O(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,O(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Ae(t){return v(t==null?void 0:t.getReader)}function N(t){if(t instanceof S)return t;if(t!=null){if(Ee(t))return Pe(t);if(le(t))return Re(t);if(he(t))return Ce(t);if(Oe(t))return ee(t);if(Ie(t))return Ue(t);if(Ae(t))return ke(t)}throw ge(t)}function Pe(t){return new S(function(r){var e=t[Y]();if(v(e.subscribe))return e.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Re(t){return new S(function(r){for(var e=0;e<t.length&&!r.closed;e++)r.next(t[e]);r.complete()})}function Ce(t){return new S(function(r){t.then(function(e){r.closed||(r.next(e),r.complete())},function(e){return r.error(e)}).then(null,J)})}function Ue(t){return new S(function(r){var e,n;try{for(var i=E(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(r.next(s),r.closed)return}}catch(c){e={error:c}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}r.complete()})}function ee(t){return new S(function(r){Le(t,r).catch(function(e){return r.error(e)})})}function ke(t){return ee(je(t))}function Le(t,r){var e,n,i,o;return ce(this,void 0,void 0,function(){var s,c;return D(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),e=fe(t),a.label=1;case 1:return[4,e.next()];case 2:if(n=a.sent(),!!n.done)return[3,4];if(s=n.value,r.next(s),r.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=a.sent(),i={error:c},[3,11];case 6:return a.trys.push([6,,9,10]),n&&!n.done&&(o=e.return)?[4,o.call(e)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function $e(t,r,e,n,i){return new We(t,r,e,n,i)}var We=function(t){_(r,t);function r(e,n,i,o,s,c){var a=t.call(this,e)||this;return a.onFinalize=s,a.shouldUnsubscribe=c,a._next=n?function(u){try{n(u)}catch(f){e.error(f)}}:t.prototype._next,a._error=o?function(u){try{o(u)}catch(f){e.error(f)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=i?function(){try{i()}catch(u){e.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,a}return r.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},r}(M),te={now:function(){return(te.delegate||Date).now()},delegate:void 0};function re(t,r){return z(function(e,n){var i=0;e.subscribe($e(n,function(o){n.next(t.call(r,o,i++))}))})}var Be=G(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),q=function(t){_(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new ne(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Be},r.prototype.next=function(e){var n=this;C(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var s=E(n.currentObservers),c=s.next();!c.done;c=s.next()){var a=c.value;a.next(e)}}catch(u){i={error:u}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},r.prototype.error=function(e){var n=this;C(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var i=n.observers;i.length;)i.shift().error(e)}})},r.prototype.complete=function(){var e=this;C(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,i=this,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?V:(this.currentObservers=null,c.push(e),new R(function(){n.currentObservers=null,F(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,i=n.hasError,o=n.thrownError,s=n.isStopped;i?e.error(o):s&&e.complete()},r.prototype.asObservable=function(){var e=new S;return e.source=this,e},r.create=function(e,n){return new ne(e,n)},r}(S),ne=function(t){_(r,t);function r(e,n){var i=t.call(this)||this;return i.destination=e,i.source=n,i}return r.prototype.next=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,e)},r.prototype.error=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&i!==void 0?i:V},r}(q),Fe=function(t){_(r,t);function r(e,n,i){e===void 0&&(e=1/0),n===void 0&&(n=1/0),i===void 0&&(i=te);var o=t.call(this)||this;return o._bufferSize=e,o._windowTime=n,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,e),o._windowTime=Math.max(1,n),o}return r.prototype.next=function(e){var n=this,i=n.isStopped,o=n._buffer,s=n._infiniteTimeWindow,c=n._timestampProvider,a=n._windowTime;i||(o.push(e),!s&&o.push(c.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},r.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(e),i=this,o=i._infiniteTimeWindow,s=i._buffer,c=s.slice(),a=0;a<c.length&&!e.closed;a+=o?1:2)e.next(c[a]);return this._checkFinalizedStatuses(e),n},r.prototype._trimBuffer=function(){var e=this,n=e._bufferSize,i=e._timestampProvider,o=e._buffer,s=e._infiniteTimeWindow,c=(s?1:2)*n;if(n<1/0&&c<o.length&&o.splice(0,o.length-c),!s){for(var a=i.now(),u=0,f=1;f<o.length&&o[f]<=a;f+=2)u=f;u&&o.splice(0,u+1)}},r}(q);function Me(t){t===void 0&&(t={});var r=t.connector,e=r===void 0?function(){return new q}:r,n=t.resetOnError,i=n===void 0?!0:n,o=t.resetOnComplete,s=o===void 0?!0:o,c=t.resetOnRefCountZero,a=c===void 0?!0:c;return function(u){var f,d,m,l=0,b=!1,h=!1,g=function(){d==null||d.unsubscribe(),d=void 0},I=function(){g(),f=m=void 0,b=h=!1},Ve=function(){var j=f;I(),j==null||j.unsubscribe()};return z(function(j,se){l++,!h&&!b&&g();var L=m=m??e();se.add(function(){l--,l===0&&!h&&!b&&(d=Q(Ve,a))}),L.subscribe(se),!f&&l>0&&(f=new x({next:function($){return L.next($)},error:function($){h=!0,g(),d=Q(I,i,$),L.error($)},complete:function(){b=!0,g(),d=Q(I,s),L.complete()}}),N(j).subscribe(f))})(u)}}function Q(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];if(r===!0){t();return}if(r!==!1){var i=new x({next:function(){i.unsubscribe(),t()}});return N(r.apply(void 0,P([],A(e)))).subscribe(i)}}function oe(t,r,e){var n,i=!1;return n=t,Me({connector:function(){return new Fe(n,r,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function ie(t){const r={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function k(t){return t.map(r=>ie(r))}function Ye(t,r,e){const n=Object.entries(r).map(([i,o])=>i===e?`${i} ${o} PRIMARY KEY`:`${i} ${o}`).join(", ");return`CREATE TABLE IF NOT EXISTS ${t} (${n})`}function qe(t,r){const e=r.map(()=>"?").join(", ");return`INSERT INTO ${t} (${r.join(", ")}) VALUES (${e})`}function Qe(t,r,e){const n=r.map(o=>`${o} = ?`).join(", "),i=e.map(o=>`${o} = ?`).join(" AND ");return`UPDATE ${t} SET ${n} WHERE ${i}`}class ze{constructor(r){T(this,"transaction");T(this,"statements",[]);this.db=r,this.transaction=r.transaction(e=>{for(const n of e)this.db.prepare(n.sql).run(n.params)})}execute(r,e=[]){this.statements.push({sql:r,params:e})}query(r,e=[]){const i=this.db.prepare(r).all(e);return k(i)}commit(){this.transaction(this.statements),this.statements=[]}rollback(){this.statements=[]}}class De{constructor(r,e){T(this,"db");T(this,"changeSubject",new w.Subject);T(this,"change$",this.changeSubject.asObservable().pipe(oe(1)));this.db=new y(r,e),this.db.function("notify_change",()=>(this.changeSubject.next(),!0))}execute(r,e={}){this.db.prepare(r).run(e.params||[]),(r.trim().toUpperCase().startsWith("INSERT")||r.trim().toUpperCase().startsWith("UPDATE")||r.trim().toUpperCase().startsWith("DELETE"))&&this.changeSubject.next()}query(r,e={}){const i=this.db.prepare(r).all(e.params||[]);return w.of(k(i))}queryOne(r,e={}){return this.query(r,e).pipe(re(n=>n[0]))}transaction(){return new ze(this.db)}reactiveQuery(r,e={}){return this.change$.pipe(re(()=>{const i=this.db.prepare(r).all(e.params||[]);return k(i)}),oe(1))}close(){this.db.close()}}function Ge(t,r){return r&&console.log("adapter options",r),new De(t,r)}p.createInsertStatement=qe,p.createSQLiteAdapter=Ge,p.createTableSchema=Ye,p.createUpdateStatement=Qe,p.rowToObject=ie,p.rowsToObjects=k,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});