blockstore-core
Advanced tools
Comparing version 4.2.0 to 4.3.0
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.BlockstoreCore = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var BlockstoreCore=(()=>{var me=Object.create;var V=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var Ee=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),K=(r,e)=>{for(var t in e)V(r,t,{get:e[t],enumerable:!0})},W=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ge(e))!ve.call(r,o)&&o!==t&&V(r,o,{get:()=>e[o],enumerable:!(n=ye(e,o))||n.enumerable});return r};var Ae=(r,e,t)=>(t=r!=null?me(xe(r)):{},W(e||!r||!r.__esModule?V(t,"default",{value:r,enumerable:!0}):t,r)),Se=r=>W(V({},"__esModule",{value:!0}),r);var ee=Ee((ft,Y)=>{"use strict";function Z(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Ue(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Z(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Z(new o,t)}}Y.exports=Ue});var dt={};K(dt,{BaseBlockstore:()=>F,Errors:()=>ct,MemoryBlockstore:()=>$});var B={};K(B,{abortedError:()=>Re,closeFailedError:()=>Oe,deleteFailedError:()=>De,getFailedError:()=>Fe,hasFailedError:()=>Me,notFoundError:()=>j,openFailedError:()=>ze,putFailedError:()=>Ce});var E=Ae(ee(),1);function ze(r){return r=r??new Error("Open failed"),(0,E.default)(r,"ERR_OPEN_FAILED")}function Oe(r){return r=r??new Error("Close failed"),(0,E.default)(r,"ERR_CLOSE_FAILED")}function Ce(r){return r=r??new Error("Put failed"),(0,E.default)(r,"ERR_PUT_FAILED")}function Fe(r){return r=r??new Error("Get failed"),(0,E.default)(r,"ERR_GET_FAILED")}function De(r){return r=r??new Error("Delete failed"),(0,E.default)(r,"ERR_DELETE_FAILED")}function Me(r){return r=r??new Error("Has failed"),(0,E.default)(r,"ERR_HAS_FAILED")}function j(r){return r=r??new Error("Not Found"),(0,E.default)(r,"ERR_NOT_FOUND")}function Re(r){return r=r??new Error("Aborted"),(0,E.default)(r,"ERR_ABORTED")}var F=class{has(e,t){return Promise.reject(new Error(".has is not implemented"))}put(e,t,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,t){for await(let{cid:n,block:o}of e)await this.put(n,o,t),yield n}get(e,t){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,t){for await(let n of e)yield{cid:n,block:await this.get(n,t)}}async delete(e,t){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,t){for await(let n of e)await this.delete(n,t),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};function Le(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,h=r.charAt(0),O=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function C(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var f=0,U=0,u=0,m=a.length;u!==m&&a[u]===0;)u++,f++;for(var y=(m-u)*p+1>>>0,l=new Uint8Array(y);u!==m;){for(var g=a[u],S=0,w=y-1;(g!==0||S<U)&&w!==-1;w--,S++)g+=256*l[w]>>>0,l[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");U=S,u++}for(var v=y-U;v!==y&&l[v]===0;)v++;for(var I=h.repeat(f);v<y;++v)I+=r.charAt(l[v]);return I}function T(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var f=0;if(a[f]!==" "){for(var U=0,u=0;a[f]===h;)U++,f++;for(var m=(a.length-f)*O+1>>>0,y=new Uint8Array(m);a[f];){var l=t[a.charCodeAt(f)];if(l===255)return;for(var g=0,S=m-1;(l!==0||g<u)&&S!==-1;S--,g++)l+=c*y[S]>>>0,y[S]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");u=g,f++}if(a[f]!==" "){for(var w=m-u;w!==m&&y[w]===0;)w++;for(var v=new Uint8Array(U+(m-w)),I=U;w!==m;)v[I++]=y[w++];return v}}}function be(a){var f=T(a);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:T,decode:be}}var Ne=Le,ke=Ne,te=ke;var ut=new Uint8Array(0);var re=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},z=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var q=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},_=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ne(this,e)}},J=class{constructor(e){this.decoders=e}or(e){return ne(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},ne=(r,e)=>new J({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),G=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new q(e,t,n),this.decoder=new _(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},oe=({name:r,prefix:e,encode:t,decode:n})=>new G(r,e,t,n),Q=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=te(t,e);return oe({prefix:r,name:e,encode:n,decode:s=>z(o(s))})},Te=(r,e,t,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,h=0,O=0;for(let p=0;p<s;++p){let C=o[r[p]];if(C===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|C,c+=t,c>=8&&(c-=8,i[O++]=255&h>>c)}if(c>=t||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return i},Ie=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let h=0;h<r.length;++h)for(c=c<<8|r[h],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},x=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>oe({prefix:e,name:r,encode(o){return Ie(o,n,t)},decode(o){return Te(o,n,t,r)}});var b=x({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xt=x({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vt=x({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Et=x({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),At=x({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),St=x({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ut=x({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zt=x({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ot=x({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ve=ae,se=128,Be=127,Pe=~Be,$e=Math.pow(2,31);function ae(r,e,t){e=e||[],t=t||0;for(var n=t;r>=$e;)e[t++]=r&255|se,r/=128;for(;r&Pe;)e[t++]=r&255|se,r>>>=7;return e[t]=r|0,ae.bytes=t-n+1,e}var je=X,qe=128,ie=127;function X(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw X.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&ie)<<o:(i&ie)*Math.pow(2,o),o+=7}while(i>=qe);return X.bytes=s-n,t}var _e=Math.pow(2,7),Je=Math.pow(2,14),Ge=Math.pow(2,21),Qe=Math.pow(2,28),Xe=Math.pow(2,35),He=Math.pow(2,42),Ke=Math.pow(2,49),We=Math.pow(2,56),Ze=Math.pow(2,63),Ye=function(r){return r<_e?1:r<Je?2:r<Ge?3:r<Qe?4:r<Xe?5:r<He?6:r<Ke?7:r<We?8:r<Ze?9:10},et={encode:Ve,decode:je,encodingLength:Ye},tt=et,L=tt;var N=(r,e=0)=>[L.decode(r,e),L.decode.bytes],D=(r,e,t=0)=>(L.encode(r,e,t),e),M=r=>L.encodingLength(r);var de=(r,e)=>{let t=e.byteLength,n=M(r),o=n+M(t),s=new Uint8Array(o+t);return D(r,s,0),D(t,s,n),s.set(e,o),new R(r,t,e,s)},P=r=>{let e=z(r),[t,n]=N(e),[o,s]=N(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new R(t,o,i,e)},he=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&re(r.bytes,t.bytes)}},R=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var A=Q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lt=Q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var pe=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return nt(t,H(r),e||A.encoder);default:return ot(t,H(r),e||b.encoder)}};var le=new WeakMap,H=r=>{let e=le.get(r);if(e==null){let t=new Map;return le.set(r,t),t}return e},d=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==k)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==st)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return d.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=de(e,t);return d.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return d.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&he(e.multihash,n.multihash)}toString(e){return pe(this,e)}toJSON(){return{"/":pe(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof d)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new d(n,o,s,i||ue(n,o,s.bytes))}else if(t[it]===!0){let{version:n,multihash:o,code:s}=t,i=P(o);return d.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==k)throw new Error(`Version 0 CID must use dag-pb (code: ${k}) block encoding`);return new d(e,t,n,n.bytes)}case 1:{let o=ue(e,t,n.bytes);return new d(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return d.create(0,k,e)}static createV1(e,t){return d.create(1,e,t)}static decode(e){let[t,n]=d.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=d.inspectBytes(e),n=t.size-t.multihashSize,o=z(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new R(t.multihashCode,t.digestSize,s,o);return[t.version===0?d.createV0(i):d.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[C,T]=N(e.subarray(t));return t+=T,C},o=n(),s=k;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),h=n(),O=t+h,p=O-i;return{version:o,codec:s,multihashCode:c,digestSize:h,multihashSize:p,size:O}}static parse(e,t){let[n,o]=rt(e,t),s=d.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return H(s).set(n,e),s}},rt=(r,e)=>{switch(r[0]){case"Q":{let t=e||A;return[A.prefix,t.decode(`${A.prefix}${r}`)]}case A.prefix:{let t=e||A;return[A.prefix,t.decode(r)]}case b.prefix:{let t=e||b;return[b.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},nt=(r,e,t)=>{let{prefix:n}=t;if(n!==A.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},ot=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},k=112,st=18,ue=(r,e,t)=>{let n=M(r),o=n+M(e),s=new Uint8Array(o+t.byteLength);return D(r,s,0),D(e,s,n),s.set(t,o),s},it=Symbol.for("@ipld/js-cid/CID");var we=85;var $=class extends F{data;constructor(){super(),this.data=new Map}put(e,t){return this.data.set(b.encode(e.multihash.bytes),t),e}get(e){let t=this.data.get(b.encode(e.multihash.bytes));if(t==null)throw j();return t}has(e){return this.data.has(b.encode(e.multihash.bytes))}async delete(e){this.data.delete(b.encode(e.multihash.bytes))}async*getAll(){for(let[e,t]of this.data.entries())yield{cid:d.createV1(we,P(b.decode(e))),block:t}}};var ct={...B};return Se(dt);})(); | ||
"use strict";var BlockstoreCore=(()=>{var Qe=Object.create;var Z=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),be=(r,e)=>{for(var t in e)Z(r,t,{get:e[t],enumerable:!0})},ye=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ze(e))!Ke.call(r,o)&&o!==t&&Z(r,o,{get:()=>e[o],enumerable:!(n=Xe(e,o))||n.enumerable});return r};var we=(r,e,t)=>(t=r!=null?Qe(He(r)):{},ye(e||!r||!r.__esModule?Z(t,"default",{value:r,enumerable:!0}):t,r)),We=r=>ye(Z({},"__esModule",{value:!0}),r);var Ce=H((sr,xe)=>{"use strict";function ge(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Ye(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return ge(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),ge(new o,t)}}xe.exports=Ye});var Te=H((Vr,Pe)=>{var V=1e3,$=V*60,_=$*60,D=_*24,Nt=D*7,Dt=D*365.25;Pe.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Rt(r);if(t==="number"&&isFinite(r))return e.long?Tt(r):Pt(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Rt(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Dt;case"weeks":case"week":case"w":return t*Nt;case"days":case"day":case"d":return t*D;case"hours":case"hour":case"hrs":case"hr":case"h":return t*_;case"minutes":case"minute":case"mins":case"min":case"m":return t*$;case"seconds":case"second":case"secs":case"sec":case"s":return t*V;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Pt(r){var e=Math.abs(r);return e>=D?Math.round(r/D)+"d":e>=_?Math.round(r/_)+"h":e>=$?Math.round(r/$)+"m":e>=V?Math.round(r/V)+"s":r+"ms"}function Tt(r){var e=Math.abs(r);return e>=D?ee(r,e,D,"day"):e>=_?ee(r,e,_,"hour"):e>=$?ee(r,e,$,"minute"):e>=V?ee(r,e,V,"second"):r+" ms"}function ee(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var Be=H(($r,je)=>{function jt(r){t.debug=t,t.default=t,t.coerce=w,t.disable=s,t.enable=o,t.enabled=a,t.humanize=Te(),t.destroy=M,Object.keys(r).forEach(i=>{t[i]=r[i]}),t.names=[],t.skips=[],t.formatters={};function e(i){let l=0;for(let h=0;h<i.length;h++)l=(l<<5)-l+i.charCodeAt(h),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(i){let l,h=null,O,d;function f(...c){if(!f.enabled)return;let p=f,m=Number(new Date),y=m-(l||m);p.diff=y,p.prev=l,p.curr=m,l=m,c[0]=t.coerce(c[0]),typeof c[0]!="string"&&c.unshift("%O");let g=0;c[0]=c[0].replace(/%([a-zA-Z%])/g,(S,v)=>{if(S==="%%")return"%";g++;let k=t.formatters[v];if(typeof k=="function"){let R=c[g];S=k.call(p,R),c.splice(g,1),g--}return S}),t.formatArgs.call(p,c),(p.log||t.log).apply(p,c)}return f.namespace=i,f.useColors=t.useColors(),f.color=t.selectColor(i),f.extend=n,f.destroy=t.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(O!==t.namespaces&&(O=t.namespaces,d=t.enabled(i)),d),set:c=>{h=c}}),typeof t.init=="function"&&t.init(f),f}function n(i,l){let h=t(this.namespace+(typeof l>"u"?":":l)+i);return h.log=this.log,h}function o(i){t.save(i),t.namespaces=i,t.names=[],t.skips=[];let l,h=(typeof i=="string"?i:"").split(/[\s,]+/),O=h.length;for(l=0;l<O;l++)h[l]&&(i=h[l].replace(/\*/g,".*?"),i[0]==="-"?t.skips.push(new RegExp("^"+i.slice(1)+"$")):t.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...t.names.map(u),...t.skips.map(u).map(l=>"-"+l)].join(",");return t.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l<h;l++)if(t.skips[l].test(i))return!1;for(l=0,h=t.names.length;l<h;l++)if(t.names[l].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function w(i){return i instanceof Error?i.stack||i.message:i}function M(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}je.exports=jt});var Ve=H((F,te)=>{F.formatArgs=Vt;F.save=$t;F.load=_t;F.useColors=Bt;F.storage=qt();F.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();F.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Bt(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Vt(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+te.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}F.log=console.debug||console.log||(()=>{});function $t(r){try{r?F.storage.setItem("debug",r):F.storage.removeItem("debug")}catch{}}function _t(){let r;try{r=F.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function qt(){try{return localStorage}catch{}}te.exports=Be()(F);var{formatters:Jt}=te.exports;Jt.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var nr={};be(nr,{BaseBlockstore:()=>I,BlackHoleBlockstore:()=>Y,Errors:()=>rr,MemoryBlockstore:()=>W,TieredBlockstore:()=>oe});var P={};be(P,{abortedError:()=>ot,closeFailedError:()=>tt,deleteFailedError:()=>ie,getFailedError:()=>rt,hasFailedError:()=>nt,notFoundError:()=>U,openFailedError:()=>et,putFailedError:()=>se});var L=we(Ce(),1);function et(r){return r=r??new Error("Open failed"),(0,L.default)(r,"ERR_OPEN_FAILED")}function tt(r){return r=r??new Error("Close failed"),(0,L.default)(r,"ERR_CLOSE_FAILED")}function se(r){return r=r??new Error("Put failed"),(0,L.default)(r,"ERR_PUT_FAILED")}function rt(r){return r=r??new Error("Get failed"),(0,L.default)(r,"ERR_GET_FAILED")}function ie(r){return r=r??new Error("Delete failed"),(0,L.default)(r,"ERR_DELETE_FAILED")}function nt(r){return r=r??new Error("Has failed"),(0,L.default)(r,"ERR_HAS_FAILED")}function U(r){return r=r??new Error("Not Found"),(0,L.default)(r,"ERR_NOT_FOUND")}function ot(r){return r=r??new Error("Aborted"),(0,L.default)(r,"ERR_ABORTED")}var I=class{has(e,t){return Promise.reject(new Error(".has is not implemented"))}put(e,t,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,t){for await(let{cid:n,block:o}of e)await this.put(n,o,t),yield n}get(e,t){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,t){for await(let n of e)yield{cid:n,block:await this.get(n,t)}}async delete(e,t){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,t){for await(let n of e)await this.delete(n,t),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};function st(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var u=r.length,w=r.charAt(0),M=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var f=0,c=0,p=0,m=d.length;p!==m&&d[p]===0;)p++,f++;for(var y=(m-p)*i+1>>>0,g=new Uint8Array(y);p!==m;){for(var C=d[p],S=0,v=y-1;(C!==0||S<c)&&v!==-1;v--,S++)C+=256*g[v]>>>0,g[v]=C%u>>>0,C=C/u>>>0;if(C!==0)throw new Error("Non-zero carry");c=S,p++}for(var k=y-c;k!==y&&g[k]===0;)k++;for(var R=w.repeat(f);k<y;++k)R+=r.charAt(g[k]);return R}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var f=0;if(d[f]!==" "){for(var c=0,p=0;d[f]===w;)c++,f++;for(var m=(d.length-f)*M+1>>>0,y=new Uint8Array(m);d[f];){var g=t[d.charCodeAt(f)];if(g===255)return;for(var C=0,S=m-1;(g!==0||C<p)&&S!==-1;S--,C++)g+=u*y[S]>>>0,y[S]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");p=C,f++}if(d[f]!==" "){for(var v=m-p;v!==m&&y[v]===0;)v++;for(var k=new Uint8Array(c+(m-v)),R=c;v!==m;)k[R++]=y[v++];return k}}}function O(d){var f=h(d);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:O}}var it=st,at=it,ve=at;var cr=new Uint8Array(0);var Ee=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},N=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var ae=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ce=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Fe(this,e)}},ue=class{constructor(e){this.decoders=e}or(e){return Fe(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Fe=(r,e)=>new ue({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),le=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ae(e,t,n),this.decoder=new ce(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ae=({name:r,prefix:e,encode:t,decode:n})=>new le(r,e,t,n),fe=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ve(t,e);return Ae({prefix:r,name:e,encode:n,decode:s=>N(o(s))})},ct=(r,e,t,n)=>{let o={};for(let i=0;i<e.length;++i)o[e[i]]=i;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),u=0,w=0,M=0;for(let i=0;i<s;++i){let l=o[r[i]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);w=w<<t|l,u+=t,u>=8&&(u-=8,a[M++]=255&w>>u)}if(u>=t||255&w<<8-u)throw new SyntaxError("Unexpected end of data");return a},ut=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,u=0;for(let w=0;w<r.length;++w)for(u=u<<8|r[w],a+=8;a>t;)a-=t,s+=e[o&u>>a];if(a&&(s+=e[o&u<<t-a]),n)for(;s.length*t&7;)s+="=";return s},x=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Ae({prefix:e,name:r,encode(o){return ut(o,n,t)},decode(o){return ct(o,n,t,r)}});var E=x({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pr=x({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=x({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),br=x({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yr=x({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wr=x({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gr=x({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=x({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cr=x({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var lt=Me,Se=128,ft=127,dt=~ft,ht=Math.pow(2,31);function Me(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ht;)e[t++]=r&255|Se,r/=128;for(;r&dt;)e[t++]=r&255|Se,r>>>=7;return e[t]=r|0,Me.bytes=t-n+1,e}var pt=de,mt=128,ke=127;function de(r,n){var t=0,n=n||0,o=0,s=n,a,u=r.length;do{if(s>=u)throw de.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=o<28?(a&ke)<<o:(a&ke)*Math.pow(2,o),o+=7}while(a>=mt);return de.bytes=s-n,t}var bt=Math.pow(2,7),yt=Math.pow(2,14),wt=Math.pow(2,21),gt=Math.pow(2,28),xt=Math.pow(2,35),Ct=Math.pow(2,42),vt=Math.pow(2,49),Et=Math.pow(2,56),Ft=Math.pow(2,63),At=function(r){return r<bt?1:r<yt?2:r<wt?3:r<gt?4:r<xt?5:r<Ct?6:r<vt?7:r<Et?8:r<Ft?9:10},St={encode:lt,decode:pt,encodingLength:At},kt=St,J=kt;var G=(r,e=0)=>[J.decode(r,e),J.decode.bytes],T=(r,e,t=0)=>(J.encode(r,e,t),e),j=r=>J.encodingLength(r);var Ie=(r,e)=>{let t=e.byteLength,n=j(r),o=n+j(t),s=new Uint8Array(o+t);return T(r,s,0),T(t,s,n),s.set(e,o),new B(r,t,e,s)},K=r=>{let e=N(r),[t,n]=G(e),[o,s]=G(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new B(t,o,a,e)},Le=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ee(r.bytes,t.bytes)}},B=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var z=fe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kr=fe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ue=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return zt(t,he(r),e||z.encoder);default:return It(t,he(r),e||E.encoder)}};var Ne=new WeakMap,he=r=>{let e=Ne.get(r);if(e==null){let t=new Map;return Ne.set(r,t),t}return e},b=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Q)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Lt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return b.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ie(e,t);return b.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return b.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Le(e.multihash,n.multihash)}toString(e){return Ue(this,e)}toJSON(){return{"/":Ue(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof b)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new b(n,o,s,a||De(n,o,s.bytes))}else if(t[Ot]===!0){let{version:n,multihash:o,code:s}=t,a=K(o);return b.create(n,s,a)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Q)throw new Error(`Version 0 CID must use dag-pb (code: ${Q}) block encoding`);return new b(e,t,n,n.bytes)}case 1:{let o=De(e,t,n.bytes);return new b(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return b.create(0,Q,e)}static createV1(e,t){return b.create(1,e,t)}static decode(e){let[t,n]=b.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=b.inspectBytes(e),n=t.size-t.multihashSize,o=N(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new B(t.multihashCode,t.digestSize,s,o);return[t.version===0?b.createV0(a):b.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,h]=G(e.subarray(t));return t+=h,l},o=n(),s=Q;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,u=n(),w=n(),M=t+w,i=M-a;return{version:o,codec:s,multihashCode:u,digestSize:w,multihashSize:i,size:M}}static parse(e,t){let[n,o]=Mt(e,t),s=b.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return he(s).set(n,e),s}},Mt=(r,e)=>{switch(r[0]){case"Q":{let t=e||z;return[z.prefix,t.decode(`${z.prefix}${r}`)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}case E.prefix:{let t=e||E;return[E.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},zt=(r,e,t)=>{let{prefix:n}=t;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},It=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Q=112,Lt=18,De=(r,e,t)=>{let n=j(r),o=n+j(e),s=new Uint8Array(o+t.byteLength);return T(r,s,0),T(e,s,n),s.set(t,o),s},Ot=Symbol.for("@ipld/js-cid/CID");var Re=85;var W=class extends I{data;constructor(){super(),this.data=new Map}put(e,t){return this.data.set(E.encode(e.multihash.bytes),t),e}get(e){let t=this.data.get(E.encode(e.multihash.bytes));if(t==null)throw U();return t}has(e){return this.data.has(E.encode(e.multihash.bytes))}async delete(e){this.data.delete(E.encode(e.multihash.bytes))}async*getAll(){for(let[e,t]of this.data.entries())yield{cid:b.createV1(Re,K(E.decode(e))),block:t}}};var Y=class extends I{put(e){return e}get(){throw U()}has(){return!1}async delete(){}async*getAll(){}};var A=we(Ve(),1);var $e=x({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qr=x({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jr=x({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gr=x({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});A.default.formatters.b=r=>r==null?"undefined":z.baseEncode(r);A.default.formatters.t=r=>r==null?"undefined":E.baseEncode(r);A.default.formatters.m=r=>r==null?"undefined":$e.baseEncode(r);A.default.formatters.p=r=>r==null?"undefined":r.toString();A.default.formatters.c=r=>r==null?"undefined":r.toString();A.default.formatters.k=r=>r==null?"undefined":r.toString();A.default.formatters.a=r=>r==null?"undefined":r.toString();function Gt(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function _e(r){let e=Gt(`${r}:trace`);return A.default.enabled(`${r}:trace`)&&A.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,A.default)(`${r}:trace`)),Object.assign((0,A.default)(r),{error:(0,A.default)(`${r}:error`),trace:e})}function Qt(r){return r[Symbol.asyncIterator]!=null}function Xt(r){if(Qt(r))return(async()=>{for await(let e of r);})();for(let e of r);}var pe=Xt;function Zt(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var qe=Zt;function Ht(r){return r[Symbol.asyncIterator]!=null}function Kt(r,e){if(Ht(r))return async function*(){for await(let u of r)await e(u)&&(yield u)}();let t=qe(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let u of t)await e(u)&&(yield u)}();let a=e;return function*(){s===!0&&(yield n);for(let u of t)a(u)&&(yield u)}()}var Je=Kt;function re(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ne=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},q=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new ne(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new ne(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var me=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function X(r={}){return Wt(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Wt(r,e){e=e??{};let t=e.onEnd,n=new q,o,s,a,u=re(),w=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((c,p)=>{s=m=>{s=null,n.push(m);try{c(r(n))}catch(y){p(y)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=re()})}},M=c=>s!=null?s(c):(n.push(c),o),i=c=>(n=new q,s!=null?s({error:c}):(n.push({error:c}),o)),l=c=>{if(a)return o;if(e?.objectMode!==!0&&c?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return M({done:!1,value:c})},h=c=>a?o:(a=!0,c!=null?i(c):M({done:!0})),O=()=>(n=new q,h(),{done:!0}),d=c=>(h(c),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:w,return:O,throw:d,push:l,end:h,get readableLength(){return n.size},onEmpty:async c=>{let p=c?.signal;if(p?.throwIfAborted(),n.isEmpty())return;let m,y;p!=null&&(m=new Promise((g,C)=>{y=()=>{C(new me)},p.addEventListener("abort",y)}));try{await Promise.race([u.promise,m])}finally{y!=null&&p!=null&&p?.removeEventListener("abort",y)}}},t==null)return o;let f=o;return o={[Symbol.asyncIterator](){return this},next(){return f.next()},throw(c){return f.throw(c),t!=null&&(t(c),t=void 0),{done:!0}},return(){return f.return(),t!=null&&(t(),t=void 0),{done:!0}},push:l,end(c){return f.end(c),t!=null&&(t(c),t=void 0),o},get readableLength(){return f.readableLength}},o}function Yt(r){return r[Symbol.asyncIterator]!=null}function er(...r){let e=[];for(let t of r)Yt(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=X({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var Ge=er;var tr=_e("blockstore:core:tiered"),oe=class extends I{stores;constructor(e){super(),this.stores=e.slice()}async put(e,t,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(e,t,n)})),e}catch(o){throw se(o)}}async get(e,t){for(let n of this.stores)try{let o=await n.get(e,t);if(o!=null)return o}catch(o){tr.error(o)}throw U()}async has(e,t){for(let n of this.stores)if(await n.has(e,t))return!0;return!1}async delete(e,t){try{await Promise.all(this.stores.map(async n=>{await n.delete(e,t)}))}catch(n){throw ie(n)}}async*putMany(e,t={}){let n,o=this.stores.map(s=>{let a=X({objectMode:!0});return pe(s.putMany(a,t)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s.cid}}finally{o.forEach(s=>s.end())}}async*deleteMany(e,t={}){let n,o=this.stores.map(s=>{let a=X({objectMode:!0});return pe(s.deleteMany(a,t)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s}}finally{o.forEach(s=>s.end())}}async*getAll(e){let t=new Set;yield*Je(Ge(...this.stores.map(n=>n.getAll(e))),n=>{let o=n.cid.toString();return t.has(o)?!1:(t.add(o),!0)})}};var rr={...P};return We(nr);})(); | ||
return BlockstoreCore})); |
export { BaseBlockstore } from './base.js'; | ||
export { MemoryBlockstore } from './memory.js'; | ||
export { BlackHoleBlockstore } from './black-hole.js'; | ||
export { TieredBlockstore } from './tiered.js'; | ||
export declare const Errors: { | ||
@@ -4,0 +6,0 @@ openFailedError(err?: Error | undefined): Error; |
import * as ErrorsImport from './errors.js'; | ||
export { BaseBlockstore } from './base.js'; | ||
export { MemoryBlockstore } from './memory.js'; | ||
export { BlackHoleBlockstore } from './black-hole.js'; | ||
export { TieredBlockstore } from './tiered.js'; | ||
export const Errors = { | ||
@@ -5,0 +7,0 @@ ...ErrorsImport |
@@ -13,3 +13,4 @@ { | ||
"Errors": "https://ipfs.github.io/js-stores/variables/index.Errors.html", | ||
"MemoryBlockstore": "https://ipfs.github.io/js-stores/classes/memory.MemoryBlockstore.html" | ||
"MemoryBlockstore": "https://ipfs.github.io/js-stores/classes/memory.MemoryBlockstore.html", | ||
"TieredBlockstore": "https://ipfs.github.io/js-stores/classes/tiered.TieredBlockstore.html" | ||
} |
{ | ||
"name": "blockstore-core", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "Contains various implementations of the API contract described in interface-blockstore", | ||
@@ -69,2 +69,6 @@ "author": "Alex Potsides <alex.potsides@protocol.ai>", | ||
"import": "./dist/src/memory.js" | ||
}, | ||
"./tiered": { | ||
"types": "./dist/src/tiered.d.ts", | ||
"import": "./dist/src/tiered.js" | ||
} | ||
@@ -179,6 +183,12 @@ }, | ||
"dependencies": { | ||
"@libp2p/logger": "^2.0.0", | ||
"err-code": "^3.0.1", | ||
"interface-blockstore": "^5.0.0", | ||
"interface-store": "^5.0.0", | ||
"multiformats": "^11.0.2" | ||
"it-drain": "^3.0.1", | ||
"it-filter": "^3.0.0", | ||
"it-merge": "^3.0.1", | ||
"it-pushable": "^3.0.0", | ||
"multiformats": "^11.0.2", | ||
"uint8arrays": "^4.0.2" | ||
}, | ||
@@ -185,0 +195,0 @@ "devDependencies": { |
@@ -19,2 +19,3 @@ # blockstore-core <!-- omit in toc --> | ||
- [BlackHoleBlockstore](#blackholeblockstore) | ||
- [TieredBlockstore](#tieredblockstore) | ||
- [API Docs](#api-docs) | ||
@@ -42,3 +43,4 @@ - [License](#license) | ||
- Memory: [`src/memory`](src/memory.ts) | ||
- BlackHole: ['src/blackhole](src/blackhole.ts) | ||
- BlackHole: ['src/black-hole](src/black-hole.ts) | ||
- Tiered: ['src/tiered](src/tiered.ts) | ||
@@ -87,2 +89,18 @@ ## Usage | ||
### TieredBlockstore | ||
A tiered blockstore wraps one or more blockstores and will query each in parallel to retrieve a block - the operation will succeed if any wrapped store has the block. | ||
Writes are invoked on all wrapped blockstores. | ||
```js | ||
import { TieredBlockstore } from 'blockstore-core/tiered' | ||
const store = new TieredBlockstore([ | ||
store1, | ||
store2, | ||
// ...etc | ||
]) | ||
``` | ||
## API Docs | ||
@@ -89,0 +107,0 @@ |
@@ -5,2 +5,4 @@ import * as ErrorsImport from './errors.js' | ||
export { MemoryBlockstore } from './memory.js' | ||
export { BlackHoleBlockstore } from './black-hole.js' | ||
export { TieredBlockstore } from './tiered.js' | ||
@@ -7,0 +9,0 @@ export const Errors = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70212
35
722
125
10
+ Added@libp2p/logger@^2.0.0
+ Addedit-drain@^3.0.1
+ Addedit-filter@^3.0.0
+ Addedit-merge@^3.0.1
+ Addedit-pushable@^3.0.0
+ Addeduint8arrays@^4.0.2
+ Added@chainsafe/is-ip@2.0.2(transitive)
+ Added@chainsafe/netmask@2.0.0(transitive)
+ Added@leichtgewicht/ip-codec@2.0.5(transitive)
+ Added@libp2p/interface-peer-id@2.0.2(transitive)
+ Added@libp2p/logger@2.1.1(transitive)
+ Added@multiformats/dns@1.0.6(transitive)
+ Added@multiformats/multiaddr@12.3.4(transitive)
+ Added@types/dns-packet@5.6.5(transitive)
+ Added@types/node@22.10.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddns-packet@5.6.1(transitive)
+ Addedeventemitter3@5.0.1(transitive)
+ Addedhashlru@2.3.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinterface-datastore@8.3.1(transitive)
+ Addedit-drain@3.0.7(transitive)
+ Addedit-filter@3.1.1(transitive)
+ Addedit-merge@3.0.5(transitive)
+ Addedit-peekable@3.0.5(transitive)
+ Addedit-pushable@3.2.3(transitive)
+ Addedms@2.1.3(transitive)
+ Addedmultiformats@12.1.3(transitive)
+ Addedp-defer@4.0.1(transitive)
+ Addedp-queue@8.0.1(transitive)
+ Addedp-timeout@6.1.3(transitive)
+ Addedprogress-events@1.0.1(transitive)
+ Addeduint8-varint@2.0.4(transitive)
+ Addeduint8arraylist@2.4.8(transitive)
+ Addeduint8arrays@4.0.105.1.0(transitive)
+ Addedundici-types@6.20.0(transitive)