@vef-framework-react/core 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/http/body-encoding.cjs +1 -1
- package/dist/cjs/http/client.cjs +1 -1
- package/dist/es/api/client.js +1 -1
- package/dist/es/api/constants.js +1 -1
- package/dist/es/api/helpers.js +1 -1
- package/dist/es/api/index.js +1 -1
- package/dist/es/auth/helpers.js +1 -1
- package/dist/es/auth/index.js +1 -1
- package/dist/es/context/api-client.js +1 -1
- package/dist/es/context/app.js +1 -1
- package/dist/es/context/context-selector.js +1 -1
- package/dist/es/context/disabled.js +1 -1
- package/dist/es/context/index.js +1 -1
- package/dist/es/dnd/index.js +1 -1
- package/dist/es/http/body-encoding.js +58 -11
- package/dist/es/http/client.js +120 -72
- package/dist/es/http/constants.js +1 -1
- package/dist/es/http/errors.js +1 -1
- package/dist/es/http/helpers.js +1 -1
- package/dist/es/http/index.js +1 -1
- package/dist/es/immer/index.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/motion/features.js +1 -1
- package/dist/es/motion/index.js +1 -1
- package/dist/es/motion/motion-provider.js +1 -1
- package/dist/es/push/client.js +1 -1
- package/dist/es/push/helpers.js +1 -1
- package/dist/es/push/index.js +1 -1
- package/dist/es/push/types.js +1 -1
- package/dist/es/query/constants.js +1 -1
- package/dist/es/query/helpers.js +1 -1
- package/dist/es/query/hooks.js +1 -1
- package/dist/es/query/index.js +1 -1
- package/dist/es/sse/client.js +1 -1
- package/dist/es/sse/helpers.js +1 -1
- package/dist/es/sse/index.js +1 -1
- package/dist/es/sse/stream-machine.js +1 -1
- package/dist/es/state/index.js +1 -1
- package/dist/es/state-machine/index.js +1 -1
- package/dist/es/storage/errors.js +1 -1
- package/dist/es/storage/index.js +1 -1
- package/dist/es/storage/protocol.js +1 -1
- package/dist/es/storage/resumable/fingerprint.js +1 -1
- package/dist/es/storage/resumable/index.js +1 -1
- package/dist/es/storage/resumable/persistence.js +1 -1
- package/dist/es/storage/resumable/plan.js +1 -1
- package/dist/es/storage/types.js +1 -1
- package/dist/es/storage/uploader-machine.js +1 -1
- package/dist/es/storage/uploader.js +1 -1
- package/dist/es/store/bound.js +1 -1
- package/dist/es/store/index.js +1 -1
- package/dist/es/store/unbound.js +1 -1
- package/dist/es/store/use-deep.js +1 -1
- package/dist/types/http/body-encoding.d.ts +12 -1
- package/dist/types/http/client.d.ts +6 -0
- package/dist/types/http/constants.d.ts +2 -2
- package/dist/types/http/types.d.ts +22 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=32768;function
|
|
1
|
+
var e=32768,t=/^(?:[A-Z\d+/]{4})*(?:[A-Z\d+/]{2}==|[A-Z\d+/]{3}=)?$/i;function n(t){if(`toBase64`in t&&typeof t.toBase64==`function`)return t.toBase64();let n=``;for(let r=0;r<t.length;r+=e)n+=String.fromCodePoint(...t.subarray(r,r+e));return btoa(n)}function r(e,n){if(e.length===0||e.length%4!=0||!t.test(e))throw TypeError(`${n} must be standard padded base64`);let r;try{r=atob(e)}catch{throw TypeError(`${n} must be standard padded base64`)}let i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.codePointAt(e);return i}function i(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e),n.set(new Uint8Array(t),e.byteLength),n}var a=class{#e;#t;encoding;constructor(e){if(e.encoding!==`aes-gcm+base64`)throw TypeError(`Unsupported protected body encoding: ${String(e.encoding)}`);let t=r(e.key,`Protected body key`);if(t.byteLength!==16&&t.byteLength!==24&&t.byteLength!==32)throw TypeError(`Protected body AES-GCM key must contain 16, 24, or 32 bytes`);if(!globalThis.crypto?.subtle)throw TypeError(`Protected body encoding requires the Web Crypto API`);this.encoding=e.encoding,this.#e=t}getKey(){return this.#t??=crypto.subtle.importKey(`raw`,this.#e,`AES-GCM`,!1,[`encrypt`,`decrypt`]),this.#t}async encode(e){let t=crypto.getRandomValues(new Uint8Array(12));return n(i(t,await crypto.subtle.encrypt({name:`AES-GCM`,iv:t},await this.getKey(),new TextEncoder().encode(e))))}async decode(e){let t=r(e.trim(),`Protected body`);if(t.byteLength<28)throw TypeError(`Protected body is too short`);let n=t.slice(0,12),i=t.slice(12),a=await crypto.subtle.decrypt({name:`AES-GCM`,iv:n},await this.getKey(),i);return new TextDecoder(`utf-8`,{fatal:!0}).decode(a)}};function o(){return typeof CompressionStream<`u`}async function s(e){let t=new CompressionStream(`gzip`),n=t.writable.getWriter(),r=n.write(e).then(()=>n.close()),[i]=await Promise.all([new Response(t.readable).arrayBuffer(),r]);return new Uint8Array(i)}async function c(e,t){let r=new TextEncoder().encode(e);return t===`gzip+base64`&&o()?{body:n(await s(r)),encoding:`gzip+base64`}:{body:n(r),encoding:`base64`}}exports.ProtectedBodyCodec=a,exports.encodeRequestBody=c;
|
package/dist/cjs/http/client.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("../_internal/_rolldown/runtime.cjs"),t=require("./body-encoding.cjs"),n=require("./constants.cjs"),r=require("./errors.cjs");let i=require("@vef-framework-react/shared"),a=require("axios");a=e.__toESM(a,1);var o=`__vefResponseMode`,s=[e=>e],c=1024*1024,l=`download`;function u(e){return Object.prototype.toString.call(e)===`[object ArrayBuffer]`}function d(e){return!(0,i.isNullish)(e)&&!(e instanceof FormData)&&!(e instanceof Blob)&&!u(e)&&!ArrayBuffer.isView(e)}function f(e){return typeof e.addEventListener==`function`&&typeof e.removeEventListener==`function`}var p=class{#e;#t;#n;#r=new Set;constructor(e){this.#t=e;let{baseUrl:t,timeout:r=n.DEFAULT_TIMEOUT}=e;this.#e=a.default.create({baseURL:t,allowAbsoluteUrls:!0,timeout:r,headers:{"Content-Type":`application/json`},paramsSerializer:e=>(0,i.encodeQueryString)(e,{arrayFormat:`repeat`,skipNulls:!0,charset:`utf-8`}),responseType:`json`,responseEncoding:`utf-8`,validateStatus:e=>e>=200&&e<300,withCredentials:!1,timeoutErrorMessage:`请求超时`}),this.initInterceptors()}initInterceptors(){this.#e.interceptors.request.use(this.handleRequest.bind(this),this.handleRequestError.bind(this)),this.#e.interceptors.response.use(this.handleResponse.bind(this),this.handleResponseError.bind(this))}matchesCode(e,t){return(0,i.isArray)(t)?t.includes(e):e===t}async handleRequest(e){let t=e.headers[n.SKIP_AUTH_HEADER]===`1`,r=this.#n?.promise;if(r&&!t&&!await this.waitForTokenRefresh(r,e))throw Error(`登录已过期, 请重新登录`);return t?delete e.headers[n.SKIP_AUTH_HEADER]:await this.injectAccessToken(e),this.replacePathParams(e),e}handleRequestError(e){let{showErrorMessage:t}=this.#t,n=`发起请求失败: ${(e instanceof Error?e.message:String(e))||`未知错误`}`;return t?t(n):console.error(`[HttpClient] ${n}`),Promise.reject(e)}handleResponse(e){if(this.getResponseMode(e.config)===`raw`)return e;if(!this.isApiResult(e.data))throw TypeError(`Invalid API response envelope`);return this.assertBusinessSuccess(e.data,e.config),e}async handleResponseError(e){if(e instanceof a.CanceledError){if(e.response){let{method:t,url:n}=e.response.config;console.warn(`[HttpClient] [${t}: ${n}] 被取消`)}throw e}let{response:t}=e;if(!t)throw this.logError(`请求失败: ${e.message||`未知错误`}`),e;let{status:n,config:r,data:i}=t,o=await this.readApiResult(i),s=o?.code,c=o?.message??e.message??`未知错误`,l=`[${r.method}: ${r.url}]`;switch(n){case 400:this.logWarning(c,`${l} 参数错误: ${c}`);break;case 401:{let t=await this.handleUnauthorized(e,s);if(t)return t;break}case 403:this.#t.showWarningMessage?.(`${c}, 请联系管理员为您开通`),console.warn(`[HttpClient] ${l} 访问被拒绝: ${c}`),await this.#t.onAccessDenied?.();break;default:this.logError(c,`${l} 返回错误: ${c}`)}throw e}async handleUnauthorized(e,t){let{tokenExpiredCode:n=[]}=this.#t;if(t===void 0||!this.matchesCode(t,n)){await this.#t.onUnauthenticated?.();return}if(this.#n)throw e;let{cycle:r}=this.tryRefreshToken(async()=>{this.logInfo(`登录已过期, 请重新登录`),await this.#t.onUnauthenticated?.()});if(await this.waitForTokenRefresh(r.promise,e.response.config))return this.retryRequest(e.response.config);await r.failureHandled}logInfo(e){this.#t.showInfoMessage?this.#t.showInfoMessage(e):console.info(`[HttpClient] ${e}`)}logWarning(e,t){this.#t.showWarningMessage?this.#t.showWarningMessage(e):console.warn(`[HttpClient] ${t??e}`)}logError(e,t){this.#t.showErrorMessage?this.#t.showErrorMessage(e):console.error(`[HttpClient] ${t??e}`)}async injectAccessToken(e){let{getAuthTokens:t}=this.#t;if(!t)return;let n=await t();n?.accessToken&&(e.headers.Authorization=`Bearer ${n.accessToken}`)}replacePathParams(e){let{url:t,params:r={}}=e;!t||!n.PATH_PARAM_REGEX.test(t)||(n.PATH_PARAM_REGEX.lastIndex=0,e.url=t.replaceAll(n.PATH_PARAM_REGEX,(e,n)=>{if(!Object.hasOwn(r,n))return console.warn(`[HttpClient] 接口: ${t} 路径参数 ${n} 未在查询参数中定义, 请检查`),`unknown`;let a=r[n];return(0,i.isNullish)(a)?(console.warn(`[HttpClient] 接口: ${t} 路径参数 ${n} 在查询参数中为空, 请检查`),`unknown`):String(a)}))}tryRefreshToken(e){if(this.#n)return{cycle:this.#n,owner:!1};let{getAuthTokens:t,refreshToken:n,setAuthTokens:r}=this.#t;if(!t||!n||!r)return{cycle:this.createRefreshCycle(Promise.resolve(!1),e,!1),owner:!0};let i=Promise.withResolvers(),a=i.promise,o=this.createRefreshCycle(a,e,!0);return this.performTokenRefresh(t,n,r).then(i.resolve,i.reject),{cycle:o,owner:!0}}createRefreshCycle(e,t,n){let r=Promise.withResolvers(),i={failureHandled:r.promise,promise:e};return n&&(this.#n=i),e.then(e=>{n&&this.finishTokenRefresh(i,e),(e?Promise.resolve():this.handleRefreshFailure(t)).then(r.resolve,r.reject)},e=>{n&&this.finishTokenRefresh(i,!1),this.handleRefreshFailure(t).then(()=>r.reject(e),r.reject)}),r.promise.catch(()=>void 0),i}async handleRefreshFailure(e){await e?.()}async performTokenRefresh(e,t,n){try{let r=await e();if(!r)return!1;let i=await t(r);return await n(Object.freeze(i)),!0}catch(e){return console.error(`[HttpClient] 刷新令牌失败: ${e}`),!1}}finishTokenRefresh(e,t){if(this.#n===e){for(let e of this.#r)e(t);this.#r.clear(),this.#n=void 0}}waitForTokenRefresh(e,t){if(this.#n?.promise!==e)return e;let{signal:n}=t;return n?.aborted?Promise.reject(new a.CanceledError(void 0,t)):new Promise((e,r)=>{let i=n&&f(n)?n:void 0,o,s=()=>{let e=o;e&&(o=void 0,this.#r.delete(e),i?.removeEventListener(`abort`,s),r(new a.CanceledError(void 0,t)))};o=t=>{let n=o;n&&(o=void 0,this.#r.delete(n),i?.removeEventListener(`abort`,s),e(t))},this.#r.add(o),i?.addEventListener(`abort`,s,{once:!0}),n?.aborted&&s()})}async retryRequest(e){let t={...e,[o]:this.getResponseMode(e)};return await this.injectAccessToken(t),this.#e(t)}getResponseMode(e){return Reflect.get(e,o)===`raw`?`raw`:`envelope`}isApiResult(e){return typeof e==`object`&&!!e&&(0,i.isNumber)(Reflect.get(e,`code`))&&(0,i.isString)(Reflect.get(e,`message`))&&Object.hasOwn(e,`data`)}assertBusinessSuccess(e,t){let{showWarningMessage:n,okCode:i=0}=this.#t,{code:a,message:o,data:s}=e;if(!this.matchesCode(a,i))throw n?n(o):console.warn(`[HttpClient] [${t.method}: ${t.url}] 返回错误: ${o}`),new r.BusinessError(a,o,s)}async readApiResult(e){if(this.isApiResult(e))return e;if((0,i.isString)(e)){if(e.length>c||new Blob([e]).size>c)return;try{let t=JSON.parse(e);return this.isApiResult(t)?t:void 0}catch{return}}if((u(e)||ArrayBuffer.isView(e))&&e.byteLength>c)return;let t;try{t=this.toBlob(e)}catch{return}if(!(t.size>c))try{let e=JSON.parse(await t.text());return this.isApiResult(e)?e:void 0}catch{}}toBlob(e,t){if(e instanceof Blob)return e;let n=(0,i.isString)(t)?{type:t}:void 0;if(u(e))return new Blob([e],n);if(ArrayBuffer.isView(e)){if(u(e.buffer))return new Blob([new Uint8Array(e.buffer,e.byteOffset,e.byteLength)],n);let t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),new Blob([t],n)}throw TypeError(`Invalid file response body`)}getResponseFilename(e){if(!(0,i.isString)(e))return;let t=e.split(`;`).find(e=>{let t=e.indexOf(`=`);return t!==-1&&e.slice(0,t).trim().toLowerCase()===`filename*`}),r=t?.slice(t.indexOf(`=`)+1).trim(),a=r?.indexOf(`'`)??-1,o=a>=0?r?.indexOf(`'`,a+1)??-1:-1,s=o>=0?r?.slice(o+1):void 0,c=a>=0?r?.slice(0,a).trim().toLowerCase():void 0;if(s&&(!c||c===`utf-8`))try{return decodeURIComponent(s)}catch{}let l=n.CONTENT_DISPOSITION_FILENAME_REGEX.exec(e),u=l?.groups?.name?.trim();return u?l?.groups?.quote?u.slice(1,-1):u:void 0}async encodeRequestData(e,r,a){let o=r??this.#t.defaultBodyEncoding??`none`;if(o===`none`||!d(e))return{data:e,options:a};let c=(0,i.isString)(e)?e:JSON.stringify(e),l=await t.encodeRequestBody(c,o);return{data:l.body,options:{...a,transformRequest:s,headers:{...a.headers,[n.BODY_ENCODING_HEADER]:l.encoding}}}}async ensureTokenRefreshed(e=!0){let t=e?()=>this.#t.onUnauthenticated?.():void 0,{cycle:n,owner:r}=this.tryRefreshToken(t),i=await n.promise;return r&&await n.failureHandled,i}async get(e,t){return(await this.#e.get(e,t)).data}async post(e,t){let{data:n,bodyEncoding:r,...i}=t??{},a=await this.encodeRequestData(n,r,i);return(await this.#e.post(e,a.data,a.options)).data}async put(e,t){let{data:n,bodyEncoding:r,...i}=t??{},a=await this.encodeRequestData(n,r,i);return(await this.#e.put(e,a.data,a.options)).data}async delete(e,t){return(await this.#e.delete(e,t)).data}async upload(e,t){let{data:n,onProgress:r,...a}=t??{};return(await this.#e.postForm(e,n,{...a,onUploadProgress:(0,i.isFunction)(r)?r:void 0})).data}async requestFile(e,t){let{method:n=`get`,data:r,onProgress:a,...s}=t??{},c={...s,[o]:`raw`,responseType:`arraybuffer`,responseEncoding:`binary`,onDownloadProgress:(0,i.isFunction)(a)?a:void 0},{config:l,data:u,headers:d}=n===`post`?await this.#e.post(e,r,c):await this.#e.get(e,c),f=this.toBlob(u,d[`content-type`]),p=await this.readApiResult(f);return p&&this.assertBusinessSuccess(p,l),{blob:f,filename:this.getResponseFilename(d[`content-disposition`])}}async download(e,t){let{filename:n,...r}=t??{},{blob:a,filename:o}=await this.requestFile(e,r),s=o??l,c=URL.createObjectURL(a);try{let e=document.createElement(`a`);e.href=c,e.download=(0,i.isFunction)(n)?n(s):n??s,e.click()}finally{setTimeout(()=>URL.revokeObjectURL(c),0)}}};exports.HttpClient=p;
|
|
1
|
+
const e=require("../_internal/_rolldown/runtime.cjs"),t=require("./body-encoding.cjs"),n=require("./constants.cjs"),r=require("./errors.cjs");let i=require("@vef-framework-react/shared"),a=require("axios");a=e.__toESM(a,1);var o=`__vefResponseMode`,s=[e=>e],c=1024*1024,l=`download`;function u(e){return Object.prototype.toString.call(e)===`[object ArrayBuffer]`}function d(e,t){let n=Reflect.get(e,`get`);return(0,i.isFunction)(n)?Reflect.apply(n,e,[t]):Reflect.get(e,t)??Reflect.get(e,t.toLowerCase())}function f(e){return(0,i.isString)(e)?Promise.resolve(e):e instanceof Blob?e.text():u(e)||ArrayBuffer.isView(e)?Promise.resolve(new TextDecoder().decode(e)):Promise.reject(TypeError(`Invalid protected response body`))}function p(e){return!(0,i.isNullish)(e)&&!(e instanceof FormData)&&!(e instanceof Blob)&&!u(e)&&!ArrayBuffer.isView(e)}function m(e){return typeof e.addEventListener==`function`&&typeof e.removeEventListener==`function`}var h=class{#e;#t;#n;#r;#i=new Set;constructor(e){this.#t=e,this.#n=e.protectedBodyEncoding?new t.ProtectedBodyCodec(e.protectedBodyEncoding):void 0;let{baseUrl:r,timeout:o=n.DEFAULT_TIMEOUT}=e;this.#e=a.default.create({baseURL:r,allowAbsoluteUrls:!0,timeout:o,headers:{"Content-Type":`application/json`},paramsSerializer:e=>(0,i.encodeQueryString)(e,{arrayFormat:`repeat`,skipNulls:!0,charset:`utf-8`}),responseType:`json`,responseEncoding:`utf-8`,validateStatus:e=>e>=200&&e<300,withCredentials:!1,timeoutErrorMessage:`请求超时`}),this.initInterceptors()}initInterceptors(){this.#e.interceptors.request.use(this.handleRequest.bind(this),this.handleRequestError.bind(this)),this.#e.interceptors.response.use(this.handleResponse.bind(this),this.handleResponseError.bind(this))}matchesCode(e,t){return(0,i.isArray)(t)?t.includes(e):e===t}async handleRequest(e){let t=e.headers[n.SKIP_AUTH_HEADER]===`1`,r=this.#r?.promise;if(r&&!t&&!await this.waitForTokenRefresh(r,e))throw Error(`登录已过期, 请重新登录`);return t?delete e.headers[n.SKIP_AUTH_HEADER]:await this.injectAccessToken(e),this.replacePathParams(e),e}handleRequestError(e){let{showErrorMessage:t}=this.#t,n=`发起请求失败: ${(e instanceof Error?e.message:String(e))||`未知错误`}`;return t?t(n):console.error(`[HttpClient] ${n}`),Promise.reject(e)}async handleResponse(e){if((this.#n||d(e.headers,`X-Body-Encoding`))&&await this.decodeProtectedResponse(e),this.getResponseMode(e.config)===`raw`)return e;if(!this.isApiResult(e.data))throw TypeError(`Invalid API response envelope`);return this.assertBusinessSuccess(e.data,e.config),e}async handleResponseError(e){if(e instanceof a.CanceledError){if(e.response){let{method:t,url:n}=e.response.config;console.warn(`[HttpClient] [${t}: ${n}] 被取消`)}throw e}let{response:t}=e;if(!t)throw this.logError(`请求失败: ${e.message||`未知错误`}`),e;(this.#n||d(t.headers,`X-Body-Encoding`))&&await this.decodeProtectedResponse(t);let{status:n,config:r,data:i}=t,o=await this.readApiResult(i),s=o?.code,c=o?.message??e.message??`未知错误`,l=`[${r.method}: ${r.url}]`;switch(n){case 400:this.logWarning(c,`${l} 参数错误: ${c}`);break;case 401:{let t=await this.handleUnauthorized(e,s);if(t)return t;break}case 403:this.#t.showWarningMessage?.(`${c}, 请联系管理员为您开通`),console.warn(`[HttpClient] ${l} 访问被拒绝: ${c}`),await this.#t.onAccessDenied?.();break;default:this.logError(c,`${l} 返回错误: ${c}`)}throw e}async handleUnauthorized(e,t){let{tokenExpiredCode:n=[]}=this.#t;if(t===void 0||!this.matchesCode(t,n)){await this.#t.onUnauthenticated?.();return}if(this.#r)throw e;let{cycle:r}=this.tryRefreshToken(async()=>{this.logInfo(`登录已过期, 请重新登录`),await this.#t.onUnauthenticated?.()});if(await this.waitForTokenRefresh(r.promise,e.response.config))return this.retryRequest(e.response.config);await r.failureHandled}logInfo(e){this.#t.showInfoMessage?this.#t.showInfoMessage(e):console.info(`[HttpClient] ${e}`)}logWarning(e,t){this.#t.showWarningMessage?this.#t.showWarningMessage(e):console.warn(`[HttpClient] ${t??e}`)}logError(e,t){this.#t.showErrorMessage?this.#t.showErrorMessage(e):console.error(`[HttpClient] ${t??e}`)}async injectAccessToken(e){let{getAuthTokens:t}=this.#t;if(!t)return;let n=await t();n?.accessToken&&(e.headers.Authorization=`Bearer ${n.accessToken}`)}replacePathParams(e){let{url:t,params:r={}}=e;!t||!n.PATH_PARAM_REGEX.test(t)||(n.PATH_PARAM_REGEX.lastIndex=0,e.url=t.replaceAll(n.PATH_PARAM_REGEX,(e,n)=>{if(!Object.hasOwn(r,n))return console.warn(`[HttpClient] 接口: ${t} 路径参数 ${n} 未在查询参数中定义, 请检查`),`unknown`;let a=r[n];return(0,i.isNullish)(a)?(console.warn(`[HttpClient] 接口: ${t} 路径参数 ${n} 在查询参数中为空, 请检查`),`unknown`):String(a)}))}tryRefreshToken(e){if(this.#r)return{cycle:this.#r,owner:!1};let{getAuthTokens:t,refreshToken:n,setAuthTokens:r}=this.#t;if(!t||!n||!r)return{cycle:this.createRefreshCycle(Promise.resolve(!1),e,!1),owner:!0};let i=Promise.withResolvers(),a=i.promise,o=this.createRefreshCycle(a,e,!0);return this.performTokenRefresh(t,n,r).then(i.resolve,i.reject),{cycle:o,owner:!0}}createRefreshCycle(e,t,n){let r=Promise.withResolvers(),i={failureHandled:r.promise,promise:e};return n&&(this.#r=i),e.then(e=>{n&&this.finishTokenRefresh(i,e),(e?Promise.resolve():this.handleRefreshFailure(t)).then(r.resolve,r.reject)},e=>{n&&this.finishTokenRefresh(i,!1),this.handleRefreshFailure(t).then(()=>r.reject(e),r.reject)}),r.promise.catch(()=>void 0),i}async handleRefreshFailure(e){await e?.()}async performTokenRefresh(e,t,n){try{let r=await e();if(!r)return!1;let i=await t(r);return await n(Object.freeze(i)),!0}catch(e){return console.error(`[HttpClient] 刷新令牌失败: ${e}`),!1}}finishTokenRefresh(e,t){if(this.#r===e){for(let e of this.#i)e(t);this.#i.clear(),this.#r=void 0}}waitForTokenRefresh(e,t){if(this.#r?.promise!==e)return e;let{signal:n}=t;return n?.aborted?Promise.reject(new a.CanceledError(void 0,t)):new Promise((e,r)=>{let i=n&&m(n)?n:void 0,o,s=()=>{let e=o;e&&(o=void 0,this.#i.delete(e),i?.removeEventListener(`abort`,s),r(new a.CanceledError(void 0,t)))};o=t=>{let n=o;n&&(o=void 0,this.#i.delete(n),i?.removeEventListener(`abort`,s),e(t))},this.#i.add(o),i?.addEventListener(`abort`,s,{once:!0}),n?.aborted&&s()})}async retryRequest(e){let t={...e,[o]:this.getResponseMode(e)};return await this.injectAccessToken(t),this.#e(t)}getResponseMode(e){return Reflect.get(e,o)===`raw`?`raw`:`envelope`}async decodeProtectedResponse(e){let t=d(e.headers,n.BODY_ENCODING_HEADER),r=(0,i.isString)(t)?t.trim():``,a=this.getResponseMode(e.config);if(!r){let t=d(e.headers,`Content-Type`),r=(0,i.isString)(t)&&t.toLowerCase().startsWith(`application/json`);if(this.#n&&(a===`envelope`||r))throw TypeError(`Missing ${n.BODY_ENCODING_HEADER} on protected API response`);return}if(!this.#n)throw TypeError(`Cannot decode ${r} response without protectedBodyEncoding`);if(r!==this.#n.encoding)throw TypeError(`Unsupported protected response body encoding: ${r}`);let o=await this.#n.decode(await f(e.data));if(a===`raw`){e.data=new TextEncoder().encode(o).buffer;return}try{e.data=JSON.parse(o)}catch{throw TypeError(`Protected API response is not valid JSON`)}}isApiResult(e){return typeof e==`object`&&!!e&&(0,i.isNumber)(Reflect.get(e,`code`))&&(0,i.isString)(Reflect.get(e,`message`))&&Object.hasOwn(e,`data`)}assertBusinessSuccess(e,t){let{showWarningMessage:n,okCode:i=0}=this.#t,{code:a,message:o,data:s}=e;if(!this.matchesCode(a,i))throw n?n(o):console.warn(`[HttpClient] [${t.method}: ${t.url}] 返回错误: ${o}`),new r.BusinessError(a,o,s)}async readApiResult(e){if(this.isApiResult(e))return e;if((0,i.isString)(e)){if(e.length>c||new Blob([e]).size>c)return;try{let t=JSON.parse(e);return this.isApiResult(t)?t:void 0}catch{return}}if((u(e)||ArrayBuffer.isView(e))&&e.byteLength>c)return;let t;try{t=this.toBlob(e)}catch{return}if(!(t.size>c))try{let e=JSON.parse(await t.text());return this.isApiResult(e)?e:void 0}catch{}}toBlob(e,t){if(e instanceof Blob)return e;let n=(0,i.isString)(t)?{type:t}:void 0;if(u(e))return new Blob([e],n);if(ArrayBuffer.isView(e)){if(u(e.buffer))return new Blob([new Uint8Array(e.buffer,e.byteOffset,e.byteLength)],n);let t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),new Blob([t],n)}throw TypeError(`Invalid file response body`)}getResponseFilename(e){if(!(0,i.isString)(e))return;let t=e.split(`;`).find(e=>{let t=e.indexOf(`=`);return t!==-1&&e.slice(0,t).trim().toLowerCase()===`filename*`}),r=t?.slice(t.indexOf(`=`)+1).trim(),a=r?.indexOf(`'`)??-1,o=a>=0?r?.indexOf(`'`,a+1)??-1:-1,s=o>=0?r?.slice(o+1):void 0,c=a>=0?r?.slice(0,a).trim().toLowerCase():void 0;if(s&&(!c||c===`utf-8`))try{return decodeURIComponent(s)}catch{}let l=n.CONTENT_DISPOSITION_FILENAME_REGEX.exec(e),u=l?.groups?.name?.trim();return u?l?.groups?.quote?u.slice(1,-1):u:void 0}async encodeRequestData(e,r,a){if(this.#n&&p(e)){let t=(0,i.isString)(e)?e:JSON.stringify(e);return{data:await this.#n.encode(t),options:{...a,transformRequest:s,headers:{...a.headers,[n.BODY_ENCODING_HEADER]:this.#n.encoding}}}}let o=r??this.#t.defaultBodyEncoding??`none`;if(o===`none`||!p(e))return{data:e,options:a};let c=(0,i.isString)(e)?e:JSON.stringify(e),l=await t.encodeRequestBody(c,o);return{data:l.body,options:{...a,transformRequest:s,headers:{...a.headers,[n.BODY_ENCODING_HEADER]:l.encoding}}}}async ensureTokenRefreshed(e=!0){let t=e?()=>this.#t.onUnauthenticated?.():void 0,{cycle:n,owner:r}=this.tryRefreshToken(t),i=await n.promise;return r&&await n.failureHandled,i}async get(e,t){return(await this.#e.get(e,t)).data}async post(e,t){let{data:n,bodyEncoding:r,...i}=t??{},a=await this.encodeRequestData(n,r,i);return(await this.#e.post(e,a.data,a.options)).data}async put(e,t){let{data:n,bodyEncoding:r,...i}=t??{},a=await this.encodeRequestData(n,r,i);return(await this.#e.put(e,a.data,a.options)).data}async delete(e,t){return(await this.#e.delete(e,t)).data}async upload(e,t){let{data:n,onProgress:r,...a}=t??{};return(await this.#e.postForm(e,n,{...a,onUploadProgress:(0,i.isFunction)(r)?r:void 0})).data}async requestFile(e,t){let{method:n=`get`,data:r,onProgress:a,...s}=t??{},c={...s,[o]:`raw`,responseType:`arraybuffer`,responseEncoding:`binary`,onDownloadProgress:(0,i.isFunction)(a)?a:void 0},l;if(n===`post`){let t=await this.encodeRequestData(r,`none`,c);l=await this.#e.post(e,t.data,t.options)}else l=await this.#e.get(e,c);let{config:u,data:d,headers:f}=l,p=this.toBlob(d,f[`content-type`]),m=await this.readApiResult(p);return m&&this.assertBusinessSuccess(m,u),{blob:p,filename:this.getResponseFilename(f[`content-disposition`])}}async download(e,t){let{filename:n,...r}=t??{},{blob:a,filename:o}=await this.requestFile(e,r),s=o??l,c=URL.createObjectURL(a);try{let e=document.createElement(`a`);e.href=c,e.download=(0,i.isFunction)(n)?n(s):n??s,e.click()}finally{setTimeout(()=>URL.revokeObjectURL(c),0)}}};exports.HttpClient=h;
|
package/dist/es/api/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { createHttpClient as e } from "../http/helpers.js";
|
|
3
3
|
import { createQueryClient as t } from "../query/helpers.js";
|
|
4
4
|
import { HTTP_CLIENT as n, PROXIED_METHODS as r, QUERY_CLIENT as i } from "./constants.js";
|
package/dist/es/api/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { HTTP_CLIENT_KEY as e } from "../http/constants.js";
|
|
3
3
|
import { QUERY_CLIENT_KEY as t } from "../query/constants.js";
|
|
4
4
|
//#region src/api/constants.ts
|
package/dist/es/api/helpers.js
CHANGED
package/dist/es/api/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { HTTP_CLIENT as e, QUERY_CLIENT as t } from "./constants.js";
|
|
3
3
|
import { ApiClient as n } from "./client.js";
|
|
4
4
|
import { createApiClient as r, createApiRequest as i } from "./helpers.js";
|
package/dist/es/auth/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { isNullish as e, isString as t } from "@vef-framework-react/shared";
|
|
3
3
|
//#region src/auth/helpers.ts
|
|
4
4
|
function n(n, r, i = "any") {
|
package/dist/es/auth/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { QUERY_CLIENT as e } from "../api/constants.js";
|
|
3
3
|
import { QueryClientProvider as t } from "@tanstack/react-query";
|
|
4
4
|
import { createContext as n, use as r } from "react";
|
package/dist/es/context/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { isFunction as e } from "@vef-framework-react/shared";
|
|
3
3
|
import { createContext as t, use as n, useEffect as r, useState as i, useSyncExternalStore as a } from "react";
|
|
4
4
|
import { jsx as o } from "@emotion/react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { createContext as e, use as t } from "react";
|
|
3
3
|
//#region src/context/disabled.ts
|
|
4
4
|
var n = e(!1);
|
package/dist/es/context/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { ApiClientProvider as e, useApiClient as t } from "./api-client.js";
|
|
3
3
|
import { AppContextProvider as n, useAppContext as r } from "./app.js";
|
|
4
4
|
import { createContextWithSelector as i } from "./context-selector.js";
|
package/dist/es/dnd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { CollisionPriority as e } from "@dnd-kit/abstract";
|
|
3
3
|
import { AxisModifier as t, RestrictToHorizontalAxis as n, RestrictToVerticalAxis as r, SnapModifier as i, restrictShapeToBoundingRectangle as a } from "@dnd-kit/abstract/modifiers";
|
|
4
4
|
import { closestCenter as o, closestCorners as s, defaultCollisionDetection as c, directionBiased as l, pointerDistance as u, pointerIntersection as d, shapeIntersection as f } from "@dnd-kit/collision";
|
|
@@ -1,28 +1,75 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
//#region src/http/body-encoding.ts
|
|
3
|
-
var e = 32768;
|
|
4
|
-
function
|
|
3
|
+
var e = 32768, t = /^(?:[A-Z\d+/]{4})*(?:[A-Z\d+/]{2}==|[A-Z\d+/]{3}=)?$/i;
|
|
4
|
+
function n(t) {
|
|
5
5
|
if ("toBase64" in t && typeof t.toBase64 == "function") return t.toBase64();
|
|
6
6
|
let n = "";
|
|
7
7
|
for (let r = 0; r < t.length; r += e) n += String.fromCodePoint(...t.subarray(r, r + e));
|
|
8
8
|
return btoa(n);
|
|
9
9
|
}
|
|
10
|
-
function n
|
|
10
|
+
function r(e, n) {
|
|
11
|
+
if (e.length === 0 || e.length % 4 != 0 || !t.test(e)) throw TypeError(`${n} must be standard padded base64`);
|
|
12
|
+
let r;
|
|
13
|
+
try {
|
|
14
|
+
r = atob(e);
|
|
15
|
+
} catch {
|
|
16
|
+
throw TypeError(`${n} must be standard padded base64`);
|
|
17
|
+
}
|
|
18
|
+
let i = new Uint8Array(r.length);
|
|
19
|
+
for (let e = 0; e < r.length; e += 1) i[e] = r.codePointAt(e);
|
|
20
|
+
return i;
|
|
21
|
+
}
|
|
22
|
+
function i(e, t) {
|
|
23
|
+
let n = new Uint8Array(e.byteLength + t.byteLength);
|
|
24
|
+
return n.set(e), n.set(new Uint8Array(t), e.byteLength), n;
|
|
25
|
+
}
|
|
26
|
+
var a = class {
|
|
27
|
+
#e;
|
|
28
|
+
#t;
|
|
29
|
+
encoding;
|
|
30
|
+
constructor(e) {
|
|
31
|
+
if (e.encoding !== "aes-gcm+base64") throw TypeError(`Unsupported protected body encoding: ${String(e.encoding)}`);
|
|
32
|
+
let t = r(e.key, "Protected body key");
|
|
33
|
+
if (t.byteLength !== 16 && t.byteLength !== 24 && t.byteLength !== 32) throw TypeError("Protected body AES-GCM key must contain 16, 24, or 32 bytes");
|
|
34
|
+
if (!globalThis.crypto?.subtle) throw TypeError("Protected body encoding requires the Web Crypto API");
|
|
35
|
+
this.encoding = e.encoding, this.#e = t;
|
|
36
|
+
}
|
|
37
|
+
getKey() {
|
|
38
|
+
return this.#t ??= crypto.subtle.importKey("raw", this.#e, "AES-GCM", !1, ["encrypt", "decrypt"]), this.#t;
|
|
39
|
+
}
|
|
40
|
+
async encode(e) {
|
|
41
|
+
let t = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12));
|
|
42
|
+
return n(i(t, await crypto.subtle.encrypt({
|
|
43
|
+
name: "AES-GCM",
|
|
44
|
+
iv: t
|
|
45
|
+
}, await this.getKey(), new TextEncoder().encode(e))));
|
|
46
|
+
}
|
|
47
|
+
async decode(e) {
|
|
48
|
+
let t = r(e.trim(), "Protected body");
|
|
49
|
+
if (t.byteLength < 28) throw TypeError("Protected body is too short");
|
|
50
|
+
let n = t.slice(0, 12), i = t.slice(12), a = await crypto.subtle.decrypt({
|
|
51
|
+
name: "AES-GCM",
|
|
52
|
+
iv: n
|
|
53
|
+
}, await this.getKey(), i);
|
|
54
|
+
return new TextDecoder("utf-8", { fatal: !0 }).decode(a);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
function o() {
|
|
11
58
|
return typeof CompressionStream < "u";
|
|
12
59
|
}
|
|
13
|
-
async function
|
|
60
|
+
async function s(e) {
|
|
14
61
|
let t = new CompressionStream("gzip"), n = t.writable.getWriter(), r = n.write(e).then(() => n.close()), [i] = await Promise.all([new Response(t.readable).arrayBuffer(), r]);
|
|
15
62
|
return new Uint8Array(i);
|
|
16
63
|
}
|
|
17
|
-
async function
|
|
18
|
-
let
|
|
19
|
-
return
|
|
20
|
-
body:
|
|
64
|
+
async function c(e, t) {
|
|
65
|
+
let r = new TextEncoder().encode(e);
|
|
66
|
+
return t === "gzip+base64" && o() ? {
|
|
67
|
+
body: n(await s(r)),
|
|
21
68
|
encoding: "gzip+base64"
|
|
22
69
|
} : {
|
|
23
|
-
body:
|
|
70
|
+
body: n(r),
|
|
24
71
|
encoding: "base64"
|
|
25
72
|
};
|
|
26
73
|
}
|
|
27
74
|
//#endregion
|
|
28
|
-
export {
|
|
75
|
+
export { a as ProtectedBodyCodec, c as encodeRequestBody };
|
package/dist/es/http/client.js
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
2
|
-
import {
|
|
3
|
-
import { BODY_ENCODING_HEADER as
|
|
4
|
-
import { BusinessError as
|
|
5
|
-
import { encodeQueryString as
|
|
6
|
-
import
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
|
+
import { ProtectedBodyCodec as e, encodeRequestBody as t } from "./body-encoding.js";
|
|
3
|
+
import { BODY_ENCODING_HEADER as n, CONTENT_DISPOSITION_FILENAME_REGEX as r, DEFAULT_TIMEOUT as i, PATH_PARAM_REGEX as a, SKIP_AUTH_HEADER as o } from "./constants.js";
|
|
4
|
+
import { BusinessError as s } from "./errors.js";
|
|
5
|
+
import { encodeQueryString as c, isArray as l, isFunction as u, isNullish as d, isNumber as f, isString as p } from "@vef-framework-react/shared";
|
|
6
|
+
import m, { CanceledError as h } from "axios";
|
|
7
7
|
//#region src/http/client.ts
|
|
8
|
-
var
|
|
9
|
-
function
|
|
8
|
+
var g = "__vefResponseMode", _ = [(e) => e], v = 1024 * 1024, y = "download";
|
|
9
|
+
function b(e) {
|
|
10
10
|
return Object.prototype.toString.call(e) === "[object ArrayBuffer]";
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
function x(e, t) {
|
|
13
|
+
let n = Reflect.get(e, "get");
|
|
14
|
+
return u(n) ? Reflect.apply(n, e, [t]) : Reflect.get(e, t) ?? Reflect.get(e, t.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
function S(e) {
|
|
17
|
+
return p(e) ? Promise.resolve(e) : e instanceof Blob ? e.text() : b(e) || ArrayBuffer.isView(e) ? Promise.resolve(new TextDecoder().decode(e)) : Promise.reject(/* @__PURE__ */ TypeError("Invalid protected response body"));
|
|
18
|
+
}
|
|
19
|
+
function C(e) {
|
|
20
|
+
return !d(e) && !(e instanceof FormData) && !(e instanceof Blob) && !b(e) && !ArrayBuffer.isView(e);
|
|
14
21
|
}
|
|
15
|
-
function
|
|
22
|
+
function w(e) {
|
|
16
23
|
return typeof e.addEventListener == "function" && typeof e.removeEventListener == "function";
|
|
17
24
|
}
|
|
18
|
-
var
|
|
25
|
+
var T = class {
|
|
19
26
|
#e;
|
|
20
27
|
#t;
|
|
21
28
|
#n;
|
|
22
|
-
#r
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
#r;
|
|
30
|
+
#i = /* @__PURE__ */ new Set();
|
|
31
|
+
constructor(t) {
|
|
32
|
+
this.#t = t, this.#n = t.protectedBodyEncoding ? new e(t.protectedBodyEncoding) : void 0;
|
|
33
|
+
let { baseUrl: n, timeout: r = i } = t;
|
|
34
|
+
this.#e = m.create({
|
|
35
|
+
baseURL: n,
|
|
28
36
|
allowAbsoluteUrls: !0,
|
|
29
|
-
timeout:
|
|
37
|
+
timeout: r,
|
|
30
38
|
headers: { "Content-Type": "application/json" },
|
|
31
|
-
paramsSerializer: (e) =>
|
|
39
|
+
paramsSerializer: (e) => c(e, {
|
|
32
40
|
arrayFormat: "repeat",
|
|
33
41
|
skipNulls: !0,
|
|
34
42
|
charset: "utf-8"
|
|
@@ -44,24 +52,24 @@ var S = class {
|
|
|
44
52
|
this.#e.interceptors.request.use(this.handleRequest.bind(this), this.handleRequestError.bind(this)), this.#e.interceptors.response.use(this.handleResponse.bind(this), this.handleResponseError.bind(this));
|
|
45
53
|
}
|
|
46
54
|
matchesCode(e, t) {
|
|
47
|
-
return
|
|
55
|
+
return l(t) ? t.includes(e) : e === t;
|
|
48
56
|
}
|
|
49
57
|
async handleRequest(e) {
|
|
50
|
-
let t = e.headers[
|
|
58
|
+
let t = e.headers[o] === "1", n = this.#r?.promise;
|
|
51
59
|
if (n && !t && !await this.waitForTokenRefresh(n, e)) throw Error("登录已过期, 请重新登录");
|
|
52
|
-
return t ? delete e.headers[
|
|
60
|
+
return t ? delete e.headers[o] : await this.injectAccessToken(e), this.replacePathParams(e), e;
|
|
53
61
|
}
|
|
54
62
|
handleRequestError(e) {
|
|
55
63
|
let { showErrorMessage: t } = this.#t, n = `发起请求失败: ${(e instanceof Error ? e.message : String(e)) || "未知错误"}`;
|
|
56
64
|
return t ? t(n) : console.error(`[HttpClient] ${n}`), Promise.reject(e);
|
|
57
65
|
}
|
|
58
|
-
handleResponse(e) {
|
|
59
|
-
if (this.getResponseMode(e.config) === "raw") return e;
|
|
66
|
+
async handleResponse(e) {
|
|
67
|
+
if ((this.#n || x(e.headers, "X-Body-Encoding")) && await this.decodeProtectedResponse(e), this.getResponseMode(e.config) === "raw") return e;
|
|
60
68
|
if (!this.isApiResult(e.data)) throw TypeError("Invalid API response envelope");
|
|
61
69
|
return this.assertBusinessSuccess(e.data, e.config), e;
|
|
62
70
|
}
|
|
63
71
|
async handleResponseError(e) {
|
|
64
|
-
if (e instanceof
|
|
72
|
+
if (e instanceof h) {
|
|
65
73
|
if (e.response) {
|
|
66
74
|
let { method: t, url: n } = e.response.config;
|
|
67
75
|
console.warn(`[HttpClient] [${t}: ${n}] 被取消`);
|
|
@@ -70,6 +78,7 @@ var S = class {
|
|
|
70
78
|
}
|
|
71
79
|
let { response: t } = e;
|
|
72
80
|
if (!t) throw this.logError(`请求失败: ${e.message || "未知错误"}`), e;
|
|
81
|
+
(this.#n || x(t.headers, "X-Body-Encoding")) && await this.decodeProtectedResponse(t);
|
|
73
82
|
let { status: n, config: r, data: i } = t, a = await this.readApiResult(i), o = a?.code, s = a?.message ?? e.message ?? "未知错误", c = `[${r.method}: ${r.url}]`;
|
|
74
83
|
switch (n) {
|
|
75
84
|
case 400:
|
|
@@ -93,7 +102,7 @@ var S = class {
|
|
|
93
102
|
await this.#t.onUnauthenticated?.();
|
|
94
103
|
return;
|
|
95
104
|
}
|
|
96
|
-
if (this.#
|
|
105
|
+
if (this.#r) throw e;
|
|
97
106
|
let { cycle: r } = this.tryRefreshToken(async () => {
|
|
98
107
|
this.logInfo("登录已过期, 请重新登录"), await this.#t.onUnauthenticated?.();
|
|
99
108
|
});
|
|
@@ -117,15 +126,15 @@ var S = class {
|
|
|
117
126
|
}
|
|
118
127
|
replacePathParams(e) {
|
|
119
128
|
let { url: t, params: n = {} } = e;
|
|
120
|
-
!t || !
|
|
129
|
+
!t || !a.test(t) || (a.lastIndex = 0, e.url = t.replaceAll(a, (e, r) => {
|
|
121
130
|
if (!Object.hasOwn(n, r)) return console.warn(`[HttpClient] 接口: ${t} 路径参数 ${r} 未在查询参数中定义, 请检查`), "unknown";
|
|
122
131
|
let i = n[r];
|
|
123
|
-
return
|
|
132
|
+
return d(i) ? (console.warn(`[HttpClient] 接口: ${t} 路径参数 ${r} 在查询参数中为空, 请检查`), "unknown") : String(i);
|
|
124
133
|
}));
|
|
125
134
|
}
|
|
126
135
|
tryRefreshToken(e) {
|
|
127
|
-
if (this.#
|
|
128
|
-
cycle: this.#
|
|
136
|
+
if (this.#r) return {
|
|
137
|
+
cycle: this.#r,
|
|
129
138
|
owner: !1
|
|
130
139
|
};
|
|
131
140
|
let { getAuthTokens: t, refreshToken: n, setAuthTokens: r } = this.#t;
|
|
@@ -144,7 +153,7 @@ var S = class {
|
|
|
144
153
|
failureHandled: r.promise,
|
|
145
154
|
promise: e
|
|
146
155
|
};
|
|
147
|
-
return n && (this.#
|
|
156
|
+
return n && (this.#r = i), e.then((e) => {
|
|
148
157
|
n && this.finishTokenRefresh(i, e), (e ? Promise.resolve() : this.handleRefreshFailure(t)).then(r.resolve, r.reject);
|
|
149
158
|
}, (e) => {
|
|
150
159
|
n && this.finishTokenRefresh(i, !1), this.handleRefreshFailure(t).then(() => r.reject(e), r.reject);
|
|
@@ -164,46 +173,66 @@ var S = class {
|
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
175
|
finishTokenRefresh(e, t) {
|
|
167
|
-
if (this.#
|
|
168
|
-
for (let e of this.#
|
|
169
|
-
this.#
|
|
176
|
+
if (this.#r === e) {
|
|
177
|
+
for (let e of this.#i) e(t);
|
|
178
|
+
this.#i.clear(), this.#r = void 0;
|
|
170
179
|
}
|
|
171
180
|
}
|
|
172
181
|
waitForTokenRefresh(e, t) {
|
|
173
|
-
if (this.#
|
|
182
|
+
if (this.#r?.promise !== e) return e;
|
|
174
183
|
let { signal: n } = t;
|
|
175
|
-
return n?.aborted ? Promise.reject(new
|
|
176
|
-
let i = n &&
|
|
184
|
+
return n?.aborted ? Promise.reject(new h(void 0, t)) : new Promise((e, r) => {
|
|
185
|
+
let i = n && w(n) ? n : void 0, a, o = () => {
|
|
177
186
|
let e = a;
|
|
178
|
-
e && (a = void 0, this.#
|
|
187
|
+
e && (a = void 0, this.#i.delete(e), i?.removeEventListener("abort", o), r(new h(void 0, t)));
|
|
179
188
|
};
|
|
180
189
|
a = (t) => {
|
|
181
190
|
let n = a;
|
|
182
|
-
n && (a = void 0, this.#
|
|
183
|
-
}, this.#
|
|
191
|
+
n && (a = void 0, this.#i.delete(n), i?.removeEventListener("abort", o), e(t));
|
|
192
|
+
}, this.#i.add(a), i?.addEventListener("abort", o, { once: !0 }), n?.aborted && o();
|
|
184
193
|
});
|
|
185
194
|
}
|
|
186
195
|
async retryRequest(e) {
|
|
187
196
|
let t = {
|
|
188
197
|
...e,
|
|
189
|
-
[
|
|
198
|
+
[g]: this.getResponseMode(e)
|
|
190
199
|
};
|
|
191
200
|
return await this.injectAccessToken(t), this.#e(t);
|
|
192
201
|
}
|
|
193
202
|
getResponseMode(e) {
|
|
194
|
-
return Reflect.get(e,
|
|
203
|
+
return Reflect.get(e, g) === "raw" ? "raw" : "envelope";
|
|
204
|
+
}
|
|
205
|
+
async decodeProtectedResponse(e) {
|
|
206
|
+
let t = x(e.headers, n), r = p(t) ? t.trim() : "", i = this.getResponseMode(e.config);
|
|
207
|
+
if (!r) {
|
|
208
|
+
let t = x(e.headers, "Content-Type"), r = p(t) && t.toLowerCase().startsWith("application/json");
|
|
209
|
+
if (this.#n && (i === "envelope" || r)) throw TypeError(`Missing ${n} on protected API response`);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (!this.#n) throw TypeError(`Cannot decode ${r} response without protectedBodyEncoding`);
|
|
213
|
+
if (r !== this.#n.encoding) throw TypeError(`Unsupported protected response body encoding: ${r}`);
|
|
214
|
+
let a = await this.#n.decode(await S(e.data));
|
|
215
|
+
if (i === "raw") {
|
|
216
|
+
e.data = new TextEncoder().encode(a).buffer;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
e.data = JSON.parse(a);
|
|
221
|
+
} catch {
|
|
222
|
+
throw TypeError("Protected API response is not valid JSON");
|
|
223
|
+
}
|
|
195
224
|
}
|
|
196
225
|
isApiResult(e) {
|
|
197
|
-
return typeof e == "object" && !!e &&
|
|
226
|
+
return typeof e == "object" && !!e && f(Reflect.get(e, "code")) && p(Reflect.get(e, "message")) && Object.hasOwn(e, "data");
|
|
198
227
|
}
|
|
199
228
|
assertBusinessSuccess(e, t) {
|
|
200
|
-
let { showWarningMessage: n, okCode: r = 0 } = this.#t, { code: i, message: a, data:
|
|
201
|
-
if (!this.matchesCode(i, r)) throw n ? n(a) : console.warn(`[HttpClient] [${t.method}: ${t.url}] 返回错误: ${a}`), new
|
|
229
|
+
let { showWarningMessage: n, okCode: r = 0 } = this.#t, { code: i, message: a, data: o } = e;
|
|
230
|
+
if (!this.matchesCode(i, r)) throw n ? n(a) : console.warn(`[HttpClient] [${t.method}: ${t.url}] 返回错误: ${a}`), new s(i, a, o);
|
|
202
231
|
}
|
|
203
232
|
async readApiResult(e) {
|
|
204
233
|
if (this.isApiResult(e)) return e;
|
|
205
|
-
if (
|
|
206
|
-
if (e.length >
|
|
234
|
+
if (p(e)) {
|
|
235
|
+
if (e.length > v || new Blob([e]).size > v) return;
|
|
207
236
|
try {
|
|
208
237
|
let t = JSON.parse(e);
|
|
209
238
|
return this.isApiResult(t) ? t : void 0;
|
|
@@ -211,56 +240,70 @@ var S = class {
|
|
|
211
240
|
return;
|
|
212
241
|
}
|
|
213
242
|
}
|
|
214
|
-
if ((
|
|
243
|
+
if ((b(e) || ArrayBuffer.isView(e)) && e.byteLength > v) return;
|
|
215
244
|
let t;
|
|
216
245
|
try {
|
|
217
246
|
t = this.toBlob(e);
|
|
218
247
|
} catch {
|
|
219
248
|
return;
|
|
220
249
|
}
|
|
221
|
-
if (!(t.size >
|
|
250
|
+
if (!(t.size > v)) try {
|
|
222
251
|
let e = JSON.parse(await t.text());
|
|
223
252
|
return this.isApiResult(e) ? e : void 0;
|
|
224
253
|
} catch {}
|
|
225
254
|
}
|
|
226
255
|
toBlob(e, t) {
|
|
227
256
|
if (e instanceof Blob) return e;
|
|
228
|
-
let n =
|
|
229
|
-
if (
|
|
257
|
+
let n = p(t) ? { type: t } : void 0;
|
|
258
|
+
if (b(e)) return new Blob([e], n);
|
|
230
259
|
if (ArrayBuffer.isView(e)) {
|
|
231
|
-
if (
|
|
260
|
+
if (b(e.buffer)) return new Blob([new Uint8Array(e.buffer, e.byteOffset, e.byteLength)], n);
|
|
232
261
|
let t = new Uint8Array(e.byteLength);
|
|
233
262
|
return t.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)), new Blob([t], n);
|
|
234
263
|
}
|
|
235
264
|
throw TypeError("Invalid file response body");
|
|
236
265
|
}
|
|
237
266
|
getResponseFilename(e) {
|
|
238
|
-
if (!
|
|
267
|
+
if (!p(e)) return;
|
|
239
268
|
let t = e.split(";").find((e) => {
|
|
240
269
|
let t = e.indexOf("=");
|
|
241
270
|
return t !== -1 && e.slice(0, t).trim().toLowerCase() === "filename*";
|
|
242
|
-
}),
|
|
271
|
+
}), n = t?.slice(t.indexOf("=") + 1).trim(), i = n?.indexOf("'") ?? -1, a = i >= 0 ? n?.indexOf("'", i + 1) ?? -1 : -1, o = a >= 0 ? n?.slice(a + 1) : void 0, s = i >= 0 ? n?.slice(0, i).trim().toLowerCase() : void 0;
|
|
243
272
|
if (o && (!s || s === "utf-8")) try {
|
|
244
273
|
return decodeURIComponent(o);
|
|
245
274
|
} catch {}
|
|
246
|
-
let c =
|
|
275
|
+
let c = r.exec(e), l = c?.groups?.name?.trim();
|
|
247
276
|
return l ? c?.groups?.quote ? l.slice(1, -1) : l : void 0;
|
|
248
277
|
}
|
|
249
|
-
async encodeRequestData(
|
|
278
|
+
async encodeRequestData(e, r, i) {
|
|
279
|
+
if (this.#n && C(e)) {
|
|
280
|
+
let t = p(e) ? e : JSON.stringify(e);
|
|
281
|
+
return {
|
|
282
|
+
data: await this.#n.encode(t),
|
|
283
|
+
options: {
|
|
284
|
+
...i,
|
|
285
|
+
transformRequest: _,
|
|
286
|
+
headers: {
|
|
287
|
+
...i.headers,
|
|
288
|
+
[n]: this.#n.encoding
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
250
293
|
let a = r ?? this.#t.defaultBodyEncoding ?? "none";
|
|
251
|
-
if (a === "none" || !
|
|
252
|
-
data:
|
|
294
|
+
if (a === "none" || !C(e)) return {
|
|
295
|
+
data: e,
|
|
253
296
|
options: i
|
|
254
297
|
};
|
|
255
|
-
let o = await
|
|
298
|
+
let o = await t(p(e) ? e : JSON.stringify(e), a);
|
|
256
299
|
return {
|
|
257
300
|
data: o.body,
|
|
258
301
|
options: {
|
|
259
302
|
...i,
|
|
260
|
-
transformRequest:
|
|
303
|
+
transformRequest: _,
|
|
261
304
|
headers: {
|
|
262
305
|
...i.headers,
|
|
263
|
-
[
|
|
306
|
+
[n]: o.encoding
|
|
264
307
|
}
|
|
265
308
|
}
|
|
266
309
|
};
|
|
@@ -287,31 +330,36 @@ var S = class {
|
|
|
287
330
|
let { data: n, onProgress: r, ...i } = t ?? {};
|
|
288
331
|
return (await this.#e.postForm(e, n, {
|
|
289
332
|
...i,
|
|
290
|
-
onUploadProgress:
|
|
333
|
+
onUploadProgress: u(r) ? r : void 0
|
|
291
334
|
})).data;
|
|
292
335
|
}
|
|
293
336
|
async requestFile(e, t) {
|
|
294
337
|
let { method: n = "get", data: r, onProgress: i, ...a } = t ?? {}, o = {
|
|
295
338
|
...a,
|
|
296
|
-
[
|
|
339
|
+
[g]: "raw",
|
|
297
340
|
responseType: "arraybuffer",
|
|
298
341
|
responseEncoding: "binary",
|
|
299
|
-
onDownloadProgress:
|
|
300
|
-
},
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
342
|
+
onDownloadProgress: u(i) ? i : void 0
|
|
343
|
+
}, s;
|
|
344
|
+
if (n === "post") {
|
|
345
|
+
let t = await this.encodeRequestData(r, "none", o);
|
|
346
|
+
s = await this.#e.post(e, t.data, t.options);
|
|
347
|
+
} else s = await this.#e.get(e, o);
|
|
348
|
+
let { config: c, data: l, headers: d } = s, f = this.toBlob(l, d["content-type"]), p = await this.readApiResult(f);
|
|
349
|
+
return p && this.assertBusinessSuccess(p, c), {
|
|
350
|
+
blob: f,
|
|
351
|
+
filename: this.getResponseFilename(d["content-disposition"])
|
|
304
352
|
};
|
|
305
353
|
}
|
|
306
354
|
async download(e, t) {
|
|
307
|
-
let { filename: n, ...r } = t ?? {}, { blob: i, filename: a } = await this.requestFile(e, r), o = a ??
|
|
355
|
+
let { filename: n, ...r } = t ?? {}, { blob: i, filename: a } = await this.requestFile(e, r), o = a ?? y, s = URL.createObjectURL(i);
|
|
308
356
|
try {
|
|
309
357
|
let e = document.createElement("a");
|
|
310
|
-
e.href = s, e.download =
|
|
358
|
+
e.href = s, e.download = u(n) ? n(o) : n ?? o, e.click();
|
|
311
359
|
} finally {
|
|
312
360
|
setTimeout(() => URL.revokeObjectURL(s), 0);
|
|
313
361
|
}
|
|
314
362
|
}
|
|
315
363
|
};
|
|
316
364
|
//#endregion
|
|
317
|
-
export {
|
|
365
|
+
export { T as HttpClient };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
//#region src/http/constants.ts
|
|
3
3
|
var e = "__vef_http_client_key", t = /(?<=\/):(?<key>[A-Z_]\w*)/gi, n = /(?:^|;)\s*filename\s*=(?<name>(?<quote>['"]).*?\2|[^;\n]*)/i, r = "X-Skip-Authentication", i = "1", a = "X-Body-Encoding", o = 3e4;
|
|
4
4
|
//#endregion
|
package/dist/es/http/errors.js
CHANGED
package/dist/es/http/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { BusinessError as e } from "./errors.js";
|
|
3
3
|
import { HttpClient as t } from "./client.js";
|
|
4
4
|
//#region src/http/helpers.ts
|
package/dist/es/http/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { HTTP_CLIENT_KEY as e, SKIP_AUTH_HEADER as t, SKIP_AUTH_VALUE as n } from "./constants.js";
|
|
3
3
|
import { BusinessError as r } from "./errors.js";
|
|
4
4
|
import "./client.js";
|
package/dist/es/immer/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { applyPatches as e, current as t, enableMapSet as n, enablePatches as r, original as i, produce as a, produceWithPatches as o, setAutoFreeze as s } from "immer";
|
|
3
3
|
import { useImmer as c, useImmerReducer as l } from "use-immer";
|
|
4
4
|
n(), r(), s(!1);
|
package/dist/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { SKIP_AUTH_HEADER as e, SKIP_AUTH_VALUE as t } from "./http/constants.js";
|
|
3
3
|
import { BusinessError as n } from "./http/errors.js";
|
|
4
4
|
import { isBusinessError as r } from "./http/helpers.js";
|
package/dist/es/motion/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import e from "./motion-provider.js";
|
|
3
3
|
import { AnimatePresence as t, LayoutGroup as n, Reorder as r, useDragControls as i, useInView as a } from "motion/react";
|
|
4
4
|
import * as o from "motion/react-m";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { generateId as e } from "@vef-framework-react/shared";
|
|
3
3
|
import { useState as t } from "react";
|
|
4
4
|
import { jsx as n } from "@emotion/react/jsx-runtime";
|
package/dist/es/push/client.js
CHANGED
package/dist/es/push/helpers.js
CHANGED
package/dist/es/push/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { PUSH_CLOSE_SESSION_INVALID as e, PUSH_CLOSE_TOO_MANY_CONNECTIONS as t } from "./types.js";
|
|
3
3
|
import { PushClient as n } from "./client.js";
|
|
4
4
|
import { createPushClient as r } from "./helpers.js";
|
package/dist/es/push/types.js
CHANGED
package/dist/es/query/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { hashKey as e, isPlainObject as t } from "@vef-framework-react/shared";
|
|
3
3
|
import { MutationCache as n, QueryClient as r, keepPreviousData as i, matchQuery as a } from "@tanstack/react-query";
|
|
4
4
|
//#region src/query/helpers.ts
|
package/dist/es/query/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { matchMutation as e, matchQuery as t, skipToken as n, useInfiniteQuery as r, useIsFetching as i, useIsMutating as a, useMutation as o, useMutationState as s, useQueries as c, useQuery as l, useQueryClient as u, useQueryErrorResetBoundary as d } from "@tanstack/react-query";
|
|
3
3
|
//#region src/query/hooks.ts
|
|
4
4
|
function f(e) {
|
package/dist/es/query/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { QUERY_CLIENT_KEY as e } from "./constants.js";
|
|
3
3
|
import { createQueryClient as t } from "./helpers.js";
|
|
4
4
|
import { useInfiniteQuery as n, useIsFetching as r, useIsMutating as i, useMutation as a, useMutationState as o, useQueries as s, useQuery as c } from "./hooks.js";
|
package/dist/es/sse/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { TokenExpiredError as e, createStreamMachine as t } from "./stream-machine.js";
|
|
3
3
|
import { isString as n } from "@vef-framework-react/shared";
|
|
4
4
|
import { fetchEventSource as r } from "@microsoft/fetch-event-source";
|
package/dist/es/sse/helpers.js
CHANGED
package/dist/es/sse/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { SseClient as e } from "./client.js";
|
|
3
3
|
import { createSseClient as t } from "./helpers.js";
|
|
4
4
|
export { e as SseClient, t as createSseClient };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { fromPromise as e, setup as t } from "xstate";
|
|
3
3
|
//#region src/sse/stream-machine.ts
|
|
4
4
|
var n = class extends Error {
|
package/dist/es/state/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { Provider as e, atom as t, createStore as n, getDefaultStore as r, useAtom as i, useAtomValue as a, useSetAtom as o, useStore as s } from "jotai";
|
|
3
3
|
export { e as AtomStoreProvider, t as atom, n as createAtomStore, r as getDefaultAtomStore, i as useAtom, s as useAtomStore, a as useAtomValue, o as useSetAtom };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { Actor as e, assign as t, createActor as n, createMachine as r } from "xstate";
|
|
3
3
|
import { useActorRef as i, useActorRef as a, useSelector as o } from "@xstate/react";
|
|
4
4
|
//#region src/state-machine/index.ts
|
package/dist/es/storage/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { UploadAbortedError as e, UploadError as t, UploadPartError as n, UploadProtocolError as r } from "./errors.js";
|
|
3
3
|
import { DEFAULT_API_PATH as i, DEFAULT_FILE_RESOURCE as a, DEFAULT_RESOURCE as o, DEFAULT_VERSION as s, abortUpload as c, completeUpload as l, initUpload as u, listParts as d, resolveFiles as f, uploadPart as p } from "./protocol.js";
|
|
4
4
|
import { PrefixFingerprinter as m, WeakFingerprinter as h } from "./resumable/fingerprint.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { createApiRequest as e } from "../api/helpers.js";
|
|
3
3
|
import { UploadProtocolError as t } from "./errors.js";
|
|
4
4
|
//#region src/storage/protocol.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { PrefixFingerprinter as e, WeakFingerprinter as t } from "./fingerprint.js";
|
|
3
3
|
import { LocalStoragePersistence as n } from "./persistence.js";
|
|
4
4
|
import { resolveResumePlan as r } from "./plan.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { abortUpload as e, listParts as t } from "../protocol.js";
|
|
3
3
|
//#region src/storage/resumable/plan.ts
|
|
4
4
|
async function n(n) {
|
package/dist/es/storage/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { assertEvent as e, fromPromise as t, setup as n } from "xstate";
|
|
3
3
|
//#region src/storage/uploader-machine.ts
|
|
4
4
|
function r(r) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { UploadAbortedError as e, UploadError as t, UploadPartError as n, UploadProtocolError as r } from "./errors.js";
|
|
3
3
|
import { abortUpload as i, completeUpload as a, initUpload as o, uploadPart as s } from "./protocol.js";
|
|
4
4
|
import { createUploaderMachine as c } from "./uploader-machine.js";
|
package/dist/es/store/bound.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { constantCase as e, identity as t } from "@vef-framework-react/shared";
|
|
3
3
|
import { create as n } from "zustand";
|
|
4
4
|
import { createJSONStorage as r, persist as i, subscribeWithSelector as a } from "zustand/middleware";
|
package/dist/es/store/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { createPersistedStore as e, createStore as t } from "./bound.js";
|
|
3
3
|
import { createComponentStore as n } from "./unbound.js";
|
|
4
4
|
import { useDeep as r } from "./use-deep.js";
|
package/dist/es/store/unbound.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { constantCase as e, identity as t, isPlainObject as n, mergeWith as r } from "@vef-framework-react/shared";
|
|
3
3
|
import { createContext as i, use as a, useRef as o } from "react";
|
|
4
4
|
import { jsx as s } from "@emotion/react/jsx-runtime";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/core v2.
|
|
1
|
+
/*! @vef-framework-react/core v2.21.0 made by Venus | 2026-09-14T13:39:01.431Z */
|
|
2
2
|
import { isDeepEqual as e } from "@vef-framework-react/shared";
|
|
3
3
|
import { useRef as t } from "react";
|
|
4
4
|
//#region src/store/use-deep.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BodyEncoding } from './types';
|
|
1
|
+
import { BodyEncoding, ProtectedBodyEncodingOptions } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* The transport encoding actually applied to a request body, paired with the
|
|
4
4
|
* encoded text. `gzip+base64` degrades to `base64` when the runtime has no
|
|
@@ -8,6 +8,17 @@ export interface EncodedRequestBody {
|
|
|
8
8
|
body: string;
|
|
9
9
|
encoding: Exclude<BodyEncoding, "none">;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Native Web Crypto codec matching the Go framework's AES-GCM wire layout.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ProtectedBodyCodec {
|
|
15
|
+
#private;
|
|
16
|
+
readonly encoding: ProtectedBodyEncodingOptions["encoding"];
|
|
17
|
+
constructor(options: ProtectedBodyEncodingOptions);
|
|
18
|
+
private getKey;
|
|
19
|
+
encode(payload: string): Promise<string>;
|
|
20
|
+
decode(payload: string): Promise<string>;
|
|
21
|
+
}
|
|
11
22
|
/**
|
|
12
23
|
* Encode a serialized JSON payload for transport so a code-shaped body (an
|
|
13
24
|
* integration adapter or envelope/auth script) survives middleboxes that
|
|
@@ -83,6 +83,12 @@ export declare class HttpClient {
|
|
|
83
83
|
* Get the response handling mode from an Axios request config.
|
|
84
84
|
*/
|
|
85
85
|
private getResponseMode;
|
|
86
|
+
/**
|
|
87
|
+
* Decode a response carrying the configured protected-body marker. Envelope
|
|
88
|
+
* responses require that marker while protected transport is configured, so
|
|
89
|
+
* a server or intermediary cannot silently downgrade them to plaintext.
|
|
90
|
+
*/
|
|
91
|
+
private decodeProtectedResponse;
|
|
86
92
|
/**
|
|
87
93
|
* Check whether a value is an API response envelope.
|
|
88
94
|
*/
|
|
@@ -22,8 +22,8 @@ export declare const SKIP_AUTH_HEADER = "X-Skip-Authentication";
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const SKIP_AUTH_VALUE = "1";
|
|
24
24
|
/**
|
|
25
|
-
* The header naming the transport encoding applied to a request
|
|
26
|
-
*
|
|
25
|
+
* The header naming the transport encoding applied to a request or response
|
|
26
|
+
* body. Protected transport uses it in both directions.
|
|
27
27
|
*/
|
|
28
28
|
export declare const BODY_ENCODING_HEADER = "X-Body-Encoding";
|
|
29
29
|
/**
|
|
@@ -30,6 +30,21 @@ export interface ApiResult<T = unknown> {
|
|
|
30
30
|
* the wire and still text-shaped.
|
|
31
31
|
*/
|
|
32
32
|
export type BodyEncoding = "none" | "base64" | "gzip+base64";
|
|
33
|
+
/**
|
|
34
|
+
* The authenticated encoding used for bidirectional protected JSON bodies.
|
|
35
|
+
* The browser implementation intentionally uses the native Web Crypto API and
|
|
36
|
+
* therefore currently supports AES-GCM only.
|
|
37
|
+
*/
|
|
38
|
+
export type ProtectedBodyEncoding = "aes-gcm+base64";
|
|
39
|
+
/**
|
|
40
|
+
* Client-wide protected JSON body transport. The key is standard base64
|
|
41
|
+
* containing 16, 24, or 32 bytes. The wire body is standard base64 containing
|
|
42
|
+
* a random 12-byte nonce followed by AES-GCM ciphertext and its 16-byte tag.
|
|
43
|
+
*/
|
|
44
|
+
export interface ProtectedBodyEncodingOptions {
|
|
45
|
+
encoding: ProtectedBodyEncoding;
|
|
46
|
+
key: string;
|
|
47
|
+
}
|
|
33
48
|
/**
|
|
34
49
|
* The authenticated tokens.
|
|
35
50
|
*/
|
|
@@ -105,6 +120,13 @@ export interface HttpClientOptions {
|
|
|
105
120
|
* is sent verbatim.
|
|
106
121
|
*/
|
|
107
122
|
defaultBodyEncoding?: BodyEncoding;
|
|
123
|
+
/**
|
|
124
|
+
* Enables mandatory bidirectional protected JSON bodies. When configured,
|
|
125
|
+
* this takes precedence over legacy per-request body encodings and cannot be
|
|
126
|
+
* opted out with `bodyEncoding: "none"`. Multipart and binary bodies remain
|
|
127
|
+
* unchanged.
|
|
128
|
+
*/
|
|
129
|
+
protectedBodyEncoding?: ProtectedBodyEncodingOptions;
|
|
108
130
|
}
|
|
109
131
|
/**
|
|
110
132
|
* A file fetched through the HTTP client.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { checkPermission, type PermissionCheckMode } from './auth';
|
|
|
3
3
|
export { type DataOption, type DataOptionWithPinyin, type PaginationParams, type PaginationResult } from './common';
|
|
4
4
|
export { ApiClientProvider, AppContextProvider, createContextWithSelector, DisabledProvider, useApiClient, useAppContext, useDisabled, type AppContext, type SelectorContextProviderProps, type SelectorContextResult, type UseSelectorContext } from './context';
|
|
5
5
|
export { AxisModifier, closestCenter, closestCorners, CollisionPriority, defaultCollisionDetection, defaultPreset, directionBiased, DragDropContext, DragDropProvider, Draggable, DragOverlay, Droppable, Feedback, KeyboardSensor, moveArrayItem, moveDragItem, PointerActivationConstraints, pointerDistance, pointerIntersection, PointerSensor, restrictShapeToBoundingRectangle, RestrictToElement, RestrictToHorizontalAxis, RestrictToVerticalAxis, RestrictToWindow, shapeIntersection, SnapModifier, swapArrayItem, swapDragItem, useDragDropMonitor, useDraggable, useDragOperation, useDroppable, useSortable, type BeforeDragStartEvent, type CollisionDetector, type CollisionEvent, type DragDropContextProps, type DragDropEventHandlers, type DragEndEvent, type DraggableChildrenFn, type DraggableId, type DraggableLocation, type DraggableProps, type DraggableProvided, type DraggableProvidedDraggableProps, type DraggableProvidedDragHandleProps, type DraggableRubric, type DraggableStateSnapshot, type DragMoveEvent, type DragOverEvent, type DragStartEvent, type DroppableId, type DroppableProps, type DroppableProvided, type DroppableProvidedProps, type DroppableStateSnapshot, type DropResult, type FeedbackInput, type FeedbackOptions, type FeedbackType, type OnBeforeCaptureResponder, type OnBeforeDragStartResponder, type OnDragEndResponder, type OnDragStartResponder, type OnDragUpdateResponder } from './dnd';
|
|
6
|
-
export type { ApiResult, AuthTokens, BodyEncoding, HttpClient, HttpClientOptions, HttpFileResponse, ProgressEvent, RequestOptions } from './http';
|
|
6
|
+
export type { ApiResult, AuthTokens, BodyEncoding, HttpClient, HttpClientOptions, HttpFileResponse, ProgressEvent, ProtectedBodyEncoding, ProtectedBodyEncodingOptions, RequestOptions } from './http';
|
|
7
7
|
export { BusinessError, isBusinessError, skipAuthenticationHeader, skipAuthenticationValue } from './http';
|
|
8
8
|
export { applyPatches, currentState, originalState, produce, produceWithPatches, useImmer, useImmerReducer } from './immer';
|
|
9
9
|
export { AnimatePresence, LayoutGroup, motion, MotionProvider, Reorder, useDragControls, useInView, type MotionProps, type ResolvedValues, type TargetAndTransition, type Transition, type Variant, type VariantLabels, type Variants } from './motion';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework-react/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Core features for VEF framework",
|
|
6
6
|
"keywords": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"use-immer": "^0.11.0",
|
|
58
58
|
"xstate": "^5.32.3",
|
|
59
59
|
"zustand": "^5.0.14",
|
|
60
|
-
"@vef-framework-react/shared": "2.
|
|
60
|
+
"@vef-framework-react/shared": "2.21.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"react": "^19.2.7"
|