@dao42/d42paas-front 0.9.235 → 0.9.236
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/DaoPaaS.cjs
CHANGED
|
@@ -711,7 +711,7 @@ background: var(--d42-keyword-search_highlight-bg)`;class OKe extends Ha{constru
|
|
|
711
711
|
`)}),h.push({...g,from:i.number+1,to:i.number+g.to-s,aiContent:n.state.doc.toJSON().slice(i.number,i.number+g.to-s).join(`
|
|
712
712
|
`)})),!O.isIn&&p.isIn&&h.push({...g,from:i.number+1,to:i.number+g.to-s,aiContent:n.state.doc.toJSON().slice(i.number,i.number+g.to-s).join(`
|
|
713
713
|
`)}),O.isIn&&!p.isIn&&h.push({...g,to:u.number-1,aiContent:n.state.doc.toJSON().slice(g.from-1,u.number-1).join(`
|
|
714
|
-
`)})}L.dao.channel().send("aiSplitAiCodeInfo",{removeItems:f,addItems:h,path:L.file.getOpenedPath()}),L.dao.channel().off("aiSplitAiCodeInfo"),L.dao.channel().on("aiSplitAiCodeInfo",m=>{he.file.aiCodeInfo(m.aiRes||[]),he.file.isSplitCode(!1),wk(n,c,l)});return}L.dao.channel().send("addAiCodeInfo",{path:L.file.getOpenedPath(),isRepalceRange:o.isRepalceRange,isDone:e,from:a,to:i.number,content:o.replaceOriginCode,aiContent:d}),L.dao.channel().off("addAiCodeInfo"),L.dao.channel().on("addAiCodeInfo",f=>{f.aiRes.length===1?he.file.aiCodeInfo(f.aiRes||[]):wk(n,c,f.addRes);const h=[...document.querySelectorAll(".cm-lineNumbers .cm-gutterElement").values()].reduce((O,p)=>p.innerHTML===a.toString()?p:O,null);let m=!1;const g=n.scrollDOM.getBoundingClientRect().top;h&&h.getBoundingClientRect().y-g-6>0&&(m=!0),m||setTimeout(()=>{h==null||h.scrollIntoView({behavior:"smooth"})},300)}),he.file.aiModifyInfo({})}}isEnableEditCode(e){const n=L.dao.isVirtualUser(),{path:r}=e,i=L.file.getOpenedPath(),o=L.dao.channel();return new Promise(s=>{if(!n){s(o.handleRes(!0));return}const a=()=>{const c=L.file.editorView();if(c){const u=Date.now(),d=c.state.doc.toString(),f=c.state.doc.lineAt(e.selection.start),h=c.state.doc.lineAt(e.selection.end);let m=!0,g={isIn:!1,isFirst:!1,item:{},firstNum:0,lastNum:0};const O=[];for(let _=f.number;_<=h.number;_++){const w=sm(c,c.state.doc.line(_));_===f.number&&(g=w),w.isIn&&(O.find(S=>S.item._id===w.item._id)||O.push(w)),w.isIn||(m=!1)}const p=c.state.sliceDoc(e.selection.start,e.selection.end);he.file.aiModifyInfo({startLine:f.number,endLine:h.number,id:u.toString(),isRepalceRange:e.selection.end>e.selection.start,isAIArea:m,item:g==null?void 0:g.item,replaceOriginCode:p,originDoc:za.exports.cloneDeep(c.state.doc),blockInfos:O});let v=m;d.trim()||(v=!0);let y=null;if(!v){const _=f.to+f.length;c.dispatch({effects:[ut.scrollIntoView(_,{y:"center"})]}),document.querySelectorAll(".cm-lineNumbers .cm-gutterElement").forEach(w=>{w.innerHTML===f.number.toString()&&(y=w)})}o.removeMessageListener(l),setTimeout(()=>{const _=o.handleRes(v);_.targetEle=y,y&&(_.boundingClientRect=y.getBoundingClientRect()),s(_)},300)}else o.removeMessageListener(l),s(o.handleRes(!1))},l=c=>{const{name:u}=c;switch(u){case at.FileOpenDone:a();break}};return i===r?a():(o.addMessageListener(l),Cd(r),o.loadFile(r),he.file.fileIntoView(!0)),!0})}replayCodeByRange(e){return new Promise(n=>{const{path:r}=e,i=L.file.getOpenedPath(),o=L.dao.channel();i!==r?(Cd(r),o.loadFile(r),he.file.fileIntoView(!0),he.dao.pendingEditorActions({actions:at.ReplayCodeByRange,payload:e})):(Hle(e),he.dao.pendingEditorActions({})),o.addMessageListener(s=>{const{name:a,payload:l}=s;a===at.ReplaceCodeDone&&l.openPath===r&&n(o.handleSuccessRes("Done"))})})}getCursor(){const e=L.file.editorView();if(e!=null&&e.state)return e.state.selection.main.head}getSelection(){const e=L.file.editorView();if(e!=null&&e.state){const n=e.state.selection.ranges,r=L.file.getOpenedPath(),i=n[0].from,o=n[0].to,s={start:i,end:o};let a=e.state.doc.sliceString(i,o);return a=encodeURI(a),{path:r,content:a,selection:s}}}getEditorInstance(){return L.file.editorView()}}const RKe=Yu(async()=>(await Promise.resolve().then(function(){return Fot})).FileTree),AKe=Yu(async()=>(await Promise.resolve().then(function(){return Ost})).Editor),IKe=Yu(async()=>(await Promise.resolve().then(function(){return iat})).default),XKe=Yu(async()=>(await Promise.resolve().then(function(){return hat})).default),DKe=Yu(async()=>(await Promise.resolve().then(function(){return mat})).default),NKe=Yu(async()=>(await Promise.resolve().then(function(){return dvt})).default),zKe=Yu(async()=>(await Promise.resolve().then(function(){return Svt})).default),MKe=Yu(async()=>(await Promise.resolve().then(function(){return Qvt})).default),LKe=Yu(async()=>(await Promise.resolve().then(function(){return Avt})).default),lV={Tree:null,Editor:null,Console:null,Browser:null,Shell:null,MarkdownPreview:null,ClaudeCode:null,ClaudeJson:null};class UKe{constructor(e){ot(this,"components",za.exports.cloneDeep(lV));ot(this,"paasOptions");ot(this,"paasDomainPath");ot(this,"sdkVersion");ot(this,"isRendered",!1);ot(this,"markdownSchema",{});ot(this,"socketParser","default");ot(this,"i18nLanguage",Hw.ZH);ot(this,"noFrameSpan",0);ot(this,"themeType",UR.dark);ot(this,"daoEditor");ot(this,"agentUser");this.daoEditor=new EKe,e.customLog&&(window.customLog=e.customLog,he.dao.customLog(e.customLog)),e.speedOption&&he.config.speedOption(e.speedOption),e.defaultLspLang&&he.config.defaultLspLang([...e.defaultLspLang]),e.replayFileChangeLogs&&he.config.replayFileChangeLogs(e.replayFileChangeLogs),he.config.recordBrowser(!!e.recordBrowser),he.config.isSplitCode(!!e.isSplitCode),he.config.originRecordBrowser(!!e.recordBrowser),he.config.customFileTreeAction(!!e.customFileTreeAction),he.config.persistenceWebData(!!e.persistenceWebData),he.config.showRRwebController(!!e.showRRwebController),he.config.showModifyIcon(!!e.showModifyIcon),he.config.customImagePreview(!!e.customImagePreview),he.config.hideEditorToolTip(!!e.hideEditorToolTip),he.config.hideEditorContextMenu(!!e.hideEditorContextMenu),he.config.editorBlankContent(e.editorBlankContent||""),e.contextMenu&&he.config.contextMenu(e.contextMenu),e.aiCodeMenu&&he.config.aiCodeMenu(e.aiCodeMenu),e.editorPlugins&&e.editorPlugins.length&&(he.config.editorPlugins(e.editorPlugins),delete e.editorPlugins),he.config.focusEditorPosition(e.focusEditorPosition||"BOTTOM"),e.globalConfig&&this.updateGlobalConfig(e.globalConfig),this.sdkVersion=eTe(),Ot.info("Start to init SDK,with version:"+this.sdkVersion,e),this.setPaasOptionsWithDefaultAvatar(e),this.setPaasDomainPathWithDefaultOrigin(e.paasDomain),this.themeType=e.themeType||UR.dark,this.i18nLanguage=e.i18nLanguage||Hw.ZH,this.noFrameSpan=e.noFrameSpan||0,this.init();const n=typeof e.openLspDiagnostic=="boolean"?e.openLspDiagnostic:!0;this.switchLspDiagnostic(n)}loadTheme(e){this.themeType=e,he.theme.setTheme(this.themeType,Do.terminal),he.theme.setTheme(this.themeType,Do.console),mEe(this.themeType)}async initAgentUserId(){var e;try{this.agentUser=await SL(),Ot.info(`findAvailableAgentUser: ${(e=this.agentUser)==null?void 0:e.id}`)}catch{}}async init(){var e,n,r,i;this.reset(),await this.initAgentUserId(),this.loadTheme(this.themeType),(e=this.paasOptions.defaultOpenFiles)!=null&&e.length&&he.dao.defaultOpenFiles(this.paasOptions.defaultOpenFiles||""),he.dao.specialOpenFile(this.paasOptions.specialOpenFile||""),he.dao.setXtermStyle(this.paasOptions.xtermStyle),he.dao.isOpenDebugMode((n=this.paasOptions.isOpenDebugMode)!=null?n:!1),he.i18n.setLanguage(this.i18nLanguage),Xo.changeLanguage(this.i18nLanguage),he.dao.noFrameSpan(this.noFrameSpan),he.dao.specialFileHighlight(this.paasOptions.specialFileHighlight||[]),this.paasOptions.reportHighlightData&&he.file.reportHighlightData(this.paasOptions.reportHighlightData),he.dao.setIsLegacyMarkdownMath((i=(r=this.paasOptions)==null?void 0:r.isLegacyMarkdownMath)!=null?i:!1),Ot.debug(`sdk: init with ${this.paasDomainPath} passDomain`),Ot.info("Start to get ticket: "+this.paasOptions.ticket),tTe(this.paasDomainPath,this.paasOptions.ticket,this.sdkVersion).then(async o=>{if(Ot.info("Reciver ticket: ",o),o.status==="failure"){Ot.error(o),L.dao.channel().trigger("message",{name:"initError",payload:o.errors[0].erromsg});return}await this.initChannel(o.data)},o=>{L.dao.channel().trigger("message",{name:"initError",payload:o.message})})}openKeywordSearch(e){he.file.searchKeywordInfo({...L.file.searchKeywordInfo(),isShow:e})}fetchKeywordSearchInfo(){return L.file.searchKeywordInfo()}startRecordBrowser(e=!0){L.dao.channel().startRecordBrowser(e)}followBrowser(e){L.dao.channel().followBrowser(e)}async initChannel(e){document.addEventListener("click",s=>{s.target&&(s.target.classList.contains("gutter-custom-span-line")||document.querySelectorAll(".gutter-custom-span-line_dropdown").forEach(l=>{l.style.display="none"}))}),window.addEventListener("message",s=>{try{if(s.data.includes("rrweb")){const a=JSON.parse(s.data),l=L.config.recordBrowser();l&&a.type==="rrweb"&&l&&L.dao.channel().appendRRWebData(a.event)}else if(s.data.includes("initRRweb"))L.dao.channel().send("initRRweb");else if(s.data.includes("initDevtools"))he.config.supportDevtools(!0);else if(s.data.includes("devtoolStatus")){const a=JSON.parse(s.data);L.dao.channel().trigger(at.DevtoolStatusChange,{name:at.DevtoolStatusChange,payload:{value:a.value}})}}catch{}});const{url:n,socketParser:r}=e;this.socketParser=r||"default",he.dao.openSocketBuffer(this.socketParser==="buffer");let i;if(this.agentUser){const s=await RQe(this.agentUser);if(s)i=this.agentUser.id;else try{const a=await SL();i=a==null?void 0:a.id}catch{i=Nd()}Ot.info(`findAvailableAgentUser: ${s} ${i}`)}else i=Nd();const o=L.dao.channel().visibilitychange;document.removeEventListener("visibilitychange",o),he.dao.reconnectMaxTimes(this.paasOptions.reconnectMaxTimes||10),L.dao.channel().startChannel(n,{...this.paasOptions,agentUserId:i,mockSocket:this.paasOptions.socket},{triggerEventForMaxTimespan:this.paasOptions.triggerEventForMaxTimespan,reconnectMaxTimes:this.paasOptions.reconnectMaxTimes,isInsertCrdt:this.paasOptions.isInsertCrdt,sockerParser:this.socketParser}),Ot.info(">>>registerVisiblityChangeEvent"),document.addEventListener("visibilitychange",o)}setPaasOptionsWithDefaultAvatar(e){this.paasOptions=e,this.paasOptions.userInfo.avatarUrl||(this.paasOptions.userInfo.avatarUrl=tte(this.paasOptions.userInfo.username))}setPaasDomainPathWithDefaultOrigin(e){this.paasDomainPath={}.PAAS_MANAGER_API_ORIGIN||"https://www.1024paas.com",e&&(this.paasDomainPath=e)}reset(){L.dao.channel().closeChannel(),TEe()}get playgroundStatus(){return L.dao.playgroundInfo().status}get dockerStatus(){return L.dao.playgroundInfo().runStatus}get currentAgentUser(){return L.dao.currentAgentUser()}get agentUsers(){return L.dao.playgroundInfo().agentUsers}get playgroundInfo(){return L.dao.playgroundInfo()}get currentFollowingAgentUser(){return L.dao.getFollowingAgentUser()}followUser(e){const n=L.dao.playgroundInfo().agentUsers.find(i=>i.agentUserId===e);if(L.dao.currentAgentUserId()===(n==null?void 0:n.followingAgentUserId)){const i=Pn("dao_paas_cannot_follow_each_other");Br.error(i);return}L.dao.channel().followingAgentUser(e);const r=L.config.supportRRWeb();L.dao.channel().followBrowser(r),n.fileOpened&&L.dao.channel().loadFile(n.fileOpened,"follow")}unFollowUser(){L.dao.channel().unFollowingAgentUser(),L.dao.channel().followBrowser(!1)}getMemorySnap(){L.dao.channel().getMemorySnap()}createFile(e,n){return L.dao.channel().createFile(e,n)}expandByPath(e){const n=L.file.fileTree(),i=vg(n)[e];return i?i.type==="FILE"?this.openFile(e):(L.dao.channel().expandByPath(e,i),Promise.resolve(this.handleSuccessRes(Pn("common_success")))):Promise.reject(Pn("dao_paas_file_does_not_exist"))}publishKeyEvent(e){L.dao.channel().publishKeyEvent(e)}setMockPlaybackData(e){he.dao.setMockPlaybackData(e)}preparePlaybackSync(){return he.dao.setPlaygroundMode(Oc.playback),L.dao.channel().getPlaybackInfo(),L.dao.channel().off(ct.PlaybackInfo),new Promise(e=>{L.dao.channel().on(ct.PlaybackInfo,n=>{const r=L.dao.channel().dealWithPlaybackData(n,!1);e(r)})})}preparePlayback(){he.dao.setPlaygroundMode(Oc.playback),L.dao.channel().getPlaybackInfo()}startPlayback(e){L.dao.channel().startPlayback(e)}restartPlayback(e){L.dao.channel().restartPlayback(e)}goToPlayback(e){L.dao.channel().goToPlayback(e)}pausePlayback(){L.dao.channel().pausePlayback()}stopPlayback(){he.dao.setPlaygroundMode(Oc.edit),L.dao.channel().stopPlayback()}setRate(e){L.dao.channel().setPlaybackRate(e)}activePlaygroundSync(){return L.dao.playgroundInfo().status==="ACTIVE"?Promise.resolve({status:"ACTIVE",message:"Already active , donot need repeat active"}):(L.dao.channel().active(),L.dao.channel().off(Cn.Active),new Promise(n=>{L.dao.channel().on(ct.Active,r=>{const i=L.dao.channel().dealWithActiveEvent(r,!1);n(i)})}))}activePlayground(){L.dao.channel().active()}retainingAllFiles(){return L.dao.channel().retainingAllFiles(),L.dao.channel().off("retainingAllFiles"),new Promise(e=>{L.dao.channel().on("retainingAllFiles",n=>{e(n)})})}runPlayground(){return new Promise((e,n)=>{const r=L.file.pendingUpdateCount();if(r>0)return n(this.handleErrorRes(Pn("editor_pending_update",{pendingUpdate:r})));L.dao.channel().run(),e(this.handleSuccessRes("running"))})}stopPlayground(){L.dao.channel().stop()}getUnitTestFun(){const e=L.dao.playgroundInfo().status;if(e!=="ACTIVE"){const n={code:e,action:Cn.GetUnitTestFun,message:"You need to active docker."};return Ot.info(n),Promise.reject(n)}return L.dao.channel().getUnitTestFun(),L.dao.channel().off(Cn.GetUnitTestFun),new Promise(n=>{L.dao.channel().on(Cn.GetUnitTestFun,r=>{n(r)})})}getRunId(e){return e+"_"+Cn.RunUnitTestResult}runUnitTestByFilePath(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const r={code:n,action:Cn.RunUnitTestResult,message:"You need to active docker."};return Ot.info(r),Promise.reject(r)}L.dao.channel().runUnitTestByFilePath(e)}stopUnitTest(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const o={code:n,action:Cn.StopUnitTest,message:"You need to active docker."};return Ot.info(o),Promise.reject(o)}const r=Array.isArray(e)?[...e]:[e],i=[];r.forEach(o=>{const s=this.getRunId(o);i.push(s)}),L.dao.channel().stopUnitTest(i)}getRunCmdRunId(e){return e+"_"+Cn.RunCmd}runCmd(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const i={code:n,action:Cn.RunCmd,message:"You need to active docker."};return Ot.info(i),Promise.reject(i)}const r=this.getRunCmdRunId(e.cmd);e.runId=r,L.dao.channel().runCmd(e)}stopRunCmd(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const i={code:n,action:Cn.StopRunCmd,message:"You need to active docker."};return Ot.info(i),Promise.reject(i)}const r=this.getRunCmdRunId(e);L.dao.channel().stopRunCmd(r)}appendCustomizeFrameDataSync(e){return L.dao.channel().appendCustomizeFrameData(e),L.dao.channel().off(ct.AppendCustomizeFrameData),new Promise(n=>{L.dao.channel().on(ct.AppendCustomizeFrameData,r=>{n(r)})})}appendCustomizeFrameData(e){L.dao.channel().appendCustomizeFrameData(e)}statisticsPlaybackData(e,n){return new Promise((r,i)=>{if(!L.dao.isReady())return i(this.handleErrorRes("no ready"));if(!e||!(n!=null&&n.length)){r({status:"fail",message:"please input right parmas",errorCode:"ERROR_PARMAS"});return}L.dao.channel().statisticsPlaybackData(e,n),L.dao.channel().off("statisticsPlaybackData"),L.dao.channel().on("statisticsPlaybackData",o=>{r({status:"success",data:o})})})}onMessage(e){L.dao.channel().addMessageListener(e)}claudejsonRestart(){L.dao.channel().claudejsonRestart()}removeMessage(e){L.dao.channel().removeMessageListener(e)}onError(e){L.dao.channel().addErrorListener(e)}removeError(e){L.dao.channel().removeErrorListener(e)}subscribePlayControlEvent(e){L.dao.channel().subscribeForPlayControl(e)}unsubscribePlayControlEvent(e){L.dao.channel().unsubscribeForPlayControl(e)}subscribe(e,n){L.dao.channel().subscribeForComponent(e,n)}unsubscribe(e,n){L.dao.channel().unsubscribeForComponent(e,n)}updateFileHeader(e){he.file.setFileHeader(e)}initComponent(e,n,r){const i=document.querySelector(n);if(!i)throw new Error(Pn("dao_paas_not_find_mount_dom_object_for_x",{x:n}));const o=pA(i),s=a=>{switch(e){case"Tree":return Z(RKe,{...a});case"Editor":return Z(AKe,{...a});case"Browser":return Z(XKe,{...a});case"Console":return Z(IKe,{...a});case"Shell":return Z(DKe,{...a});case"MarkdownPreview":return Z(NKe,{...a});case"Debug":return Z(zKe,{...a});case"ClaudeCode":return Z(MKe,{...a});case"ClaudeJson":return Z(LKe,{...a});default:throw new Error(Pn("dao_paas_x_component_is_not_supported",{x:e}))}};this.components[e]={reactComponent:s,container:n,props:r,root:o},o.render(Z(C.exports.Suspense,{children:Z(s,{...r})})),L.dao.channel().uploadLog("RenderComponent",e)}mountMarkdownPreview(){const{MarkdownPreview:e}=this.components;if(Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u6302\u8F7D\u4E2D",this.markdownSchema),e)Ot.debug("\u6302\u8F7D\u5931\u8D25\uFF0C\u8BF7\u52FF\u91CD\u590D\u6302\u8F7D\u540C\u4E00\u4E2A\u7EC4\u4EF6",this.markdownSchema);else if(Object.keys(this.markdownSchema).length>0){const{item:n,container:r,props:i}=this.markdownSchema;this.initComponent(n,r,i),Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u6302\u8F7D\u5B8C\u6210",this.markdownSchema)}}unMountMarkdownPreview(){var n;const{MarkdownPreview:e}=this.components;Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u5378\u8F7D\u4E2D",e),e?((n=e.root)==null||n.unmount(),this.components.MarkdownPreview=null,Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u5378\u8F7D\u6210\u529F",e)):Ot.debug("\u5378\u8F7D\u5931\u8D25\uFF0Cmarkdown\u9884\u89C8\u7EC4\u4EF6\u4E0D\u5B58\u5728",e)}mapRender(e){for(const n of e){const{item:r,container:i,props:o}=n;if(this.components[r])throw new Error(`Before the SDK is destroyed, the ${r} component cannot be rendered repeatedly`);r==="MarkdownPreview"&&(this.markdownSchema=n,!o.isRender)||this.initComponent(r,i,o)}}isShowPreviewMDIframe(e){L.dao.channel().trigger("message",{name:"showPreviewMDIframe",payload:e})}handleErrorRes(e){return{status:!1,message:e}}handleSuccessRes(e){return{status:!0,message:e}}insertTextById(e,n,r){L.dao.channel().insertTextById(e,n,r)}updateAreaFlags(e){L.dao.channel().updateAreaFlags(e)}removeAreaTextById(e,n,r){L.dao.channel().removeAreaTextById(e,n,r)}jumpToAreaById(e,n){L.dao.channel().jumpToAreaById(e,n)}switchLanguage(e,n,r,i){return new Promise((o,s)=>{if(!L.dao.isReady())return s(this.handleErrorRes(Pn("dao_paas_no_ready")));L.dao.channel().switchLanguage(e,n,r,i),L.dao.channel().off("switchLanguage"),L.dao.channel().on("switchLanguage",a=>{const l=L.file.getOpenedPath(),{destination:c}=a;a.status&&r===l&&(L.dao.channel().loadFile(c),o(this.handleSuccessRes(Pn("common_success")))),o(a)})})}restartServer(){return new Promise((e,n)=>{if(!L.dao.isReady())return n(this.handleErrorRes(Pn("dao_paas_no_ready")));L.dao.channel().restartServer(),L.dao.channel().off("restartServer"),L.dao.channel().on("restartServer",r=>{const i={status:r.success,message:r.success?r.message||r.messageId:r.error};e(i)})})}turnOnLSPServer(e,n=!0){if(he.config.stopLsp(e),!L.dao.isReady())return this.handleErrorRes(Pn("dao_paas_no_ready"));L.dao.channel().stopLSPServer(e,n)}restartLSPServer(){if(!L.dao.isReady())return this.handleErrorRes(Pn("dao_paas_no_ready"));L.dao.channel().restartLSPServer()}addCDNSource(e,n,r){return new Promise((i,o)=>{if(!L.dao.isReady())return o(this.handleErrorRes(Pn("dao_paas_no_ready")));L.dao.channel().addCDNSource(e,n,r),L.dao.channel().off("addCDNSource"),L.dao.channel().on("addCDNSource",s=>{const a=L.file.getOpenedPath();s.status&&r===a&&this.openFile(r,"refresh"),i(s)})})}openFile(e,n="default"){return L.dao.channel().openFile(e,n)}updateGlobalBaseConfig(e){he.config.update(e)}updateGlobalConfig(e){const n={...L.config.globalConfig(),...e};window.navigator.cookieEnabled&&(window.localStorage.setItem("paasGlobalConfig",JSON.stringify(n)),he.config.globalConfig(n))}updateConfig(e){const n={...L.dao.config(),...e};he.dao.config(n)}toggleMarkDownPreview(e){e?this.mountMarkdownPreview():this.unMountMarkdownPreview()}reload(e=["Editor","Tree"]){const n={file:()=>{he.dao.setPlaygroundInfo(ste),he.file.reset()}},r=(e==null?void 0:e.includes("Editor"))||(e==null?void 0:e.includes("Tree"))?"file":"";e&&r&&n[r]()}switchI18nLanguage(e){he.i18n.setLanguage(e),L.dao.channel().emitI18nLanguage(e),Xo.changeLanguage(e)}offlineVirtualUser(){return L.dao.channel().offlineVirtualUser()}registerVirtualUser(e){return L.dao.channel().registerVirtualUser(e)}switchVirtualUser(e){return L.dao.channel().switchVirtualUser(e)}reloadI18nResources(e,n){try{(Array.isArray(e)?e:[{language:e,resource:n}]).forEach(i=>{Xo.addResources(i.language,"translation",i.resource)}),Xo.changeLanguage(L.i18n.getLanguage())}catch(r){Ot.error("\u66F4\u65B0\u56FD\u9645\u5316\u6587\u672C\u5931\u8D25\uFF0C\u9519\u8BEF:",r)}}getEditorContent(){const e=L.file.editorView(),n=e?e.state.doc.toJSON().join(`
|
|
714
|
+
`)})}L.dao.channel().send("aiSplitAiCodeInfo",{removeItems:f,addItems:h,path:L.file.getOpenedPath()}),L.dao.channel().off("aiSplitAiCodeInfo"),L.dao.channel().on("aiSplitAiCodeInfo",m=>{he.file.aiCodeInfo(m.aiRes||[]),he.file.isSplitCode(!1),wk(n,c,l)});return}L.dao.channel().send("addAiCodeInfo",{path:L.file.getOpenedPath(),isRepalceRange:o.isRepalceRange,isDone:e,from:a,to:i.number,content:o.replaceOriginCode,aiContent:d}),L.dao.channel().off("addAiCodeInfo"),L.dao.channel().on("addAiCodeInfo",f=>{f.aiRes.length===1?he.file.aiCodeInfo(f.aiRes||[]):wk(n,c,f.addRes);const h=[...document.querySelectorAll(".cm-lineNumbers .cm-gutterElement").values()].reduce((O,p)=>p.innerHTML===a.toString()?p:O,null);let m=!1;const g=n.scrollDOM.getBoundingClientRect().top;h&&h.getBoundingClientRect().y-g-6>0&&(m=!0),m||setTimeout(()=>{h==null||h.scrollIntoView({behavior:"smooth"})},300)}),he.file.aiModifyInfo({})}}isEnableEditCode(e){const n=L.dao.isVirtualUser(),{path:r}=e,i=L.file.getOpenedPath(),o=L.dao.channel();return new Promise(s=>{if(!n){s(o.handleRes(!0));return}const a=()=>{const c=L.file.editorView();if(c){const u=Date.now(),d=c.state.doc.toString(),f=c.state.doc.lineAt(e.selection.start),h=c.state.doc.lineAt(e.selection.end);let m=!0,g={isIn:!1,isFirst:!1,item:{},firstNum:0,lastNum:0};const O=[];for(let _=f.number;_<=h.number;_++){const w=sm(c,c.state.doc.line(_));_===f.number&&(g=w),w.isIn&&(O.find(S=>S.item._id===w.item._id)||O.push(w)),w.isIn||(m=!1)}const p=c.state.sliceDoc(e.selection.start,e.selection.end);he.file.aiModifyInfo({startLine:f.number,endLine:h.number,id:u.toString(),isRepalceRange:e.selection.end>e.selection.start,isAIArea:m,item:g==null?void 0:g.item,replaceOriginCode:p,originDoc:za.exports.cloneDeep(c.state.doc),blockInfos:O});let v=m;d.trim()||(v=!0);let y=null;if(!v){const _=f.to+f.length;c.dispatch({effects:[ut.scrollIntoView(_,{y:"center"})]}),document.querySelectorAll(".cm-lineNumbers .cm-gutterElement").forEach(w=>{w.innerHTML===f.number.toString()&&(y=w)})}o.removeMessageListener(l),setTimeout(()=>{const _=o.handleRes(v);_.targetEle=y,y&&(_.boundingClientRect=y.getBoundingClientRect()),s(_)},300)}else o.removeMessageListener(l),s(o.handleRes(!1))},l=c=>{const{name:u}=c;switch(u){case at.FileOpenDone:a();break}};return i===r?a():(o.addMessageListener(l),Cd(r),o.loadFile(r),he.file.fileIntoView(!0)),!0})}replayCodeByRange(e){return new Promise(n=>{const{path:r}=e,i=L.file.getOpenedPath(),o=L.dao.channel();i!==r?(Cd(r),o.loadFile(r),he.file.fileIntoView(!0),he.dao.pendingEditorActions({actions:at.ReplayCodeByRange,payload:e})):(Hle(e),he.dao.pendingEditorActions({})),o.addMessageListener(s=>{const{name:a,payload:l}=s;a===at.ReplaceCodeDone&&l.openPath===r&&n(o.handleSuccessRes("Done"))})})}getCursor(){const e=L.file.editorView();if(e!=null&&e.state)return e.state.selection.main.head}getSelection(){const e=L.file.editorView();if(e!=null&&e.state){const n=e.state.selection.ranges,r=L.file.getOpenedPath(),i=n[0].from,o=n[0].to,s={start:i,end:o};let a=e.state.doc.sliceString(i,o);return a=encodeURI(a),{path:r,content:a,selection:s}}}getEditorInstance(){return L.file.editorView()}}const RKe=Yu(async()=>(await Promise.resolve().then(function(){return Fot})).FileTree),AKe=Yu(async()=>(await Promise.resolve().then(function(){return Ost})).Editor),IKe=Yu(async()=>(await Promise.resolve().then(function(){return iat})).default),XKe=Yu(async()=>(await Promise.resolve().then(function(){return hat})).default),DKe=Yu(async()=>(await Promise.resolve().then(function(){return mat})).default),NKe=Yu(async()=>(await Promise.resolve().then(function(){return dvt})).default),zKe=Yu(async()=>(await Promise.resolve().then(function(){return Svt})).default),MKe=Yu(async()=>(await Promise.resolve().then(function(){return Qvt})).default),LKe=Yu(async()=>(await Promise.resolve().then(function(){return Avt})).default),lV={Tree:null,Editor:null,Console:null,Browser:null,Shell:null,MarkdownPreview:null,ClaudeCode:null,ClaudeJson:null};class UKe{constructor(e){ot(this,"components",za.exports.cloneDeep(lV));ot(this,"paasOptions");ot(this,"paasDomainPath");ot(this,"sdkVersion");ot(this,"isRendered",!1);ot(this,"markdownSchema",{});ot(this,"socketParser","default");ot(this,"i18nLanguage",Hw.ZH);ot(this,"noFrameSpan",0);ot(this,"themeType",UR.dark);ot(this,"daoEditor");ot(this,"agentUser");this.daoEditor=new EKe,e.customLog&&(window.customLog=e.customLog,he.dao.customLog(e.customLog)),e.speedOption&&he.config.speedOption(e.speedOption),e.defaultLspLang&&he.config.defaultLspLang([...e.defaultLspLang]),e.replayFileChangeLogs&&he.config.replayFileChangeLogs(e.replayFileChangeLogs),he.config.recordBrowser(!!e.recordBrowser),he.config.isSplitCode(!!e.isSplitCode),he.config.originRecordBrowser(!!e.recordBrowser),he.config.customFileTreeAction(!!e.customFileTreeAction),he.config.persistenceWebData(!!e.persistenceWebData),he.config.showRRwebController(!!e.showRRwebController),he.config.showModifyIcon(!!e.showModifyIcon),he.config.customImagePreview(!!e.customImagePreview),he.config.hideEditorToolTip(!!e.hideEditorToolTip),he.config.hideEditorContextMenu(!!e.hideEditorContextMenu),he.config.editorBlankContent(e.editorBlankContent||""),e.contextMenu&&he.config.contextMenu(e.contextMenu),e.aiCodeMenu&&he.config.aiCodeMenu(e.aiCodeMenu),e.editorPlugins&&e.editorPlugins.length&&(he.config.editorPlugins(e.editorPlugins),delete e.editorPlugins),he.config.focusEditorPosition(e.focusEditorPosition||"BOTTOM"),e.globalConfig&&this.updateGlobalConfig(e.globalConfig),this.sdkVersion=eTe(),Ot.info("Start to init SDK,with version:"+this.sdkVersion,e),this.setPaasOptionsWithDefaultAvatar(e),this.setPaasDomainPathWithDefaultOrigin(e.paasDomain),this.themeType=e.themeType||UR.dark,this.i18nLanguage=e.i18nLanguage||Hw.ZH,this.noFrameSpan=e.noFrameSpan||0,this.init();const n=typeof e.openLspDiagnostic=="boolean"?e.openLspDiagnostic:!0;this.switchLspDiagnostic(n)}loadTheme(e){this.themeType=e,he.theme.setTheme(this.themeType,Do.terminal),he.theme.setTheme(this.themeType,Do.console),mEe(this.themeType)}async initAgentUserId(){var e;try{this.agentUser=await SL(),Ot.info(`findAvailableAgentUser: ${(e=this.agentUser)==null?void 0:e.id}`)}catch{}}async init(){var e,n,r,i;this.reset(),await this.initAgentUserId(),this.loadTheme(this.themeType),(e=this.paasOptions.defaultOpenFiles)!=null&&e.length&&he.dao.defaultOpenFiles(this.paasOptions.defaultOpenFiles||""),he.dao.specialOpenFile(this.paasOptions.specialOpenFile||""),he.dao.setXtermStyle(this.paasOptions.xtermStyle),he.dao.isOpenDebugMode((n=this.paasOptions.isOpenDebugMode)!=null?n:!1),he.i18n.setLanguage(this.i18nLanguage),Xo.changeLanguage(this.i18nLanguage),he.dao.noFrameSpan(this.noFrameSpan),he.dao.specialFileHighlight(this.paasOptions.specialFileHighlight||[]),this.paasOptions.reportHighlightData&&he.file.reportHighlightData(this.paasOptions.reportHighlightData),he.dao.setIsLegacyMarkdownMath((i=(r=this.paasOptions)==null?void 0:r.isLegacyMarkdownMath)!=null?i:!1),Ot.debug(`sdk: init with ${this.paasDomainPath} passDomain`),Ot.info("Start to get ticket: "+this.paasOptions.ticket),tTe(this.paasDomainPath,this.paasOptions.ticket,this.sdkVersion).then(async o=>{if(Ot.info("Reciver ticket: ",o),o.status==="failure"){Ot.error(o),L.dao.channel().trigger("message",{name:"initError",payload:o.errors[0].erromsg});return}await this.initChannel(o.data)},o=>{L.dao.channel().trigger("message",{name:"initError",payload:o.message})})}openKeywordSearch(e){he.file.searchKeywordInfo({...L.file.searchKeywordInfo(),isShow:e})}fetchKeywordSearchInfo(){return L.file.searchKeywordInfo()}startRecordBrowser(e=!0){L.dao.channel().startRecordBrowser(e)}followBrowser(e){L.dao.channel().followBrowser(e)}async initChannel(e){document.addEventListener("click",s=>{s.target&&(s.target.classList.contains("gutter-custom-span-line")||document.querySelectorAll(".gutter-custom-span-line_dropdown").forEach(l=>{l.style.display="none"}))}),window.addEventListener("message",s=>{try{if(s.data.includes("rrweb")){const a=JSON.parse(s.data),l=L.config.recordBrowser();l&&a.type==="rrweb"&&l&&L.dao.channel().appendRRWebData(a.event)}else if(s.data.includes("initRRweb"))L.dao.channel().send("initRRweb");else if(s.data.includes("initDevtools"))he.config.supportDevtools(!0);else if(s.data.includes("devtoolStatus")){const a=JSON.parse(s.data);L.dao.channel().trigger(at.DevtoolStatusChange,{name:at.DevtoolStatusChange,payload:{value:a.value}})}}catch{}});const{url:n,socketParser:r}=e;this.socketParser=r||"default",he.dao.openSocketBuffer(this.socketParser==="buffer");let i;if(this.agentUser){const s=await RQe(this.agentUser);if(s)i=this.agentUser.id;else try{const a=await SL();i=a==null?void 0:a.id}catch{i=Nd()}Ot.info(`findAvailableAgentUser: ${s} ${i}`)}else i=Nd();const o=L.dao.channel().visibilitychange;document.removeEventListener("visibilitychange",o),he.dao.reconnectMaxTimes(this.paasOptions.reconnectMaxTimes||10),L.dao.channel().startChannel(n,{...this.paasOptions,agentUserId:i,mockSocket:this.paasOptions.socket},{triggerEventForMaxTimespan:this.paasOptions.triggerEventForMaxTimespan,reconnectMaxTimes:this.paasOptions.reconnectMaxTimes,isInsertCrdt:this.paasOptions.isInsertCrdt,sockerParser:this.socketParser}),Ot.info(">>>registerVisiblityChangeEvent"),document.addEventListener("visibilitychange",o)}setPaasOptionsWithDefaultAvatar(e){this.paasOptions=e,this.paasOptions.userInfo.avatarUrl||(this.paasOptions.userInfo.avatarUrl=tte(this.paasOptions.userInfo.username))}setPaasDomainPathWithDefaultOrigin(e){this.paasDomainPath={}.PAAS_MANAGER_API_ORIGIN||"https://www.1024paas.com",e&&(this.paasDomainPath=e)}reset(){L.dao.channel().closeChannel(),TEe()}get playgroundStatus(){return L.dao.playgroundInfo().status}get dockerStatus(){return L.dao.playgroundInfo().runStatus}get currentAgentUser(){return L.dao.currentAgentUser()}get agentUsers(){return L.dao.playgroundInfo().agentUsers}get playgroundInfo(){return L.dao.playgroundInfo()}get currentFollowingAgentUser(){return L.dao.getFollowingAgentUser()}followUser(e){const n=L.dao.playgroundInfo().agentUsers.find(i=>i.agentUserId===e);if(L.dao.currentAgentUserId()===(n==null?void 0:n.followingAgentUserId)){const i=Pn("dao_paas_cannot_follow_each_other");Br.error(i);return}L.dao.channel().followingAgentUser(e);const r=L.config.supportRRWeb();L.dao.channel().followBrowser(r),n.fileOpened&&L.dao.channel().loadFile(n.fileOpened,"follow")}unFollowUser(){L.dao.channel().unFollowingAgentUser(),L.dao.channel().followBrowser(!1)}getMemorySnap(){L.dao.channel().getMemorySnap()}createFile(e,n){return L.dao.channel().createFile(e,n)}expandByPath(e){const n=L.file.fileTree(),i=vg(n)[e];return i?i.type==="FILE"?this.openFile(e):(L.dao.channel().expandByPath(e,i),Promise.resolve(this.handleSuccessRes(Pn("common_success")))):Promise.reject(Pn("dao_paas_file_does_not_exist"))}publishKeyEvent(e){L.dao.channel().publishKeyEvent(e)}setMockPlaybackData(e){he.dao.setMockPlaybackData(e)}preparePlaybackSync(){return he.dao.setPlaygroundMode(Oc.playback),L.dao.channel().getPlaybackInfo(),L.dao.channel().off(ct.PlaybackInfo),new Promise(e=>{L.dao.channel().on(ct.PlaybackInfo,n=>{const r=L.dao.channel().dealWithPlaybackData(n,!1);e(r)})})}preparePlayback(){he.dao.setPlaygroundMode(Oc.playback),L.dao.channel().getPlaybackInfo()}startPlayback(e){L.dao.channel().startPlayback(e)}restartPlayback(e){L.dao.channel().restartPlayback(e)}goToPlayback(e){L.dao.channel().goToPlayback(e)}pausePlayback(){L.dao.channel().pausePlayback()}stopPlayback(){he.dao.setPlaygroundMode(Oc.edit),L.dao.channel().stopPlayback()}setRate(e){L.dao.channel().setPlaybackRate(e)}activePlaygroundSync(){return L.dao.playgroundInfo().status==="ACTIVE"?Promise.resolve({status:"ACTIVE",message:"Already active , donot need repeat active"}):(L.dao.channel().active(),L.dao.channel().off(Cn.Active),new Promise(n=>{L.dao.channel().on(ct.Active,r=>{const i=L.dao.channel().dealWithActiveEvent(r,!1);n(i)})}))}activePlayground(){L.dao.channel().active()}retainingAllFiles(){return L.dao.channel().retainingAllFiles(),L.dao.channel().off("retainingAllFiles"),new Promise(e=>{L.dao.channel().on("retainingAllFiles",n=>{e(n)})})}runPlayground(){return new Promise((e,n)=>{const r=L.file.pendingUpdateCount();if(r>0)return n(this.handleErrorRes(Pn("editor_pending_update",{pendingUpdate:r})));L.dao.channel().run(),e(this.handleSuccessRes("running"))})}stopPlayground(){L.dao.channel().stop()}getUnitTestFun(){const e=L.dao.playgroundInfo().status;if(e!=="ACTIVE"){const n={code:e,action:Cn.GetUnitTestFun,message:"You need to active docker."};return Ot.info(n),Promise.reject(n)}return L.dao.channel().getUnitTestFun(),L.dao.channel().off(Cn.GetUnitTestFun),new Promise(n=>{L.dao.channel().on(Cn.GetUnitTestFun,r=>{n(r)})})}getRunId(e){return e+"_"+Cn.RunUnitTestResult}runUnitTestByFilePath(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const r={code:n,action:Cn.RunUnitTestResult,message:"You need to active docker."};return Ot.info(r),Promise.reject(r)}L.dao.channel().runUnitTestByFilePath(e)}stopUnitTest(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const o={code:n,action:Cn.StopUnitTest,message:"You need to active docker."};return Ot.info(o),Promise.reject(o)}const r=Array.isArray(e)?[...e]:[e],i=[];r.forEach(o=>{const s=this.getRunId(o);i.push(s)}),L.dao.channel().stopUnitTest(i)}getRunCmdRunId(e){return e+"_"+Cn.RunCmd}runCmd(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const i={code:n,action:Cn.RunCmd,message:"You need to active docker."};return Ot.info(i),Promise.reject(i)}const r=this.getRunCmdRunId(e.cmd);e.runId=r,L.dao.channel().runCmd(e)}stopRunCmd(e){const n=L.dao.playgroundInfo().status;if(n!=="ACTIVE"){const i={code:n,action:Cn.StopRunCmd,message:"You need to active docker."};return Ot.info(i),Promise.reject(i)}const r=this.getRunCmdRunId(e);L.dao.channel().stopRunCmd(r)}appendCustomizeFrameDataSync(e){return L.dao.channel().appendCustomizeFrameData(e),L.dao.channel().off(ct.AppendCustomizeFrameData),new Promise(n=>{L.dao.channel().on(ct.AppendCustomizeFrameData,r=>{n(r)})})}appendCustomizeFrameData(e){L.dao.channel().appendCustomizeFrameData(e)}statisticsPlaybackData(e,n){return new Promise((r,i)=>{if(!L.dao.isReady())return i(this.handleErrorRes("no ready"));if(!e||!(n!=null&&n.length)){r({status:"fail",message:"please input right parmas",errorCode:"ERROR_PARMAS"});return}L.dao.channel().statisticsPlaybackData(e,n),L.dao.channel().off("statisticsPlaybackData"),L.dao.channel().on("statisticsPlaybackData",o=>{r({status:"success",data:o})})})}onMessage(e){L.dao.channel().addMessageListener(e)}claudejsonRestart(){L.dao.channel().claudejsonRestart()}removeMessage(e){L.dao.channel().removeMessageListener(e)}onError(e){L.dao.channel().addErrorListener(e)}removeError(e){L.dao.channel().removeErrorListener(e)}subscribePlayControlEvent(e){L.dao.channel().subscribeForPlayControl(e)}unsubscribePlayControlEvent(e){L.dao.channel().unsubscribeForPlayControl(e)}subscribe(e,n){L.dao.channel().subscribeForComponent(e,n)}unsubscribe(e,n){L.dao.channel().unsubscribeForComponent(e,n)}updateFileHeader(e){he.file.setFileHeader(e)}initComponent(e,n,r){const i=document.querySelector(n);if(!i)throw new Error(Pn("dao_paas_not_find_mount_dom_object_for_x",{x:n}));const o=pA(i),s=a=>{switch(e){case"Tree":return Z(RKe,{...a});case"Editor":return Z(AKe,{...a});case"Browser":return Z(XKe,{...a});case"Console":return Z(IKe,{...a});case"Shell":return Z(DKe,{...a});case"MarkdownPreview":return Z(NKe,{...a});case"Debug":return Z(zKe,{...a});case"ClaudeCode":return Z(MKe,{...a});case"ClaudeJson":return Z(LKe,{...a});default:throw new Error(Pn("dao_paas_x_component_is_not_supported",{x:e}))}};this.components[e]={reactComponent:s,container:n,props:r,root:o},o.render(Z(C.exports.Suspense,{children:Z(s,{...r})})),L.dao.channel().uploadLog("RenderComponent",e)}mountMarkdownPreview(){const{MarkdownPreview:e}=this.components;if(Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u6302\u8F7D\u4E2D",this.markdownSchema),e)Ot.debug("\u6302\u8F7D\u5931\u8D25\uFF0C\u8BF7\u52FF\u91CD\u590D\u6302\u8F7D\u540C\u4E00\u4E2A\u7EC4\u4EF6",this.markdownSchema);else if(Object.keys(this.markdownSchema).length>0){const{item:n,container:r,props:i}=this.markdownSchema;this.initComponent(n,r,i),Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u6302\u8F7D\u5B8C\u6210",this.markdownSchema)}}unMountMarkdownPreview(){var n;const{MarkdownPreview:e}=this.components;Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u5378\u8F7D\u4E2D",e),e?((n=e.root)==null||n.unmount(),this.components.MarkdownPreview=null,Ot.debug("markdown\u9884\u89C8\u7EC4\u4EF6\u5378\u8F7D\u6210\u529F",e)):Ot.debug("\u5378\u8F7D\u5931\u8D25\uFF0Cmarkdown\u9884\u89C8\u7EC4\u4EF6\u4E0D\u5B58\u5728",e)}mapRender(e){for(const n of e){const{item:r,container:i,props:o}=n;if(this.components[r])throw new Error(`Before the SDK is destroyed, the ${r} component cannot be rendered repeatedly`);r==="MarkdownPreview"&&(this.markdownSchema=n,!o.isRender)||this.initComponent(r,i,o)}}unmapRender(e){var r;const n=this.components[e];if(!n)return!1;try{(r=n.root)==null||r.unmount()}catch{}return this.components[e]=null,!0}isShowPreviewMDIframe(e){L.dao.channel().trigger("message",{name:"showPreviewMDIframe",payload:e})}handleErrorRes(e){return{status:!1,message:e}}handleSuccessRes(e){return{status:!0,message:e}}insertTextById(e,n,r){L.dao.channel().insertTextById(e,n,r)}updateAreaFlags(e){L.dao.channel().updateAreaFlags(e)}removeAreaTextById(e,n,r){L.dao.channel().removeAreaTextById(e,n,r)}jumpToAreaById(e,n){L.dao.channel().jumpToAreaById(e,n)}switchLanguage(e,n,r,i){return new Promise((o,s)=>{if(!L.dao.isReady())return s(this.handleErrorRes(Pn("dao_paas_no_ready")));L.dao.channel().switchLanguage(e,n,r,i),L.dao.channel().off("switchLanguage"),L.dao.channel().on("switchLanguage",a=>{const l=L.file.getOpenedPath(),{destination:c}=a;a.status&&r===l&&(L.dao.channel().loadFile(c),o(this.handleSuccessRes(Pn("common_success")))),o(a)})})}restartServer(){return new Promise((e,n)=>{if(!L.dao.isReady())return n(this.handleErrorRes(Pn("dao_paas_no_ready")));L.dao.channel().restartServer(),L.dao.channel().off("restartServer"),L.dao.channel().on("restartServer",r=>{const i={status:r.success,message:r.success?r.message||r.messageId:r.error};e(i)})})}turnOnLSPServer(e,n=!0){if(he.config.stopLsp(e),!L.dao.isReady())return this.handleErrorRes(Pn("dao_paas_no_ready"));L.dao.channel().stopLSPServer(e,n)}restartLSPServer(){if(!L.dao.isReady())return this.handleErrorRes(Pn("dao_paas_no_ready"));L.dao.channel().restartLSPServer()}addCDNSource(e,n,r){return new Promise((i,o)=>{if(!L.dao.isReady())return o(this.handleErrorRes(Pn("dao_paas_no_ready")));L.dao.channel().addCDNSource(e,n,r),L.dao.channel().off("addCDNSource"),L.dao.channel().on("addCDNSource",s=>{const a=L.file.getOpenedPath();s.status&&r===a&&this.openFile(r,"refresh"),i(s)})})}openFile(e,n="default"){return L.dao.channel().openFile(e,n)}updateGlobalBaseConfig(e){he.config.update(e)}updateGlobalConfig(e){const n={...L.config.globalConfig(),...e};window.navigator.cookieEnabled&&(window.localStorage.setItem("paasGlobalConfig",JSON.stringify(n)),he.config.globalConfig(n))}updateConfig(e){const n={...L.dao.config(),...e};he.dao.config(n)}toggleMarkDownPreview(e){e?this.mountMarkdownPreview():this.unMountMarkdownPreview()}reload(e=["Editor","Tree"]){const n={file:()=>{he.dao.setPlaygroundInfo(ste),he.file.reset()}},r=(e==null?void 0:e.includes("Editor"))||(e==null?void 0:e.includes("Tree"))?"file":"";e&&r&&n[r]()}switchI18nLanguage(e){he.i18n.setLanguage(e),L.dao.channel().emitI18nLanguage(e),Xo.changeLanguage(e)}offlineVirtualUser(){return L.dao.channel().offlineVirtualUser()}registerVirtualUser(e){return L.dao.channel().registerVirtualUser(e)}switchVirtualUser(e){return L.dao.channel().switchVirtualUser(e)}reloadI18nResources(e,n){try{(Array.isArray(e)?e:[{language:e,resource:n}]).forEach(i=>{Xo.addResources(i.language,"translation",i.resource)}),Xo.changeLanguage(L.i18n.getLanguage())}catch(r){Ot.error("\u66F4\u65B0\u56FD\u9645\u5316\u6587\u672C\u5931\u8D25\uFF0C\u9519\u8BEF:",r)}}getEditorContent(){const e=L.file.editorView(),n=e?e.state.doc.toJSON().join(`
|
|
715
715
|
`):L.file.doc().content;return{path:L.file.doc().openedPath,content:n}}debugRun(){L.dao.channel().debugRun()}setFileStyle(e){try{he.file.setFileStyle(e)}catch(n){Ot.error("\u8BBE\u7F6E\u6587\u4EF6\u6837\u5F0F\u5931\u8D25\uFF0C\u9519\u8BEF:",n)}}syncXtermKey(e){L.dao.getFollowingAgentUser()||L.dao.channel().xtermStatus({xtermKey:e})}syncServeDocForce(){he.file.refresh()}switchLspDiagnostic(e){var r,i,o;if(typeof e!="boolean")throw new Error("The switchLspDiagnostic function expects a Boolean parameter");(r=L.file.lspClient())==null||r.setOpenDiagnostic(e);const n=L.file.editorView();if(n&&e){const s=MA({rootUri:L.dao.playgroundInfo().lspRootPath,lspLanguageId:L.dao.playgroundInfo().lspLanguageId});(o=L.file.lspClient())==null||o.textDocumentDidChange({textDocument:{uri:s.documentUri(),version:((i=L.file.lspClient())==null?void 0:i.documentVersion)||0},contentChanges:[{text:n.state.doc.toString()}]});return}n&&!e&&n.dispatch(jie(n.state,[])),he.file.openLspDiagnostic(e)}forceRefreshFile(e){L.dao.channel().forceRefreshFile(e)}customExecute(e){L.dao.channel().customExecute(e)}focuseEditorByCursorPosition(e,n){const r=L.file.editorView();if(r){r.focus();const i=r.state.doc.length;n=n>i?i:n,r==null||r.dispatch({selection:{anchor:n,head:n},effects:[ut.scrollIntoView(n,{y:"center"})]})}}insertCodeByCursor(e){return new Promise((n,r)=>{const i=L.file.getOpenedPath(),o=L.file.editorView();if(i&&o){const s=o.state.selection.main.head,a=o.state.doc.lineAt(s).number;e(a,l=>{L.dao.channel().insertCodeByCursor(l)}),n("")}else r("\u6587\u4EF6\u672A\u6253\u5F00")})}setFileLockStatus(e){L.dao.channel().setFileLockStatus(e)}setFileVisible(e){L.dao.channel().setFileVisible(e)}setFileToUnitTest(e){e.unitTest?L.dao.channel().addFileToUnitTest(e.path):L.dao.channel().removeFileFromUnitTest(e.path)}dispose(){var e;Ot.debug("destroy components...",this.components),this.reset();for(const[n,r]of Object.entries(this.components)){if(!r)break;(e=r.root)==null||e.unmount(),Ot.debug(`destroy unmount: ${r.container}`)}Ot.debug("close ws..."),L.dao.channel().closeChannel(),this.components=za.exports.cloneDeep(lV)}loggerEnable(){DQe()}}const ic=({icon:t,active:e=!1,disabled:n=!1,radius:r=4,iconSize:i=16,className:o="",style:s={},onClick:a})=>{const l=C.exports.useMemo(()=>`d42 ${t}`,[t]),c=C.exports.useMemo(()=>n?"dao-icon-button style-disabled":e?"dao-icon-button style-active":"dao-icon-button style-default",[e,n]),u=d=>{n||(d.stopPropagation(),a&&a(d))};return Z(yo,{children:Z("button",{className:`${c} ${o}`,style:{borderRadius:`${r}px`,...s},onClick:d=>u(d),children:Z("i",{style:{fontSize:`${i}px`},className:l})})})};function BKe(t,e,n){if(!n||!t)return{left:0,width:0,height:0,top:0,pageScrollTop:0};const r=m=>document.documentElement[m]||document.body[m],i=n===document.body?r("scrollTop"):n.scrollTop,o=n===document.body?r("scrollLeft"):n.scrollLeft,{left:s,top:a,width:l,height:c}=e,u=n===document.body?0:n.getBoundingClientRect().left,d=n===document.body?0:n.getBoundingClientRect().top,f=a+i-d;return{left:s+o-u,top:f,width:l,height:c,pageScrollTop:i,pageScrollLeft:o}}function jce(t,e,n,r){if(!n||!e||!r)return{};const{position:i,popupAlign:o}=t,s={},a=n.getBoundingClientRect(),{left:l,top:c,width:u,height:d,pageScrollTop:f}=BKe(n,a,r);let h=i;const m=o.left||0,g=o.right||0,O=o.top||0,p=o.bottom||0,v=w=>{const S=(r==null?void 0:r.clientHeight)||window.innerHeight,Q=(r==null?void 0:r.clientWidth)||window.innerWidth;let k=!1;const E={left:l-a.left,top:c-a.top},{top:X=0,left:D=0}=s;if((w==="top"||w==="bottom")&&(E.left>D&&a.right>12?(s.left=Math.max(E.left,l-e.clientWidth),s.left=Math.max(s.left,l-e.clientWidth+24)):D-E.left+e.clientWidth>Q&&Q-a.left>12&&(s.left=Math.max(E.left,E.left+Q-e.clientWidth),s.left=Math.max(s.left,l-e.clientWidth+24))),(w==="left"||w==="right")&&(E.top>X&&a.bottom>12?(s.top=E.top,s.top=Math.max(s.top,c-e.clientHeight+a.height/2)):X-E.top+e.clientHeight>S&&S-a.top>12&&(s.top=Math.max(E.top,E.top+S-e.clientHeight),s.top=Math.max(s.top,c-e.clientHeight+a.height/2))),w==="top"&&E.top>X&&(a.top<S-a.bottom?(s.top=Math.min(c+d+(O||0),E.top+S-e.clientHeight),k=!0):s.top=E.top),w==="bottom"&&X-f+e.clientHeight>S&&(S-a.bottom<a.top?(s.top=Math.max(c-e.clientHeight-(p||0),E.top),k=!0):s.top=E.top+S-e.clientHeight),w==="left"&&E.left>D&&(a.left<Q-a.right?(s.left=Math.min(u+l+g,E.left+Q-e.clientWidth),k=!0):s.left=E.left),w==="right"&&D-E.left+e.clientWidth>Q&&(Q-a.right<a.left?(s.left=Math.max(l-e.clientWidth-m,E.left),k=!0):s.left=E.left+Q-e.clientWidth),s.left<0)s.left=0;else{const P=r.scrollWidth-e.clientWidth;s.left=Math.min(P,s.left)}return k},y=0,_=0;switch(t.position){case"top":{s.top=c-e.clientHeight-O,s.left=l+u/2-e.clientWidth/2,v("top")&&(h="bottom"),s.left+=y;break}case"tl":s.top=c-e.clientHeight-O,s.left=l,v("top")&&(h="bl"),s.left+=y;break;case"tr":s.top=-e.clientHeight+c-O,s.left=l+u-e.clientWidth,v("top")&&(h="br"),s.left+=y;break;case"bottom":{s.top=d+c+p,s.left=l+u/2-e.clientWidth/2,v("bottom")&&(h="top"),s.left+=y;break}case"bl":s.top=d+c+p,s.left=l,v("bottom")&&(h="tl"),s.left+=y;break;case"br":s.top=d+c+p,s.left=l+u-e.clientWidth,v("bottom")&&(h="tr"),s.left+=y;break;case"left":{s.top=c+d/2-e.clientHeight/2,s.left=l-e.clientWidth-m,v("left")&&(h="right"),s.top+=_;break}case"lt":s.top=c,s.left=l-e.clientWidth-m,v("left")&&(h="rt"),s.top+=_;break;case"lb":s.top=c+d-e.clientHeight,s.left=l-e.clientWidth-m,v("left")&&(h="rb"),s.top+=_;break;case"right":{s.top=c+d/2-e.clientHeight/2,s.left=u+l+g,v("right")&&(h="left"),s.top+=_;break}case"rt":s.top=c,s.left=u+l+g,v("right")&&(h="lt"),s.top+=_;break;case"rb":s.top=c+d-e.clientHeight,s.left=u+l+g,v("right")&&(h="lb"),s.top+=_;break}return{style:s,realPosition:h}}function N8(t,e){if(!t)return!1;if(t.contains)return t.contains(e);let n=e;for(;n;){if(n===t)return!0;n=n.parentNode}return!1}function FKe(){const t=C.exports.useRef(!0);return C.exports.useEffect(()=>{t.current=!1},[]),t.current}const qKe=t=>{const{getContainer:e,children:n}=t,r=C.exports.useRef();return(FKe()||r.current===null)&&(r.current=e()),C.exports.useEffect(()=>()=>{const o=r.current;o&&o.parentNode&&(o.parentNode.removeChild(o),r.current=null)},[]),r.current?qc.createPortal(n,r.current):null};function WKe(t){const e=C.exports.useRef(null),[n,r]=C.exports.useState(t);C.exports.useEffect(()=>{e.current&&(e.current(n),e.current=null)},[n]);const i=C.exports.useCallback((o,s)=>(e.current=s,r(o)),[]);return[n,i]}const YKe=Cr.div``,VKe={className:"",position:"bottom",trigger:"hover",mouseLeaveDelay:100,mouseEnterDelay:200,duration:200,disabled:!1,visibility:!1,unmountOnExit:!0,popupHoverStay:!0,popupAlign:{left:6,right:6,top:6,bottom:6}},Ji=t=>{const{popup:e,children:n,position:r,trigger:i,duration:o,popupAlign:s,disabled:a,className:l,unmountOnExit:c,mouseLeaveDelay:u,mouseEnterDelay:d,popupHoverStay:f,visibility:h,getPopupContainer:m}=Object.assign({},VKe,t),[g,O]=WKe(!1),[p,v]=C.exports.useState({}),y=C.exports.useRef(null),_=C.exports.useRef(null),w=C.exports.useRef(null),S=C.exports.useRef(!1),Q=C.exports.useRef(null),k=C.exports.useRef(null),E=(le,Oe)=>{le?(X(),Q.current=setTimeout(()=>{Oe(),X()},le)):Oe()};C.exports.useEffect(()=>{h&&(M(!0,0),setTimeout(()=>{M(!1,0)},1e3*3))},[h]),C.exports.useEffect(()=>()=>{X()},[]),C.exports.useEffect(()=>{a&&Y()},[a]);const X=()=>{Q.current&&(clearTimeout(Q.current),Q.current=null)},D=C.exports.useCallback(()=>{if(!_.current||!y.current||!w.current)return;const le=_.current,Oe=y.current,H=w.current,{style:ae}=jce({position:r,popupAlign:s},Oe,H,le);return{...ae}},[s,r]),P=C.exports.useCallback(()=>{const le=D();v(le||{})},[D]);C.exports.useEffect(()=>{S.current&&(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{P()},80))},[e,P]);const M=(le,Oe=0)=>{E(Oe,()=>{le?(O(!0,()=>{P()}),S.current=!0):(O(!1,()=>{}),S.current=!1)})},V=()=>{X(),M(!0,d||0)},Y=()=>{X(),M(!1,u||0)},G=()=>{X()},W=()=>{Y()},N={},B={};i==="hover"&&!a&&(N.onMouseEnter=V,N.onMouseLeave=Y,f&&(B.onMouseEnter=G,B.onMouseLeave=W));const R=Z(zt.Fragment,{children:zt.cloneElement(n,{})}),ee=()=>{var H;const le=document.createElement("div");return le.style.width="100%",le.style.position="absolute",le.style.top="0",le.style.left="0",_.current=le,(m&&(H=m())!=null?H:document.body).appendChild(le),le},ie=zt.Children.only(e()),te=Z(RO,{in:!!g,timeout:o,classNames:"d42-fade",unmountOnExit:c,appear:!0,mountOnEnter:!0,onEnter:le=>{le.style.display="initial",le.style.pointerEvents="none"},onEntered:le=>{le.style.pointerEvents="auto"},onExit:le=>{le.style.pointerEvents="none"},onExited:le=>{le.style.display="none",c&&(y.current=null),v({})},children:Z("div",{ref:y,style:{position:"absolute",zIndex:1115,...p},...B,children:Z("div",{className:"d42-tooltip-content",children:Z(ie.type,{className:"d42-tooltip-title",ref:ie.ref,...ie.props,style:{...ie.props.style}})})})}),me=g||y.current?Z(qKe,{getContainer:ee,children:te}):null;return Z(YKe,{className:"d42-tooltip",ref:w,children:ze(zt.Fragment,{children:[Z("div",{...N,className:l,children:R}),me]})})};const ZKe=({handleClear:t,handleExpand:e,handleRefresh:n})=>{const{t:r}=Lo();return Z(yo,{children:ze("div",{className:"file-search-tool-bar d42-root-toolbar",children:[Z("strong",{children:r("keyword_search_toolbar_title")}),ze("div",{className:"tool-bar-right",children:[Z(Ji,{popup:()=>Z("span",{children:r("keyword_search_btn_refresh")}),children:Z(ic,{icon:"dao42__icon--refresh",onClick:i=>n(i)})}),Z(Ji,{popup:()=>Z("span",{children:r("keyword_search_btn_clear")}),children:Z(ic,{icon:"dao42__icon--file-search-clear",onClick:i=>t(i)})}),Z(Ji,{popup:()=>Z("span",{children:r("keyword_search_btn_collapse")}),children:Z(ic,{icon:"dao42__icon--file-search-expand",onClick:i=>e(i)})})]})]})})};function Wb(){return navigator.userAgent.includes("Mac OS")}const Gce=C.exports.forwardRef(({isExpanded:t,searchState:e,disabled:n,valueSearch:r,valueReplace:i,wholeActive:o,regularActive:s,letterActive:a,preserveActive:l,matchLetter:c,matchWhole:u,matchRegular:d,preserveCase:f,handleReplaceAll:h,handleExpandSearch:m,onChangeSearch:g,onKeyDownSearch:O},p)=>{const{t:v}=Lo(),y=C.exports.useRef(null),_=C.exports.useRef(null),w=(S,Q)=>{switch(S.stopPropagation(),Q){case"letter":c();break;case"whole":u();break;case"regular":d();break;case"preserve":f();break;case"replace":h();break}};return C.exports.useImperativeHandle(p,()=>({inputEnterFocus:()=>{var S;return(S=y.current)==null?void 0:S.focus()},inputReplaceFocus:()=>{var S;return(S=_.current)==null?void 0:S.focus()}})),Z("div",{className:"file-search-input",children:Z("div",{className:"file-search-input-containor",children:ze("div",{className:"file-search-input-section",children:[ze("div",{className:"input-component-wrap",children:[Z("div",{className:e?"input-wrap input-disabled":"input-wrap",children:Z("input",{ref:y,type:"text",placeholder:v("keyword_search_input_enter_placeholder"),disabled:e,value:r,onChange:S=>g(S,"search"),onKeyDown:S=>O(S,"search")})}),ze("div",{className:"button-group",children:[Z(Ji,{popup:()=>Z("span",{children:v("keyword_search_btn_case",{press:"Alt + C"})}),children:Z(ic,{icon:"dao42__icon--match-letter",active:a,onClick:S=>w(S,"letter")})}),Z(Ji,{popup:()=>Z("span",{children:v("keyword_search_btn_whole",{press:"Alt + W"})}),children:Z(ic,{icon:"dao42__icon--match-whole",active:o,onClick:S=>w(S,"whole")})}),Z(Ji,{popup:()=>Z("span",{children:v("keyword_search_btn_expression",{press:"Alt + R"})}),children:Z(ic,{icon:"dao42__icon--match-regular",active:s,onClick:S=>w(S,"regular")})})]})]}),t&&ze("div",{className:"replace-input-section",children:[ze("div",{className:"input-component-wrap mr-8",children:[Z("div",{className:e?"input-wrap input-disabled":"input-wrap",children:Z("input",{ref:_,type:"text",placeholder:v("keyword_search_input_replace_placeholder"),disabled:e,value:i,onChange:S=>g(S,"replace"),onKeyDown:S=>O(S,"replace")})}),Z("div",{className:"button-group",children:Z(Ji,{popup:()=>Z("span",{children:v("keyword_search_btn_preserve",{press:"Alt + P"})}),children:Z(ic,{icon:"dao42__icon--preserve-case",active:l,onClick:S=>w(S,"preserve")})})})]}),Z(Ji,{disabled:n,popup:()=>Z("span",{children:v("keyword_search_btn_replace_all",{press:`${Wb()?"Command":"Ctrl"} + Alt + Enter`})}),children:Z(ic,{className:"icon-replace-all",icon:"dao42__icon--replace-all",iconSize:20,radius:8,disabled:n,onClick:S=>w(S,"replace")})})]})]})})})});Gce.displayName="FsileSearchInput";const jKe=t=>t.reduce((e,n)=>(e.file+=1,e.words=e.words+n.rows.length,e),{file:0,words:0}),GKe=t=>{const e=[];for(const n in t){const r=n,i=t[n];e.push({title:r,rows:i,isExpand:!0})}return e},HKe=(t,e,n,r)=>{const i="^\\$.\\*+-?=!:|\\/()[]{}";let o;if(!t)return"";if(e)if(e instanceof Array){if(!e.length)return t;o=new RegExp(e.reduce((s,a)=>(a&&s.push(i.includes(a)?"\\"+a:a),s),[]).join("|"),r?"ig":"g")}else typeof e=="string"&&(o=new RegExp(e,r?"ig":"g"));if(t&&o){const s=t.split(o),a=t.match(o),l=s.length;return Z(yo,{children:s.map((c,u)=>ze(yo,{children:[c,u!==l-1&&Z("mark",{style:n,children:a==null?void 0:a[u]})]}))})}return t};const KKe={background:"var(--d42-keyword-search_highlight-bg)",color:"#EBEBF0",borderRadius:"4px"},JKe=({isExpanded:t,searchState:e,letterActive:n,searchData:r,searchTip:i,keyword:o,handleReplaceSingle:s,handleResultExpand:a,handleDeleteFile:l,handleDeleteRow:c,handleSelectRow:u})=>{const d=(h,m,g)=>{switch(h.stopPropagation(),g){case"replace":s();break;case"delete":l(m);break;case"expand":a(m);break}},f=(h,m,g,O,p)=>{switch(h.stopPropagation(),p){case"delete":c(m,O);break;case"select":u(h,m,g);break}};return ze("div",{className:"file-search-result",children:[ze("div",{className:"result-tips-wrap",children:[Z("div",{className:"result-tips",children:i}),e&&Z("div",{className:"d42-root-toolbar-btns",children:Z("i",{className:"d42 dao42__icon--loading"})})]}),Z("div",{className:"result-files",children:r.map(h=>ze("div",{className:"result-file-wrap",children:[ze("div",{className:"result-file-title-wrap",children:[Z("div",{className:"abs-btn",children:Z(ic,{icon:h.isExpand?"d42 dao42__icon--smb-icon-arrow-down":"d42 dao42__icon-arrow-right",onClick:m=>d(m,h,"expand")})}),ze("div",{className:"result-file-title",children:[Z("div",{className:"result-file-title-context context-over-style",children:h.title}),ze("div",{className:"result-file-title-right",children:[Z("p",{className:"result-file-title-count",children:h.rows.length}),Z("div",{className:"button-group",children:Z(ic,{icon:"dao42__icon--close",onClick:m=>d(m,h,"delete")})})]})]})]}),Z("ul",{className:h.isExpand?"result-file-rows":"result-file-rows file-rows-hidden",children:h.rows.map((m,g)=>ze("li",{className:m.active?"file-item-active":"file-item-hover",onClick:O=>f(O,h,m,g,"select"),children:[Z("p",{className:"context-over-style",children:HKe(m.text,o,KKe,!n)}),m.active&&Z(ic,{icon:"dao42__icon--replace-single",onClick:O=>d(O,h,"replace")}),Z(ic,{icon:"dao42__icon--close",onClick:O=>f(O,h,m,g,"delete")})]},`${m.text}_${m.line}_${g}`))})]},h.title))})]})},eJe=Cr.div`
|
|
716
716
|
&.d42-btn {
|
|
717
717
|
padding: 5px 20px;
|
package/dist/DaoPaaS.d.ts
CHANGED
|
@@ -451,6 +451,13 @@ export interface IDaoPaaS {
|
|
|
451
451
|
* @param {Component[]} components 组件配置信息
|
|
452
452
|
*/
|
|
453
453
|
mapRender(components: Component[]): void;
|
|
454
|
+
/**
|
|
455
|
+
* 卸载已通过 mapRender 挂载的组件。
|
|
456
|
+
* 宿主组件 v-if 切换或父级路由切换时调用,避免下一次 mapRender 撞到守卫。
|
|
457
|
+
* @param {string} componentName 组件名(与 mapRender 的 item 字段对应)
|
|
458
|
+
* @returns {boolean} 之前是否真的挂载过该组件
|
|
459
|
+
*/
|
|
460
|
+
unmapRender(componentName: string): boolean;
|
|
454
461
|
/**
|
|
455
462
|
* 设置本地logger打印是否开启的方法
|
|
456
463
|
* @param {any} data 设置的值,当这个值存在就会打印logger
|