xn-fe-tools 1.6.2 → 1.7.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.
@@ -41,6 +41,28 @@ export interface UseRequestCacheReturn<T> {
41
41
  /** 清除指定 key 的缓存,如果不传则清除当前自动生成的 key */
42
42
  clearCache: (key?: string) => Promise<void>;
43
43
  }
44
+ /** 缓存快照条目,由 getRequestCache 返回 */
45
+ export interface CacheSnapshot {
46
+ /** 缓存的原始 key(不含 storageKeyPrefix) */
47
+ key: string;
48
+ /** 缓存的原始数据(未经 transformResult 处理) */
49
+ data: unknown;
50
+ /** 写入时间戳(毫秒) */
51
+ timestamp: number;
52
+ /** 所在 storage 策略 */
53
+ storage: CacheStrategy;
54
+ /** 是否已过期(但尚未被清除) */
55
+ isExpired: boolean;
56
+ }
57
+ /** clearRequestCache / getRequestCache 的过滤条件 */
58
+ export interface RequestCacheFilter {
59
+ /** 指定要操作的 key 列表,不传则匹配所有 */
60
+ keys?: string[];
61
+ /** 按 storage 策略过滤,不传则匹配所有 */
62
+ storage?: CacheStrategy | CacheStrategy[];
63
+ /** 按 storageKeyPrefix 过滤,不传则匹配所有 */
64
+ storageKeyPrefix?: string;
65
+ }
44
66
  /**
45
67
  * 支持缓存的请求 Hook
46
68
  *
@@ -53,4 +75,14 @@ export interface UseRequestCacheReturn<T> {
53
75
  * @param options 配置选项
54
76
  */
55
77
  export declare function useRequestCache<T = any, P = any, R = any>(options: UseRequestCacheOptions<T, P, R>): UseRequestCacheReturn<T>;
