minecodex 2.0.16 → 2.0.17
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/apps/dashboard/app.js
CHANGED
|
@@ -222,7 +222,7 @@ function updatePluginCard(card, feature) {
|
|
|
222
222
|
const dot = card.querySelector(".plugin-state .status-dot");
|
|
223
223
|
const stateLabel = card.querySelector(".plugin-state-label");
|
|
224
224
|
card.dataset.featureId = feature.id;
|
|
225
|
-
image.src = `${feature.iconUrl}?v=resource-1`;
|
|
225
|
+
image.src = feature.iconUrl.startsWith("data:") ? feature.iconUrl : `${feature.iconUrl}?v=resource-1`;
|
|
226
226
|
name.textContent = feature.label;
|
|
227
227
|
description.textContent = feature.description;
|
|
228
228
|
input.checked = Boolean(feature.enabled);
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var vz=Object.defineProperty;var Rn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var zt=(e,t)=>{for(var n in t)vz(e,n,{get:t[n],enumerable:!0})};function G$(e){return{minecodexVersion:e?.version??null,codexBuild:e?.renderer?.codexBuild??e?.runtime?.codex?.version??null,buildSource:e?.renderer?.buildSource??null,verification:"runtime-observation-only",targets:(e?.renderer?.targets??[]).map(t=>({targetId:t.targetId,checkedAt:t.checkedAt,reason:t.reason??null,tokens:t.tokens,capabilities:t.capabilities,plugins:(t.plugins??[]).map(n=>({featureId:n.featureId,installation:n.installation,state:n.state,reason:n.reason,checks:n.checks,tokens:n.tokens}))})),services:(e?.features??[]).map(t=>({featureId:t.id,state:t.state,failureCode:t.failure?.code??null}))}}var W$=Rn(()=>{});async function sn(e,t={}){let n=window.minecodexMcpApp;if(!n)return fetch(e,t);let o=t.method??"GET",r=await n.callServerTool({name:o==="GET"?"minecodex_read":"minecodex_write",arguments:{route:e,method:o,locale:new Headers(t.headers).get("Accept-Language")??document.documentElement.lang,...t.body?{body:JSON.parse(t.body)}:{}}});if(r.isError)throw new Error(r.content?.find(s=>s.type==="text")?.text??"MineCodex request failed");let{status:i,body:a}=r.structuredContent;return new Response(JSON.stringify(a),{status:i,headers:{"Content-Type":"application/json"}})}var Vv=Rn(()=>{});var ET={};function kT(){D.languageToggle.setAttribute("aria-label",At==="zh-CN"?"\u8BED\u8A00":"Language");for(let e of D.languageButtons)e.setAttribute("aria-pressed",String(e.dataset.languageChoice===At));D.runtimeLabel.textContent=Y.connecting,D.restartTitle.textContent=Y.restartTitle,D.restartCopy.textContent=Y.restartCopy,D.restartButton.querySelector(".button-label").textContent=Y.restart,D.pluginsHeading.textContent=Y.plugins,D.errorTitle.textContent=Y.loadError,D.errorCopy.textContent=Y.loadErrorCopy,D.retryButton.textContent=Y.retry,D.versionLabel.textContent=Y.version,D.diagnosticsButton.textContent=Y.copyDiagnostics,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}function xT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=Y.states[t]??Y.states.stopped,o={healthy:"is-active",injected:"is-active",configured:"is-warning",failed:"is-failed",launching:"is-warning","restart-required":"is-warning",saved:"is-warning",stopped:"is-stopped"}[t]??"is-warning";return{label:e.failure?.message&&t==="failed"?`${n}: ${Y.failureDetail}`:n,className:o}}function qe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function IT(e){let t=qe("article","plugin-card");t.dataset.featureId=e.id;let n=qe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=qe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=qe("div","plugin-copy"),i=qe("div","plugin-title-line"),a=qe("h3","plugin-name");i.append(a);let s=qe("p","plugin-description");r.append(i,s);let l=qe("div","plugin-topline"),c=qe("label","switch"),d=qe("input");d.type="checkbox",d.name=`feature-${e.id}`,d.setAttribute("role","switch"),d.setAttribute("aria-describedby",`description-${e.id} state-${e.id}`),s.id=`description-${e.id}`;let p=qe("span","switch-track");p.setAttribute("aria-hidden","true"),c.append(d,p);let h=qe("span","plugin-state"),f=qe("span","status-dot");f.setAttribute("aria-hidden","true");let v=qe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),t}function Ud(e,t){for(let c of D.languageButtons)c.disabled=at.size>0;let n=xT(t),o=e.querySelector('input[type="checkbox"]'),r=e.querySelector(".plugin-icon img"),i=e.querySelector(".plugin-name"),a=e.querySelector(".plugin-description"),s=e.querySelector(".plugin-state .status-dot"),l=e.querySelector(".plugin-state-label");e.dataset.featureId=t.id,r.src=`${t.iconUrl}?v=resource-1`,i.textContent=t.label,a.textContent=t.description,o.checked=!!t.enabled,o.disabled=at.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label}function Q$(e){return[...D.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function RT(e){e=e.filter(n=>n.id!=="unread-inbox");for(let n of[...D.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let n of e){let o=Q$(n.id);o||(o=IT(n)),D.pluginList.append(o),Ud(o,n)}for(let n of[...D.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&n.remove();D.pluginList.setAttribute("aria-busy","false")}function ez(){let e=!!ze?.runtime?.running,t=ze?.renderer,n=!!(t?.discovered&&t.runtimeSessionId&&t.runtimeSessionId===ze?.runtime?.runtimeSessionId&&t.active&&Number(t.injectedTargets)>0),o=e&&n;D.runtimeLabel.closest(".overview").hidden=o,D.runtimeDot.className=`status-dot ${o?"is-active":"is-warning"}`,D.runtimeLabel.textContent=o?Y.runtimeActive:e?Y.runtimeNotInjected:Y.runtimeStopped,D.versionValue.textContent=ze?.version??"\u2014",D.restartNotice.hidden=!ze?.pendingRestart}function PT(){ez(),RT(ze?.features??[])}function TT(e){let t=document.activeElement,n=t?.closest?.("[data-feature-id]");return!n||n.dataset.featureId!==e?null:{featureId:e,input:t.matches?.('input[type="checkbox"]')}}function X$(e){if(!e?.input)return;Q$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(Y$),D.toast.textContent=e,D.toast.hidden=!1,Y$=setTimeout(()=>{D.toast.hidden=!0},4200)}function Zv(e,t){ze.features=ze.features.map(n=>n.id===e?{...n,...t}:n)}async function Md(){D.loadError.hidden=!0;try{let e=await sn("/api/status",{headers:{"Accept-Language":At}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();at.size&&ze&&(t.features=t.features.map(n=>at.has(n.id)?ze.features.find(o=>o.id===n.id)??n:n)),ze=t,D.pluginList.hidden=!1,PT()}catch{D.pluginList.hidden=!0,D.loadError.hidden=!1,D.runtimeDot.className="status-dot is-warning",D.runtimeLabel.textContent=Y.runtimeStopped,D.runtimeLabel.closest(".overview").hidden=!0}}function qd(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":tz.matches,t=Tc==="dark"||Tc!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",D.themeToggle.setAttribute("aria-label",At==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of D.themeButtons)n.setAttribute("aria-label",n.dataset.themeChoice==="light"?Y.lightAppearance:Y.darkAppearance),n.setAttribute("aria-pressed",String(n.dataset.themeChoice===(t?"dark":"light")))}var Fv,At,Y,D,ze,Y$,at,tz,Tc,rz=Rn(()=>{W$();Vv();try{Fv=localStorage.getItem("minecodex-language")}catch{}At=["en","zh-CN"].includes(Fv)?Fv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=At;Y={en:{connecting:"Connecting\u2026",runtimeActive:"Active in Codex",runtimeStopped:"Runtime unavailable",runtimeNotInjected:"Runtime running \u2014 restart Codex to apply plugins",plugins:"Your extensions",restartTitle:"Restart Codex to apply changes",restartCopy:"Your plugin choices are saved. Restart when you are ready.",restart:"Restart Codex",restarting:"Restarting\u2026",saved:"Saved",saving:"Saving\u2026",states:{saved:"Saved \u2014 restart Codex to apply",configured:"Configured \u2014 starting in Codex\u2026",launching:"Launching in Codex\u2026",injected:"Active in Codex",healthy:"Active in Codex",checking:"Checking compatibility\u2026",partial:"Available in some windows",degraded:"Appearance needs an update",unavailable:"Temporarily unavailable \u2014 check for updates","not-applicable":"Not needed on this page",failed:"Couldn\u2019t start \u2014 try again",stopped:"Stopped","restart-required":"Restart required \u2014 restart Codex"},loadError:"Couldn\u2019t load MineCodex",loadErrorCopy:"Check that the background service is running.",retry:"Try again",version:"Version",darkAppearance:"Dark appearance",lightAppearance:"Light appearance",updateFailed:"Couldn\u2019t check for updates. Please try again.",copyDiagnostics:"Copy diagnostics",diagnosticsCopied:"Diagnostics copied",diagnosticsFailed:"Couldn\u2019t copy diagnostics. Please try again.",checkUpdates:"Check for updates",checkingUpdates:"Checking\u2026",current:"You\u2019re up to date.",updateAvailable:e=>`MineCodex ${e} is available. Run mcx update in Terminal.`,changeFailed:"The plugin setting could not be saved.",restartFailed:"MineCodex could not restart Codex. Please try again or copy diagnostics.",failureDetail:"This extension could not be confirmed. Copy diagnostics to help investigate."},"zh-CN":{connecting:"\u6B63\u5728\u8FDE\u63A5\u2026",runtimeActive:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",runtimeStopped:"\u8FD0\u884C\u670D\u52A1\u4E0D\u53EF\u7528",runtimeNotInjected:"\u8FD0\u884C\u670D\u52A1\u5DF2\u542F\u52A8\u2014\u2014\u91CD\u542F Codex \u4EE5\u5E94\u7528\u63D2\u4EF6",plugins:"\u529F\u80FD\u6269\u5C55",restartTitle:"\u91CD\u542F Codex \u4EE5\u5E94\u7528\u66F4\u6539",restartCopy:"\u63D2\u4EF6\u9009\u62E9\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u53EF\u4EE5\u5728\u51C6\u5907\u597D\u540E\u7EDF\u4E00\u91CD\u542F\u3002",restart:"\u91CD\u542F Codex",restarting:"\u6B63\u5728\u91CD\u542F\u2026",saved:"\u5DF2\u4FDD\u5B58",saving:"\u6B63\u5728\u4FDD\u5B58\u2026",states:{saved:"\u5DF2\u4FDD\u5B58\u2014\u2014\u91CD\u542F Codex \u540E\u5E94\u7528",configured:"\u5DF2\u914D\u7F6E\u2014\u2014\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",launching:"\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",injected:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",healthy:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",checking:"\u6B63\u5728\u81EA\u68C0\u2026",partial:"\u90E8\u5206\u7A97\u53E3\u53EF\u7528",degraded:"\u5916\u89C2\u9002\u914D\u9700\u8981\u66F4\u65B0",unavailable:"\u6682\u4E0D\u53EF\u7528\u2014\u2014\u8BF7\u68C0\u67E5\u66F4\u65B0","not-applicable":"\u5F53\u524D\u9875\u9762\u4E0D\u9002\u7528",failed:"\u6682\u65F6\u65E0\u6CD5\u542F\u52A8\u2014\u2014\u8BF7\u91CD\u8BD5",stopped:"\u5DF2\u505C\u6B62","restart-required":"\u9700\u8981\u91CD\u542F\u2014\u2014\u8BF7\u91CD\u542F Codex"},loadError:"\u65E0\u6CD5\u52A0\u8F7D MineCodex",loadErrorCopy:"\u8BF7\u68C0\u67E5\u540E\u53F0\u670D\u52A1\u662F\u5426\u6B63\u5728\u8FD0\u884C\u3002",retry:"\u91CD\u8BD5",version:"\u7248\u672C",darkAppearance:"\u6DF1\u8272\u5916\u89C2",lightAppearance:"\u6D45\u8272\u5916\u89C2",updateFailed:"\u6682\u65F6\u65E0\u6CD5\u68C0\u67E5\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",copyDiagnostics:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",diagnosticsCopied:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",diagnosticsFailed:"\u6682\u65F6\u65E0\u6CD5\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\uFF0C\u8BF7\u91CD\u8BD5\u3002",checkUpdates:"\u68C0\u67E5\u66F4\u65B0",checkingUpdates:"\u6B63\u5728\u68C0\u67E5\u2026",current:"\u5F53\u524D\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002",updateAvailable:e=>`\u53D1\u73B0 MineCodex ${e}\uFF0C\u8BF7\u5728\u7EC8\u7AEF\u8FD0\u884C mcx update\u3002`,changeFailed:"\u63D2\u4EF6\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002",restartFailed:"MineCodex \u65E0\u6CD5\u91CD\u542F Codex\u3002\u8BF7\u91CD\u8BD5\u6216\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002",failureDetail:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u8FD9\u9879\u529F\u80FD\u7684\u72B6\u6001\uFF0C\u53EF\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002"}}[At],D={runtimeDot:document.querySelector("#runtime-dot"),runtimeLabel:document.querySelector("#runtime-label"),restartNotice:document.querySelector("#restart-notice"),restartTitle:document.querySelector("#restart-title"),restartCopy:document.querySelector("#restart-copy"),restartButton:document.querySelector("#restart-button"),pluginsHeading:document.querySelector("#plugins-heading"),saveState:document.querySelector("#save-state"),pluginList:document.querySelector("#plugin-list"),loadError:document.querySelector("#load-error"),errorTitle:document.querySelector("#error-title"),errorCopy:document.querySelector("#error-copy"),retryButton:document.querySelector("#retry-button"),versionLabel:document.querySelector("#version-label"),versionValue:document.querySelector("#version-value"),languageToggle:document.querySelector(".language-toggle"),languageButtons:[...document.querySelectorAll("[data-language-choice]")],themeToggle:document.querySelector(".theme-toggle"),themeButtons:[...document.querySelectorAll("[data-theme-choice]")],updateResult:document.querySelector("#update-result"),updateButton:document.querySelector("#update-button"),diagnosticsButton:document.querySelector("#diagnostics-button"),toast:document.querySelector("#toast")},ze=null,Y$=null,at=new Set;D.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!ze)return;let o=n.dataset.featureId,r={...ze.features.find(a=>a.id===o)},i=TT(o);at.add(o),Zv(o,{enabled:t.checked,state:"saved"}),Ud(n,ze.features.find(a=>a.id===o)),D.saveState.textContent=Y.saving;try{let a=await sn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":At},body:JSON.stringify({enabled:t.checked})});if(!a.ok)throw new Error(`HTTP ${a.status}`);let s=await a.json(),l=s.features?.find(d=>d.id===o);l&&Zv(o,l),ze.pendingRestart=s.pendingRestart,at.delete(o);let c=l??ze.features.find(d=>d.id===o);c&&Ud(n,c),ez(),X$(i),D.saveState.textContent=at.size?Y.saving:Y.saved}catch{at.delete(o),Zv(o,r),Ud(n,r),D.saveState.textContent=at.size?Y.saving:"",X$(i),Dd(Y.changeFailed)}});D.restartButton.addEventListener("click",async()=>{D.restartButton.disabled=!0,D.restartButton.querySelector(".button-label").textContent=Y.restarting;try{let e=await sn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":At},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Md()}catch{Dd(Y.restartFailed)}finally{D.restartButton.disabled=!1,D.restartButton.querySelector(".button-label").textContent=Y.restart}});D.retryButton.addEventListener("click",()=>{D.pluginList.hidden=!1,Md()});D.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(G$(ze),null,2)),Dd(Y.diagnosticsCopied)}catch{Dd(Y.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!at.size&&Md()},5e3);D.updateButton.addEventListener("click",async()=>{D.updateButton.disabled=!0,D.updateButton.querySelector(".button-label").textContent=Y.checkingUpdates,D.updateResult.hidden=!0;try{let e=await sn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();D.updateResult.textContent=t.available?Y.updateAvailable(t.latest):Y.current,D.updateResult.hidden=!1}catch{D.updateResult.textContent=Y.updateFailed,D.updateResult.hidden=!1}finally{D.updateButton.disabled=!1,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}});tz=matchMedia("(prefers-color-scheme: dark)"),Tc=null;try{Tc=localStorage.getItem("minecodex-appearance")}catch{}D.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");if(t){Tc=t.dataset.themeChoice;try{localStorage.setItem("minecodex-appearance",Tc)}catch{}qd()}});D.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||at.size||D.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==At){try{localStorage.setItem("minecodex-language",n)}catch{return}location.reload()}});tz.addEventListener("change",qd);window.addEventListener("minecodex-host-theme",qd);document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});kT();qd();Md()});function nz(e){let t="data-minecodex-tooltip",n=document.createElement("div");n.id="minecodex-feature-tooltip",n.setAttribute("role","tooltip"),n.hidden=!0;let o=document.createElement("style");o.setAttribute("data-minecodex-ui-styles","tooltip"),o.textContent=`
|
|
1
|
+
var vz=Object.defineProperty;var Rn=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var zt=(e,t)=>{for(var n in t)vz(e,n,{get:t[n],enumerable:!0})};function G$(e){return{minecodexVersion:e?.version??null,codexBuild:e?.renderer?.codexBuild??e?.runtime?.codex?.version??null,buildSource:e?.renderer?.buildSource??null,verification:"runtime-observation-only",targets:(e?.renderer?.targets??[]).map(t=>({targetId:t.targetId,checkedAt:t.checkedAt,reason:t.reason??null,tokens:t.tokens,capabilities:t.capabilities,plugins:(t.plugins??[]).map(n=>({featureId:n.featureId,installation:n.installation,state:n.state,reason:n.reason,checks:n.checks,tokens:n.tokens}))})),services:(e?.features??[]).map(t=>({featureId:t.id,state:t.state,failureCode:t.failure?.code??null}))}}var W$=Rn(()=>{});async function sn(e,t={}){let n=window.minecodexMcpApp;if(!n)return fetch(e,t);let o=t.method??"GET",r=await n.callServerTool({name:o==="GET"?"minecodex_read":"minecodex_write",arguments:{route:e,method:o,locale:new Headers(t.headers).get("Accept-Language")??document.documentElement.lang,...t.body?{body:JSON.parse(t.body)}:{}}});if(r.isError)throw new Error(r.content?.find(s=>s.type==="text")?.text??"MineCodex request failed");let{status:i,body:a}=r.structuredContent;return new Response(JSON.stringify(a),{status:i,headers:{"Content-Type":"application/json"}})}var Vv=Rn(()=>{});var ET={};function kT(){D.languageToggle.setAttribute("aria-label",At==="zh-CN"?"\u8BED\u8A00":"Language");for(let e of D.languageButtons)e.setAttribute("aria-pressed",String(e.dataset.languageChoice===At));D.runtimeLabel.textContent=Y.connecting,D.restartTitle.textContent=Y.restartTitle,D.restartCopy.textContent=Y.restartCopy,D.restartButton.querySelector(".button-label").textContent=Y.restart,D.pluginsHeading.textContent=Y.plugins,D.errorTitle.textContent=Y.loadError,D.errorCopy.textContent=Y.loadErrorCopy,D.retryButton.textContent=Y.retry,D.versionLabel.textContent=Y.version,D.diagnosticsButton.textContent=Y.copyDiagnostics,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}function xT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=Y.states[t]??Y.states.stopped,o={healthy:"is-active",injected:"is-active",configured:"is-warning",failed:"is-failed",launching:"is-warning","restart-required":"is-warning",saved:"is-warning",stopped:"is-stopped"}[t]??"is-warning";return{label:e.failure?.message&&t==="failed"?`${n}: ${Y.failureDetail}`:n,className:o}}function qe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function IT(e){let t=qe("article","plugin-card");t.dataset.featureId=e.id;let n=qe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=qe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=qe("div","plugin-copy"),i=qe("div","plugin-title-line"),a=qe("h3","plugin-name");i.append(a);let s=qe("p","plugin-description");r.append(i,s);let l=qe("div","plugin-topline"),c=qe("label","switch"),d=qe("input");d.type="checkbox",d.name=`feature-${e.id}`,d.setAttribute("role","switch"),d.setAttribute("aria-describedby",`description-${e.id} state-${e.id}`),s.id=`description-${e.id}`;let p=qe("span","switch-track");p.setAttribute("aria-hidden","true"),c.append(d,p);let h=qe("span","plugin-state"),f=qe("span","status-dot");f.setAttribute("aria-hidden","true");let v=qe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),t}function Ud(e,t){for(let c of D.languageButtons)c.disabled=at.size>0;let n=xT(t),o=e.querySelector('input[type="checkbox"]'),r=e.querySelector(".plugin-icon img"),i=e.querySelector(".plugin-name"),a=e.querySelector(".plugin-description"),s=e.querySelector(".plugin-state .status-dot"),l=e.querySelector(".plugin-state-label");e.dataset.featureId=t.id,r.src=t.iconUrl.startsWith("data:")?t.iconUrl:`${t.iconUrl}?v=resource-1`,i.textContent=t.label,a.textContent=t.description,o.checked=!!t.enabled,o.disabled=at.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label}function Q$(e){return[...D.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function RT(e){e=e.filter(n=>n.id!=="unread-inbox");for(let n of[...D.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let n of e){let o=Q$(n.id);o||(o=IT(n)),D.pluginList.append(o),Ud(o,n)}for(let n of[...D.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&n.remove();D.pluginList.setAttribute("aria-busy","false")}function ez(){let e=!!ze?.runtime?.running,t=ze?.renderer,n=!!(t?.discovered&&t.runtimeSessionId&&t.runtimeSessionId===ze?.runtime?.runtimeSessionId&&t.active&&Number(t.injectedTargets)>0),o=e&&n;D.runtimeLabel.closest(".overview").hidden=o,D.runtimeDot.className=`status-dot ${o?"is-active":"is-warning"}`,D.runtimeLabel.textContent=o?Y.runtimeActive:e?Y.runtimeNotInjected:Y.runtimeStopped,D.versionValue.textContent=ze?.version??"\u2014",D.restartNotice.hidden=!ze?.pendingRestart}function PT(){ez(),RT(ze?.features??[])}function TT(e){let t=document.activeElement,n=t?.closest?.("[data-feature-id]");return!n||n.dataset.featureId!==e?null:{featureId:e,input:t.matches?.('input[type="checkbox"]')}}function X$(e){if(!e?.input)return;Q$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(Y$),D.toast.textContent=e,D.toast.hidden=!1,Y$=setTimeout(()=>{D.toast.hidden=!0},4200)}function Zv(e,t){ze.features=ze.features.map(n=>n.id===e?{...n,...t}:n)}async function Md(){D.loadError.hidden=!0;try{let e=await sn("/api/status",{headers:{"Accept-Language":At}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();at.size&&ze&&(t.features=t.features.map(n=>at.has(n.id)?ze.features.find(o=>o.id===n.id)??n:n)),ze=t,D.pluginList.hidden=!1,PT()}catch{D.pluginList.hidden=!0,D.loadError.hidden=!1,D.runtimeDot.className="status-dot is-warning",D.runtimeLabel.textContent=Y.runtimeStopped,D.runtimeLabel.closest(".overview").hidden=!0}}function qd(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":tz.matches,t=Tc==="dark"||Tc!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",D.themeToggle.setAttribute("aria-label",At==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of D.themeButtons)n.setAttribute("aria-label",n.dataset.themeChoice==="light"?Y.lightAppearance:Y.darkAppearance),n.setAttribute("aria-pressed",String(n.dataset.themeChoice===(t?"dark":"light")))}var Fv,At,Y,D,ze,Y$,at,tz,Tc,rz=Rn(()=>{W$();Vv();try{Fv=localStorage.getItem("minecodex-language")}catch{}At=["en","zh-CN"].includes(Fv)?Fv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=At;Y={en:{connecting:"Connecting\u2026",runtimeActive:"Active in Codex",runtimeStopped:"Runtime unavailable",runtimeNotInjected:"Runtime running \u2014 restart Codex to apply plugins",plugins:"Your extensions",restartTitle:"Restart Codex to apply changes",restartCopy:"Your plugin choices are saved. Restart when you are ready.",restart:"Restart Codex",restarting:"Restarting\u2026",saved:"Saved",saving:"Saving\u2026",states:{saved:"Saved \u2014 restart Codex to apply",configured:"Configured \u2014 starting in Codex\u2026",launching:"Launching in Codex\u2026",injected:"Active in Codex",healthy:"Active in Codex",checking:"Checking compatibility\u2026",partial:"Available in some windows",degraded:"Appearance needs an update",unavailable:"Temporarily unavailable \u2014 check for updates","not-applicable":"Not needed on this page",failed:"Couldn\u2019t start \u2014 try again",stopped:"Stopped","restart-required":"Restart required \u2014 restart Codex"},loadError:"Couldn\u2019t load MineCodex",loadErrorCopy:"Check that the background service is running.",retry:"Try again",version:"Version",darkAppearance:"Dark appearance",lightAppearance:"Light appearance",updateFailed:"Couldn\u2019t check for updates. Please try again.",copyDiagnostics:"Copy diagnostics",diagnosticsCopied:"Diagnostics copied",diagnosticsFailed:"Couldn\u2019t copy diagnostics. Please try again.",checkUpdates:"Check for updates",checkingUpdates:"Checking\u2026",current:"You\u2019re up to date.",updateAvailable:e=>`MineCodex ${e} is available. Run mcx update in Terminal.`,changeFailed:"The plugin setting could not be saved.",restartFailed:"MineCodex could not restart Codex. Please try again or copy diagnostics.",failureDetail:"This extension could not be confirmed. Copy diagnostics to help investigate."},"zh-CN":{connecting:"\u6B63\u5728\u8FDE\u63A5\u2026",runtimeActive:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",runtimeStopped:"\u8FD0\u884C\u670D\u52A1\u4E0D\u53EF\u7528",runtimeNotInjected:"\u8FD0\u884C\u670D\u52A1\u5DF2\u542F\u52A8\u2014\u2014\u91CD\u542F Codex \u4EE5\u5E94\u7528\u63D2\u4EF6",plugins:"\u529F\u80FD\u6269\u5C55",restartTitle:"\u91CD\u542F Codex \u4EE5\u5E94\u7528\u66F4\u6539",restartCopy:"\u63D2\u4EF6\u9009\u62E9\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u53EF\u4EE5\u5728\u51C6\u5907\u597D\u540E\u7EDF\u4E00\u91CD\u542F\u3002",restart:"\u91CD\u542F Codex",restarting:"\u6B63\u5728\u91CD\u542F\u2026",saved:"\u5DF2\u4FDD\u5B58",saving:"\u6B63\u5728\u4FDD\u5B58\u2026",states:{saved:"\u5DF2\u4FDD\u5B58\u2014\u2014\u91CD\u542F Codex \u540E\u5E94\u7528",configured:"\u5DF2\u914D\u7F6E\u2014\u2014\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",launching:"\u6B63\u5728 Codex \u4E2D\u542F\u52A8\u2026",injected:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",healthy:"\u5DF2\u5728 Codex \u4E2D\u751F\u6548",checking:"\u6B63\u5728\u81EA\u68C0\u2026",partial:"\u90E8\u5206\u7A97\u53E3\u53EF\u7528",degraded:"\u5916\u89C2\u9002\u914D\u9700\u8981\u66F4\u65B0",unavailable:"\u6682\u4E0D\u53EF\u7528\u2014\u2014\u8BF7\u68C0\u67E5\u66F4\u65B0","not-applicable":"\u5F53\u524D\u9875\u9762\u4E0D\u9002\u7528",failed:"\u6682\u65F6\u65E0\u6CD5\u542F\u52A8\u2014\u2014\u8BF7\u91CD\u8BD5",stopped:"\u5DF2\u505C\u6B62","restart-required":"\u9700\u8981\u91CD\u542F\u2014\u2014\u8BF7\u91CD\u542F Codex"},loadError:"\u65E0\u6CD5\u52A0\u8F7D MineCodex",loadErrorCopy:"\u8BF7\u68C0\u67E5\u540E\u53F0\u670D\u52A1\u662F\u5426\u6B63\u5728\u8FD0\u884C\u3002",retry:"\u91CD\u8BD5",version:"\u7248\u672C",darkAppearance:"\u6DF1\u8272\u5916\u89C2",lightAppearance:"\u6D45\u8272\u5916\u89C2",updateFailed:"\u6682\u65F6\u65E0\u6CD5\u68C0\u67E5\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",copyDiagnostics:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",diagnosticsCopied:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",diagnosticsFailed:"\u6682\u65F6\u65E0\u6CD5\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\uFF0C\u8BF7\u91CD\u8BD5\u3002",checkUpdates:"\u68C0\u67E5\u66F4\u65B0",checkingUpdates:"\u6B63\u5728\u68C0\u67E5\u2026",current:"\u5F53\u524D\u5DF2\u662F\u6700\u65B0\u7248\u672C\u3002",updateAvailable:e=>`\u53D1\u73B0 MineCodex ${e}\uFF0C\u8BF7\u5728\u7EC8\u7AEF\u8FD0\u884C mcx update\u3002`,changeFailed:"\u63D2\u4EF6\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002",restartFailed:"MineCodex \u65E0\u6CD5\u91CD\u542F Codex\u3002\u8BF7\u91CD\u8BD5\u6216\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002",failureDetail:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u8FD9\u9879\u529F\u80FD\u7684\u72B6\u6001\uFF0C\u53EF\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u534F\u52A9\u6392\u67E5\u3002"}}[At],D={runtimeDot:document.querySelector("#runtime-dot"),runtimeLabel:document.querySelector("#runtime-label"),restartNotice:document.querySelector("#restart-notice"),restartTitle:document.querySelector("#restart-title"),restartCopy:document.querySelector("#restart-copy"),restartButton:document.querySelector("#restart-button"),pluginsHeading:document.querySelector("#plugins-heading"),saveState:document.querySelector("#save-state"),pluginList:document.querySelector("#plugin-list"),loadError:document.querySelector("#load-error"),errorTitle:document.querySelector("#error-title"),errorCopy:document.querySelector("#error-copy"),retryButton:document.querySelector("#retry-button"),versionLabel:document.querySelector("#version-label"),versionValue:document.querySelector("#version-value"),languageToggle:document.querySelector(".language-toggle"),languageButtons:[...document.querySelectorAll("[data-language-choice]")],themeToggle:document.querySelector(".theme-toggle"),themeButtons:[...document.querySelectorAll("[data-theme-choice]")],updateResult:document.querySelector("#update-result"),updateButton:document.querySelector("#update-button"),diagnosticsButton:document.querySelector("#diagnostics-button"),toast:document.querySelector("#toast")},ze=null,Y$=null,at=new Set;D.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!ze)return;let o=n.dataset.featureId,r={...ze.features.find(a=>a.id===o)},i=TT(o);at.add(o),Zv(o,{enabled:t.checked,state:"saved"}),Ud(n,ze.features.find(a=>a.id===o)),D.saveState.textContent=Y.saving;try{let a=await sn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":At},body:JSON.stringify({enabled:t.checked})});if(!a.ok)throw new Error(`HTTP ${a.status}`);let s=await a.json(),l=s.features?.find(d=>d.id===o);l&&Zv(o,l),ze.pendingRestart=s.pendingRestart,at.delete(o);let c=l??ze.features.find(d=>d.id===o);c&&Ud(n,c),ez(),X$(i),D.saveState.textContent=at.size?Y.saving:Y.saved}catch{at.delete(o),Zv(o,r),Ud(n,r),D.saveState.textContent=at.size?Y.saving:"",X$(i),Dd(Y.changeFailed)}});D.restartButton.addEventListener("click",async()=>{D.restartButton.disabled=!0,D.restartButton.querySelector(".button-label").textContent=Y.restarting;try{let e=await sn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":At},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Md()}catch{Dd(Y.restartFailed)}finally{D.restartButton.disabled=!1,D.restartButton.querySelector(".button-label").textContent=Y.restart}});D.retryButton.addEventListener("click",()=>{D.pluginList.hidden=!1,Md()});D.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(G$(ze),null,2)),Dd(Y.diagnosticsCopied)}catch{Dd(Y.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!at.size&&Md()},5e3);D.updateButton.addEventListener("click",async()=>{D.updateButton.disabled=!0,D.updateButton.querySelector(".button-label").textContent=Y.checkingUpdates,D.updateResult.hidden=!0;try{let e=await sn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();D.updateResult.textContent=t.available?Y.updateAvailable(t.latest):Y.current,D.updateResult.hidden=!1}catch{D.updateResult.textContent=Y.updateFailed,D.updateResult.hidden=!1}finally{D.updateButton.disabled=!1,D.updateButton.querySelector(".button-label").textContent=Y.checkUpdates}});tz=matchMedia("(prefers-color-scheme: dark)"),Tc=null;try{Tc=localStorage.getItem("minecodex-appearance")}catch{}D.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");if(t){Tc=t.dataset.themeChoice;try{localStorage.setItem("minecodex-appearance",Tc)}catch{}qd()}});D.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||at.size||D.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==At){try{localStorage.setItem("minecodex-language",n)}catch{return}location.reload()}});tz.addEventListener("change",qd);window.addEventListener("minecodex-host-theme",qd);document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});kT();qd();Md()});function nz(e){let t="data-minecodex-tooltip",n=document.createElement("div");n.id="minecodex-feature-tooltip",n.setAttribute("role","tooltip"),n.hidden=!0;let o=document.createElement("style");o.setAttribute("data-minecodex-ui-styles","tooltip"),o.textContent=`
|
|
2
2
|
[data-mcx-ui-tooltip] { position:fixed;z-index:2147483001;pointer-events:none;box-sizing:border-box;
|
|
3
3
|
padding:calc(var(--mcx-spacing) * 1.25) calc(var(--mcx-spacing) * 3);border:1px solid var(--mcx-color-border-tooltip);border-radius:var(--mcx-radius-2xl);corner-shape:var(--mcx-codex-corner-shape);
|
|
4
4
|
background:var(--mcx-color-background-tooltip);color:var(--mcx-color-text-tooltip);box-shadow:var(--mcx-shadow-tooltip);
|
|
@@ -11,8 +11,9 @@ export async function createAppHtml(packageRoot) {
|
|
|
11
11
|
}
|
|
12
12
|
const script = await readFile(path.join(packageRoot, "packages/plugin/assets/app.js"), "utf8");
|
|
13
13
|
html = html.replace(/\s*<link[^>]+>/g, "").replace(/\s*<script[\s\S]*?<\/script>/g, "");
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// 回调保留资源中的 $&、$` 等字面量,避免被 replace 当成替换指令。
|
|
15
|
+
return html.replace("</head>", () => `<style>${css}</style></head>`)
|
|
16
|
+
.replace("</body>", () => `<script type="module">${script.replaceAll("</script", "<\\/script")}</script></body>`);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export async function createPromptsHtml(packageRoot) {
|