whistle.mock-plugins 1.4.0-beta.3 → 1.4.0-beta.4
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/VERSION.md +15 -0
- package/app/public/js/198.index.js +2 -0
- package/app/public/js/26.index.js +2 -0
- package/app/public/js/{810.index.js.LICENSE.txt → 26.index.js.LICENSE.txt} +2 -0
- package/app/public/js/367.index.js +1 -0
- package/app/public/js/481.index.js +2 -0
- package/app/public/js/574.index.js +2 -0
- package/app/public/js/602.index.js +1 -0
- package/app/public/js/682.index.js +2 -0
- package/app/public/js/682.index.js.LICENSE.txt +1 -0
- package/app/public/js/737.index.js +2 -0
- package/app/public/js/index.js +1 -1
- package/package.json +11 -2
- package/app/public/js/11.index.js +0 -2
- package/app/public/js/296.index.js +0 -2
- package/app/public/js/704.index.js +0 -2
- package/app/public/js/807.index.js +0 -2
- package/app/public/js/810.index.js +0 -2
- /package/app/public/js/{704.index.js.LICENSE.txt → 198.index.js.LICENSE.txt} +0 -0
- /package/app/public/js/{11.index.js.LICENSE.txt → 481.index.js.LICENSE.txt} +0 -0
- /package/app/public/js/{807.index.js.LICENSE.txt → 574.index.js.LICENSE.txt} +0 -0
- /package/app/public/js/{296.index.js.LICENSE.txt → 737.index.js.LICENSE.txt} +0 -0
package/VERSION.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# 🔄 版本更新记录
|
|
2
2
|
|
|
3
|
+
## 1.4.0-beta.4(2026-11-04)
|
|
4
|
+
|
|
5
|
+
- UI 2.0 新增抓包列表侧栏入口,复用同一抓包页面并适配旧主题和移动端。
|
|
6
|
+
- UI 3.0 模块卡片全区域可进入接口,开关、编辑、导出和删除保持独立操作。
|
|
7
|
+
|
|
8
|
+
- 抓包列表改为无分页滚动,请求体/响应体 JSON 默认格式化,可切回原文;长整数原样保留,复制与保存使用原文。
|
|
9
|
+
- 新版导航增加 Whistle 抓包列表,支持增量同步、筛选、详情和保存/追加 Mock;同源读取现有会话,不重放源请求。
|
|
10
|
+
- 响应设置改为固定面板和受控展开,切换响应时复用面板,避免反复销毁重建。
|
|
11
|
+
|
|
12
|
+
- 响应编辑区升级为按需加载的代码编辑器,支持行号、JSON 折叠/展开、语法高亮、查找替换、换行、错误定位及撤销重做;全屏保留同一编辑器与历史。
|
|
13
|
+
- 新版接口编辑合并为同页布局,响应内容常驻,接口规则、响应选项和响应设置按需折叠。
|
|
14
|
+
- 移除详情中的简化真实响应录制标签,统一从接口嗅探获取真实响应,保留离开草稿提示。
|
|
15
|
+
- 保持响应下拉切换立即生效,新建接口自动展开必填配置。
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## 1.4.0-beta.3(2026-10-13)
|
|
4
19
|
|
|
5
20
|
- 响应下拉选择后直接切换默认响应并立即生效,无需额外保存接口;保留未保存草稿提示及失败回滚。
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 198.index.js.LICENSE.txt */
|
|
2
|
+
(self.webpackChunkwhistle_mock_plugins=self.webpackChunkwhistle_mock_plugins||[]).push([[198],{1019:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(6540),o=r(1847),a=r(770);function i(){var e="legacy"===localStorage.getItem("mm-ui-version")?"legacy":"modern";return n.createElement("div",{style:{marginBottom:24}},n.createElement(o.A.Title,{level:5},"界面版本"),n.createElement(a.Ay.Group,{value:e,onChange:function(e){localStorage.setItem("mm-ui-version",e.target.value),window.location.reload()},options:[{value:"modern",label:"UI 3.0 工作台"},{value:"legacy",label:"经典 UI 2.0"}]}),n.createElement(o.A.Paragraph,{type:"secondary",style:{marginTop:8}},"切换后刷新页面,两个界面共用原有模块、接口和同步数据。此偏好仅保存在当前浏览器。"))}},4677:(e,t,r)=>{"use strict";r.d(t,{N8:()=>l});var n=r(1083);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(){a=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",s=c.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,a=Object.create(o.prototype),c=new P(n||[]);return i(a,"_invoke",{value:T(e,r,c)}),a}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var m="suspendedStart",d="suspendedYield",y="executing",v="completed",g={};function b(){}function w(){}function x(){}var E={};f(E,u,(function(){return this}));var S=Object.getPrototypeOf,A=S&&S(S(_([])));A&&A!==r&&n.call(A,u)&&(E=A);var k=x.prototype=b.prototype=Object.create(E);function L(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(a,i,c,u){var l=h(e[a],e,i);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==o(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,c,u)}),(function(e){r("throw",e,c,u)})):t.resolve(f).then((function(e){s.value=e,c(s)}),(function(e){return r("throw",e,c,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function T(t,r,n){var o=m;return function(a,i){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=j(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===m)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=h(t,r,n);if("normal"===l.type){if(o=n.done?v:d,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=v,n.method="throw",n.arg=l.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function N(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function _(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(o(t)+" is not iterable")}return w.prototype=x,i(k,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:w,configurable:!0}),w.displayName=f(x,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,f(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},L(O.prototype),f(O.prototype,l,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new O(p(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},L(k),f(k,s,"Generator"),f(k,u,(function(){return this})),f(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=_,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(u&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function i(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){i(a,n,o,c,u,"next",e)}function u(e){i(a,n,o,c,u,"throw",e)}c(void 0)}))}}var u=function(){var e=c(a().mark((function e(){var t;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.A.get("/_flush_cache");case 3:return t=e.sent,e.abrupt("return",t.data);case 7:throw e.prev=7,e.t0=e.catch(0),console.error("刷新缓存失败:",e.t0),e.t0;case 11:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),l=function(){var e=c(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u();case 3:e.next=8;break;case 5:e.prev=5,e.t0=e.catch(0),console.error("刷新缓存失败,可能需要等待缓存自动过期:",e.t0);case 8:case"end":return e.stop()}}),e,null,[[0,5]])})));return function(){return e.apply(this,arguments)}}()},4807:e=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,r,n){return(r=function(e){var r=function(e){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var u=function(e){return JSON.parse(JSON.stringify(e))},l=function(){return"resp-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,10))},s=function(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,o=Array.isArray(r.responses)&&r.responses.length?u(r.responses).map((function(e,t){var r;return i(i({},e),{},{id:e.id||l(),name:e.name||"响应 ".concat(t+1),content:"string"==typeof e.content?e.content:JSON.stringify(null!==(r=e.content)&&void 0!==r?r:{}),paramMatchers:e.paramMatchers||[]})})):[{id:l(),name:"默认响应",content:null!==(e=r.responseContent)&&void 0!==e?e:'{\n "code": 0,\n "data": {}\n}',paramMatchers:[]}];return i(i({},u(r)),{},{featureId:r.featureId||n,name:r.name||"",group:"string"==typeof r.group?r.group:"",urlPattern:r.urlPattern||"",httpMethod:r.httpMethod||r.method||"ALL",proxyType:r.proxyType||"response",active:!1!==r.active,responses:o,activeResponseId:o.some((function(e){return e.id===r.activeResponseId}))?r.activeResponseId:o[0].id,httpStatus:r.httpStatus||200,responseDelay:null!==(t=r.responseDelay)&&void 0!==t?t:0,contentType:r.contentType||"application/json; charset=utf-8",headers:r.headers||{},customHeaders:r.customHeaders||{},paramMatchers:r.paramMatchers||[],filePath:r.filePath||"",targetUrl:r.targetUrl||""})};e.exports={clone:u,createId:l,normalizeInterface:s,duplicateInterface:function(e,t){var r=s(e,t),n=new Map;return r.responses=r.responses.map((function(e){var t=l();return n.set(e.id,t),i(i({},e),{},{id:t})})),r.activeResponseId=n.get(r.activeResponseId),r.paramMatchers=r.paramMatchers.map((function(e){return i(i({},e),e.targetResponseId?{targetResponseId:n.get(e.targetResponseId)||""}:{})})),delete r.id,r.name="".concat(r.name," - 副本"),r},filterInterfaces:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return e.filter((function(e){return(!r||e.group===r)&&"".concat(e.name," ").concat(e.urlPattern).toLowerCase().includes(t.toLowerCase())}))},visibleSelection:function(e,t){return e.filter((function(e){return t.some((function(t){return t.id===e}))}))},validateDraft:function(e){if(!e.name.trim())return"请输入接口名称";if(!e.urlPattern.trim())return"请输入 URL 匹配规则";if(e.urlPattern.length>2&&e.urlPattern.startsWith("/")&&e.urlPattern.endsWith("/"))try{new RegExp(e.urlPattern.slice(1,-1))}catch(e){return"URL 正则表达式无效:".concat(e.message)}if(!Number.isInteger(Number(e.httpStatus))||e.httpStatus<100||e.httpStatus>599)return"HTTP 状态码须为 100~599 的整数";if(!Number.isFinite(Number(e.responseDelay))||e.responseDelay<0)return"延迟须为非负数";if(["redirect","url_redirect"].includes(e.proxyType))try{var t=new URL(e.targetUrl);if(!["http:","https:"].includes(t.protocol))return"目标地址仅支持 HTTP / HTTPS"}catch(e){return"请输入完整有效的目标 URL"}if("file"===e.proxyType&&!e.filePath.trim())return"请输入本地文件路径";if("response"===e.proxyType&&e.contentType.includes("json")){var o,a=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=n(e))){t&&(e=t);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(c)throw a}}}}(e.responses);try{for(a.s();!(o=a.n()).done;){var i=o.value;try{JSON.parse(i.content)}catch(e){return"响应「".concat(i.name,"」JSON 格式有误:").concat(e.message)}}}catch(e){a.e(e)}finally{a.f()}}if(e.paramMatchers.some((function(t){return t.targetResponseId&&!e.responses.some((function(e){return e.id===t.targetResponseId}))})))return"接口匹配条件引用了已删除的响应,请修改目标响应";if(e.responses.length&&!e.responses.some((function(t){return t.id===e.activeResponseId})))return"请选择有效的默认响应";for(var c=0,u=[].concat(r(e.paramMatchers),r(e.responses.flatMap((function(e){return e.paramMatchers||[]}))));c<u.length;c++){var l=u[c];if(!l.paramPath||void 0===l.paramValue||""===l.paramValue)return"请补全参数匹配规则或删除空行";if("regex"===l.matchType)try{new RegExp(l.paramValue)}catch(e){return"参数匹配规则中的正则表达式无效"}}return null}}},4956:(e,t,r)=>{"use strict";r.d(t,{A:()=>X});var n=r(6540),o=r(7260),a=r(770),i=r(2941),c=r(1847),u=r(3217),l=r(6914),s=r(277),f=r(9957),p=r(5739),h=r(9924),m=r(7308),d=r(6143),y=r(2702),v=r(4716),g=r(1357),b=r(5132),w=r(581),x=r(7345),E=r(1083),S=r(7004),A=r(9820),k=r(6857),L=r(8333),O=r(9637),T=r(5072),j=r.n(T),N=r(7825),I=r.n(N),P=r(7659),_=r.n(P),C=r(5056),M=r.n(C),G=r(540),R=r.n(G),F=r(1113),q=r.n(F),W=r(8233),D={};function z(e){return z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},z(e)}function U(){U=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,i=Object.create(a.prototype),c=new N(n||[]);return o(i,"_invoke",{value:L(e,r,c)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=s;var p="suspendedStart",h="suspendedYield",m="executing",d="completed",y={};function v(){}function g(){}function b(){}var w={};l(w,i,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(I([])));E&&E!==r&&n.call(E,i)&&(w=E);var S=b.prototype=v.prototype=Object.create(w);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(o,a,i,c){var u=f(e[o],e,a);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==z(s)&&n.call(s,"__await")?t.resolve(s.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(s).then((function(e){l.value=e,i(l)}),(function(e){return r("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function L(t,r,n){var o=p;return function(a,i){if(o===m)throw Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=O(c,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=m;var l=f(t,r,n);if("normal"===l.type){if(o=n.done?d:h,l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function O(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=f(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(z(t)+" is not iterable")}return g.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=l(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,l(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},t.awrap=function(e){return{__await:e}},A(k.prototype),l(k.prototype,c,(function(){return this})),t.AsyncIterator=k,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new k(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},A(S),l(S,u,"Generator"),l(S,i,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(j),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(u&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),j(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function J(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function H(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){J(a,n,o,i,c,"next",e)}function c(e){J(a,n,o,i,c,"throw",e)}i(void 0)}))}}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Y(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Y(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}D.styleTagTransform=q(),D.setAttributes=M(),D.insert=_().bind(null,"head"),D.domAPI=I(),D.insertStyleElement=R(),j()(W.A,D),W.A&&W.A.locals&&W.A.locals;var V=function(e){return null==e?"—":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB")},$=function(e){return e?new Date(e).toLocaleTimeString():"—"};function K(e){var t=e.body,r=e.onCopy,u=B((0,n.useState)("pretty"),2),l=u[0],s=u[1],f=(0,n.useMemo)((function(){return t.available?(0,O.formatJSONForDisplay)(t.text):null}),[t.available,t.text]);return t.available?n.createElement("div",null,n.createElement("div",{className:"mm-capture-body-tools"},n.createElement(a.Ay.Group,{size:"small","aria-label":"正文展示方式",optionType:"button",buttonStyle:"solid",value:f.available?l:"raw",onChange:function(e){return s(e.target.value)},options:[{value:"pretty",label:"格式化",disabled:!f.available},{value:"raw",label:"原文"}]}),n.createElement(i.Ay,{size:"small",onClick:r},"复制原文"),n.createElement(c.A.Text,{type:"secondary"},f.available?"仅调整展示,复制与保存使用原文":f.reason)),n.createElement("pre",{className:"mm-capture-body"},(f.available&&"pretty"===l?f.text:t.text)||"(空内容)")):n.createElement(o.A,{type:"warning",showIcon:!0,message:t.reason})}function X(){var e,t,r,a=u.A.useApp().message,O=B((0,n.useState)([]),2),T=O[0],j=O[1],N=B((0,n.useState)(!0),2),I=N[0],P=N[1],_=B((0,n.useState)(!0),2),C=_[0],M=_[1],G=B((0,n.useState)(""),2),R=G[0],F=G[1],q=B((0,n.useState)(null),2),W=q[0],D=q[1],z=B((0,n.useState)(0),2),J=z[0],Y=z[1],X=B((0,n.useState)(""),2),Q=X[0],Z=X[1],ee=B((0,n.useState)("ALL"),2),te=ee[0],re=ee[1],ne=B((0,n.useState)("all"),2),oe=ne[0],ae=ne[1],ie=(0,n.useRef)(),ce=(0,n.useRef)(),ue=(0,n.useRef)([]),le=(0,n.useRef)(0),se=(0,n.useRef)(null),fe=B((0,n.useState)(300),2),pe=fe[0],he=fe[1],me=B((0,n.useState)(null),2),de=me[0],ye=me[1],ve=B((0,n.useState)(null),2),ge=ve[0],be=ve[1],we=B((0,n.useState)(""),2),xe=we[0],Ee=we[1],Se=B((0,n.useState)(!1),2),Ae=Se[0],ke=Se[1],Le=B((0,n.useState)(0),2),Oe=Le[0],Te=Le[1],je=B((0,n.useState)(null),2),Ne=je[0],Ie=je[1];(0,n.useEffect)((function(){var e=se.current;if(e){var t=new ResizeObserver((function(){return he(Math.max(80,e.clientHeight-60))}));return t.observe(e),function(){return t.disconnect()}}}),[]),(0,n.useEffect)((function(){if(I){var e,t,r=!1,n=le.current,o=function(){var a=H(U().mark((function a(){var i,c;return U().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(!r){a.next=2;break}return a.abrupt("return");case 2:if(!document.hidden){a.next=5;break}return e=setTimeout(o,2e3),a.abrupt("return");case 5:return t=new AbortController,i=!1,a.prev=7,a.next=10,(0,k.fetchNetwork)(ie.current,ue.current,t.signal);case 10:if(c=a.sent,!r&&n===le.current){a.next=13;break}return a.abrupt("return");case 13:c.cursor&&(ie.current=c.cursor),c.endId&&(ce.current=c.endId),j((function(e){var t=(0,L.mergeRows)(e,c.rows);return ue.current=t.filter((function(e){return!e.endTime&&!e.reqError&&!e.resError})).slice(0,25).map((function(e){return e.id})),t})),D(Date.now()),F(""),i=c.hasNew,a.next=24;break;case 21:a.prev=21,a.t0=a.catch(7),r||n!==le.current||E.A.isCancel(a.t0)||(F(a.t0.message),P(!1));case 24:return a.prev=24,r||n!==le.current||(M(!1),e=setTimeout(o,i?200:2500)),a.finish(24);case 27:case"end":return a.stop()}}),a,null,[[7,21,24,27]])})));return function(){return a.apply(this,arguments)}}();return o(),function(){var n;r=!0,clearTimeout(e),null===(n=t)||void 0===n||n.abort()}}M(!1)}),[I,J]);var Pe=T.find((function(e){return e.id===de}));(0,n.useEffect)((function(){if(de){var e=!0,t=new AbortController;return be(null),Ee(""),ke(!0),(0,k.fetchSession)(de,t.signal).then((function(t){e&&be((0,L.sessionDetail)(t))})).catch((function(t){e&&!E.A.isCancel(t)&&Ee(t.message)})).finally((function(){e&&ke(!1)})),function(){e=!1,t.abort()}}be(null)}),[de,null==Pe?void 0:Pe.endTime,Oe]);var _e=(0,n.useMemo)((function(){return T.filter((function(e){var t=Number(e.status),r=e.reqError||e.resError;return(!Q||String(e.url||"").toLowerCase().includes(Q.toLowerCase()))&&("ALL"===te||e.method===te)&&("all"===oe||("pending"===oe?!e.endTime&&!r:"error"===oe?r||t>=400:Math.floor(t/100)===Number(oe)))}))}),[T,Q,te,oe]),Ce=function(e){le.current++,ue.current=[],j([]),ye(null),F(""),ie.current=e?void 0:ce.current||ie.current,e&&(ce.current=void 0,M(!0),P(!0)),Y((function(e){return e+1}))},Me=function(){var e=H(U().mark((function e(t){return U().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.clipboard.writeText(t);case 3:a.success("已复制"),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),a.error("复制失败,请手动选择文本");case 9:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t){return e.apply(this,arguments)}}(),Ge=[{title:"时间",dataIndex:"startTime",width:100,render:$},{title:"方法",dataIndex:"method",width:85,render:function(e){return n.createElement(l.A,null,e||"—")}},{title:"状态",width:95,render:function(e,t){return n.createElement(l.A,{color:t.reqError||t.resError||Number(t.status)>=400?"error":Number(t.status)>=200?"success":"default"},t.reqError||t.resError?"传输错误":t.status||"进行中")}},{title:"URL",dataIndex:"url",ellipsis:!0,render:function(e,t){return n.createElement("button",{className:"mm-network-url",title:e,onClick:function(){return ye(t.id)}},e||t.id)}},{title:"耗时",width:90,render:function(e,t){return t.endTime?"".concat(Math.max(0,t.endTime-t.startTime)," ms"):"—"}},{title:"大小",dataIndex:"size",width:85,render:V},{title:"类型",dataIndex:"contentType",width:180,ellipsis:!0,render:function(e){return e||"—"}}],Re=function(e){var t;return n.createElement(s.A,{items:[{key:"body",label:"内容",children:n.createElement(K,{key:"".concat(ge.session.id,"-").concat(e),body:ge["req"===e?"request":"response"],onCopy:function(){return Me(ge["req"===e?"request":"response"].text)}})},{key:"headers",label:"Headers",children:n.createElement("pre",{className:"mm-capture-body"},JSON.stringify((null===(t=ge.session[e])||void 0===t?void 0:t.headers)||{},null,2))}]})};return n.createElement("div",{className:"mm-network-page"},n.createElement(S.A,{kicker:"WHISTLE NETWORK",title:"抓包列表",description:"查看 Whistle 已捕获的请求,直接将响应转为 Mock,无需重新发送。",actions:n.createElement(n.Fragment,null,n.createElement(i.Ay,{icon:I?n.createElement(g.A,null):n.createElement(b.A,null),onClick:function(){return P((function(e){return!e}))}},I?"暂停同步":"继续同步"),n.createElement(i.Ay,{"aria-label":"重新载入最近请求",icon:n.createElement(w.A,null),onClick:function(){return Ce(!0)}}),n.createElement(i.Ay,{icon:n.createElement(x.A,null),onClick:function(){return Ce(!1)}},"清空本页"))}),R&&n.createElement(o.A,{type:"error",showIcon:!0,message:R,action:n.createElement(i.Ay,{onClick:function(){F(""),P(!0),Y((function(e){return e+1}))}},"重试连接")}),n.createElement("div",{className:"mm-network-controls"},n.createElement(f.A.Search,{"aria-label":"搜索抓包 URL",placeholder:"搜索 URL",allowClear:!0,value:Q,onChange:function(e){return Z(e.target.value)}}),n.createElement(p.A,{"aria-label":"筛选请求方法",value:te,onChange:re,options:["ALL","GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","CONNECT"].map((function(e){return{value:e,label:"ALL"===e?"全部方法":e}}))}),n.createElement(p.A,{"aria-label":"筛选请求状态",value:oe,onChange:ae,options:[["all","全部状态"],["2","2xx"],["3","3xx"],["4","4xx"],["5","5xx"],["pending","进行中"],["error","错误请求"]].map((function(e){var t=B(e,2);return{value:t[0],label:t[1]}}))}),n.createElement("span",{className:"mm-network-state"},_e.length," / ",T.length," 条 · ",I&&!R?"同步中":"已暂停",W?" · ".concat($(W)):"")),n.createElement(c.A.Text,{type:"secondary",className:"mm-network-note"},"仅保留本页最近 ",L.MAX_ROWS," 条,单页滚动;首次载入最近 50 条,后续增量同步。清空本页不影响 Whistle 的 Network 记录。"),n.createElement("div",{className:"mm-network-table",ref:se},n.createElement(h.A,{rowKey:"id",size:"small",loading:C,dataSource:_e,columns:Ge,scroll:{x:1e3,y:pe},pagination:!1,locale:{emptyText:n.createElement(m.A,{description:R?"连接 Whistle 后查看抓包数据":"暂无匹配请求,请确认请求已经过 Whistle 代理"})}})),n.createElement(d.A,{title:"抓包详情",open:!!de,onClose:function(){return ye(null)},width:"min(900px, 100vw)",extra:n.createElement(i.Ay,{"aria-label":"刷新抓包详情",icon:n.createElement(w.A,null),onClick:function(){return Te((function(e){return e+1}))}}),footer:n.createElement(y.A,{wrap:!0},n.createElement(i.Ay,{disabled:!(null!=ge&&ge.canSave),type:"primary",onClick:function(){var e;null!=ge&&ge.canSave&&Ie({status:Number(ge.session.res.statusCode),headers:ge.session.res.headers||{},body:ge.response.text,request:{url:ge.session.url,method:(null===(e=ge.session.req)||void 0===e?void 0:e.method)||"GET"}})}},"保存为 Mock"),n.createElement(i.Ay,{disabled:!(null!=ge&&ge.response.available),onClick:function(){return Me(ge.response.text)}},"复制响应体"))},n.createElement(v.A,{spinning:Ae},xe&&n.createElement(o.A,{type:"error",message:xe,action:n.createElement(i.Ay,{onClick:function(){return Te((function(e){return e+1}))}},"重试")}),ge&&n.createElement(n.Fragment,null,n.createElement("div",{className:"mm-network-detail-url"},n.createElement(l.A,null,null===(e=ge.session.req)||void 0===e?void 0:e.method),n.createElement(l.A,null,(null===(t=ge.session.res)||void 0===t?void 0:t.statusCode)||"进行中"),n.createElement(c.A.Text,{copyable:!0},ge.session.url)),!ge.canSave&&ge.reason!==ge.response.reason&&n.createElement(o.A,{className:"mm-error",type:"warning",showIcon:!0,message:ge.reason}),n.createElement(s.A,{items:[{key:"response",label:"响应",children:Re("res")},{key:"request",label:"请求",children:Re("req")},{key:"overview",label:"概览",children:n.createElement("div",{className:"mm-network-overview"},n.createElement("p",null,"请求 ID:",ge.session.id),n.createElement("p",null,"开始时间:",new Date(ge.session.startTime).toLocaleString()),n.createElement("p",null,"耗时:",ge.session.endTime?"".concat(ge.session.endTime-ge.session.startTime," ms"):"进行中"),n.createElement("p",null,"响应大小:",V(null===(r=ge.session.res)||void 0===r?void 0:r.size)),n.createElement("p",null,"说明:数据来自 Whistle 内存缓存;未做重放,WebSocket 帧请在 Whistle 中查看。"))}]})))),n.createElement(A.A,{open:!!Ne,onClose:function(){return Ie(null)},response:Ne,initialActive:!1,source:"Whistle Network"}))}},6857:(e,t,r)=>{function n(){"use strict";n=function(){return t};var e,t={},r=Object.prototype,a=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",l=c.asyncIterator||"@@asyncIterator",s=c.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(e){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,a=Object.create(o.prototype),c=new P(n||[]);return i(a,"_invoke",{value:T(e,r,c)}),a}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=p;var m="suspendedStart",d="suspendedYield",y="executing",v="completed",g={};function b(){}function w(){}function x(){}var E={};f(E,u,(function(){return this}));var S=Object.getPrototypeOf,A=S&&S(S(_([])));A&&A!==r&&a.call(A,u)&&(E=A);var k=x.prototype=b.prototype=Object.create(E);function L(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(n,i,c,u){var l=h(e[n],e,i);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==o(f)&&a.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,c,u)}),(function(e){r("throw",e,c,u)})):t.resolve(f).then((function(e){s.value=e,c(s)}),(function(e){return r("throw",e,c,u)}))}u(l.arg)}var n;i(this,"_invoke",{value:function(e,o){function a(){return new t((function(t,n){r(e,o,t,n)}))}return n=n?n.then(a,a):a()}})}function T(t,r,n){var o=m;return function(a,i){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=j(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===m)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=h(t,r,n);if("normal"===l.type){if(o=n.done?v:d,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=v,n.method="throw",n.arg=l.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function N(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function _(t){if(t||""===t){var r=t[u];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(a.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(o(t)+" is not iterable")}return w.prototype=x,i(k,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:w,configurable:!0}),w.displayName=f(x,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,f(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},L(O.prototype),f(O.prototype,l,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new O(p(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},L(k),f(k,s,"Generator"),f(k,u,(function(){return this})),f(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=_,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function c(e){a(i,n,o,c,u,"next",e)}function u(e){a(i,n,o,c,u,"throw",e)}c(void 0)}))}}var c=r(6425),u=r(8333).summarize,l="/whistle/cgi-bin/",s=function(e){var t,r=null===(t=e.response)||void 0===t?void 0:t.status;return new Error(401===r||403===r?"Whistle 需要登录:请先在同一浏览器打开 Whistle 并登录,再重试。":e.message||"无法读取 Whistle 抓包数据")};function f(){return(f=i(n().mark((function e(t,r,a){var i,f,p;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c.get(l+"get-data",{signal:a,timeout:15e3,params:{count:50,startTime:t||void 0,ids:r.join(",")||void 0,status:r.map((function(){return"--"})).join(",")||void 0,startLogTime:-3,startSvrLogTime:-3}});case 3:if(i=e.sent,0===(null==(f=i.data)?void 0:f.ec)&&f.data&&f.data.data&&"object"===o(f.data.data)&&!Array.isArray(f.data.data)){e.next=7;break}throw new Error("当前页面未连接到兼容的 Whistle Network API,请从 Whistle 插件页面打开。");case 7:return p=f.data,e.abrupt("return",{rows:Object.values(p.data).filter((function(e){return e&&"object"===o(e)})).map(u),cursor:p.lastId,endId:p.endId,hasNew:!!p.hasNew});case 11:if(e.prev=11,e.t0=e.catch(0),!c.isCancel(e.t0)){e.next=15;break}throw e.t0;case 15:throw s(e.t0);case 16:case"end":return e.stop()}}),e,null,[[0,11]])})))).apply(this,arguments)}function p(){return(p=i(n().mark((function e(t,r){var a,i;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c.get(l+"get-session",{signal:r,timeout:15e3,params:{reqList:JSON.stringify([t]),resList:JSON.stringify([t])}});case 3:if(a=e.sent,(i=a.data)&&"object"===o(i)&&!Array.isArray(i)){e.next=7;break}throw new Error("无法读取 Whistle 请求详情。");case 7:if(0!==i[t]){e.next=9;break}throw new Error("该请求已从 Whistle 缓存中移除,无法读取原始内容。");case 9:if(i[t]&&"object"===o(i[t])&&i[t].id===t){e.next=11;break}throw new Error("请求详情暂未就绪,请稍后刷新。");case 11:return e.abrupt("return",i[t]);case 14:if(e.prev=14,e.t0=e.catch(0),!c.isCancel(e.t0)){e.next=18;break}throw e.t0;case 18:throw s(e.t0);case 19:case"end":return e.stop()}}),e,null,[[0,14]])})))).apply(this,arguments)}e.exports={fetchNetwork:function(e,t,r){return f.apply(this,arguments)},fetchSession:function(e,t){return p.apply(this,arguments)}}},7004:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var n=r(6540);function o(e){var t=e.title,r=e.description,o=e.kicker,a=e.actions;return n.createElement("div",{className:"mm-page-header"},n.createElement("div",null,o&&n.createElement("div",{className:"mm-page-kicker"},o),n.createElement("h1",null,t),r&&n.createElement("p",null,r)),a&&n.createElement("div",{className:"page-actions"},a))}},8233:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var n=r(1601),o=r.n(n),a=r(6314),i=r.n(a)()(o());i.push([e.id,".mm-app-network { height:100vh; height:100dvh; min-height:0; display:flex; flex-direction:column; overflow:hidden; }\n.mm-app-network .mm-app-header { flex-shrink:0; }\n.mm-app-main-network { flex:1; min-height:0; width:100%; max-width:none; margin:0; overflow:hidden; display:flex; flex-direction:column; }\n.mm-network-page { display:flex; flex-direction:column; flex:1; min-height:0; gap:14px; }\n.mm-network-page .mm-page-header { margin:0; flex-shrink:0; }\n.mm-network-controls { display:flex; flex-wrap:wrap; gap:8px; align-items:center; flex-shrink:0; }\n.mm-network-controls>.ant-input-search { width:360px; max-width:100%; flex:1; min-width:150px; }\n.mm-network-controls>.ant-select { width:120px; }\n.mm-network-state,.mm-network-note { color:var(--mm-muted); font-size:12px; }\n.mm-network-note { flex-shrink:0; }\n.mm-network-table { flex:1; min-height:0; overflow:auto; }\n.mm-network-url { border:0; background:none; color:var(--mm-primary); text-align:left; font:inherit; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; display:block; }\n.mm-network-detail-url { display:flex; align-items:flex-start; flex-wrap:wrap; gap:8px; margin-bottom:16px; }\n.mm-network-detail-url .ant-typography { overflow-wrap:anywhere; }\n.mm-capture-body { white-space:pre-wrap; overflow-wrap:anywhere; max-height:60vh; overflow:auto; background:var(--mm-bg); border:1px solid var(--mm-border); color:var(--mm-text); padding:14px; border-radius:6px; font:12px/1.8 'SFMono-Regular',Consolas,monospace; }\n.mm-network-overview { overflow-wrap:anywhere; color:var(--mm-text); }\n@media(max-width:480px) { .mm-network-page { gap:10px; }.mm-network-controls>.ant-input-search { flex-basis:100%; }.mm-network-state { flex-basis:100%; }.mm-network-controls>.ant-select { flex:1; } }\n\n.mm-capture-body-tools { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:10px; }.mm-capture-body-tools>.ant-typography { font-size:12px; }\n\n.mm-network-page .mm-page-header { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }\n.mm-network-page .mm-page-header h1 { margin:0 0 5px; color:var(--mm-text); font-size:23px; }\n.mm-network-page .mm-page-header p { margin:0; color:var(--mm-muted); font-size:13px; }\n.mm-network-page .mm-page-kicker { margin-bottom:6px; color:var(--mm-muted); font-size:11px; letter-spacing:1.5px; }\n.mm-network-page .page-actions,.mm-save-footer { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }\n.mm-save-footer { justify-content:space-between; }\n",""]);const c=i},8333:e=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,r,n){return(r=function(e){var r=function(e){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function a(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var c=5242880,u=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return(null===(e=Object.entries(t||{}).find((function(e){return(t=e,n=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(t,n)||a(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0].toLowerCase()===r.toLowerCase();var t,n})))||void 0===e?void 0:e[1])||""},l=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";e=e||{};var r,o=String(u(e.headers,"content-type")),a={text:"",available:!1,reason:"",contentType:o},i=o.split(";")[0].trim().toLowerCase();if(i&&!/^text\//.test(i)&&!/json|xml|javascript|x-www-form-urlencoded|graphql/.test(i))return n(n({},a),{},{reason:"二进制或不支持的内容类型,请在 Whistle 中查看或下载。"});try{var l,s,f,p;if("string"==typeof e.base64&&e.base64.length){if(e.base64.length>Math.ceil(20971520/3)+4)return n(n({},a),{},{reason:"内容超过 5 MB,请在 Whistle 中查看或下载。"});r=Uint8Array.from(atob(e.base64),(function(e){return e.charCodeAt(0)}))}else if("Buffer"===(null===(l=e.body)||void 0===l?void 0:l.type)&&Array.isArray(e.body.data)){if(e.body.data.length>c)return n(n({},a),{},{reason:"内容超过 5 MB,请在 Whistle 中查看或下载。"});r=Uint8Array.from(e.body.data)}else r="string"==typeof e.body?(new TextEncoder).encode(e.body):new Uint8Array;if(r.length>c)return n(n({},a),{},{reason:"内容超过 5 MB,请在 Whistle 中查看或下载。"});if(e.hasGzipError)return n(n({},a),{},{reason:"Whistle 解压响应失败,无法确认内容完整。"});var h=Number(null!==(s=null!==(f=e.unzipSize)&&void 0!==f?f:e.size)&&void 0!==s?s:0),m="HEAD"===t||[204,304].includes(Number(e.statusCode));if(!m&&h>0&&0===r.length)return n(n({},a),{},{reason:"Whistle 未保留此请求/响应体,可能被清除或超过抓包大小限制。"});if(!m&&h>r.length&&(void 0!==e.unzipSize||!u(e.headers,"content-encoding")))return n(n({},a),{},{reason:"捕获内容不完整,不能作为完整 Mock 保存。"});var d=(null===(p=/charset\s*=\s*["']?([^;\s"']+)/i.exec(o))||void 0===p?void 0:p[1])||"utf-8",y="string"!=typeof e.body||e.base64?new TextDecoder(d,{fatal:!0}).decode(r):e.body;return/[\x00-\x08\x0e-\x1f]/.test(y)?n(n({},a),{},{reason:"包含二进制数据,不能作为文本 Mock 保存。"}):n(n({},a),{},{available:!0,text:y})}catch(e){return n(n({},a),{},{reason:"内容编码无效或暂不支持,不能按文本导入。"})}};e.exports={MAX_ROWS:500,MAX_BODY_BYTES:c,header:u,summarize:function(e){for(var t,r,n,o,a={id:e.id},i=0,c=["url","startTime","endTime","requestTime","responseTime","reqError","resError"];i<c.length;i++){var l=c[i];void 0!==e[l]&&(a[l]=e[l])}null!==(t=e.req)&&void 0!==t&&t.method&&(a.method=e.req.method),void 0!==(null===(r=e.res)||void 0===r?void 0:r.statusCode)&&(a.status=e.res.statusCode),void 0!==(null===(n=e.res)||void 0===n?void 0:n.size)&&(a.size=e.res.size);var s=u(null===(o=e.res)||void 0===o?void 0:o.headers,"content-type");return s&&(a.contentType=s),a},mergeRows:function(e,t){var r,o,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,u=new Map(e.map((function(e){return[e.id,e]}))),l=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=a(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){c=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(c)throw o}}}}(t);try{for(l.s();!(r=l.n()).done;){var s=r.value;null!=s&&s.id&&u.set(s.id,n(n({},u.get(s.id)),s))}}catch(e){l.e(e)}finally{l.f()}return(o=u.values(),function(e){if(Array.isArray(e))return i(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||a(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).sort((function(e,t){return(t.startTime||0)-(e.startTime||0)||String(t.id).localeCompare(String(e.id))})).slice(0,c)},decodeBody:l,sessionDetail:function(e){var t,r,n,o=l(e.req),a=l(e.res,null===(t=e.req)||void 0===t?void 0:t.method),i=/^https?:\/\//i.test(e.url||"")&&"CONNECT"!==(null===(r=e.req)||void 0===r?void 0:r.method),c=Number(null===(n=e.res)||void 0===n?void 0:n.statusCode),u=c>=200&&c<=599,s=!!e.endTime&&!e.resError&&!e.reqError;return{session:e,request:o,response:a,canSave:i&&u&&s&&a.available,reason:i&&101!==c?s?u?a.reason:"没有可用的 HTTP 响应状态,无法转为 Mock。":"请求尚未结束或发生传输错误,请等待或刷新详情。":"当前仅支持 HTTP/HTTPS 文本响应转为 Mock。"}}}},9637:e=>{var t=2097152;e.exports={formatJSONForDisplay:function(e){var r=function(t){return{available:!1,text:e,reason:t}};if(!e)return r("空内容");if(e.length>t)return r("内容较大,显示原文");try{JSON.parse(e)}catch(e){return r("非 JSON 或 JSON 格式无效,显示原文")}for(var n="",o=0,a=!1,i=!1,c="",u=function(){return"\n"+" ".repeat(o)},l=0;l<e.length;l++){var s=e[l];if(a)n+=s,i?i=!1:"\\"===s?i=!0:'"'===s&&(a=!1);else{if(/\s/.test(s))continue;if('"'===s)a=!0,n+=s;else if("{"===s||"["===s){if(n+=s,++o>100)return r("嵌套较深,显示原文");for(var f=l+1;/\s/.test(e[f]||"")&&f<e.length;)f++;e[f]!==("{"===s?"}":"]")&&(n+=u())}else"}"===s||"]"===s?(o--,c!==("}"===s?"{":"[")&&(n+=u()),n+=s):n+=","===s?","+u():":"===s?": ":s}if(c=s,n.length>t)return r("格式化后内容较大,显示原文")}return{available:!0,text:n,reason:""}}}},9820:(e,t,r)=>{"use strict";r.d(t,{A:()=>E});var n=r(6540),o=r(3217),a=r(5895),i=r(6143),c=r(2941),u=r(7260),l=r(5739),s=r(9957),f=r(2609),p=r(1847),h=r(1083),m=r(4807),d=r(4677);function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function v(){v=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var a=t&&t.prototype instanceof b?t:b,i=Object.create(a.prototype),c=new P(n||[]);return o(i,"_invoke",{value:T(e,r,c)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=s;var p="suspendedStart",h="suspendedYield",m="executing",d="completed",g={};function b(){}function w(){}function x(){}var E={};l(E,i,(function(){return this}));var S=Object.getPrototypeOf,A=S&&S(S(_([])));A&&A!==r&&n.call(A,i)&&(E=A);var k=x.prototype=b.prototype=Object.create(E);function L(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(o,a,i,c){var u=f(e[o],e,a);if("throw"!==u.type){var l=u.arg,s=l.value;return s&&"object"==y(s)&&n.call(s,"__await")?t.resolve(s.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(s).then((function(e){l.value=e,i(l)}),(function(e){return r("throw",e,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function T(t,r,n){var o=p;return function(a,i){if(o===m)throw Error("Generator is already running");if(o===d){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=j(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=m;var l=f(t,r,n);if("normal"===l.type){if(o=n.done?d:h,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=d,n.method="throw",n.arg=l.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=f(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function N(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function _(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(y(t)+" is not iterable")}return w.prototype=x,o(k,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:w,configurable:!0}),w.displayName=l(x,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,l(e,u,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},L(O.prototype),l(O.prototype,c,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new O(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},L(k),l(k,u,"Generator"),l(k,i,(function(){return this})),l(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=_,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),l=n.call(i,"finallyLoc");if(u&&l){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!l)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:_(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function g(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(e,t)||w(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){if(e){if("string"==typeof e)return x(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function E(e){var t=e.open,r=e.onClose,y=e.response,E=e.initialActive,S=void 0===E||E,A=e.source,k=void 0===A?"真实接口录制":A,L=o.A.useApp().message,O=b(a.A.useForm(),1)[0],T=b((0,n.useState)([]),2),j=T[0],N=T[1],I=b((0,n.useState)([]),2),P=I[0],_=I[1],C=b((0,n.useState)("new"),2),M=C[0],G=C[1],R=b((0,n.useState)(!1),2),F=R[0],q=R[1],W=b((0,n.useState)(""),2),D=W[0],z=W[1],U=b((0,n.useState)(0),2),J=U[0],H=U[1],B=a.A.useWatch("featureId",O);(0,n.useEffect)((function(){var e,r,n;if(t){var o=!0;G("new"),z(""),N([]),_([]),O.resetFields();var a=(null==y||null===(e=y.request)||void 0===e?void 0:e.url)||"";try{a=new URL(a).pathname}catch(e){}return O.setFieldsValue({urlPattern:a,name:a?"".concat((null==y||null===(r=y.request)||void 0===r?void 0:r.method)||"GET"," ").concat(a):"",active:S,contentType:String((null===(n=Object.entries((null==y?void 0:y.headers)||{}).find((function(e){return"content-type"===b(e,1)[0].toLowerCase()})))||void 0===n?void 0:n[1])||"text/plain; charset=utf-8").replace(/charset\s*=\s*["']?[^;\s"']+["']?/i,"charset=utf-8")}),h.A.get("/cgi-bin/features").then((function(e){var t,r=e.data;if(o){if(0!==r.code)throw new Error(r.message);N(r.data||[]),O.setFieldValue("featureId",null===(t=r.data)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.id)}})).catch((function(e){o&&z(e.message||"获取模块失败")})),function(){o=!1}}}),[t,J]),(0,n.useEffect)((function(){if(t&&B){var e=!0;return _([]),O.setFieldValue("interfaceId",void 0),h.A.get("/cgi-bin/interfaces",{params:{featureId:B}}).then((function(t){var r=t.data;if(e){if(0!==r.code)throw new Error(r.message);_((r.data||[]).filter((function(e){return"response"===e.proxyType||!e.proxyType})))}})).catch((function(t){e&&L.error(t.message||"读取接口失败")})),function(){e=!1}}}),[B,t]);var Y=function(){var e,t=(e=v().mark((function e(){var t,n,o,a,i,c,u,l,s,f,p,g,b,E;return v().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!F){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,O.validateFields();case 5:if(t=e.sent,y&&!y.incomplete&&"string"==typeof y.body){e.next=8;break}throw new Error("没有完整的文本响应,无法保存");case 8:if(q(!0),n=(0,m.createId)(),o={id:n,name:"append"===M?t.name:"默认响应",description:"来自".concat(k),content:y.body,paramMatchers:[]},"append"!==M){e.next=35;break}return e.next=14,h.A.get("/cgi-bin/interfaces",{params:{featureId:t.featureId}});case 14:if(0===(u=e.sent).data.code){e.next=17;break}throw new Error(u.data.message);case 17:if((l=u.data.data.find((function(e){return e.id===t.interfaceId})))&&(!l.proxyType||"response"===l.proxyType)){e.next=20;break}throw new Error("目标接口不存在或不是模拟响应模式");case 20:if(null===(i=l.contentType)||void 0===i||!i.toLowerCase().includes("json")){e.next=28;break}e.prev=21,JSON.parse(o.content),e.next=28;break;case 25:throw e.prev=25,e.t0=e.catch(21),new Error("目标接口使用 JSON,但当前响应不是有效 JSON,请改为创建纯文本 Mock。");case 28:return s=null!==(c=l.responses)&&void 0!==c&&c.length?l.responses:[{id:(0,m.createId)(),name:"默认响应",content:l.responseContent||"{}",paramMatchers:[]}],e.next=31,h.A.patch("/cgi-bin/interfaces/".concat(l.id),{responses:[].concat((v=s,function(e){if(Array.isArray(e))return x(e)}(v)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||w(v)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),[o]),activeResponseId:l.activeResponseId||s[0].id});case 31:f=e.sent,a=f.data,e.next=48;break;case 35:if(!(g=t.contentType||"text/plain; charset=utf-8").toLowerCase().includes("json")){e.next=44;break}e.prev=37,JSON.parse(o.content),e.next=44;break;case 41:throw e.prev=41,e.t1=e.catch(37),new Error("响应不是有效 JSON,可将 Content-Type 改为 text/plain 后保存。");case 44:return e.next=46,h.A.post("/cgi-bin/interfaces",{name:t.name,featureId:t.featureId,urlPattern:t.urlPattern,httpMethod:(null===(p=y.request)||void 0===p?void 0:p.method)||"GET",proxyType:"response",httpStatus:Number(y.status)||200,contentType:g,active:t.active,responseContent:o.content,responses:[o],activeResponseId:n});case 46:b=e.sent,a=b.data;case 48:if(0===a.code){e.next=50;break}throw new Error(a.message);case 50:return e.next=52,(0,d.N8)();case 52:L.success("append"===M?"已追加响应(默认响应未切换)":"已创建 Mock 接口"),r(),e.next=59;break;case 56:e.prev=56,e.t2=e.catch(2),e.t2.errorFields||L.error((null===(E=e.t2.response)||void 0===E||null===(E=E.data)||void 0===E?void 0:E.message)||e.t2.message);case 59:return e.prev=59,q(!1),e.finish(59);case 62:case"end":return e.stop()}var v}),e,null,[[2,56,59,62],[21,25],[37,41]])})),function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){g(a,n,o,i,c,"next",e)}function c(e){g(a,n,o,i,c,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}();return n.createElement(i.A,{title:"保存为 Mock",open:t,onClose:function(){return!F&&r()},width:"min(480px, 100vw)",footer:n.createElement("div",{className:"mm-save-footer"},n.createElement(c.Ay,{disabled:F,onClick:r},"取消"),n.createElement(c.Ay,{type:"primary",loading:F,disabled:!j.length||!!D,onClick:Y},"append"===M?"追加响应":"创建接口"))},D&&n.createElement(u.A,{type:"error",message:D,action:n.createElement(c.Ay,{onClick:function(){return H((function(e){return e+1}))}},"重试")}),n.createElement(a.A,{form:O,layout:"vertical"},n.createElement(a.A.Item,{label:"保存方式"},n.createElement(l.A,{"aria-label":"Mock 保存方式",value:M,onChange:G,options:[{value:"new",label:"创建 Mock 接口"},{value:"append",label:"追加到已有接口"}]})),n.createElement(a.A.Item,{name:"featureId",label:"功能模块",rules:[{required:!0,message:"请选择功能模块"}]},n.createElement(l.A,{options:j.map((function(e){return{value:e.id,label:e.name}}))})),"append"===M?n.createElement(a.A.Item,{name:"interfaceId",label:"接口",rules:[{required:!0,message:"请选择接口"}]},n.createElement(l.A,{options:P.map((function(e){return{value:e.id,label:e.name}}))})):n.createElement(a.A.Item,{name:"urlPattern",label:"URL 匹配路径",rules:[{required:!0,whitespace:!0,message:"请输入匹配规则"}]},n.createElement(s.A,null)),n.createElement(a.A.Item,{name:"name",label:"append"===M?"响应名称":"接口名称",rules:[{required:!0,whitespace:!0,message:"请输入名称"}]},n.createElement(s.A,null)),"new"===M&&n.createElement(a.A.Item,{name:"contentType",label:"Content-Type"},n.createElement(s.A,null)),"new"===M&&n.createElement(a.A.Item,{name:"active",label:"创建后启用",valuePropName:"checked"},n.createElement(f.A,null))),n.createElement(p.A.Paragraph,{type:"secondary"},"创建接口保存响应体、状态码与 Content-Type,文本默认使用 UTF-8;请求头和 Cookie 不会写入配置。追加响应保留目标接口的默认响应、状态码和响应头。"))}}}]);
|