78
+ /**
79
+ * 清除缓存注册表中匹配的缓存条目。
80
+ * 不传 filter 时清除全部;孤儿缓存(已卸载实例写入的持久化缓存)不在清除范围内,会等待自然过期。
81
+ */
82
+ export declare function clearRequestCache(filter?: RequestCacheFilter): Promise<void>;
83
+ /**
84
+ * 获取缓存注册表中匹配的缓存快照列表。
85
+ * 不传 filter 时返回全部;返回的 data 为原始数据,未经 transformResult 处理。
86
+ */
87
+ export declare function getRequestCache(filter?: RequestCacheFilter): Promise<CacheSnapshot[]>;
56
88
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRequestCache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIlE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,cAAc,GAAG,gBAAgB,GAAG,WAAW,CAAA;AACtF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,CAAA;AAEnE,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IAC/D,WAAW;IACX,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IAEpC,kCAAkC;IAClC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAE9B,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAA;IAEzC,gCAAgC;IAChC,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAE5B,wBAAwB;IACxB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAA;IAEhC,qBAAqB;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,iCAAiC;IACjC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/C,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,cAAc;IACd,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IAE7B,cAAc;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;CAC/B;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IACxB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;IAEf,oBAAoB;IACpB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAEjC,oBAAoB;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAErC,sCAAsC;IACtC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5C;AA8CD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EACvD,OAAO,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACvC,qBAAqB,CAAC,CAAC,CAAC,CAoT1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRequestCache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIlE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,cAAc,GAAG,gBAAgB,GAAG,WAAW,CAAA;AACtF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,CAAA;AAEnE,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IAC/D,WAAW;IACX,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IAEpC,kCAAkC;IAClC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAE9B,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAA;IAEzC,gCAAgC;IAChC,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAE5B,wBAAwB;IACxB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAA;IAEhC,qBAAqB;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,iCAAiC;IACjC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/C,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,cAAc;IACd,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IAE7B,cAAc;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;CAC/B;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IACxB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;IAEf,oBAAoB;IACpB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAEjC,oBAAoB;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAErC,sCAAsC;IACtC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5C;AAED,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,qCAAqC;IACrC,IAAI,EAAE,OAAO,CAAA;IACb,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,oBAAoB;IACpB,OAAO,EAAE,aAAa,CAAA;IACtB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,6BAA6B;IAC7B,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,CAAA;IACzC,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AA4GD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EACvD,OAAO,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACvC,qBAAqB,CAAC,CAAC,CAAC,CAwT1B;AAID;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGlF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA0B3F"}
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=e=>!("object"!=typeof e||null===e||Array.isArray(e)||e instanceof Date||e instanceof RegExp||e instanceof File||e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData),r=(e,n)=>{const o={...e};for(const s in n){if(!Object.prototype.hasOwnProperty.call(n,s))continue;const e=n[s];if(void 0===e)continue;const a=o[s];t(e)&&t(a)?o[s]=r(a,e):o[s]=e}return o},n=e=>e>=200&&e<300,o=()=>!0,s=e=>new Promise(t=>setTimeout(t,e)),a=async e=>{if(!(e=>{if(!e)return!0;if(204===e.status||205===e.status||304===e.status)return!0;const t=e.headers.get("content-length");return!(!t||0!==Number(t))})(e))try{return await e.json()}catch(t){let n;try{n=await e.text()}catch{return}if(!n.trim())return;try{return JSON.parse(n)}catch(r){return}}},i=(e,t,r,n,o)=>({message:e,type:t,status:r,response:n,error:o}),u=e=>{if(e instanceof Error){const t=new Error(e.message);return e.name&&(t.name=e.name),e.stack&&(t.stack=e.stack),t}return new Error(String(e))},c=async(e,t,r)=>!!e?.enabled&&(!(t>(e.maxRetryCount??3))&&(e.shouldRetry?await e.shouldRetry(t,r):"network"===r.type||"timeout"===r.type)),l=(e,t)=>{const r=Object.create(e);let n=!1,o=!1,s=!1;const a=e.then.bind(e),i=e.catch.bind(e),u=a(e=>{s=!0===e.__errorSuppressed,delete e.__errorSuppressed;const t=new Proxy(e,{get(e,t){if(("1"===t||"number"==typeof t&&1===t)&&(o=!0),t===Symbol.iterator){const t=e[Symbol.iterator]();return function*(){let e=0;for(const r of t)1===e&&(o=!0),yield r,e++}}return e[t]}}),r=e[1];return e[2]||!r||s||n||queueMicrotask(()=>{queueMicrotask(()=>{if(!(o||o||n||s)){const e=new Error(`Unhandled fetch error: ${r.message} (type: ${r.type})`);throw e.fetchError=r,e}})}),t});r.cancel=()=>{t&&t()};const c=u.then.bind(u);return r.then=function(e,r){return e&&"function"==typeof e&&!r&&e.length<=2?l(c(t=>{const r=t[2],n=t[0],o=t[3];return r&&void 0!==n&&e(n,o),t}),t):c(e,r)},r.catchHttp=function(e){n=!0;const r=c(t=>{const r=t[2],n=t[1];return!r&&n&&"http"===n.type&&e(n),!r&&n&&(t.__errorSuppressed=!0),t});return l(r,t)},r.catchBusiness=function(e){n=!0;const r=c(t=>{const r=t[1],n=t[2];return!n&&r&&"business"===r.type&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return l(r,t)},r.catchNetwork=function(e){if(n=!0,e&&"function"==typeof e){const r=c(t=>{const r=t[1],n=t[2];return!n&&r&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return l(r,t)}return i(e)},r};class d{globalConfig={};constructor(e){e&&(this.globalConfig={...e}),this.request=this.request.bind(this),this.sendGet=this.sendGet.bind(this),this.sendPost=this.sendPost.bind(this),this.sendPostForm=this.sendPostForm.bind(this),this.sendPostBlob=this.sendPostBlob.bind(this),this.sendGetBlob=this.sendGetBlob.bind(this),this.setGlobalConfig=this.setGlobalConfig.bind(this)}async executeRequest(e,r,l=1){try{const y=e,w=y.signal;w&&(w.aborted?r.abort():w.addEventListener("abort",()=>r.abort(),{once:!0}));const b=(d=y.headers,f=y.url,p=y.method,d?"function"==typeof d?d({url:f,method:p}):d:{}),{body:v,urlParams:S}=((e,r,n)=>{if(!e)return{};if("GET"===r||"HEAD"===r||"OPTIONS"===r){if(t(e)){const t=new URLSearchParams;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&t.append(r,String(n))}return{urlParams:t.toString()}}return{}}if("form"===n&&e instanceof FormData)return{body:e};if("form"===n&&t(e)){const t=new FormData;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&(n instanceof File||n instanceof Blob?t.append(r,n):t.append(r,String(n)))}return{body:t}}return"json"===n?{body:JSON.stringify(e)}:"text"===n?{body:String(e)}:"blob"===n&&e instanceof Blob||"arraybuffer"===n&&e instanceof ArrayBuffer?{body:e}:{body:String(e)}})(y.data,y.method||"GET",y.requestType||"json"),x=((e,t,r)=>{if(t.startsWith("http://")||t.startsWith("https://")){if(r){const e=t.includes("?")?"&":"?";return`${t}${e}${r}`}return t}let n=t;e&&(n=`${e.endsWith("/")?e.slice(0,-1):e}${t.startsWith("/")?t:`/${t}`}`);if(r){const e=n.includes("?")?"&":"?";n=`${n}${e}${r}`}return n})(y.baseURL,y.url,S),E=y.timeout;let q,P=!1,T=b;v&&"string"==typeof v&&"json"===y.requestType?T={"Content-Type":"application/json",...b}:v instanceof FormData&&(T=b);const R=new AbortController,B=()=>R.abort();r.signal.addEventListener("abort",B);const $={method:y.method||"GET",headers:T,body:v,mode:"cors",credentials:!1===y.withCredentials?"same-origin":"include",signal:R.signal},C=fetch(x,$);let G;try{if(E){const e=new Promise((e,t)=>{q=setTimeout(()=>{P=!0,R.abort(),t(i("Request timeout","timeout"))},E)});G=await Promise.race([C,e])}else G=await C}catch(g){if(q&&clearTimeout(q),P){const e=i("Request timeout","timeout");if(await c(y.retry,l,e))return r.signal.removeEventListener("abort",B),await s(y.retry?.delay||1e3),this.executeRequest(y,r,l+1);let t=!1;if(y.onNetworkError){const r=()=>{t=!0};await y.onNetworkError(u(new Error(e.message)),r)}const n=[void 0,e,!1,void 0];return n.__errorSuppressed=t,r.signal.removeEventListener("abort",B),n}throw g}finally{q&&clearTimeout(q),r.signal.removeEventListener("abort",B)}const _=y.responseType||"json";let D;try{D=await(async(e,t)=>{if(!e)throw new Error("No response received");switch(t){case"json":default:return await a(e);case"text":return await e.text();case"blob":return await e.blob();case"arraybuffer":return await e.arrayBuffer();case"formData":return await e.formData()}})(G,_)}catch(h){const e=i("Failed to parse response","network",G.status,void 0,h instanceof Error?h:new Error(String(h)));if(await c(y.retry,l,e))return await s(y.retry?.delay||1e3),this.executeRequest(y,r,l+1);let t=!1;if(y.onNetworkError){const r=()=>{t=!0};await y.onNetworkError(u(e.error||new Error(e.message)),r)}const n=[void 0,e,!1,void 0];return n.__errorSuppressed=t,n}if(!(y.validateStatus||n)(G.status)){const e=i(`HTTP Error: ${G.status} ${G.statusText}`,"http",G.status,D);if(await c(y.retry,l,e))return await s(y.retry?.delay||1e3),this.executeRequest(y,r,l+1);let t=!1;if(y.onHttpError){const r=()=>{t=!0},n=new Error(e.message);await y.onHttpError(n,G.status,D,r)}const n=[void 0,e,!1,{data:D,status:G.status,statusText:G.statusText,headers:G.headers,response:G}];return n.__errorSuppressed=t,n}if(!(y.validateResponse||o)(D)){const e=i("Business validation failed","business",G.status,D);if(await c(y.retry,l,e))return await s(y.retry?.delay||1e3),this.executeRequest(y,r,l+1);let t=!1;if(y.onBusinessError){const r=()=>{t=!0},n=new Error(e.message);await y.onBusinessError(n,D,r)}const n=[void 0,e,!1,{data:D,status:G.status,statusText:G.statusText,headers:G.headers,response:G}];return n.__errorSuppressed=t,n}let F=D;if(y.transformResponse)try{F=y.transformResponse(D)}catch(m){console.warn("[toAwaitFetch] transformResponse error:",m)}return[F,void 0,!0,{data:D,status:G.status,statusText:G.statusText,headers:G.headers,response:G}]}catch(g){const t=(e=>e instanceof DOMException&&"AbortError"===e.name)(g),n=i(t?"Request aborted":g instanceof Error?g.message:"Network error","network",void 0,void 0,g instanceof Error?g:new Error(String(g)));if(!t&&await c(e.retry,l,n))return await s(e.retry?.delay||1e3),this.executeRequest(e,r,l+1);let o=!1;if(e.onNetworkError){const t=()=>{o=!0};await e.onNetworkError(u(n.error||new Error(n.message)),t)}const a=[void 0,n,!1,void 0];return a.__errorSuppressed=o,a}var d,f,p}request(e){const t=r({...this.globalConfig},e),n=new AbortController,o=this.executeRequest(t,n);return l(o,()=>n.abort())}setGlobalConfig(e){this.globalConfig={...e}}getGlobalConfig(){return{...this.globalConfig}}mergeGlobalConfig(e){this.globalConfig=r(this.globalConfig,e)}sendGet(e,t,r){return this.request({...r,url:e,method:"GET",data:t})}sendPost(e,t,r){return this.request({...r,url:e,method:"POST",data:t,requestType:"json"})}sendPostForm(e,t,r){return this.request({...r,url:e,method:"POST",data:t,requestType:"form"})}sendPostBlob(e,t,r){return this.request({...r,url:e,method:"POST",data:t,requestType:"json",responseType:"blob"})}sendGetBlob(e,t,r){return this.request({...r,url:e,method:"GET",data:t,responseType:"blob"})}}const f=e=>new d(e),p=new d,g=e=>{e?.cancel?.()},h=Object.assign(e=>e&&"object"==typeof e&&"url"in e?p.request(e):f(e),{create:f,sendGet:p.sendGet.bind(p),sendPost:p.sendPost.bind(p),sendPostForm:p.sendPostForm.bind(p),sendPostBlob:p.sendPostBlob.bind(p),sendGetBlob:p.sendGetBlob.bind(p),setGlobalConfig:p.setGlobalConfig.bind(p),cancel:g});function m(e,t){if(!e||!t)return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(null==n)return;n=n[o]}return n}function y(t){return"function"==typeof t?t():e.unref(t)}function w(t,r){"undefined"!=typeof __DEV__&&__DEV__&&void 0!==t&&!function(t){return"function"==typeof t||e.isRef(t)}(t)&&console.warn(`[${r}] 检测到 params 是普通对象,参数变化将不会触发请求更新。\n请使用 computed() 或 getter 函数包装:`)}const b={};const v=new Map,S=new Map,x=new Map,E=new Set;let q=null;const P=(e,t)=>new Promise((r,n)=>{if(q)return r(q);const o=indexedDB.open(e,1);o.onupgradeneeded=e=>{const r=e.target.result;r.objectStoreNames.contains(t)||r.createObjectStore(t)},o.onsuccess=e=>{q=e.target.result,r(q)},o.onerror=e=>{n(e.target.error)}});const T="1.6.2";exports.VERSION=T,exports.cancel=g,exports.createInstance=f,exports.getTableRequestGlobalConfig=function(){return{...b,pagination:{...b.pagination}}},exports.getVersion=function(){return T},exports.sendGet=(e,t,r)=>p.request({...r,url:e,method:"GET",data:t}),exports.sendGetBlob=(e,t,r)=>p.sendGetBlob(e,t,r),exports.sendPost=(e,t,r)=>p.sendPost(e,t,r),exports.sendPostBlob=(e,t,r)=>p.sendPostBlob(e,t,r),exports.sendPostForm=(e,t,r)=>p.sendPostForm(e,t,r),exports.setGlobalConfig=e=>{p.setGlobalConfig(e)},exports.setTableRequestGlobalConfig=function(e){Object.assign(b,e),e.pagination&&(b.pagination={...b.pagination,...e.pagination})},exports.toAwaitFetch=h,exports.useInputNumber=function(t,r){let n,o;null===t||"object"!=typeof t||e.isRef(t)?(n=t,o=r||{}):(o=t,n="");const s=()=>e.toValue(o.precision)??0,a=()=>e.toValue(o.showThousands)??!1,i=e.ref(e.toValue(n)?.toString()??""),u=e.computed(()=>{let e=i.value;if(a()){const[t,r]=e.split(".");let n=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return r?n+=`.${r}`:e.includes(".")&&(n+="."),n}return e}),c=t=>{let r=null==t?"":t.toString().trim();const n=e.toValue(o.allowNegative)?/[^\d.-]/g:/[^\d.]/g;r=r.replace(n,""),r=r.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),r.length>1&&r.startsWith("0")&&"."!==r[1]&&(r=r.replace(/^0+/,""),""===r&&(r="0")),r.startsWith("-0")&&r.length>2&&"."!==r[2]&&(r="-"+r.slice(2).replace(/^0+/,""),"-"===r&&(r="-0"));const a=s();if(a>0){r=r.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const t=r.indexOf(".");if(-1!==t){if(r.slice(t+1).length>a){const n=e.toValue(o.decimalLimitMode)??"discard";if("discard"===n)r=r.slice(0,t+a+1);else{const e=Math.pow(10,a);let o=Number(r);isNaN(o)?r=r.slice(0,t+a+1):("round"===n?o=Math.round(o*e)/e:"ceil"===n&&(o=Math.ceil(o*e)/e),r=o.toString())}}}}else r=r.replace(/\./g,"");return r};return e.watch(()=>e.toValue(n),e=>{const t=null==e?"":e.toString();t!==i.value&&(i.value=t)}),{value:i,displayValue:u,handleInput:e=>{const t=c(e);i.value=t},handleBlur:()=>{if(!i.value)return;let t=Number(i.value);const r=o.max??1/0,n=o.min??-1/0;t>r&&(t=r,i.value=r.toString()),t<n&&(t=n,i.value=n.toString());const a=e.toValue(o.autoFixed)??!1;i.value=!0===a||"pad"===a?t.toFixed(s()):"trim"===a?Number(t.toFixed(s())).toString():t.toString()},formatter:e=>u.value,parser:e=>a()?e.replace(/,/g,""):e,clean:c}},exports.useRequestCache=function(t){const{requestFn:r,cacheKey:n,cacheTime:o=3e5,storage:s="memory",params:a,transformResult:i,immediate:u=!0,storageKeyPrefix:c="req_cache_",forceRefreshOnFirst:l=!1,dbName:d="RequestCacheDB",storeName:f="request_cache",onSuccess:p,onError:g}=t,h=(e=>{if("undefined"==typeof window)return"memory";try{if("localStorage"===e&&!window.localStorage)throw new Error;if("sessionStorage"===e&&!window.sessionStorage)throw new Error;if("indexedDB"===e&&!window.indexedDB)throw new Error;return e}catch(t){return console.warn(`[useRequestCache] ${e} is not supported in this environment, falling back to 'memory' mode.`),"memory"}})(y(s)),m=e.ref(),w=e.ref(!1),b=e.ref(null),q=()=>{const e=a?y(a):{};if("function"==typeof n)try{return n(e)}catch(t){return console.warn("[useRequestCache] Generate key failed",t),""}return n},T=async e=>{if("indexedDB"===h){try{const t=await P(d,f);return new Promise((r,n)=>{const o=t.transaction([f],"readwrite").objectStore(f).delete(`${c}${e}`);o.onsuccess=()=>r(),o.onerror=()=>n(o.error)})}catch(r){console.warn("[useRequestCache] IndexedDB delete failed",r)}return}const t="localStorage"===h?localStorage:"sessionStorage"===h?sessionStorage:null;t&&t.removeItem(`${c}${e}`)},R=async(e=!1)=>{const t=q();if(!t)return void console.warn("[useRequestCache] Cache key is empty, skipping request");const n=y(l)&&!E.has(t),s=e||n,u=a?y(a):{};if(!s&&"indexedDB"!==h){const e=v.get(t);if(e){if(Date.now()-e.timestamp<o)return m.value=i?i(e.data):e.data,p&&p(m.value),m.value;v.delete(t)}}w.value=!0,b.value=null;try{if(S.has(t)){if(p||g){const e=x.get(t);e&&(p&&e.onSuccess.push(p),g&&e.onError.push(g))}const e=await S.get(t);return m.value=i?i(e):e,m.value}if(!s&&"memory"!==h){const e=await(async e=>{if("indexedDB"===h)try{const t=await P(d,f);return new Promise(r=>{const n=t.transaction([f],"readonly").objectStore(f).get(`${c}${e}`);n.onsuccess=()=>r(n.result||null),n.onerror=()=>r(null)})}catch(r){return console.warn("[useRequestCache] IndexedDB read failed",r),null}const t="localStorage"===h?localStorage:"sessionStorage"===h?sessionStorage:null;if(!t)return null;try{const r=t.getItem(`${c}${e}`);if(r)return JSON.parse(r)}catch(r){console.warn("[useRequestCache] Read storage failed",r)}return null})(t);if(e){if(Date.now()-e.timestamp<o)return"indexedDB"!==h&&v.set(t,e),m.value=i?i(e.data):e.data,p&&p(m.value),m.value;await T(t)}}const e=r(u);S.set(t,e),x.set(t,{onSuccess:p?[p]:[],onError:g?[g]:[]});try{const r=await e,o={data:r,timestamp:Date.now()};"indexedDB"!==h&&v.set(t,o),"memory"!==h&&await(async(e,t)=>{if("indexedDB"===h){try{const r=await P(d,f);return new Promise((n,o)=>{const s=r.transaction([f],"readwrite").objectStore(f).put(t,`${c}${e}`);s.onsuccess=()=>n(),s.onerror=()=>o(s.error)})}catch(n){console.warn("[useRequestCache] IndexedDB write failed",n)}return}const r="localStorage"===h?localStorage:"sessionStorage"===h?sessionStorage:null;if(r)try{r.setItem(`${c}${e}`,JSON.stringify(t))}catch(n){console.warn("[useRequestCache] Write storage failed",n)}})(t,o),n&&E.add(t),m.value=i?i(r):r;const s=x.get(t);if(s&&s.onSuccess){[...s.onSuccess].forEach(e=>e(m.value))}return S.delete(t),x.delete(t),m.value}catch(R){b.value=R;const e=x.get(t);if(e&&e.onError){[...e.onError].forEach(e=>e(R))}throw S.delete(t),x.delete(t),R}}catch(R){throw b.value=R,R}finally{w.value=!1}},B=()=>R(!1);return a?e.watch(()=>y(a),()=>{B()},{deep:!0,immediate:u}):u&&B(),{data:m,loading:w,error:b,run:B,refresh:()=>R(!0),clearCache:async e=>{const t=e||q();t&&(v.delete(t),"memory"!==h&&await T(t))}}},exports.useTableRequest=function(t,r={}){const n={...b.pagination,...r.pagination},{params:o,immediate:s=b.immediate??!0,debounceDelay:a=b.debounceDelay??0,dataField:i=b.dataField??"",totalField:u=b.totalField??"",currentPageField:c=b.currentPageField??"",transformParams:l,transformResult:d,onSuccess:f,onError:p,incremental:g=b.incremental??!1}=r,{defaultPage:h=1,defaultPageSize:v=10,pageKey:S="page",pageSizeKey:x="pageSize"}=n,E=e.ref([]),q=e.ref(!1),P=e.ref(null),T=e.reactive({page:h,pageSize:v,total:0});let R=0;async function B(){const e=++R;q.value=!0,P.value=null;try{const r=o?y(o):{},n={[S]:T.page,[x]:T.pageSize};let s;s=l?l(r,{page:T.page,pageSize:T.pageSize}):{...r,...n};const a=await t(s);if(e!==R)return;if(d){const e=d(a);if(e&&"object"==typeof e&&Array.isArray(e.list)){const t=e.list;g&&T.page>h?E.value=[...E.value,...t]:E.value=t,T.total="number"==typeof e.total?e.total:e.list.length}else E.value=[],T.total=0,console.warn("[useTableRequest] transformResult 返回格式无法识别,请返回 { list: T[], total: number } 格式。")}else{const e=a;if(Array.isArray(e))g&&T.page>h?E.value=[...E.value,...e]:E.value=e,T.total=e.length;else if(e&&"object"==typeof e){if(i&&""!==i.trim()){const t=m(e,i)||[];g&&T.page>h?E.value=[...E.value,...t]:E.value=t}else E.value=[];u&&""!==u.trim()?T.total=m(e,u)??0:T.total=0}else E.value=[],T.total=0}if(c&&""!==c.trim()){const e=m(a,c);"number"==typeof e&&e!==T.page&&(console.warn(`[useTableRequest] 后端返回页码(${e})与客户端页码(${T.page})不一致,已自动修正`),T.page=e)}f?.(E.value,a)}catch(r){if(e!==R)return;P.value=r instanceof Error?r:new Error(String(r)),p?.(P.value)}finally{e===R&&(q.value=!1)}}const $=a>0?function(e,t){let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...n),r=null},t)}}(B,a):B;let C=!1;async function G(){await B()}return e.watch(()=>[T.page,T.pageSize],()=>{C||$()}),o&&(w(o,"useTableRequest"),e.watch(()=>y(o),()=>{C=!0,T.page=h,C=!1,$()},{deep:!0})),s&&B(),{data:E,loading:q,error:P,pagination:T,run:G,onPageChange:async function(e){const t=T.page!==e;T.page=e,t||await B()},onSizeChange:async function(e){const t=T.pageSize!==e,r=T.page!==h;T.pageSize=e,T.page=h,t||r||await B()},refresh:async function(){g?(C=!0,T.page=h,E.value=[],await e.nextTick(),C=!1,await B()):await G()}}};
1
+ "use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,l=(e,t)=>{for(var r in t||(t={}))o.call(t,r)&&a(e,r,t[r]);if(n)for(var r of n(t))s.call(t,r)&&a(e,r,t[r]);return e},i=(e,n)=>t(e,r(n)),u=(e,t,r)=>new Promise((n,o)=>{var s=e=>{try{l(r.next(e))}catch(t){o(t)}},a=e=>{try{l(r.throw(e))}catch(t){o(t)}},l=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,a);l((r=r.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("vue"),d=e=>!("object"!=typeof e||null===e||Array.isArray(e)||e instanceof Date||e instanceof RegExp||e instanceof File||e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData),f=(e,t)=>{const r=l({},e);for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const e=t[n];if(void 0===e)continue;const o=r[n];d(e)&&d(o)?r[n]=f(o,e):r[n]=e}return r},p=e=>e>=200&&e<300,g=()=>!0,y=e=>new Promise(t=>setTimeout(t,e)),h=e=>u(null,null,function*(){if(!(e=>{if(!e)return!0;if(204===e.status||205===e.status||304===e.status)return!0;const t=e.headers.get("content-length");return!(!t||0!==Number(t))})(e))try{return yield e.json()}catch(t){let o;try{o=yield e.text()}catch(r){return}if(!o.trim())return;try{return JSON.parse(o)}catch(n){return}}}),m=(e,t,r,n,o)=>({message:e,type:t,status:r,response:n,error:o}),b=e=>{if(e instanceof Error){const t=new Error(e.message);return e.name&&(t.name=e.name),e.stack&&(t.stack=e.stack),t}return new Error(String(e))},v=(e,t,r)=>u(null,null,function*(){var n;return!!(null==e?void 0:e.enabled)&&(!(t>(null!=(n=e.maxRetryCount)?n:3))&&(e.shouldRetry?yield e.shouldRetry(t,r):"network"===r.type||"timeout"===r.type))}),w=(e,t)=>{const r=Object.create(e);let n=!1,o=!1,s=!1;const a=e.then.bind(e),l=e.catch.bind(e),i=a(e=>{s=!0===e.__errorSuppressed,delete e.__errorSuppressed;const t=new Proxy(e,{get(e,t){if(("1"===t||"number"==typeof t&&1===t)&&(o=!0),t===Symbol.iterator){const t=e[Symbol.iterator]();return function*(){let e=0;for(const r of t)1===e&&(o=!0),yield r,e++}}return e[t]}}),r=e[1];return e[2]||!r||s||n||queueMicrotask(()=>{queueMicrotask(()=>{if(!(o||o||n||s)){const e=new Error(`Unhandled fetch error: ${r.message} (type: ${r.type})`);throw e.fetchError=r,e}})}),t});r.cancel=()=>{t&&t()};const u=i.then.bind(i);return r.then=function(e,r){return e&&"function"==typeof e&&!r&&e.length<=2?w(u(t=>{const r=t[2],n=t[0],o=t[3];return r&&void 0!==n&&e(n,o),t}),t):u(e,r)},r.catchHttp=function(e){n=!0;const r=u(t=>{const r=t[2],n=t[1];return!r&&n&&"http"===n.type&&e(n),!r&&n&&(t.__errorSuppressed=!0),t});return w(r,t)},r.catchBusiness=function(e){n=!0;const r=u(t=>{const r=t[1],n=t[2];return!n&&r&&"business"===r.type&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return w(r,t)},r.catchNetwork=function(e){if(n=!0,e&&"function"==typeof e){const r=u(t=>{const r=t[1],n=t[2];return!n&&r&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return w(r,t)}return l(e)},r};class S{constructor(e){var t;a(this,"symbol"!=typeof(t="globalConfig")?t+"":t,{}),e&&(this.globalConfig=l({},e)),this.request=this.request.bind(this),this.sendGet=this.sendGet.bind(this),this.sendPost=this.sendPost.bind(this),this.sendPostForm=this.sendPostForm.bind(this),this.sendPostBlob=this.sendPostBlob.bind(this),this.sendGetBlob=this.sendGetBlob.bind(this),this.setGlobalConfig=this.setGlobalConfig.bind(this)}executeRequest(e,t,r=1){return u(this,null,function*(){var n,o,s,a,i,c,f,w;try{const i=e,E=i.signal;E&&(E.aborted?t.abort():E.addEventListener("abort",()=>t.abort(),{once:!0}));const q=(c=i.headers,f=i.url,w=i.method,c?"function"==typeof c?c({url:f,method:w}):c:{}),{body:T,urlParams:R}=((e,t,r)=>{if(!e)return{};if("GET"===t||"HEAD"===t||"OPTIONS"===t){if(d(e)){const t=new URLSearchParams;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&t.append(r,String(n))}return{urlParams:t.toString()}}return{}}if("form"===r&&e instanceof FormData)return{body:e};if("form"===r&&d(e)){const t=new FormData;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&(n instanceof File||n instanceof Blob?t.append(r,n):t.append(r,String(n)))}return{body:t}}return"json"===r?{body:JSON.stringify(e)}:"text"===r?{body:String(e)}:"blob"===r&&e instanceof Blob||"arraybuffer"===r&&e instanceof ArrayBuffer?{body:e}:{body:String(e)}})(i.data,i.method||"GET",i.requestType||"json"),$=((e,t,r)=>{if(t.startsWith("http://")||t.startsWith("https://")){if(r){const e=t.includes("?")?"&":"?";return`${t}${e}${r}`}return t}let n=t;e&&(n=`${e.endsWith("/")?e.slice(0,-1):e}${t.startsWith("/")?t:`/${t}`}`);if(r){const e=n.includes("?")?"&":"?";n=`${n}${e}${r}`}return n})(i.baseURL,i.url,R),B=i.timeout;let C,O=!1,j=q;T&&"string"==typeof T&&"json"===i.requestType?j=l({"Content-Type":"application/json"},q):T instanceof FormData&&(j=q);const D=new AbortController,N=()=>D.abort();t.signal.addEventListener("abort",N);const F={method:i.method||"GET",headers:j,body:T,mode:"cors",credentials:!1===i.withCredentials?"same-origin":"include",signal:D.signal},G=fetch($,F);let _;try{if(B){const e=new Promise((e,t)=>{C=setTimeout(()=>{O=!0,D.abort(),t(m("Request timeout","timeout"))},B)});_=yield Promise.race([G,e])}else _=yield G}catch(S){if(C&&clearTimeout(C),O){const e=m("Request timeout","timeout");if(yield v(i.retry,r,e))return t.signal.removeEventListener("abort",N),yield y((null==(n=i.retry)?void 0:n.delay)||1e3),this.executeRequest(i,t,r+1);let o=!1;if(i.onNetworkError){const t=()=>{o=!0};yield i.onNetworkError(b(new Error(e.message)),t)}const s=[void 0,e,!1,void 0];return s.__errorSuppressed=o,t.signal.removeEventListener("abort",N),s}throw S}finally{C&&clearTimeout(C),t.signal.removeEventListener("abort",N)}const k=i.responseType||"json";let A;try{A=yield((e,t)=>u(null,null,function*(){if(!e)throw new Error("No response received");switch(t){case"json":default:return yield h(e);case"text":return yield e.text();case"blob":return yield e.blob();case"arraybuffer":return yield e.arrayBuffer();case"formData":return yield e.formData()}}))(_,k)}catch(x){const e=m("Failed to parse response","network",_.status,void 0,x instanceof Error?x:new Error(String(x)));if(yield v(i.retry,r,e))return yield y((null==(o=i.retry)?void 0:o.delay)||1e3),this.executeRequest(i,t,r+1);let n=!1;if(i.onNetworkError){const t=()=>{n=!0};yield i.onNetworkError(b(e.error||new Error(e.message)),t)}const s=[void 0,e,!1,void 0];return s.__errorSuppressed=n,s}if(!(i.validateStatus||p)(_.status)){const e=m(`HTTP Error: ${_.status} ${_.statusText}`,"http",_.status,A);if(yield v(i.retry,r,e))return yield y((null==(s=i.retry)?void 0:s.delay)||1e3),this.executeRequest(i,t,r+1);let n=!1;if(i.onHttpError){const t=()=>{n=!0},r=new Error(e.message);yield i.onHttpError(r,_.status,A,t)}const o=[void 0,e,!1,{data:A,status:_.status,statusText:_.statusText,headers:_.headers,response:_}];return o.__errorSuppressed=n,o}if(!(i.validateResponse||g)(A)){const e=m("Business validation failed","business",_.status,A);if(yield v(i.retry,r,e))return yield y((null==(a=i.retry)?void 0:a.delay)||1e3),this.executeRequest(i,t,r+1);let n=!1;if(i.onBusinessError){const t=()=>{n=!0},r=new Error(e.message);yield i.onBusinessError(r,A,t)}const o=[void 0,e,!1,{data:A,status:_.status,statusText:_.statusText,headers:_.headers,response:_}];return o.__errorSuppressed=n,o}let I=A;if(i.transformResponse)try{I=i.transformResponse(A)}catch(P){console.warn("[toAwaitFetch] transformResponse error:",P)}return[I,void 0,!0,{data:A,status:_.status,statusText:_.statusText,headers:_.headers,response:_}]}catch(S){const n=(e=>e instanceof DOMException&&"AbortError"===e.name)(S),o=m(n?"Request aborted":S instanceof Error?S.message:"Network error","network",void 0,void 0,S instanceof Error?S:new Error(String(S)));if(!n&&(yield v(e.retry,r,o)))return yield y((null==(i=e.retry)?void 0:i.delay)||1e3),this.executeRequest(e,t,r+1);let s=!1;if(e.onNetworkError){const t=()=>{s=!0};yield e.onNetworkError(b(o.error||new Error(o.message)),t)}const a=[void 0,o,!1,void 0];return a.__errorSuppressed=s,a}})}request(e){const t=f(l({},this.globalConfig),e),r=new AbortController,n=this.executeRequest(t,r);return w(n,()=>r.abort())}setGlobalConfig(e){this.globalConfig=l({},e)}getGlobalConfig(){return l({},this.globalConfig)}mergeGlobalConfig(e){this.globalConfig=f(this.globalConfig,e)}sendGet(e,t,r){return this.request(i(l({},r),{url:e,method:"GET",data:t}))}sendPost(e,t,r){return this.request(i(l({},r),{url:e,method:"POST",data:t,requestType:"json"}))}sendPostForm(e,t,r){return this.request(i(l({},r),{url:e,method:"POST",data:t,requestType:"form"}))}sendPostBlob(e,t,r){return this.request(i(l({},r),{url:e,method:"POST",data:t,requestType:"json",responseType:"blob"}))}sendGetBlob(e,t,r){return this.request(i(l({},r),{url:e,method:"GET",data:t,responseType:"blob"}))}}const x=e=>new S(e),P=new S,E=e=>{var t;null==(t=null==e?void 0:e.cancel)||t.call(e)},q=Object.assign(e=>e&&"object"==typeof e&&"url"in e?P.request(e):x(e),{create:x,sendGet:P.sendGet.bind(P),sendPost:P.sendPost.bind(P),sendPostForm:P.sendPostForm.bind(P),sendPostBlob:P.sendPostBlob.bind(P),sendGetBlob:P.sendGetBlob.bind(P),setGlobalConfig:P.setGlobalConfig.bind(P),cancel:E});function T(e,t){if(!e||!t)return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(null==n)return;n=n[o]}return n}function R(e){return"function"==typeof e?e():c.unref(e)}function $(e,t){"undefined"!=typeof __DEV__&&__DEV__&&void 0!==e&&!function(e){return"function"==typeof e||c.isRef(e)}(e)&&console.warn(`[${t}] 检测到 params 是普通对象,参数变化将不会触发请求更新。\n请使用 computed() 或 getter 函数包装:`)}const B={};const C=new Map,O=new Map,j=new Map,D=new Set,N=new Map;let F=null;const G=(e,t)=>new Promise((r,n)=>{if(F)return r(F);const o=indexedDB.open(e,1);o.onupgradeneeded=e=>{const r=e.target.result;r.objectStoreNames.contains(t)||r.createObjectStore(t)},o.onsuccess=e=>{F=e.target.result,r(F)},o.onerror=e=>{n(e.target.error)}});function _(e,t){return u(this,null,function*(){const{storage:r,storageKeyPrefix:n,dbName:o,storeName:s}=t;if("indexedDB"===r)try{const t=yield G(o,s);return new Promise(r=>{const o=t.transaction([s],"readonly").objectStore(s).get(`${n}${e}`);o.onsuccess=()=>r(o.result||null),o.onerror=()=>r(null)})}catch(l){return null}const a="localStorage"===r?localStorage:"sessionStorage"===r?sessionStorage:null;if(!a)return null;try{const t=a.getItem(`${n}${e}`);if(t)return JSON.parse(t)}catch(l){}return null})}function k(e,t,r){if(!r)return!0;if(r.keys&&!r.keys.includes(e))return!1;if(r.storage){if(!(Array.isArray(r.storage)?r.storage:[r.storage]).includes(t.storage))return!1}return void 0===r.storageKeyPrefix||t.storageKeyPrefix===r.storageKeyPrefix}const A="1.7.0";exports.VERSION=A,exports.cancel=E,exports.clearRequestCache=function(e){return u(this,null,function*(){const t=[...N.entries()].filter(([t,r])=>k(t,r,e));yield Promise.all(t.map(([,e])=>e.clearFn()))})},exports.createInstance=x,exports.getRequestCache=function(e){return u(this,null,function*(){var t;const r=[];for(const[n,o]of N.entries()){if(!k(n,o,e))continue;let s=null;s="memory"===o.storage?null!=(t=C.get(n))?t:null:yield _(n,o),s&&r.push({key:n,data:s.data,timestamp:s.timestamp,storage:o.storage,isExpired:Date.now()-s.timestamp>=o.cacheTime})}return r})},exports.getTableRequestGlobalConfig=function(){return i(l({},B),{pagination:l({},B.pagination)})},exports.getVersion=function(){return A},exports.sendGet=(e,t,r)=>P.request(i(l({},r),{url:e,method:"GET",data:t})),exports.sendGetBlob=(e,t,r)=>P.sendGetBlob(e,t,r),exports.sendPost=(e,t,r)=>P.sendPost(e,t,r),exports.sendPostBlob=(e,t,r)=>P.sendPostBlob(e,t,r),exports.sendPostForm=(e,t,r)=>P.sendPostForm(e,t,r),exports.setGlobalConfig=e=>{P.setGlobalConfig(e)},exports.setTableRequestGlobalConfig=function(e){Object.assign(B,e),e.pagination&&(B.pagination=l(l({},B.pagination),e.pagination))},exports.toAwaitFetch=q,exports.useInputNumber=function(e,t){var r,n;let o,s;null===e||"object"!=typeof e||c.isRef(e)?(o=e,s=t||{}):(s=e,o="");const a=()=>{var e;return null!=(e=c.toValue(s.precision))?e:0},l=()=>{var e;return null!=(e=c.toValue(s.showThousands))&&e},i=c.ref(null!=(n=null==(r=c.toValue(o))?void 0:r.toString())?n:""),u=c.computed(()=>{let e=i.value;if(l()){const[t,r]=e.split(".");let n=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return r?n+=`.${r}`:e.includes(".")&&(n+="."),n}return e}),d=e=>{let t=null==e?"":e.toString().trim();const r=null!=(n=c.toValue(s.allowNegative))&&n?/[^\d.-]/g:/[^\d.]/g;var n;t=t.replace(r,""),t=t.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),t.length>1&&t.startsWith("0")&&"."!==t[1]&&(t=t.replace(/^0+/,""),""===t&&(t="0")),t.startsWith("-0")&&t.length>2&&"."!==t[2]&&(t="-"+t.slice(2).replace(/^0+/,""),"-"===t&&(t="-0"));const o=a();if(o>0){t=t.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=t.indexOf(".");if(-1!==e){if(t.slice(e+1).length>o){const r=(()=>{var e;return null!=(e=c.toValue(s.decimalLimitMode))?e:"discard"})();if("discard"===r)t=t.slice(0,e+o+1);else{const n=Math.pow(10,o);let s=Number(t);isNaN(s)?t=t.slice(0,e+o+1):("round"===r?s=Math.round(s*n)/n:"ceil"===r&&(s=Math.ceil(s*n)/n),t=s.toString())}}}}else t=t.replace(/\./g,"");return t};return c.watch(()=>c.toValue(o),e=>{const t=null==e?"":e.toString();t!==i.value&&(i.value=t)}),{value:i,displayValue:u,handleInput:e=>{const t=d(e);i.value=t},handleBlur:()=>{var e,t;if(!i.value)return;let r=Number(i.value);const n=null!=(e=s.max)?e:1/0,o=null!=(t=s.min)?t:-1/0;r>n&&(r=n,i.value=n.toString()),r<o&&(r=o,i.value=o.toString());const l=(()=>{var e;return null!=(e=c.toValue(s.autoFixed))&&e})();i.value=!0===l||"pad"===l?r.toFixed(a()):"trim"===l?Number(r.toFixed(a())).toString():r.toString()},formatter:e=>u.value,parser:e=>l()?e.replace(/,/g,""):e,clean:d}},exports.useRequestCache=function(e){const{requestFn:t,cacheKey:r,cacheTime:n=3e5,storage:o="memory",params:s,transformResult:a,immediate:l=!0,storageKeyPrefix:i="req_cache_",forceRefreshOnFirst:d=!1,dbName:f="RequestCacheDB",storeName:p="request_cache",onSuccess:g,onError:y}=e,h=(e=>{if("undefined"==typeof window)return"memory";try{if("localStorage"===e&&!window.localStorage)throw new Error;if("sessionStorage"===e&&!window.sessionStorage)throw new Error;if("indexedDB"===e&&!window.indexedDB)throw new Error;return e}catch(t){return console.warn(`[useRequestCache] ${e} is not supported in this environment, falling back to 'memory' mode.`),"memory"}})(R(o)),m=c.ref(),b=c.ref(!1),v=c.ref(null),w=()=>{const e=s?R(s):{};if("function"==typeof r)try{return r(e)}catch(t){return console.warn("[useRequestCache] Generate key failed",t),""}return r},S=e=>u(null,null,function*(){if("indexedDB"===h){try{const t=yield G(f,p);return new Promise((r,n)=>{const o=t.transaction([p],"readwrite").objectStore(p).delete(`${i}${e}`);o.onsuccess=()=>r(),o.onerror=()=>n(o.error)})}catch(r){console.warn("[useRequestCache] IndexedDB delete failed",r)}return}const t="localStorage"===h?localStorage:"sessionStorage"===h?sessionStorage:null;t&&t.removeItem(`${i}${e}`)}),x=(e=!1)=>u(null,null,function*(){const r=w();if(!r)return void console.warn("[useRequestCache] Cache key is empty, skipping request");const o=R(d)&&!D.has(r),l=e||o,c=s?R(s):{};if(!l&&"indexedDB"!==h){const e=C.get(r);if(e){if(Date.now()-e.timestamp<n)return m.value=a?a(e.data):e.data,g&&g(m.value),m.value;C.delete(r)}}b.value=!0,v.value=null;try{if(O.has(r)){if(g||y){const e=j.get(r);e&&(g&&e.onSuccess.push(g),y&&e.onError.push(y))}const e=yield O.get(r);return m.value=a?a(e):e,m.value}if(!l&&"memory"!==h){const e=yield(e=>u(null,null,function*(){if("indexedDB"===h)try{const t=yield G(f,p);return new Promise(r=>{const n=t.transaction([p],"readonly").objectStore(p).get(`${i}${e}`);n.onsuccess=()=>r(n.result||null),n.onerror=()=>r(null)})}catch(r){return console.warn("[useRequestCache] IndexedDB read failed",r),null}const t="localStorage"===h?localStorage:"sessionStorage"===h?sessionStorage:null;if(!t)return null;try{const r=t.getItem(`${i}${e}`);if(r)return JSON.parse(r)}catch(r){console.warn("[useRequestCache] Read storage failed",r)}return null}))(r);if(e){if(Date.now()-e.timestamp<n)return"indexedDB"!==h&&C.set(r,e),N.set(r,{storage:h,storageKeyPrefix:i,dbName:f,storeName:p,cacheTime:n,clearFn:()=>E(r)}),m.value=a?a(e.data):e.data,g&&g(m.value),m.value;yield S(r)}}const e=t(c);O.set(r,e),j.set(r,{onSuccess:g?[g]:[],onError:y?[y]:[]});try{const t=yield e,s={data:t,timestamp:Date.now()};"indexedDB"!==h&&C.set(r,s),"memory"!==h&&(yield((e,t)=>u(null,null,function*(){if("indexedDB"===h){try{const r=yield G(f,p);return new Promise((n,o)=>{const s=r.transaction([p],"readwrite").objectStore(p).put(t,`${i}${e}`);s.onsuccess=()=>n(),s.onerror=()=>o(s.error)})}catch(n){console.warn("[useRequestCache] IndexedDB write failed",n)}return}const r="localStorage"===h?localStorage:"sessionStorage"===h?sessionStorage:null;if(r)try{r.setItem(`${i}${e}`,JSON.stringify(t))}catch(n){console.warn("[useRequestCache] Write storage failed",n)}}))(r,s)),N.set(r,{storage:h,storageKeyPrefix:i,dbName:f,storeName:p,cacheTime:n,clearFn:()=>E(r)}),o&&D.add(r),m.value=a?a(t):t;const l=j.get(r);if(l&&l.onSuccess){[...l.onSuccess].forEach(e=>e(m.value))}return O.delete(r),j.delete(r),m.value}catch(x){v.value=x;const e=j.get(r);if(e&&e.onError){[...e.onError].forEach(e=>e(x))}throw O.delete(r),j.delete(r),x}}catch(x){throw v.value=x,x}finally{b.value=!1}}),P=()=>x(!1),E=e=>u(null,null,function*(){const t=e||w();t&&(C.delete(t),N.delete(t),"memory"!==h&&(yield S(t)))});return s?c.watch(()=>R(s),()=>{P()},{deep:!0,immediate:l}):l&&P(),{data:m,loading:b,error:v,run:P,refresh:()=>x(!0),clearCache:E}},exports.useTableRequest=function(e,t={}){var r,n,o,s,a,i;const d=l(l({},B.pagination),t.pagination),{params:f,immediate:p=null==(r=B.immediate)||r,debounceDelay:g=(null!=(n=B.debounceDelay)?n:0),dataField:y=(null!=(o=B.dataField)?o:""),totalField:h=(null!=(s=B.totalField)?s:""),currentPageField:m=(null!=(a=B.currentPageField)?a:""),transformParams:b,transformResult:v,onSuccess:w,onError:S,incremental:x=null!=(i=B.incremental)&&i}=t,{defaultPage:P=1,defaultPageSize:E=10,pageKey:q="page",pageSizeKey:C="pageSize"}=d,O=c.ref([]),j=c.ref(!1),D=c.ref(null),N=c.reactive({page:P,pageSize:E,total:0});let F=0;function G(){return u(this,null,function*(){var t;const r=++F;j.value=!0,D.value=null;try{const n=f?R(f):{},o={[q]:N.page,[C]:N.pageSize};let s;s=b?b(n,{page:N.page,pageSize:N.pageSize}):l(l({},n),o);const a=yield e(s);if(r!==F)return;if(v){const e=v(a);if(e&&"object"==typeof e&&Array.isArray(e.list)){const t=e.list;x&&N.page>P?O.value=[...O.value,...t]:O.value=t,N.total="number"==typeof e.total?e.total:e.list.length}else O.value=[],N.total=0,console.warn("[useTableRequest] transformResult 返回格式无法识别,请返回 { list: T[], total: number } 格式。")}else{const e=a;if(Array.isArray(e))x&&N.page>P?O.value=[...O.value,...e]:O.value=e,N.total=e.length;else if(e&&"object"==typeof e){if(y&&""!==y.trim()){const t=T(e,y)||[];x&&N.page>P?O.value=[...O.value,...t]:O.value=t}else O.value=[];h&&""!==h.trim()?N.total=null!=(t=T(e,h))?t:0:N.total=0}else O.value=[],N.total=0}if(m&&""!==m.trim()){const e=T(a,m);"number"==typeof e&&e!==N.page&&(console.warn(`[useTableRequest] 后端返回页码(${e})与客户端页码(${N.page})不一致,已自动修正`),N.page=e)}null==w||w(O.value,a)}catch(n){if(r!==F)return;D.value=n instanceof Error?n:new Error(String(n)),null==S||S(D.value)}finally{r===F&&(j.value=!1)}})}const _=g>0?function(e,t){let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...n),r=null},t)}}(G,g):G;let k=!1;function A(){return u(this,null,function*(){yield G()})}return c.watch(()=>[N.page,N.pageSize],()=>{k||_()}),f&&($(f,"useTableRequest"),c.watch(()=>R(f),()=>{k=!0,N.page=P,k=!1,_()},{deep:!0})),p&&G(),{data:O,loading:j,error:D,pagination:N,run:A,onPageChange:function(e){return u(this,null,function*(){const t=N.page!==e;N.page=e,t||(yield G())})},onSizeChange:function(e){return u(this,null,function*(){const t=N.pageSize!==e,r=N.page!==P;N.pageSize=e,N.page=P,t||r||(yield G())})},refresh:function(){return u(this,null,function*(){x?(k=!0,N.page=P,O.value=[],yield c.nextTick(),k=!1,yield G()):yield A()})}}};
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- import{unref as e,isRef as t,ref as r,reactive as n,watch as o,nextTick as s,toValue as a,computed as i}from"vue";const u=e=>!("object"!=typeof e||null===e||Array.isArray(e)||e instanceof Date||e instanceof RegExp||e instanceof File||e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData),c=(e,t)=>{const r={...e};for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const e=t[n];if(void 0===e)continue;const o=r[n];u(e)&&u(o)?r[n]=c(o,e):r[n]=e}return r},l=e=>e>=200&&e<300,d=()=>!0,f=e=>new Promise(t=>setTimeout(t,e)),p=async e=>{if(!(e=>{if(!e)return!0;if(204===e.status||205===e.status||304===e.status)return!0;const t=e.headers.get("content-length");return!(!t||0!==Number(t))})(e))try{return await e.json()}catch(t){let n;try{n=await e.text()}catch{return}if(!n.trim())return;try{return JSON.parse(n)}catch(r){return}}},g=(e,t,r,n,o)=>({message:e,type:t,status:r,response:n,error:o}),h=e=>{if(e instanceof Error){const t=new Error(e.message);return e.name&&(t.name=e.name),e.stack&&(t.stack=e.stack),t}return new Error(String(e))},m=async(e,t,r)=>!!e?.enabled&&(!(t>(e.maxRetryCount??3))&&(e.shouldRetry?await e.shouldRetry(t,r):"network"===r.type||"timeout"===r.type)),y=(e,t)=>{const r=Object.create(e);let n=!1,o=!1,s=!1;const a=e.then.bind(e),i=e.catch.bind(e),u=a(e=>{s=!0===e.__errorSuppressed,delete e.__errorSuppressed;const t=new Proxy(e,{get(e,t){if(("1"===t||"number"==typeof t&&1===t)&&(o=!0),t===Symbol.iterator){const t=e[Symbol.iterator]();return function*(){let e=0;for(const r of t)1===e&&(o=!0),yield r,e++}}return e[t]}}),r=e[1];return e[2]||!r||s||n||queueMicrotask(()=>{queueMicrotask(()=>{if(!(o||o||n||s)){const e=new Error(`Unhandled fetch error: ${r.message} (type: ${r.type})`);throw e.fetchError=r,e}})}),t});r.cancel=()=>{t&&t()};const c=u.then.bind(u);return r.then=function(e,r){return e&&"function"==typeof e&&!r&&e.length<=2?y(c(t=>{const r=t[2],n=t[0],o=t[3];return r&&void 0!==n&&e(n,o),t}),t):c(e,r)},r.catchHttp=function(e){n=!0;const r=c(t=>{const r=t[2],n=t[1];return!r&&n&&"http"===n.type&&e(n),!r&&n&&(t.__errorSuppressed=!0),t});return y(r,t)},r.catchBusiness=function(e){n=!0;const r=c(t=>{const r=t[1],n=t[2];return!n&&r&&"business"===r.type&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return y(r,t)},r.catchNetwork=function(e){if(n=!0,e&&"function"==typeof e){const r=c(t=>{const r=t[1],n=t[2];return!n&&r&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return y(r,t)}return i(e)},r};class w{globalConfig={};constructor(e){e&&(this.globalConfig={...e}),this.request=this.request.bind(this),this.sendGet=this.sendGet.bind(this),this.sendPost=this.sendPost.bind(this),this.sendPostForm=this.sendPostForm.bind(this),this.sendPostBlob=this.sendPostBlob.bind(this),this.sendGetBlob=this.sendGetBlob.bind(this),this.setGlobalConfig=this.setGlobalConfig.bind(this)}async executeRequest(e,t,r=1){try{const y=e,w=y.signal;w&&(w.aborted?t.abort():w.addEventListener("abort",()=>t.abort(),{once:!0}));const b=(n=y.headers,o=y.url,s=y.method,n?"function"==typeof n?n({url:o,method:s}):n:{}),{body:v,urlParams:S}=((e,t,r)=>{if(!e)return{};if("GET"===t||"HEAD"===t||"OPTIONS"===t){if(u(e)){const t=new URLSearchParams;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&t.append(r,String(n))}return{urlParams:t.toString()}}return{}}if("form"===r&&e instanceof FormData)return{body:e};if("form"===r&&u(e)){const t=new FormData;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&(n instanceof File||n instanceof Blob?t.append(r,n):t.append(r,String(n)))}return{body:t}}return"json"===r?{body:JSON.stringify(e)}:"text"===r?{body:String(e)}:"blob"===r&&e instanceof Blob||"arraybuffer"===r&&e instanceof ArrayBuffer?{body:e}:{body:String(e)}})(y.data,y.method||"GET",y.requestType||"json"),E=((e,t,r)=>{if(t.startsWith("http://")||t.startsWith("https://")){if(r){const e=t.includes("?")?"&":"?";return`${t}${e}${r}`}return t}let n=t;e&&(n=`${e.endsWith("/")?e.slice(0,-1):e}${t.startsWith("/")?t:`/${t}`}`);if(r){const e=n.includes("?")?"&":"?";n=`${n}${e}${r}`}return n})(y.baseURL,y.url,S),P=y.timeout;let q,x=!1,T=b;v&&"string"==typeof v&&"json"===y.requestType?T={"Content-Type":"application/json",...b}:v instanceof FormData&&(T=b);const $=new AbortController,B=()=>$.abort();t.signal.addEventListener("abort",B);const R={method:y.method||"GET",headers:T,body:v,mode:"cors",credentials:!1===y.withCredentials?"same-origin":"include",signal:$.signal},C=fetch(E,R);let _;try{if(P){const e=new Promise((e,t)=>{q=setTimeout(()=>{x=!0,$.abort(),t(g("Request timeout","timeout"))},P)});_=await Promise.race([C,e])}else _=await C}catch(a){if(q&&clearTimeout(q),x){const e=g("Request timeout","timeout");if(await m(y.retry,r,e))return t.signal.removeEventListener("abort",B),await f(y.retry?.delay||1e3),this.executeRequest(y,t,r+1);let n=!1;if(y.onNetworkError){const t=()=>{n=!0};await y.onNetworkError(h(new Error(e.message)),t)}const o=[void 0,e,!1,void 0];return o.__errorSuppressed=n,t.signal.removeEventListener("abort",B),o}throw a}finally{q&&clearTimeout(q),t.signal.removeEventListener("abort",B)}const D=y.responseType||"json";let F;try{F=await(async(e,t)=>{if(!e)throw new Error("No response received");switch(t){case"json":default:return await p(e);case"text":return await e.text();case"blob":return await e.blob();case"arraybuffer":return await e.arrayBuffer();case"formData":return await e.formData()}})(_,D)}catch(i){const e=g("Failed to parse response","network",_.status,void 0,i instanceof Error?i:new Error(String(i)));if(await m(y.retry,r,e))return await f(y.retry?.delay||1e3),this.executeRequest(y,t,r+1);let n=!1;if(y.onNetworkError){const t=()=>{n=!0};await y.onNetworkError(h(e.error||new Error(e.message)),t)}const o=[void 0,e,!1,void 0];return o.__errorSuppressed=n,o}if(!(y.validateStatus||l)(_.status)){const e=g(`HTTP Error: ${_.status} ${_.statusText}`,"http",_.status,F);if(await m(y.retry,r,e))return await f(y.retry?.delay||1e3),this.executeRequest(y,t,r+1);let n=!1;if(y.onHttpError){const t=()=>{n=!0},r=new Error(e.message);await y.onHttpError(r,_.status,F,t)}const o=[void 0,e,!1,{data:F,status:_.status,statusText:_.statusText,headers:_.headers,response:_}];return o.__errorSuppressed=n,o}if(!(y.validateResponse||d)(F)){const e=g("Business validation failed","business",_.status,F);if(await m(y.retry,r,e))return await f(y.retry?.delay||1e3),this.executeRequest(y,t,r+1);let n=!1;if(y.onBusinessError){const t=()=>{n=!0},r=new Error(e.message);await y.onBusinessError(r,F,t)}const o=[void 0,e,!1,{data:F,status:_.status,statusText:_.statusText,headers:_.headers,response:_}];return o.__errorSuppressed=n,o}let G=F;if(y.transformResponse)try{G=y.transformResponse(F)}catch(c){console.warn("[toAwaitFetch] transformResponse error:",c)}return[G,void 0,!0,{data:F,status:_.status,statusText:_.statusText,headers:_.headers,response:_}]}catch(a){const n=(e=>e instanceof DOMException&&"AbortError"===e.name)(a),o=g(n?"Request aborted":a instanceof Error?a.message:"Network error","network",void 0,void 0,a instanceof Error?a:new Error(String(a)));if(!n&&await m(e.retry,r,o))return await f(e.retry?.delay||1e3),this.executeRequest(e,t,r+1);let s=!1;if(e.onNetworkError){const t=()=>{s=!0};await e.onNetworkError(h(o.error||new Error(o.message)),t)}const i=[void 0,o,!1,void 0];return i.__errorSuppressed=s,i}var n,o,s}request(e){const t=c({...this.globalConfig},e),r=new AbortController,n=this.executeRequest(t,r);return y(n,()=>r.abort())}setGlobalConfig(e){this.globalConfig={...e}}getGlobalConfig(){return{...this.globalConfig}}mergeGlobalConfig(e){this.globalConfig=c(this.globalConfig,e)}sendGet(e,t,r){return this.request({...r,url:e,method:"GET",data:t})}sendPost(e,t,r){return this.request({...r,url:e,method:"POST",data:t,requestType:"json"})}sendPostForm(e,t,r){return this.request({...r,url:e,method:"POST",data:t,requestType:"form"})}sendPostBlob(e,t,r){return this.request({...r,url:e,method:"POST",data:t,requestType:"json",responseType:"blob"})}sendGetBlob(e,t,r){return this.request({...r,url:e,method:"GET",data:t,responseType:"blob"})}}const b=e=>new w(e),v=new w,S=(e,t,r)=>v.request({...r,url:e,method:"GET",data:t}),E=(e,t,r)=>v.sendPost(e,t,r),P=(e,t,r)=>v.sendPostForm(e,t,r),q=(e,t,r)=>v.sendPostBlob(e,t,r),x=(e,t,r)=>v.sendGetBlob(e,t,r),T=e=>{v.setGlobalConfig(e)},$=e=>{e?.cancel?.()},B=Object.assign(e=>e&&"object"==typeof e&&"url"in e?v.request(e):b(e),{create:b,sendGet:v.sendGet.bind(v),sendPost:v.sendPost.bind(v),sendPostForm:v.sendPostForm.bind(v),sendPostBlob:v.sendPostBlob.bind(v),sendGetBlob:v.sendGetBlob.bind(v),setGlobalConfig:v.setGlobalConfig.bind(v),cancel:$});function R(e,t){if(!e||!t)return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(null==n)return;n=n[o]}return n}function C(t){return"function"==typeof t?t():e(t)}function _(e,r){"undefined"!=typeof __DEV__&&__DEV__&&void 0!==e&&!function(e){return"function"==typeof e||t(e)}(e)&&console.warn(`[${r}] 检测到 params 是普通对象,参数变化将不会触发请求更新。\n请使用 computed() 或 getter 函数包装:`)}const D={};function F(e){Object.assign(D,e),e.pagination&&(D.pagination={...D.pagination,...e.pagination})}function G(){return{...D,pagination:{...D.pagination}}}function j(e,t={}){const a={...D.pagination,...t.pagination},{params:i,immediate:u=D.immediate??!0,debounceDelay:c=D.debounceDelay??0,dataField:l=D.dataField??"",totalField:d=D.totalField??"",currentPageField:f=D.currentPageField??"",transformParams:p,transformResult:g,onSuccess:h,onError:m,incremental:y=D.incremental??!1}=t,{defaultPage:w=1,defaultPageSize:b=10,pageKey:v="page",pageSizeKey:S="pageSize"}=a,E=r([]),P=r(!1),q=r(null),x=n({page:w,pageSize:b,total:0});let T=0;async function $(){const t=++T;P.value=!0,q.value=null;try{const r=i?C(i):{},n={[v]:x.page,[S]:x.pageSize};let o;o=p?p(r,{page:x.page,pageSize:x.pageSize}):{...r,...n};const s=await e(o);if(t!==T)return;if(g){const e=g(s);if(e&&"object"==typeof e&&Array.isArray(e.list)){const t=e.list;y&&x.page>w?E.value=[...E.value,...t]:E.value=t,x.total="number"==typeof e.total?e.total:e.list.length}else E.value=[],x.total=0,console.warn("[useTableRequest] transformResult 返回格式无法识别,请返回 { list: T[], total: number } 格式。")}else{const e=s;if(Array.isArray(e))y&&x.page>w?E.value=[...E.value,...e]:E.value=e,x.total=e.length;else if(e&&"object"==typeof e){if(l&&""!==l.trim()){const t=R(e,l)||[];y&&x.page>w?E.value=[...E.value,...t]:E.value=t}else E.value=[];d&&""!==d.trim()?x.total=R(e,d)??0:x.total=0}else E.value=[],x.total=0}if(f&&""!==f.trim()){const e=R(s,f);"number"==typeof e&&e!==x.page&&(console.warn(`[useTableRequest] 后端返回页码(${e})与客户端页码(${x.page})不一致,已自动修正`),x.page=e)}h?.(E.value,s)}catch(r){if(t!==T)return;q.value=r instanceof Error?r:new Error(String(r)),m?.(q.value)}finally{t===T&&(P.value=!1)}}const B=c>0?function(e,t){let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...n),r=null},t)}}($,c):$;let F=!1;async function G(){await $()}return o(()=>[x.page,x.pageSize],()=>{F||B()}),i&&(_(i,"useTableRequest"),o(()=>C(i),()=>{F=!0,x.page=w,F=!1,B()},{deep:!0})),u&&$(),{data:E,loading:P,error:q,pagination:x,run:G,onPageChange:async function(e){const t=x.page!==e;x.page=e,t||await $()},onSizeChange:async function(e){const t=x.pageSize!==e,r=x.page!==w;x.pageSize=e,x.page=w,t||r||await $()},refresh:async function(){y?(F=!0,x.page=w,E.value=[],await s(),F=!1,await $()):await G()}}}function N(e,n){let s,u;null===e||"object"!=typeof e||t(e)?(s=e,u=n||{}):(u=e,s="");const c=()=>a(u.precision)??0,l=()=>a(u.showThousands)??!1,d=r(a(s)?.toString()??""),f=i(()=>{let e=d.value;if(l()){const[t,r]=e.split(".");let n=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return r?n+=`.${r}`:e.includes(".")&&(n+="."),n}return e}),p=e=>{let t=null==e?"":e.toString().trim();const r=a(u.allowNegative)?/[^\d.-]/g:/[^\d.]/g;t=t.replace(r,""),t=t.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),t.length>1&&t.startsWith("0")&&"."!==t[1]&&(t=t.replace(/^0+/,""),""===t&&(t="0")),t.startsWith("-0")&&t.length>2&&"."!==t[2]&&(t="-"+t.slice(2).replace(/^0+/,""),"-"===t&&(t="-0"));const n=c();if(n>0){t=t.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=t.indexOf(".");if(-1!==e){if(t.slice(e+1).length>n){const r=a(u.decimalLimitMode)??"discard";if("discard"===r)t=t.slice(0,e+n+1);else{const o=Math.pow(10,n);let s=Number(t);isNaN(s)?t=t.slice(0,e+n+1):("round"===r?s=Math.round(s*o)/o:"ceil"===r&&(s=Math.ceil(s*o)/o),t=s.toString())}}}}else t=t.replace(/\./g,"");return t};return o(()=>a(s),e=>{const t=null==e?"":e.toString();t!==d.value&&(d.value=t)}),{value:d,displayValue:f,handleInput:e=>{const t=p(e);d.value=t},handleBlur:()=>{if(!d.value)return;let e=Number(d.value);const t=u.max??1/0,r=u.min??-1/0;e>t&&(e=t,d.value=t.toString()),e<r&&(e=r,d.value=r.toString());const n=a(u.autoFixed)??!1;d.value=!0===n||"pad"===n?e.toFixed(c()):"trim"===n?Number(e.toFixed(c())).toString():e.toString()},formatter:e=>f.value,parser:e=>l()?e.replace(/,/g,""):e,clean:p}}const O=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,z=/* @__PURE__ */new Set;let M=null;const I=(e,t)=>new Promise((r,n)=>{if(M)return r(M);const o=indexedDB.open(e,1);o.onupgradeneeded=e=>{const r=e.target.result;r.objectStoreNames.contains(t)||r.createObjectStore(t)},o.onsuccess=e=>{M=e.target.result,r(M)},o.onerror=e=>{n(e.target.error)}});function L(e){const{requestFn:t,cacheKey:n,cacheTime:s=3e5,storage:a="memory",params:i,transformResult:u,immediate:c=!0,storageKeyPrefix:l="req_cache_",forceRefreshOnFirst:d=!1,dbName:f="RequestCacheDB",storeName:p="request_cache",onSuccess:g,onError:h}=e,m=(e=>{if("undefined"==typeof window)return"memory";try{if("localStorage"===e&&!window.localStorage)throw new Error;if("sessionStorage"===e&&!window.sessionStorage)throw new Error;if("indexedDB"===e&&!window.indexedDB)throw new Error;return e}catch(t){return console.warn(`[useRequestCache] ${e} is not supported in this environment, falling back to 'memory' mode.`),"memory"}})(C(a)),y=r(),w=r(!1),b=r(null),v=()=>{const e=i?C(i):{};if("function"==typeof n)try{return n(e)}catch(t){return console.warn("[useRequestCache] Generate key failed",t),""}return n},S=async e=>{if("indexedDB"===m){try{const t=await I(f,p);return new Promise((r,n)=>{const o=t.transaction([p],"readwrite").objectStore(p).delete(`${l}${e}`);o.onsuccess=()=>r(),o.onerror=()=>n(o.error)})}catch(r){console.warn("[useRequestCache] IndexedDB delete failed",r)}return}const t="localStorage"===m?localStorage:"sessionStorage"===m?sessionStorage:null;t&&t.removeItem(`${l}${e}`)},E=async(e=!1)=>{const r=v();if(!r)return void console.warn("[useRequestCache] Cache key is empty, skipping request");const n=C(d)&&!z.has(r),o=e||n,a=i?C(i):{};if(!o&&"indexedDB"!==m){const e=O.get(r);if(e){if(Date.now()-e.timestamp<s)return y.value=u?u(e.data):e.data,g&&g(y.value),y.value;O.delete(r)}}w.value=!0,b.value=null;try{if(k.has(r)){if(g||h){const e=A.get(r);e&&(g&&e.onSuccess.push(g),h&&e.onError.push(h))}const e=await k.get(r);return y.value=u?u(e):e,y.value}if(!o&&"memory"!==m){const e=await(async e=>{if("indexedDB"===m)try{const t=await I(f,p);return new Promise(r=>{const n=t.transaction([p],"readonly").objectStore(p).get(`${l}${e}`);n.onsuccess=()=>r(n.result||null),n.onerror=()=>r(null)})}catch(r){return console.warn("[useRequestCache] IndexedDB read failed",r),null}const t="localStorage"===m?localStorage:"sessionStorage"===m?sessionStorage:null;if(!t)return null;try{const r=t.getItem(`${l}${e}`);if(r)return JSON.parse(r)}catch(r){console.warn("[useRequestCache] Read storage failed",r)}return null})(r);if(e){if(Date.now()-e.timestamp<s)return"indexedDB"!==m&&O.set(r,e),y.value=u?u(e.data):e.data,g&&g(y.value),y.value;await S(r)}}const e=t(a);k.set(r,e),A.set(r,{onSuccess:g?[g]:[],onError:h?[h]:[]});try{const t=await e,o={data:t,timestamp:Date.now()};"indexedDB"!==m&&O.set(r,o),"memory"!==m&&await(async(e,t)=>{if("indexedDB"===m){try{const r=await I(f,p);return new Promise((n,o)=>{const s=r.transaction([p],"readwrite").objectStore(p).put(t,`${l}${e}`);s.onsuccess=()=>n(),s.onerror=()=>o(s.error)})}catch(n){console.warn("[useRequestCache] IndexedDB write failed",n)}return}const r="localStorage"===m?localStorage:"sessionStorage"===m?sessionStorage:null;if(r)try{r.setItem(`${l}${e}`,JSON.stringify(t))}catch(n){console.warn("[useRequestCache] Write storage failed",n)}})(r,o),n&&z.add(r),y.value=u?u(t):t;const s=A.get(r);if(s&&s.onSuccess){[...s.onSuccess].forEach(e=>e(y.value))}return k.delete(r),A.delete(r),y.value}catch(c){b.value=c;const e=A.get(r);if(e&&e.onError){[...e.onError].forEach(e=>e(c))}throw k.delete(r),A.delete(r),c}}catch(c){throw b.value=c,c}finally{w.value=!1}},P=()=>E(!1);return i?o(()=>C(i),()=>{P()},{deep:!0,immediate:c}):c&&P(),{data:y,loading:w,error:b,run:P,refresh:()=>E(!0),clearCache:async e=>{const t=e||v();t&&(O.delete(t),"memory"!==m&&await S(t))}}}const W="1.6.2";function H(){return W}export{W as VERSION,$ as cancel,b as createInstance,G as getTableRequestGlobalConfig,H as getVersion,S as sendGet,x as sendGetBlob,E as sendPost,q as sendPostBlob,P as sendPostForm,T as setGlobalConfig,F as setTableRequestGlobalConfig,B as toAwaitFetch,N as useInputNumber,L as useRequestCache,j as useTableRequest};
1
+ var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,i=(e,t)=>{for(var r in t||(t={}))o.call(t,r)&&a(e,r,t[r]);if(n)for(var r of n(t))s.call(t,r)&&a(e,r,t[r]);return e},l=(e,n)=>t(e,r(n)),u=(e,t,r)=>new Promise((n,o)=>{var s=e=>{try{i(r.next(e))}catch(t){o(t)}},a=e=>{try{i(r.throw(e))}catch(t){o(t)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,a);i((r=r.apply(e,t)).next())});import{unref as c,isRef as d,ref as f,reactive as p,watch as y,nextTick as g,toValue as h,computed as m}from"vue";const b=e=>!("object"!=typeof e||null===e||Array.isArray(e)||e instanceof Date||e instanceof RegExp||e instanceof File||e instanceof Blob||"undefined"!=typeof FormData&&e instanceof FormData),v=(e,t)=>{const r=i({},e);for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const e=t[n];if(void 0===e)continue;const o=r[n];b(e)&&b(o)?r[n]=v(o,e):r[n]=e}return r},w=e=>e>=200&&e<300,S=()=>!0,E=e=>new Promise(t=>setTimeout(t,e)),P=e=>u(null,null,function*(){if(!(e=>{if(!e)return!0;if(204===e.status||205===e.status||304===e.status)return!0;const t=e.headers.get("content-length");return!(!t||0!==Number(t))})(e))try{return yield e.json()}catch(t){let o;try{o=yield e.text()}catch(r){return}if(!o.trim())return;try{return JSON.parse(o)}catch(n){return}}}),x=(e,t,r,n,o)=>({message:e,type:t,status:r,response:n,error:o}),q=e=>{if(e instanceof Error){const t=new Error(e.message);return e.name&&(t.name=e.name),e.stack&&(t.stack=e.stack),t}return new Error(String(e))},T=(e,t,r)=>u(null,null,function*(){var n;return!!(null==e?void 0:e.enabled)&&(!(t>(null!=(n=e.maxRetryCount)?n:3))&&(e.shouldRetry?yield e.shouldRetry(t,r):"network"===r.type||"timeout"===r.type))}),$=(e,t)=>{const r=Object.create(e);let n=!1,o=!1,s=!1;const a=e.then.bind(e),i=e.catch.bind(e),l=a(e=>{s=!0===e.__errorSuppressed,delete e.__errorSuppressed;const t=new Proxy(e,{get(e,t){if(("1"===t||"number"==typeof t&&1===t)&&(o=!0),t===Symbol.iterator){const t=e[Symbol.iterator]();return function*(){let e=0;for(const r of t)1===e&&(o=!0),yield r,e++}}return e[t]}}),r=e[1];return e[2]||!r||s||n||queueMicrotask(()=>{queueMicrotask(()=>{if(!(o||o||n||s)){const e=new Error(`Unhandled fetch error: ${r.message} (type: ${r.type})`);throw e.fetchError=r,e}})}),t});r.cancel=()=>{t&&t()};const u=l.then.bind(l);return r.then=function(e,r){return e&&"function"==typeof e&&!r&&e.length<=2?$(u(t=>{const r=t[2],n=t[0],o=t[3];return r&&void 0!==n&&e(n,o),t}),t):u(e,r)},r.catchHttp=function(e){n=!0;const r=u(t=>{const r=t[2],n=t[1];return!r&&n&&"http"===n.type&&e(n),!r&&n&&(t.__errorSuppressed=!0),t});return $(r,t)},r.catchBusiness=function(e){n=!0;const r=u(t=>{const r=t[1],n=t[2];return!n&&r&&"business"===r.type&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return $(r,t)},r.catchNetwork=function(e){if(n=!0,e&&"function"==typeof e){const r=u(t=>{const r=t[1],n=t[2];return!n&&r&&e(r),!n&&r&&(t.__errorSuppressed=!0),t});return $(r,t)}return i(e)},r};class B{constructor(e){var t;a(this,"symbol"!=typeof(t="globalConfig")?t+"":t,{}),e&&(this.globalConfig=i({},e)),this.request=this.request.bind(this),this.sendGet=this.sendGet.bind(this),this.sendPost=this.sendPost.bind(this),this.sendPostForm=this.sendPostForm.bind(this),this.sendPostBlob=this.sendPostBlob.bind(this),this.sendGetBlob=this.sendGetBlob.bind(this),this.setGlobalConfig=this.setGlobalConfig.bind(this)}executeRequest(e,t,r=1){return u(this,null,function*(){var n,o,s,a,l,c,d,f;try{const l=e,h=l.signal;h&&(h.aborted?t.abort():h.addEventListener("abort",()=>t.abort(),{once:!0}));const m=(c=l.headers,d=l.url,f=l.method,c?"function"==typeof c?c({url:d,method:f}):c:{}),{body:v,urlParams:$}=((e,t,r)=>{if(!e)return{};if("GET"===t||"HEAD"===t||"OPTIONS"===t){if(b(e)){const t=new URLSearchParams;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&t.append(r,String(n))}return{urlParams:t.toString()}}return{}}if("form"===r&&e instanceof FormData)return{body:e};if("form"===r&&b(e)){const t=new FormData;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const n=e[r];null!=n&&(n instanceof File||n instanceof Blob?t.append(r,n):t.append(r,String(n)))}return{body:t}}return"json"===r?{body:JSON.stringify(e)}:"text"===r?{body:String(e)}:"blob"===r&&e instanceof Blob||"arraybuffer"===r&&e instanceof ArrayBuffer?{body:e}:{body:String(e)}})(l.data,l.method||"GET",l.requestType||"json"),B=((e,t,r)=>{if(t.startsWith("http://")||t.startsWith("https://")){if(r){const e=t.includes("?")?"&":"?";return`${t}${e}${r}`}return t}let n=t;e&&(n=`${e.endsWith("/")?e.slice(0,-1):e}${t.startsWith("/")?t:`/${t}`}`);if(r){const e=n.includes("?")?"&":"?";n=`${n}${e}${r}`}return n})(l.baseURL,l.url,$),R=l.timeout;let C,D=!1,j=m;v&&"string"==typeof v&&"json"===l.requestType?j=i({"Content-Type":"application/json"},m):v instanceof FormData&&(j=m);const O=new AbortController,N=()=>O.abort();t.signal.addEventListener("abort",N);const _={method:l.method||"GET",headers:j,body:v,mode:"cors",credentials:!1===l.withCredentials?"same-origin":"include",signal:O.signal},F=fetch(B,_);let G;try{if(R){const e=new Promise((e,t)=>{C=setTimeout(()=>{D=!0,O.abort(),t(x("Request timeout","timeout"))},R)});G=yield Promise.race([F,e])}else G=yield F}catch(p){if(C&&clearTimeout(C),D){const e=x("Request timeout","timeout");if(yield T(l.retry,r,e))return t.signal.removeEventListener("abort",N),yield E((null==(n=l.retry)?void 0:n.delay)||1e3),this.executeRequest(l,t,r+1);let o=!1;if(l.onNetworkError){const t=()=>{o=!0};yield l.onNetworkError(q(new Error(e.message)),t)}const s=[void 0,e,!1,void 0];return s.__errorSuppressed=o,t.signal.removeEventListener("abort",N),s}throw p}finally{C&&clearTimeout(C),t.signal.removeEventListener("abort",N)}const k=l.responseType||"json";let A;try{A=yield((e,t)=>u(null,null,function*(){if(!e)throw new Error("No response received");switch(t){case"json":default:return yield P(e);case"text":return yield e.text();case"blob":return yield e.blob();case"arraybuffer":return yield e.arrayBuffer();case"formData":return yield e.formData()}}))(G,k)}catch(y){const e=x("Failed to parse response","network",G.status,void 0,y instanceof Error?y:new Error(String(y)));if(yield T(l.retry,r,e))return yield E((null==(o=l.retry)?void 0:o.delay)||1e3),this.executeRequest(l,t,r+1);let n=!1;if(l.onNetworkError){const t=()=>{n=!0};yield l.onNetworkError(q(e.error||new Error(e.message)),t)}const s=[void 0,e,!1,void 0];return s.__errorSuppressed=n,s}if(!(l.validateStatus||w)(G.status)){const e=x(`HTTP Error: ${G.status} ${G.statusText}`,"http",G.status,A);if(yield T(l.retry,r,e))return yield E((null==(s=l.retry)?void 0:s.delay)||1e3),this.executeRequest(l,t,r+1);let n=!1;if(l.onHttpError){const t=()=>{n=!0},r=new Error(e.message);yield l.onHttpError(r,G.status,A,t)}const o=[void 0,e,!1,{data:A,status:G.status,statusText:G.statusText,headers:G.headers,response:G}];return o.__errorSuppressed=n,o}if(!(l.validateResponse||S)(A)){const e=x("Business validation failed","business",G.status,A);if(yield T(l.retry,r,e))return yield E((null==(a=l.retry)?void 0:a.delay)||1e3),this.executeRequest(l,t,r+1);let n=!1;if(l.onBusinessError){const t=()=>{n=!0},r=new Error(e.message);yield l.onBusinessError(r,A,t)}const o=[void 0,e,!1,{data:A,status:G.status,statusText:G.statusText,headers:G.headers,response:G}];return o.__errorSuppressed=n,o}let z=A;if(l.transformResponse)try{z=l.transformResponse(A)}catch(g){console.warn("[toAwaitFetch] transformResponse error:",g)}return[z,void 0,!0,{data:A,status:G.status,statusText:G.statusText,headers:G.headers,response:G}]}catch(p){const n=(e=>e instanceof DOMException&&"AbortError"===e.name)(p),o=x(n?"Request aborted":p instanceof Error?p.message:"Network error","network",void 0,void 0,p instanceof Error?p:new Error(String(p)));if(!n&&(yield T(e.retry,r,o)))return yield E((null==(l=e.retry)?void 0:l.delay)||1e3),this.executeRequest(e,t,r+1);let s=!1;if(e.onNetworkError){const t=()=>{s=!0};yield e.onNetworkError(q(o.error||new Error(o.message)),t)}const a=[void 0,o,!1,void 0];return a.__errorSuppressed=s,a}})}request(e){const t=v(i({},this.globalConfig),e),r=new AbortController,n=this.executeRequest(t,r);return $(n,()=>r.abort())}setGlobalConfig(e){this.globalConfig=i({},e)}getGlobalConfig(){return i({},this.globalConfig)}mergeGlobalConfig(e){this.globalConfig=v(this.globalConfig,e)}sendGet(e,t,r){return this.request(l(i({},r),{url:e,method:"GET",data:t}))}sendPost(e,t,r){return this.request(l(i({},r),{url:e,method:"POST",data:t,requestType:"json"}))}sendPostForm(e,t,r){return this.request(l(i({},r),{url:e,method:"POST",data:t,requestType:"form"}))}sendPostBlob(e,t,r){return this.request(l(i({},r),{url:e,method:"POST",data:t,requestType:"json",responseType:"blob"}))}sendGetBlob(e,t,r){return this.request(l(i({},r),{url:e,method:"GET",data:t,responseType:"blob"}))}}const R=e=>new B(e),C=new B,D=(e,t,r)=>C.request(l(i({},r),{url:e,method:"GET",data:t})),j=(e,t,r)=>C.sendPost(e,t,r),O=(e,t,r)=>C.sendPostForm(e,t,r),N=(e,t,r)=>C.sendPostBlob(e,t,r),_=(e,t,r)=>C.sendGetBlob(e,t,r),F=e=>{C.setGlobalConfig(e)},G=e=>{var t;null==(t=null==e?void 0:e.cancel)||t.call(e)},k=Object.assign(e=>e&&"object"==typeof e&&"url"in e?C.request(e):R(e),{create:R,sendGet:C.sendGet.bind(C),sendPost:C.sendPost.bind(C),sendPostForm:C.sendPostForm.bind(C),sendPostBlob:C.sendPostBlob.bind(C),sendGetBlob:C.sendGetBlob.bind(C),setGlobalConfig:C.setGlobalConfig.bind(C),cancel:G});function A(e,t){if(!e||!t)return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(null==n)return;n=n[o]}return n}function z(e){return"function"==typeof e?e():c(e)}function M(e,t){"undefined"!=typeof __DEV__&&__DEV__&&void 0!==e&&!function(e){return"function"==typeof e||d(e)}(e)&&console.warn(`[${t}] 检测到 params 是普通对象,参数变化将不会触发请求更新。\n请使用 computed() 或 getter 函数包装:`)}const I={};function K(e){Object.assign(I,e),e.pagination&&(I.pagination=i(i({},I.pagination),e.pagination))}function L(){return l(i({},I),{pagination:i({},I.pagination)})}function W(e,t={}){var r,n,o,s,a,l;const c=i(i({},I.pagination),t.pagination),{params:d,immediate:h=null==(r=I.immediate)||r,debounceDelay:m=(null!=(n=I.debounceDelay)?n:0),dataField:b=(null!=(o=I.dataField)?o:""),totalField:v=(null!=(s=I.totalField)?s:""),currentPageField:w=(null!=(a=I.currentPageField)?a:""),transformParams:S,transformResult:E,onSuccess:P,onError:x,incremental:q=null!=(l=I.incremental)&&l}=t,{defaultPage:T=1,defaultPageSize:$=10,pageKey:B="page",pageSizeKey:R="pageSize"}=c,C=f([]),D=f(!1),j=f(null),O=p({page:T,pageSize:$,total:0});let N=0;function _(){return u(this,null,function*(){var t;const r=++N;D.value=!0,j.value=null;try{const n=d?z(d):{},o={[B]:O.page,[R]:O.pageSize};let s;s=S?S(n,{page:O.page,pageSize:O.pageSize}):i(i({},n),o);const a=yield e(s);if(r!==N)return;if(E){const e=E(a);if(e&&"object"==typeof e&&Array.isArray(e.list)){const t=e.list;q&&O.page>T?C.value=[...C.value,...t]:C.value=t,O.total="number"==typeof e.total?e.total:e.list.length}else C.value=[],O.total=0,console.warn("[useTableRequest] transformResult 返回格式无法识别,请返回 { list: T[], total: number } 格式。")}else{const e=a;if(Array.isArray(e))q&&O.page>T?C.value=[...C.value,...e]:C.value=e,O.total=e.length;else if(e&&"object"==typeof e){if(b&&""!==b.trim()){const t=A(e,b)||[];q&&O.page>T?C.value=[...C.value,...t]:C.value=t}else C.value=[];v&&""!==v.trim()?O.total=null!=(t=A(e,v))?t:0:O.total=0}else C.value=[],O.total=0}if(w&&""!==w.trim()){const e=A(a,w);"number"==typeof e&&e!==O.page&&(console.warn(`[useTableRequest] 后端返回页码(${e})与客户端页码(${O.page})不一致,已自动修正`),O.page=e)}null==P||P(C.value,a)}catch(n){if(r!==N)return;j.value=n instanceof Error?n:new Error(String(n)),null==x||x(j.value)}finally{r===N&&(D.value=!1)}})}const F=m>0?function(e,t){let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{e(...n),r=null},t)}}(_,m):_;let G=!1;function k(){return u(this,null,function*(){yield _()})}return y(()=>[O.page,O.pageSize],()=>{G||F()}),d&&(M(d,"useTableRequest"),y(()=>z(d),()=>{G=!0,O.page=T,G=!1,F()},{deep:!0})),h&&_(),{data:C,loading:D,error:j,pagination:O,run:k,onPageChange:function(e){return u(this,null,function*(){const t=O.page!==e;O.page=e,t||(yield _())})},onSizeChange:function(e){return u(this,null,function*(){const t=O.pageSize!==e,r=O.page!==T;O.pageSize=e,O.page=T,t||r||(yield _())})},refresh:function(){return u(this,null,function*(){q?(G=!0,O.page=T,C.value=[],yield g(),G=!1,yield _()):yield k()})}}}function H(e,t){var r,n;let o,s;null===e||"object"!=typeof e||d(e)?(o=e,s=t||{}):(s=e,o="");const a=()=>{var e;return null!=(e=h(s.precision))?e:0},i=()=>{var e;return null!=(e=h(s.showThousands))&&e},l=f(null!=(n=null==(r=h(o))?void 0:r.toString())?n:""),u=m(()=>{let e=l.value;if(i()){const[t,r]=e.split(".");let n=t.replace(/\B(?=(\d{3})+(?!\d))/g,",");return r?n+=`.${r}`:e.includes(".")&&(n+="."),n}return e}),c=e=>{let t=null==e?"":e.toString().trim();const r=null!=(n=h(s.allowNegative))&&n?/[^\d.-]/g:/[^\d.]/g;var n;t=t.replace(r,""),t=t.replace(/^-/,"$#$").replace(/-/g,"").replace("$#$","-"),t.length>1&&t.startsWith("0")&&"."!==t[1]&&(t=t.replace(/^0+/,""),""===t&&(t="0")),t.startsWith("-0")&&t.length>2&&"."!==t[2]&&(t="-"+t.slice(2).replace(/^0+/,""),"-"===t&&(t="-0"));const o=a();if(o>0){t=t.replace(/^\./g,"").replace(/\./g,"$#$").replace(/\./g,"").replace("$#$",".");const e=t.indexOf(".");if(-1!==e){if(t.slice(e+1).length>o){const r=(()=>{var e;return null!=(e=h(s.decimalLimitMode))?e:"discard"})();if("discard"===r)t=t.slice(0,e+o+1);else{const n=Math.pow(10,o);let s=Number(t);isNaN(s)?t=t.slice(0,e+o+1):("round"===r?s=Math.round(s*n)/n:"ceil"===r&&(s=Math.ceil(s*n)/n),t=s.toString())}}}}else t=t.replace(/\./g,"");return t};return y(()=>h(o),e=>{const t=null==e?"":e.toString();t!==l.value&&(l.value=t)}),{value:l,displayValue:u,handleInput:e=>{const t=c(e);l.value=t},handleBlur:()=>{var e,t;if(!l.value)return;let r=Number(l.value);const n=null!=(e=s.max)?e:1/0,o=null!=(t=s.min)?t:-1/0;r>n&&(r=n,l.value=n.toString()),r<o&&(r=o,l.value=o.toString());const i=(()=>{var e;return null!=(e=h(s.autoFixed))&&e})();l.value=!0===i||"pad"===i?r.toFixed(a()):"trim"===i?Number(r.toFixed(a())).toString():r.toString()},formatter:e=>u.value,parser:e=>i()?e.replace(/,/g,""):e,clean:c}}const J=/* @__PURE__ */new Map,V=/* @__PURE__ */new Map,U=/* @__PURE__ */new Map,Q=/* @__PURE__ */new Set,X=/* @__PURE__ */new Map;let Y=null;const Z=(e,t)=>new Promise((r,n)=>{if(Y)return r(Y);const o=indexedDB.open(e,1);o.onupgradeneeded=e=>{const r=e.target.result;r.objectStoreNames.contains(t)||r.createObjectStore(t)},o.onsuccess=e=>{Y=e.target.result,r(Y)},o.onerror=e=>{n(e.target.error)}});function ee(e,t){return u(this,null,function*(){const{storage:r,storageKeyPrefix:n,dbName:o,storeName:s}=t;if("indexedDB"===r)try{const t=yield Z(o,s);return new Promise(r=>{const o=t.transaction([s],"readonly").objectStore(s).get(`${n}${e}`);o.onsuccess=()=>r(o.result||null),o.onerror=()=>r(null)})}catch(i){return null}const a="localStorage"===r?localStorage:"sessionStorage"===r?sessionStorage:null;if(!a)return null;try{const t=a.getItem(`${n}${e}`);if(t)return JSON.parse(t)}catch(i){}return null})}function te(e,t,r){if(!r)return!0;if(r.keys&&!r.keys.includes(e))return!1;if(r.storage){if(!(Array.isArray(r.storage)?r.storage:[r.storage]).includes(t.storage))return!1}return void 0===r.storageKeyPrefix||t.storageKeyPrefix===r.storageKeyPrefix}function re(e){const{requestFn:t,cacheKey:r,cacheTime:n=3e5,storage:o="memory",params:s,transformResult:a,immediate:i=!0,storageKeyPrefix:l="req_cache_",forceRefreshOnFirst:c=!1,dbName:d="RequestCacheDB",storeName:p="request_cache",onSuccess:g,onError:h}=e,m=(e=>{if("undefined"==typeof window)return"memory";try{if("localStorage"===e&&!window.localStorage)throw new Error;if("sessionStorage"===e&&!window.sessionStorage)throw new Error;if("indexedDB"===e&&!window.indexedDB)throw new Error;return e}catch(t){return console.warn(`[useRequestCache] ${e} is not supported in this environment, falling back to 'memory' mode.`),"memory"}})(z(o)),b=f(),v=f(!1),w=f(null),S=()=>{const e=s?z(s):{};if("function"==typeof r)try{return r(e)}catch(t){return console.warn("[useRequestCache] Generate key failed",t),""}return r},E=e=>u(null,null,function*(){if("indexedDB"===m){try{const t=yield Z(d,p);return new Promise((r,n)=>{const o=t.transaction([p],"readwrite").objectStore(p).delete(`${l}${e}`);o.onsuccess=()=>r(),o.onerror=()=>n(o.error)})}catch(r){console.warn("[useRequestCache] IndexedDB delete failed",r)}return}const t="localStorage"===m?localStorage:"sessionStorage"===m?sessionStorage:null;t&&t.removeItem(`${l}${e}`)}),P=(e=!1)=>u(null,null,function*(){const r=S();if(!r)return void console.warn("[useRequestCache] Cache key is empty, skipping request");const o=z(c)&&!Q.has(r),i=e||o,f=s?z(s):{};if(!i&&"indexedDB"!==m){const e=J.get(r);if(e){if(Date.now()-e.timestamp<n)return b.value=a?a(e.data):e.data,g&&g(b.value),b.value;J.delete(r)}}v.value=!0,w.value=null;try{if(V.has(r)){if(g||h){const e=U.get(r);e&&(g&&e.onSuccess.push(g),h&&e.onError.push(h))}const e=yield V.get(r);return b.value=a?a(e):e,b.value}if(!i&&"memory"!==m){const e=yield(e=>u(null,null,function*(){if("indexedDB"===m)try{const t=yield Z(d,p);return new Promise(r=>{const n=t.transaction([p],"readonly").objectStore(p).get(`${l}${e}`);n.onsuccess=()=>r(n.result||null),n.onerror=()=>r(null)})}catch(r){return console.warn("[useRequestCache] IndexedDB read failed",r),null}const t="localStorage"===m?localStorage:"sessionStorage"===m?sessionStorage:null;if(!t)return null;try{const r=t.getItem(`${l}${e}`);if(r)return JSON.parse(r)}catch(r){console.warn("[useRequestCache] Read storage failed",r)}return null}))(r);if(e){if(Date.now()-e.timestamp<n)return"indexedDB"!==m&&J.set(r,e),X.set(r,{storage:m,storageKeyPrefix:l,dbName:d,storeName:p,cacheTime:n,clearFn:()=>q(r)}),b.value=a?a(e.data):e.data,g&&g(b.value),b.value;yield E(r)}}const e=t(f);V.set(r,e),U.set(r,{onSuccess:g?[g]:[],onError:h?[h]:[]});try{const t=yield e,s={data:t,timestamp:Date.now()};"indexedDB"!==m&&J.set(r,s),"memory"!==m&&(yield((e,t)=>u(null,null,function*(){if("indexedDB"===m){try{const r=yield Z(d,p);return new Promise((n,o)=>{const s=r.transaction([p],"readwrite").objectStore(p).put(t,`${l}${e}`);s.onsuccess=()=>n(),s.onerror=()=>o(s.error)})}catch(n){console.warn("[useRequestCache] IndexedDB write failed",n)}return}const r="localStorage"===m?localStorage:"sessionStorage"===m?sessionStorage:null;if(r)try{r.setItem(`${l}${e}`,JSON.stringify(t))}catch(n){console.warn("[useRequestCache] Write storage failed",n)}}))(r,s)),X.set(r,{storage:m,storageKeyPrefix:l,dbName:d,storeName:p,cacheTime:n,clearFn:()=>q(r)}),o&&Q.add(r),b.value=a?a(t):t;const i=U.get(r);if(i&&i.onSuccess){[...i.onSuccess].forEach(e=>e(b.value))}return V.delete(r),U.delete(r),b.value}catch(y){w.value=y;const e=U.get(r);if(e&&e.onError){[...e.onError].forEach(e=>e(y))}throw V.delete(r),U.delete(r),y}}catch(y){throw w.value=y,y}finally{v.value=!1}}),x=()=>P(!1),q=e=>u(null,null,function*(){const t=e||S();t&&(J.delete(t),X.delete(t),"memory"!==m&&(yield E(t)))});return s?y(()=>z(s),()=>{x()},{deep:!0,immediate:i}):i&&x(),{data:b,loading:v,error:w,run:x,refresh:()=>P(!0),clearCache:q}}function ne(e){return u(this,null,function*(){const t=[...X.entries()].filter(([t,r])=>te(t,r,e));yield Promise.all(t.map(([,e])=>e.clearFn()))})}function oe(e){return u(this,null,function*(){var t;const r=[];for(const[n,o]of X.entries()){if(!te(n,o,e))continue;let s=null;s="memory"===o.storage?null!=(t=J.get(n))?t:null:yield ee(n,o),s&&r.push({key:n,data:s.data,timestamp:s.timestamp,storage:o.storage,isExpired:Date.now()-s.timestamp>=o.cacheTime})}return r})}const se="1.7.0";function ae(){return se}export{se as VERSION,G as cancel,ne as clearRequestCache,R as createInstance,oe as getRequestCache,L as getTableRequestGlobalConfig,ae as getVersion,D as sendGet,_ as sendGetBlob,j as sendPost,N as sendPostBlob,O as sendPostForm,F as setGlobalConfig,K as setTableRequestGlobalConfig,k as toAwaitFetch,H as useInputNumber,re as useRequestCache,W as useTableRequest};
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.6.2",
3
- "generatedAt": "2026-03-17T05:37:08.311Z",
2
+ "version": "1.7.0",
3
+ "generatedAt": "2026-03-20T03:13:18.627Z",
4
4
  "hooks": [
5
5
  {
6
6
  "name": "toAwaitFetch",
@@ -43,7 +43,7 @@
43
43
  {
44
44
  "name": "useRequestCache",
45
45
  "description": "用于处理请求缓存的 Hook,支持内存缓存、持久化缓存(LocalStorage/SessionStorage)、请求去重(并发共享)和结果转换。",
46
- "typeDefinitions": "export type CacheStrategy = 'memory' | 'localStorage' | 'sessionStorage' | 'indexedDB'\n\nexport type CacheKeyGenerator<P> = string | ((params: P) => string)\n\nexport interface UseRequestCacheOptions<T = any, P = any, R = any> {\n /** 请求函数 */\n requestFn: (params: P) => Promise<R>\n \n /** 缓存唯一标记,用于区分不同请求。可以是字符串或生成函数 */\n cacheKey: CacheKeyGenerator<P>\n \n /** 缓存时间(毫秒),默认 5 分钟 (300000ms) */\n cacheTime?: number\n \n /** Storage 策略,默认为 'memory' */\n storage?: MaybeRefOrGetter<CacheStrategy>\n \n /** 请求参数(响应式或普通对象),用于生成动态 key */\n params?: MaybeRefOrGetter<P>\n \n /** 结果转换函数,在返回数据前进行转换 */\n transformResult?: (data: R) => T\n \n /** 是否立即执行,默认 true */\n immediate?: boolean\n\n /** 手动指定的 storage key 前缀,默认 'req_cache_' */\n storageKeyPrefix?: string\n\n /** 首次请求是否强制更新(跳过缓存),默认为 false */\n forceRefreshOnFirst?: MaybeRefOrGetter<boolean>\n\n /** IndexedDB 数据库名称,仅在 storage 为 'indexedDB' 时有效,默认 'RequestCacheDB' */\n dbName?: string\n\n /** IndexedDB 存储对象名称,仅在 storage 为 'indexedDB' 时有效,默认 'request_cache' */\n storeName?: string\n\n /** 请求成功的回调 */\n onSuccess?: (data: T) => void\n\n /** 请求失败的回调 */\n onError?: (error: any) => void\n}\n\nexport interface UseRequestCacheReturn<T> {\n data: Ref<T | undefined>\n loading: Ref<boolean>\n error: Ref<any>\n \n /** 执行请求 (优先使用缓存) */\n run: () => Promise<T | undefined>\n \n /** 刷新(忽略缓存,强制请求) */\n refresh: () => Promise<T | undefined>\n \n /** 清除指定 key 的缓存,如果不传则清除当前自动生成的 key */\n clearCache: (key?: string) => Promise<void>\n}",
46
+ "typeDefinitions": "export type CacheStrategy = 'memory' | 'localStorage' | 'sessionStorage' | 'indexedDB'\n\nexport type CacheKeyGenerator<P> = string | ((params: P) => string)\n\nexport interface UseRequestCacheOptions<T = any, P = any, R = any> {\n /** 请求函数 */\n requestFn: (params: P) => Promise<R>\n \n /** 缓存唯一标记,用于区分不同请求。可以是字符串或生成函数 */\n cacheKey: CacheKeyGenerator<P>\n \n /** 缓存时间(毫秒),默认 5 分钟 (300000ms) */\n cacheTime?: number\n \n /** Storage 策略,默认为 'memory' */\n storage?: MaybeRefOrGetter<CacheStrategy>\n \n /** 请求参数(响应式或普通对象),用于生成动态 key */\n params?: MaybeRefOrGetter<P>\n \n /** 结果转换函数,在返回数据前进行转换 */\n transformResult?: (data: R) => T\n \n /** 是否立即执行,默认 true */\n immediate?: boolean\n\n /** 手动指定的 storage key 前缀,默认 'req_cache_' */\n storageKeyPrefix?: string\n\n /** 首次请求是否强制更新(跳过缓存),默认为 false */\n forceRefreshOnFirst?: MaybeRefOrGetter<boolean>\n\n /** IndexedDB 数据库名称,仅在 storage 为 'indexedDB' 时有效,默认 'RequestCacheDB' */\n dbName?: string\n\n /** IndexedDB 存储对象名称,仅在 storage 为 'indexedDB' 时有效,默认 'request_cache' */\n storeName?: string\n\n /** 请求成功的回调 */\n onSuccess?: (data: T) => void\n\n /** 请求失败的回调 */\n onError?: (error: any) => void\n}\n\nexport interface UseRequestCacheReturn<T> {\n data: Ref<T | undefined>\n loading: Ref<boolean>\n error: Ref<any>\n \n /** 执行请求 (优先使用缓存) */\n run: () => Promise<T | undefined>\n \n /** 刷新(忽略缓存,强制请求) */\n refresh: () => Promise<T | undefined>\n \n /** 清除指定 key 的缓存,如果不传则清除当前自动生成的 key */\n clearCache: (key?: string) => Promise<void>\n}\n\nexport interface CacheSnapshot {\n /** 缓存的原始 key(不含 storageKeyPrefix) */\n key: string\n /** 缓存的原始数据(未经 transformResult 处理) */\n data: unknown\n /** 写入时间戳(毫秒) */\n timestamp: number\n /** 所在 storage 策略 */\n storage: CacheStrategy\n /** 是否已过期(但尚未被清除) */\n isExpired: boolean\n}\n\nexport interface RequestCacheFilter {\n /** 指定要操作的 key 列表,不传则匹配所有 */\n keys?: string[]\n /** 按 storage 策略过滤,不传则匹配所有 */\n storage?: CacheStrategy | CacheStrategy[]\n /** 按 storageKeyPrefix 过滤,不传则匹配所有 */\n storageKeyPrefix?: string\n}",
47
47
  "templates": {
48
48
  "default": "<script setup lang=\"ts\">\nimport { useRequestCache } from 'xn-fe-tools'\nimport { ref, computed } from 'vue'\n\n// 模拟请求函数\nconst fetchUserInfo = async (params: { id: number }) => {\n return new Promise(resolve =>\n setTimeout(() => {\n resolve({ id: params.id, name: `User ${params.id}`, role: 'admin' })\n }, 500)\n )\n}\n\nconst userId = ref(1)\n\nconst { data, loading, run, refresh } = useRequestCache({\n // 请求函数\n requestFn: fetchUserInfo,\n // 参数 (响应式)\n params: computed(() => ({ id: userId.value })),\n // 缓存 Key (动态)\n cacheKey: params => `user-info-${params.id}`,\n // 缓存时间 5 分钟\n cacheTime: 5 * 60 * 1000,\n // 自动执行\n immediate: true,\n})\n</script>\n\n<template>\n <div>\n <div v-if=\"loading\">Loading...</div>\n <div v-else>\n <pre>{{ data }}</pre>\n </div>\n\n <button @click=\"userId++\">Next User (New Request)</button>\n <button @click=\"userId--\">Prev User (Cached?)</button>\n <button @click=\"refresh\">Force Refresh</button>\n </div>\n</template>"
49
49
  },
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../shared/core.cjs.js"),t=require("../shared/sentry/shared-base.cjs.js");exports.getSentryViteConfig=e.getSentryViteConfig,exports.breadcrumbsIntegration=t.breadcrumbsIntegration,exports.browserTracingIntegration=t.browserTracingIntegration,exports.captureConsoleIntegration=t.captureConsoleIntegration,exports.contextLinesIntegration=t.contextLinesIntegration,exports.extraErrorDataIntegration=t.extraErrorDataIntegration,exports.feedbackIntegration=t.feedbackSyncIntegration,exports.httpClientIntegration=t.httpClientIntegration,exports.replayIntegration=t.replayIntegration,exports.reportingObserverIntegration=t.reportingObserverIntegration,exports.toSentrySetup=function(r){const{dsn:n,enabled:i=!0}=r;if(!e.isValidDsn(n))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),e.createUninitializedReturn();if(!i)return e.createUninitializedReturn();const o=e.buildIntegrations(r,[],{browserTracingIntegration:e=>t.browserTracingIntegration(e),replayIntegration:e=>t.replayIntegration(e),breadcrumbsIntegration:e=>t.breadcrumbsIntegration(e)}),a=e.mergeConfig(r);return t.init({...a,integrations:o}),{isInitialized:!0,captureException:e=>t.captureException(e),captureMessage:e=>t.captureMessage(e),setUser:e=>t.setUser(e)}};
1
+ "use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../shared/core.cjs.js"),g=require("../shared/sentry/shared-base.cjs.js");exports.getSentryViteConfig=s.getSentryViteConfig,exports.breadcrumbsIntegration=g.breadcrumbsIntegration,exports.browserTracingIntegration=g.browserTracingIntegration,exports.captureConsoleIntegration=g.captureConsoleIntegration,exports.contextLinesIntegration=g.contextLinesIntegration,exports.extraErrorDataIntegration=g.extraErrorDataIntegration,exports.feedbackIntegration=g.feedbackSyncIntegration,exports.httpClientIntegration=g.httpClientIntegration,exports.replayIntegration=g.replayIntegration,exports.reportingObserverIntegration=g.reportingObserverIntegration,exports.toSentrySetup=function(e){const{dsn:p,enabled:c=!0}=e;if(!s.isValidDsn(p))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),s.createUninitializedReturn();if(!c)return s.createUninitializedReturn();const b=s.buildIntegrations(e,[],{browserTracingIntegration:e=>g.browserTracingIntegration(e),replayIntegration:e=>g.replayIntegration(e),breadcrumbsIntegration:e=>g.breadcrumbsIntegration(e)}),l=s.mergeConfig(e);var u;return g.init((u=((e,t)=>{for(var r in t||(t={}))o.call(t,r)&&a(e,r,t[r]);if(n)for(var r of n(t))i.call(t,r)&&a(e,r,t[r]);return e})({},l),t(u,r({integrations:b})))),{isInitialized:!0,captureException:e=>g.captureException(e),captureMessage:e=>g.captureMessage(e),setUser:e=>g.setUser(e)}};
@@ -1 +1 @@
1
- import{i as e,c as r,b as t,m as s}from"../shared/core.es.js";import{g as a}from"../shared/core.es.js";import{i as n,r as i,u as o,c,v as g,w as p,p as d}from"../shared/sentry/shared-base.es.js";import{z as f,A as m,B as I,x as b,y as u,C as l}from"../shared/sentry/shared-base.es.js";function h(a){const{dsn:f,enabled:m=!0}=a;if(!e(f))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),r();if(!m)return r();const I=t(a,[],{browserTracingIntegration:e=>d(e),replayIntegration:e=>p(e),breadcrumbsIntegration:e=>g(e)}),b=s(a);return n({...b,integrations:I}),{isInitialized:!0,captureException:e=>c(e),captureMessage:e=>o(e),setUser:e=>i(e)}}export{g as breadcrumbsIntegration,d as browserTracingIntegration,f as captureConsoleIntegration,m as contextLinesIntegration,I as extraErrorDataIntegration,b as feedbackIntegration,a as getSentryViteConfig,u as httpClientIntegration,p as replayIntegration,l as reportingObserverIntegration,h as toSentrySetup};
1
+ var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,o=(r,t,a)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;import{i,c as p,b as c,m as b}from"../shared/core.es.js";import{g}from"../shared/core.es.js";import{i as l,r as f,u as d,c as u,v as m,w as y,p as I}from"../shared/sentry/shared-base.es.js";import{z as j,A as O,B as h,x as v,y as w,C as x}from"../shared/sentry/shared-base.es.js";function P(e){const{dsn:g,enabled:j=!0}=e;if(!i(g))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),p();if(!j)return p();const O=c(e,[],{browserTracingIntegration:e=>I(e),replayIntegration:e=>y(e),breadcrumbsIntegration:e=>m(e)}),h=b(e);var v;return l((v=((e,r)=>{for(var t in r||(r={}))n.call(r,t)&&o(e,t,r[t]);if(a)for(var t of a(r))s.call(r,t)&&o(e,t,r[t]);return e})({},h),r(v,t({integrations:O})))),{isInitialized:!0,captureException:e=>u(e),captureMessage:e=>d(e),setUser:e=>f(e)}}export{m as breadcrumbsIntegration,I as browserTracingIntegration,j as captureConsoleIntegration,O as contextLinesIntegration,h as extraErrorDataIntegration,v as feedbackIntegration,g as getSentryViteConfig,w as httpClientIntegration,y as replayIntegration,x as reportingObserverIntegration,P as toSentrySetup};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../shared/core.cjs.js"),t=require("../shared/sentry/shared-base.cjs.js"),r=require("../shared/sentry/shared-react.cjs.js");exports.getSentryViteConfig=e.getSentryViteConfig,exports.breadcrumbsIntegration=t.breadcrumbsIntegration,exports.browserTracingIntegration=t.browserTracingIntegration,exports.captureConsoleIntegration=t.captureConsoleIntegration,exports.contextLinesIntegration=t.contextLinesIntegration,exports.extraErrorDataIntegration=t.extraErrorDataIntegration,exports.feedbackIntegration=t.feedbackSyncIntegration,exports.httpClientIntegration=t.httpClientIntegration,exports.replayIntegration=t.replayIntegration,exports.reportingObserverIntegration=t.reportingObserverIntegration,exports.toReactSentrySetup=function(n){const{dsn:i,enabled:a=!0,reactRouter:o}=n;if(!e.isValidDsn(i))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),e.createUninitializedReturn();if(!a)return e.createUninitializedReturn();const s=o?[t.browserTracingIntegration({...o})]:[],g=e.buildIntegrations(n,s,{browserTracingIntegration:e=>t.browserTracingIntegration(e),replayIntegration:e=>t.replayIntegration(e),breadcrumbsIntegration:e=>t.breadcrumbsIntegration(e)}),{reactRouter:c,...p}=e.mergeConfig(n);return r.init({...p,integrations:g}),{isInitialized:!0,captureException:e=>t.captureException(e),captureMessage:e=>t.captureMessage(e),setUser:e=>t.setUser(e)}};
1
+ "use strict";var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,i=(r,t,n)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,s=(e,r)=>{for(var t in r||(r={}))o.call(r,t)&&i(e,t,r[t]);if(n)for(var t of n(r))a.call(r,t)&&i(e,t,r[t]);return e};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../shared/core.cjs.js"),g=require("../shared/sentry/shared-base.cjs.js"),p=require("../shared/sentry/shared-react.cjs.js");exports.getSentryViteConfig=c.getSentryViteConfig,exports.breadcrumbsIntegration=g.breadcrumbsIntegration,exports.browserTracingIntegration=g.browserTracingIntegration,exports.captureConsoleIntegration=g.captureConsoleIntegration,exports.contextLinesIntegration=g.contextLinesIntegration,exports.extraErrorDataIntegration=g.extraErrorDataIntegration,exports.feedbackIntegration=g.feedbackSyncIntegration,exports.httpClientIntegration=g.httpClientIntegration,exports.replayIntegration=g.replayIntegration,exports.reportingObserverIntegration=g.reportingObserverIntegration,exports.toReactSentrySetup=function(e){const{dsn:i,enabled:l=!0,reactRouter:u}=e;if(!c.isValidDsn(i))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),c.createUninitializedReturn();if(!l)return c.createUninitializedReturn();const b=u?[g.browserTracingIntegration(s({},u))]:[],I=c.buildIntegrations(e,b,{browserTracingIntegration:e=>g.browserTracingIntegration(e),replayIntegration:e=>g.replayIntegration(e),breadcrumbsIntegration:e=>g.breadcrumbsIntegration(e)}),d=c.mergeConfig(e),{reactRouter:f}=d,x=((e,r)=>{var t={};for(var i in e)o.call(e,i)&&r.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&n)for(var i of n(e))r.indexOf(i)<0&&a.call(e,i)&&(t[i]=e[i]);return t})(d,["reactRouter"]);var y;return p.init((y=s({},x),r(y,t({integrations:I})))),{isInitialized:!0,captureException:e=>g.captureException(e),captureMessage:e=>g.captureMessage(e),setUser:e=>g.setUser(e)}};
@@ -1 +1 @@
1
- import{i as e,c as r,b as t,m as s}from"../shared/core.es.js";import{g as a}from"../shared/core.es.js";import{p as n,r as o,u as i,c,v as p,w as g}from"../shared/sentry/shared-base.es.js";import{z as d,A as m,B as f,x as u,y as I,C as b}from"../shared/sentry/shared-base.es.js";import{i as h}from"../shared/sentry/shared-react.es.js";function l(a){const{dsn:d,enabled:m=!0,reactRouter:f}=a;if(!e(d))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),r();if(!m)return r();const u=f?[n({...f})]:[],I=t(a,u,{browserTracingIntegration:e=>n(e),replayIntegration:e=>g(e),breadcrumbsIntegration:e=>p(e)}),{reactRouter:b,...l}=s(a);return h({...l,integrations:I}),{isInitialized:!0,captureException:e=>c(e),captureMessage:e=>i(e),setUser:e=>o(e)}}export{p as breadcrumbsIntegration,n as browserTracingIntegration,d as captureConsoleIntegration,m as contextLinesIntegration,f as extraErrorDataIntegration,u as feedbackIntegration,a as getSentryViteConfig,I as httpClientIntegration,g as replayIntegration,b as reportingObserverIntegration,l as toReactSentrySetup};
1
+ var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,o=(r,t,a)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a,i=(e,r)=>{for(var t in r||(r={}))n.call(r,t)&&o(e,t,r[t]);if(a)for(var t of a(r))s.call(r,t)&&o(e,t,r[t]);return e};import{i as c,c as p,b as f,m as l}from"../shared/core.es.js";import{g as b}from"../shared/core.es.js";import{p as d,r as g,u,c as m,v as y,w as O}from"../shared/sentry/shared-base.es.js";import{z as j,A as v,B as I,x as h,y as w,C as x}from"../shared/sentry/shared-base.es.js";import{i as P}from"../shared/sentry/shared-react.es.js";function S(e){const{dsn:o,enabled:b=!0,reactRouter:j}=e;if(!c(o))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),p();if(!b)return p();const v=j?[d(i({},j))]:[],I=f(e,v,{browserTracingIntegration:e=>d(e),replayIntegration:e=>O(e),breadcrumbsIntegration:e=>y(e)}),h=l(e),{reactRouter:w}=h,x=((e,r)=>{var t={};for(var o in e)n.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&a)for(var o of a(e))r.indexOf(o)<0&&s.call(e,o)&&(t[o]=e[o]);return t})(h,["reactRouter"]);var S;return P((S=i({},x),r(S,t({integrations:I})))),{isInitialized:!0,captureException:e=>m(e),captureMessage:e=>u(e),setUser:e=>g(e)}}export{y as breadcrumbsIntegration,d as browserTracingIntegration,j as captureConsoleIntegration,v as contextLinesIntegration,I as extraErrorDataIntegration,h as feedbackIntegration,b as getSentryViteConfig,w as httpClientIntegration,O as replayIntegration,x as reportingObserverIntegration,S as toReactSentrySetup};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../shared/core.cjs.js"),t=require("../shared/sentry/shared-vue.cjs.js"),r=require("../shared/sentry/shared-base.cjs.js");exports.getSentryViteConfig=e.getSentryViteConfig,exports.browserTracingIntegration=t.browserTracingIntegration,exports.breadcrumbsIntegration=r.breadcrumbsIntegration,exports.captureConsoleIntegration=r.captureConsoleIntegration,exports.contextLinesIntegration=r.contextLinesIntegration,exports.extraErrorDataIntegration=r.extraErrorDataIntegration,exports.feedbackIntegration=r.feedbackSyncIntegration,exports.httpClientIntegration=r.httpClientIntegration,exports.replayIntegration=r.replayIntegration,exports.reportingObserverIntegration=r.reportingObserverIntegration,exports.toVue2SentrySetup=function(n){const{dsn:i,enabled:o=!0,Vue:a,router:s}=n;if(!e.isValidDsn(i))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),e.createUninitializedReturn();if(!o)return e.createUninitializedReturn();const g=s?[t.browserTracingIntegration({router:s})]:[],c=e.buildIntegrations(n,g,{browserTracingIntegration:e=>t.browserTracingIntegration(e),replayIntegration:e=>r.replayIntegration(e),breadcrumbsIntegration:e=>r.breadcrumbsIntegration(e)}),{Vue:p,router:u,...I}=e.mergeConfig(n);return t.init({...I,Vue:a,integrations:c}),{isInitialized:!0,captureException:e=>r.captureException(e),captureMessage:e=>r.captureMessage(e),setUser:e=>r.setUser(e)}};
1
+ "use strict";var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(r,t,n)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../shared/core.cjs.js"),g=require("../shared/sentry/shared-vue.cjs.js"),c=require("../shared/sentry/shared-base.cjs.js");exports.getSentryViteConfig=s.getSentryViteConfig,exports.browserTracingIntegration=g.browserTracingIntegration,exports.breadcrumbsIntegration=c.breadcrumbsIntegration,exports.captureConsoleIntegration=c.captureConsoleIntegration,exports.contextLinesIntegration=c.contextLinesIntegration,exports.extraErrorDataIntegration=c.extraErrorDataIntegration,exports.feedbackIntegration=c.feedbackSyncIntegration,exports.httpClientIntegration=c.httpClientIntegration,exports.replayIntegration=c.replayIntegration,exports.reportingObserverIntegration=c.reportingObserverIntegration,exports.toVue2SentrySetup=function(e){const{dsn:p,enabled:u=!0,Vue:l,router:b}=e;if(!s.isValidDsn(p))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),s.createUninitializedReturn();if(!u)return s.createUninitializedReturn();const I=b?[g.browserTracingIntegration({router:b})]:[],d=s.buildIntegrations(e,I,{browserTracingIntegration:e=>g.browserTracingIntegration(e),replayIntegration:e=>c.replayIntegration(e),breadcrumbsIntegration:e=>c.breadcrumbsIntegration(e)}),f=s.mergeConfig(e),{Vue:x,router:y}=f,O=((e,r)=>{var t={};for(var a in e)o.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&n)for(var a of n(e))r.indexOf(a)<0&&i.call(e,a)&&(t[a]=e[a]);return t})(f,["Vue","router"]);var j;return g.init((j=((e,r)=>{for(var t in r||(r={}))o.call(r,t)&&a(e,t,r[t]);if(n)for(var t of n(r))i.call(r,t)&&a(e,t,r[t]);return e})({},O),r(j,t({Vue:l,integrations:d})))),{isInitialized:!0,captureException:e=>c.captureException(e),captureMessage:e=>c.captureMessage(e),setUser:e=>c.setUser(e)}};
@@ -1 +1 @@
1
- import{i as e,c as r,b as t,m as s}from"../shared/core.es.js";import{g as a}from"../shared/core.es.js";import{b as n,i as o}from"../shared/sentry/shared-vue.es.js";import{r as i,u as c,c as g,v as p,w as u}from"../shared/sentry/shared-base.es.js";import{z as d,A as m,B as f,x as b,y as I,C as h}from"../shared/sentry/shared-base.es.js";function l(a){const{dsn:d,enabled:m=!0,Vue:f,router:b}=a;if(!e(d))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),r();if(!m)return r();const I=b?[n({router:b})]:[],h=t(a,I,{browserTracingIntegration:e=>n(e),replayIntegration:e=>u(e),breadcrumbsIntegration:e=>p(e)}),{Vue:l,router:y,...j}=s(a);return o({...j,Vue:f,integrations:h}),{isInitialized:!0,captureException:e=>g(e),captureMessage:e=>c(e),setUser:e=>i(e)}}export{p as breadcrumbsIntegration,n as browserTracingIntegration,d as captureConsoleIntegration,m as contextLinesIntegration,f as extraErrorDataIntegration,b as feedbackIntegration,a as getSentryViteConfig,I as httpClientIntegration,u as replayIntegration,h as reportingObserverIntegration,l as toVue2SentrySetup};
1
+ var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,o=(r,t,a)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;import{i,c,b as p,m as u}from"../shared/core.es.js";import{g as f}from"../shared/core.es.js";import{b as l,i as b}from"../shared/sentry/shared-vue.es.js";import{r as d,u as g,c as m,v as y,w as v}from"../shared/sentry/shared-base.es.js";import{z as O,A as j,B as I,x as h,y as w,C as x}from"../shared/sentry/shared-base.es.js";function P(e){const{dsn:f,enabled:O=!0,Vue:j,router:I}=e;if(!i(f))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),c();if(!O)return c();const h=I?[l({router:I})]:[],w=p(e,h,{browserTracingIntegration:e=>l(e),replayIntegration:e=>v(e),breadcrumbsIntegration:e=>y(e)}),x=u(e),{Vue:P,router:V}=x,S=((e,r)=>{var t={};for(var o in e)n.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&a)for(var o of a(e))r.indexOf(o)<0&&s.call(e,o)&&(t[o]=e[o]);return t})(x,["Vue","router"]);var C;return b((C=((e,r)=>{for(var t in r||(r={}))n.call(r,t)&&o(e,t,r[t]);if(a)for(var t of a(r))s.call(r,t)&&o(e,t,r[t]);return e})({},S),r(C,t({Vue:j,integrations:w})))),{isInitialized:!0,captureException:e=>m(e),captureMessage:e=>g(e),setUser:e=>d(e)}}export{y as breadcrumbsIntegration,l as browserTracingIntegration,O as captureConsoleIntegration,j as contextLinesIntegration,I as extraErrorDataIntegration,h as feedbackIntegration,f as getSentryViteConfig,w as httpClientIntegration,v as replayIntegration,x as reportingObserverIntegration,P as toVue2SentrySetup};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../shared/core.cjs.js"),t=require("../shared/sentry/shared-vue.cjs.js"),r=require("../shared/sentry/shared-base.cjs.js");exports.getSentryViteConfig=e.getSentryViteConfig,exports.browserTracingIntegration=t.browserTracingIntegration,exports.breadcrumbsIntegration=r.breadcrumbsIntegration,exports.captureConsoleIntegration=r.captureConsoleIntegration,exports.contextLinesIntegration=r.contextLinesIntegration,exports.extraErrorDataIntegration=r.extraErrorDataIntegration,exports.feedbackIntegration=r.feedbackSyncIntegration,exports.httpClientIntegration=r.httpClientIntegration,exports.replayIntegration=r.replayIntegration,exports.reportingObserverIntegration=r.reportingObserverIntegration,exports.toVue3SentrySetup=function(n){const{dsn:i,enabled:o=!0,app:a,router:s}=n;if(!e.isValidDsn(i))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),e.createUninitializedReturn();if(!o)return e.createUninitializedReturn();const g=s?[t.browserTracingIntegration({router:s})]:[],p=e.buildIntegrations(n,g,{browserTracingIntegration:e=>t.browserTracingIntegration(e),replayIntegration:e=>r.replayIntegration(e),breadcrumbsIntegration:e=>r.breadcrumbsIntegration(e)}),{app:c,router:u,...I}=e.mergeConfig(n);return t.init({...I,app:a,integrations:p}),{isInitialized:!0,captureException:e=>r.captureException(e),captureMessage:e=>r.captureMessage(e),setUser:e=>r.setUser(e)}};
1
+ "use strict";var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,i=(r,t,n)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../shared/core.cjs.js"),p=require("../shared/sentry/shared-vue.cjs.js"),g=require("../shared/sentry/shared-base.cjs.js");exports.getSentryViteConfig=s.getSentryViteConfig,exports.browserTracingIntegration=p.browserTracingIntegration,exports.breadcrumbsIntegration=g.breadcrumbsIntegration,exports.captureConsoleIntegration=g.captureConsoleIntegration,exports.contextLinesIntegration=g.contextLinesIntegration,exports.extraErrorDataIntegration=g.extraErrorDataIntegration,exports.feedbackIntegration=g.feedbackSyncIntegration,exports.httpClientIntegration=g.httpClientIntegration,exports.replayIntegration=g.replayIntegration,exports.reportingObserverIntegration=g.reportingObserverIntegration,exports.toVue3SentrySetup=function(e){const{dsn:c,enabled:u=!0,app:l,router:b}=e;if(!s.isValidDsn(c))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),s.createUninitializedReturn();if(!u)return s.createUninitializedReturn();const I=b?[p.browserTracingIntegration({router:b})]:[],d=s.buildIntegrations(e,I,{browserTracingIntegration:e=>p.browserTracingIntegration(e),replayIntegration:e=>g.replayIntegration(e),breadcrumbsIntegration:e=>g.breadcrumbsIntegration(e)}),f=s.mergeConfig(e),{app:x,router:y}=f,O=((e,r)=>{var t={};for(var i in e)o.call(e,i)&&r.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&n)for(var i of n(e))r.indexOf(i)<0&&a.call(e,i)&&(t[i]=e[i]);return t})(f,["app","router"]);var j;return p.init((j=((e,r)=>{for(var t in r||(r={}))o.call(r,t)&&i(e,t,r[t]);if(n)for(var t of n(r))a.call(r,t)&&i(e,t,r[t]);return e})({},O),r(j,t({app:l,integrations:d})))),{isInitialized:!0,captureException:e=>g.captureException(e),captureMessage:e=>g.captureMessage(e),setUser:e=>g.setUser(e)}};
@@ -1 +1 @@
1
- import{i as e,c as r,b as t,m as s}from"../shared/core.es.js";import{g as a}from"../shared/core.es.js";import{b as n,i as o}from"../shared/sentry/shared-vue.es.js";import{r as i,u as p,c,v as g,w as d}from"../shared/sentry/shared-base.es.js";import{z as u,A as m,B as f,x as b,y as I,C as h}from"../shared/sentry/shared-base.es.js";function l(a){const{dsn:u,enabled:m=!0,app:f,router:b}=a;if(!e(u))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),r();if(!m)return r();const I=b?[n({router:b})]:[],h=t(a,I,{browserTracingIntegration:e=>n(e),replayIntegration:e=>d(e),breadcrumbsIntegration:e=>g(e)}),{app:l,router:y,...j}=s(a);return o({...j,app:f,integrations:h}),{isInitialized:!0,captureException:e=>c(e),captureMessage:e=>p(e),setUser:e=>i(e)}}export{g as breadcrumbsIntegration,n as browserTracingIntegration,u as captureConsoleIntegration,m as contextLinesIntegration,f as extraErrorDataIntegration,b as feedbackIntegration,a as getSentryViteConfig,I as httpClientIntegration,d as replayIntegration,h as reportingObserverIntegration,l as toVue3SentrySetup};
1
+ var r=Object.defineProperty,e=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,o=(e,t,a)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;import{i,c as p,b as c,m as f}from"../shared/core.es.js";import{g as l}from"../shared/core.es.js";import{b,i as u}from"../shared/sentry/shared-vue.es.js";import{r as d,u as g,c as m,v as y,w as v}from"../shared/sentry/shared-base.es.js";import{z as O,A as j,B as I,x as h,y as w,C as x}from"../shared/sentry/shared-base.es.js";function P(r){const{dsn:l,enabled:O=!0,app:j,router:I}=r;if(!i(l))return console.warn("[xn-fe-tools] Sentry DSN is not provided, skipping initialization"),p();if(!O)return p();const h=I?[b({router:I})]:[],w=c(r,h,{browserTracingIntegration:r=>b(r),replayIntegration:r=>v(r),breadcrumbsIntegration:r=>y(r)}),x=f(r),{app:P,router:S}=x,C=((r,e)=>{var t={};for(var o in r)n.call(r,o)&&e.indexOf(o)<0&&(t[o]=r[o]);if(null!=r&&a)for(var o of a(r))e.indexOf(o)<0&&s.call(r,o)&&(t[o]=r[o]);return t})(x,["app","router"]);var D;return u((D=((r,e)=>{for(var t in e||(e={}))n.call(e,t)&&o(r,t,e[t]);if(a)for(var t of a(e))s.call(e,t)&&o(r,t,e[t]);return r})({},C),e(D,t({app:j,integrations:w})))),{isInitialized:!0,captureException:r=>m(r),captureMessage:r=>g(r),setUser:r=>d(r)}}export{y as breadcrumbsIntegration,b as browserTracingIntegration,O as captureConsoleIntegration,j as contextLinesIntegration,I as extraErrorDataIntegration,h as feedbackIntegration,l as getSentryViteConfig,w as httpClientIntegration,v as replayIntegration,x as reportingObserverIntegration,P as toVue3SentrySetup};
@@ -1 +1 @@
1
- "use strict";const e="production",r=.1,t=.1,n=1,a=!0,s=!0;exports.buildIntegrations=function(e,r,t){const n=e.enableTracing??a,o=e.enableReplay??s,i=Array.isArray(e.integrations)?e.integrations:[],p=void 0!==e.enableTracing,c=void 0!==e.enableReplay,u=void 0!==e.breadcrumbs,l=i.some(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name),b=i.some(e=>e&&"object"==typeof e&&"Replay"===e.name),m=i.some(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name),g=[];p?n&&(r.length>0?g.push(...r):g.push(t.browserTracingIntegration())):l?g.push(...i.filter(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name)):r.length>0?g.push(...r):g.push(t.browserTracingIntegration()),c?o&&g.push(t.replayIntegration()):b?g.push(...i.filter(e=>e&&"object"==typeof e&&"Replay"===e.name)):g.push(t.replayIntegration()),u?g.push(t.breadcrumbsIntegration(e.breadcrumbs)):m&&g.push(...i.filter(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name));const f=new Set(["BrowserTracing","Replay","Breadcrumbs"]),y=i.filter(e=>!(e&&"object"==typeof e&&f.has(e.name??"")));return g.push(...y),g},exports.createUninitializedReturn=function(){return{isInitialized:!1,captureException:()=>{},captureMessage:()=>{},setUser:()=>{}}},exports.getSentryViteConfig=function(e){const{sourcemaps:r,...t}=e;return{...t,sourcemaps:{filesToDeleteAfterUpload:["./dist/**/*.map"],...r}}},exports.isValidDsn=function(e){return"string"==typeof e&&e.trim().length>0},exports.mergeConfig=function(a){const{enableTracing:s,enableReplay:o,breadcrumbs:i,...p}=a;return{environment:e,tracesSampleRate:r,replaysSessionSampleRate:t,replaysOnErrorSampleRate:n,...p}};
1
+ "use strict";var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(r,t,n)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,i=(e,r)=>{for(var t in r||(r={}))a.call(r,t)&&s(e,t,r[t]);if(n)for(var t of n(r))o.call(r,t)&&s(e,t,r[t]);return e},p=(e,r)=>{var t={};for(var s in e)a.call(e,s)&&r.indexOf(s)<0&&(t[s]=e[s]);if(null!=e&&n)for(var s of n(e))r.indexOf(s)<0&&o.call(e,s)&&(t[s]=e[s]);return t};const l="production",c=.1,u=.1,b=1,f=!0,m=!0;exports.buildIntegrations=function(e,r,t){var n,a;const o=null!=(n=e.enableTracing)?n:f,s=null!=(a=e.enableReplay)?a:m,i=Array.isArray(e.integrations)?e.integrations:[],p=void 0!==e.enableTracing,l=void 0!==e.enableReplay,c=void 0!==e.breadcrumbs,u=i.some(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name),b=i.some(e=>e&&"object"==typeof e&&"Replay"===e.name),y=i.some(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name),g=[];p?o&&(r.length>0?g.push(...r):g.push(t.browserTracingIntegration())):u?g.push(...i.filter(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name)):r.length>0?g.push(...r):g.push(t.browserTracingIntegration()),l?s&&g.push(t.replayIntegration()):b?g.push(...i.filter(e=>e&&"object"==typeof e&&"Replay"===e.name)):g.push(t.replayIntegration()),c?g.push(t.breadcrumbsIntegration(e.breadcrumbs)):y&&g.push(...i.filter(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name));const d=new Set(["BrowserTracing","Replay","Breadcrumbs"]),h=i.filter(e=>{var r;return!(e&&"object"==typeof e&&d.has(null!=(r=e.name)?r:""))});return g.push(...h),g},exports.createUninitializedReturn=function(){return{isInitialized:!1,captureException:()=>{},captureMessage:()=>{},setUser:()=>{}}},exports.getSentryViteConfig=function(e){const n=e,{sourcemaps:a}=n,o=p(n,["sourcemaps"]);return s=i({},o),l={sourcemaps:i({filesToDeleteAfterUpload:["./dist/**/*.map"]},a)},r(s,t(l));var s,l},exports.isValidDsn=function(e){return"string"==typeof e&&e.trim().length>0},exports.mergeConfig=function(e){const r=e,{enableTracing:t,enableReplay:n,breadcrumbs:a}=r,o=p(r,["enableTracing","enableReplay","breadcrumbs"]);return i({environment:l,tracesSampleRate:c,replaysSessionSampleRate:u,replaysOnErrorSampleRate:b},o)};
@@ -1 +1 @@
1
- const e="production",r=.1,t=.1,a=1,n=!0,s=!0;function o(e){return"string"==typeof e&&e.trim().length>0}function i(){return{isInitialized:!1,captureException:()=>{},captureMessage:()=>{},setUser:()=>{}}}function p(e,r,t){const a=e.enableTracing??n,o=e.enableReplay??s,i=Array.isArray(e.integrations)?e.integrations:[],p=void 0!==e.enableTracing,c=void 0!==e.enableReplay,u=void 0!==e.breadcrumbs,l=i.some(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name),b=i.some(e=>e&&"object"==typeof e&&"Replay"===e.name),m=i.some(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name),g=[];p?a&&(r.length>0?g.push(...r):g.push(t.browserTracingIntegration())):l?g.push(...i.filter(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name)):r.length>0?g.push(...r):g.push(t.browserTracingIntegration()),c?o&&g.push(t.replayIntegration()):b?g.push(...i.filter(e=>e&&"object"==typeof e&&"Replay"===e.name)):g.push(t.replayIntegration()),u?g.push(t.breadcrumbsIntegration(e.breadcrumbs)):m&&g.push(...i.filter(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name));const y=/* @__PURE__ */new Set(["BrowserTracing","Replay","Breadcrumbs"]),f=i.filter(e=>!(e&&"object"==typeof e&&y.has(e.name??"")));return g.push(...f),g}function c(n){const{enableTracing:s,enableReplay:o,breadcrumbs:i,...p}=n;return{environment:e,tracesSampleRate:r,replaysSessionSampleRate:t,replaysOnErrorSampleRate:a,...p}}function u(e){const{sourcemaps:r,...t}=e;return{...t,sourcemaps:{filesToDeleteAfterUpload:["./dist/**/*.map"],...r}}}export{p as b,i as c,u as g,o as i,c as m};
1
+ var e=Object.defineProperty,r=Object.defineProperties,a=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(r,a,t)=>a in r?e(r,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[a]=t,i=(e,r)=>{for(var a in r||(r={}))n.call(r,a)&&s(e,a,r[a]);if(t)for(var a of t(r))o.call(r,a)&&s(e,a,r[a]);return e},c=(e,r)=>{var a={};for(var s in e)n.call(e,s)&&r.indexOf(s)<0&&(a[s]=e[s]);if(null!=e&&t)for(var s of t(e))r.indexOf(s)<0&&o.call(e,s)&&(a[s]=e[s]);return a};const l="production",p=.1,u=.1,b=1,f=!0,m=!0;function y(e){return"string"==typeof e&&e.trim().length>0}function g(){return{isInitialized:!1,captureException:()=>{},captureMessage:()=>{},setUser:()=>{}}}function d(e,r,a){var t,n;const o=null!=(t=e.enableTracing)?t:f,s=null!=(n=e.enableReplay)?n:m,i=Array.isArray(e.integrations)?e.integrations:[],c=void 0!==e.enableTracing,l=void 0!==e.enableReplay,p=void 0!==e.breadcrumbs,u=i.some(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name),b=i.some(e=>e&&"object"==typeof e&&"Replay"===e.name),y=i.some(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name),g=[];c?o&&(r.length>0?g.push(...r):g.push(a.browserTracingIntegration())):u?g.push(...i.filter(e=>e&&"object"==typeof e&&"BrowserTracing"===e.name)):r.length>0?g.push(...r):g.push(a.browserTracingIntegration()),l?s&&g.push(a.replayIntegration()):b?g.push(...i.filter(e=>e&&"object"==typeof e&&"Replay"===e.name)):g.push(a.replayIntegration()),p?g.push(a.breadcrumbsIntegration(e.breadcrumbs)):y&&g.push(...i.filter(e=>e&&"object"==typeof e&&"Breadcrumbs"===e.name));const d=/* @__PURE__ */new Set(["BrowserTracing","Replay","Breadcrumbs"]),h=i.filter(e=>{var r;return!(e&&"object"==typeof e&&d.has(null!=(r=e.name)?r:""))});return g.push(...h),g}function h(e){const r=e,{enableTracing:a,enableReplay:t,breadcrumbs:n}=r,o=c(r,["enableTracing","enableReplay","breadcrumbs"]);return i({environment:l,tracesSampleRate:p,replaysSessionSampleRate:u,replaysOnErrorSampleRate:b},o)}function v(e){const t=e,{sourcemaps:n}=t,o=c(t,["sourcemaps"]);return s=i({},o),l={sourcemaps:i({filesToDeleteAfterUpload:["./dist/**/*.map"]},n)},r(s,a(l));var s,l}export{d as b,g as c,v as g,y as i,h as m};