snow-cms 1.4.4 → 1.5.1

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.
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-cms",
3
- "version": "1.4.4",
3
+ "version": "1.5.1",
4
4
  "description": "A configurable CMS built with Svelte.",
5
5
  "keywords": [],
6
6
  "author": "Sammy-T",
@@ -22,7 +22,7 @@
22
22
  "@milkdown/kit": "^7.18.0",
23
23
  "@milkdown/theme-nord": "^7.18.0",
24
24
  "@octokit/core": "^7.0.6",
25
- "@sveltejs/vite-plugin-svelte": "^6.2.4",
25
+ "@sveltejs/vite-plugin-svelte": "^7.0.0",
26
26
  "browser-fs-access": "^0.38.0",
27
27
  "dayjs": "^1.11.19",
28
28
  "dotenv": "^17.2.3",
@@ -33,7 +33,7 @@
33
33
  "pouchdb-core": "^9.0.0",
34
34
  "pouchdb-find": "^9.0.0",
35
35
  "svelte": "^5.49.1",
36
- "vite": "^7.3.1"
36
+ "vite": "^8.0.3"
37
37
  },
38
38
  "scripts": {
39
39
  "dev": "run-p build:watch:cms serve:site",
@@ -1 +0,0 @@
1
- import{g as G}from"./milkdown.js";class _ extends Error{constructor(o,u,l){super(),this.status=o,this.name=u,this.message=l,this.error=!0}toString(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})}}new _(401,"unauthorized","Name or password is incorrect.");var Ve=new _(400,"bad_request","Missing JSON list of 'docs'"),ze=new _(404,"not_found","missing"),Ke=new _(409,"conflict","Document update conflict"),Y=new _(400,"bad_request","_id field must contain a string"),Z=new _(412,"missing_id","_id is required for puts"),k=new _(400,"bad_request","Only reserved document ids may start with underscore.");new _(412,"precondition_failed","Database not open");var ee=new _(500,"unknown_error","Database encountered an unknown error"),Ge=new _(500,"badarg","Some query argument is invalid");new _(400,"invalid_request","Request was invalid");var We=new _(400,"query_parse_error","Some query parameter is invalid"),Je=new _(500,"doc_validation","Bad special document member"),te=new _(400,"bad_request","Something wrong with the request"),$e=new _(400,"bad_request","Document must be a JSON object");new _(404,"not_found","Database not found");var He=new _(500,"indexed_db_went_bad","unknown");new _(500,"web_sql_went_bad","unknown");new _(500,"levelDB_went_went_bad","unknown");new _(403,"forbidden","Forbidden by design doc validate_doc_update function");var Qe=new _(400,"bad_request","Invalid rev format");new _(412,"file_exists","The database could not be created, the file already exists.");var Xe=new _(412,"missing_stub","A pre-existing attachment stub wasn't found");new _(413,"invalid_url","Provided URL is invalid");function N(i,o){function u(l){for(var f=Object.getOwnPropertyNames(i),c=0,g=f.length;c<g;c++)typeof i[f[c]]!="function"&&(this[f[c]]=i[f[c]]);this.stack===void 0&&(this.stack=new Error().stack),l!==void 0&&(this.reason=l)}return u.prototype=_.prototype,new u(o)}function Ye(i){if(typeof i!="object"){var o=i;i=ee,i.data=o}return"error"in i&&i.error==="conflict"&&(i.name="conflict",i.status=409),"name"in i||(i.name=i.error||"unknown"),"status"in i||(i.status=500),"message"in i||(i.message=i.message||i.reason),"stack"in i||(i.stack=new Error().stack),i}var I={exports:{}},j;function ne(){if(j)return I.exports;j=1;var i=typeof Reflect=="object"?Reflect:null,o=i&&typeof i.apply=="function"?i.apply:function(t,n,h){return Function.prototype.apply.call(t,n,h)},u;i&&typeof i.ownKeys=="function"?u=i.ownKeys:Object.getOwnPropertySymbols?u=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:u=function(t){return Object.getOwnPropertyNames(t)};function l(e){console&&console.warn&&console.warn(e)}var f=Number.isNaN||function(t){return t!==t};function c(){c.init.call(this)}I.exports=c,I.exports.once=a,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var g=10;function m(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return g},set:function(e){if(typeof e!="number"||e<0||f(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");g=e}}),c.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||f(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function b(e){return e._maxListeners===void 0?c.defaultMaxListeners:e._maxListeners}c.prototype.getMaxListeners=function(){return b(this)},c.prototype.emit=function(t){for(var n=[],h=1;h<arguments.length;h++)n.push(arguments[h]);var d=t==="error",v=this._events;if(v!==void 0)d=d&&v.error===void 0;else if(!d)return!1;if(d){var y;if(n.length>0&&(y=n[0]),y instanceof Error)throw y;var O=new Error("Unhandled error."+(y?" ("+y.message+")":""));throw O.context=y,O}var x=v[t];if(x===void 0)return!1;if(typeof x=="function")o(x,this,n);else for(var P=x.length,X=R(x,P),h=0;h<P;++h)o(X[h],this,n);return!0};function S(e,t,n,h){var d,v,y;if(m(n),v=e._events,v===void 0?(v=e._events=Object.create(null),e._eventsCount=0):(v.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),v=e._events),y=v[t]),y===void 0)y=v[t]=n,++e._eventsCount;else if(typeof y=="function"?y=v[t]=h?[n,y]:[y,n]:h?y.unshift(n):y.push(n),d=b(e),d>0&&y.length>d&&!y.warned){y.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+y.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=e,O.type=t,O.count=y.length,l(O)}return e}c.prototype.addListener=function(t,n){return S(this,t,n,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(t,n){return S(this,t,n,!0)};function A(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(e,t,n){var h={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},d=A.bind(h);return d.listener=n,h.wrapFn=d,d}c.prototype.once=function(t,n){return m(n),this.on(t,E(this,t,n)),this},c.prototype.prependOnceListener=function(t,n){return m(n),this.prependListener(t,E(this,t,n)),this},c.prototype.removeListener=function(t,n){var h,d,v,y,O;if(m(n),d=this._events,d===void 0)return this;if(h=d[t],h===void 0)return this;if(h===n||h.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete d[t],d.removeListener&&this.emit("removeListener",t,h.listener||n));else if(typeof h!="function"){for(v=-1,y=h.length-1;y>=0;y--)if(h[y]===n||h[y].listener===n){O=h[y].listener,v=y;break}if(v<0)return this;v===0?h.shift():w(h,v),h.length===1&&(d[t]=h[0]),d.removeListener!==void 0&&this.emit("removeListener",t,O||n)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(t){var n,h,d;if(h=this._events,h===void 0)return this;if(h.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):h[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete h[t]),this;if(arguments.length===0){var v=Object.keys(h),y;for(d=0;d<v.length;++d)y=v[d],y!=="removeListener"&&this.removeAllListeners(y);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=h[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(d=n.length-1;d>=0;d--)this.removeListener(t,n[d]);return this};function L(e,t,n){var h=e._events;if(h===void 0)return[];var d=h[t];return d===void 0?[]:typeof d=="function"?n?[d.listener||d]:[d]:n?p(d):R(d,d.length)}c.prototype.listeners=function(t){return L(this,t,!0)},c.prototype.rawListeners=function(t){return L(this,t,!1)},c.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):C.call(e,t)},c.prototype.listenerCount=C;function C(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?u(this._events):[]};function R(e,t){for(var n=new Array(t),h=0;h<t;++h)n[h]=e[h];return n}function w(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function p(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function a(e,t){return new Promise(function(n,h){function d(y){e.removeListener(t,v),h(y)}function v(){typeof e.removeListener=="function"&&e.removeListener("error",d),n([].slice.call(arguments))}r(e,t,v,{once:!0}),t!=="error"&&s(e,d,{once:!0})})}function s(e,t,n){typeof e.on=="function"&&r(e,"error",t,n)}function r(e,t,n,h){if(typeof e.on=="function")h.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function d(v){h.once&&e.removeEventListener(t,d),n(v)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}return I.exports}var re=ne();const W=G(re);var M,ie=new Uint8Array(16);function oe(){if(!M&&(M=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!M))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return M(ie)}const se=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ae(i){return typeof i=="string"&&se.test(i)}var B=[];for(var D=0;D<256;++D)B.push((D+256).toString(16).substr(1));function ue(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,u=(B[i[o+0]]+B[i[o+1]]+B[i[o+2]]+B[i[o+3]]+"-"+B[i[o+4]]+B[i[o+5]]+"-"+B[i[o+6]]+B[i[o+7]]+"-"+B[i[o+8]]+B[i[o+9]]+"-"+B[i[o+10]]+B[i[o+11]]+B[i[o+12]]+B[i[o+13]]+B[i[o+14]]+B[i[o+15]]).toLowerCase();if(!ae(u))throw TypeError("Stringified UUID is invalid");return u}function J(i,o,u){i=i||{};var l=i.random||(i.rng||oe)();if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,o){u=u||0;for(var f=0;f<16;++f)o[u+f]=l[f];return o}return ue(l)}var fe=function(i){return atob(i)},$=function(i){return btoa(i)};function ce(i,o){i=i||[],o=o||{};try{return new Blob(i,o)}catch(c){if(c.name!=="TypeError")throw c;for(var u=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,l=new u,f=0;f<i.length;f+=1)l.append(i[f]);return l.getBlob(o.type)}}function le(i){for(var o=i.length,u=new ArrayBuffer(o),l=new Uint8Array(u),f=0;f<o;f++)l[f]=i.charCodeAt(f);return u}function he(i,o){return ce([le(i)],{type:o})}function Ze(i,o){return he(fe(i),o)}function de(i){for(var o="",u=new Uint8Array(i),l=u.byteLength,f=0;f<l;f++)o+=String.fromCharCode(u[f]);return o}function pe(i,o){var u=new FileReader,l=typeof u.readAsBinaryString=="function";u.onloadend=function(f){var c=f.target.result||"";if(l)return o(c);o(de(c))},l?u.readAsBinaryString(i):u.readAsArrayBuffer(i)}function ve(i,o){pe(i,function(u){o(u)})}function ke(i,o){ve(i,function(u){o($(u))})}function ye(i,o){var u=new FileReader;u.onloadend=function(l){var f=l.target.result||new ArrayBuffer(0);o(f)},u.readAsArrayBuffer(i)}var T={exports:{}},V;function ge(){return V||(V=1,(function(i,o){(function(u){i.exports=u()})(function(u){var l=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function f(a,s){var r=a[0],e=a[1],t=a[2],n=a[3];r+=(e&t|~e&n)+s[0]-680876936|0,r=(r<<7|r>>>25)+e|0,n+=(r&e|~r&t)+s[1]-389564586|0,n=(n<<12|n>>>20)+r|0,t+=(n&r|~n&e)+s[2]+606105819|0,t=(t<<17|t>>>15)+n|0,e+=(t&n|~t&r)+s[3]-1044525330|0,e=(e<<22|e>>>10)+t|0,r+=(e&t|~e&n)+s[4]-176418897|0,r=(r<<7|r>>>25)+e|0,n+=(r&e|~r&t)+s[5]+1200080426|0,n=(n<<12|n>>>20)+r|0,t+=(n&r|~n&e)+s[6]-1473231341|0,t=(t<<17|t>>>15)+n|0,e+=(t&n|~t&r)+s[7]-45705983|0,e=(e<<22|e>>>10)+t|0,r+=(e&t|~e&n)+s[8]+1770035416|0,r=(r<<7|r>>>25)+e|0,n+=(r&e|~r&t)+s[9]-1958414417|0,n=(n<<12|n>>>20)+r|0,t+=(n&r|~n&e)+s[10]-42063|0,t=(t<<17|t>>>15)+n|0,e+=(t&n|~t&r)+s[11]-1990404162|0,e=(e<<22|e>>>10)+t|0,r+=(e&t|~e&n)+s[12]+1804603682|0,r=(r<<7|r>>>25)+e|0,n+=(r&e|~r&t)+s[13]-40341101|0,n=(n<<12|n>>>20)+r|0,t+=(n&r|~n&e)+s[14]-1502002290|0,t=(t<<17|t>>>15)+n|0,e+=(t&n|~t&r)+s[15]+1236535329|0,e=(e<<22|e>>>10)+t|0,r+=(e&n|t&~n)+s[1]-165796510|0,r=(r<<5|r>>>27)+e|0,n+=(r&t|e&~t)+s[6]-1069501632|0,n=(n<<9|n>>>23)+r|0,t+=(n&e|r&~e)+s[11]+643717713|0,t=(t<<14|t>>>18)+n|0,e+=(t&r|n&~r)+s[0]-373897302|0,e=(e<<20|e>>>12)+t|0,r+=(e&n|t&~n)+s[5]-701558691|0,r=(r<<5|r>>>27)+e|0,n+=(r&t|e&~t)+s[10]+38016083|0,n=(n<<9|n>>>23)+r|0,t+=(n&e|r&~e)+s[15]-660478335|0,t=(t<<14|t>>>18)+n|0,e+=(t&r|n&~r)+s[4]-405537848|0,e=(e<<20|e>>>12)+t|0,r+=(e&n|t&~n)+s[9]+568446438|0,r=(r<<5|r>>>27)+e|0,n+=(r&t|e&~t)+s[14]-1019803690|0,n=(n<<9|n>>>23)+r|0,t+=(n&e|r&~e)+s[3]-187363961|0,t=(t<<14|t>>>18)+n|0,e+=(t&r|n&~r)+s[8]+1163531501|0,e=(e<<20|e>>>12)+t|0,r+=(e&n|t&~n)+s[13]-1444681467|0,r=(r<<5|r>>>27)+e|0,n+=(r&t|e&~t)+s[2]-51403784|0,n=(n<<9|n>>>23)+r|0,t+=(n&e|r&~e)+s[7]+1735328473|0,t=(t<<14|t>>>18)+n|0,e+=(t&r|n&~r)+s[12]-1926607734|0,e=(e<<20|e>>>12)+t|0,r+=(e^t^n)+s[5]-378558|0,r=(r<<4|r>>>28)+e|0,n+=(r^e^t)+s[8]-2022574463|0,n=(n<<11|n>>>21)+r|0,t+=(n^r^e)+s[11]+1839030562|0,t=(t<<16|t>>>16)+n|0,e+=(t^n^r)+s[14]-35309556|0,e=(e<<23|e>>>9)+t|0,r+=(e^t^n)+s[1]-1530992060|0,r=(r<<4|r>>>28)+e|0,n+=(r^e^t)+s[4]+1272893353|0,n=(n<<11|n>>>21)+r|0,t+=(n^r^e)+s[7]-155497632|0,t=(t<<16|t>>>16)+n|0,e+=(t^n^r)+s[10]-1094730640|0,e=(e<<23|e>>>9)+t|0,r+=(e^t^n)+s[13]+681279174|0,r=(r<<4|r>>>28)+e|0,n+=(r^e^t)+s[0]-358537222|0,n=(n<<11|n>>>21)+r|0,t+=(n^r^e)+s[3]-722521979|0,t=(t<<16|t>>>16)+n|0,e+=(t^n^r)+s[6]+76029189|0,e=(e<<23|e>>>9)+t|0,r+=(e^t^n)+s[9]-640364487|0,r=(r<<4|r>>>28)+e|0,n+=(r^e^t)+s[12]-421815835|0,n=(n<<11|n>>>21)+r|0,t+=(n^r^e)+s[15]+530742520|0,t=(t<<16|t>>>16)+n|0,e+=(t^n^r)+s[2]-995338651|0,e=(e<<23|e>>>9)+t|0,r+=(t^(e|~n))+s[0]-198630844|0,r=(r<<6|r>>>26)+e|0,n+=(e^(r|~t))+s[7]+1126891415|0,n=(n<<10|n>>>22)+r|0,t+=(r^(n|~e))+s[14]-1416354905|0,t=(t<<15|t>>>17)+n|0,e+=(n^(t|~r))+s[5]-57434055|0,e=(e<<21|e>>>11)+t|0,r+=(t^(e|~n))+s[12]+1700485571|0,r=(r<<6|r>>>26)+e|0,n+=(e^(r|~t))+s[3]-1894986606|0,n=(n<<10|n>>>22)+r|0,t+=(r^(n|~e))+s[10]-1051523|0,t=(t<<15|t>>>17)+n|0,e+=(n^(t|~r))+s[1]-2054922799|0,e=(e<<21|e>>>11)+t|0,r+=(t^(e|~n))+s[8]+1873313359|0,r=(r<<6|r>>>26)+e|0,n+=(e^(r|~t))+s[15]-30611744|0,n=(n<<10|n>>>22)+r|0,t+=(r^(n|~e))+s[6]-1560198380|0,t=(t<<15|t>>>17)+n|0,e+=(n^(t|~r))+s[13]+1309151649|0,e=(e<<21|e>>>11)+t|0,r+=(t^(e|~n))+s[4]-145523070|0,r=(r<<6|r>>>26)+e|0,n+=(e^(r|~t))+s[11]-1120210379|0,n=(n<<10|n>>>22)+r|0,t+=(r^(n|~e))+s[2]+718787259|0,t=(t<<15|t>>>17)+n|0,e+=(n^(t|~r))+s[9]-343485551|0,e=(e<<21|e>>>11)+t|0,a[0]=r+a[0]|0,a[1]=e+a[1]|0,a[2]=t+a[2]|0,a[3]=n+a[3]|0}function c(a){var s=[],r;for(r=0;r<64;r+=4)s[r>>2]=a.charCodeAt(r)+(a.charCodeAt(r+1)<<8)+(a.charCodeAt(r+2)<<16)+(a.charCodeAt(r+3)<<24);return s}function g(a){var s=[],r;for(r=0;r<64;r+=4)s[r>>2]=a[r]+(a[r+1]<<8)+(a[r+2]<<16)+(a[r+3]<<24);return s}function m(a){var s=a.length,r=[1732584193,-271733879,-1732584194,271733878],e,t,n,h,d,v;for(e=64;e<=s;e+=64)f(r,c(a.substring(e-64,e)));for(a=a.substring(e-64),t=a.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<t;e+=1)n[e>>2]|=a.charCodeAt(e)<<(e%4<<3);if(n[e>>2]|=128<<(e%4<<3),e>55)for(f(r,n),e=0;e<16;e+=1)n[e]=0;return h=s*8,h=h.toString(16).match(/(.*?)(.{0,8})$/),d=parseInt(h[2],16),v=parseInt(h[1],16)||0,n[14]=d,n[15]=v,f(r,n),r}function b(a){var s=a.length,r=[1732584193,-271733879,-1732584194,271733878],e,t,n,h,d,v;for(e=64;e<=s;e+=64)f(r,g(a.subarray(e-64,e)));for(a=e-64<s?a.subarray(e-64):new Uint8Array(0),t=a.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<t;e+=1)n[e>>2]|=a[e]<<(e%4<<3);if(n[e>>2]|=128<<(e%4<<3),e>55)for(f(r,n),e=0;e<16;e+=1)n[e]=0;return h=s*8,h=h.toString(16).match(/(.*?)(.{0,8})$/),d=parseInt(h[2],16),v=parseInt(h[1],16)||0,n[14]=d,n[15]=v,f(r,n),r}function S(a){var s="",r;for(r=0;r<4;r+=1)s+=l[a>>r*8+4&15]+l[a>>r*8&15];return s}function A(a){var s;for(s=0;s<a.length;s+=1)a[s]=S(a[s]);return a.join("")}A(m("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function a(s,r){return s=s|0||0,s<0?Math.max(s+r,0):Math.min(s,r)}ArrayBuffer.prototype.slice=function(s,r){var e=this.byteLength,t=a(s,e),n=e,h,d,v,y;return r!==u&&(n=a(r,e)),t>n?new ArrayBuffer(0):(h=n-t,d=new ArrayBuffer(h),v=new Uint8Array(d),y=new Uint8Array(this,t,h),v.set(y),d)}})();function E(a){return/[\u0080-\uFFFF]/.test(a)&&(a=unescape(encodeURIComponent(a))),a}function L(a,s){var r=a.length,e=new ArrayBuffer(r),t=new Uint8Array(e),n;for(n=0;n<r;n+=1)t[n]=a.charCodeAt(n);return s?t:e}function C(a){return String.fromCharCode.apply(null,new Uint8Array(a))}function R(a,s,r){var e=new Uint8Array(a.byteLength+s.byteLength);return e.set(new Uint8Array(a)),e.set(new Uint8Array(s),a.byteLength),e}function w(a){var s=[],r=a.length,e;for(e=0;e<r-1;e+=2)s.push(parseInt(a.substr(e,2),16));return String.fromCharCode.apply(String,s)}function p(){this.reset()}return p.prototype.append=function(a){return this.appendBinary(E(a)),this},p.prototype.appendBinary=function(a){this._buff+=a,this._length+=a.length;var s=this._buff.length,r;for(r=64;r<=s;r+=64)f(this._hash,c(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},p.prototype.end=function(a){var s=this._buff,r=s.length,e,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n;for(e=0;e<r;e+=1)t[e>>2]|=s.charCodeAt(e)<<(e%4<<3);return this._finish(t,r),n=A(this._hash),a&&(n=w(n)),this.reset(),n},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(a){return this._buff=a.buff,this._length=a.length,this._hash=a.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(a,s){var r=s,e,t,n;if(a[r>>2]|=128<<(r%4<<3),r>55)for(f(this._hash,a),r=0;r<16;r+=1)a[r]=0;e=this._length*8,e=e.toString(16).match(/(.*?)(.{0,8})$/),t=parseInt(e[2],16),n=parseInt(e[1],16)||0,a[14]=t,a[15]=n,f(this._hash,a)},p.hash=function(a,s){return p.hashBinary(E(a),s)},p.hashBinary=function(a,s){var r=m(a),e=A(r);return s?w(e):e},p.ArrayBuffer=function(){this.reset()},p.ArrayBuffer.prototype.append=function(a){var s=R(this._buff.buffer,a),r=s.length,e;for(this._length+=a.byteLength,e=64;e<=r;e+=64)f(this._hash,g(s.subarray(e-64,e)));return this._buff=e-64<r?new Uint8Array(s.buffer.slice(e-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(a){var s=this._buff,r=s.length,e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t,n;for(t=0;t<r;t+=1)e[t>>2]|=s[t]<<(t%4<<3);return this._finish(e,r),n=A(this._hash),a&&(n=w(n)),this.reset(),n},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var a=p.prototype.getState.call(this);return a.buff=C(a.buff),a},p.ArrayBuffer.prototype.setState=function(a){return a.buff=L(a.buff,!0),p.prototype.setState.call(this,a)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(a,s){var r=b(new Uint8Array(a)),e=A(r);return s?w(e):e},p})})(T)),T.exports}var me=ge();const U=G(me);var _e=self.setImmediate||self.setTimeout,we=32768;function be(i){return $(i)}function Ae(i,o,u,l,f){(u>0||l<o.size)&&(o=o.slice(u,l)),ye(o,function(c){i.append(c),f()})}function Be(i,o,u,l,f){(u>0||l<o.length)&&(o=o.substring(u,l)),i.appendBinary(o),f()}function et(i,o){var u=typeof i=="string",l=u?i.length:i.size,f=Math.min(we,l),c=Math.ceil(l/f),g=0,m=u?new U:new U.ArrayBuffer,b=u?Be:Ae;function S(){_e(E)}function A(){var L=m.end(!0),C=be(L);o(C),m.destroy()}function E(){var L=g*f,C=L+f;g++,g<c?b(m,i,L,C,S):b(m,i,L,C,A)}E()}function Le(i){return U.hash(i)}function Se(i){return typeof ArrayBuffer<"u"&&i instanceof ArrayBuffer||typeof Blob<"u"&&i instanceof Blob}function Ee(i){return i instanceof ArrayBuffer?i.slice(0):i.slice(0,i.size,i.type)}var H=Function.prototype.toString,Ce=H.call(Object);function Oe(i){var o=Object.getPrototypeOf(i);if(o===null)return!0;var u=o.constructor;return typeof u=="function"&&u instanceof u&&H.call(u)==Ce}function F(i){var o,u,l;if(!i||typeof i!="object")return i;if(Array.isArray(i)){for(o=[],u=0,l=i.length;u<l;u++)o[u]=F(i[u]);return o}if(i instanceof Date&&isFinite(i))return i.toISOString();if(Se(i))return Ee(i);if(!Oe(i))return i;o={};for(u in i)if(Object.prototype.hasOwnProperty.call(i,u)){var f=F(i[u]);typeof f<"u"&&(o[u]=f)}return o}function Re(i){var o=!1;return function(...u){if(o)throw new Error("once called more than once");o=!0,i.apply(this,u)}}function xe(i){return function(...o){o=F(o);var u=this,l=typeof o[o.length-1]=="function"?o.pop():!1,f=new Promise(function(c,g){var m;try{var b=Re(function(S,A){S?g(S):c(A)});o.push(b),m=i.apply(u,o),m&&typeof m.then=="function"&&c(m)}catch(S){g(S)}});return l&&f.then(function(c){l(null,c)},l),f}}function Ie(i,o,u){if(i.constructor.listeners("debug").length){for(var l=["api",i.name,o],f=0;f<u.length-1;f++)l.push(u[f]);i.constructor.emit("debug",l);var c=u[u.length-1];u[u.length-1]=function(g,m){var b=["api",i.name,o];b=b.concat(g?["error",g]:["success",m]),i.constructor.emit("debug",b),c(g,m)}}}function tt(i,o){return xe(function(...u){if(this._closed)return Promise.reject(new Error("database is closed"));if(this._destroyed)return Promise.reject(new Error("database is destroyed"));var l=this;return Ie(l,i,u),this.taskqueue.isReady?o.apply(this,u):new Promise(function(f,c){l.taskqueue.addTask(function(g){g?c(g):f(l[i].apply(l,u))})})})}function Q(i,o){for(var u={},l=0,f=o.length;l<f;l++){var c=o[l];c in i&&(u[c]=i[c])}return u}var Me=6;function z(i){return i}function Ne(i){return[{ok:i}]}function nt(i,o,u){var l=o.docs,f=new Map;l.forEach(function(w){f.has(w.id)?f.get(w.id).push(w):f.set(w.id,[w])});var c=f.size,g=0,m=new Array(c);function b(){var w=[];m.forEach(function(p){p.docs.forEach(function(a){w.push({id:p.id,docs:[a]})})}),u(null,{results:w})}function S(){++g===c&&b()}function A(w,p,a){m[w]={id:p,docs:a},S()}var E=[];f.forEach(function(w,p){E.push(p)});var L=0;function C(){if(!(L>=E.length)){var w=Math.min(L+Me,E.length),p=E.slice(L,w);R(p,L),L+=p.length}}function R(w,p){w.forEach(function(a,s){var r=p+s,e=f.get(a),t=Q(e[0],["atts_since","attachments"]);t.open_revs=e.map(function(h){return h.rev}),t.open_revs=t.open_revs.filter(z);var n=z;t.open_revs.length===0&&(delete t.open_revs,n=Ne),["revs","attachments","binary","ajax","latest"].forEach(function(h){h in o&&(t[h]=o[h])}),i.get(a,t,function(h,d){var v;h?v=[{error:h}]:v=n(d),A(r,a,v),C()})})}C()}var q;try{localStorage.setItem("_pouch_check_localstorage",1),q=!!localStorage.getItem("_pouch_check_localstorage")}catch{q=!1}function K(){return q}const De=typeof queueMicrotask=="function"?queueMicrotask:function(o){Promise.resolve().then(o)};class rt extends W{constructor(){super(),this._listeners={},K()&&addEventListener("storage",o=>{this.emit(o.key)})}addListener(o,u,l,f){if(this._listeners[u])return;var c=!1,g=this;function m(){if(!g._listeners[u])return;if(c){c="waiting";return}c=!0;var b=Q(f,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);function S(){c=!1}l.changes(b).on("change",function(A){A.seq>f.since&&!f.cancelled&&(f.since=A.seq,f.onChange(A))}).on("complete",function(){c==="waiting"&&De(m),c=!1}).on("error",S)}this._listeners[u]=m,this.on(o,m)}removeListener(o,u){u in this._listeners&&(super.removeListener(o,this._listeners[u]),delete this._listeners[u])}notifyLocalWindows(o){K()&&(localStorage[o]=localStorage[o]==="a"?"b":"a")}notify(o){this.emit(o),this.notifyLocalWindows(o)}}function Te(i){if(typeof console<"u"&&typeof console[i]=="function"){var o=Array.prototype.slice.call(arguments,1);console[i].apply(console,o)}}function Ue(i,o,u){try{return!i(o,u)}catch(f){var l="Filter function threw: "+f.toString();return N(te,l)}}function it(i){var o={},u=i.filter&&typeof i.filter=="function";return o.query=i.query_params,function(f){f.doc||(f.doc={});var c=u&&Ue(i.filter,f.doc,o);if(typeof c=="object")return c;if(c)return!1;if(!i.include_docs)delete f.doc;else if(!i.attachments)for(var g in f.doc._attachments)Object.prototype.hasOwnProperty.call(f.doc._attachments,g)&&(f.doc._attachments[g].stub=!0);return!0}}function ot(i){var o;if(i?typeof i!="string"?o=N(Y):/^_/.test(i)&&!/^_(design|local)/.test(i)&&(o=N(k)):o=N(Z),o)throw o}function st(i){return typeof i._remote=="boolean"?i._remote:typeof i.type=="function"?(Te("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),i.type()==="http"):!1}function at(i,o){return"listenerCount"in i?i.listenerCount(o):W.listenerCount(i,o)}function Fe(i){if(!i)return null;var o=i.split("/");return o.length===2?o:o.length===1?[i,i]:null}function ut(i){var o=Fe(i);return o?o.join("/"):null}function ft(i,o){var u=[],l=[];for(var f in o)Object.prototype.hasOwnProperty.call(o,f)&&(u.push(f),l.push(o[f]));return u.push(i),Function.apply(null,u).apply(null,l)}function qe(i,o,u){return i.get(o).catch(function(l){if(l.status!==404)throw l;return{}}).then(function(l){var f=l._rev,c=u(l);return c?(c._id=o,c._rev=f,Pe(i,c,u)):{updated:!1,rev:f}})}function Pe(i,o,u){return i.put(o).then(function(l){return{updated:!0,rev:l.rev}},function(l){if(l.status!==409)throw l;return qe(i,o._id,u)})}function ct(i,o){if(!o)return J().replace(/-/g,"").toLowerCase();var u=Object.assign({},i);return delete u._rev_tree,Le(JSON.stringify(u))}var lt=J;export{fe as A,te as B,Ge as C,Je as D,W as E,ve as F,ke as G,xe as H,Qe as I,rt as J,Ze as K,pe as L,ze as M,$e as N,He as O,it as P,We as Q,Ke as R,Xe as S,Le as T,ee as U,tt as a,F as b,N as c,ot as d,Te as e,nt as f,Ye as g,Y as h,st as i,Ve as j,K as k,at as l,De as m,ut as n,Re as o,Fe as p,Q as q,ct as r,ft as s,ce as t,qe as u,J as v,lt as w,he as x,$ as y,et as z};
package/dist/index.es2.js DELETED
@@ -1,2 +0,0 @@
1
- import{g as Qe}from"./milkdown.js";import{t as je,w as Ae,r as ze,d as Ue,c as W,D as we,I as Ye,x as Xe,y as Te,z as Pe,A as Ze,C as $e,F as ke,G as et,R as _e,M as ae,H as tt,J as rt,m as Ke,e as Oe,K as nt,L as at,O as Re,b as it,P as ot,q as st,k as ut,S as ct}from"./index-browser.es2.js";import{i as ge,m as Le,d as ft,w as le,b as ie,l as vt,t as lt,a as dt,e as _t}from"./index.es3.js";var de={},Ce;function gt(){if(Ce)return de;Ce=1,de.stringify=function(r){var t=[];t.push({obj:r});for(var a="",c,o,d,g,m,S,A,C,D,R,q;c=t.pop();)if(o=c.obj,d=c.prefix||"",g=c.val||"",a+=d,g)a+=g;else if(typeof o!="object")a+=typeof o>"u"?null:JSON.stringify(o);else if(o===null)a+="null";else if(Array.isArray(o)){for(t.push({val:"]"}),m=o.length-1;m>=0;m--)S=m===0?"":",",t.push({obj:o[m],prefix:S});t.push({val:"["})}else{A=[];for(C in o)o.hasOwnProperty(C)&&A.push(C);for(t.push({val:"}"}),m=A.length-1;m>=0;m--)D=A[m],R=o[D],q=m>0?",":"",q+=JSON.stringify(D)+":",t.push({obj:R,prefix:q});t.push({val:"{"})}return a};function e(n,r,t){var a=t[t.length-1];n===a.element&&(t.pop(),a=t[t.length-1]);var c=a.element,o=a.index;if(Array.isArray(c))c.push(n);else if(o===r.length-2){var d=r.pop();c[d]=n}else r.push(n)}return de.parse=function(n){for(var r=[],t=[],a=0,c,o,d,g,m,S,A,C,D;;){if(c=n[a++],c==="}"||c==="]"||typeof c>"u"){if(r.length===1)return r.pop();e(r.pop(),r,t);continue}switch(c){case" ":case" ":case`
2
- `:case":":case",":break;case"n":a+=3,e(null,r,t);break;case"t":a+=3,e(!0,r,t);break;case"f":a+=4,e(!1,r,t);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":for(o="",a--;;)if(d=n[a++],/[\d\.\-e\+]/.test(d))o+=d;else{a--;break}e(parseFloat(o),r,t);break;case'"':for(g="",m=void 0,S=0;A=n[a++],A!=='"'||m==="\\"&&S%2===1;)g+=A,m=A,m==="\\"?S++:S=0;e(JSON.parse('"'+g+'"'),r,t);break;case"[":C={element:[],index:r.length},r.push(C.element),t.push(C);break;case"{":D={element:{},index:r.length},r.push(D.element),t.push(D);break;default:throw new Error("unexpectedly reached end of input: "+c)}}},de}var ht=gt();const Me=Qe(ht);function mt(e){try{return JSON.parse(e)}catch{return Me.parse(e)}}function pt(e){try{return JSON.stringify(e)}catch{return Me.stringify(e)}}function yt(e,n,r){return new Promise(function(t){var a=je([""]);let c;{const o=r;c=e.objectStore(n).put(a,o)}c.onsuccess=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),d=navigator.userAgent.match(/Edge\//);t(d||!o||parseInt(o[1],10)>=43)},c.onerror=e.onabort=function(o){o.preventDefault(),o.stopPropagation(),t(!1)}}).catch(function(){return!1})}function Ie(e){return e.reduce(function(n,r){return n[r]=!0,n},{})}var St=Ie(["_id","_rev","_access","_attachments","_deleted","_revisions","_revs_info","_conflicts","_deleted_conflicts","_local_seq","_rev_tree","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats","_removed"]),Dt=Ie(["_access","_attachments","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats"]);function Be(e){if(!/^\d+-/.test(e))return W(Ye);var n=e.indexOf("-"),r=e.substring(0,n),t=e.substring(n+1);return{prefix:parseInt(r,10),id:t}}function xt(e,n){for(var r=e.start-e.ids.length+1,t=e.ids,a=[t[0],n,[]],c=1,o=t.length;c<o;c++)a=[t[c],{status:"missing"},[a]];return[{pos:r,ids:a}]}function Ne(e,n,r){r||(r={deterministic_revs:!0});var t,a,c,o={status:"available"};if(e._deleted&&(o.deleted=!0),n)if(e._id||(e._id=Ae()),a=ze(e,r.deterministic_revs),e._rev){if(c=Be(e._rev),c.error)return c;e._rev_tree=[{pos:c.prefix,ids:[c.id,{status:"missing"},[[a,o,[]]]]}],t=c.prefix+1}else e._rev_tree=[{pos:1,ids:[a,o,[]]}],t=1;else if(e._revisions&&(e._rev_tree=xt(e._revisions,o),t=e._revisions.start,a=e._revisions.ids[0]),!e._rev_tree){if(c=Be(e._rev),c.error)return c;t=c.prefix,a=c.id,e._rev_tree=[{pos:t,ids:[a,o,[]]}]}Ue(e._id),e._rev=t+"-"+a;var d={metadata:{},data:{}};for(var g in e)if(Object.prototype.hasOwnProperty.call(e,g)){var m=g[0]==="_";if(m&&!St[g]){var S=W(we,g);throw S.message=we.message+": "+g,S}else m&&!Dt[g]?d.metadata[g.slice(1)]=e[g]:d.data[g]=e[g]}return d}function qt(e){try{return Ze(e)}catch{var n=W($e,"Attachment is not a valid base64 string");return{error:n}}}function bt(e,n,r){var t=qt(e.data);if(t.error)return r(t.error);e.length=t.length,n==="blob"?e.data=Xe(t,e.content_type):n==="base64"?e.data=Te(t):e.data=t,Pe(t,function(a){e.digest="md5-"+a,r()})}function At(e,n,r){Pe(e.data,function(t){e.digest="md5-"+t,e.length=e.data.size||e.data.length||0,n==="binary"?ke(e.data,function(a){e.data=a,r()}):n==="base64"?et(e.data,function(a){e.data=a,r()}):r()})}function Rt(e,n,r){if(e.stub)return r();typeof e.data=="string"?bt(e,n,r):At(e,n,r)}function wt(e,n,r){if(!e.length)return r();var t=0,a;e.forEach(function(o){var d=o.data&&o.data._attachments?Object.keys(o.data._attachments):[],g=0;if(!d.length)return c();function m(A){a=A,g++,g===d.length&&c()}for(var S in o.data._attachments)Object.prototype.hasOwnProperty.call(o.data._attachments,S)&&Rt(o.data._attachments[S],n,m)});function c(){t++,e.length===t&&(a?r(a):r())}}function Ot(e,n,r,t,a,c,o,d){if(ft(n.rev_tree,r.metadata.rev)&&!d)return t[a]=r,c();var g=n.winningRev||le(n),m="deleted"in n?n.deleted:ie(n,g),S="deleted"in r.metadata?r.metadata.deleted:ie(r.metadata),A=/^1-/.test(r.metadata.rev);if(m&&!S&&d&&A){var C=r.data;C._rev=g,C._id=r.metadata.id,r=Ne(C,d)}var D=Le(n.rev_tree,r.metadata.rev_tree[0],e),R=d&&(m&&S&&D.conflicts!=="new_leaf"||!m&&D.conflicts!=="new_leaf"||m&&!S&&D.conflicts==="new_branch");if(R){var q=W(_e);return t[a]=q,c()}var s=r.metadata.rev;r.metadata.rev_tree=D.tree,r.stemmedRevs=D.stemmedRevs||[],n.rev_map&&(r.metadata.rev_map=n.rev_map);var i=le(r.metadata),u=ie(r.metadata,i),v=m===u?0:m<u?-1:1,l;s===i?l=u:l=ie(r.metadata,s),o(r,i,u,l,!0,v,a,c)}function Ct(e){return e.metadata.rev_tree[0].ids[1].status==="missing"}function Bt(e,n,r,t,a,c,o,d,g){e=e||1e3;function m(q,s,i){var u=le(q.metadata),v=ie(q.metadata,u);if("was_delete"in d&&v)return c[s]=W(ae,"deleted"),i();var l=S&&Ct(q);if(l){var f=W(_e);return c[s]=f,i()}var _=v?0:1;o(q,u,v,v,!1,_,s,i)}var S=d.new_edits,A=new Map,C=0,D=n.length;function R(){++C===D&&g&&g()}n.forEach(function(q,s){if(q._id&&ge(q._id)){var i=q._deleted?"_removeLocal":"_putLocal";r[i](q,{ctx:a},function(v,l){c[s]=v||l,R()});return}var u=q.metadata.id;A.has(u)?(D--,A.get(u).push([q,s])):A.set(u,[[q,s]])}),A.forEach(function(q,s){var i=0;function u(){++i<q.length?v():R()}function v(){var l=q[i],f=l[0],_=l[1];if(t.has(s))Ot(e,t.get(s),f,c,_,u,o,S);else{var p=Le([],f.metadata.rev_tree[0],e);f.metadata.rev_tree=p.tree,f.stemmedRevs=p.stemmedRevs||[],m(f,_,u)}}v()})}var Et=5,V="document-store",Q="by-sequence",Y="attach-store",oe="attach-seq-store",U="meta-store",$="local-store",pe="detect-blob-support";function k(e){return function(n){var r="unknown_error";n.target&&n.target.error&&(r=n.target.error.name||n.target.error.message),e(W(Re,r,n.type))}}function De(e,n,r){return{data:pt(e),winningRev:n,deletedOrLocal:r?"1":"0",seq:e.seq,id:e.id}}function se(e){if(!e)return null;var n=mt(e.data);return n.winningRev=e.winningRev,n.deleted=e.deletedOrLocal==="1",n.seq=e.seq,n}function he(e){if(!e)return e;var n=e._doc_id_rev.lastIndexOf(":");return e._id=e._doc_id_rev.substring(0,n-1),e._rev=e._doc_id_rev.substring(n+1),delete e._doc_id_rev,e}function Ge(e,n,r,t){r?t(e?typeof e!="string"?e:nt(e,n):je([""],{type:n})):e?typeof e!="string"?at(e,function(a){t(Te(a))}):t(e):t("")}function Ve(e,n,r,t){var a=Object.keys(e._attachments||{});if(!a.length)return t&&t();var c=0;function o(){++c===a.length&&t&&t()}function d(g,m){var S=g._attachments[m],A=S.digest,C=r.objectStore(Y).get(A);C.onsuccess=function(D){S.body=D.target.result.body,o()}}a.forEach(function(g){n.attachments&&n.include_docs?d(e,g):(e._attachments[g].stub=!0,o())})}function xe(e,n){return Promise.all(e.map(function(r){if(r.doc&&r.doc._attachments){var t=Object.keys(r.doc._attachments);return Promise.all(t.map(function(a){var c=r.doc._attachments[a];if("body"in c){var o=c.body,d=c.content_type;return new Promise(function(g){Ge(o,d,n,function(m){r.doc._attachments[a]=Object.assign(st(c,["digest","content_type"]),{data:m}),g()})})}}))}}))}function Fe(e,n,r){var t=[],a=r.objectStore(Q),c=r.objectStore(Y),o=r.objectStore(oe),d=e.length;function g(){d--,d||m()}function m(){t.length&&t.forEach(function(S){var A=o.index("digestSeq").count(IDBKeyRange.bound(S+"::",S+"::￿",!1,!1));A.onsuccess=function(C){var D=C.target.result;D||c.delete(S)}})}e.forEach(function(S){var A=a.index("_doc_id_rev"),C=n+"::"+S;A.getKey(C).onsuccess=function(D){var R=D.target.result;if(typeof R!="number")return g();a.delete(R);var q=o.index("seq").openCursor(IDBKeyRange.only(R));q.onsuccess=function(s){var i=s.target.result;if(i){var u=i.value.digestSeq.split("::")[0];t.push(u),o.delete(i.primaryKey),i.continue()}else g()}}})}function X(e,n,r){try{return{txn:e.transaction(n,r)}}catch(t){return{error:t}}}var ve=new rt;function jt(e,n,r,t,a,c){for(var o=n.docs,d,g,m,S,A,C,D,R,q=0,s=o.length;q<s;q++){var i=o[q];i._id&&ge(i._id)||(i=o[q]=Ne(i,r.new_edits,e),i.error&&!D&&(D=i))}if(D)return c(D);var u=!1,v=0,l=new Array(o.length),f=new Map,_=!1,p=t._meta.blobSupport?"blob":"base64";wt(o,p,function(x){if(x)return c(x);y()});function y(){var x=[V,Q,Y,$,oe,U],E=X(a,x,"readwrite");if(E.error)return c(E.error);d=E.txn,d.onabort=k(c),d.ontimeout=k(c),d.oncomplete=B,g=d.objectStore(V),m=d.objectStore(Q),S=d.objectStore(Y),A=d.objectStore(oe),C=d.objectStore(U),C.get(U).onsuccess=function(K){R=K.target.result,O()},j(function(K){if(K)return _=!0,c(K);M()})}function h(){u=!0,O()}function w(){Bt(e.revs_limit,o,t,f,d,l,T,r,h)}function O(){!R||!u||(R.docCount+=v,C.put(R))}function M(){if(!o.length)return;var x=0;function E(){++x===o.length&&w()}function K(L){var H=se(L.target.result);H&&f.set(H.id,H),E()}for(var F=0,G=o.length;F<G;F++){var N=o[F];if(N._id&&ge(N._id)){E();continue}var I=g.get(N.metadata.id);I.onsuccess=K}}function B(){_||(ve.notify(t._meta.name),c(null,l))}function b(x,E){var K=S.get(x);K.onsuccess=function(F){if(F.target.result)E();else{var G=W(ct,"unknown stub attachment with digest "+x);G.status=412,E(G)}}}function j(x){var E=[];if(o.forEach(function(N){N.data&&N.data._attachments&&Object.keys(N.data._attachments).forEach(function(I){var L=N.data._attachments[I];L.stub&&E.push(L.digest)})}),!E.length)return x();var K=0,F;function G(){++K===E.length&&x(F)}E.forEach(function(N){b(N,function(I){I&&!F&&(F=I),G()})})}function T(x,E,K,F,G,N,I,L){x.metadata.winningRev=E,x.metadata.deleted=K;var H=x.data;H._id=x.metadata.id,H._rev=x.metadata.rev,F&&(H._deleted=!0);var te=H._attachments&&Object.keys(H._attachments).length;if(te)return J(x,E,K,G,I,L);v+=N,O(),P(x,E,K,G,I,L)}function P(x,E,K,F,G,N){var I=x.data,L=x.metadata;I._doc_id_rev=L.id+"::"+L.rev,delete I._id,delete I._rev;function H(Z){var ee=x.stemmedRevs||[];F&&t.auto_compaction&&(ee=ee.concat(_t(x.metadata))),ee&&ee.length&&Fe(ee,x.metadata.id,d),L.seq=Z.target.result;var fe=De(L,E,K),me=g.put(fe);me.onsuccess=ue}function te(Z){Z.preventDefault(),Z.stopPropagation();var ee=m.index("_doc_id_rev"),fe=ee.getKey(I._doc_id_rev);fe.onsuccess=function(me){var He=m.put(I,me.target.result);He.onsuccess=H}}function ue(){l[G]={ok:!0,id:L.id,rev:L.rev},f.set(x.metadata.id,x.metadata),z(x,L.seq,N)}var ne=m.put(I);ne.onsuccess=H,ne.onerror=te}function J(x,E,K,F,G,N){var I=x.data,L=0,H=Object.keys(I._attachments);function te(){L===H.length&&P(x,E,K,F,G,N)}function ue(){L++,te()}H.forEach(function(ne){var Z=x.data._attachments[ne];if(Z.stub)L++,te();else{var ee=Z.data;delete Z.data,Z.revpos=parseInt(E,10);var fe=Z.digest;re(fe,ee,ue)}})}function z(x,E,K){var F=0,G=Object.keys(x.data._attachments||{});if(!G.length)return K();function N(){++F===G.length&&K()}function I(H){var te=x.data._attachments[H].digest,ue=A.put({seq:E,digestSeq:te+"::"+E});ue.onsuccess=N,ue.onerror=function(ne){ne.preventDefault(),ne.stopPropagation(),N()}}for(var L=0;L<G.length;L++)I(G[L])}function re(x,E,K){var F=S.count(x);F.onsuccess=function(G){var N=G.target.result;if(N)return K();var I={digest:x,body:E},L=S.put(I);L.onsuccess=K}}}function Je(e,n,r,t,a){t===-1&&(t=1e3);var c=typeof e.getAll=="function"&&typeof e.getAllKeys=="function"&&t>1&&!r,o,d,g;function m(D){d=D.target.result,o&&a(o,d,g)}function S(D){o=D.target.result,d&&a(o,d,g)}function A(){if(!o.length)return a();var D=o[o.length-1],R;if(n&&n.upper)try{R=IDBKeyRange.bound(D,n.upper,!0,n.upperOpen)}catch(q){if(q.name==="DataError"&&q.code===0)return a()}else R=IDBKeyRange.lowerBound(D,!0);n=R,o=null,d=null,e.getAll(n,t).onsuccess=m,e.getAllKeys(n,t).onsuccess=S}function C(D){var R=D.target.result;if(!R)return a();a([R.key],[R.value],R)}c?(g={continue:A},e.getAll(n,t).onsuccess=m,e.getAllKeys(n,t).onsuccess=S):r?e.openCursor(n,"prev").onsuccess=C:e.openCursor(n).onsuccess=C}function Tt(e,n,r){if(typeof e.getAll=="function"){e.getAll(n).onsuccess=r;return}var t=[];function a(c){var o=c.target.result;o?(t.push(o.value),o.continue()):r({target:{result:t}})}e.openCursor(n).onsuccess=a}function Pt(e,n,r){var t=new Array(e.length),a=0;e.forEach(function(c,o){n.get(c).onsuccess=function(d){d.target.result?t[o]=d.target.result:t[o]={key:c,error:"not_found"},a++,a===e.length&&r(e,t,{})}})}function Kt(e,n,r,t,a){try{if(e&&n)return a?IDBKeyRange.bound(n,e,!r,!1):IDBKeyRange.bound(e,n,!1,!r);if(e)return a?IDBKeyRange.upperBound(e):IDBKeyRange.lowerBound(e);if(n)return a?IDBKeyRange.lowerBound(n,!r):IDBKeyRange.upperBound(n,!r);if(t)return IDBKeyRange.only(t)}catch(c){return{error:c}}return null}function Lt(e,n,r){var t="startkey"in e?e.startkey:!1,a="endkey"in e?e.endkey:!1,c="key"in e?e.key:!1,o="keys"in e?e.keys:!1,d=e.skip||0,g=typeof e.limit=="number"?e.limit:-1,m=e.inclusive_end!==!1,S,A;if(!o&&(S=Kt(t,a,m,c,e.descending),A=S&&S.error,A&&!(A.name==="DataError"&&A.code===0)))return r(W(Re,A.name,A.message));var C=[V,Q,U];e.attachments&&C.push(Y);var D=X(n,C,"readonly");if(D.error)return r(D.error);var R=D.txn;R.oncomplete=M,R.onabort=k(r);var q=R.objectStore(V),s=R.objectStore(Q),i=R.objectStore(U),u=s.index("_doc_id_rev"),v=[],l,f;i.get(U).onsuccess=function(B){l=B.target.result.docCount},e.update_seq&&(s.openKeyCursor(null,"prev").onsuccess=B=>{var b=B.target.result;b&&b.key&&(f=b.key)});function _(B,b,j){var T=B.id+"::"+j;u.get(T).onsuccess=function(J){if(b.doc=he(J.target.result)||{},e.conflicts){var z=dt(B);z.length&&(b.doc._conflicts=z)}Ve(b.doc,e,R)}}function p(B,b){var j={id:b.id,key:b.id,value:{rev:B}},T=b.deleted;T?o&&(v.push(j),j.value.deleted=!0,j.doc=null):d--<=0&&(v.push(j),e.include_docs&&_(b,j,B))}function y(B){for(var b=0,j=B.length;b<j&&v.length!==g;b++){var T=B[b];if(T.error&&o){v.push(T);continue}var P=se(T),J=P.winningRev;p(J,P)}}function h(B,b,j){j&&(y(b),v.length<g&&j.continue())}function w(B){var b=B.target.result;e.descending&&(b=b.reverse()),y(b)}function O(){var B={total_rows:l,offset:e.skip,rows:v};e.update_seq&&f!==void 0&&(B.update_seq=f),r(null,B)}function M(){e.attachments?xe(v,e.binary).then(O):O()}if(!(A||g===0)){if(o)return Pt(o,q,h);if(g===-1)return Tt(q,S,w);Je(q,S,e.descending,g+d,h)}}function Mt(e,n){var r=e.objectStore(V).index("deletedOrLocal");r.count(IDBKeyRange.only("0")).onsuccess=function(t){n(t.target.result)}}var qe=!1,be=[];function It(e,n,r,t){try{e(n,r)}catch(a){t.emit("error",a)}}function Ee(){qe||!be.length||(qe=!0,be.shift()())}function Nt(e,n,r){be.push(function(){e(function(c,o){It(n,c,o,r),qe=!1,Ke(function(){Ee()})})}),Ee()}function Gt(e,n,r,t){if(e=it(e),e.continuous){var a=r+":"+Ae();return ve.addListener(r,a,n,e),ve.notify(r),{cancel:function(){ve.removeListener(r,a)}}}var c=e.doc_ids&&new Set(e.doc_ids);e.since=e.since||0;var o=e.since,d="limit"in e?e.limit:-1;d===0&&(d=1);var g=[],m=0,S=ot(e),A=new Map,C,D,R,q;function s(y,h,w){if(!w||!y.length)return;var O=new Array(y.length),M=new Array(y.length);function B(T,P){var J=e.processChange(P,T,e);o=J.seq=T.seq;var z=S(J);return typeof z=="object"?Promise.reject(z):z?(m++,e.return_docs&&g.push(J),e.attachments&&e.include_docs?new Promise(function(re){Ve(P,e,C,function(){xe([J],e.binary).then(function(){re(J)})})}):Promise.resolve(J)):Promise.resolve()}function b(){for(var T=[],P=0,J=O.length;P<J&&m!==d;P++){var z=O[P];if(z){var re=M[P];T.push(B(re,z))}}Promise.all(T).then(function(x){for(var E=0,K=x.length;E<K;E++)x[E]&&e.onChange(x[E])}).catch(e.complete),m!==d&&w.continue()}var j=0;h.forEach(function(T,P){var J=he(T),z=y[P];u(J,z,function(re,x){M[P]=re,O[P]=x,++j===y.length&&b()})})}function i(y,h,w,O){if(w.seq!==h)return O();if(w.winningRev===y._rev)return O(w,y);var M=y._id+"::"+w.winningRev,B=q.get(M);B.onsuccess=function(b){O(w,he(b.target.result))}}function u(y,h,w){if(c&&!c.has(y._id))return w();var O=A.get(y._id);if(O)return i(y,h,O,w);R.get(y._id).onsuccess=function(M){O=se(M.target.result),A.set(y._id,O),i(y,h,O,w)}}function v(){e.complete(null,{results:g,last_seq:o})}function l(){!e.continuous&&e.attachments?xe(g).then(v):v()}var f=[V,Q];e.attachments&&f.push(Y);var _=X(t,f,"readonly");if(_.error)return e.complete(_.error);C=_.txn,C.onabort=k(e.complete),C.oncomplete=l,D=C.objectStore(Q),R=C.objectStore(V),q=D.index("_doc_id_rev");var p=e.since&&!e.descending?IDBKeyRange.lowerBound(e.since,!0):null;Je(D,p,e.descending,d,s)}var ce=new Map,ye,Se=new Map;function We(e,n){var r=this;Nt(function(t){Vt(r,e,t)},n,r.constructor)}function Vt(e,n,r){var t=n.name,a=null,c=null;e._meta=null;function o(s){return function(i,u){i&&i instanceof Error&&!i.reason&&c&&(i.reason=c),s(i,u)}}function d(s){var i=s.createObjectStore(V,{keyPath:"id"});s.createObjectStore(Q,{autoIncrement:!0}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0}),s.createObjectStore(Y,{keyPath:"digest"}),s.createObjectStore(U,{keyPath:"id",autoIncrement:!1}),s.createObjectStore(pe),i.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),s.createObjectStore($,{keyPath:"_id"});var u=s.createObjectStore(oe,{autoIncrement:!0});u.createIndex("seq","seq"),u.createIndex("digestSeq","digestSeq",{unique:!0})}function g(s,i){var u=s.objectStore(V);u.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),u.openCursor().onsuccess=function(v){var l=v.target.result;if(l){var f=l.value,_=ie(f);f.deletedOrLocal=_?"1":"0",u.put(f),l.continue()}else i()}}function m(s){s.createObjectStore($,{keyPath:"_id"}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0})}function S(s,i){var u=s.objectStore($),v=s.objectStore(V),l=s.objectStore(Q),f=v.openCursor();f.onsuccess=function(_){var p=_.target.result;if(p){var y=p.value,h=y.id,w=ge(h),O=le(y);if(w){var M=h+"::"+O,B=h+"::",b=h+"::~",j=l.index("_doc_id_rev"),T=IDBKeyRange.bound(B,b,!1,!1),P=j.openCursor(T);P.onsuccess=function(J){if(P=J.target.result,!P)v.delete(p.primaryKey),p.continue();else{var z=P.value;z._doc_id_rev===M&&u.put(z),l.delete(P.primaryKey),P.continue()}}}else p.continue()}else i&&i()}}function A(s){var i=s.createObjectStore(oe,{autoIncrement:!0});i.createIndex("seq","seq"),i.createIndex("digestSeq","digestSeq",{unique:!0})}function C(s,i){var u=s.objectStore(Q),v=s.objectStore(Y),l=s.objectStore(oe),f=v.count();f.onsuccess=function(_){var p=_.target.result;if(!p)return i();u.openCursor().onsuccess=function(y){var h=y.target.result;if(!h)return i();for(var w=h.value,O=h.primaryKey,M=Object.keys(w._attachments||{}),B={},b=0;b<M.length;b++){var j=w._attachments[M[b]];B[j.digest]=!0}var T=Object.keys(B);for(b=0;b<T.length;b++){var P=T[b];l.put({seq:O,digestSeq:P+"::"+O})}h.continue()}}}function D(s){function i(f){return f.data?se(f):(f.deleted=f.deletedOrLocal==="1",f)}var u=s.objectStore(Q),v=s.objectStore(V),l=v.openCursor();l.onsuccess=function(f){var _=f.target.result;if(!_)return;var p=i(_.value);p.winningRev=p.winningRev||le(p);function y(){var w=p.id+"::",O=p.id+"::￿",M=u.index("_doc_id_rev").openCursor(IDBKeyRange.bound(w,O)),B=0;M.onsuccess=function(b){var j=b.target.result;if(!j)return p.seq=B,h();var T=j.primaryKey;T>B&&(B=T),j.continue()}}function h(){var w=De(p,p.winningRev,p.deleted),O=v.put(w);O.onsuccess=function(){_.continue()}}if(p.seq)return h();y()}}e._remote=!1,e.type=function(){return"idb"},e._id=tt(function(s){s(null,e._meta.instanceId)}),e._bulkDocs=function(i,u,v){jt(n,i,u,e,a,o(v))},e._get=function(i,u,v){var l,f,_,p=u.ctx;if(!p){var y=X(a,[V,Q,Y],"readonly");if(y.error)return v(y.error);p=y.txn}function h(){v(_,{doc:l,metadata:f,ctx:p})}p.objectStore(V).get(i).onsuccess=function(w){if(f=se(w.target.result),!f)return _=W(ae,"missing"),h();var O;if(u.rev)O=u.latest?vt(u.rev,f):u.rev;else{O=f.winningRev;var M=ie(f);if(M)return _=W(ae,"deleted"),h()}var B=p.objectStore(Q),b=f.id+"::"+O;B.index("_doc_id_rev").get(b).onsuccess=function(j){if(l=j.target.result,l&&(l=he(l)),!l)return _=W(ae,"missing"),h();h()}}},e._getAttachment=function(s,i,u,v,l){var f;if(v.ctx)f=v.ctx;else{var _=X(a,[V,Q,Y],"readonly");if(_.error)return l(_.error);f=_.txn}var p=u.digest,y=u.content_type;f.objectStore(Y).get(p).onsuccess=function(h){var w=h.target.result.body;Ge(w,y,v.binary,function(O){l(null,O)})}},e._info=function(i){var u,v,l=X(a,[U,Q],"readonly");if(l.error)return i(l.error);var f=l.txn;f.objectStore(U).get(U).onsuccess=function(_){v=_.target.result.docCount},f.objectStore(Q).openKeyCursor(null,"prev").onsuccess=function(_){var p=_.target.result;u=p?p.key:0},f.oncomplete=function(){i(null,{doc_count:v,update_seq:u,idb_attachment_format:e._meta.blobSupport?"binary":"base64"})}},e._allDocs=function(i,u){Lt(i,a,o(u))},e._changes=function(i){return Gt(i,e,t,a)},e._close=function(s){a.close(),ce.delete(t),s()},e._getRevisionTree=function(s,i){var u=X(a,[V],"readonly");if(u.error)return i(u.error);var v=u.txn,l=v.objectStore(V).get(s);l.onsuccess=function(f){var _=se(f.target.result);_?i(null,_.rev_tree):i(W(ae))}},e._doCompaction=function(s,i,u){var v=[V,Q,Y,oe],l=X(a,v,"readwrite");if(l.error)return u(l.error);var f=l.txn,_=f.objectStore(V);_.get(s).onsuccess=function(p){var y=se(p.target.result);lt(y.rev_tree,function(O,M,B,b,j){var T=M+"-"+B;i.indexOf(T)!==-1&&(j.status="missing")}),Fe(i,s,f);var h=y.winningRev,w=y.deleted;f.objectStore(V).put(De(y,h,w))},f.onabort=k(u),f.oncomplete=function(){u()}},e._getLocal=function(s,i){var u=X(a,[$],"readonly");if(u.error)return i(u.error);var v=u.txn,l=v.objectStore($).get(s);l.onerror=k(i),l.onsuccess=function(f){var _=f.target.result;_?(delete _._doc_id_rev,i(null,_)):i(W(ae))}},e._putLocal=function(s,i,u){typeof i=="function"&&(u=i,i={}),delete s._revisions;var v=s._rev,l=s._id;v?s._rev="0-"+(parseInt(v.split("-")[1],10)+1):s._rev="0-1";var f=i.ctx,_;if(!f){var p=X(a,[$],"readwrite");if(p.error)return u(p.error);f=p.txn,f.onerror=k(u),f.oncomplete=function(){_&&u(null,_)}}var y=f.objectStore($),h;v?(h=y.get(l),h.onsuccess=function(w){var O=w.target.result;if(!O||O._rev!==v)u(W(_e));else{var M=y.put(s);M.onsuccess=function(){_={ok:!0,id:s._id,rev:s._rev},i.ctx&&u(null,_)}}}):(h=y.add(s),h.onerror=function(w){u(W(_e)),w.preventDefault(),w.stopPropagation()},h.onsuccess=function(){_={ok:!0,id:s._id,rev:s._rev},i.ctx&&u(null,_)})},e._removeLocal=function(s,i,u){typeof i=="function"&&(u=i,i={});var v=i.ctx;if(!v){var l=X(a,[$],"readwrite");if(l.error)return u(l.error);v=l.txn,v.oncomplete=function(){f&&u(null,f)}}var f,_=s._id,p=v.objectStore($),y=p.get(_);y.onerror=k(u),y.onsuccess=function(h){var w=h.target.result;!w||w._rev!==s._rev?u(W(ae)):(p.delete(_),f={ok:!0,id:_,rev:"0-0"},i.ctx&&u(null,f))}},e._destroy=function(s,i){ve.removeAllListeners(t);var u=Se.get(t);u&&u.result&&(u.result.close(),ce.delete(t));var v=indexedDB.deleteDatabase(t);v.onsuccess=function(){Se.delete(t),ut()&&t in localStorage&&delete localStorage[t],i(null,{ok:!0})},v.onerror=k(i)};var R=ce.get(t);if(R)return a=R.idb,e._meta=R.global,Ke(function(){r(null,e)});var q=indexedDB.open(t,Et);Se.set(t,q),q.onupgradeneeded=function(s){var i=s.target.result;if(s.oldVersion<1)return d(i);var u=s.currentTarget.transaction;s.oldVersion<3&&m(i),s.oldVersion<4&&A(i);var v=[g,S,C,D],l=s.oldVersion;function f(){var _=v[l-1];l++,_&&_(u,f)}f()},q.onsuccess=function(s){a=s.target.result,a.onversionchange=function(){a.close(),ce.delete(t)},a.onabort=function(h){Oe("error","Database has a global failure",h.target.error),c=h.target.error,a.close(),ce.delete(t)};var i=a.transaction([U,pe,V],"readwrite"),u=!1,v,l,f,_;function p(){typeof f>"u"||!u||(e._meta={name:t,instanceId:_,blobSupport:f},ce.set(t,{idb:a,global:e._meta}),r(null,e))}function y(){if(!(typeof l>"u"||typeof v>"u")){var h=t+"_id";h in v?_=v[h]:v[h]=_=Ae(),v.docCount=l,i.objectStore(U).put(v)}}i.objectStore(U).get(U).onsuccess=function(h){v=h.target.result||{id:U},y()},Mt(i,function(h){l=h,y()}),ye||(ye=yt(i,pe,"key")),ye.then(function(h){f=h,p()}),i.oncomplete=function(){u=!0,p()},i.onabort=k(r)},q.onerror=function(s){var i=s.target.error&&s.target.error.message;i?i.indexOf("stored database is a higher version")!==-1&&(i=new Error('This DB was created with the newer "indexeddb" adapter, but you are trying to open it with the older "idb" adapter')):i="Failed to open indexedDB, are you in private browsing mode?",Oe("error",i),r(W(Re,i))}}We.valid=function(){try{return typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}};function Ht(e){e.adapter("idb",We,!0)}export{Ht as default};
package/dist/index.es3.js DELETED
@@ -1 +0,0 @@
1
- import"./index-browser.es2.js";function V(t){for(var e,i,r,s=t.rev_tree.slice(),n;n=s.pop();){var o=n.ids,v=o[2],a=n.pos;if(v.length){for(var l=0,f=v.length;l<f;l++)s.push({pos:a+1,ids:v[l]});continue}var u=!!o[1].deleted,c=o[0];(!e||(r!==u?r:i!==a?i<a:e<c))&&(e=c,i=a,r=u)}return i+"-"+e}function x(t,e){for(var i=t.slice(),r;r=i.pop();)for(var s=r.pos,n=r.ids,o=n[2],v=e(o.length===0,s,n[0],r.ctx,n[1]),a=0,l=o.length;a<l;a++)i.push({pos:s+1,ids:o[a],ctx:v})}function P(t,e){return t.pos-e.pos}function q(t){var e=[];x(t,function(s,n,o,v,a){s&&e.push({rev:n+"-"+o,pos:n,opts:a})}),e.sort(P).reverse();for(var i=0,r=e.length;i<r;i++)delete e[i].pos;return e}function M(t){for(var e=V(t),i=q(t.rev_tree),r=[],s=0,n=i.length;s<n;s++){var o=i[s];o.rev!==e&&!o.opts.deleted&&r.push(o.rev)}return r}function U(t){var e=[];return x(t.rev_tree,function(i,r,s,n,o){o.status==="available"&&!i&&(e.push(r+"-"+s),o.status="missing")}),e}function W(t,e){let i=[];const r=t.slice();let s;for(;s=r.pop();){const{pos:n,ids:o}=s,v=`${n}-${o[0]}`,a=o[2];if(i.push(v),v===e){if(a.length!==0)throw new Error("The requested revision is not a leaf");return i.reverse()}(a.length===0||a.length>1)&&(i=[]);for(let l=0,f=a.length;l<f;l++)r.push({pos:n+1,ids:a[l]})}if(i.length===0)throw new Error("The requested revision does not exist");return i.reverse()}function L(t){for(var e=[],i=t.slice(),r;r=i.pop();){var s=r.pos,n=r.ids,o=n[0],v=n[1],a=n[2],l=a.length===0,f=r.history?r.history.slice():[];f.push({id:o,opts:v}),l&&e.push({pos:s+1-f.length,ids:f});for(var u=0,c=a.length;u<c;u++)i.push({pos:s+1,ids:a[u],history:f})}return e.reverse()}function $(t,e){return t.pos-e.pos}function y(t,e,i){for(var r=0,s=t.length,n;r<s;)n=r+s>>>1,i(t[n],e)<0?r=n+1:s=n;return r}function B(t,e,i){var r=y(t,e,i);t.splice(r,0,e)}function _(t,e){for(var i,r,s=e,n=t.length;s<n;s++){var o=t[s],v=[o.id,o.opts,[]];r?(r[2].push(v),r=v):i=r=v}return i}function D(t,e){return t[0]<e[0]?-1:1}function I(t,e){for(var i=[{tree1:t,tree2:e}],r=!1;i.length>0;){var s=i.pop(),n=s.tree1,o=s.tree2;(n[1].status||o[1].status)&&(n[1].status=n[1].status==="available"||o[1].status==="available"?"available":"missing");for(var v=0;v<o[2].length;v++){if(!n[2][0]){r="new_leaf",n[2][0]=o[2][v];continue}for(var a=!1,l=0;l<n[2].length;l++)n[2][l][0]===o[2][v][0]&&(i.push({tree1:n[2][l],tree2:o[2][v]}),a=!0);a||(r="new_branch",B(n[2],o[2][v],D))}}return{conflicts:r,tree:t}}function R(t,e,i){var r=[],s=!1,n=!1,o;if(!t.length)return{tree:[e],conflicts:"new_leaf"};for(var v=0,a=t.length;v<a;v++){var l=t[v];if(l.pos===e.pos&&l.ids[0]===e.ids[0])o=I(l.ids,e.ids),r.push({pos:l.pos,ids:o.tree}),s=s||o.conflicts,n=!0;else if(i!==!0){var f=l.pos<e.pos?l:e,u=l.pos<e.pos?e:l,c=u.pos-f.pos,g=[],d=[];for(d.push({ids:f.ids,diff:c,parent:null,parentIdx:null});d.length>0;){var p=d.pop();if(p.diff===0){p.ids[0]===u.ids[0]&&g.push(p);continue}for(var h=p.ids[2],w=0,E=h.length;w<E;w++)d.push({ids:h[w],diff:p.diff-1,parent:p.ids,parentIdx:w})}var T=g[0];T?(o=I(T.ids,u.ids),T.parent[2][T.parentIdx]=o.tree,r.push({pos:f.pos,ids:f.ids}),s=s||o.conflicts,n=!0):r.push(l)}else r.push(l)}return n||r.push(e),r.sort($),{tree:r,conflicts:s||"internal_node"}}function O(t,e){for(var i=L(t),r,s,n=0,o=i.length;n<o;n++){var v=i[n],a=v.ids,l;if(a.length>e){r||(r={});var f=a.length-e;l={pos:v.pos+f,ids:_(a,f)};for(var u=0;u<f;u++){var c=v.pos+u+"-"+a[u].id;r[c]=!0}}else l={pos:v.pos,ids:_(a,0)};s?s=R(s,l,!0).tree:s=[l]}return r&&x(s,function(g,d,p){delete r[d+"-"+p]}),{tree:s,revs:r?Object.keys(r):[]}}function z(t,e,i){var r=R(t,e),s=O(r.tree,i);return{tree:s.tree,stemmedRevs:s.revs,conflicts:r.conflicts}}function A(t,e){for(var i=t.slice(),r=e.split("-"),s=parseInt(r[0],10),n=r[1],o;o=i.pop();){if(o.pos===s&&o.ids[0]===n)return!0;for(var v=o.ids[2],a=0,l=v.length;a<l;a++)i.push({pos:o.pos+1,ids:v[a]})}return!1}function k(t){return t.ids}function F(t,e){e||(e=V(t));for(var i=e.substring(e.indexOf("-")+1),r=t.rev_tree.map(k),s;s=r.pop();){if(s[0]===i)return!!s[1].deleted;r=r.concat(s[2])}}function G(t){return typeof t=="string"&&t.startsWith("_local/")}function H(t,e){for(var i=e.rev_tree.slice(),r;r=i.pop();){var s=r.pos,n=r.ids,o=n[0],v=n[1],a=n[2],l=a.length===0,f=r.history?r.history.slice():[];if(f.push({id:o,pos:s,opts:v}),l)for(var u=0,c=f.length;u<c;u++){var g=f[u],d=g.pos+"-"+g.id;if(d===t)return s+"-"+o}for(var p=0,h=a.length;p<h;p++)i.push({pos:s+1,ids:a[p],history:f})}throw new Error("Unable to resolve latest revision for id "+e.id+", rev "+t)}export{M as a,F as b,q as c,A as d,U as e,W as f,G as i,H as l,z as m,L as r,x as t,V as w};
package/dist/index.es4.js DELETED
@@ -1 +0,0 @@
1
- import{b as q}from"./index-browser.es2.js";var sn=fetch,$n=Headers;function J(r,n,t){for(var e="",f=t-r.length;e.length<f;)e+=n;return e}function H(r,n,t){var e=J(r,n,t);return e+r}var S=-324,x=3,A="";function s(r,n){if(r===n)return 0;r=y(r),n=y(n);var t=m(r),e=m(n);if(t-e!==0)return t-e;switch(typeof r){case"number":return r-n;case"boolean":return r<n?-1:1;case"string":return U(r,n)}return Array.isArray(r)?R(r,n):W(r,n)}function y(r){switch(typeof r){case"undefined":return null;case"number":return r===1/0||r===-1/0||isNaN(r)?null:r;case"object":var n=r;if(Array.isArray(r)){var t=r.length;r=new Array(t);for(var e=0;e<t;e++)r[e]=y(n[e])}else{if(r instanceof Date)return r.toJSON();if(r!==null){r={};for(var f in n)if(Object.prototype.hasOwnProperty.call(n,f)){var u=n[f];typeof u<"u"&&(r[f]=y(u))}}}}return r}function B(r){if(r!==null)switch(typeof r){case"boolean":return r?1:0;case"number":return X(r);case"string":return r.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var n=Array.isArray(r),t=n?r:Object.keys(r),e=-1,f=t.length,u="";if(n)for(;++e<f;)u+=j(t[e]);else for(;++e<f;){var i=t[e];u+=j(i)+j(r[i])}return u}return""}function j(r){var n="\0";return r=y(r),m(r)+A+B(r)+n}function P(r,n){var t=n,e,f=r[n]==="1";if(f)e=0,n++;else{var u=r[n]==="0";n++;var i="",a=r.substring(n,n+x),o=parseInt(a,10)+S;for(u&&(o=-o),n+=x;;){var c=r[n];if(c==="\0")break;i+=c,n++}i=i.split("."),i.length===1?e=parseInt(i,10):e=parseFloat(i[0]+"."+i[1]),u&&(e=e-10),o!==0&&(e=parseFloat(e+"e"+o))}return{num:e,length:n-t}}function Q(r,n){var t=r.pop();if(n.length){var e=n[n.length-1];t===e.element&&(n.pop(),e=n[n.length-1]);var f=e.element,u=e.index;if(Array.isArray(f))f.push(t);else if(u===r.length-2){var i=r.pop();f[i]=t}else r.push(t)}}function gn(r){for(var n=[],t=[],e=0;;){var f=r[e++];if(f==="\0"){if(n.length===1)return n.pop();Q(n,t);continue}switch(f){case"1":n.push(null);break;case"2":n.push(r[e]==="1"),e++;break;case"3":var u=P(r,e);n.push(u.num),e+=u.length;break;case"4":for(var i="";;){var a=r[e];if(a==="\0")break;i+=a,e++}i=i.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),n.push(i);break;case"5":var o={element:[],index:n.length};n.push(o.element),t.push(o);break;case"6":var c={element:{},index:n.length};n.push(c.element),t.push(c);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+f)}}}function R(r,n){for(var t=Math.min(r.length,n.length),e=0;e<t;e++){var f=s(r[e],n[e]);if(f!==0)return f}return r.length===n.length?0:r.length>n.length?1:-1}function U(r,n){return r===n?0:r>n?1:-1}function W(r,n){for(var t=Object.keys(r),e=Object.keys(n),f=Math.min(t.length,e.length),u=0;u<f;u++){var i=s(t[u],e[u]);if(i!==0||(i=s(r[t[u]],n[e[u]]),i!==0))return i}return t.length===e.length?0:t.length>e.length?1:-1}function m(r){var n=["boolean","number","string","object"],t=n.indexOf(typeof r);if(~t)return r===null?1:Array.isArray(r)?5:t<3?t+2:t+3;if(Array.isArray(r))return 5}function X(r){if(r===0)return"1";var n=r.toExponential().split(/e\+?/),t=parseInt(n[1],10),e=r<0,f=e?"0":"2",u=(e?-t:t)-S,i=H(u.toString(),"0",x);f+=A+i;var a=Math.abs(parseFloat(n[0]));e&&(a=10-a);var o=a.toFixed(20);return o=o.replace(/\.?0+$/,""),f+=A+o,f}function I(r,n){for(var t=r,e=0,f=n.length;e<f;e++){var u=n[e];if(t=t[u],!t)break}return t}function vn(r,n,t){for(var e=0,f=n.length;e<f-1;e++){var u=n[e];r=r[u]=r[u]||{}}r[n[f-1]]=t}function Y(r,n){return r<n?-1:r>n?1:0}function E(r){for(var n=[],t="",e=0,f=r.length;e<f;e++){var u=r[e];e>0&&r[e-1]==="\\"&&(u==="$"||u===".")?t=t.substring(0,t.length-1)+u:u==="."?(n.push(t),t=""):t+=u}return n.push(t),n}var Z=["$or","$nor","$not"];function G(r){return Z.indexOf(r)>-1}function L(r){return Object.keys(r)[0]}function k(r){return r[L(r)]}function b(r){var n={},t={$or:!0,$nor:!0};return r.forEach(function(e){Object.keys(e).forEach(function(f){var u=e[f];if(typeof u!="object"&&(u={$eq:u}),G(f))if(u instanceof Array){if(t[f]){t[f]=!1,n[f]=u;return}var i=[];n[f].forEach(function(o){Object.keys(u).forEach(function(c){var v=u[c],p=Math.max(Object.keys(o).length,Object.keys(v).length),w=b([o,v]);Object.keys(w).length<=p||i.push(w)})}),n[f]=i}else n[f]=b([u]);else{var a=n[f]=n[f]||{};Object.keys(u).forEach(function(o){var c=u[o];if(o==="$gt"||o==="$gte")return K(o,c,a);if(o==="$lt"||o==="$lte")return D(o,c,a);if(o==="$ne")return F(c,a);if(o==="$eq")return d(c,a);if(o==="$regex")return M(c,a);a[o]=c})}})}),n}function K(r,n,t){typeof t.$eq<"u"||(typeof t.$gte<"u"?r==="$gte"?n>t.$gte&&(t.$gte=n):n>=t.$gte&&(delete t.$gte,t.$gt=n):typeof t.$gt<"u"?r==="$gte"?n>t.$gt&&(delete t.$gt,t.$gte=n):n>t.$gt&&(t.$gt=n):t[r]=n)}function D(r,n,t){typeof t.$eq<"u"||(typeof t.$lte<"u"?r==="$lte"?n<t.$lte&&(t.$lte=n):n<=t.$lte&&(delete t.$lte,t.$lt=n):typeof t.$lt<"u"?r==="$lte"?n<t.$lt&&(delete t.$lt,t.$lte=n):n<t.$lt&&(t.$lt=n):t[r]=n)}function F(r,n){"$ne"in n?n.$ne.push(r):n.$ne=[r]}function d(r,n){delete n.$gt,delete n.$gte,delete n.$lt,delete n.$lte,delete n.$ne,n.$eq=r}function M(r,n){"$regex"in n?n.$regex.push(r):n.$regex=[r]}function T(r){for(var n in r){if(Array.isArray(r))for(var t in r)r[t].$and&&(r[t]=b(r[t].$and));var e=r[n];typeof e=="object"&&T(e)}return r}function _(r,n){for(var t in r){t==="$and"&&(n=!0);var e=r[t];typeof e=="object"&&(n=_(e,n))}return n}function V(r){var n=q(r);_(n,!1)&&(n=T(n),"$and"in n&&(n=b(n.$and))),["$or","$nor"].forEach(function(i){i in n&&n[i].forEach(function(a){for(var o=Object.keys(a),c=0;c<o.length;c++){var v=o[c],p=a[v];(typeof p!="object"||p===null)&&(a[v]={$eq:p})}})}),"$not"in n&&(n.$not=b([n.$not]));for(var t=Object.keys(n),e=0;e<t.length;e++){var f=t[e],u=n[f];(typeof u!="object"||u===null)&&(u={$eq:u}),n[f]=u}return O(n),n}function O(r){Object.keys(r).forEach(function(n){var t=r[n];Array.isArray(t)?t.forEach(function(e){e&&typeof e=="object"&&O(e)}):n==="$ne"?r.$ne=[t]:n==="$regex"?r.$regex=[t]:t&&typeof t=="object"&&O(t)})}function nn(r){function n(t){return r.map(function(e){var f=L(e),u=E(f),i=I(t,u);return i})}return function(t,e){var f=n(t.doc),u=n(e.doc),i=s(f,u);return i!==0?i:Y(t.doc._id,e.doc._id)}}function rn(r,n,t){if(r=r.filter(function(i){return g(i.doc,n.selector,t)}),n.sort){var e=nn(n.sort);r=r.sort(e),typeof n.sort[0]!="string"&&k(n.sort[0])==="desc"&&(r=r.reverse())}if("limit"in n||"skip"in n){var f=n.skip||0,u=("limit"in n?n.limit:r.length)+f;r=r.slice(f,u)}return r}function g(r,n,t){return t.every(function(e){var f=n[e],u=E(e),i=I(r,u);return G(e)?en(e,f,r):h(f,r,u,i)})}function h(r,n,t,e){return r?typeof r=="object"?Object.keys(r).every(function(f){var u=r[f];if(f.indexOf("$")===0)return C(f,n,u,t,e);var i=E(f);if(e===void 0&&typeof u!="object"&&i.length>0)return!1;var a=I(e,i);return typeof u=="object"?h(u,n,t,a):C("$eq",n,u,i,a)}):r===e:!0}function en(r,n,t){return r==="$or"?n.some(function(e){return g(t,e,Object.keys(e))}):r==="$not"?!g(t,n,Object.keys(n)):!n.find(function(e){return g(t,e,Object.keys(e))})}function C(r,n,t,e,f){if(!z[r])throw new Error('unknown operator "'+r+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return z[r](n,t,e,f)}function l(r){return typeof r<"u"&&r!==null}function $(r){return typeof r<"u"}function tn(r,n){if(typeof r!="number"||parseInt(r,10)!==r)return!1;var t=n[0],e=n[1];return r%t===e}function N(r,n){return n.some(function(t){return r instanceof Array?r.some(function(e){return s(t,e)===0}):s(t,r)===0})}function fn(r,n){return n.every(function(t){return r.some(function(e){return s(t,e)===0})})}function un(r,n){return r.length===n}function on(r,n){var t=new RegExp(n);return t.test(r)}function an(r,n){switch(n){case"null":return r===null;case"boolean":return typeof r=="boolean";case"number":return typeof r=="number";case"string":return typeof r=="string";case"array":return r instanceof Array;case"object":return{}.toString.call(r)==="[object Object]"}}var z={$elemMatch:function(r,n,t,e){return!Array.isArray(e)||e.length===0?!1:typeof e[0]=="object"&&e[0]!==null?e.some(function(f){return g(f,n,Object.keys(n))}):e.some(function(f){return h(n,r,t,f)})},$allMatch:function(r,n,t,e){return!Array.isArray(e)||e.length===0?!1:typeof e[0]=="object"&&e[0]!==null?e.every(function(f){return g(f,n,Object.keys(n))}):e.every(function(f){return h(n,r,t,f)})},$eq:function(r,n,t,e){return $(e)&&s(e,n)===0},$gte:function(r,n,t,e){return $(e)&&s(e,n)>=0},$gt:function(r,n,t,e){return $(e)&&s(e,n)>0},$lte:function(r,n,t,e){return $(e)&&s(e,n)<=0},$lt:function(r,n,t,e){return $(e)&&s(e,n)<0},$exists:function(r,n,t,e){return n?$(e):!$(e)},$mod:function(r,n,t,e){return l(e)&&tn(e,n)},$ne:function(r,n,t,e){return n.every(function(f){return s(e,f)!==0})},$in:function(r,n,t,e){return l(e)&&N(e,n)},$nin:function(r,n,t,e){return l(e)&&!N(e,n)},$size:function(r,n,t,e){return l(e)&&Array.isArray(e)&&un(e,n)},$all:function(r,n,t,e){return Array.isArray(e)&&fn(e,n)},$regex:function(r,n,t,e){return l(e)&&typeof e=="string"&&n.every(function(f){return on(e,f)})},$type:function(r,n,t,e){return an(e,n)}};function pn(r,n){if(typeof n!="object")throw new Error("Selector error: expected a JSON object");n=V(n);var t={doc:r},e=rn([t],{selector:n},Object.keys(n));return e&&e.length===1}export{V as a,rn as b,s as c,Y as d,E as e,sn as f,k as g,$n as h,I as i,L as j,pn as m,y as n,gn as p,vn as s,j as t};