@reclaimprotocol/browser-extension-sdk
Version:
This guide will walk you through integrating the Reclaim Protocol Browser Extension SDK into your own browser extension or web application. It covers installation, manifest configuration, background initialization, content script setup, and how to trigg
2 lines • 8.18 kB
JavaScript
"use strict";(self.webpackChunk_reclaimprotocol_browser_extension_sdk=self.webpackChunk_reclaimprotocol_browser_extension_sdk||[]).push([[343],{30228:e=>{var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,s||e,o),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i<s;i++)o[i]=r[i].fn;return o},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,s,o){var a=n?n+e:e;if(!this._events[a])return!1;var u,c,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,r),!0;case 4:return h.fn.call(h.context,t,r,i),!0;case 5:return h.fn.call(h.context,t,r,i,s),!0;case 6:return h.fn.call(h.context,t,r,i,s,o),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var v,d=h.length;for(c=0;c<d;c++)switch(h[c].once&&this.removeListener(e,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,t);break;case 3:h[c].fn.call(h[c].context,t,r);break;case 4:h[c].fn.call(h[c].context,t,r,i);break;default:if(!u)for(v=1,u=new Array(l-1);v<l;v++)u[v-1]=arguments[v];h[c].fn.apply(h[c].context,u)}}return!0},a.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||o(this,s);else{for(var u=0,c=[],h=a.length;u<h;u++)(a[u].fn!==t||i&&!a[u].once||r&&a[u].context!==r)&&c.push(a[u]);c.length?this._events[s]=1===c.length?c[0]:c:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},38343:(e,t,n)=>{n.d(t,{default:()=>c});var r=n(30228);class i extends Error{constructor(e){super(e),this.name="TimeoutError"}}class s extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const o=e=>void 0===globalThis.DOMException?new s(e):new DOMException(e),a=e=>{const t=void 0===e.reason?o("This operation was aborted."):e.reason;return t instanceof Error?t:o(t)};class u{#e=[];enqueue(e,t){const n={priority:(t={priority:0,...t}).priority,id:t.id,run:e};if(0===this.size||this.#e[this.size-1].priority>=t.priority)return void this.#e.push(n);const r=function(e,t,n){let r=0,i=e.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;n(e[o],t)<=0?(r=++o,i-=s+1):i=s}return r}(this.#e,n,(e,t)=>t.priority-e.priority);this.#e.splice(r,0,n)}setPriority(e,t){const n=this.#e.findIndex(t=>t.id===e);if(-1===n)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);const[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}dequeue(){const e=this.#e.shift();return e?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}}class c extends r{#t;#n;#r=0;#i;#s;#o=0;#a;#u;#e;#c;#h=0;#l;#v;#d;#p=1n;timeout;constructor(e){if(super(),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:u,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#t=e.carryoverConcurrencyCount,this.#n=e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,this.#i=e.intervalCap,this.#s=e.interval,this.#e=new e.queueClass,this.#c=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#d=!0===e.throwOnTimeout,this.#v=!1===e.autoStart}get#f(){return this.#n||this.#r<this.#i}get#y(){return this.#h<this.#l}#m(){this.#h--,this.#I(),this.emit("next")}#w(){this.#g(),this.#C(),this.#u=void 0}get#b(){const e=Date.now();if(void 0===this.#a){const t=this.#o-e;if(!(t<0))return void 0===this.#u&&(this.#u=setTimeout(()=>{this.#w()},t)),!0;this.#r=this.#t?this.#h:0}return!1}#I(){if(0===this.#e.size)return this.#a&&clearInterval(this.#a),this.#a=void 0,this.emit("empty"),0===this.#h&&this.emit("idle"),!1;if(!this.#v){const e=!this.#b;if(this.#f&&this.#y){const t=this.#e.dequeue();return!!t&&(this.emit("active"),t(),e&&this.#C(),!0)}}return!1}#C(){this.#n||void 0!==this.#a||(this.#a=setInterval(()=>{this.#g()},this.#s),this.#o=Date.now()+this.#s)}#g(){0===this.#r&&0===this.#h&&this.#a&&(clearInterval(this.#a),this.#a=void 0),this.#r=this.#t?this.#h:0,this.#_()}#_(){for(;this.#I(););}get concurrency(){return this.#l}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#_()}async#T(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}setPriority(e,t){this.#e.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#p++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#d,...t},new Promise((n,r)=>{this.#e.enqueue(async()=>{this.#h++,this.#r++;try{t.signal?.throwIfAborted();let r=e({signal:t.signal});t.timeout&&(r=function(e,t){const{milliseconds:n,fallback:r,message:s,customTimers:o={setTimeout,clearTimeout}}=t;let u,c;const h=new Promise((h,l)=>{if("number"!=typeof n||1!==Math.sign(n))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(t.signal){const{signal:e}=t;e.aborted&&l(a(e)),c=()=>{l(a(e))},e.addEventListener("abort",c,{once:!0})}if(n===Number.POSITIVE_INFINITY)return void e.then(h,l);const v=new i;u=o.setTimeout.call(void 0,()=>{if(r)try{h(r())}catch(e){l(e)}else"function"==typeof e.cancel&&e.cancel(),!1===s?h():s instanceof Error?l(s):(v.message=s??`Promise timed out after ${n} milliseconds`,l(v))},n),(async()=>{try{h(await e)}catch(e){l(e)}})()}).finally(()=>{h.clear(),c&&t.signal&&t.signal.removeEventListener("abort",c)});return h.clear=()=>{o.clearTimeout.call(void 0,u),u=void 0},h}(Promise.resolve(r),{milliseconds:t.timeout})),t.signal&&(r=Promise.race([r,this.#T(t.signal)]));const s=await r;n(s),this.emit("completed",s)}catch(e){if(e instanceof i&&!t.throwOnTimeout)return void n();r(e),this.emit("error",e)}finally{this.#m()}},t),this.emit("add"),this.#I()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#v?(this.#v=!1,this.#_(),this):this}pause(){this.#v=!0}clear(){this.#e=new this.#c}async onEmpty(){0!==this.#e.size&&await this.#q("empty")}async onSizeLessThan(e){this.#e.size<e||await this.#q("next",()=>this.#e.size<e)}async onIdle(){0===this.#h&&0===this.#e.size||await this.#q("idle")}async#q(e,t){return new Promise(n=>{const r=()=>{t&&!t()||(this.off(e,r),n())};this.on(e,r)})}get size(){return this.#e.size}sizeBy(e){return this.#e.filter(e).length}get pending(){return this.#h}get isPaused(){return this.#v}}}}]);
//# sourceMappingURL=343.bundle.js.map