@bereasoftware/nexa 1.7.0 → 1.8.0
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.
- package/README.en.md +32 -0
- package/README.md +35 -2
- package/dist/bereasoftware-nexa-1.8.0.tgz +0 -0
- package/dist/nexa.cjs.js +163 -163
- package/dist/nexa.cjs.js.map +1 -1
- package/dist/nexa.es.js +473 -363
- package/dist/nexa.es.js.map +1 -1
- package/dist/nexa.iife.js +163 -163
- package/dist/nexa.iife.js.map +1 -1
- package/dist/nexa.umd.js +163 -163
- package/dist/nexa.umd.js.map +1 -1
- package/dist/types/dev-overlay/env.d.ts +1 -0
- package/dist/types/dev-overlay/format.d.ts +3 -0
- package/dist/types/dev-overlay/overlay.d.ts +0 -2
- package/dist/types/dev-overlay/render.d.ts +6 -0
- package/dist/types/dev-overlay/theme.d.ts +40 -0
- package/dist/types/dev-overlay/tracker.d.ts +7 -1
- package/dist/types/http-client/http-client.d.ts +7 -0
- package/dist/types/http-client/index.d.ts +1 -1
- package/dist/types/realtime/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +31 -6
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +16 -16
- package/dist/bereasoftware-nexa-1.7.0.tgz +0 -0
package/dist/nexa.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Nexa={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=e=>({ok:!0,value:e}),n=e=>({ok:!1,error:e});function r(e){return{validate(r){let i=r;for(let[t,r]of Object.entries(e))if(!r(i[t]))return n({message:`Validation failed: field "${t}" is invalid`,code:`VALIDATION_ERROR`});return t(r)}}}function i(e){return{validate(r){let i=r,a=e.filter(e=>!(e in i));return a.length>0?n({message:`Validation failed: missing fields: ${a.join(`, `)}`,code:`VALIDATION_ERROR`}):t(r)}}}var a={validate(e){return Array.isArray(e)?t(e):n({message:`Expected array response`,code:`VALIDATION_ERROR`})}},o={validate(e){return e&&typeof e==`object`&&!Array.isArray(e)?t(e):n({message:`Expected object response`,code:`VALIDATION_ERROR`})}},s={transform(e){return h(e,te)}},c={transform(e){return h(e,m)}},l={transform(e){return g(e)}};function u(e){return{transform(t){return Array.isArray(t)?t.map(t=>_(t,e)):_(t,e)}}}function d(e){return{transform(t){return{[e]:t}}}}var f=class{maxAttempts;constructor(e=5){this.maxAttempts=e}shouldRetry(e){return e<this.maxAttempts}delayMs(e){return e*50}},p=class{retryableStatuses=[408,429,500,502,503,504];maxAttempts;constructor(e=3){this.maxAttempts=e}shouldRetry(e,t){return e>=this.maxAttempts?!1:this.retryableStatuses.includes(t.status??0)||t.code===`TIMEOUT`}delayMs(e){return Math.min(1e3*2**(e-1),1e4)}},ee=class{failureCount=0;lastFailureTime=0;maxAttempts;failureThreshold;resetTimeMs;constructor(e=3,t=5,n=6e4){this.maxAttempts=e,this.failureThreshold=t,this.resetTimeMs=n}shouldRetry(e){return e>=this.maxAttempts||(Date.now()-this.lastFailureTime>this.resetTimeMs&&(this.failureCount=0),this.failureCount>=this.failureThreshold)?!1:(this.failureCount++,this.lastFailureTime=Date.now(),!0)}delayMs(e){return 100*2**(e-1)}reset(){this.failureCount=0,this.lastFailureTime=0}};function te(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function m(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function h(e,t){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>h(e,t));let n={};for(let[r,i]of Object.entries(e))n[t(r)]=h(i,t);return n}function g(e,t=``){let n={};if(Array.isArray(e))e.forEach((e,r)=>{let i=t?`${t}[${r}]`:`[${r}]`;Object.assign(n,g(e,i))});else if(e&&typeof e==`object`)for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;i&&typeof i==`object`&&!Array.isArray(i)?Object.assign(n,g(i,e)):n[e]=i}return n}function _(e,t){if(!e||typeof e!=`object`)return{};let n=e,r={};for(let e of t)e in n&&(r[e]=n[e]);return r}function ne(e){let t=new AbortController,n=setTimeout(()=>t.abort(),e);return t.signal.addEventListener(`abort`,()=>clearTimeout(n),{once:!0}),t}async function v(e,t=3){try{return await e()}catch(n){if(t<=0)throw n;return v(e,t-1)}}var y=class{cache=new Map;get(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>t.ttlMs?(this.cache.delete(e),null):t.data:null}set(e,t,n=6e4){this.cache.set(e,{data:t,timestamp:Date.now(),ttlMs:n})}clear(){this.cache.clear()}has(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>t.ttlMs?(this.cache.delete(e),!1):!0:!1}delete(e){this.cache.delete(e)}};function b(e={}){let t=e.cache||new y,n=e.ttlMs||6e4,r=e.cacheableStatuses||[200,304];return async(e,i)=>{let a=(e.request.method||`GET`).toUpperCase(),o=a===`GET`,s=`${a}:${e.request.url}`;if(o&&t.has(s)){let n=t.get(s);if(n){e.response=n,e.state.cacheHit=!0;return}}await i(),o&&e.response&&r.includes(e.response.status)&&(t.set(s,e.response,n),e.state.cacheMiss=!0)}}var re=b(),x=class{pending=new Map;async execute(e,t){if(this.pending.has(e))return this.pending.get(e);let n=t().finally(()=>{this.pending.delete(e)});return this.pending.set(e,n),n}clear(){this.pending.clear()}};function S(e={}){let t=e.deduplicator||new x,n=e.includeBody??!1,r=e.methods||[`GET`];return async(e,i)=>{let a=(e.request.method||`GET`).toUpperCase();if(!r.includes(a)){await i();return}let o=`${a}:${e.request.url}`;n&&e.request.body&&(o+=`:${JSON.stringify(e.request.body)}`);try{e.response=await t.execute(o,async()=>(await i(),e.response)),e.state.deduped=!0}catch(t){throw e.error=t,t}}}var ie=S();function C(e){return async t=>{let n=-1;async function r(i){if(i<=n)throw Error(`next() called multiple times`);n=i;let a=e[i];a&&await a(t,()=>r(i+1))}await r(0)}}var w=class{middlewares=[];use(e){return this.middlewares.push(e),this}async execute(e){if(e&&typeof e==`object`&&`request`in e&&`response`in e){let t=e;return await C(this.middlewares.map(e=>typeof e==`function`&&e.length===2?e:async(t,n)=>{let r=e;t.response.body=await r(t.response.body),await n()}))(t),t.response.body}let t=e;for(let e of this.middlewares)t=await e(t);return t}clear(){this.middlewares=[]}};function T(e,t,n,r={}){return{ok:e>=200&&e<300,data:t,error:n,status:e,headers:r}}function E(e){return async(t,n)=>{let r=e.path,i;switch(e.method){case`GET`:i=await t.get(r);break;case`POST`:i=await t.post(r,n);break;case`PUT`:i=await t.put(r,n);break;case`PATCH`:i=await t.patch(r,n);break;case`DELETE`:i=await t.delete(r);break;default:throw Error(`Unsupported method: ${e.method}`)}return i}}function D(e){return{request:async(t,n,r)=>{let i=e[n];return await E(i)(t,r)}}}var ae=class e{subscribers=[];errorSubscribers=[];completeSubscribers=[];subscribe(e,t,n){return e&&this.subscribers.push(e),t&&this.errorSubscribers.push(t),n&&this.completeSubscribers.push(n),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e),this.errorSubscribers=this.errorSubscribers.filter(e=>e!==t),this.completeSubscribers=this.completeSubscribers.filter(e=>e!==n)}}}next(e){this.subscribers.forEach(t=>t(e))}error(e){this.errorSubscribers.forEach(t=>t(e))}complete(){this.completeSubscribers.forEach(e=>e())}map(t){let n=new e;return this.subscribe(e=>n.next(t(e)),e=>n.error(e),()=>n.complete()),n}filter(t){let n=new e;return this.subscribe(e=>{t(e)&&n.next(e)},e=>n.error(e),()=>n.complete()),n}};function oe(e){return t=>{if(!e(t))throw TypeError(`Value does not match expected type`);return t}}function O(e){return e}function se(e){return O(e)}var ce=class{_promise;resolveFunc;rejectFunc;constructor(){this._promise=new Promise((e,t)=>{this.resolveFunc=e,this.rejectFunc=t})}resolve(e){this.resolveFunc(e)}reject(e){this.rejectFunc(e)}get promise(){return this._promise}promise_(){return this._promise}};async function k(e,t={}){let n=e.body?.getReader();if(!n)throw Error(`Response body is not readable`);let r=[],i=0,a=parseInt(e.headers.get(`content-length`)||`0`,10);for(;;){let{done:e,value:o}=await n.read();if(e)break;r.push(o),i+=o.length,t.onChunk&&await t.onChunk(o),t.onProgress&&a>0&&t.onProgress(i,a)}return A(r,i)}function A(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}async function le(e,t){let n=await k(e);if(typeof window>`u`)await(await import(`fs`).then(e=>e.promises)).writeFile(t,n);else{let e=new Blob([n.buffer],{type:`application/octet-stream`}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}}function j(e={}){return async(t,n)=>{if(await n(),t.response&&t.response.body&&typeof t.response.body==`object`&&`getReader`in t.response.body){let n=t.response.body.getReader(),r=[],i=0,a=parseInt(t.response.headers?.[`content-length`]||`0`,10);try{for(;;){let{done:o,value:s}=await n.read();if(o)break;r.push(s),i+=s.length,e.onChunk&&await e.onChunk(s),e.onProgress&&a>0&&e.onProgress(i,a),t.state.streamedChunks=t.state.streamedChunks||[],t.state.streamedChunks.push(s)}let o=A(r,i);t.response.body=o,t.state.streaming=!0,t.state.streamedBytes=i}finally{n.releaseLock()}}}}var ue=j({onProgress:(e,t)=>{if(t>0){let n=Math.round(e/t*100);console.warn(`Streaming: ${n}% (${e}/${t} bytes)`)}}}),M=class{plugins=[];cache=new y;deduplicator=new x;middlewares=[];listeners=new Map;register(e){return this.plugins.push(e),e.setup(this),this.emit(`plugin:registered`,e.name),this}addMiddleware(e){return this.middlewares.push(e),this}getCache(){return this.cache}getDeduplicator(){return this.deduplicator}getPipeline(){return C(this.middlewares)}async executePipeline(e){await this.getPipeline()(e)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set);let n=this.listeners.get(e),r=t;return n&&n.add(r),this}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of n)e(...t)}off(e,t){return this.listeners.get(e)?.delete(t),this}getPlugins(){return[...this.plugins]}clear(){this.plugins=[],this.middlewares=[],this.listeners.clear(),this.cache.clear(),this.deduplicator.clear()}},de={name:`logger`,setup(e){e.on(`request:start`,(...e)=>{let t=e[0];console.warn(`Request started: ${t}`)}),e.on(`request:success`,(...e)=>{let t=e[0],n=e[1];console.warn(`Request succeeded: ${t} (${n})`)}),e.on(`request:error`,(...e)=>{let t=e[0],n=e[1];console.error(`❌ Request failed: ${t}`,n)})}},fe=class{name=`metrics`;metrics={requests:0,errors:0,totalTime:0,avgTime:0};setup(e){e.on(`request:complete`,(...e)=>{let t=e[0],n=e[1];this.metrics.requests++,this.metrics.totalTime+=t,this.metrics.avgTime=this.metrics.totalTime/this.metrics.requests,n||this.metrics.errors++})}getMetrics(){return{...this.metrics}}},pe=class{name=`cache`;ttlMs;constructor(e=6e4){this.ttlMs=e}setup(e){e.addMiddleware(b({ttlMs:this.ttlMs}))}},me=class{name=`dedupe`;setup(e){e.addMiddleware(S())}},N=class{store=new y;get(e){return this.store.get(e)}set(e,t,n=6e4){this.store.set(e,t,n)}has(e){return this.store.has(e)}clear(){this.store.clear()}},P=class{maxAttempts;baseDelayMs;constructor(e=3,t=100){this.maxAttempts=e,this.baseDelayMs=t}shouldRetry(e,t){let n=t.status!==void 0&&t.status>=500,r=t.code===`NETWORK_ERROR`;return e<this.maxAttempts&&(n||r||t.code===`TIMEOUT`)}delayMs(e){let t=this.baseDelayMs*2**(e-1),n=Math.random()*t*.1;return Math.min(t+n,3e4)}},F=class{running=0;queue=[];maxConcurrent;constructor(e){this.maxConcurrent=e}async acquire(){if(this.running<this.maxConcurrent){this.running++;return}return new Promise(e=>{this.queue.push(()=>{this.running++,e()})})}release(){this.running--;let e=this.queue.shift();e&&e()}get pending(){return this.queue.length}get active(){return this.running}};function I(e){return e==null?{serialized:void 0,contentType:null}:typeof e==`string`?{serialized:e,contentType:`text/plain`}:typeof FormData<`u`&&e instanceof FormData?{serialized:e,contentType:null}:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?{serialized:e,contentType:`application/x-www-form-urlencoded`}:typeof Blob<`u`&&e instanceof Blob?{serialized:e,contentType:e.type||`application/octet-stream`}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof ReadableStream<`u`&&e instanceof ReadableStream?{serialized:e,contentType:`application/octet-stream`}:{serialized:JSON.stringify(e),contentType:`application/json`}}function L(e,t){return t?e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>{let r=t[n];if(r===void 0)throw Error(`Missing path parameter: :${n}`);return encodeURIComponent(String(r))}):e}var R=class e{requestInterceptors=[];responseInterceptors=[];cache;devTracker;config;requestQueue;pendingRequests=new Set;constructor(e={}){this.config={baseURL:e.baseURL??``,defaultHeaders:e.defaultHeaders??{"Content-Type":`application/json`},defaultTimeout:e.defaultTimeout??3e4,validateStatus:e.validateStatus??(e=>e>=200&&e<300),cacheStrategy:e.cacheStrategy??new N,maxConcurrent:e.maxConcurrent??0,defaultResponseType:e.defaultResponseType??`auto`,defaultHooks:e.defaultHooks??{},adapter:e.adapter},this.cache=this.config.cacheStrategy,this.requestQueue=this.config.maxConcurrent>0?new F(this.config.maxConcurrent):null,this.devTracker=e.devTracker??null}async request(e){if(!this.requestInterceptors.length&&!this.responseInterceptors.length&&!e.cache?.enabled&&!e.hooks&&!Object.keys(this.config.defaultHooks).length&&!e.retry&&!e.validate&&!e.transform&&!this.requestQueue&&!e.onDownloadProgress&&!e.signal)return this.fastPath(e);let r=e.hooks?{...this.config.defaultHooks,...e.hooks}:this.config.defaultHooks,i=this.getMaxAttempts(e.retry),a=this.getRetryStrategy(e.retry),o=this.buildRequest(e);r.onStart?.(o),this.requestQueue&&await this.requestQueue.acquire();try{for(let s=1;s<=i;s++){let c;try{if((e.method===`GET`||!e.method)&&e.cache?.enabled){let n=this.getCacheKey(e),i=this.cache.get(n);if(i){let n=i;return this.trackDev({method:e.method??`GET`,url:o.url,status:n.status,duration:n.duration,cached:!0,ok:!0,headers:{...o.headers},body:e.body,retryCount:0}),r.onSuccess?.(n),r.onFinally?.(),t(n)}}let n=o;for(let e of this.requestInterceptors)n=await e.onRequest(n);c=new AbortController,this.pendingRequests.add(c),e.signal&&e.signal.addEventListener(`abort`,()=>c.abort(),{once:!0});let i=performance.now(),a=await this.fetchWithTimeout(n,this.resolveTimeoutMs(e.timeout??this.config.defaultTimeout),c),l=performance.now()-i,u=a;e.onDownloadProgress&&a.body&&(u=this.trackDownloadProgress(a,e.onDownloadProgress));let d=e.responseType??this.config.defaultResponseType,f=await this.parseResponse(u,n,l,d);if(!this.config.validateStatus(f.status))throw{message:`Request failed with status ${f.status}`,status:f.status,statusText:f.statusText,code:`HTTP_ERROR`};if(e.validate){let t=e.validate.validate(f.data);if(!t.ok)return t}e.transform&&(f.data=e.transform.transform(f.data));let p=f;for(let e of this.responseInterceptors)p=await e.onResponse(p);if((e.method===`GET`||!e.method)&&e.cache?.enabled){let t=this.getCacheKey(e);this.cache.set(t,p,e.cache.ttlMs)}return r.onSuccess?.(p),this.pendingRequests.delete(c),this.trackDev({method:e.method??`GET`,url:o.url,status:p.status,duration:p.duration,cached:!1,ok:!0,headers:{...o.headers},body:e.body,retryCount:s-1}),t(p)}catch(t){let l;if(l=t instanceof DOMException?t.name===`TimeoutError`?{message:`Request timed out`,code:`TIMEOUT`}:t.name===`AbortError`?{message:`Request aborted`,code:`ABORTED`}:{message:t.message,code:`UNKNOWN_ERROR`,originalError:t}:this.isHttpErrorDetails(t)?t:this.normalizeError(t),s<i&&a.shouldRetry(s,l)){r.onRetry?.(s,l);let e=a.delayMs(s);await this.delay(e);continue}let u=l;for(let e of this.responseInterceptors)e.onError&&(u=await e.onError(u));return r.onError?.(u),c&&this.pendingRequests.delete(c),this.trackDev({method:e.method??`GET`,url:o.url,status:u.status,duration:0,cached:!1,ok:!1,code:u.code,headers:{...o.headers},body:e.body,retryCount:s-1}),n(u)}}let s={message:`Max retries exceeded`,code:`MAX_RETRIES`};return r.onError?.(s),this.trackDev({method:e.method??`GET`,url:o.url,duration:0,cached:!1,ok:!1,code:`MAX_RETRIES`,headers:{...o.headers},body:e.body,retryCount:i}),n(s)}finally{r.onFinally?.(),this.requestQueue&&this.requestQueue.release()}}async fastPath(e){let r=L(e.url,e.params),i=this.buildUrl(r,e.query),{serialized:a,contentType:o}=I(e.body),s={...this.config.defaultHeaders,...e.headers};o?s[`Content-Type`]=o:a instanceof FormData&&delete s[`Content-Type`];let c=new AbortController,l=this.resolveTimeoutMs(e.timeout??this.config.defaultTimeout);this.pendingRequests.add(c);try{let r=performance.now(),a=await this.fetchWithTimeout({url:i,method:e.method??`GET`,headers:s,body:e.body,params:e.params},l,c),o=performance.now()-r,u=await this.parseBody(a,e.responseType??this.config.defaultResponseType);if(!this.config.validateStatus(a.status)){let t=n({message:`Request failed with status ${a.status}`,status:a.status,statusText:a.statusText,code:`HTTP_ERROR`});return this.trackDev({method:e.method??`GET`,url:i,status:a.status,duration:o,cached:!1,ok:!1,code:`HTTP_ERROR`,headers:s,body:e.body,retryCount:0}),this.pendingRequests.delete(c),t}return this.pendingRequests.delete(c),this.trackDev({method:e.method??`GET`,url:i,status:a.status,duration:o,cached:!1,ok:!0,headers:s,body:e.body,retryCount:0}),t({status:a.status,statusText:a.statusText,headers:a.headers,data:u,request:{url:i,method:e.method??`GET`,headers:s,body:e.body,params:e.params},duration:o})}catch(t){this.pendingRequests.delete(c);let r=`UNKNOWN_ERROR`;if(t instanceof DOMException?t.name===`TimeoutError`?r=`TIMEOUT`:t.name===`AbortError`&&(r=`ABORTED`):t instanceof Error&&(t.name===`TimeoutError`?r=`TIMEOUT`:t.name===`AbortError`||t.message.includes(`abort`)?r=`ABORTED`:t.name===`TypeError`&&(r=`NETWORK_ERROR`)),this.trackDev({method:e.method??`GET`,url:i,duration:performance.now()-(performance.now()-0),cached:!1,ok:!1,code:r,headers:s,body:e.body,retryCount:0}),t instanceof DOMException){if(t.name===`TimeoutError`)return n({message:`Request timed out`,code:`TIMEOUT`});if(t.name===`AbortError`)return n({message:`Request aborted`,code:`ABORTED`})}return t instanceof Error?t.name===`TimeoutError`?n({message:`Request timed out`,code:`TIMEOUT`}):t.name===`AbortError`||t.message.includes(`abort`)?n({message:`Request aborted`,code:`ABORTED`}):n({message:t.message,code:t.name===`TypeError`?`NETWORK_ERROR`:`UNKNOWN_ERROR`}):n({message:String(t),code:`UNKNOWN_ERROR`})}}get(e,t){return this.request({...t,url:e,method:`GET`})}post(e,t,n){return this.request({...n,url:e,method:`POST`,body:t})}put(e,t,n){return this.request({...n,url:e,method:`PUT`,body:t})}patch(e,t,n){return this.request({...n,url:e,method:`PATCH`,body:t})}delete(e,t){return this.request({...t,url:e,method:`DELETE`})}head(e,t){return this.request({...t,url:e,method:`HEAD`})}options(e,t){return this.request({...t,url:e,method:`OPTIONS`})}addRequestInterceptor(e){return this.requestInterceptors.push(e),()=>{let t=this.requestInterceptors.indexOf(e);t!==-1&&this.requestInterceptors.splice(t,1)}}addResponseInterceptor(e){return this.responseInterceptors.push(e),()=>{let t=this.responseInterceptors.indexOf(e);t!==-1&&this.responseInterceptors.splice(t,1)}}clearInterceptors(){this.requestInterceptors=[],this.responseInterceptors=[]}clearCache(){this.cache.clear()}cancelAll(){for(let e of this.pendingRequests)e.abort();this.pendingRequests.clear()}get activeRequests(){return this.pendingRequests.size}get queueStats(){return{active:this.requestQueue?.active??this.pendingRequests.size,pending:this.requestQueue?.pending??0}}extend(t={}){let n=new e({baseURL:t.baseURL??this.config.baseURL,defaultHeaders:{...this.config.defaultHeaders,...t.defaultHeaders},defaultTimeout:t.defaultTimeout??this.config.defaultTimeout,validateStatus:t.validateStatus??this.config.validateStatus,cacheStrategy:t.cacheStrategy??this.cache,maxConcurrent:t.maxConcurrent??this.config.maxConcurrent,defaultResponseType:t.defaultResponseType??this.config.defaultResponseType,defaultHooks:{...this.config.defaultHooks,...t.defaultHooks},adapter:t.adapter});for(let e of this.requestInterceptors)n.addRequestInterceptor(e);for(let e of this.responseInterceptors)n.addResponseInterceptor(e);return n}async*paginate(e,t,n={}){let r={...n};for(;;){let n=await this.get(e,r);if(!n.ok)break;yield t.getItems(n.value.data);let i=t.getNextPage(n.value.data,r);if(!i)break;r=i}}async poll(e,t,r={}){let i=t.maxAttempts??0;for(let n=1;i===0||n<=i;n++){let a=await this.get(e,r);if(!a.ok||(t.onPoll?.(a.value.data,n),t.until(a.value.data)))return a;if(i>0&&n>=i)break;await this.delay(t.intervalMs)}return n({message:`Polling exhausted after ${i} attempts`,code:`POLL_EXHAUSTED`})}buildRequest(e){let t=L(e.url,e.params);return{url:this.buildUrl(t,e.query),method:e.method??`GET`,headers:{...this.config.defaultHeaders,...e.headers},body:e.body,params:e.params}}buildUrl(e,t){let n=this.config.baseURL+e;if(t){let e=Object.keys(t);if(e.length>0){let r=new URLSearchParams;for(let n=0;n<e.length;n++)r.append(e[n],String(t[e[n]]));n+=`?${r.toString()}`}}return n}getCacheKey(e){let t=L(e.url,e.params),n=e.query?JSON.stringify(e.query):``;return`${e.method??`GET`}:${t}${n?`:`+n:``}`}fetchWithTimeout(e,t,n){let{serialized:r,contentType:i}=I(e.body),a={...e.headers};return i?a[`Content-Type`]=i:r instanceof FormData&&delete a[`Content-Type`],new Promise((i,o)=>{let s=setTimeout(()=>{n.abort(),o(new DOMException(`Request timed out`,`TimeoutError`))},t);(this.config.adapter??fetch)(e.url,{method:e.method,headers:a,body:r,signal:n.signal}).then(e=>{clearTimeout(s),i(e)},e=>{clearTimeout(s),o(e)})})}trackDownloadProgress(e,t){let n=parseInt(e.headers.get(`content-length`)||`0`,10),r=e.body?.getReader();if(!r)return e;let i=0,a=new ReadableStream({async pull(e){let{done:a,value:o}=await r.read();if(a){e.close();return}i+=o.byteLength,t({loaded:i,total:n,percent:n>0?Math.round(i/n*100):0}),e.enqueue(o)}});return new Response(a,{headers:e.headers,status:e.status,statusText:e.statusText})}async parseResponse(e,t,n,r){let i=await this.parseBody(e,r);return{status:e.status,statusText:e.statusText,headers:e.headers,data:i,request:t,duration:n}}async parseBody(e,t){switch(t){case`json`:return await e.json();case`text`:return await e.text();case`blob`:return await e.blob();case`arrayBuffer`:return await e.arrayBuffer();case`formData`:return await e.formData();case`stream`:return e.body;default:{let t=e.headers.get(`content-type`)??``;if(t.includes(`application/json`))return await e.json();if(t.includes(`text/`))return await e.text();if(t.includes(`multipart/form-data`))return await e.formData();if(t.includes(`application/octet-stream`)||t.includes(`image/`)||t.includes(`audio/`)||t.includes(`video/`))return await e.blob();try{return await e.json()}catch{return await e.text()}}}}normalizeError(e){if(e instanceof DOMException){if(e.name===`TimeoutError`)return{message:`Request timed out`,code:`TIMEOUT`};if(e.name===`AbortError`)return{message:`Request aborted`,code:`ABORTED`}}return e instanceof Error?e.name===`TimeoutError`?{message:`Request timed out`,code:`TIMEOUT`}:e.name===`AbortError`||e.message.includes(`abort`)?{message:`Request aborted`,code:`ABORTED`}:{message:e.message,code:e.name===`TypeError`?`NETWORK_ERROR`:`UNKNOWN_ERROR`,originalError:e}:{message:String(e),code:`UNKNOWN_ERROR`,originalError:e}}isHttpErrorDetails(e){return typeof e==`object`&&!!e&&`message`in e&&`code`in e}getMaxAttempts(e){return e?`maxAttempts`in e?e.maxAttempts??1:100:1}getRetryStrategy(e){return e?`shouldRetry`in e?e:new P(e.maxAttempts,e.backoffMs):{shouldRetry:()=>!1,delayMs:()=>0}}resolveTimeoutMs(e){return typeof e==`number`?e:e.total??e.response??e.connection??3e4}delay(e){return new Promise(t=>setTimeout(t,e))}trackDev(e){this.devTracker&&this.devTracker.track(e)}},z=class extends Error{status;code;response;constructor(e,t,n,r){super(e),this.name=`HttpError`,this.status=t,this.code=n,this.response=r}};function he(e){return e instanceof z}function ge(e){return new R(e)}function B(){return typeof window>`u`&&typeof process<`u`&&process.versions?.node!==void 0}var _e=class{url;options;pluginManager;status=`closed`;reconnectAttempt=0;reconnectTimer=null;heartbeatTimer=null;stats={messagesSent:0,messagesReceived:0,connectionTime:0,reconnectAttempts:0};connectionStartTime=0;listeners={open:new Set,close:new Set,error:new Set,message:new Set};constructor(e,t={}){this.url=e,this.options=t,this.pluginManager=new M}updateStatus(e){this.status=e,e===`open`?this.connectionStartTime=Date.now():e===`closed`&&this.connectionStartTime>0&&(this.stats.connectionTime+=Date.now()-this.connectionStartTime,this.connectionStartTime=0)}emitOpen(e){this.pluginManager.emit(`websocket:open`,this.url,e);for(let t of this.listeners.open)t(e)}emitClose(e){this.pluginManager.emit(`websocket:close`,this.url,e);for(let t of this.listeners.close)t(e)}emitError(e){let t;e instanceof Error?(t=new Event(`error`),t.error=e):t=e,this.pluginManager.emit(`websocket:error`,this.url,t);for(let e of this.listeners.error)e(t)}emitMessage(e){this.pluginManager.emit(`websocket:message`,this.url,e);for(let t of this.listeners.message)t(e)}onOpen(e){return this.listeners.open.add(e),()=>this.listeners.open.delete(e)}onClose(e){return this.listeners.close.add(e),()=>this.listeners.close.delete(e)}onError(e){return this.listeners.error.add(e),()=>this.listeners.error.delete(e)}onMessage(e){return this.listeners.message.add(e),()=>this.listeners.message.delete(e)}getStatus(){return this.status}getStats(){return{...this.stats,connectionTime:this.stats.connectionTime+(this.connectionStartTime>0?Date.now()-this.connectionStartTime:0)}}scheduleReconnect(){if(this.options.reconnect?.enabled===!1)return;let e=this.options.reconnect?.maxAttempts??1/0;if(this.reconnectAttempt>=e){this.pluginManager.emit(`websocket:reconnect:failed`,this.url,this.reconnectAttempt);return}let t=this.options.reconnect?.baseDelay??1e3,n=this.options.reconnect?.maxDelay??3e4,r=Math.min(n,t*2**this.reconnectAttempt);this.reconnectAttempt++,this.stats.reconnectAttempts=this.reconnectAttempt,this.options.reconnect?.onReconnecting?.(this.reconnectAttempt,r),this.pluginManager.emit(`websocket:reconnecting`,this.url,this.reconnectAttempt,r),this.reconnectTimer=setTimeout(()=>{this.connect().catch(e=>{this.emitError(e instanceof Error?e:Error(String(e)))})},r)}startHeartbeat(){if(!this.options.heartbeat)return;let e=this.options.heartbeat.interval??3e4,t=this.options.heartbeat.pingMessage??`ping`,n=this.options.heartbeat.pongMessage??`pong`,r=!0,i=()=>{if(!r){this.pluginManager.emit(`websocket:heartbeat:timeout`,this.url),this.disconnect();return}r=!1,this.send(t),this.heartbeatTimer=setTimeout(i,e)};this.onMessage(e=>{let t=e.raw;typeof t==`string`&&t===n&&(r=!0)}),this.heartbeatTimer=setTimeout(i,e)}stopHeartbeat(){this.heartbeatTimer&&=(clearTimeout(this.heartbeatTimer),null)}cleanup(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.stopHeartbeat()}},V=class extends _e{socket=null;messageTypeListeners=new Map;constructor(e,t={}){super(e,t)}async connect(){if(!(this.status===`connecting`||this.status===`open`))return this.updateStatus(`connecting`),this.pluginManager.emit(`websocket:connect:start`,this.url),new Promise((e,t)=>{let n=this.options.timeout??1e4,r=setTimeout(()=>{this.updateStatus(`closed`),this.socket?.close(),this.socket=null;let e=Error(`WebSocket connection timeout after ${n}ms`);this.emitError(e),t(e)},n);try{this.socket=new WebSocket(this.url,this.options.protocols),this.socket.onopen=t=>{clearTimeout(r),this.updateStatus(`open`),this.reconnectAttempt=0,this.emitOpen(t),this.options.onOpen?.(t),this.startHeartbeat(),this.pluginManager.emit(`websocket:connect:success`,this.url),e()},this.socket.onclose=e=>{clearTimeout(r),this.updateStatus(`closed`),this.emitClose(e),this.options.onClose?.(e),this.stopHeartbeat(),this.pluginManager.emit(`websocket:disconnected`,this.url,e.code,e.reason),e.code!==1e3&&!e.wasClean&&this.scheduleReconnect()},this.socket.onerror=e=>{clearTimeout(r),this.updateStatus(`closed`),this.emitError(e),this.options.onError?.(e),this.pluginManager.emit(`websocket:connect:error`,this.url,e),t(e)},this.socket.onmessage=e=>{this.stats.messagesReceived++;let t={data:this.tryParseData(e.data),raw:e.data,type:`message`,timestamp:Date.now()};this.emitMessage(t),this.pluginManager.emit(`websocket:message:received`,this.url,t)}}catch(e){clearTimeout(r),this.updateStatus(`closed`),this.pluginManager.emit(`websocket:connect:error`,this.url,e),t(e)}})}disconnect(){this.cleanup(),this.socket&&(this.updateStatus(`closing`),this.socket.close(1e3,`Client disconnected`),this.socket=null,this.updateStatus(`closed`))}send(e){if(!this.socket||this.socket.readyState!==WebSocket.OPEN)throw Error(`WebSocket is not connected`);this.socket.send(e),this.stats.messagesSent++,this.pluginManager.emit(`websocket:message:sent`,this.url,e)}sendJson(e){this.send(JSON.stringify(e))}onMessageType(e,t){return this.messageTypeListeners.has(e)||this.messageTypeListeners.set(e,new Set),this.messageTypeListeners.get(e).add(t),()=>{let n=this.messageTypeListeners.get(e);n&&(n.delete(t),n.size===0&&this.messageTypeListeners.delete(e))}}tryParseData(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}},ve=class extends V{async connect(){if(B())try{let{default:e}=await import(`ws`);return super.connect()}catch{throw Error(`WebSocket client for Node.js requires the "ws" package. Please install it: npm install ws`)}return super.connect()}};function ye(e,t={}){return B()?new ve(e,t):new V(e,t)}function H(){return typeof window>`u`&&typeof process<`u`&&process.versions?.node!==void 0}var U=class{url;options;_source=null;pluginManager;status=`closed`;reconnectAttempt=0;reconnectTimer=null;stats={messagesSent:0,messagesReceived:0,connectionTime:0,reconnectAttempts:0};connectionStartTime=0;listeners={open:new Set,close:new Set,error:new Set,message:new Set,event:new Map};_lastEventId=null;constructor(e,t={}){this.url=e,this.options=t,this.pluginManager=new M}updateStatus(e){this.status=e,e===`open`?this.connectionStartTime=Date.now():e===`closed`&&this.connectionStartTime>0&&(this.stats.connectionTime+=Date.now()-this.connectionStartTime,this.connectionStartTime=0)}async connect(){if(!(this.status===`connecting`||this.status===`open`))return this.updateStatus(`connecting`),this.pluginManager.emit(`sse:connect:start`,this.url),new Promise((e,t)=>{let n=this.options.timeout??1e4,r=setTimeout(()=>{this.updateStatus(`closed`),this._source?.close(),this._source=null;let e=Error(`SSE connection timeout after ${n}ms`);this.emitError(e),t(e)},n);try{this._source=new EventSource(this.url),this._source.onopen=t=>{clearTimeout(r),this.updateStatus(`open`),this.reconnectAttempt=0,this.emitOpen(t),this.options.onOpen?.(t),this.pluginManager.emit(`sse:connect:success`,this.url),e()},this._source.onerror=e=>{clearTimeout(r),this.updateStatus(`closed`),this.emitError(e),this.options.onError?.(e),this.pluginManager.emit(`sse:connect:error`,this.url,e),this._source?.readyState===EventSource.CLOSED&&(this.emitClose(),this.options.onClose?.(),this.scheduleReconnect()),t(e)},this._source.onmessage=e=>{this.stats.messagesReceived++,this._lastEventId=e.lastEventId||this._lastEventId;let t={data:this.tryParseData(e.data),raw:e.data,type:e.type||`message`,timestamp:Date.now()};this.emitMessage(t),this.pluginManager.emit(`sse:message:received`,this.url,t);let n=e.type||`message`,r=this.listeners.event.get(n);if(r)for(let e of r)e(t.data)},this._source.addEventListener=this._source.addEventListener.bind(this._source)}catch(e){clearTimeout(r),this.updateStatus(`closed`),this.pluginManager.emit(`sse:connect:error`,this.url,e),t(e)}})}disconnect(){this.cleanup(),this._source&&(this.updateStatus(`closing`),this._source.close(),this._source=null,this.updateStatus(`closed`),this.emitClose(),this.options.onClose?.())}send(e){throw Error(`SSE is a receive-only protocol. Use HTTP requests to send data to server.`)}onMessage(e){return this.listeners.message.add(e),()=>this.listeners.message.delete(e)}onOpen(e){return this.listeners.open.add(e),()=>this.listeners.open.delete(e)}onClose(e){return this.listeners.close.add(e),()=>this.listeners.close.delete(e)}onError(e){return this.listeners.error.add(e),()=>this.listeners.error.delete(e)}onEvent(e,t){return this.listeners.event.has(e)||this.listeners.event.set(e,new Set),this.listeners.event.get(e).add(t),this._source&&!this._source[`on${e}`]&&this._source.addEventListener(e,n=>{t({data:this.tryParseData(n.data),raw:n.data,type:e,timestamp:Date.now()}.data)}),()=>{let n=this.listeners.event.get(e);n&&(n.delete(t),n.size===0&&this.listeners.event.delete(e))}}getStatus(){return this.status}getStats(){return{...this.stats,connectionTime:this.stats.connectionTime+(this.connectionStartTime>0?Date.now()-this.connectionStartTime:0)}}get lastEventId(){return this._lastEventId}get source(){return this._source}emitOpen(e){this.pluginManager.emit(`sse:open`,this.url,e);for(let t of this.listeners.open)t(e)}emitClose(){this.pluginManager.emit(`sse:close`,this.url);for(let e of this.listeners.close)e()}emitError(e){let t;e instanceof Error?(t=new Event(`error`),t.error=e):t=e,this.pluginManager.emit(`sse:error`,this.url,t);for(let e of this.listeners.error)e(t)}emitMessage(e){this.pluginManager.emit(`sse:message`,this.url,e);for(let t of this.listeners.message)t(e)}scheduleReconnect(){if(this.options.reconnect?.enabled===!1)return;let e=this.options.reconnect?.maxAttempts??1/0;if(this.reconnectAttempt>=e){this.pluginManager.emit(`sse:reconnect:failed`,this.url,this.reconnectAttempt);return}let t=this.options.reconnect?.baseDelay??1e3,n=this.options.reconnect?.maxDelay??3e4,r=Math.min(n,t*2**this.reconnectAttempt);this.reconnectAttempt++,this.stats.reconnectAttempts=this.reconnectAttempt,this.options.reconnect?.onReconnecting?.(this.reconnectAttempt,r),this.pluginManager.emit(`sse:reconnecting`,this.url,this.reconnectAttempt,r),this.reconnectTimer=setTimeout(()=>{this.connect().catch(e=>{this.emitError(e instanceof Error?e:Error(String(e)))})},r)}cleanup(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}tryParseData(e){try{return JSON.parse(e)}catch{return e}}},be=class extends U{async connect(){if(H())throw Error(`SSE client for Node.js requires a polyfill or custom implementation. Consider using a library like "eventsource" or implement using fetch with streaming.`);return super.connect()}};function xe(e,t={}){return H()?new be(e,t):new U(e,t)}var Se=class{name=`realtime`;setup(e){e.on(`websocket:connect:start`,(...t)=>{let n=t[0];e.emit(`realtime:connect:start`,`websocket`,n)}),e.on(`websocket:connect:success`,(...t)=>{let n=t[0];e.emit(`realtime:connect:success`,`websocket`,n)}),e.on(`websocket:message:received`,(...t)=>{let n=t[0],r=t[1];e.emit(`realtime:message`,`websocket`,n,r)}),e.on(`sse:connect:start`,(...t)=>{let n=t[0];e.emit(`realtime:connect:start`,`sse`,n)}),e.on(`sse:connect:success`,(...t)=>{let n=t[0];e.emit(`realtime:connect:success`,`sse`,n)}),e.on(`sse:message:received`,(...t)=>{let n=t[0],r=t[1];e.emit(`realtime:message`,`sse`,n,r)})}};function Ce(){return new Se}var W=`nexa.devOverlay.config`;function G(){try{if(typeof localStorage>`u`)return{};let e=localStorage.getItem(W);return e?JSON.parse(e):{}}catch{return{}}}function we(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(W,JSON.stringify(e))}catch{}}var K=class{history=[];maxHistory;listeners=new Set;startTime=Date.now();config;constructor(e={}){this.maxHistory=e.maxHistory??500,this.config={enabled:e.enabled??!0,maxHistory:this.maxHistory,keyboardShortcut:e.keyboardShortcut??`ctrl+shift+n`,position:e.position??`bottom-right`,theme:e.theme??`dark`,devOnly:e.devOnly??!0,floatingButtonSize:e.floatingButtonSize??48,floatingButtonOffset:e.floatingButtonOffset??24,floatingButtonTheme:e.floatingButtonTheme??`inherit`,branding:e.branding??`Nexa DevTools`,icon:e.icon??`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`}}track(e){let t={...e,id:this.generateId(),timestamp:Date.now()};this.history.unshift(t),this.history.length>this.maxHistory&&this.history.pop();for(let e of this.listeners)e(t);return t}getHistory(){return this.history}getMetrics(){let e=this.history.map(e=>e.duration),t=(Date.now()-this.startTime)/1e3;return{totalRequests:this.history.length,successfulRequests:this.history.filter(e=>e.ok).length,failedRequests:this.history.filter(e=>!e.ok).length,cachedRequests:this.history.filter(e=>e.cached).length,avgDuration:e.length?e.reduce((e,t)=>e+t,0)/e.length:0,maxDuration:e.length?Math.max(...e):0,minDuration:e.length?Math.min(...e):0,requestsPerSecond:t>0?this.history.length/t:0,slowestRequests:[...this.history].sort((e,t)=>t.duration-e.duration).slice(0,5)}}clear(){this.history=[],this.startTime=Date.now()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getConfig(){return this.config}updateConfig(e){this.config={...this.config,...e},this.maxHistory=this.config.maxHistory;try{we(this.config)}catch{}return this.config}generateId(){return`${Date.now()}-${Math.random().toString(36).slice(2,8)}`}},q={gear:`<svg width="16" height="16" viewBox="0 0 48 48" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Nexa={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=e=>({ok:!0,value:e}),n=e=>({ok:!1,error:e});function r(e){return{validate(r){if(typeof r!=`object`||!r)return n({message:`Validation failed: expected an object`,code:`VALIDATION_ERROR`});let i=r;for(let[t,r]of Object.entries(e))if(!r(i[t]))return n({message:`Validation failed: field "${t}" is invalid`,code:`VALIDATION_ERROR`});return t(r)}}}function i(e){return{validate(r){if(typeof r!=`object`||!r)return n({message:`Validation failed: expected an object`,code:`VALIDATION_ERROR`});let i=r,a=e.filter(e=>!(e in i));return a.length>0?n({message:`Validation failed: missing fields: ${a.join(`, `)}`,code:`VALIDATION_ERROR`}):t(r)}}}var a={validate(e){return Array.isArray(e)?t(e):n({message:`Expected array response`,code:`VALIDATION_ERROR`})}},o={validate(e){return e&&typeof e==`object`&&!Array.isArray(e)?t(e):n({message:`Expected object response`,code:`VALIDATION_ERROR`})}},s={transform(e){return h(e,ee)}},c={transform(e){return h(e,te)}},l={transform(e){return g(e)}};function u(e){return{transform(t){return Array.isArray(t)?t.map(t=>_(t,e)):_(t,e)}}}function d(e){return{transform(t){return{[e]:t}}}}var f=class{maxAttempts;constructor(e=5){this.maxAttempts=e}shouldRetry(e){return e<this.maxAttempts}delayMs(e){return e*50}},p=class{retryableStatuses=[408,429,500,502,503,504];maxAttempts;constructor(e=3){this.maxAttempts=e}shouldRetry(e,t){return e>=this.maxAttempts?!1:this.retryableStatuses.includes(t.status??0)||t.code===`TIMEOUT`}delayMs(e){return Math.min(1e3*2**(e-1),1e4)}},m=class{failureCount=0;lastFailureTime=0;maxAttempts;failureThreshold;resetTimeMs;constructor(e=3,t=5,n=6e4){this.maxAttempts=e,this.failureThreshold=t,this.resetTimeMs=n}shouldRetry(e){return e>=this.maxAttempts||(Date.now()-this.lastFailureTime>this.resetTimeMs&&(this.failureCount=0),this.failureCount>=this.failureThreshold)?!1:(this.failureCount++,this.lastFailureTime=Date.now(),!0)}delayMs(e){return 100*2**(e-1)}reset(){this.failureCount=0,this.lastFailureTime=0}};function ee(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function te(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function h(e,t){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>h(e,t));let n={};for(let[r,i]of Object.entries(e))n[t(r)]=h(i,t);return n}function g(e,t=``){let n={};if(Array.isArray(e))e.forEach((e,r)=>{let i=t?`${t}[${r}]`:`[${r}]`;Object.assign(n,g(e,i))});else if(e&&typeof e==`object`)for(let[r,i]of Object.entries(e)){let e=t?`${t}.${r}`:r;i&&typeof i==`object`?Object.assign(n,g(i,e)):n[e]=i}return n}function _(e,t){if(!e||typeof e!=`object`)return{};let n=e,r={};for(let e of t)e in n&&(r[e]=n[e]);return r}function ne(e){let t=new AbortController,n=setTimeout(()=>t.abort(),e);return t.signal.addEventListener(`abort`,()=>clearTimeout(n),{once:!0}),t}async function v(e,t=3){try{return await e()}catch(n){if(t<=0)throw n;return v(e,t-1)}}var y=class{cache=new Map;get(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>t.ttlMs?(this.cache.delete(e),null):t.data:null}set(e,t,n=6e4){this.cache.set(e,{data:t,timestamp:Date.now(),ttlMs:n})}clear(){this.cache.clear()}has(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>t.ttlMs?(this.cache.delete(e),!1):!0:!1}delete(e){this.cache.delete(e)}};function b(e={}){let t=e.cache||new y,n=e.ttlMs||6e4,r=e.cacheableStatuses||[200,304];return async(e,i)=>{let a=(e.request.method||`GET`).toUpperCase(),o=a===`GET`,s=`${a}:${e.request.url}`;if(o&&t.has(s)){let n=t.get(s);if(n){e.response=n,e.state.cacheHit=!0;return}}await i(),o&&e.response&&r.includes(e.response.status)&&(t.set(s,e.response,n),e.state.cacheMiss=!0)}}var x=b(),S=class{pending=new Map;async execute(e,t){if(this.pending.has(e))return this.pending.get(e);let n=t().finally(()=>{this.pending.delete(e)});return this.pending.set(e,n),n}clear(){this.pending.clear()}};function C(e={}){let t=e.deduplicator||new S,n=e.includeBody??!1,r=e.methods||[`GET`];return async(e,i)=>{let a=(e.request.method||`GET`).toUpperCase();if(!r.includes(a)){await i();return}let o=`${a}:${e.request.url}`;n&&e.request.body&&(o+=`:${JSON.stringify(e.request.body)}`);try{e.response=await t.execute(o,async()=>(await i(),e.response)),e.state.deduped=!0}catch(t){throw e.error=t,t}}}var re=C();function w(e){return async t=>{let n=-1;async function r(i){if(i<=n)throw Error(`next() called multiple times`);n=i;let a=e[i];a&&await a(t,()=>r(i+1))}await r(0)}}var ie=class{middlewares=[];use(e){return this.middlewares.push(e),this}async execute(e){if(e&&typeof e==`object`&&`request`in e&&`response`in e){let t=e;return await w(this.middlewares.map(e=>typeof e==`function`&&e.length===2?e:async(t,n)=>{let r=e;t.response.body=await r(t.response.body),await n()}))(t),t.response.body}let t=e;for(let e of this.middlewares)t=await e(t);return t}clear(){this.middlewares=[]}};function T(e,t,n,r={}){return{ok:e>=200&&e<300,data:t,error:n,status:e,headers:r}}function E(e){return async(t,n)=>{let r=e.path,i;switch(e.method){case`GET`:i=await t.get(r);break;case`POST`:i=await t.post(r,n);break;case`PUT`:i=await t.put(r,n);break;case`PATCH`:i=await t.patch(r,n);break;case`DELETE`:i=await t.delete(r);break;case`QUERY`:i=await t.query(r,n);break;default:throw Error(`Unsupported method: ${e.method}`)}if(!i.ok)throw Error(i.error.message);return i.value.data}}function D(e){return{request:async(t,n,r)=>{let i=e[n];return await E(i)(t,r)}}}var ae=class e{subscribers=[];errorSubscribers=[];completeSubscribers=[];subscribe(e,t,n){return e&&this.subscribers.push(e),t&&this.errorSubscribers.push(t),n&&this.completeSubscribers.push(n),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e),this.errorSubscribers=this.errorSubscribers.filter(e=>e!==t),this.completeSubscribers=this.completeSubscribers.filter(e=>e!==n)}}}next(e){this.subscribers.forEach(t=>t(e))}error(e){this.errorSubscribers.forEach(t=>t(e))}complete(){this.completeSubscribers.forEach(e=>e())}map(t){let n=new e;return this.subscribe(e=>n.next(t(e)),e=>n.error(e),()=>n.complete()),n}filter(t){let n=new e;return this.subscribe(e=>{t(e)&&n.next(e)},e=>n.error(e),()=>n.complete()),n}};function oe(e){return t=>{if(!e(t))throw TypeError(`Value does not match expected type`);return t}}function O(e){return e}function se(e){return O(e)}var ce=class{_promise;resolveFunc;rejectFunc;constructor(){this._promise=new Promise((e,t)=>{this.resolveFunc=e,this.rejectFunc=t})}resolve(e){this.resolveFunc(e)}reject(e){this.rejectFunc(e)}get promise(){return this._promise}promise_(){return this._promise}};async function k(e,t={}){let n=e.body?.getReader();if(!n)throw Error(`Response body is not readable`);let r=[],i=0,a=parseInt(e.headers.get(`content-length`)||`0`,10);for(;;){let{done:e,value:o}=await n.read();if(e)break;r.push(o),i+=o.length,t.onChunk&&await t.onChunk(o),t.onProgress&&a>0&&t.onProgress(i,a)}return A(r,i)}function A(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}async function le(e,t){let n=await k(e);if(typeof window>`u`)await(await import(`fs`).then(e=>e.promises)).writeFile(t,n);else{let e=new Blob([n.buffer],{type:`application/octet-stream`}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}}function j(e={}){return async(t,n)=>{if(await n(),t.response&&t.response.body&&typeof t.response.body==`object`&&`getReader`in t.response.body){let n=t.response.body.getReader(),r=[],i=0,a=parseInt(t.response.headers?.[`content-length`]||`0`,10);try{for(;;){let{done:o,value:s}=await n.read();if(o)break;r.push(s),i+=s.length,e.onChunk&&await e.onChunk(s),e.onProgress&&a>0&&e.onProgress(i,a),t.state.streamedChunks=t.state.streamedChunks||[],t.state.streamedChunks.push(s)}let o=A(r,i);t.response.body=o,t.state.streaming=!0,t.state.streamedBytes=i}finally{n.releaseLock()}}}}var ue=j({onProgress:(e,t)=>{if(t>0){let n=Math.round(e/t*100);console.warn(`Streaming: ${n}% (${e}/${t} bytes)`)}}}),M=class{plugins=[];cache=new y;deduplicator=new S;middlewares=[];listeners=new Map;register(e){return this.plugins.push(e),e.setup(this),this.emit(`plugin:registered`,e.name),this}addMiddleware(e){return this.middlewares.push(e),this}getCache(){return this.cache}getDeduplicator(){return this.deduplicator}getPipeline(){return w(this.middlewares)}async executePipeline(e){await this.getPipeline()(e)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set);let n=this.listeners.get(e),r=t;return n&&n.add(r),this}emit(e,...t){let n=this.listeners.get(e);if(n)for(let e of n)e(...t)}off(e,t){return this.listeners.get(e)?.delete(t),this}getPlugins(){return[...this.plugins]}clear(){this.plugins=[],this.middlewares=[],this.listeners.clear(),this.cache.clear(),this.deduplicator.clear()}},de={name:`logger`,setup(e){e.on(`request:start`,(...e)=>{let t=e[0];console.warn(`Request started: ${t}`)}),e.on(`request:success`,(...e)=>{let t=e[0],n=e[1];console.warn(`Request succeeded: ${t} (${n})`)}),e.on(`request:error`,(...e)=>{let t=e[0],n=e[1];console.error(`❌ Request failed: ${t}`,n)})}},fe=class{name=`metrics`;metrics={requests:0,errors:0,totalTime:0,avgTime:0};setup(e){e.on(`request:complete`,(...e)=>{let t=e[0],n=e[1];this.metrics.requests++,this.metrics.totalTime+=t,this.metrics.avgTime=this.metrics.totalTime/this.metrics.requests,n||this.metrics.errors++})}getMetrics(){return{...this.metrics}}},pe=class{name=`cache`;ttlMs;constructor(e=6e4){this.ttlMs=e}setup(e){e.addMiddleware(b({ttlMs:this.ttlMs}))}},me=class{name=`dedupe`;setup(e){e.addMiddleware(C())}},he=class{store=new y;get(e){return this.store.get(e)}set(e,t,n=6e4){this.store.set(e,t,n)}has(e){return this.store.has(e)}clear(){this.store.clear()}},ge=class{maxAttempts;baseDelayMs;constructor(e=3,t=100){this.maxAttempts=e,this.baseDelayMs=t}shouldRetry(e,t){let n=t.status!==void 0&&t.status>=500,r=t.code===`NETWORK_ERROR`;return e<this.maxAttempts&&(n||r||t.code===`TIMEOUT`)}delayMs(e){let t=this.baseDelayMs*2**(e-1),n=Math.random()*t*.1;return Math.min(t+n,3e4)}},_e=class{running=0;queue=[];maxConcurrent;constructor(e){this.maxConcurrent=e}async acquire(){if(this.running<this.maxConcurrent){this.running++;return}return new Promise(e=>{this.queue.push(()=>{this.running++,e()})})}release(){this.running--;let e=this.queue.shift();e&&e()}get pending(){return this.queue.length}get active(){return this.running}};function N(e){return e==null?{serialized:void 0,contentType:null}:typeof e==`string`?{serialized:e,contentType:`text/plain`}:typeof FormData<`u`&&e instanceof FormData?{serialized:e,contentType:null}:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?{serialized:e,contentType:`application/x-www-form-urlencoded`}:typeof Blob<`u`&&e instanceof Blob?{serialized:e,contentType:e.type||`application/octet-stream`}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof ReadableStream<`u`&&e instanceof ReadableStream?{serialized:e,contentType:`application/octet-stream`}:{serialized:JSON.stringify(e),contentType:`application/json`}}function P(e,t){return t?e.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>{let r=t[n];if(r===void 0)throw Error(`Missing path parameter: :${n}`);return encodeURIComponent(String(r))}):e}function F(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r))for(let e of r)t.append(n,String(e));else if(typeof r==`object`)for(let[e,i]of Object.entries(r))i!=null&&t.append(`${n}[${e}]`,String(i));else t.append(n,String(r));return t.toString()}var I=class e{requestInterceptors=[];responseInterceptors=[];cache;devTracker;config;requestQueue;pendingRequests=new Set;constructor(e={}){this.config={baseURL:e.baseURL??``,defaultHeaders:e.defaultHeaders??{"Content-Type":`application/json`},defaultTimeout:e.defaultTimeout??3e4,validateStatus:e.validateStatus??(e=>e>=200&&e<300),cacheStrategy:e.cacheStrategy??new he,maxConcurrent:e.maxConcurrent??0,defaultResponseType:e.defaultResponseType??`auto`,defaultHooks:e.defaultHooks??{},adapter:e.adapter},this.cache=this.config.cacheStrategy,this.requestQueue=this.config.maxConcurrent>0?new _e(this.config.maxConcurrent):null,this.devTracker=e.devTracker??null}async request(e){if(!this.requestInterceptors.length&&!this.responseInterceptors.length&&!e.cache?.enabled&&!e.hooks&&!Object.keys(this.config.defaultHooks).length&&!e.retry&&!e.validate&&!e.transform&&!this.requestQueue&&!e.onDownloadProgress&&!e.signal)return this.fastPath(e);let r=e.hooks?{...this.config.defaultHooks,...e.hooks}:this.config.defaultHooks,i=this.getMaxAttempts(e.retry),a=this.getRetryStrategy(e.retry),o=this.buildRequest(e);r.onStart?.(o),this.requestQueue&&await this.requestQueue.acquire();try{for(let s=1;s<=i;s++){let c,l;try{if(this.isCacheableMethod(e.method)&&e.cache?.enabled){let n=this.getCacheKey(e),i=this.cache.get(n);if(i){let n=i;return this.trackDev({method:e.method??`GET`,url:o.url,status:n.status,duration:n.duration,cached:!0,ok:!0,headers:{...o.headers},body:e.body,retryCount:0}),r.onSuccess?.(n),r.onFinally?.(),t(n)}}let n=o;for(let e of this.requestInterceptors)n=await e.onRequest(n);c=new AbortController,this.pendingRequests.add(c),e.signal&&(l=()=>c.abort(),e.signal.addEventListener(`abort`,l,{once:!0}));let i=performance.now(),a=await this.fetchWithTimeout(n,this.resolveTimeoutMs(e.timeout??this.config.defaultTimeout),c),u=performance.now()-i,d=a;e.onDownloadProgress&&a.body&&(d=this.trackDownloadProgress(a,e.onDownloadProgress));let f=e.responseType??this.config.defaultResponseType,p=await this.parseResponse(d,n,u,f);if(!this.config.validateStatus(p.status))throw{message:`Request failed with status ${p.status}`,status:p.status,statusText:p.statusText,code:`HTTP_ERROR`};if(e.validate){let t=e.validate.validate(p.data);if(!t.ok)return t}e.transform&&(p.data=e.transform.transform(p.data));let m=p;for(let e of this.responseInterceptors)m=await e.onResponse(m);if(this.isCacheableMethod(e.method)&&e.cache?.enabled){let t=this.getCacheKey(e);this.cache.set(t,m,e.cache.ttlMs)}return r.onSuccess?.(m),this.pendingRequests.delete(c),this.trackDev({method:e.method??`GET`,url:o.url,status:m.status,duration:m.duration,cached:!1,ok:!0,headers:{...o.headers},body:e.body,retryCount:s-1}),t(m)}catch(t){let l;if(l=t instanceof DOMException?t.name===`TimeoutError`?{message:`Request timed out`,code:`TIMEOUT`}:t.name===`AbortError`?{message:`Request aborted`,code:`ABORTED`}:{message:t.message,code:`UNKNOWN_ERROR`,originalError:t}:this.isHttpErrorDetails(t)?t:this.normalizeError(t),s<i&&a.shouldRetry(s,l)){r.onRetry?.(s,l);let e=a.delayMs(s);await this.delay(e);continue}let u=l;for(let e of this.responseInterceptors)e.onError&&(u=await e.onError(u));return r.onError?.(u),c&&this.pendingRequests.delete(c),this.trackDev({method:e.method??`GET`,url:o.url,status:u.status,duration:0,cached:!1,ok:!1,code:u.code,headers:{...o.headers},body:e.body,retryCount:s-1}),n(u)}finally{e.signal&&l&&e.signal.removeEventListener(`abort`,l)}}let s={message:`Max retries exceeded`,code:`MAX_RETRIES`};return r.onError?.(s),this.trackDev({method:e.method??`GET`,url:o.url,duration:0,cached:!1,ok:!1,code:`MAX_RETRIES`,headers:{...o.headers},body:e.body,retryCount:i}),n(s)}finally{r.onFinally?.(),this.requestQueue&&this.requestQueue.release()}}async fastPath(e){let r=P(e.url,e.params),i=this.buildUrl(r,e.query),{serialized:a,contentType:o}=N(e.body),s={...this.config.defaultHeaders,...e.headers};o?s[`Content-Type`]=o:a instanceof FormData&&delete s[`Content-Type`];let c=new AbortController,l=this.resolveTimeoutMs(e.timeout??this.config.defaultTimeout);this.pendingRequests.add(c);let u=performance.now();try{let r=await this.fetchWithTimeout({url:i,method:e.method??`GET`,headers:s,body:e.body,params:e.params},l,c),a=performance.now()-u,o=await this.parseBody(r,e.responseType??this.config.defaultResponseType);if(!this.config.validateStatus(r.status)){let t=n({message:`Request failed with status ${r.status}`,status:r.status,statusText:r.statusText,code:`HTTP_ERROR`});return this.trackDev({method:e.method??`GET`,url:i,status:r.status,duration:a,cached:!1,ok:!1,code:`HTTP_ERROR`,headers:s,body:e.body,retryCount:0}),this.pendingRequests.delete(c),t}return this.pendingRequests.delete(c),this.trackDev({method:e.method??`GET`,url:i,status:r.status,duration:a,cached:!1,ok:!0,headers:s,body:e.body,retryCount:0}),t({status:r.status,statusText:r.statusText,headers:r.headers,data:o,request:{url:i,method:e.method??`GET`,headers:s,body:e.body,params:e.params},duration:a})}catch(t){this.pendingRequests.delete(c);let r=`UNKNOWN_ERROR`;if(t instanceof DOMException?t.name===`TimeoutError`?r=`TIMEOUT`:t.name===`AbortError`&&(r=`ABORTED`):t instanceof Error&&(t.name===`TimeoutError`?r=`TIMEOUT`:t.name===`AbortError`||t.message.includes(`abort`)?r=`ABORTED`:t.name===`TypeError`&&(r=`NETWORK_ERROR`)),this.trackDev({method:e.method??`GET`,url:i,duration:performance.now()-u,cached:!1,ok:!1,code:r,headers:s,body:e.body,retryCount:0}),t instanceof DOMException){if(t.name===`TimeoutError`)return n({message:`Request timed out`,code:`TIMEOUT`});if(t.name===`AbortError`)return n({message:`Request aborted`,code:`ABORTED`})}return t instanceof Error?t.name===`TimeoutError`?n({message:`Request timed out`,code:`TIMEOUT`}):t.name===`AbortError`||t.message.includes(`abort`)?n({message:`Request aborted`,code:`ABORTED`}):n({message:t.message,code:t.name===`TypeError`?`NETWORK_ERROR`:`UNKNOWN_ERROR`}):n({message:String(t),code:`UNKNOWN_ERROR`})}}get(e,t){return this.request({...t,url:e,method:`GET`})}post(e,t,n){return this.request({...n,url:e,method:`POST`,body:t})}put(e,t,n){return this.request({...n,url:e,method:`PUT`,body:t})}patch(e,t,n){return this.request({...n,url:e,method:`PATCH`,body:t})}query(e,t,n){return this.request({...n,url:e,method:`QUERY`,body:t})}delete(e,t){return this.request({...t,url:e,method:`DELETE`})}head(e,t){return this.request({...t,url:e,method:`HEAD`})}options(e,t){return this.request({...t,url:e,method:`OPTIONS`})}addRequestInterceptor(e){return this.requestInterceptors.push(e),()=>{let t=this.requestInterceptors.indexOf(e);t!==-1&&this.requestInterceptors.splice(t,1)}}addResponseInterceptor(e){return this.responseInterceptors.push(e),()=>{let t=this.responseInterceptors.indexOf(e);t!==-1&&this.responseInterceptors.splice(t,1)}}clearInterceptors(){this.requestInterceptors=[],this.responseInterceptors=[]}clearCache(){this.cache.clear()}cancelAll(){for(let e of this.pendingRequests)e.abort();this.pendingRequests.clear()}get activeRequests(){return this.pendingRequests.size}get queueStats(){return{active:this.requestQueue?.active??this.pendingRequests.size,pending:this.requestQueue?.pending??0}}extend(t={}){let n=new e({baseURL:t.baseURL??this.config.baseURL,defaultHeaders:{...this.config.defaultHeaders,...t.defaultHeaders},defaultTimeout:t.defaultTimeout??this.config.defaultTimeout,validateStatus:t.validateStatus??this.config.validateStatus,cacheStrategy:t.cacheStrategy??this.cache,maxConcurrent:t.maxConcurrent??this.config.maxConcurrent,defaultResponseType:t.defaultResponseType??this.config.defaultResponseType,defaultHooks:{...this.config.defaultHooks,...t.defaultHooks},adapter:t.adapter});for(let e of this.requestInterceptors)n.addRequestInterceptor(e);for(let e of this.responseInterceptors)n.addResponseInterceptor(e);return n}async*paginate(e,t,n={}){let r={...n};for(;;){let n=await this.get(e,r);if(!n.ok)break;yield t.getItems(n.value.data);let i=t.getNextPage(n.value.data,r);if(!i)break;r=i}}async poll(e,t,r={}){let i=t.maxAttempts??0;for(let n=1;i===0||n<=i;n++){let a=await this.get(e,r);if(!a.ok||(t.onPoll?.(a.value.data,n),t.until(a.value.data)))return a;if(i>0&&n>=i)break;await this.delay(t.intervalMs)}return n({message:`Polling exhausted after ${i} attempts`,code:`POLL_EXHAUSTED`})}buildRequest(e){let t=P(e.url,e.params);return{url:this.buildUrl(t,e.query),method:e.method??`GET`,headers:{...this.config.defaultHeaders,...e.headers},body:e.body,params:e.params}}buildUrl(e,t){let n=this.config.baseURL+e;if(t&&Object.keys(t).length>0){let e=F(t);e&&(n+=`?${e}`)}return n}isCacheableMethod(e){return e===`GET`||e===`QUERY`||!e}getCacheKey(e){let t=P(e.url,e.params),n=e.query?JSON.stringify(e.query):``,r=e.method===`QUERY`&&e.body!==void 0?JSON.stringify(e.body):``;return`${e.method??`GET`}:${t}${n?`:`+n:``}${r?`:`+r:``}`}fetchWithTimeout(e,t,n){let{serialized:r,contentType:i}=N(e.body),a={...e.headers};return i?a[`Content-Type`]=i:r instanceof FormData&&delete a[`Content-Type`],new Promise((i,o)=>{let s=setTimeout(()=>{n.abort(),o(new DOMException(`Request timed out`,`TimeoutError`))},t);(this.config.adapter??fetch)(e.url,{method:e.method,headers:a,body:r,signal:n.signal}).then(e=>{clearTimeout(s),i(e)},e=>{clearTimeout(s),o(e)})})}trackDownloadProgress(e,t){let n=parseInt(e.headers.get(`content-length`)||`0`,10),r=e.body?.getReader();if(!r)return e;let i=0,a=new ReadableStream({async pull(e){let{done:a,value:o}=await r.read();if(a){e.close();return}i+=o.byteLength,t({loaded:i,total:n,percent:n>0?Math.round(i/n*100):0}),e.enqueue(o)}});return new Response(a,{headers:e.headers,status:e.status,statusText:e.statusText})}async parseResponse(e,t,n,r){let i=await this.parseBody(e,r);return{status:e.status,statusText:e.statusText,headers:e.headers,data:i,request:t,duration:n}}async parseBody(e,t){switch(t){case`json`:return await e.json();case`text`:return await e.text();case`blob`:return await e.blob();case`arrayBuffer`:return await e.arrayBuffer();case`formData`:return await e.formData();case`stream`:return e.body;default:{let t=e.headers.get(`content-type`)??``;if(t.includes(`application/json`))return await e.json();if(t.includes(`text/`))return await e.text();if(t.includes(`multipart/form-data`))return await e.formData();if(t.includes(`application/octet-stream`)||t.includes(`image/`)||t.includes(`audio/`)||t.includes(`video/`))return await e.blob();try{return await e.json()}catch{return await e.text()}}}}normalizeError(e){if(e instanceof DOMException){if(e.name===`TimeoutError`)return{message:`Request timed out`,code:`TIMEOUT`};if(e.name===`AbortError`)return{message:`Request aborted`,code:`ABORTED`}}return e instanceof Error?e.name===`TimeoutError`?{message:`Request timed out`,code:`TIMEOUT`}:e.name===`AbortError`||e.message.includes(`abort`)?{message:`Request aborted`,code:`ABORTED`}:{message:e.message,code:e.name===`TypeError`?`NETWORK_ERROR`:`UNKNOWN_ERROR`,originalError:e}:{message:String(e),code:`UNKNOWN_ERROR`,originalError:e}}isHttpErrorDetails(e){return typeof e==`object`&&!!e&&`message`in e&&`code`in e}getMaxAttempts(e){return e?`maxAttempts`in e?e.maxAttempts??1:100:1}getRetryStrategy(e){return e?`shouldRetry`in e?e:new ge(e.maxAttempts,e.backoffMs):{shouldRetry:()=>!1,delayMs:()=>0}}resolveTimeoutMs(e){return typeof e==`number`?e:e.total??e.response??e.connection??3e4}delay(e){return new Promise(t=>setTimeout(t,e))}trackDev(e){this.devTracker&&this.devTracker.track(e)}},L=class extends Error{status;code;response;constructor(e,t,n,r){super(e),this.name=`HttpError`,this.status=t,this.code=n,this.response=r}};function ve(e){return e instanceof L}function ye(e){return new I(e)}function R(){return typeof window>`u`&&typeof process<`u`&&process.versions?.node!==void 0}var be=class{url;options;pluginManager;status=`closed`;reconnectAttempt=0;reconnectTimer=null;heartbeatTimer=null;stopHeartbeatMessageListener=null;stats={messagesSent:0,messagesReceived:0,connectionTime:0,reconnectAttempts:0};connectionStartTime=0;listeners={open:new Set,close:new Set,error:new Set,message:new Set};constructor(e,t={}){this.url=e,this.options=t,this.pluginManager=new M}updateStatus(e){this.status=e,e===`open`?this.connectionStartTime=Date.now():e===`closed`&&this.connectionStartTime>0&&(this.stats.connectionTime+=Date.now()-this.connectionStartTime,this.connectionStartTime=0)}emitOpen(e){this.pluginManager.emit(`websocket:open`,this.url,e);for(let t of this.listeners.open)t(e)}emitClose(e){this.pluginManager.emit(`websocket:close`,this.url,e);for(let t of this.listeners.close)t(e)}emitError(e){let t;e instanceof Error?(t=new Event(`error`),t.error=e):t=e,this.pluginManager.emit(`websocket:error`,this.url,t);for(let e of this.listeners.error)e(t)}emitMessage(e){this.pluginManager.emit(`websocket:message`,this.url,e);for(let t of this.listeners.message)t(e)}onOpen(e){return this.listeners.open.add(e),()=>this.listeners.open.delete(e)}onClose(e){return this.listeners.close.add(e),()=>this.listeners.close.delete(e)}onError(e){return this.listeners.error.add(e),()=>this.listeners.error.delete(e)}onMessage(e){return this.listeners.message.add(e),()=>this.listeners.message.delete(e)}getStatus(){return this.status}getStats(){return{...this.stats,connectionTime:this.stats.connectionTime+(this.connectionStartTime>0?Date.now()-this.connectionStartTime:0)}}scheduleReconnect(){if(this.options.reconnect?.enabled===!1)return;let e=this.options.reconnect?.maxAttempts??1/0;if(this.reconnectAttempt>=e){this.pluginManager.emit(`websocket:reconnect:failed`,this.url,this.reconnectAttempt);return}let t=this.options.reconnect?.baseDelay??1e3,n=this.options.reconnect?.maxDelay??3e4,r=t*2**this.reconnectAttempt,i=Math.random()*r*.1,a=Math.min(n,r+i);this.reconnectAttempt++,this.stats.reconnectAttempts=this.reconnectAttempt,this.options.reconnect?.onReconnecting?.(this.reconnectAttempt,a),this.pluginManager.emit(`websocket:reconnecting`,this.url,this.reconnectAttempt,a),this.reconnectTimer=setTimeout(()=>{this.connect().catch(e=>{this.emitError(e instanceof Error?e:Error(String(e)))})},a)}startHeartbeat(){if(!this.options.heartbeat)return;let e=this.options.heartbeat.interval??3e4,t=this.options.heartbeat.pingMessage??`ping`,n=this.options.heartbeat.pongMessage??`pong`,r=!0,i=()=>{if(!r){this.pluginManager.emit(`websocket:heartbeat:timeout`,this.url),this.disconnect();return}r=!1;let n=this.send(t);n.ok||this.pluginManager.emit(`websocket:heartbeat:send-failed`,this.url,n.error),this.heartbeatTimer=setTimeout(i,e)},a=e=>{let t=e.raw;typeof t==`string`&&t===n&&(r=!0)};this.stopHeartbeatMessageListener?.(),this.stopHeartbeatMessageListener=this.onMessage(a),this.heartbeatTimer=setTimeout(i,e)}stopHeartbeat(){this.heartbeatTimer&&=(clearTimeout(this.heartbeatTimer),null),this.stopHeartbeatMessageListener?.(),this.stopHeartbeatMessageListener=null}cleanup(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.stopHeartbeat()}},z=class extends be{socket=null;messageTypeListeners=new Map;constructor(e,t={}){super(e,t)}async connect(){if(!(this.status===`connecting`||this.status===`open`))return this.updateStatus(`connecting`),this.pluginManager.emit(`websocket:connect:start`,this.url),new Promise((e,t)=>{let n=this.options.timeout??1e4,r=setTimeout(()=>{this.updateStatus(`closed`),this.socket?.close(),this.socket=null;let e=Error(`WebSocket connection timeout after ${n}ms`);this.emitError(e),t(e)},n);try{this.socket=new WebSocket(this.url,this.options.protocols),this.socket.onopen=t=>{clearTimeout(r),this.updateStatus(`open`),this.reconnectAttempt=0,this.emitOpen(t),this.options.onOpen?.(t),this.startHeartbeat(),this.pluginManager.emit(`websocket:connect:success`,this.url),e()},this.socket.onclose=e=>{clearTimeout(r),this.updateStatus(`closed`),this.emitClose(e),this.options.onClose?.(e),this.stopHeartbeat(),this.pluginManager.emit(`websocket:disconnected`,this.url,e.code,e.reason),e.code!==1e3&&!e.wasClean&&this.scheduleReconnect()},this.socket.onerror=e=>{clearTimeout(r),this.updateStatus(`closed`),this.emitError(e),this.options.onError?.(e),this.pluginManager.emit(`websocket:connect:error`,this.url,e),t(e)},this.socket.onmessage=e=>{this.stats.messagesReceived++;let t={data:this.tryParseData(e.data),raw:e.data,type:`message`,timestamp:Date.now()};this.emitMessage(t),this.pluginManager.emit(`websocket:message:received`,this.url,t)}}catch(e){clearTimeout(r),this.updateStatus(`closed`),this.pluginManager.emit(`websocket:connect:error`,this.url,e),t(e)}})}disconnect(){this.cleanup(),this.socket&&(this.updateStatus(`closing`),this.socket.close(1e3,`Client disconnected`),this.socket=null,this.updateStatus(`closed`))}send(e){if(!this.socket||this.socket.readyState!==WebSocket.OPEN)return n({message:`WebSocket is not connected`,code:`NOT_CONNECTED`});try{this.socket.send(e)}catch(e){return n({message:e instanceof Error?e.message:`Failed to send WebSocket message`,code:`SEND_FAILED`})}return this.stats.messagesSent++,this.pluginManager.emit(`websocket:message:sent`,this.url,e),t(void 0)}sendJson(e){return this.send(JSON.stringify(e))}onMessageType(e,t){return this.messageTypeListeners.has(e)||this.messageTypeListeners.set(e,new Set),this.messageTypeListeners.get(e).add(t),()=>{let n=this.messageTypeListeners.get(e);n&&(n.delete(t),n.size===0&&this.messageTypeListeners.delete(e))}}tryParseData(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}},xe=class extends z{async connect(){if(R())try{let{default:e}=await import(`ws`);return super.connect()}catch{throw Error(`WebSocket client for Node.js requires the "ws" package. Please install it: npm install ws`)}return super.connect()}};function Se(e,t={}){return R()?new xe(e,t):new z(e,t)}function Ce(){return typeof window>`u`&&typeof process<`u`&&process.versions?.node!==void 0}var B=class{url;options;_source=null;pluginManager;status=`closed`;reconnectAttempt=0;reconnectTimer=null;stats={messagesSent:0,messagesReceived:0,connectionTime:0,reconnectAttempts:0};connectionStartTime=0;listeners={open:new Set,close:new Set,error:new Set,message:new Set,event:new Map};_lastEventId=null;nativeEventListeners=new Map;constructor(e,t={}){this.url=e,this.options=t,this.pluginManager=new M}updateStatus(e){this.status=e,e===`open`?this.connectionStartTime=Date.now():e===`closed`&&this.connectionStartTime>0&&(this.stats.connectionTime+=Date.now()-this.connectionStartTime,this.connectionStartTime=0)}async connect(){if(!(this.status===`connecting`||this.status===`open`))return this.updateStatus(`connecting`),this.pluginManager.emit(`sse:connect:start`,this.url),new Promise((e,t)=>{let n=this.options.timeout??1e4,r=setTimeout(()=>{this.updateStatus(`closed`),this._source?.close(),this._source=null,this.nativeEventListeners.clear();let e=Error(`SSE connection timeout after ${n}ms`);this.emitError(e),t(e)},n);try{this._source=new EventSource(this.url),this._source.onopen=t=>{clearTimeout(r),this.updateStatus(`open`),this.reconnectAttempt=0,this.emitOpen(t),this.options.onOpen?.(t),this.pluginManager.emit(`sse:connect:success`,this.url),e()},this._source.onerror=e=>{clearTimeout(r),this.updateStatus(`closed`),this.emitError(e),this.options.onError?.(e),this.pluginManager.emit(`sse:connect:error`,this.url,e),this._source?.readyState===EventSource.CLOSED&&(this.emitClose(),this.options.onClose?.(),this.scheduleReconnect()),t(e)},this._source.onmessage=e=>{this.stats.messagesReceived++,this._lastEventId=e.lastEventId||this._lastEventId;let t={data:this.tryParseData(e.data),raw:e.data,type:e.type||`message`,timestamp:Date.now()};this.emitMessage(t),this.pluginManager.emit(`sse:message:received`,this.url,t);let n=e.type||`message`,r=this.listeners.event.get(n);if(r)for(let e of r)e(t.data)},this.attachAllNamedListeners()}catch(e){clearTimeout(r),this.updateStatus(`closed`),this.pluginManager.emit(`sse:connect:error`,this.url,e),t(e)}})}disconnect(){this.cleanup(),this._source&&(this.updateStatus(`closing`),this._source.close(),this._source=null,this.nativeEventListeners.clear(),this.updateStatus(`closed`),this.emitClose(),this.options.onClose?.())}send(e){return n({message:`SSE is a receive-only protocol. Use HTTP requests to send data to server.`,code:`UNSUPPORTED`})}onMessage(e){return this.listeners.message.add(e),()=>this.listeners.message.delete(e)}onOpen(e){return this.listeners.open.add(e),()=>this.listeners.open.delete(e)}onClose(e){return this.listeners.close.add(e),()=>this.listeners.close.delete(e)}onError(e){return this.listeners.error.add(e),()=>this.listeners.error.delete(e)}attachNamedListener(e,t){if(!this._source)return;let n=n=>{t({data:this.tryParseData(n.data),raw:n.data,type:e,timestamp:Date.now()}.data)};this._source.addEventListener(e,n),this.nativeEventListeners.has(e)||this.nativeEventListeners.set(e,new Map),this.nativeEventListeners.get(e).set(t,n)}detachNamedListener(e,t){let n=this.nativeEventListeners.get(e)?.get(t);n&&(this._source?.removeEventListener(e,n),this.nativeEventListeners.get(e).delete(t),this.nativeEventListeners.get(e).size===0&&this.nativeEventListeners.delete(e))}attachAllNamedListeners(){this.nativeEventListeners.clear();for(let[e,t]of this.listeners.event)for(let n of t)this.attachNamedListener(e,n)}onEvent(e,t){return this.listeners.event.has(e)||this.listeners.event.set(e,new Set),this.listeners.event.get(e).add(t),this.attachNamedListener(e,t),()=>{let n=this.listeners.event.get(e);n&&(n.delete(t),n.size===0&&this.listeners.event.delete(e)),this.detachNamedListener(e,t)}}getStatus(){return this.status}getStats(){return{...this.stats,connectionTime:this.stats.connectionTime+(this.connectionStartTime>0?Date.now()-this.connectionStartTime:0)}}get lastEventId(){return this._lastEventId}get source(){return this._source}emitOpen(e){this.pluginManager.emit(`sse:open`,this.url,e);for(let t of this.listeners.open)t(e)}emitClose(){this.pluginManager.emit(`sse:close`,this.url);for(let e of this.listeners.close)e()}emitError(e){let t;e instanceof Error?(t=new Event(`error`),t.error=e):t=e,this.pluginManager.emit(`sse:error`,this.url,t);for(let e of this.listeners.error)e(t)}emitMessage(e){this.pluginManager.emit(`sse:message`,this.url,e);for(let t of this.listeners.message)t(e)}scheduleReconnect(){if(this.options.reconnect?.enabled===!1)return;let e=this.options.reconnect?.maxAttempts??1/0;if(this.reconnectAttempt>=e){this.pluginManager.emit(`sse:reconnect:failed`,this.url,this.reconnectAttempt);return}let t=this.options.reconnect?.baseDelay??1e3,n=this.options.reconnect?.maxDelay??3e4,r=t*2**this.reconnectAttempt,i=Math.random()*r*.1,a=Math.min(n,r+i);this.reconnectAttempt++,this.stats.reconnectAttempts=this.reconnectAttempt,this.options.reconnect?.onReconnecting?.(this.reconnectAttempt,a),this.pluginManager.emit(`sse:reconnecting`,this.url,this.reconnectAttempt,a),this.reconnectTimer=setTimeout(()=>{this.connect().catch(e=>{this.emitError(e instanceof Error?e:Error(String(e)))})},a)}cleanup(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}tryParseData(e){try{return JSON.parse(e)}catch{return e}}},we=class extends B{constructor(e,t={}){throw super(e,t),Error(`Nexa's SSE client is browser-only (it relies on the native EventSource API). Node.js has no built-in EventSource. Use a polyfill (e.g. the "eventsource" package) and pass it via a custom implementation, or run this client in a browser environment.`)}};function Te(e,t={}){return Ce()?new we(e,t):new B(e,t)}var Ee=class{name=`realtime`;setup(e){e.on(`websocket:connect:start`,(...t)=>{let n=t[0];e.emit(`realtime:connect:start`,`websocket`,n)}),e.on(`websocket:connect:success`,(...t)=>{let n=t[0];e.emit(`realtime:connect:success`,`websocket`,n)}),e.on(`websocket:message:received`,(...t)=>{let n=t[0],r=t[1];e.emit(`realtime:message`,`websocket`,n,r)}),e.on(`sse:connect:start`,(...t)=>{let n=t[0];e.emit(`realtime:connect:start`,`sse`,n)}),e.on(`sse:connect:success`,(...t)=>{let n=t[0];e.emit(`realtime:connect:success`,`sse`,n)}),e.on(`sse:message:received`,(...t)=>{let n=t[0],r=t[1];e.emit(`realtime:message`,`sse`,n,r)})}};function De(){return new Ee}var V=`nexa.devOverlay.config`;function H(){try{if(typeof localStorage>`u`)return{};let e=localStorage.getItem(V);return e?JSON.parse(e):{}}catch{return{}}}function Oe(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(V,JSON.stringify(e))}catch{}}var U=class{buffer=[];writeIndex=0;count=0;maxHistory;listeners=new Set;startTime=Date.now();config;constructor(e={}){this.maxHistory=Math.max(1,e.maxHistory??500),this.buffer=Array(this.maxHistory),this.config={enabled:e.enabled??!0,maxHistory:this.maxHistory,keyboardShortcut:e.keyboardShortcut??`ctrl+shift+n`,position:e.position??`bottom-right`,theme:e.theme??`dark`,devOnly:e.devOnly??!0,floatingButtonSize:e.floatingButtonSize??48,floatingButtonOffset:e.floatingButtonOffset??24,floatingButtonTheme:e.floatingButtonTheme??`inherit`,branding:e.branding??`Nexa DevTools`,icon:e.icon??`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`}}track(e){let t={...e,id:this.generateId(),timestamp:Date.now()};this.buffer[this.writeIndex]=t,this.writeIndex=(this.writeIndex+1)%this.maxHistory,this.count=Math.min(this.count+1,this.maxHistory);for(let e of this.listeners)e(t);return t}getHistory(){let e=[];for(let t=0;t<this.count;t++){let n=((this.writeIndex-1-t)%this.maxHistory+this.maxHistory)%this.maxHistory;e.push(this.buffer[n])}return e}getMetrics(){let e=this.getHistory(),t=e.map(e=>e.duration),n=(Date.now()-this.startTime)/1e3;return{totalRequests:e.length,successfulRequests:e.filter(e=>e.ok).length,failedRequests:e.filter(e=>!e.ok).length,cachedRequests:e.filter(e=>e.cached).length,avgDuration:t.length?t.reduce((e,t)=>e+t,0)/t.length:0,maxDuration:t.length?Math.max(...t):0,minDuration:t.length?Math.min(...t):0,requestsPerSecond:n>0?e.length/n:0,slowestRequests:e.sort((e,t)=>t.duration-e.duration).slice(0,5)}}clear(){this.buffer=Array(this.maxHistory),this.writeIndex=0,this.count=0,this.startTime=Date.now()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getConfig(){return this.config}updateConfig(e){this.config={...this.config,...e};let t=Math.max(1,this.config.maxHistory);t!==this.maxHistory&&this.resizeHistory(t);try{Oe(this.config)}catch{}return this.config}resizeHistory(e){let t=this.getHistory().slice(0,e);this.maxHistory=e,this.buffer=Array(e),this.writeIndex=0,this.count=0;for(let e=t.length-1;e>=0;e--)this.buffer[this.writeIndex]=t[e],this.writeIndex=(this.writeIndex+1)%this.maxHistory,this.count++}generateId(){return`${Date.now()}-${Math.random().toString(36).slice(2,8)}`}},W={gear:`<svg width="16" height="16" viewBox="0 0 48 48" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<path d="M 24 4 C 22.423103 4 20.902664 4.1994284 19.451172 4.5371094 A 1.50015 1.50015 0 0 0 18.300781 5.8359375 L 17.982422 8.7382812 C 17.878304 9.6893592 17.328913 10.530853 16.5 11.009766 C 15.672739 11.487724 14.66862 11.540667 13.792969 11.15625 L 13.791016 11.15625 L 11.125 9.9824219 A 1.50015 1.50015 0 0 0 9.4257812 10.330078 C 7.3532865 12.539588 5.7626807 15.215064 4.859375 18.201172 A 1.50015 1.50015 0 0 0 5.4082031 19.845703 L 7.7734375 21.580078 C 8.5457929 22.147918 9 23.042801 9 24 C 9 24.95771 8.5458041 25.853342 7.7734375 26.419922 L 5.4082031 28.152344 A 1.50015 1.50015 0 0 0 4.859375 29.796875 C 5.7625845 32.782665 7.3519262 35.460112 9.4257812 37.669922 A 1.50015 1.50015 0 0 0 11.125 38.015625 L 13.791016 36.841797 C 14.667094 36.456509 15.672169 36.511947 16.5 36.990234 C 17.328913 37.469147 17.878304 38.310641 17.982422 39.261719 L 18.300781 42.164062 A 1.50015 1.50015 0 0 0 19.449219 43.460938 C 20.901371 43.799844 22.423103 44 24 44 C 25.576897 44 27.097336 43.800572 28.548828 43.462891 A 1.50015 1.50015 0 0 0 29.699219 42.164062 L 30.017578 39.261719 C 30.121696 38.310641 30.671087 37.469147 31.5 36.990234 C 32.327261 36.512276 33.33138 36.45738 34.207031 36.841797 L 36.875 38.015625 A 1.50015 1.50015 0 0 0 38.574219 37.669922 C 40.646713 35.460412 42.237319 32.782983 43.140625 29.796875 A 1.50015 1.50015 0 0 0 42.591797 28.152344 L 40.226562 26.419922 C 39.454197 25.853342 39 24.95771 39 24 C 39 23.04229 39.454197 22.146658 40.226562 21.580078 L 42.591797 19.847656 A 1.50015 1.50015 0 0 0 43.140625 18.203125 C 42.237319 15.217017 40.646713 12.539588 38.574219 10.330078 A 1.50015 1.50015 0 0 0 36.875 9.984375 L 34.207031 11.158203 C 33.33138 11.54262 32.327261 11.487724 31.5 11.009766 C 30.671087 10.530853 30.121696 9.6893592 30.017578 8.7382812 L 29.699219 5.8359375 A 1.50015 1.50015 0 0 0 28.550781 4.5390625 C 27.098629 4.2001555 25.576897 4 24 4 z M 24 7 C 24.974302 7 25.90992 7.1748796 26.847656 7.3398438 L 27.035156 9.0644531 C 27.243038 10.963375 28.346913 12.652335 30 13.607422 C 31.654169 14.563134 33.668094 14.673009 35.416016 13.904297 L 37.001953 13.207031 C 38.219788 14.669402 39.183985 16.321182 39.857422 18.130859 L 38.451172 19.162109 C 36.911538 20.291529 36 22.08971 36 24 C 36 25.91029 36.911538 27.708471 38.451172 28.837891 L 39.857422 29.869141 C 39.183985 31.678818 38.219788 33.330598 37.001953 34.792969 L 35.416016 34.095703 C 33.668094 33.326991 31.654169 33.436866 30 34.392578 C 28.346913 35.347665 27.243038 37.036625 27.035156 38.935547 L 26.847656 40.660156 C 25.910002 40.82466 24.973817 41 24 41 C 23.025698 41 22.09008 40.82512 21.152344 40.660156 L 20.964844 38.935547 C 20.756962 37.036625 19.653087 35.347665 18 34.392578 C 16.345831 33.436866 14.331906 33.326991 12.583984 34.095703 L 10.998047 34.792969 C 9.7799772 33.330806 8.8159425 31.678964 8.1425781 29.869141 L 9.5488281 28.837891 C 11.088462 27.708471 12 25.91029 12 24 C 12 22.08971 11.087719 20.290363 9.5488281 19.160156 L 8.1425781 18.128906 C 8.8163325 16.318532 9.7814501 14.667839 11 13.205078 L 12.583984 13.902344 C 14.331906 14.671056 16.345831 14.563134 18 13.607422 C 19.653087 12.652335 20.756962 10.963375 20.964844 9.0644531 L 21.152344 7.3398438 C 22.089998 7.1753403 23.026183 7 24 7 z M 24 16 C 19.599487 16 16 19.59949 16 24 C 16 28.40051 19.599487 32 24 32 C 28.400513 32 32 28.40051 32 24 C 32 19.59949 28.400513 16 24 16 z M 24 19 C 26.779194 19 29 21.220808 29 24 C 29 26.779192 26.779194 29 24 29 C 21.220806 29 19 26.779192 19 24 C 19 21.220808 21.220806 19 24 19 z"></path>
|
|
3
|
-
</svg>`,close:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18M6 6l12 12"/></svg>`,chevron:`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>`,back:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>`,retry:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 4v6h6M23 20v-6h-6"/><path d="M20.49 9A9 9 0 005.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 013.51 15"/></svg>`,clear:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>`,search:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>`,clock:`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>`,zap:`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,download:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,copy:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>`},
|
|
3
|
+
</svg>`,close:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18M6 6l12 12"/></svg>`,chevron:`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>`,back:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>`,retry:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 4v6h6M23 20v-6h-6"/><path d="M20.49 9A9 9 0 005.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 013.51 15"/></svg>`,clear:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>`,search:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>`,clock:`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/></svg>`,zap:`<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,download:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`,copy:`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>`},G={bg:`#0b1120`,bgElevated:`#111827`,bgSurface:`#172033`,border:`#24324a`,borderFocus:`#35507a`,text:`#e5eefb`,textMuted:`#b4c4dd`,textDim:`#7f93b3`,accent:`#38bdf8`,accentHover:`#0ea5e9`,accentSoft:`rgba(56, 189, 248, 0.18)`,success:`#34d399`,successBg:`rgba(52, 211, 153, 0.16)`,error:`#fb7185`,errorBg:`rgba(251, 113, 133, 0.16)`,warning:`#fbbf24`,warningBg:`rgba(251, 191, 36, 0.16)`,info:`#a78bfa`,infoBg:`rgba(167, 139, 250, 0.16)`,get:`#34d399`,post:`#38bdf8`,put:`#fbbf24`,patch:`#a78bfa`,delete:`#fb7185`},ke=`
|
|
4
4
|
#nexa-dev-overlay * { margin: 0; padding: 0; box-sizing: border-box; }
|
|
5
5
|
#nexa-dev-overlay {
|
|
6
6
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
7
|
-
background: ${
|
|
8
|
-
color: ${
|
|
9
|
-
border: 1px solid ${
|
|
7
|
+
background: ${G.bg};
|
|
8
|
+
color: ${G.text};
|
|
9
|
+
border: 1px solid ${G.border};
|
|
10
10
|
border-radius: 16px;
|
|
11
11
|
box-shadow: 0 28px 60px -24px rgba(2, 6, 23, 0.78), 0 0 0 1px rgba(148, 163, 184, 0.08);
|
|
12
12
|
overflow: hidden;
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
align-items: center;
|
|
17
17
|
justify-content: space-between;
|
|
18
18
|
padding: 16px 20px;
|
|
19
|
-
border-bottom: 1px solid ${
|
|
20
|
-
background: ${
|
|
19
|
+
border-bottom: 1px solid ${G.border};
|
|
20
|
+
background: ${G.bgElevated};
|
|
21
21
|
}
|
|
22
22
|
#nexa-dev-overlay .nexa-header-left {
|
|
23
23
|
display: flex;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
32
|
justify-content: center;
|
|
33
|
-
background: linear-gradient(135deg, ${
|
|
33
|
+
background: linear-gradient(135deg, ${G.accentSoft}, rgba(255,255,255,0.02));
|
|
34
34
|
border-radius: 8px;
|
|
35
35
|
overflow: hidden;
|
|
36
36
|
}
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
background: transparent;
|
|
53
53
|
border: none;
|
|
54
54
|
border-radius: 8px;
|
|
55
|
-
color: ${
|
|
55
|
+
color: ${G.textMuted};
|
|
56
56
|
cursor: pointer;
|
|
57
57
|
transition: all 0.15s;
|
|
58
58
|
}
|
|
59
59
|
#nexa-dev-overlay .nexa-icon-btn:hover {
|
|
60
|
-
background: ${
|
|
61
|
-
color: ${
|
|
60
|
+
background: ${G.bgSurface};
|
|
61
|
+
color: ${G.text};
|
|
62
62
|
}
|
|
63
63
|
#nexa-dev-overlay .nexa-metrics-bar {
|
|
64
64
|
display: flex;
|
|
65
65
|
gap: 4px;
|
|
66
66
|
padding: 12px 16px;
|
|
67
|
-
background: ${
|
|
68
|
-
border-bottom: 1px solid ${
|
|
67
|
+
background: ${G.bg};
|
|
68
|
+
border-bottom: 1px solid ${G.border};
|
|
69
69
|
}
|
|
70
70
|
#nexa-dev-overlay .nexa-metric {
|
|
71
71
|
flex: 1;
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
align-items: center;
|
|
75
75
|
gap: 2px;
|
|
76
76
|
padding: 8px 12px;
|
|
77
|
-
background: ${
|
|
77
|
+
background: ${G.bgSurface};
|
|
78
78
|
border-radius: 10px;
|
|
79
79
|
transition: all 0.2s;
|
|
80
80
|
}
|
|
@@ -85,19 +85,19 @@
|
|
|
85
85
|
font-size: 18px;
|
|
86
86
|
font-weight: 700;
|
|
87
87
|
letter-spacing: -0.03em;
|
|
88
|
-
color: ${
|
|
88
|
+
color: ${G.text};
|
|
89
89
|
}
|
|
90
|
-
#nexa-dev-overlay .nexa-metric-ok .nexa-metric-value { color: ${
|
|
91
|
-
#nexa-dev-overlay .nexa-metric-err .nexa-metric-value { color: ${
|
|
90
|
+
#nexa-dev-overlay .nexa-metric-ok .nexa-metric-value { color: ${G.success}; }
|
|
91
|
+
#nexa-dev-overlay .nexa-metric-err .nexa-metric-value { color: ${G.error}; }
|
|
92
92
|
#nexa-dev-overlay .nexa-metric-label {
|
|
93
93
|
font-size: 11px;
|
|
94
|
-
color: ${
|
|
94
|
+
color: ${G.textDim};
|
|
95
95
|
text-transform: uppercase;
|
|
96
96
|
letter-spacing: 0.05em;
|
|
97
97
|
}
|
|
98
98
|
#nexa-dev-overlay .nexa-search {
|
|
99
99
|
padding: 12px 16px;
|
|
100
|
-
border-bottom: 1px solid ${
|
|
100
|
+
border-bottom: 1px solid ${G.border};
|
|
101
101
|
position: relative;
|
|
102
102
|
}
|
|
103
103
|
#nexa-dev-overlay .nexa-search-icon {
|
|
@@ -105,29 +105,29 @@
|
|
|
105
105
|
left: 28px;
|
|
106
106
|
top: 50%;
|
|
107
107
|
transform: translateY(-50%);
|
|
108
|
-
color: ${
|
|
108
|
+
color: ${G.textDim};
|
|
109
109
|
}
|
|
110
110
|
#nexa-dev-overlay .nexa-search-input {
|
|
111
111
|
width: 100%;
|
|
112
112
|
padding: 10px 12px 10px 38px;
|
|
113
|
-
background: ${
|
|
114
|
-
border: 1px solid ${
|
|
113
|
+
background: ${G.bg};
|
|
114
|
+
border: 1px solid ${G.border};
|
|
115
115
|
border-radius: 10px;
|
|
116
|
-
color: ${
|
|
116
|
+
color: ${G.text};
|
|
117
117
|
font-size: 13px;
|
|
118
118
|
outline: none;
|
|
119
119
|
transition: all 0.15s;
|
|
120
120
|
}
|
|
121
121
|
#nexa-dev-overlay .nexa-search-input:focus {
|
|
122
|
-
border-color: ${
|
|
123
|
-
box-shadow: 0 0 0 3px ${
|
|
122
|
+
border-color: ${G.accent};
|
|
123
|
+
box-shadow: 0 0 0 3px ${G.accentSoft};
|
|
124
124
|
}
|
|
125
|
-
#nexa-dev-overlay .nexa-search-input::placeholder { color: ${
|
|
125
|
+
#nexa-dev-overlay .nexa-search-input::placeholder { color: ${G.textDim}; }
|
|
126
126
|
#nexa-dev-overlay .nexa-filters {
|
|
127
127
|
display: flex;
|
|
128
128
|
gap: 6px;
|
|
129
129
|
padding: 12px 16px 12px 16px;
|
|
130
|
-
border-bottom: 1px solid ${
|
|
130
|
+
border-bottom: 1px solid ${G.border};
|
|
131
131
|
overflow-x: auto;
|
|
132
132
|
scrollbar-width: none;
|
|
133
133
|
min-height: 50px;
|
|
@@ -135,27 +135,27 @@
|
|
|
135
135
|
#nexa-dev-overlay .nexa-filters::-webkit-scrollbar { display: none; }
|
|
136
136
|
#nexa-dev-overlay .nexa-filter-chip {
|
|
137
137
|
padding: 4px 10px;
|
|
138
|
-
background: ${
|
|
139
|
-
border: 1px solid ${
|
|
138
|
+
background: ${G.bgSurface};
|
|
139
|
+
border: 1px solid ${G.border};
|
|
140
140
|
border-radius: 20px;
|
|
141
|
-
color: ${
|
|
141
|
+
color: ${G.textDim};
|
|
142
142
|
font-size: 11px;
|
|
143
143
|
font-weight: 600;
|
|
144
144
|
white-space: nowrap;
|
|
145
145
|
cursor: pointer;
|
|
146
146
|
transition: all 0.15s;
|
|
147
147
|
}
|
|
148
|
-
#nexa-dev-overlay .nexa-filter-chip:hover { border-color: ${
|
|
148
|
+
#nexa-dev-overlay .nexa-filter-chip:hover { border-color: ${G.borderFocus}; color: ${G.textMuted}; }
|
|
149
149
|
#nexa-dev-overlay .nexa-filter-chip-active {
|
|
150
|
-
background: ${
|
|
151
|
-
border-color: ${
|
|
152
|
-
color: ${
|
|
150
|
+
background: ${G.accentSoft};
|
|
151
|
+
border-color: ${G.accent};
|
|
152
|
+
color: ${G.accent};
|
|
153
153
|
}
|
|
154
154
|
#nexa-dev-overlay .nexa-tabs {
|
|
155
155
|
display: flex;
|
|
156
156
|
gap: 4px;
|
|
157
157
|
padding: 8px 16px;
|
|
158
|
-
border-bottom: 1px solid ${
|
|
158
|
+
border-bottom: 1px solid ${G.border};
|
|
159
159
|
}
|
|
160
160
|
#nexa-dev-overlay .nexa-tab {
|
|
161
161
|
display: flex;
|
|
@@ -165,14 +165,14 @@
|
|
|
165
165
|
background: transparent;
|
|
166
166
|
border: none;
|
|
167
167
|
border-radius: 8px;
|
|
168
|
-
color: ${
|
|
168
|
+
color: ${G.textMuted};
|
|
169
169
|
font-size: 13px;
|
|
170
170
|
font-weight: 500;
|
|
171
171
|
cursor: pointer;
|
|
172
172
|
transition: all 0.15s;
|
|
173
173
|
}
|
|
174
|
-
#nexa-dev-overlay .nexa-tab:hover { color: ${
|
|
175
|
-
#nexa-dev-overlay .nexa-tab-active { color: ${
|
|
174
|
+
#nexa-dev-overlay .nexa-tab:hover { color: ${G.text}; background: ${G.bgElevated}; }
|
|
175
|
+
#nexa-dev-overlay .nexa-tab-active { color: ${G.text}; background: ${G.accent} !important; }
|
|
176
176
|
#nexa-dev-overlay .nexa-tab-count {
|
|
177
177
|
font-size: 11px;
|
|
178
178
|
padding: 2px 6px;
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
align-items: center;
|
|
194
194
|
justify-content: space-between;
|
|
195
195
|
padding: 12px 14px;
|
|
196
|
-
background: ${
|
|
196
|
+
background: ${G.bgSurface};
|
|
197
197
|
border: 1px solid transparent;
|
|
198
198
|
border-radius: 12px;
|
|
199
199
|
cursor: pointer;
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
@keyframes nexaFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
|
205
205
|
#nexa-dev-overlay .nexa-request-item:hover {
|
|
206
206
|
background: rgba(23, 32, 51, 0.92);
|
|
207
|
-
border-color: ${
|
|
207
|
+
border-color: ${G.borderFocus};
|
|
208
208
|
transform: translateX(2px);
|
|
209
209
|
}
|
|
210
210
|
#nexa-dev-overlay .nexa-req-left {
|
|
@@ -220,11 +220,11 @@
|
|
|
220
220
|
text-transform: uppercase;
|
|
221
221
|
letter-spacing: 0.03em;
|
|
222
222
|
}
|
|
223
|
-
#nexa-dev-overlay .nexa-method-get { background: ${
|
|
224
|
-
#nexa-dev-overlay .nexa-method-post { background: ${
|
|
225
|
-
#nexa-dev-overlay .nexa-method-put { background: ${
|
|
226
|
-
#nexa-dev-overlay .nexa-method-patch { background: ${
|
|
227
|
-
#nexa-dev-overlay .nexa-method-delete { background: ${
|
|
223
|
+
#nexa-dev-overlay .nexa-method-get { background: ${G.successBg}; color: ${G.get}; }
|
|
224
|
+
#nexa-dev-overlay .nexa-method-post { background: ${G.accentSoft}; color: ${G.post}; }
|
|
225
|
+
#nexa-dev-overlay .nexa-method-put { background: ${G.warningBg}; color: ${G.put}; }
|
|
226
|
+
#nexa-dev-overlay .nexa-method-patch { background: ${G.infoBg}; color: ${G.patch}; }
|
|
227
|
+
#nexa-dev-overlay .nexa-method-delete { background: ${G.errorBg}; color: ${G.delete}; }
|
|
228
228
|
#nexa-dev-overlay .nexa-status {
|
|
229
229
|
font-size: 12px;
|
|
230
230
|
font-weight: 600;
|
|
@@ -233,11 +233,11 @@
|
|
|
233
233
|
min-width: 36px;
|
|
234
234
|
text-align: center;
|
|
235
235
|
}
|
|
236
|
-
#nexa-dev-overlay .nexa-ok { background: ${
|
|
237
|
-
#nexa-dev-overlay .nexa-err { background: ${
|
|
236
|
+
#nexa-dev-overlay .nexa-ok { background: ${G.successBg}; color: ${G.success}; }
|
|
237
|
+
#nexa-dev-overlay .nexa-err { background: ${G.errorBg}; color: ${G.error}; }
|
|
238
238
|
#nexa-dev-overlay .nexa-url {
|
|
239
239
|
font-size: 13px;
|
|
240
|
-
color: ${
|
|
240
|
+
color: ${G.textMuted};
|
|
241
241
|
max-width: 180px;
|
|
242
242
|
overflow: hidden;
|
|
243
243
|
text-overflow: ellipsis;
|
|
@@ -256,15 +256,15 @@
|
|
|
256
256
|
text-transform: uppercase;
|
|
257
257
|
letter-spacing: 0.03em;
|
|
258
258
|
}
|
|
259
|
-
#nexa-dev-overlay .nexa-badge-cache { background: ${
|
|
260
|
-
#nexa-dev-overlay .nexa-badge-retry { background: ${
|
|
259
|
+
#nexa-dev-overlay .nexa-badge-cache { background: ${G.infoBg}; color: ${G.info}; }
|
|
260
|
+
#nexa-dev-overlay .nexa-badge-retry { background: ${G.warningBg}; color: ${G.warning}; }
|
|
261
261
|
#nexa-dev-overlay .nexa-duration {
|
|
262
262
|
font-size: 12px;
|
|
263
263
|
font-weight: 600;
|
|
264
|
-
color: ${
|
|
264
|
+
color: ${G.textDim};
|
|
265
265
|
font-variant-numeric: tabular-nums;
|
|
266
266
|
}
|
|
267
|
-
#nexa-dev-overlay .nexa-slow { color: ${
|
|
267
|
+
#nexa-dev-overlay .nexa-slow { color: ${G.warning}; }
|
|
268
268
|
#nexa-dev-overlay .nexa-empty {
|
|
269
269
|
display: flex;
|
|
270
270
|
flex-direction: column;
|
|
@@ -272,11 +272,11 @@
|
|
|
272
272
|
justify-content: center;
|
|
273
273
|
padding: 48px 24px;
|
|
274
274
|
text-align: center;
|
|
275
|
-
color: ${
|
|
275
|
+
color: ${G.textDim};
|
|
276
276
|
}
|
|
277
277
|
#nexa-dev-overlay .nexa-empty svg { margin-bottom: 16px; opacity: 0.4; }
|
|
278
|
-
#nexa-dev-overlay .nexa-empty p { font-size: 14px; color: ${
|
|
279
|
-
#nexa-dev-overlay .nexa-empty span { font-size: 12px; color: ${
|
|
278
|
+
#nexa-dev-overlay .nexa-empty p { font-size: 14px; color: ${G.textMuted}; margin-bottom: 4px; }
|
|
279
|
+
#nexa-dev-overlay .nexa-empty span { font-size: 12px; color: ${G.textDim}; }
|
|
280
280
|
#nexa-dev-overlay .nexa-detail {
|
|
281
281
|
flex-direction: column;
|
|
282
282
|
padding: 16px;
|
|
@@ -300,23 +300,23 @@
|
|
|
300
300
|
align-items: center;
|
|
301
301
|
gap: 6px;
|
|
302
302
|
padding: 8px 14px;
|
|
303
|
-
background: ${
|
|
304
|
-
border: 1px solid ${
|
|
303
|
+
background: ${G.bgSurface};
|
|
304
|
+
border: 1px solid ${G.border};
|
|
305
305
|
border-radius: 8px;
|
|
306
|
-
color: ${
|
|
306
|
+
color: ${G.textMuted};
|
|
307
307
|
font-size: 13px;
|
|
308
308
|
font-weight: 500;
|
|
309
309
|
cursor: pointer;
|
|
310
310
|
transition: all 0.15s;
|
|
311
311
|
}
|
|
312
|
-
#nexa-dev-overlay .nexa-btn:hover { background: rgba(53, 80, 122, 0.24); color: ${
|
|
313
|
-
#nexa-dev-overlay .nexa-btn-retry { background: ${
|
|
314
|
-
#nexa-dev-overlay .nexa-btn-retry:hover { background: ${
|
|
315
|
-
#nexa-dev-overlay .nexa-btn-copy { background: ${
|
|
316
|
-
#nexa-dev-overlay .nexa-btn-copy:hover { background: ${
|
|
312
|
+
#nexa-dev-overlay .nexa-btn:hover { background: rgba(53, 80, 122, 0.24); color: ${G.text}; }
|
|
313
|
+
#nexa-dev-overlay .nexa-btn-retry { background: ${G.successBg}; border-color: transparent; color: ${G.success}; }
|
|
314
|
+
#nexa-dev-overlay .nexa-btn-retry:hover { background: ${G.success}; color: #052e26; }
|
|
315
|
+
#nexa-dev-overlay .nexa-btn-copy { background: ${G.accentSoft}; border-color: transparent; color: ${G.accent}; }
|
|
316
|
+
#nexa-dev-overlay .nexa-btn-copy:hover { background: ${G.accent}; color: #ffffff; }
|
|
317
317
|
#nexa-dev-overlay .nexa-card {
|
|
318
|
-
background: ${
|
|
319
|
-
border: 1px solid ${
|
|
318
|
+
background: ${G.bgSurface};
|
|
319
|
+
border: 1px solid ${G.border};
|
|
320
320
|
border-radius: 12px;
|
|
321
321
|
padding: 16px;
|
|
322
322
|
margin-bottom: 12px;
|
|
@@ -324,7 +324,7 @@
|
|
|
324
324
|
#nexa-dev-overlay .nexa-card h3 {
|
|
325
325
|
font-size: 12px;
|
|
326
326
|
font-weight: 600;
|
|
327
|
-
color: ${
|
|
327
|
+
color: ${G.textDim};
|
|
328
328
|
text-transform: uppercase;
|
|
329
329
|
letter-spacing: 0.05em;
|
|
330
330
|
margin-bottom: 12px;
|
|
@@ -334,11 +334,11 @@
|
|
|
334
334
|
bottom: 24px;
|
|
335
335
|
left: 50%;
|
|
336
336
|
transform: translateX(-50%) translateY(20px);
|
|
337
|
-
background: ${
|
|
338
|
-
color: ${
|
|
337
|
+
background: ${G.bgElevated};
|
|
338
|
+
color: ${G.text};
|
|
339
339
|
padding: 10px 18px;
|
|
340
340
|
border-radius: 12px;
|
|
341
|
-
border: 1px solid ${
|
|
341
|
+
border: 1px solid ${G.borderFocus};
|
|
342
342
|
font-size: 13px;
|
|
343
343
|
font-weight: 500;
|
|
344
344
|
box-shadow: 0 12px 32px rgba(0,0,0,0.4);
|
|
@@ -357,20 +357,20 @@
|
|
|
357
357
|
align-items: center;
|
|
358
358
|
padding: 6px 0;
|
|
359
359
|
font-size: 13px;
|
|
360
|
-
border-bottom: 1px solid ${
|
|
360
|
+
border-bottom: 1px solid ${G.border};
|
|
361
361
|
}
|
|
362
362
|
#nexa-dev-overlay .nexa-row:last-child { border-bottom: none; }
|
|
363
|
-
#nexa-dev-overlay .nexa-row span { color: ${
|
|
364
|
-
#nexa-dev-overlay .nexa-row strong { color: ${
|
|
365
|
-
#nexa-dev-overlay .nexa-row .nexa-ok { color: ${
|
|
366
|
-
#nexa-dev-overlay .nexa-row .nexa-err { color: ${
|
|
363
|
+
#nexa-dev-overlay .nexa-row span { color: ${G.textMuted}; }
|
|
364
|
+
#nexa-dev-overlay .nexa-row strong { color: ${G.text}; font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
365
|
+
#nexa-dev-overlay .nexa-row .nexa-ok { color: ${G.success}; }
|
|
366
|
+
#nexa-dev-overlay .nexa-row .nexa-err { color: ${G.error}; }
|
|
367
367
|
#nexa-dev-overlay .nexa-code {
|
|
368
|
-
background: ${
|
|
368
|
+
background: ${G.bg};
|
|
369
369
|
border-radius: 8px;
|
|
370
370
|
padding: 12px;
|
|
371
371
|
font-size: 11px;
|
|
372
372
|
font-family: 'JetBrains Mono', 'Fira Code', monospace;
|
|
373
|
-
color: ${
|
|
373
|
+
color: ${G.textMuted};
|
|
374
374
|
overflow-x: auto;
|
|
375
375
|
white-space: pre;
|
|
376
376
|
max-height: 200px;
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
#nexa-dev-overlay .nexa-url-full {
|
|
380
380
|
font-size: 12px;
|
|
381
381
|
word-break: break-all;
|
|
382
|
-
color: ${
|
|
382
|
+
color: ${G.accent};
|
|
383
383
|
}
|
|
384
384
|
#nexa-dev-overlay .nexa-metrics-content {
|
|
385
385
|
padding: 16px;
|
|
@@ -399,14 +399,14 @@
|
|
|
399
399
|
gap: 12px;
|
|
400
400
|
padding: 16px;
|
|
401
401
|
border-radius: 12px;
|
|
402
|
-
background: ${
|
|
403
|
-
border: 1px solid ${
|
|
402
|
+
background: ${G.bgElevated};
|
|
403
|
+
border: 1px solid ${G.border};
|
|
404
404
|
box-shadow: 0 28px 60px -24px rgba(2, 6, 23, 0.76);
|
|
405
405
|
overflow: auto;
|
|
406
406
|
}
|
|
407
407
|
#nexa-dev-overlay .nexa-settings-row { display:flex;align-items:center;gap:8px;margin-bottom:8px }
|
|
408
|
-
#nexa-dev-overlay .nexa-settings-row label{font-size:13px;color:${
|
|
409
|
-
#nexa-dev-overlay .nexa-settings-row select{padding:6px 8px;border-radius:8px;border:1px solid ${
|
|
408
|
+
#nexa-dev-overlay .nexa-settings-row label{font-size:13px;color:${G.textDim};min-width:70px}
|
|
409
|
+
#nexa-dev-overlay .nexa-settings-row select{padding:6px 8px;border-radius:8px;border:1px solid ${G.border};background:${G.bg};color:${G.text}}
|
|
410
410
|
|
|
411
411
|
#nexa-dev-overlay.nexa-theme-light {
|
|
412
412
|
background: #f8fbff;
|
|
@@ -504,7 +504,76 @@
|
|
|
504
504
|
#nexa-dev-overlay.nexa-view-detail .nexa-body {
|
|
505
505
|
display: none !important;
|
|
506
506
|
}
|
|
507
|
-
`;function
|
|
507
|
+
`;function K(){try{if(typeof process<`u`){let e=process;if(e.env&&typeof e.env.NODE_ENV==`string`)return e.env.NODE_ENV===`development`}}catch{}try{if(typeof location<`u`&&location.hostname){let e=location.hostname;if(e===`localhost`||e===`127.0.0.1`||e===`0.0.0.0`)return!0}}catch{}return!1}function q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function J(e,t=35){try{let t=new URL(e);return t.pathname+(t.search||``)}catch{return e.length>t?e.slice(0,t)+`...`:e}}function Y(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ae(e,t,n){let r=e;return t===`err`?r=r.filter(e=>!e.ok):t===`xhr`?r=r.filter(e=>e.headers[`content-type`]&&e.headers[`content-type`].includes(`json`)||e.responseHeaders&&e.responseHeaders[`content-type`]&&e.responseHeaders[`content-type`].includes(`json`)):t===`slow`&&(r=r.filter(e=>e.duration>500)),n&&(r=r.filter(e=>e.url.toLowerCase().includes(n)||e.method.toLowerCase().includes(n)||String(e.status).includes(n))),r}function je(e,t){return e.length===0?`
|
|
508
|
+
<div class="nexa-empty">
|
|
509
|
+
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
510
|
+
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
511
|
+
</svg>
|
|
512
|
+
<p>${t?`No matching requests`:`No requests yet`}</p>
|
|
513
|
+
<span>${t?`Try a different search term`:`Make a request to see it here`}</span>
|
|
514
|
+
</div>`:e.map((e,t)=>`
|
|
515
|
+
<div class="nexa-request-item" data-id="${e.id}" style="animation-delay: ${Math.min(t*20,300)}ms">
|
|
516
|
+
<div class="nexa-req-left">
|
|
517
|
+
<span class="nexa-method nexa-method-${e.method.toLowerCase()}">${e.method}</span>
|
|
518
|
+
<span class="nexa-status ${e.ok?`nexa-ok`:`nexa-err`}">${e.status||`ERR`}</span>
|
|
519
|
+
<span class="nexa-url" title="${q(e.url)}">${q(J(e.url))}</span>
|
|
520
|
+
</div>
|
|
521
|
+
<div class="nexa-req-right">
|
|
522
|
+
${e.cached?`<span class="nexa-badge nexa-badge-cache">Cache</span>`:``}
|
|
523
|
+
${e.retryCount>0?`<span class="nexa-badge nexa-badge-retry">${e.retryCount}R</span>`:``}
|
|
524
|
+
<span class="nexa-duration ${e.duration>500?`nexa-slow`:``}">${e.duration.toFixed(0)}ms</span>
|
|
525
|
+
${W.chevron}
|
|
526
|
+
</div>
|
|
527
|
+
</div>
|
|
528
|
+
`).join(``)}function Me(e){let t=e.totalRequests>0?(e.successfulRequests/e.totalRequests*100).toFixed(1):`0`;return`
|
|
529
|
+
<div class="nexa-card">
|
|
530
|
+
<h3>Overview</h3>
|
|
531
|
+
<div class="nexa-row"><span>Total Requests</span><strong>${e.totalRequests}</strong></div>
|
|
532
|
+
<div class="nexa-row"><span>Successful</span><strong class="nexa-ok">${e.successfulRequests}</strong></div>
|
|
533
|
+
<div class="nexa-row"><span>Failed</span><strong class="nexa-err">${e.failedRequests}</strong></div>
|
|
534
|
+
<div class="nexa-row"><span>Cached</span><strong>${e.cachedRequests}</strong></div>
|
|
535
|
+
<div class="nexa-row"><span>Success Rate</span><strong>${t}%</strong></div>
|
|
536
|
+
</div>
|
|
537
|
+
<div class="nexa-card">
|
|
538
|
+
<h3>Performance</h3>
|
|
539
|
+
<div class="nexa-row"><span>Average</span><strong>${e.avgDuration.toFixed(1)}ms</strong></div>
|
|
540
|
+
<div class="nexa-row"><span>Fastest</span><strong class="nexa-ok">${e.minDuration.toFixed(1)}ms</strong></div>
|
|
541
|
+
<div class="nexa-row"><span>Slowest</span><strong class="nexa-err">${e.maxDuration.toFixed(1)}ms</strong></div>
|
|
542
|
+
<div class="nexa-row"><span>Throughput</span><strong>${e.requestsPerSecond.toFixed(2)} req/s</strong></div>
|
|
543
|
+
</div>
|
|
544
|
+
${e.slowestRequests.length>0?`
|
|
545
|
+
<div class="nexa-card">
|
|
546
|
+
<h3>Slowest Requests</h3>
|
|
547
|
+
${e.slowestRequests.map(e=>`
|
|
548
|
+
<div class="nexa-row nexa-slow-req">
|
|
549
|
+
<span><span class="nexa-method nexa-method-${e.method.toLowerCase()}" style="font-size:10px;padding:2px 5px;">${e.method}</span> ${q(J(e.url,25))}</span>
|
|
550
|
+
<strong class="nexa-err">${e.duration.toFixed(0)}ms</strong>
|
|
551
|
+
</div>
|
|
552
|
+
`).join(``)}
|
|
553
|
+
</div>
|
|
554
|
+
`:``}`}function Ne(e){return`
|
|
555
|
+
<div class="nexa-card">
|
|
556
|
+
<h3>Request</h3>
|
|
557
|
+
<div class="nexa-row"><span>Method</span><strong style="color:${e.method===`GET`?G.get:e.method===`POST`?G.post:e.method===`DELETE`?G.delete:G.warning}">${e.method}</strong></div>
|
|
558
|
+
<div class="nexa-row"><span>URL</span><span class="nexa-url-full">${q(e.url)}</span></div>
|
|
559
|
+
<div class="nexa-row"><span>Status</span><strong class="${e.ok?`nexa-ok`:`nexa-err`}">${e.status||`N/A`}</strong></div>
|
|
560
|
+
<div class="nexa-row"><span>Duration</span><strong>${e.duration.toFixed(1)}ms</strong></div>
|
|
561
|
+
<div class="nexa-row"><span>Cached</span><strong>${e.cached?`Yes`:`No`}</strong></div>
|
|
562
|
+
<div class="nexa-row"><span>Retries</span><strong>${e.retryCount}</strong></div>
|
|
563
|
+
<div class="nexa-row"><span>Timestamp</span><strong>${new Date(e.timestamp).toLocaleTimeString()}</strong></div>
|
|
564
|
+
</div>
|
|
565
|
+
${e.body===void 0?``:`
|
|
566
|
+
<div class="nexa-card">
|
|
567
|
+
<h3>Request Body</h3>
|
|
568
|
+
<pre class="nexa-code">${q(Y(e.body))}</pre>
|
|
569
|
+
</div>
|
|
570
|
+
`}
|
|
571
|
+
${Object.keys(e.headers).length>0?`
|
|
572
|
+
<div class="nexa-card">
|
|
573
|
+
<h3>Headers</h3>
|
|
574
|
+
<pre class="nexa-code">${q(Y(e.headers))}</pre>
|
|
575
|
+
</div>
|
|
576
|
+
`:``}`}var X=class{panel=null;floatingIcon=null;tracker;visible=!1;selectedRequest=null;config;searchQuery=``;filterType=`all`;removeTrackerListener=null;keyboardShortcutHandler=null;globalKeyboardHandler=null;constructor(e){this.tracker=e,this.config=e.getConfig(),this.canUseDOM()&&(this.setupKeyboardShortcut(),this.createPanel())}show(){this.panel&&(this.panel.style.display=`flex`,this.panel.style.opacity=`0`,this.panel.style.transform=`scale(0.96) translateY(8px)`,(typeof requestAnimationFrame==`function`?requestAnimationFrame:e=>setTimeout(e,0))(()=>{this.panel.style.transition=`all 0.25s cubic-bezier(0.16, 1, 0.3, 1)`,this.panel.style.opacity=`1`,this.panel.style.transform=`scale(1) translateY(0)`}),this.visible=!0,this.hideFloatingIcon())}hide(){this.panel&&(this.panel.style.transition=`all 0.15s ease-out`,this.panel.style.opacity=`0`,this.panel.style.transform=`scale(0.96) translateY(8px)`,setTimeout(()=>{this.panel&&(this.panel.style.display=`none`)},150),this.visible=!1,this.config.enabled&&(!this.config.devOnly||K())&&this.showFloatingIcon())}toggle(){this.visible?this.hide():this.show()}destroy(){this.keyboardShortcutHandler&&=(document.removeEventListener(`keydown`,this.keyboardShortcutHandler),null),this.globalKeyboardHandler&&=(document.removeEventListener(`keydown`,this.globalKeyboardHandler),null),this.removeTrackerListener?.(),this.removeTrackerListener=null,this.panel?.remove(),this.panel=null,this.visible=!1,this.selectedRequest=null,this.floatingIcon&&=(this.floatingIcon.remove(),null)}setupKeyboardShortcut(){let e=this.config.keyboardShortcut.split(`+`),t=new Set(e.map(e=>e.toLowerCase()));this.keyboardShortcutHandler=e=>{let n=new Set;e.ctrlKey&&n.add(`ctrl`),e.metaKey&&(n.add(`meta`),n.add(`cmd`),n.add(`ctrl`)),e.shiftKey&&n.add(`shift`),e.altKey&&n.add(`alt`),(e.key&&e.key.length===1||e.key.length>1)&&n.add(e.key.toLowerCase());let r=!0;for(let e of t)if(!n.has(e)){r=!1;break}r&&n.size===t.size&&(e.preventDefault(),this.toggle())},document.addEventListener(`keydown`,this.keyboardShortcutHandler)}createPanel(){if(!this.canUseDOM())return;try{let e=document.getElementById(`nexa-dev-overlay`);e&&e.remove()}catch{}this.panel=document.createElement(`div`),this.panel.id=`nexa-dev-overlay`;let e=this.config.position,t=e.includes(`bottom`),n=e.includes(`right`),r=`${this.config.floatingButtonOffset??24}px`,i=this.config.branding||`Nexa DevTools`,a=this.config.icon||`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`;this.panel.style.cssText=`
|
|
508
577
|
position: fixed;
|
|
509
578
|
${t?`bottom: ${r};`:`top: ${r};`}
|
|
510
579
|
${n?`right: ${r};`:`left: ${r};`}
|
|
@@ -514,7 +583,7 @@
|
|
|
514
583
|
display: flex;
|
|
515
584
|
flex-direction: column;
|
|
516
585
|
overflow: hidden;
|
|
517
|
-
`,this.panel.innerHTML=`<style>${
|
|
586
|
+
`,this.panel.innerHTML=`<style>${ke}</style>
|
|
518
587
|
|
|
519
588
|
<div class="nexa-header">
|
|
520
589
|
<div class="nexa-header-left">
|
|
@@ -524,10 +593,10 @@
|
|
|
524
593
|
<span class="nexa-title">${i}</span>
|
|
525
594
|
</div>
|
|
526
595
|
<div class="nexa-header-actions">
|
|
527
|
-
<button class="nexa-icon-btn nexa-btn-export" title="Export history (JSON)">${
|
|
528
|
-
<button class="nexa-icon-btn nexa-btn-settings" title="Settings">${
|
|
529
|
-
<button class="nexa-icon-btn nexa-btn-clear" title="Clear history">${
|
|
530
|
-
<button class="nexa-icon-btn nexa-btn-close" title="Close (Esc)">${
|
|
596
|
+
<button class="nexa-icon-btn nexa-btn-export" title="Export history (JSON)">${W.download}</button>
|
|
597
|
+
<button class="nexa-icon-btn nexa-btn-settings" title="Settings">${W.gear}</button>
|
|
598
|
+
<button class="nexa-icon-btn nexa-btn-clear" title="Clear history">${W.clear}</button>
|
|
599
|
+
<button class="nexa-icon-btn nexa-btn-close" title="Close (Esc)">${W.close}</button>
|
|
531
600
|
</div>
|
|
532
601
|
</div>
|
|
533
602
|
|
|
@@ -565,7 +634,7 @@
|
|
|
565
634
|
</div>
|
|
566
635
|
|
|
567
636
|
<div class="nexa-search">
|
|
568
|
-
<span class="nexa-search-icon">${
|
|
637
|
+
<span class="nexa-search-icon">${W.search}</span>
|
|
569
638
|
<input type="text" class="nexa-search-input" placeholder="Filter by URL, method, or status..." />
|
|
570
639
|
</div>
|
|
571
640
|
|
|
@@ -588,86 +657,17 @@
|
|
|
588
657
|
|
|
589
658
|
<div class="nexa-detail" style="display:none">
|
|
590
659
|
<div class="nexa-detail-header">
|
|
591
|
-
<button class="nexa-btn nexa-btn-back">${
|
|
660
|
+
<button class="nexa-btn nexa-btn-back">${W.back} Back</button>
|
|
592
661
|
<div class="nexa-btn-group">
|
|
593
|
-
<button class="nexa-btn nexa-btn-copy">${
|
|
594
|
-
<button class="nexa-btn nexa-btn-retry">${
|
|
662
|
+
<button class="nexa-btn nexa-btn-copy">${W.copy} Copy as fetch</button>
|
|
663
|
+
<button class="nexa-btn nexa-btn-retry">${W.retry} Retry</button>
|
|
595
664
|
</div>
|
|
596
665
|
</div>
|
|
597
666
|
<div class="nexa-detail-body"></div>
|
|
598
667
|
</div>
|
|
599
|
-
`,document.body.appendChild(this.panel),this.config.theme===`light`?this.panel.classList.add(`nexa-theme-light`):this.panel.classList.remove(`nexa-theme-light`),this.bindEvents(),this.removeTrackerListener=this.tracker.onChange(()=>this.render());let o=!this.config.devOnly||
|
|
600
|
-
<div class="nexa-empty">
|
|
601
|
-
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
602
|
-
<circle cx="12" cy="12" r="10"/><path d="M8 12h8M12 8v8"/>
|
|
603
|
-
</svg>
|
|
604
|
-
<p>${this.searchQuery?`No matching requests`:`No requests yet`}</p>
|
|
605
|
-
<span>${this.searchQuery?`Try a different search term`:`Make a request to see it here`}</span>
|
|
606
|
-
</div>`;return}e.innerHTML=t.map((e,t)=>`
|
|
607
|
-
<div class="nexa-request-item" data-id="${e.id}" style="animation-delay: ${Math.min(t*20,300)}ms">
|
|
608
|
-
<div class="nexa-req-left">
|
|
609
|
-
<span class="nexa-method nexa-method-${e.method.toLowerCase()}">${e.method}</span>
|
|
610
|
-
<span class="nexa-status ${e.ok?`nexa-ok`:`nexa-err`}">${e.status||`ERR`}</span>
|
|
611
|
-
<span class="nexa-url" title="${e.url}">${this.truncateUrl(e.url)}</span>
|
|
612
|
-
</div>
|
|
613
|
-
<div class="nexa-req-right">
|
|
614
|
-
${e.cached?`<span class="nexa-badge nexa-badge-cache">Cache</span>`:``}
|
|
615
|
-
${e.retryCount>0?`<span class="nexa-badge nexa-badge-retry">${e.retryCount}R</span>`:``}
|
|
616
|
-
<span class="nexa-duration ${e.duration>500?`nexa-slow`:``}">${e.duration.toFixed(0)}ms</span>
|
|
617
|
-
${q.chevron}
|
|
618
|
-
</div>
|
|
619
|
-
</div>
|
|
620
|
-
`).join(``),e.querySelectorAll(`.nexa-request-item`).forEach(e=>{e.addEventListener(`click`,()=>{let n=e.dataset.id,r=t.find(e=>e.id===n);r&&this.showDetail(r)})})}renderMetrics(){let e=this.tracker.getMetrics(),t=this.panel?.querySelector(`.nexa-metrics-content`);if(!t)return;let n=e.totalRequests>0?(e.successfulRequests/e.totalRequests*100).toFixed(1):`0`;t.innerHTML=`
|
|
621
|
-
<div class="nexa-card">
|
|
622
|
-
<h3>Overview</h3>
|
|
623
|
-
<div class="nexa-row"><span>Total Requests</span><strong>${e.totalRequests}</strong></div>
|
|
624
|
-
<div class="nexa-row"><span>Successful</span><strong class="nexa-ok">${e.successfulRequests}</strong></div>
|
|
625
|
-
<div class="nexa-row"><span>Failed</span><strong class="nexa-err">${e.failedRequests}</strong></div>
|
|
626
|
-
<div class="nexa-row"><span>Cached</span><strong>${e.cachedRequests}</strong></div>
|
|
627
|
-
<div class="nexa-row"><span>Success Rate</span><strong>${n}%</strong></div>
|
|
628
|
-
</div>
|
|
629
|
-
<div class="nexa-card">
|
|
630
|
-
<h3>Performance</h3>
|
|
631
|
-
<div class="nexa-row"><span>Average</span><strong>${e.avgDuration.toFixed(1)}ms</strong></div>
|
|
632
|
-
<div class="nexa-row"><span>Fastest</span><strong class="nexa-ok">${e.minDuration.toFixed(1)}ms</strong></div>
|
|
633
|
-
<div class="nexa-row"><span>Slowest</span><strong class="nexa-err">${e.maxDuration.toFixed(1)}ms</strong></div>
|
|
634
|
-
<div class="nexa-row"><span>Throughput</span><strong>${e.requestsPerSecond.toFixed(2)} req/s</strong></div>
|
|
635
|
-
</div>
|
|
636
|
-
${e.slowestRequests.length>0?`
|
|
637
|
-
<div class="nexa-card">
|
|
638
|
-
<h3>Slowest Requests</h3>
|
|
639
|
-
${e.slowestRequests.map(e=>`
|
|
640
|
-
<div class="nexa-row nexa-slow-req">
|
|
641
|
-
<span><span class="nexa-method nexa-method-${e.method.toLowerCase()}" style="font-size:10px;padding:2px 5px;">${e.method}</span> ${this.truncateUrl(e.url,25)}</span>
|
|
642
|
-
<strong class="nexa-err">${e.duration.toFixed(0)}ms</strong>
|
|
643
|
-
</div>
|
|
644
|
-
`).join(``)}
|
|
645
|
-
</div>
|
|
646
|
-
`:``}`}showDetail(e){if(this.selectedRequest=e,!this.panel)return;let t=this.panel.querySelector(`.nexa-body`),n=this.panel.querySelector(`.nexa-detail`),r=this.panel.querySelector(`.nexa-detail-body`);!t||!n||!r||(this.panel.classList.add(`nexa-view-detail`),t.style.display=`none`,n.style.display=`flex`,r.innerHTML=`
|
|
647
|
-
<div class="nexa-card">
|
|
648
|
-
<h3>Request</h3>
|
|
649
|
-
<div class="nexa-row"><span>Method</span><strong style="color:${e.method===`GET`?J.get:e.method===`POST`?J.post:e.method===`DELETE`?J.delete:J.warning}">${e.method}</strong></div>
|
|
650
|
-
<div class="nexa-row"><span>URL</span><span class="nexa-url-full">${e.url}</span></div>
|
|
651
|
-
<div class="nexa-row"><span>Status</span><strong class="${e.ok?`nexa-ok`:`nexa-err`}">${e.status||`N/A`}</strong></div>
|
|
652
|
-
<div class="nexa-row"><span>Duration</span><strong>${e.duration.toFixed(1)}ms</strong></div>
|
|
653
|
-
<div class="nexa-row"><span>Cached</span><strong>${e.cached?`Yes`:`No`}</strong></div>
|
|
654
|
-
<div class="nexa-row"><span>Retries</span><strong>${e.retryCount}</strong></div>
|
|
655
|
-
<div class="nexa-row"><span>Timestamp</span><strong>${new Date(e.timestamp).toLocaleTimeString()}</strong></div>
|
|
656
|
-
</div>
|
|
657
|
-
${e.body===void 0?``:`
|
|
658
|
-
<div class="nexa-card">
|
|
659
|
-
<h3>Request Body</h3>
|
|
660
|
-
<pre class="nexa-code">${this.formatJson(e.body)}</pre>
|
|
661
|
-
</div>
|
|
662
|
-
`}
|
|
663
|
-
${Object.keys(e.headers).length>0?`
|
|
664
|
-
<div class="nexa-card">
|
|
665
|
-
<h3>Headers</h3>
|
|
666
|
-
<pre class="nexa-code">${this.formatJson(e.headers)}</pre>
|
|
667
|
-
</div>
|
|
668
|
-
`:``}`)}showMainView(){this.panel&&this.panel.classList.remove(`nexa-view-detail`);let e=this.panel?.querySelector(`.nexa-body`),t=this.panel?.querySelector(`.nexa-detail`);e&&(e.style.display=`flex`),t&&(t.style.display=`none`),this.selectedRequest=null}retrySelected(){if(!this.selectedRequest)return;let{method:e,url:t,body:n,headers:r}=this.selectedRequest;fetch(t,{method:e,headers:r,body:n?JSON.stringify(n):void 0}).then(async e=>{this.selectedRequest&&(this.selectedRequest={...this.selectedRequest,status:e.status,ok:e.ok,duration:this.selectedRequest.duration,timestamp:Date.now()},this.showDetail(this.selectedRequest))}).catch(()=>{})}exportHistory(){let e=this.tracker.getHistory(),t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`nexa-history-${new Date().toISOString().slice(0,19).replace(/[:]/g,`-`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r),this.showNotification(`History exported as JSON`)}copyAsFetch(){if(!this.selectedRequest)return;let e=this.selectedRequest,t={...e.headers};delete t.host;let n=`fetch("${e.url}", {\n`;n+=` "method": "${e.method}",\n`,Object.keys(t).length>0&&(n+=` "headers": ${JSON.stringify(t,null,4).replace(/\n/g,`
|
|
668
|
+
`,document.body.appendChild(this.panel),this.config.theme===`light`?this.panel.classList.add(`nexa-theme-light`):this.panel.classList.remove(`nexa-theme-light`),this.bindEvents(),this.removeTrackerListener=this.tracker.onChange(()=>this.render());let o=!this.config.devOnly||K();this.config.enabled&&o&&this.createFloatingIcon(),this.updateHeaderActionsVisibility(),this.hide(),this.globalKeyboardHandler=e=>{if(e.key===`Escape`&&this.visible){this.hide();return}if(this.visible&&(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`f`){e.preventDefault();let t=this.panel?.querySelector(`.nexa-search-input`);t?.focus(),t?.select()}},document.addEventListener(`keydown`,this.globalKeyboardHandler)}bindEvents(){this.panel&&(this.panel.querySelector(`.nexa-btn-close`)?.addEventListener(`click`,()=>this.hide()),this.panel.querySelector(`.nexa-btn-export`)?.addEventListener(`click`,()=>this.exportHistory()),this.panel.querySelector(`.nexa-btn-copy`)?.addEventListener(`click`,()=>this.copyAsFetch()),this.panel.querySelector(`.nexa-btn-clear`)?.addEventListener(`click`,()=>{this.tracker.clear(),this.render()}),this.panel.querySelector(`.nexa-btn-back`)?.addEventListener(`click`,()=>this.showMainView()),this.panel.querySelector(`.nexa-btn-retry`)?.addEventListener(`click`,()=>this.retrySelected()),this.panel.querySelector(`.nexa-search-input`)?.addEventListener(`input`,e=>{this.searchQuery=e.target.value.toLowerCase(),this.renderRequestList()}),this.panel.querySelectorAll(`.nexa-filter-chip`).forEach(e=>{e.addEventListener(`click`,()=>{this.panel.querySelectorAll(`.nexa-filter-chip`).forEach(e=>e.classList.remove(`nexa-filter-chip-active`)),e.classList.add(`nexa-filter-chip-active`),this.filterType=e.dataset.filter,this.renderRequestList()})}),this.panel.querySelectorAll(`.nexa-tab`).forEach(e=>{e.addEventListener(`click`,()=>{this.panel.querySelectorAll(`.nexa-tab`).forEach(e=>e.classList.remove(`nexa-tab-active`)),this.panel.querySelectorAll(`.nexa-panel`).forEach(e=>e.classList.remove(`nexa-panel-active`)),e.classList.add(`nexa-tab-active`),this.panel.querySelector(`[data-panel="${e.dataset.tab}"]`)?.classList.add(`nexa-panel-active`),e.dataset.tab===`metrics`&&this.renderMetrics()})}),this.panel.querySelector(`.nexa-btn-settings`)?.addEventListener(`click`,()=>{let e=this.panel.querySelector(`.nexa-settings-panel`);if(!e)return;let t=this.panel.querySelector(`[data-setting="position"]`),n=this.panel.querySelector(`[data-setting="theme"]`),r=e.style.display===`flex`;e.style.display=r?`none`:`flex`,r||(this.hideFloatingIcon(),t&&(t.value=this.config.position),n&&(n.value=this.config.theme),t?.focus())}),this.panel.querySelector(`.nexa-btn-save`)?.addEventListener(`click`,()=>{let e=this.panel.querySelector(`[data-setting="position"]`),t=this.panel.querySelector(`[data-setting="theme"]`),n=e?.value,r=t?.value,i={};n!==void 0&&(i.position=n),r!==void 0&&(i.theme=r);let a=this.tracker.updateConfig(i);this.applyConfigToUI(a);let o=this.panel.querySelector(`.nexa-settings-panel`);o&&(o.style.display=`none`)}),this.panel.querySelector(`.nexa-btn-cancel`)?.addEventListener(`click`,()=>{let e=this.panel.querySelector(`.nexa-settings-panel`);e&&(e.style.display=`none`)}))}render(){!this.panel||!this.visible||(this.renderMetricsBar(),this.renderRequestList())}renderMetricsBar(){let e=this.tracker.getMetrics(),t=this.panel;t&&(t.querySelector(`[data-metric="total"]`).textContent=String(e.totalRequests),t.querySelector(`[data-metric="avg"]`).textContent=`${e.avgDuration.toFixed(0)}ms`,t.querySelector(`[data-metric="rate"]`).textContent=`${e.requestsPerSecond.toFixed(1)}`,t.querySelector(`[data-metric="success"]`).textContent=String(e.successfulRequests),t.querySelector(`[data-metric="fail"]`).textContent=String(e.failedRequests),t.querySelector(`[data-count="requests"]`).textContent=String(e.totalRequests),this.updateHeaderActionsVisibility())}updateHeaderActionsVisibility(){let e=this.tracker.getHistory().length>0,t=this.panel?.querySelector(`.nexa-btn-export`),n=this.panel?.querySelector(`.nexa-btn-clear`);t&&(t.style.display=e?`flex`:`none`),n&&(n.style.display=e?`flex`:`none`)}renderRequestList(){let e=this.panel?.querySelector(`.nexa-request-list`);if(!e)return;let t=Ae(this.tracker.getHistory(),this.filterType,this.searchQuery);e.innerHTML=je(t,this.searchQuery),e.querySelectorAll(`.nexa-request-item`).forEach(e=>{e.addEventListener(`click`,()=>{let n=e.dataset.id,r=t.find(e=>e.id===n);r&&this.showDetail(r)})})}renderMetrics(){let e=this.panel?.querySelector(`.nexa-metrics-content`);e&&(e.innerHTML=Me(this.tracker.getMetrics()))}showDetail(e){if(this.selectedRequest=e,!this.panel)return;let t=this.panel.querySelector(`.nexa-body`),n=this.panel.querySelector(`.nexa-detail`),r=this.panel.querySelector(`.nexa-detail-body`);!t||!n||!r||(this.panel.classList.add(`nexa-view-detail`),t.style.display=`none`,n.style.display=`flex`,r.innerHTML=Ne(e))}showMainView(){this.panel&&this.panel.classList.remove(`nexa-view-detail`);let e=this.panel?.querySelector(`.nexa-body`),t=this.panel?.querySelector(`.nexa-detail`);e&&(e.style.display=`flex`),t&&(t.style.display=`none`),this.selectedRequest=null}retrySelected(){if(!this.selectedRequest)return;let{method:e,url:t,body:n,headers:r}=this.selectedRequest,i=performance.now();fetch(t,{method:e,headers:r,body:n?JSON.stringify(n):void 0}).then(a=>{let o=this.tracker.track({method:e,url:t,status:a.status,duration:performance.now()-i,cached:!1,ok:a.ok,headers:r,body:n,retryCount:0});this.showDetail(o)}).catch(()=>{let a=this.tracker.track({method:e,url:t,duration:performance.now()-i,cached:!1,ok:!1,code:`NETWORK_ERROR`,headers:r,body:n,retryCount:0});this.showDetail(a)})}exportHistory(){let e=this.tracker.getHistory(),t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`nexa-history-${new Date().toISOString().slice(0,19).replace(/[:]/g,`-`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r),this.showNotification(`History exported as JSON`)}copyAsFetch(){if(!this.selectedRequest)return;let e=this.selectedRequest,t={...e.headers};delete t.host;let n=`fetch("${e.url}", {\n`;n+=` "method": "${e.method}",\n`,Object.keys(t).length>0&&(n+=` "headers": ${JSON.stringify(t,null,4).replace(/\n/g,`
|
|
669
669
|
`)},\n`),e.body&&(n+=` "body": ${JSON.stringify(e.body,null,4).replace(/\n/g,`
|
|
670
|
-
`)},\n`),n+=`});`,navigator.clipboard.writeText(n).then(()=>{this.showNotification(`Copied as fetch to clipboard`)}).catch(()=>{this.showNotification(`Failed to copy to clipboard`)})}showNotification(e){let t=this.panel?.querySelector(`.nexa-notification`);t&&(t.textContent=e,t.classList.add(`nexa-notification-show`),setTimeout(()=>{t.classList.remove(`nexa-notification-show`)},2500))}
|
|
670
|
+
`)},\n`),n+=`});`,navigator.clipboard.writeText(n).then(()=>{this.showNotification(`Copied as fetch to clipboard`)}).catch(()=>{this.showNotification(`Failed to copy to clipboard`)})}showNotification(e){let t=this.panel?.querySelector(`.nexa-notification`);t&&(t.textContent=e,t.classList.add(`nexa-notification-show`),setTimeout(()=>{t.classList.remove(`nexa-notification-show`)},2500))}canUseDOM(){return typeof document<`u`&&typeof document.createElement==`function`&&!!document.body}createFloatingIcon(){if(!this.canUseDOM())return;try{let e=document.getElementById(`nexa-dev-overlay-floating`);e&&e.remove()}catch{}this.floatingIcon&&=(this.floatingIcon.remove(),null);let e=document.createElement(`button`);e.id=`nexa-dev-overlay-floating`,e.title=`Toggle Nexa DevTools`;let t=this.config.floatingButtonSize??48,n=this.config.floatingButtonOffset??24,r=this.config.position||`bottom-right`,i=r.includes(`bottom`),a=r.includes(`right`),o=`${i?`bottom: ${n}px;`:`top: ${n}px;`} ${a?`right: ${n}px;`:`left: ${n}px;`}`,s=this.config.floatingButtonTheme===`inherit`?this.config.theme:this.config.floatingButtonTheme,c=`linear-gradient(135deg,#0ea5e9,#8b5cf6)`,l=`#ffffff`,u=`0 16px 36px rgba(2,6,23,0.34)`,d=`none`;s===`light`&&(c=`linear-gradient(135deg,#f8fbff,#e0f2fe)`,l=`#0f172a`,u=`0 14px 30px rgba(15,23,42,0.16)`,d=`1px solid #d8e4f2`);let f=this.config.branding||`Nexa DevTools`,p=this.config.icon||`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`;e.style.cssText=`
|
|
671
671
|
position: fixed;
|
|
672
672
|
${o}
|
|
673
673
|
width: ${t}px;
|
|
@@ -684,5 +684,5 @@
|
|
|
684
684
|
color: ${l};
|
|
685
685
|
font-weight: 700;
|
|
686
686
|
font-size: ${Math.max(12,Math.floor(t/3))}px;
|
|
687
|
-
`,e.innerHTML=`<img src="${p}" alt="${f}" style="width:${t-10}px;height:auto;object-fit:cover;border-radius:999px;display:block;" />`,e.addEventListener(`click`,e=>{e.stopPropagation(),this.toggle()}),e.addEventListener(`mousedown`,e=>e.preventDefault()),document.body.appendChild(e),e.style.display=this.visible?`none`:`flex`,this.floatingIcon=e}showFloatingIcon(){if(!this.floatingIcon){this.config.enabled&&this.createFloatingIcon();return}this.floatingIcon.style.display=`flex`}hideFloatingIcon(){this.floatingIcon&&(this.floatingIcon.style.display=`none`)}applyConfigToUI(e){this.config=e??this.tracker.getConfig();let t=this.config.position,n=t.includes(`bottom`),r=t.includes(`right`),i=`${this.config.floatingButtonOffset??24}px`;if(this.panel){this.panel.style.bottom=n?i:``,this.panel.style.top=n?``:i,this.panel.style.right=r?i:``,this.panel.style.left=r?``:i,this.config.theme===`light`?this.panel.classList.add(`nexa-theme-light`):this.panel.classList.remove(`nexa-theme-light`);let e=this.panel.querySelector(`.nexa-logo img`),t=this.panel.querySelector(`.nexa-title`),a=this.config.branding||`Nexa DevTools`,o=this.config.icon||`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`;e&&(e.src=o,e.alt=a),t&&(t.textContent=a)}this.floatingIcon&&=(this.floatingIcon.remove(),null),this.config.enabled&&(!this.config.devOnly||
|
|
687
|
+
`,e.innerHTML=`<img src="${p}" alt="${f}" style="width:${t-10}px;height:auto;object-fit:cover;border-radius:999px;display:block;" />`,e.addEventListener(`click`,e=>{e.stopPropagation(),this.toggle()}),e.addEventListener(`mousedown`,e=>e.preventDefault()),document.body.appendChild(e),e.style.display=this.visible?`none`:`flex`,this.floatingIcon=e}showFloatingIcon(){if(!this.floatingIcon){this.config.enabled&&this.createFloatingIcon();return}this.floatingIcon.style.display=`flex`}hideFloatingIcon(){this.floatingIcon&&(this.floatingIcon.style.display=`none`)}applyConfigToUI(e){this.config=e??this.tracker.getConfig();let t=this.config.position,n=t.includes(`bottom`),r=t.includes(`right`),i=`${this.config.floatingButtonOffset??24}px`;if(this.panel){this.panel.style.bottom=n?i:``,this.panel.style.top=n?``:i,this.panel.style.right=r?i:``,this.panel.style.left=r?``:i,this.config.theme===`light`?this.panel.classList.add(`nexa-theme-light`):this.panel.classList.remove(`nexa-theme-light`);let e=this.panel.querySelector(`.nexa-logo img`),t=this.panel.querySelector(`.nexa-title`),a=this.config.branding||`Nexa DevTools`,o=this.config.icon||`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`;e&&(e.src=o,e.alt=a),t&&(t.textContent=a)}this.floatingIcon&&=(this.floatingIcon.remove(),null),this.config.enabled&&(!this.config.devOnly||K())&&this.createFloatingIcon()}refreshConfig(e){this.applyConfigToUI(e)}},Z=null,Q=null,$={enabled:!0,maxHistory:500,keyboardShortcut:`ctrl+shift+n`,position:`bottom-right`,theme:`dark`,devOnly:!0,floatingButtonSize:48,floatingButtonOffset:24,floatingButtonTheme:`inherit`,branding:`Nexa DevTools`,icon:`https://raw.githubusercontent.com/Berea-Soft/nexa/refs/heads/main/src/assets/faviconNew.png`};function Pe(e={}){if(Z&&Q){let t=H(),n={...$,...e,...t},r=Q.updateConfig(n);try{Z.refreshConfig(r)}catch{}return{tracker:Q,ui:Z,config:r}}let t=H();return Q=new U({...$,...e,...t}),Z=new X(Q),{tracker:Q,ui:Z,config:Q.getConfig()}}function Fe(){return{tracker:Q,ui:Z}}function Ie(){Z?.destroy(),Z=null,Q=null}e.AggressiveRetry=f,e.CachePlugin=pe,e.CacheStore=y,e.CircuitBreakerRetry=m,e.ConservativeRetry=p,e.DedupePlugin=me,e.Defer=ce,e.Err=n,e.HttpClient=I,e.HttpError=L,e.LoggerPlugin=de,e.MetricsPlugin=fe,e.MiddlewarePipeline=ie,e.Ok=t,e.PluginManager=M,e.RequestDeduplicator=S,e.RequestTracker=U,e.TypedObservable=ae,e.cacheMiddleware=x,e.createApiUrl=se,e.createCacheMiddleware=b,e.createDedupeMiddleware=C,e.createDevOverlay=Pe,e.createHttpClient=ye,e.createPipeline=w,e.createProjectionTransformer=u,e.createRealtimePlugin=De,e.createRequiredFieldsValidator=i,e.createSSEClient=Te,e.createSchemaValidator=r,e.createStreamingMiddleware=j,e.createTypeGuard=oe,e.createTypedApiClient=D,e.createTypedRequest=E,e.createTypedResponse=T,e.createUrl=O,e.createWebSocketClient=Se,e.createWrapperTransformer=d,e.dedupeMiddleware=re,e.destroyDevOverlay=Ie,e.getDevOverlay=Fe,e.handleStream=k,e.isHttpError=ve,e.retry=v,e.streamToFile=le,e.streamingMiddleware=ue,e.transformCamelToSnake=c,e.transformFlatten=l,e.transformSnakeToCamel=s,e.validatorIsArray=a,e.validatorIsObject=o,e.withTimeout=ne});
|
|
688
688
|
//# sourceMappingURL=nexa.umd.js.map
|