minecodex 2.0.53 → 2.0.54
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/README.md +1 -1
- package/apps/dashboard/assets/preview-content.js +2 -2
- package/features/mermaid-diagrams/assets/qv-dependencies.js +850 -815
- package/features/mermaid-diagrams/assets/qv-template.json +1 -1
- package/features/mermaid-diagrams/codex-feature.json +4 -4
- package/features/mermaid-diagrams/src/adapters/codex/native.mjs +12 -3
- package/features/mermaid-diagrams/src/mermaid/detail-position.mjs +7 -0
- package/features/mermaid-diagrams/src/mermaid/frame.mjs +1 -1
- package/features/mermaid-diagrams/src/mermaid/qv-git.js +95 -0
- package/features/mermaid-diagrams/src/mermaid/qv-motion.js +25 -0
- package/features/mermaid-diagrams/src/mermaid/qv-polish.css +20 -0
- package/features/mermaid-diagrams/src/mermaid/qv-title.mjs +11 -0
- package/features/mermaid-diagrams/vendor/qv/THIRD_PARTY_NOTICES.txt +27 -0
- package/package.json +2 -1
- package/packages/cli/src/config.mjs +1 -1
- package/packages/plugin/assets/app.js +2 -2
- package/packages/plugin/assets/prompts.js +1 -1
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"id": "mermaid-diagrams",
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"label": {
|
|
6
|
-
"en": "Mermaid Diagrams
|
|
7
|
-
"zh-CN": "Mermaid
|
|
6
|
+
"en": "Mermaid Diagrams",
|
|
7
|
+
"zh-CN": "Mermaid 图表增强"
|
|
8
8
|
},
|
|
9
9
|
"description": {
|
|
10
|
-
"en": "
|
|
11
|
-
"zh-CN": "在 Markdown
|
|
10
|
+
"en": "Enhance Markdown diagrams with readable layouts, zoom and PNG download. Enabled by default.",
|
|
11
|
+
"zh-CN": "在 Markdown 预览中增强图表排版,支持缩放与 PNG 下载。默认启用。"
|
|
12
12
|
},
|
|
13
13
|
"entry": {
|
|
14
14
|
"kind": "page-script",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findCodexModule } from '../../../../../packages/codex-adapter/src/renderer/modules.mjs';
|
|
2
2
|
import { saveQvDiagram } from '../../mermaid/export.mjs';
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// 图表下载协议只由图表功能加载,阅读增强不依赖此能力。
|
|
5
5
|
export async function loadNativeMermaidActions(native, {read = async url => { const response = await fetch(url); if (!response.ok) throw new Error('native-diagram-source-unavailable'); return response.text(); }, load = url => import(url)} = {}) {
|
|
6
6
|
if (native.rspack) return loadRspackMermaidActions(native);
|
|
7
7
|
const url = await findCodexModule('app-initial',{read});
|
|
@@ -49,8 +49,17 @@ export function loadRspackMermaidActions(native) {
|
|
|
49
49
|
const preview=registry.module(source=>source.includes('imagePreviewDialog.label')&&source.includes('suggestedFilename:')&&source.includes('downloadSrc:'),'diagram preview download');
|
|
50
50
|
const call=preview.source.match(/\(0,([\w$]+\.[\w$]+)\)\(\{downloadSrc:[^}]*suggestedFilename:/);
|
|
51
51
|
const icon=call&&preview.source.slice(call.index).match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+\.[\w$]+),\{className:"icon-xs"\}/)?.[1];
|
|
52
|
-
|
|
53
|
-
const
|
|
52
|
+
// 新版原生图标通过组件 + asset 绘制,沿真实下载按钮读取两者。
|
|
53
|
+
const assetIcon=call&&preview.source.slice(call.index).match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+\.[\w$]+),\{"aria-hidden":!1,asset:([\w$]+\.[\w$]+)\}/);
|
|
54
|
+
if (!call || (!icon && !assetIcon)) throw new Error('native-diagram-download-unavailable');
|
|
55
|
+
const downloadImage=registry.binding(preview,call[1]);
|
|
56
|
+
let DownloadIcon;
|
|
57
|
+
if(icon) DownloadIcon=registry.binding(preview,icon);
|
|
58
|
+
else {
|
|
59
|
+
const Icon=registry.binding(preview,assetIcon[1]),asset=registry.binding(preview,assetIcon[2]);
|
|
60
|
+
if(typeof Icon!=='function'||!asset||!native.React?.createElement) throw new Error('native-diagram-download-unavailable');
|
|
61
|
+
DownloadIcon=props=>native.React.createElement(Icon,{...props,asset});
|
|
62
|
+
}
|
|
54
63
|
if (typeof DownloadIcon!=='function' || typeof downloadImage!=='function'
|
|
55
64
|
|| !String(downloadImage).includes('workspaceFiles.saveStream')
|
|
56
65
|
|| !String(downloadImage).includes('Failed to download image')) throw new Error('native-diagram-download-unavailable');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// 先限定与触发对象的距离,再在局部候选中避让;避免宽画布的空角吸走气泡。
|
|
2
|
+
export function nearbyRadarDetails(candidates) {
|
|
3
|
+
const unobscured = candidates.filter(candidate => !(candidate.pointer ?? candidate.coversPointer));
|
|
4
|
+
const available = unobscured.length ? unobscured : candidates;
|
|
5
|
+
const nearest = Math.min(...available.map(candidate => candidate.distance));
|
|
6
|
+
return available.filter(candidate => candidate.distance <= Math.max(32, nearest + 16));
|
|
7
|
+
}
|
|
@@ -51,7 +51,7 @@ export function createQvFrame(source, assets, theme, onHeight, onReady, onEscape
|
|
|
51
51
|
frame.style.height = '240px';
|
|
52
52
|
let disposed = false, height = 240, input = null;
|
|
53
53
|
const timeout = setTimeout(() => { if (!disposed) onReady('error'); }, 30000);
|
|
54
|
-
const config = { source, title: '', descriptions: {}, icons: 'auto',
|
|
54
|
+
const config = { source, title: '', descriptions: {}, icons: 'auto', readingWidth: theme.readingWidth };
|
|
55
55
|
const encode = (value) => JSON.stringify(value).replace(/</g, '\\u003c');
|
|
56
56
|
const bootstrap = `const token=${encode(token)};window.__mcxDiagramConfig=${encode(config)};window.openai={displayMode:'inline',maxHeight:innerHeight};
|
|
57
57
|
const send=()=>{const root=document.querySelector('.qv-mermaid');parent.postMessage({type:'mcx-qv',token,state:root.dataset.state,height:Math.ceil(root.offsetHeight)},'*');};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// QV 风格的 Git 分支图:模型读取与绘制。由构建器组装进 QV 模板,不修改 vendor 快照。
|
|
2
|
+
// 视觉沿用 QV:分支色取 --viz-series-*(与背景混合降饱和)、12px 文字、按钮承载交互、共享视口与入场动效。
|
|
3
|
+
function readMermaidGitModel(db,descriptions={}){
|
|
4
|
+
if(!db.getCommits||!db.getBranchesAsObjArray)return {reason:'gitGraph 数据接口不兼容'};
|
|
5
|
+
const branches=db.getBranchesAsObjArray().map(b=>b.name);
|
|
6
|
+
// 未写 id 的提交由 Mermaid 生成「序号-7 位哈希」,只展示哈希。
|
|
7
|
+
const commits=[...db.getCommits().values()].sort((a,b)=>a.seq-b.seq).map(c=>({id:String(c.id),message:String(c.message||''),type:c.type,tags:[...(c.tags||[])].map(String),parents:[...(c.parents||[])].map(String),branch:c.branch,auto:/^\d+-[0-9a-f]{7}$/.test(String(c.id)),description:descriptions[c.id]||''}));
|
|
8
|
+
if(!commits.length)return {reason:'gitGraph 没有提交'};
|
|
9
|
+
if(commits.some(c=>[c.id,c.message,...c.tags].some(hasRichMermaidLabel)))return {reason:'gitGraph 包含富文本,保留原生语义'};
|
|
10
|
+
const unknown=Object.keys(descriptions).filter(id=>!commits.some(c=>c.id===id));if(unknown.length)throw new Error('说明引用了未知提交:'+unknown.join('、'));
|
|
11
|
+
return {data:{kind:'git',branches,commits,direction:db.getDirection?.()||'LR',title:db.getDiagramTitle?.()||''}};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function renderMermaidGit(root,data){
|
|
15
|
+
const scene=root.querySelector('.scene'),viewport=root.querySelector('.diagram-scroll'),svg=scene.querySelector('svg'),NS='http://www.w3.org/2000/svg';
|
|
16
|
+
root.classList.add('qv-git');root.dataset.state='enhanced';root.dataset.renderer='qv-git';root.querySelector('.edge-key').hidden=true;
|
|
17
|
+
if(data.title&&root.querySelector('h3').hidden){root.querySelector('h3').textContent=data.title;root.querySelector('h3').hidden=false;}
|
|
18
|
+
const style=document.createElement('style');style.textContent=`
|
|
19
|
+
#${root.id} .git-branch{position:absolute;display:block;box-sizing:border-box;height:24px;padding:0 10px;border:0;border-radius:999px;font:inherit;font-size:12px;line-height:24px;color:color-mix(in srgb,var(--git-tone) 60%,var(--foreground));background:color-mix(in srgb,var(--git-tone) 14%,var(--background));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:var(--cursor-interaction,pointer)}
|
|
20
|
+
#${root.id} .git-commit{position:absolute;display:flex;align-items:center;gap:8px;box-sizing:border-box;height:24px;padding:0;border:0;background:transparent;font:inherit;font-size:12px;line-height:18px;color:var(--foreground);white-space:nowrap;overflow:hidden;cursor:var(--cursor-interaction,pointer)}
|
|
21
|
+
#${root.id} .git-commit.lr{justify-content:center}
|
|
22
|
+
#${root.id} .git-commit>span{overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
23
|
+
#${root.id} .git-commit .git-text{flex:0 1 auto}
|
|
24
|
+
#${root.id} .git-commit .git-hash{color:var(--muted-foreground);font-variant-numeric:tabular-nums}
|
|
25
|
+
#${root.id} .git-commit .git-ref{flex:none;max-width:160px;height:20px;padding:0 8px;border-radius:999px;line-height:20px;color:color-mix(in srgb,var(--git-tone) 60%,var(--foreground));background:color-mix(in srgb,var(--git-tone) 14%,var(--background))}
|
|
26
|
+
#${root.id} .git-tag{flex:none;max-width:200px;height:20px;padding:0 8px;box-sizing:border-box;border:1px solid var(--border);border-radius:6px;line-height:18px;color:var(--muted-foreground);background:var(--background);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
27
|
+
#${root.id} .git-tag.lr{position:absolute}
|
|
28
|
+
#${root.id} .git-edge{fill:none;stroke:color-mix(in srgb,var(--git-tone) 70%,var(--background));stroke-width:2;stroke-linecap:round}
|
|
29
|
+
#${root.id} .git-dot{fill:var(--git-tone);stroke:var(--background);stroke-width:2}
|
|
30
|
+
#${root.id} .git-dot.merge{fill:var(--background);stroke:var(--git-tone);stroke-width:2.5}
|
|
31
|
+
#${root.id} .git-dot.cherry{fill:var(--background);stroke:var(--git-tone);stroke-width:2;stroke-dasharray:3 2}
|
|
32
|
+
#${root.id} .git-mark{fill:none;stroke:var(--git-tone);stroke-width:2;stroke-linecap:round}
|
|
33
|
+
#${root.id} [data-branch]{transition:opacity 140ms}
|
|
34
|
+
#${root.id} [data-dim]{opacity:.22}
|
|
35
|
+
#${root.id} .git-commit:focus-visible,#${root.id} .git-branch:focus-visible{outline:1px solid var(--viz-series-1);outline-offset:2px}
|
|
36
|
+
@media(prefers-reduced-motion:reduce){#${root.id} [data-branch]{transition:none}}
|
|
37
|
+
`;root.append(style);
|
|
38
|
+
const el=(tag,attrs)=>{const n=document.createElementNS(NS,tag);for(const [k,v] of Object.entries(attrs))n.setAttribute(k,v);svg.append(n);return n;};
|
|
39
|
+
const html=(tag,cls,text)=>{const n=document.createElement(tag);n.className=cls;if(text!==undefined)n.textContent=text;return n;};
|
|
40
|
+
const lane=new Map(data.branches.map((b,i)=>[b,i])),tone=b=>`var(--viz-series-${(lane.get(b)??0)%6+1})`;
|
|
41
|
+
const index=new Map(data.commits.map((c,i)=>[c.id,i])),firstOf=new Map();data.commits.forEach(c=>{if(!firstOf.has(c.branch))firstOf.set(c.branch,c.id);});
|
|
42
|
+
const context=document.createElement('canvas').getContext('2d');context.font='12px '+getComputedStyle(root).fontFamily;const measure=t=>Math.ceil(context.measureText(t).width);
|
|
43
|
+
const label=c=>c.auto?c.id.split('-')[1]:c.id;
|
|
44
|
+
// 横排放得下正文宽度就沿用 Mermaid 默认方向;放不下改为 git log 式纵排(与流程图主轴规则一致)。
|
|
45
|
+
const limit=cfg.readingWidth||root.clientWidth,n=data.commits.length,lanes=data.branches.length;
|
|
46
|
+
const branchCol=Math.min(160,Math.max(...data.branches.map(measure))+20),step=Math.min(140,Math.max(56,...data.commits.map(c=>measure(label(c))+16)));
|
|
47
|
+
const lrStart=24+branchCol+24,lrWidth=lrStart+(n-1)*step+step/2+24;
|
|
48
|
+
const vertical=data.direction!=='LR'||lrWidth>limit;root.dataset.gitLayout=vertical?'rows':'lanes';root.dataset.mcxLayout=vertical?'git-rows':'git-lanes';
|
|
49
|
+
const commits=[],edges=[],refs=[];let width,height,point;
|
|
50
|
+
if(!vertical){
|
|
51
|
+
const tagged=new Set(data.commits.filter(c=>c.tags.length).map(c=>lane.get(c.branch)));let y=36;const laneY=data.branches.map((b,i)=>{if(tagged.has(i))y+=26;const v=y;y+=56;return v;});
|
|
52
|
+
width=lrWidth;height=laneY.at(-1)+48;point=c=>({x:lrStart+index.get(c.id)*step,y:laneY[lane.get(c.branch)]});
|
|
53
|
+
data.branches.forEach((b,i)=>{const r=html('button','git-branch',b);r.type='button';r.title=b;r.dataset.branch=b;r.style.setProperty('--git-tone',tone(b));r.style.left='24px';r.style.top=(laneY[i]-12)+'px';r.style.maxWidth=branchCol+'px';scene.append(r);refs.push(r);});
|
|
54
|
+
}else{
|
|
55
|
+
const rowH=32,top=12,textX=24+lanes*24+12,order=data.direction==='BT'?[...data.commits].reverse():data.commits,row=new Map(order.map((c,i)=>[c.id,i]));
|
|
56
|
+
width=Math.max(textX+240,limit);height=top+n*rowH+12;point=c=>({x:24+12+lane.get(c.branch)*24,y:top+row.get(c.id)*rowH+rowH/2});
|
|
57
|
+
}
|
|
58
|
+
scene.style.width=scene.style.minWidth=width+'px';scene.style.height=height+'px';svg.setAttribute('width',width);svg.setAttribute('height',height);svg.setAttribute('viewBox',`0 0 ${width} ${height}`);svg.style.width=width+'px';svg.style.height=height+'px';
|
|
59
|
+
// 分支分出时在父提交附近转入新泳道;合并时沿来源泳道前进,在合并提交前转入。
|
|
60
|
+
const toXY=(m,c)=>vertical?[c,m]:[m,c],unit=vertical?32:step;
|
|
61
|
+
for(const c of data.commits){const b=point(c),bm=vertical?b.y:b.x,bc=vertical?b.x:b.y;
|
|
62
|
+
for(const [k,pid] of c.parents.entries()){const parent=data.commits[index.get(pid)];if(!parent)continue;const a=point(parent),am=vertical?a.y:a.x,ac=vertical?a.x:a.y,s=Math.sign(bm-am)||1,r=Math.min(Math.abs(bm-am),unit);
|
|
63
|
+
let d,owner;const curve=(m0,c0,m1,c1)=>{const mid=(m0+m1)/2;return `C${toXY(mid,c0)} ${toXY(mid,c1)} ${toXY(m1,c1)}`;};
|
|
64
|
+
if(ac===bc){d=`M${toXY(am,ac)} L${toXY(bm,bc)}`;owner=c.branch;}
|
|
65
|
+
else if(firstOf.get(c.branch)===c.id&&k===0){d=`M${toXY(am,ac)} ${curve(am,ac,am+s*r,bc)} L${toXY(bm,bc)}`;owner=c.branch;}
|
|
66
|
+
else{d=`M${toXY(am,ac)} L${toXY(bm-s*r,ac)} ${curve(bm-s*r,ac,bm,bc)}`;owner=parent.branch;}
|
|
67
|
+
const path=el('path',{d,class:'git-edge','data-branch':owner});path.style.setProperty('--git-tone',tone(owner));edges.push({path,index:index.get(c.id)});}}
|
|
68
|
+
for(const c of data.commits){const p=point(c),i=index.get(c.id),t=tone(c.branch),kind=['normal','reverse','highlight','merge','cherry'][c.type]||'normal';let mark;
|
|
69
|
+
if(kind==='highlight')mark=el('rect',{x:p.x-6,y:p.y-6,width:12,height:12,rx:2,class:'git-dot','data-branch':c.branch});
|
|
70
|
+
else{mark=el('circle',{cx:p.x,cy:p.y,r:kind==='merge'?6:kind==='cherry'?6:5.5,class:'git-dot '+kind,'data-branch':c.branch});}
|
|
71
|
+
mark.style.setProperty('--git-tone',t);const marks=[mark];
|
|
72
|
+
if(kind==='reverse'){const x=el('path',{d:`M${p.x-3} ${p.y-3}l6 6m0 -6l-6 6`,class:'git-mark','data-branch':c.branch});x.style.setProperty('--git-tone','var(--background)');marks.push(x);}
|
|
73
|
+
const b=html('button','git-commit'+(vertical?'':' lr'));b.type='button';b.dataset.branch=c.branch;b.style.setProperty('--git-tone',t);
|
|
74
|
+
b.title=[c.branch,c.auto?c.id.split('-')[1]:c.id,c.message,...c.tags,c.description].filter(Boolean).join(' · ');b.setAttribute('aria-label',b.title);
|
|
75
|
+
const text=html('span','git-text'+(c.auto?' git-hash':''),label(c));const tags=[];
|
|
76
|
+
if(vertical){const textX=24+lanes*24+12;if(firstOf.get(c.branch)===c.id){const ref=html('span','git-ref',c.branch);b.append(ref);}b.append(text);if(c.message&&!c.auto)b.append(html('span','git-hash',c.message));c.tags.forEach(v=>{const g=html('span','git-tag',v);b.append(g);});b.style.left=textX+'px';b.style.top=(p.y-12)+'px';b.style.maxWidth=(width-textX-16)+'px';}
|
|
77
|
+
else{b.append(text);b.style.left=(p.x-(step-8)/2)+'px';b.style.width=(step-8)+'px';b.style.top=(p.y+10)+'px';c.tags.forEach((v,j)=>{const g=html('span','git-tag lr',v);g.title=v;g.dataset.branch=c.branch;g.style.maxWidth=Math.max(step-8,96)+'px';scene.append(g);g.style.left=(p.x-g.offsetWidth/2)+'px';g.style.top=(p.y-34-j*24)+'px';tags.push(g);});}
|
|
78
|
+
scene.append(b);commits.push({c,i,b,marks,tags});}
|
|
79
|
+
const view=createMermaidViewport(root);
|
|
80
|
+
// 悬停或聚焦某提交时只保留其所在分支,其余分支降为背景。
|
|
81
|
+
const all=()=>root.querySelectorAll('[data-branch]');function clear(){all().forEach(n=>n.removeAttribute('data-dim'));}
|
|
82
|
+
function focus(branch){all().forEach(n=>n.toggleAttribute('data-dim',n.dataset.branch!==branch));}
|
|
83
|
+
for(const o of commits){o.b.addEventListener('pointerenter',()=>focus(o.c.branch));o.b.addEventListener('pointerleave',clear);o.b.addEventListener('focus',()=>{focus(o.c.branch);const r=o.b.getBoundingClientRect(),v=viewport.getBoundingClientRect();if(r.left<v.left+12)viewport.scrollLeft-=v.left+12-r.left;else if(r.right>v.right-12)viewport.scrollLeft+=r.right-v.right+12;});o.b.addEventListener('blur',clear);}
|
|
84
|
+
for(const r of refs){r.addEventListener('pointerenter',()=>focus(r.dataset.branch));r.addEventListener('pointerleave',clear);r.addEventListener('focus',()=>focus(r.dataset.branch));r.addEventListener('blur',clear);}
|
|
85
|
+
viewport.addEventListener('scroll',clear,{passive:true});root.addEventListener('keydown',e=>{if(e.key==='Escape')clear();});
|
|
86
|
+
// 入场:按提交顺序画出连线并点亮提交,总时长约 1.2 秒;减少动态效果时不播放。
|
|
87
|
+
const reduced=matchMedia('(prefers-reduced-motion:reduce)');let running=[],armed=true;const gap=Math.min(120,1200/Math.max(1,n-1));
|
|
88
|
+
function replay(){running.forEach(a=>a.cancel());running=[];if(reduced.matches||view.expanded)return;
|
|
89
|
+
for(const {path,index:i} of edges){const length=path.getTotalLength();path.style.strokeDasharray=`${length} ${length}`;const a=path.animate([{strokeDashoffset:length},{strokeDashoffset:0}],{duration:360,delay:Math.max(0,i-1)*gap,easing:'cubic-bezier(.2,.7,.3,1)',fill:'backwards'});a.onfinish=()=>{path.style.strokeDasharray='';};running.push(a);}
|
|
90
|
+
for(const o of commits){const delay=o.i*gap;o.marks.forEach(m=>running.push(m.animate([{opacity:0},{opacity:1}],{duration:200,delay,fill:'backwards'})));[o.b,...o.tags].forEach(n=>running.push(n.animate([{opacity:0},{opacity:1}],{duration:200,delay:delay+60,fill:'backwards'})));}
|
|
91
|
+
root.dataset.replays=String(+(root.dataset.replays||0)+1);}
|
|
92
|
+
new IntersectionObserver(es=>{if(!es[0].isIntersecting)armed=true;else if(es[0].intersectionRatio>=.2&&armed){armed=false;replay();}},{threshold:[0,.2]}).observe(root);
|
|
93
|
+
document.addEventListener('visibilitychange',()=>{if(document.hidden)armed=true;else if(armed){armed=false;replay();}});
|
|
94
|
+
root.addEventListener('qv:display-mode',()=>{running.forEach(a=>a.cancel());clear();if(!view.expanded)viewport.scrollLeft=view.savedInlinePosition?.left||0;});reduced.addEventListener('change',()=>running.forEach(a=>a.cancel()));view.refresh();
|
|
95
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// 规则 32–33:渲染器显式接入,不修改宿主或 iframe 的全局原型。
|
|
2
|
+
const mermaidEntryEase='cubic-bezier(.23,1,.32,1)',mermaidEntryBudget=1200;
|
|
3
|
+
let mermaidEntryBatch=null;
|
|
4
|
+
function animateMermaidEntry(element,frames,options){
|
|
5
|
+
const timing=typeof options==='number'?{duration:options}:{...options};
|
|
6
|
+
timing.easing=mermaidEntryEase;
|
|
7
|
+
if(Array.isArray(frames))frames=frames.map(frame=>{
|
|
8
|
+
const match=typeof frame.transform==='string'&&frame.transform.match(/^scale\((0|0?\.\d+)\)$/);
|
|
9
|
+
if(!match||+match[1]>=.9)return frame;
|
|
10
|
+
return {...frame,transform:`scale(${+match[1]<.5?.92:.97})`,opacity:frame.opacity??(+match[1]<.5?0:1)};
|
|
11
|
+
});
|
|
12
|
+
const animation=element.animate(frames,timing);
|
|
13
|
+
if(!mermaidEntryBatch){mermaidEntryBatch=[];queueMicrotask(()=>{
|
|
14
|
+
const batch=mermaidEntryBatch;mermaidEntryBatch=null;
|
|
15
|
+
const end=Math.max(0,...batch.map(a=>{const t=a.effect.getTiming();return Number(t.delay)+Number(t.duration);}));
|
|
16
|
+
if(end>mermaidEntryBudget){const ratio=mermaidEntryBudget/end;for(const a of batch){const t=a.effect.getTiming();a.effect.updateTiming({delay:Number(t.delay)*ratio,duration:Number(t.duration)*ratio});}}
|
|
17
|
+
});}
|
|
18
|
+
mermaidEntryBatch.push(animation);return animation;
|
|
19
|
+
}
|
|
20
|
+
// rAF 与 D3 几何动画采用同一条曲线,二分求解 Bézier 的时间参数。
|
|
21
|
+
function mermaidEntryProgress(time){
|
|
22
|
+
const t=Math.max(0,Math.min(1,time));let low=0,high=1;
|
|
23
|
+
for(let i=0;i<16;i++){const u=(low+high)/2,x=3*(1-u)*(1-u)*u*.23+3*(1-u)*u*u*.32+u*u*u;if(x<t)low=u;else high=u;}
|
|
24
|
+
const u=(low+high)/2;return 1-(1-u)**3;
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#mcx-qv-root.qv-mermaid{--mcx-ease-out:cubic-bezier(.23,1,.32,1);--mcx-tip-shadow:0 4px 16px light-dark(color-mix(in srgb,var(--foreground) 9%,transparent),rgb(0 0 0/.5));--mcx-tip-surface:light-dark(var(--popover),color-mix(in srgb,var(--popover-foreground) 6%,var(--popover)))}
|
|
2
|
+
#mcx-qv-root.qv-mermaid :is(.node-tip,.seq-tip,.er-tip,.class-tip,.state-tip,.state-peers,.xy-tip,.sankey-detail,.radar-detail,.quadrant-detail,.architecture-detail,.bubble,.quick-radar-tooltip){background:var(--mcx-tip-surface);color:var(--popover-foreground);border:1px solid var(--border);border-radius:12px;padding:12px 14px;font-size:12px;line-height:18px;box-shadow:var(--mcx-tip-shadow);transition:opacity 140ms var(--mcx-ease-out),scale 140ms var(--mcx-ease-out)}
|
|
3
|
+
@starting-style{#mcx-qv-root.qv-mermaid :is(.node-tip,.seq-tip,.er-tip,.class-tip,.state-tip,.state-peers,.xy-tip,.sankey-detail,.radar-detail,.quadrant-detail,.architecture-detail,.bubble,.quick-radar-tooltip){opacity:0;scale:.97}}
|
|
4
|
+
#mcx-qv-root.qv-mermaid :is(.xy-tip-title,.sankey-detail-title,.radar-detail-title,.c4-tip-title,.state-tip-name,.bubble-title,.quick-radar-tooltip-dimension){font-size:14px;line-height:20px;font-weight:500}
|
|
5
|
+
#mcx-qv-root.qv-mermaid :is(.xy-tip-name,.radar-detail-name,.quick-radar-tooltip-name){color:var(--muted-foreground);font-weight:400}
|
|
6
|
+
#mcx-qv-root.qv-mermaid :is(.xy-tip-value,.radar-detail-value,.quick-radar-tooltip-value,.bubble-value){color:var(--popover-foreground);font-weight:500;font-variant-numeric:tabular-nums}
|
|
7
|
+
#mcx-qv-root.qv-mermaid :is(.state-tip-caption,.architecture-detail-label){font-size:12px;line-height:18px}
|
|
8
|
+
@media (prefers-reduced-motion:reduce){#mcx-qv-root.qv-mermaid :is(.node-tip,.seq-tip,.er-tip,.class-tip,.state-tip,.state-peers,.xy-tip,.sankey-detail,.radar-detail,.quadrant-detail,.architecture-detail,.bubble,.quick-radar-tooltip){transition:none}}
|
|
9
|
+
|
|
10
|
+
/* 规则 37:标题、正文与辅助信息保持稳定层级。 */
|
|
11
|
+
#mcx-qv-root.qv-mermaid h3{font-size:16px;line-height:24px}
|
|
12
|
+
#mcx-qv-root.qv-mermaid .state-node{font-size:14px;line-height:20px}
|
|
13
|
+
#mcx-qv-root.qv-mermaid .timeline-period{font-size:14px}
|
|
14
|
+
#mcx-qv-root.qv-mermaid .er-type{color:var(--muted-foreground)}
|
|
15
|
+
|
|
16
|
+
/* 内容画布在宽容器内居中,超宽时保留左侧可达的滚动起点。 */
|
|
17
|
+
#mcx-qv-root.qv-mermaid:is([data-renderer="qv-quadrant"],[data-renderer="qv-er"],[data-renderer="qv-class"]) .scene{margin-inline:auto}
|
|
18
|
+
/* Journey 的固定参考轴与步骤画布一起居中,溢出时只滚动步骤。 */
|
|
19
|
+
#mcx-qv-root.qv-mermaid[data-renderer="qv-journey"] .journey-frame{max-width:100%;margin-inline:auto}
|
|
20
|
+
#mcx-qv-root.qv-mermaid:is([data-renderer="qv-radar"],[data-renderer="qv-sankey"]) h3{margin-inline:0;text-align:center}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { load, JSON_SCHEMA } from 'js-yaml';
|
|
2
|
+
|
|
3
|
+
// Mermaid 11.12 的 getDiagramFromText 只转交显式 metadata,未转交预处理得到的标题。
|
|
4
|
+
// 使用相同的 YAML schema 与边界,避免另写只能识别单行标题的解析器。
|
|
5
|
+
export function readMermaidTitle(source) {
|
|
6
|
+
const match = source.replace(/\r\n?/g, '\n').match(/^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s);
|
|
7
|
+
if (!match) return '';
|
|
8
|
+
const metadata = load(match[1], { schema: JSON_SCHEMA });
|
|
9
|
+
return metadata && typeof metadata === 'object' && !Array.isArray(metadata) && metadata.title
|
|
10
|
+
? String(metadata.title) : '';
|
|
11
|
+
}
|
|
@@ -2563,6 +2563,33 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
|
2563
2563
|
THIS SOFTWARE.
|
|
2564
2564
|
|
|
2565
2565
|
|
|
2566
|
+
========================================================================
|
|
2567
|
+
js-yaml@4.1.1 — MIT
|
|
2568
|
+
|
|
2569
|
+
LICENSE
|
|
2570
|
+
(The MIT License)
|
|
2571
|
+
|
|
2572
|
+
Copyright (C) 2011-2015 by Vitaly Puzrin
|
|
2573
|
+
|
|
2574
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2575
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
2576
|
+
in the Software without restriction, including without limitation the rights
|
|
2577
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2578
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
2579
|
+
furnished to do so, subject to the following conditions:
|
|
2580
|
+
|
|
2581
|
+
The above copyright notice and this permission notice shall be included in
|
|
2582
|
+
all copies or substantial portions of the Software.
|
|
2583
|
+
|
|
2584
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2585
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2586
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2587
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2588
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2589
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
2590
|
+
THE SOFTWARE.
|
|
2591
|
+
|
|
2592
|
+
|
|
2566
2593
|
========================================================================
|
|
2567
2594
|
katex@0.16.47 — MIT
|
|
2568
2595
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecodex",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.54",
|
|
4
4
|
"description": "Lightweight, local-first plugins for the Codex desktop app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
"elkjs": "0.10.0",
|
|
143
143
|
"esbuild": "^0.28.2",
|
|
144
144
|
"html-to-image": "1.11.13",
|
|
145
|
+
"js-yaml": "4.1.1",
|
|
145
146
|
"lucide": "0.468.0",
|
|
146
147
|
"mermaid": "11.12.0"
|
|
147
148
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var uz=Object.defineProperty;var Nr=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var At=(e,t)=>{for(var n in t)uz(e,n,{get:t[n],enumerable:!0})};function q$(e,t){return ST[e]?.[t==="zh-CN"?0:1]??(t==="zh-CN"?["Codex \u4E2D\u5BF9\u5E94\u529F\u80FD\u7684\u4F4D\u7F6E\u3002","\u8BF7\u53C2\u8003\u529F\u80FD\u8BF4\u660E\u3002","\u6548\u679C\u53D6\u51B3\u4E8E\u5F53\u524D\u7248\u672C\u4E0E\u9002\u7528\u9875\u9762\u3002"]:["The feature\u2019s location in Codex.","Refer to the feature description.","Availability depends on the version and current page."])}var ST,V$=Nr(()=>{ST={"model-slider":[["\u8F93\u5165\u6846\u7684\u6A21\u578B\u9009\u62E9\u533A\u57DF\u3002","\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\u5206\u6563\uFF0C\u5207\u6362\u4E0D\u591F\u76F4\u63A5\u3002","\u6253\u5F00\u6A21\u578B\u7A97\u53E3\uFF0C\u9009\u62E9\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\uFF1B\u6536\u85CF\u5E38\u7528\u6A21\u578B\u4EE5\u4FBF\u518D\u6B21\u9009\u62E9\u3002"],["The model selector beside the composer.","Switching models and reasoning levels takes extra steps.","Open the model panel, choose a model and reasoning level, and save favorites for quick access."]],notes:[["\u5B98\u65B9 Prompt \u9875\u9762\u4E0E\u8F93\u5165\u6846\u65C1\u7684 Quick Prompts\u3002","\u5E38\u7528\u63D0\u793A\u8BCD\u9700\u8981\u53CD\u590D\u67E5\u627E\u548C\u590D\u5236\u3002","\u6309\u5206\u7C7B\u7BA1\u7406\u63D0\u793A\u8BCD\uFF0C\u4ECE Quick Prompts \u586B\u5165\u5F53\u524D\u8F93\u5165\u6846\uFF1B\u586B\u5165\u540E\u7531\u4F60\u68C0\u67E5\u5E76\u53D1\u9001\u3002"],["The Prompt page and Quick Prompts beside the composer.","Reusable prompts are hard to find and copy repeatedly.","Organize prompts by category and insert one into the current composer. Review it before sending."]],"usage-meter":[["Codex \u4FA7\u680F\u7684\u989D\u5EA6\u73AF\u3002","\u67E5\u770B\u5269\u4F59\u989D\u5EA6\u9700\u8981\u6253\u5F00\u8D26\u53F7\u83DC\u5355\u3002","\u7528\u989D\u5EA6\u73AF\u67E5\u770B\u4F7F\u7528\u6BD4\u4F8B\uFF0C\u70B9\u51FB\u6253\u5F00\u7528\u91CF\u8BE6\u60C5\u3002"],["The usage ring in the Codex sidebar.","Checking remaining usage requires opening the account menu.","Read usage at a glance, then click for usage details."]],"session-status":[["\u5F53\u524D\u4F1A\u8BDD\u7684\u72B6\u6001\u533A\u57DF\u3002","\u4F1A\u8BDD\u7528\u91CF\u4E0E\u751F\u6210\u901F\u5EA6\u4E0D\u5BB9\u6613\u96C6\u4E2D\u67E5\u770B\u3002","\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u7684\u7528\u91CF\u3001\u4E0A\u4E0B\u6587\u548C\u751F\u6210\u6307\u6807\uFF1B\u53EF\u7528\u9879\u76EE\u53D6\u51B3\u4E8E\u4F1A\u8BDD\u4E0E\u63D0\u4F9B\u65B9\u3002"],["The current conversation\u2019s status area.","Usage and generation metrics are spread across the interface.","Read session usage, context and generation metrics when supported by the session and provider."]],"markdown-reading":[["Codex \u7684 Markdown \u6587\u4EF6\u9884\u89C8\u3002","\u957F\u6587\u9605\u8BFB\u3001\u811A\u6CE8\u8DF3\u8F6C\u548C\u8868\u683C\u67E5\u770B\u4E0D\u591F\u65B9\u4FBF\u3002","\u5728\u6587\u4EF6\u9884\u89C8\u4E2D\u9605\u8BFB\u589E\u5F3A\u6392\u7248\uFF0C\u4F7F\u7528\u76EE\u5F55\u3001\u811A\u6CE8\u548C\u8868\u683C\u64CD\u4F5C\u3002"],["Markdown file previews in Codex.","Long documents, footnotes and tables take extra effort to read.","Read enhanced formatting and use the outline, footnote navigation and table actions."]],"mermaid-diagrams":[["Markdown \u6587\u4EF6\u9884\u89C8\u4E2D\u7684 Mermaid \u56FE\u8868\u3002","\u5B9E\u9A8C\u6027\u56FE\u8868\u6837\u5F0F\u4E0E\u4EA4\u4E92\u4ECD\u5728\u5B8C\u5584\uFF0C\u9ED8\u8BA4\u5173\u95ED\u3002","\u6309\u9700\u5F00\u542F\u56FE\u8868\u589E\u5F3A\uFF0C\u4F7F\u7528\u7F29\u653E\u548C PNG \u4E0B\u8F7D\uFF1B\u5173\u95ED\u540E\u4F7F\u7528 Codex \u539F\u751F\u56FE\u8868\u3002"],["Mermaid diagrams in Markdown file previews.","Enhanced diagram styles and interactions are experimental and off by default.","Opt in to diagram zoom and PNG download. Turn it off to use native Codex diagrams."]],"file-navigation":[["Codex \u6587\u4EF6\u9884\u89C8\u4E0A\u65B9\u7684\u8DEF\u5F84\u533A\u57DF\u3002","\u6D4F\u89C8\u76F8\u90BB\u76EE\u5F55\u548C\u6587\u4EF6\u9700\u8981\u989D\u5916\u8DF3\u8F6C\u3002","\u70B9\u51FB\u8DEF\u5F84\u5C55\u5F00\u5206\u5217\u76EE\u5F55\uFF0C\u9010\u7EA7\u6D4F\u89C8\u5E76\u6253\u5F00\u53E6\u4E00\u4E2A\u6587\u4EF6\u3002"],["The path above a file preview in Codex.","Browsing nearby files and folders takes extra navigation.","Open the path to browse cascading folder columns and choose another file."]],"files-auto-refresh":[["Codex Side Panel \u7684 Files \u76EE\u5F55\u5217\u8868\u3002","Agent \u6539\u53D8\u9879\u76EE\u6587\u4EF6\u540E\uFF0C\u9700\u8981\u53CD\u590D\u6536\u8D77\u3001\u5C55\u5F00\u624D\u80FD\u770B\u5230\u65B0\u5217\u8868\u3002","\u4FDD\u6301 Files \u6253\u5F00\uFF0C\u81EA\u52A8\u540C\u6B65\u6839\u76EE\u5F55\u548C\u5DF2\u5C55\u5F00\u76EE\u5F55\uFF1B\u4FDD\u7559\u5F53\u524D\u6587\u4EF6\u4E0E\u6D4F\u89C8\u4F4D\u7F6E\u3002"],["The Files tree in the Codex side panel.","File changes can require collapsing and reopening the tree.","Keep Files open to refresh the root and expanded folders while preserving the current file and browsing position."]],images:[["Codex Library \u7684\u56FE\u7247\u96C6\u5408\u4E0E\u56FE\u7247\u67E5\u770B\u5668\u3002","\u67E5\u627E\u56FE\u7247\u53CA\u5176\u63D0\u793A\u8BCD\u9700\u8981\u6765\u56DE\u5207\u6362\u3002","\u6D4F\u89C8\u56FE\u7247\u96C6\u5408\uFF0C\u6253\u5F00\u56FE\u7247\u67E5\u770B\u5927\u56FE\u53CA\u53EF\u8FFD\u6EAF\u7684\u63D0\u793A\u8BCD\u4FE1\u606F\u3002"],["Image collections in Codex Library and the image viewer.","Finding images and their prompts requires switching views.","Browse collections, open an image, and inspect available prompt provenance."]],sites:[["Codex \u4E2D\u7684 Sites \u9875\u9762\u3002","\u672C\u5730\u9879\u76EE\u4E0E\u5E38\u7528\u7F51\u5740\u5206\u6563\u5728\u4E0D\u540C\u4F4D\u7F6E\u3002","\u6536\u85CF\u7F51\u5740\u3001\u53D1\u73B0\u6B63\u5728\u8FD0\u884C\u7684\u672C\u5730\u7AD9\u70B9\uFF0C\u5E76\u4ECE Sites \u6253\u5F00\u3002"],["The Sites page in Codex.","Local projects and saved links are scattered.","Save URLs, discover running local sites, and open them from Sites."]],"composer-expand":[["Work \u4E0E Codex \u7684\u8F93\u5165\u6846\u53F3\u4E0A\u89D2\u3002","\u957F\u6307\u4EE4\u53D7\u8F93\u5165\u6846\u9AD8\u5EA6\u9650\u5236\uFF0C\u7F16\u8F91\u65F6\u9700\u8981\u53CD\u590D\u6EDA\u52A8\u3002","\u8F93\u5165\u591A\u884C\u6587\u5B57\u540E\u70B9\u51FB\u5C55\u5F00\uFF1B\u7F16\u8F91\u5B8C\u6210\u540E\u6536\u8D77\uFF0C\u8349\u7A3F\u4FDD\u6301\u4E0D\u53D8\u3002"],["The upper-right corner of the Work and Codex composer.","Long drafts need repeated scrolling in a compact editor.","Enter a multiline draft and click Expand. Collapse when finished; your draft stays in place."]],"quick-chat":[["Codex \u7684\u6D6E\u52A8 Quick Chat \u7A97\u53E3\u3002","\u4E34\u65F6\u63D0\u95EE\u65F6\u9700\u8981\u5207\u6362\u4E3B\u7A97\u53E3\uFF0C\u5386\u53F2\u4E0D\u6613\u7EE7\u7EED\u3002","\u4ECE\u4FA7\u680F\u6216\u5FEB\u6377\u952E\u6253\u5F00 Quick Chat\uFF0C\u53D1\u9001\u540E\u5C55\u5F00\uFF0C\u6062\u590D\u6700\u5C0F\u5316\u8F93\u5165\u6846\u5E76\u67E5\u770B\u5386\u53F2\u3002"],["The floating Quick Chat window.","Quick questions and continuing recent chats require window switching.","Open Quick Chat from the sidebar or shortcut, expand after sending, restore a minimized composer and browse history."]],"sidebar-focus":[["Codex \u5DE6\u4FA7\u680F\u7684\u5206\u7EC4\u6807\u9898\u3002","\u591A\u4E2A\u4FA7\u680F\u5206\u7EC4\u5C55\u5F00\u65F6\uFF0C\u5F53\u524D\u5206\u7EC4\u4E0D\u5BB9\u6613\u805A\u7126\u3002","\u70B9\u51FB\u5F53\u524D\u5206\u7EC4\uFF0C\u4E00\u952E\u6536\u8D77\u5176\u4ED6\u5206\u7EC4\uFF1B\u518D\u6B21\u70B9\u51FB\u6062\u590D\u5148\u524D\u7684\u5C55\u5F00\u72B6\u6001\u3002"],["Group headings in the Codex sidebar.","Several expanded groups make the current group harder to focus on.","Click a group to collapse other groups. Click again to restore their previous expanded state."]]}});function Z$(e,t){let n=t==="zh-CN",o=(A,K)=>n?A:K,r=new AbortController,i=(A,K,Q,re={})=>A.addEventListener(K,Q,{...re,signal:r.signal}),a=matchMedia("(hover: hover) and (pointer: fine)"),s=matchMedia("(prefers-reduced-motion: reduce)"),l=null,c=null,d=null,m,h,f,v=!1,y=0,k=!1,T=null,R,N=null,Z=!1,X=null,M=()=>R??=window.minecodexPreviewMedia!==void 0?Promise.resolve(window.minecodexPreviewMedia):fetch("/assets/previews/manifest.json").then(A=>A.ok?A.json():{}).then(A=>A&&typeof A=="object"?A:{}).catch(()=>({})),B=(A,K,Q)=>{let re=document.createElement(A);return re.className=K,Q&&(re.textContent=Q),re};async function De(A,K,Q,re){if(!window.minecodexMcpApp)return`/assets/previews/${Q}`;let be=(await window.minecodexMcpApp.readServerResource({uri:`resource://minecodex/previews/${A}/${K}`},{signal:re})).contents?.[0];if(!be?.blob)throw new Error("Preview resource unavailable");return`data:${be.mimeType};base64,${be.blob}`}function ie({restore:A=!1}={}){clearTimeout(m),clearTimeout(h),clearTimeout(f),y++,T?.abort(),T=null;let K=c,Q=l,re=d;c=null,l=null,d=null,v=!1,re&&(re.pause(),re.removeAttribute("src"),re.load());let le=Q?.querySelector(".preview-entry");le?.setAttribute("aria-expanded","false"),le?.removeAttribute("aria-controls"),Q?.classList.remove("is-previewing"),e.classList.remove("has-preview"),K?.remove(),A&&le?.isConnected&&(k=!0,le.focus({preventScroll:!0}),k=!1)}function fe(){if(!l||!c)return;let A=l.getBoundingClientRect(),K=Math.min(360,innerWidth-32);c.style.width=`${K}px`,c.style.maxHeight=`${Math.max(120,innerHeight-32)}px`;let Q=c.getBoundingClientRect().height,re,le;if(innerWidth-A.right>=K+24)re=A.right+8;else if(A.left>=K+24)re=A.left-K-8;else{re=Math.max(16,Math.min(A.left,innerWidth-K-16));let be=innerHeight-A.bottom-24,Oe=A.top-24;be>=Math.min(Q,180)?(c.style.maxHeight=`${be}px`,le=A.bottom+8):Oe>=Math.min(Q,180)?(c.style.maxHeight=`${Oe}px`,le=Math.max(16,A.top-Q-8)):(le=Math.max(16,A.top+l.querySelector(".plugin-topline").getBoundingClientRect().height+32),c.style.maxHeight=`${Math.max(100,innerHeight-le-16)}px`)}le??=Math.max(16,Math.min(A.top,innerHeight-Q-16)),Object.assign(c.style,{left:`${re}px`,top:`${le}px`,visibility:"visible"})}function et(){!v&&!N&&!Z&&(h=setTimeout(()=>ie(),100))}async function Nt(A,K,Q,re){let le=(await M())?.[A];if(re!==y||!c||!le)return;T=new AbortController;let be=T.signal,Oe,at,He=!1;Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u9884\u89C8\u2026","Loading preview\u2026");let pt=await Promise.all(["poster","video"].map(async jt=>{if(!le[jt])return null;try{return await De(A,jt,le[jt],be)}catch{return He=!0,null}}));if(re!==y)return;[Oe,at]=pt,Q.textContent=He?o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon");let ue=null;if(Oe&&(ue=B("img","preview-poster"),ue.alt=o("\u529F\u80FD\u9759\u6001\u9884\u89C8","Static feature preview"),ue.addEventListener("load",fe,{once:!0}),ue.addEventListener("error",()=>{ue.remove(),He=!0,d||(Q.textContent=o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description")),fe()},{once:!0}),ue.src=Oe,K.append(ue),Q.textContent=o("\u9759\u6001\u9884\u89C8","Static preview")),!at){fe();return}if(s.matches){fe();return}let ne=B("video","preview-video");d=ne,ne.muted=!0,ne.playsInline=!0,ne.preload="metadata",ne.hidden=!0;let zt=()=>{c.classList.remove("is-media-only"),ue&&(ue.hidden=!1)},zr=()=>{re===y&&(clearTimeout(f),ne.pause(),ne.removeAttribute("src"),ne.load(),ne.remove(),d=null,zt(),Q.textContent=ue?.isConnected?o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u9759\u6001\u9884\u89C8","Video unavailable \xB7 Static preview"):o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Video unavailable \xB7 See description"),fe())};ne.addEventListener("error",zr,{once:!0}),ne.addEventListener("loadeddata",()=>{re===y&&fe()}),ne.addEventListener("play",()=>{re===y&&(ne.hidden=!1,ue&&(ue.hidden=!0),c.classList.add("is-media-only"),fe())});let Wt=async()=>{if(re===y)try{await ne.play()}catch{re===y&&d===ne&&ne.isConnected&&(ne.hidden=!0,zt(),Q.textContent=ue?.isConnected?o("\u9759\u6001\u9884\u89C8","Static preview"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"),fe())}};ne.addEventListener("ended",()=>{clearTimeout(f),f=setTimeout(()=>{re!==y||d!==ne||(ne.currentTime=0,Wt())},2e3)}),K.append(ne),Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u6F14\u793A\u2026","Loading demo\u2026"),ne.src=at,Wt(),fe()}function mt(A,K=!1){if(clearTimeout(m),clearTimeout(h),A===l){v||=K;return}ie(),Z=!1,l=A,v=K,c=B("section","feature-preview"),c.id="feature-preview",c.setAttribute("role","region");let Q=B("h3","preview-title",A.querySelector(".plugin-name").textContent);Q.id="feature-preview-title",c.setAttribute("aria-labelledby",Q.id);let re=B("button","button quiet preview-close",o("\u5173\u95ED","Close"));re.type="button",re.addEventListener("click",()=>ie({restore:v||c.contains(document.activeElement)}));let le=B("div","preview-heading");le.append(Q,re),c.append(le);let be=B("div","preview-media");c.append(be);let Oe=B("dl","preview-details"),at=[o("\u51FA\u73B0\u4F4D\u7F6E","Location"),o("\u89E3\u51B3\u95EE\u9898","Problem"),o("\u64CD\u4F5C\u4E0E\u6548\u679C","Action and result")];q$(A.dataset.featureId,t).forEach((ue,ne)=>{Oe.append(B("dt","",at[ne]),B("dd","",ue))});let He=B("p","preview-resource-state",o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"));c.append(Oe,He),c.addEventListener("pointerenter",()=>{Z=!0,clearTimeout(h)}),c.addEventListener("pointerleave",()=>{Z=!1,et()}),c.addEventListener("focusin",()=>{clearTimeout(h)}),c.addEventListener("focusout",ue=>{!c?.contains(ue.relatedTarget)&&!l?.contains(ue.relatedTarget)&&ie()}),document.querySelector(".dashboard-surface").append(c),A.classList.add("is-previewing"),e.classList.add("has-preview");let pt=A.querySelector(".preview-entry");pt.setAttribute("aria-expanded","true"),pt.setAttribute("aria-controls",c.id),fe(),Nt(A.dataset.featureId,be,He,y)}function Gt(A){let K=B("button","preview-entry");K.type="button",K.setAttribute("aria-expanded","false"),K.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${A.querySelector(".plugin-name").textContent||A.dataset.featureId}`),A.append(K),i(A,"pointerenter",()=>{a.matches&&(N=A,X=A,clearTimeout(m),clearTimeout(h),m=setTimeout(()=>{X=null,mt(A)},200))}),i(A,"pointerleave",()=>{N===A&&(N=null),X===A&&(clearTimeout(m),X=null),et()}),i(K,"focus",()=>{k||mt(A)}),i(K,"click",()=>mt(A,!0)),i(A,"focusout",Q=>{!A.contains(Q.relatedTarget)&&!c?.contains(Q.relatedTarget)&&document.documentElement.dataset.input==="keyboard"&&ie()})}i(document,"keydown",A=>{if(A.key==="Escape"&&l){A.preventDefault();let K=v||c.contains(document.activeElement);ie({restore:K})}}),i(document,"pointerdown",A=>{l&&!l.contains(A.target)&&!c.contains(A.target)&&ie()}),i(window,"scroll",A=>{c?.contains(A.target)||ie()},{capture:!0}),i(window,"resize",()=>ie()),i(document,"visibilitychange",()=>{document.hidden&&ie()}),i(window,"blur",()=>ie()),i(document.querySelector("#data-dialog"),"toggle",()=>ie()),i(document.querySelector("#language-menu"),"toggle",()=>ie()),i(window,"pagehide",()=>{ie(),r.abort()});function $t(A){ie(),t=A,n=t==="zh-CN";for(let K of e.querySelectorAll(".plugin-card"))K.querySelector(".preview-entry")?.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${K.querySelector(".plugin-name").textContent}`)}return{attach:Gt,close:ie,setLocale:$t}}var F$=Nr(()=>{V$()});function H$(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 J$=Nr(()=>{});async function gn(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 jv=Nr(()=>{});var kT={};function W$(){document.querySelector("#brand-slogan").textContent=$e==="zh-CN"?"\u8BA9 Codex \u66F4\u987A\u624B\u3002":"Make Codex work better for you.",document.querySelector("#brand-description").textContent=$e==="zh-CN"?"\u6309\u9700\u5F00\u542F\u4EA4\u4E92\u589E\u5F3A\uFF0C\u8BA9\u65E5\u5E38\u4F7F\u7528\u66F4\u9AD8\u6548\u3002":"Enable the enhancements you need for a smoother daily workflow.";let e=document.querySelector("#language-button"),t=$e==="zh-CN"?"\u8BED\u8A00 \xB7 \u4E2D\u6587":"Language \xB7 English";e.setAttribute("aria-label",t),e.setAttribute("data-minecodex-tooltip",t),q.languageToggle.setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language"),document.querySelector("#language-menu").setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language");for(let n of q.languageButtons)n.setAttribute("aria-pressed",String(n.dataset.languageChoice===$e));q.restartTitle.textContent=oe.restartTitle,q.restartCopy.textContent=oe.restartCopy,q.restartButton.querySelector(".button-label").textContent=oe.restart,q.pluginsHeading.textContent=oe.plugins,q.errorTitle.textContent=oe.loadError,q.errorCopy.textContent=oe.loadErrorCopy,q.retryButton.textContent=oe.retry,q.versionLabel.textContent=oe.version,q.diagnosticsButton.textContent=oe.copyDiagnostics,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}function bT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=oe.states[t]??oe.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}: ${oe.failureDetail}`:n,className:o}}function Xe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function yT(e){let t=Xe("article","plugin-card");t.dataset.featureId=e.id;let n=Xe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=Xe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=Xe("div","plugin-copy"),i=Xe("div","plugin-title-line"),a=Xe("h3","plugin-name");i.append(a);let s=Xe("p","plugin-description");r.append(i,s);let l=Xe("div","plugin-topline"),c=Xe("label","switch"),d=Xe("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 m=Xe("span","switch-track");m.setAttribute("aria-hidden","true"),c.append(d,m);let h=Xe("span","plugin-state"),f=Xe("span","status-dot");f.setAttribute("aria-hidden","true");let v=Xe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),Vi.attach(t),t}function Ud(e,t){for(let d of q.languageButtons)d.disabled=yt.size>0;let n=bT(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=yt.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label,e.querySelector(".preview-entry")?.setAttribute("aria-label",`${$e==="zh-CN"?"\u67E5\u770B\u6548\u679C":"See how it works"} \xB7 ${t.label}`)}function Y$(e){return[...q.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function _T(e){e=e.filter(n=>!["unread-inbox","hide-upsell-banner"].includes(n.id));for(let n of[...q.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let[n,o]of e.entries()){let r=Y$(o.id);r||(r=yT(o));let i=q.pluginList.children[n];i!==r&&q.pluginList.insertBefore(r,i??null),Ud(r,o)}for(let n of[...q.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&(n.classList.contains("is-previewing")&&Vi.close(),n.remove());q.pluginList.setAttribute("aria-busy","false")}function X$(){q.versionValue.textContent=Qe?.version??"\u2014",q.restartNotice.hidden=!Qe?.pendingRestart}function $T(){X$(),_T(Qe?.features??[])}function zT(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 K$(e){if(!e?.input)return;Y$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(B$),q.toast.textContent=e,q.toast.hidden=!1,B$=setTimeout(()=>{q.toast.hidden=!0},4200)}function Av(e,t){Qe.features=Qe.features.map(n=>n.id===e?{...n,...t}:n)}async function Tc(){q.loadError.hidden=!0;try{let e=await gn("/api/status",{headers:{"Accept-Language":$e}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();yt.size&&Qe&&(t.features=t.features.map(n=>yt.has(n.id)?Qe.features.find(o=>o.id===n.id)??n:n)),Qe=t,q.pluginList.hidden=!1,$T()}catch{Vi.close(),q.pluginList.hidden=!0,q.loadError.hidden=!1}}function Fi(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":Q$.matches,t=Zi==="dark"||Zi!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",q.themeToggle.setAttribute("aria-label",$e==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of q.themeButtons){n.dataset.themeChoice=t?"dark":"light",n.querySelector(".ui-icon").className=`ui-icon ${t?"moon":"sun"}-icon`;let o=t?oe.darkAppearance:oe.lightAppearance,r=t?oe.lightAppearance:oe.darkAppearance,i=$e==="zh-CN"?`${o} \xB7 \u5207\u6362\u4E3A${r}`:`${o} \xB7 Switch to ${r.toLowerCase()}`;n.setAttribute("aria-label",i),n.setAttribute("data-minecodex-tooltip",i)}}async function wT(e){if(Uv)return;if(Vi.close(),Zi=document.documentElement.dataset.theme==="dark"?"light":"dark",!window.minecodexMcpApp)try{localStorage.setItem("minecodex-appearance",Zi)}catch{}if(!document.startViewTransition||matchMedia("(prefers-reduced-motion: reduce)").matches){Fi();return}let t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,r=Math.hypot(Math.max(n,innerWidth-n),Math.max(o,innerHeight-o)),i=document.startViewTransition(Fi);Uv=i;try{await i.ready,document.documentElement.animate({clipPath:[`circle(0px at ${n}px ${o}px)`,`circle(${r}px at ${n}px ${o}px)`]},{duration:420,easing:"cubic-bezier(0.23, 1, 0.32, 1)",pseudoElement:"::view-transition-new(root)"}),await i.finished}catch{i.skipTransition()}finally{Uv=null}}var Mv,$e,G$,oe,q,Qe,B$,yt,Vi,Q$,Zi,Uv,Dv,ez=Nr(()=>{F$();J$();jv();try{Mv=localStorage.getItem("minecodex-language")}catch{}$e=["en","zh-CN"].includes(Mv)?Mv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=$e;G$={en:{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":{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"}},oe=G$[$e],q={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")},Qe=null,B$=null,yt=new Set,Vi=Z$(q.pluginList,$e);q.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!Qe)return;let o=n.dataset.featureId,r={...Qe.features.find(a=>a.id===o)},i=zT(o);yt.add(o),Av(o,{enabled:t.checked,state:"saved"}),Ud(n,Qe.features.find(a=>a.id===o)),q.saveState.textContent=oe.saving;try{let a=await gn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":$e},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&&Av(o,l),Qe.pendingRestart=s.pendingRestart,yt.delete(o);let c=l??Qe.features.find(d=>d.id===o);c&&Ud(n,c),X$(),K$(i),q.saveState.textContent=yt.size?oe.saving:oe.saved}catch{yt.delete(o),Av(o,r),Ud(n,r),q.saveState.textContent=yt.size?oe.saving:"",K$(i),Dd(oe.changeFailed)}});q.restartButton.addEventListener("click",async()=>{q.restartButton.disabled=!0,q.restartButton.querySelector(".button-label").textContent=oe.restarting;try{let e=await gn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":$e},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Tc()}catch{Dd(oe.restartFailed)}finally{q.restartButton.disabled=!1,q.restartButton.querySelector(".button-label").textContent=oe.restart}});q.retryButton.addEventListener("click",()=>{q.pluginList.hidden=!1,Tc()});q.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(H$(Qe),null,2)),Dd(oe.diagnosticsCopied)}catch{Dd(oe.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!yt.size&&Tc()},5e3);q.updateButton.addEventListener("click",async()=>{q.updateButton.disabled=!0,q.updateButton.querySelector(".button-label").textContent=oe.checkingUpdates,q.updateResult.hidden=!0;try{let e=await gn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();q.updateResult.textContent=t.available?oe.updateAvailable(t.latest):oe.current,q.updateResult.hidden=!1}catch{q.updateResult.textContent=oe.updateFailed,q.updateResult.hidden=!1}finally{q.updateButton.disabled=!1,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}});Q$=matchMedia("(prefers-color-scheme: dark)"),Zi=null;if(!window.minecodexMcpApp)try{Zi=localStorage.getItem("minecodex-appearance")}catch{}Uv=null;q.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");t&&wT(t)});q.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||yt.size||q.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==$e){try{localStorage.setItem("minecodex-language",n)}catch{return}if(Vi.close(),!window.minecodexMcpApp){location.reload();return}$e=n,oe=G$[$e],document.documentElement.lang=$e,Vi.setLocale($e),document.querySelector("#language-menu").hidePopover(),W$(),Fi(),q.updateResult.hidden=!0,q.toast.hidden=!0,window.dispatchEvent(new Event("minecodex-language")),Tc()}});Q$.addEventListener("change",Fi);window.addEventListener("minecodex-host-theme",()=>{Zi=null,Fi()});document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});W$();Fi();Tc();Dv=document.querySelector("#language-menu");Dv.addEventListener("toggle",e=>{if(document.querySelector("#language-button").setAttribute("aria-expanded",String(e.newState==="open")),e.newState!=="open")return;let t=document.querySelector("#language-button").getBoundingClientRect();Dv.style.left=`${Math.max(8,Math.min(t.right-140,innerWidth-148))}px`,Dv.style.top=`${t.bottom+8}px`})});function tz(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 uz=Object.defineProperty;var Nr=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var At=(e,t)=>{for(var n in t)uz(e,n,{get:t[n],enumerable:!0})};function q$(e,t){return ST[e]?.[t==="zh-CN"?0:1]??(t==="zh-CN"?["Codex \u4E2D\u5BF9\u5E94\u529F\u80FD\u7684\u4F4D\u7F6E\u3002","\u8BF7\u53C2\u8003\u529F\u80FD\u8BF4\u660E\u3002","\u6548\u679C\u53D6\u51B3\u4E8E\u5F53\u524D\u7248\u672C\u4E0E\u9002\u7528\u9875\u9762\u3002"]:["The feature\u2019s location in Codex.","Refer to the feature description.","Availability depends on the version and current page."])}var ST,V$=Nr(()=>{ST={"model-slider":[["\u8F93\u5165\u6846\u7684\u6A21\u578B\u9009\u62E9\u533A\u57DF\u3002","\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\u5206\u6563\uFF0C\u5207\u6362\u4E0D\u591F\u76F4\u63A5\u3002","\u6253\u5F00\u6A21\u578B\u7A97\u53E3\uFF0C\u9009\u62E9\u6A21\u578B\u4E0E\u601D\u8003\u6863\u4F4D\uFF1B\u6536\u85CF\u5E38\u7528\u6A21\u578B\u4EE5\u4FBF\u518D\u6B21\u9009\u62E9\u3002"],["The model selector beside the composer.","Switching models and reasoning levels takes extra steps.","Open the model panel, choose a model and reasoning level, and save favorites for quick access."]],notes:[["\u5B98\u65B9 Prompt \u9875\u9762\u4E0E\u8F93\u5165\u6846\u65C1\u7684 Quick Prompts\u3002","\u5E38\u7528\u63D0\u793A\u8BCD\u9700\u8981\u53CD\u590D\u67E5\u627E\u548C\u590D\u5236\u3002","\u6309\u5206\u7C7B\u7BA1\u7406\u63D0\u793A\u8BCD\uFF0C\u4ECE Quick Prompts \u586B\u5165\u5F53\u524D\u8F93\u5165\u6846\uFF1B\u586B\u5165\u540E\u7531\u4F60\u68C0\u67E5\u5E76\u53D1\u9001\u3002"],["The Prompt page and Quick Prompts beside the composer.","Reusable prompts are hard to find and copy repeatedly.","Organize prompts by category and insert one into the current composer. Review it before sending."]],"usage-meter":[["Codex \u4FA7\u680F\u7684\u989D\u5EA6\u73AF\u3002","\u67E5\u770B\u5269\u4F59\u989D\u5EA6\u9700\u8981\u6253\u5F00\u8D26\u53F7\u83DC\u5355\u3002","\u7528\u989D\u5EA6\u73AF\u67E5\u770B\u4F7F\u7528\u6BD4\u4F8B\uFF0C\u70B9\u51FB\u6253\u5F00\u7528\u91CF\u8BE6\u60C5\u3002"],["The usage ring in the Codex sidebar.","Checking remaining usage requires opening the account menu.","Read usage at a glance, then click for usage details."]],"session-status":[["\u5F53\u524D\u4F1A\u8BDD\u7684\u72B6\u6001\u533A\u57DF\u3002","\u4F1A\u8BDD\u7528\u91CF\u4E0E\u751F\u6210\u901F\u5EA6\u4E0D\u5BB9\u6613\u96C6\u4E2D\u67E5\u770B\u3002","\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u7684\u7528\u91CF\u3001\u4E0A\u4E0B\u6587\u548C\u751F\u6210\u6307\u6807\uFF1B\u53EF\u7528\u9879\u76EE\u53D6\u51B3\u4E8E\u4F1A\u8BDD\u4E0E\u63D0\u4F9B\u65B9\u3002"],["The current conversation\u2019s status area.","Usage and generation metrics are spread across the interface.","Read session usage, context and generation metrics when supported by the session and provider."]],"markdown-reading":[["Codex \u7684 Markdown \u6587\u4EF6\u9884\u89C8\u3002","\u957F\u6587\u9605\u8BFB\u3001\u811A\u6CE8\u8DF3\u8F6C\u548C\u8868\u683C\u67E5\u770B\u4E0D\u591F\u65B9\u4FBF\u3002","\u5728\u6587\u4EF6\u9884\u89C8\u4E2D\u9605\u8BFB\u589E\u5F3A\u6392\u7248\uFF0C\u4F7F\u7528\u76EE\u5F55\u3001\u811A\u6CE8\u548C\u8868\u683C\u64CD\u4F5C\u3002"],["Markdown file previews in Codex.","Long documents, footnotes and tables take extra effort to read.","Read enhanced formatting and use the outline, footnote navigation and table actions."]],"mermaid-diagrams":[["Markdown \u6587\u4EF6\u9884\u89C8\u4E2D\u7684 Mermaid \u56FE\u8868\u3002","\u590D\u6742\u56FE\u8868\u7684\u5E03\u5C40\u3001\u5173\u7CFB\u548C\u6570\u636E\u7EC6\u8282\u4E0D\u6613\u9605\u8BFB\u3002","\u9ED8\u8BA4\u589E\u5F3A\u56FE\u8868\u6392\u7248\uFF0C\u652F\u6301\u7F29\u653E\u548C PNG \u4E0B\u8F7D\uFF1B\u5173\u95ED\u540E\u4F7F\u7528 Codex \u539F\u751F\u56FE\u8868\u3002"],["Mermaid diagrams in Markdown file previews.","Complex layouts, relationships and data details can be hard to read.","Enhanced layouts, zoom and PNG download are enabled by default. Turn it off to use native Codex diagrams."]],"file-navigation":[["Codex \u6587\u4EF6\u9884\u89C8\u4E0A\u65B9\u7684\u8DEF\u5F84\u533A\u57DF\u3002","\u6D4F\u89C8\u76F8\u90BB\u76EE\u5F55\u548C\u6587\u4EF6\u9700\u8981\u989D\u5916\u8DF3\u8F6C\u3002","\u70B9\u51FB\u8DEF\u5F84\u5C55\u5F00\u5206\u5217\u76EE\u5F55\uFF0C\u9010\u7EA7\u6D4F\u89C8\u5E76\u6253\u5F00\u53E6\u4E00\u4E2A\u6587\u4EF6\u3002"],["The path above a file preview in Codex.","Browsing nearby files and folders takes extra navigation.","Open the path to browse cascading folder columns and choose another file."]],"files-auto-refresh":[["Codex Side Panel \u7684 Files \u76EE\u5F55\u5217\u8868\u3002","Agent \u6539\u53D8\u9879\u76EE\u6587\u4EF6\u540E\uFF0C\u9700\u8981\u53CD\u590D\u6536\u8D77\u3001\u5C55\u5F00\u624D\u80FD\u770B\u5230\u65B0\u5217\u8868\u3002","\u4FDD\u6301 Files \u6253\u5F00\uFF0C\u81EA\u52A8\u540C\u6B65\u6839\u76EE\u5F55\u548C\u5DF2\u5C55\u5F00\u76EE\u5F55\uFF1B\u4FDD\u7559\u5F53\u524D\u6587\u4EF6\u4E0E\u6D4F\u89C8\u4F4D\u7F6E\u3002"],["The Files tree in the Codex side panel.","File changes can require collapsing and reopening the tree.","Keep Files open to refresh the root and expanded folders while preserving the current file and browsing position."]],images:[["Codex Library \u7684\u56FE\u7247\u96C6\u5408\u4E0E\u56FE\u7247\u67E5\u770B\u5668\u3002","\u67E5\u627E\u56FE\u7247\u53CA\u5176\u63D0\u793A\u8BCD\u9700\u8981\u6765\u56DE\u5207\u6362\u3002","\u6D4F\u89C8\u56FE\u7247\u96C6\u5408\uFF0C\u6253\u5F00\u56FE\u7247\u67E5\u770B\u5927\u56FE\u53CA\u53EF\u8FFD\u6EAF\u7684\u63D0\u793A\u8BCD\u4FE1\u606F\u3002"],["Image collections in Codex Library and the image viewer.","Finding images and their prompts requires switching views.","Browse collections, open an image, and inspect available prompt provenance."]],sites:[["Codex \u4E2D\u7684 Sites \u9875\u9762\u3002","\u672C\u5730\u9879\u76EE\u4E0E\u5E38\u7528\u7F51\u5740\u5206\u6563\u5728\u4E0D\u540C\u4F4D\u7F6E\u3002","\u6536\u85CF\u7F51\u5740\u3001\u53D1\u73B0\u6B63\u5728\u8FD0\u884C\u7684\u672C\u5730\u7AD9\u70B9\uFF0C\u5E76\u4ECE Sites \u6253\u5F00\u3002"],["The Sites page in Codex.","Local projects and saved links are scattered.","Save URLs, discover running local sites, and open them from Sites."]],"composer-expand":[["Work \u4E0E Codex \u7684\u8F93\u5165\u6846\u53F3\u4E0A\u89D2\u3002","\u957F\u6307\u4EE4\u53D7\u8F93\u5165\u6846\u9AD8\u5EA6\u9650\u5236\uFF0C\u7F16\u8F91\u65F6\u9700\u8981\u53CD\u590D\u6EDA\u52A8\u3002","\u8F93\u5165\u591A\u884C\u6587\u5B57\u540E\u70B9\u51FB\u5C55\u5F00\uFF1B\u7F16\u8F91\u5B8C\u6210\u540E\u6536\u8D77\uFF0C\u8349\u7A3F\u4FDD\u6301\u4E0D\u53D8\u3002"],["The upper-right corner of the Work and Codex composer.","Long drafts need repeated scrolling in a compact editor.","Enter a multiline draft and click Expand. Collapse when finished; your draft stays in place."]],"quick-chat":[["Codex \u7684\u6D6E\u52A8 Quick Chat \u7A97\u53E3\u3002","\u4E34\u65F6\u63D0\u95EE\u65F6\u9700\u8981\u5207\u6362\u4E3B\u7A97\u53E3\uFF0C\u5386\u53F2\u4E0D\u6613\u7EE7\u7EED\u3002","\u4ECE\u4FA7\u680F\u6216\u5FEB\u6377\u952E\u6253\u5F00 Quick Chat\uFF0C\u53D1\u9001\u540E\u5C55\u5F00\uFF0C\u6062\u590D\u6700\u5C0F\u5316\u8F93\u5165\u6846\u5E76\u67E5\u770B\u5386\u53F2\u3002"],["The floating Quick Chat window.","Quick questions and continuing recent chats require window switching.","Open Quick Chat from the sidebar or shortcut, expand after sending, restore a minimized composer and browse history."]],"sidebar-focus":[["Codex \u5DE6\u4FA7\u680F\u7684\u5206\u7EC4\u6807\u9898\u3002","\u591A\u4E2A\u4FA7\u680F\u5206\u7EC4\u5C55\u5F00\u65F6\uFF0C\u5F53\u524D\u5206\u7EC4\u4E0D\u5BB9\u6613\u805A\u7126\u3002","\u70B9\u51FB\u5F53\u524D\u5206\u7EC4\uFF0C\u4E00\u952E\u6536\u8D77\u5176\u4ED6\u5206\u7EC4\uFF1B\u518D\u6B21\u70B9\u51FB\u6062\u590D\u5148\u524D\u7684\u5C55\u5F00\u72B6\u6001\u3002"],["Group headings in the Codex sidebar.","Several expanded groups make the current group harder to focus on.","Click a group to collapse other groups. Click again to restore their previous expanded state."]]}});function Z$(e,t){let n=t==="zh-CN",o=(A,K)=>n?A:K,r=new AbortController,i=(A,K,Q,re={})=>A.addEventListener(K,Q,{...re,signal:r.signal}),a=matchMedia("(hover: hover) and (pointer: fine)"),s=matchMedia("(prefers-reduced-motion: reduce)"),l=null,c=null,d=null,m,h,f,v=!1,y=0,k=!1,T=null,R,N=null,Z=!1,X=null,M=()=>R??=window.minecodexPreviewMedia!==void 0?Promise.resolve(window.minecodexPreviewMedia):fetch("/assets/previews/manifest.json").then(A=>A.ok?A.json():{}).then(A=>A&&typeof A=="object"?A:{}).catch(()=>({})),B=(A,K,Q)=>{let re=document.createElement(A);return re.className=K,Q&&(re.textContent=Q),re};async function De(A,K,Q,re){if(!window.minecodexMcpApp)return`/assets/previews/${Q}`;let be=(await window.minecodexMcpApp.readServerResource({uri:`resource://minecodex/previews/${A}/${K}`},{signal:re})).contents?.[0];if(!be?.blob)throw new Error("Preview resource unavailable");return`data:${be.mimeType};base64,${be.blob}`}function ie({restore:A=!1}={}){clearTimeout(m),clearTimeout(h),clearTimeout(f),y++,T?.abort(),T=null;let K=c,Q=l,re=d;c=null,l=null,d=null,v=!1,re&&(re.pause(),re.removeAttribute("src"),re.load());let le=Q?.querySelector(".preview-entry");le?.setAttribute("aria-expanded","false"),le?.removeAttribute("aria-controls"),Q?.classList.remove("is-previewing"),e.classList.remove("has-preview"),K?.remove(),A&&le?.isConnected&&(k=!0,le.focus({preventScroll:!0}),k=!1)}function fe(){if(!l||!c)return;let A=l.getBoundingClientRect(),K=Math.min(360,innerWidth-32);c.style.width=`${K}px`,c.style.maxHeight=`${Math.max(120,innerHeight-32)}px`;let Q=c.getBoundingClientRect().height,re,le;if(innerWidth-A.right>=K+24)re=A.right+8;else if(A.left>=K+24)re=A.left-K-8;else{re=Math.max(16,Math.min(A.left,innerWidth-K-16));let be=innerHeight-A.bottom-24,Oe=A.top-24;be>=Math.min(Q,180)?(c.style.maxHeight=`${be}px`,le=A.bottom+8):Oe>=Math.min(Q,180)?(c.style.maxHeight=`${Oe}px`,le=Math.max(16,A.top-Q-8)):(le=Math.max(16,A.top+l.querySelector(".plugin-topline").getBoundingClientRect().height+32),c.style.maxHeight=`${Math.max(100,innerHeight-le-16)}px`)}le??=Math.max(16,Math.min(A.top,innerHeight-Q-16)),Object.assign(c.style,{left:`${re}px`,top:`${le}px`,visibility:"visible"})}function et(){!v&&!N&&!Z&&(h=setTimeout(()=>ie(),100))}async function Nt(A,K,Q,re){let le=(await M())?.[A];if(re!==y||!c||!le)return;T=new AbortController;let be=T.signal,Oe,at,He=!1;Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u9884\u89C8\u2026","Loading preview\u2026");let pt=await Promise.all(["poster","video"].map(async jt=>{if(!le[jt])return null;try{return await De(A,jt,le[jt],be)}catch{return He=!0,null}}));if(re!==y)return;[Oe,at]=pt,Q.textContent=He?o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon");let ue=null;if(Oe&&(ue=B("img","preview-poster"),ue.alt=o("\u529F\u80FD\u9759\u6001\u9884\u89C8","Static feature preview"),ue.addEventListener("load",fe,{once:!0}),ue.addEventListener("error",()=>{ue.remove(),He=!0,d||(Q.textContent=o("\u8D44\u6E90\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Preview unavailable \xB7 See description")),fe()},{once:!0}),ue.src=Oe,K.append(ue),Q.textContent=o("\u9759\u6001\u9884\u89C8","Static preview")),!at){fe();return}if(s.matches){fe();return}let ne=B("video","preview-video");d=ne,ne.muted=!0,ne.playsInline=!0,ne.preload="metadata",ne.hidden=!0;let zt=()=>{c.classList.remove("is-media-only"),ue&&(ue.hidden=!1)},zr=()=>{re===y&&(clearTimeout(f),ne.pause(),ne.removeAttribute("src"),ne.load(),ne.remove(),d=null,zt(),Q.textContent=ue?.isConnected?o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u9759\u6001\u9884\u89C8","Video unavailable \xB7 Static preview"):o("\u89C6\u9891\u6682\u4E0D\u53EF\u7528 \xB7 \u8BF7\u53C2\u8003\u8BF4\u660E","Video unavailable \xB7 See description"),fe())};ne.addEventListener("error",zr,{once:!0}),ne.addEventListener("loadeddata",()=>{re===y&&fe()}),ne.addEventListener("play",()=>{re===y&&(ne.hidden=!1,ue&&(ue.hidden=!0),c.classList.add("is-media-only"),fe())});let Wt=async()=>{if(re===y)try{await ne.play()}catch{re===y&&d===ne&&ne.isConnected&&(ne.hidden=!0,zt(),Q.textContent=ue?.isConnected?o("\u9759\u6001\u9884\u89C8","Static preview"):o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"),fe())}};ne.addEventListener("ended",()=>{clearTimeout(f),f=setTimeout(()=>{re!==y||d!==ne||(ne.currentTime=0,Wt())},2e3)}),K.append(ne),Q.textContent=o("\u6B63\u5728\u52A0\u8F7D\u6F14\u793A\u2026","Loading demo\u2026"),ne.src=at,Wt(),fe()}function mt(A,K=!1){if(clearTimeout(m),clearTimeout(h),A===l){v||=K;return}ie(),Z=!1,l=A,v=K,c=B("section","feature-preview"),c.id="feature-preview",c.setAttribute("role","region");let Q=B("h3","preview-title",A.querySelector(".plugin-name").textContent);Q.id="feature-preview-title",c.setAttribute("aria-labelledby",Q.id);let re=B("button","button quiet preview-close",o("\u5173\u95ED","Close"));re.type="button",re.addEventListener("click",()=>ie({restore:v||c.contains(document.activeElement)}));let le=B("div","preview-heading");le.append(Q,re),c.append(le);let be=B("div","preview-media");c.append(be);let Oe=B("dl","preview-details"),at=[o("\u51FA\u73B0\u4F4D\u7F6E","Location"),o("\u89E3\u51B3\u95EE\u9898","Problem"),o("\u64CD\u4F5C\u4E0E\u6548\u679C","Action and result")];q$(A.dataset.featureId,t).forEach((ue,ne)=>{Oe.append(B("dt","",at[ne]),B("dd","",ue))});let He=B("p","preview-resource-state",o("\u6F14\u793A\u89C6\u9891\u51C6\u5907\u4E2D","Demo video coming soon"));c.append(Oe,He),c.addEventListener("pointerenter",()=>{Z=!0,clearTimeout(h)}),c.addEventListener("pointerleave",()=>{Z=!1,et()}),c.addEventListener("focusin",()=>{clearTimeout(h)}),c.addEventListener("focusout",ue=>{!c?.contains(ue.relatedTarget)&&!l?.contains(ue.relatedTarget)&&ie()}),document.querySelector(".dashboard-surface").append(c),A.classList.add("is-previewing"),e.classList.add("has-preview");let pt=A.querySelector(".preview-entry");pt.setAttribute("aria-expanded","true"),pt.setAttribute("aria-controls",c.id),fe(),Nt(A.dataset.featureId,be,He,y)}function Gt(A){let K=B("button","preview-entry");K.type="button",K.setAttribute("aria-expanded","false"),K.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${A.querySelector(".plugin-name").textContent||A.dataset.featureId}`),A.append(K),i(A,"pointerenter",()=>{a.matches&&(N=A,X=A,clearTimeout(m),clearTimeout(h),m=setTimeout(()=>{X=null,mt(A)},200))}),i(A,"pointerleave",()=>{N===A&&(N=null),X===A&&(clearTimeout(m),X=null),et()}),i(K,"focus",()=>{k||mt(A)}),i(K,"click",()=>mt(A,!0)),i(A,"focusout",Q=>{!A.contains(Q.relatedTarget)&&!c?.contains(Q.relatedTarget)&&document.documentElement.dataset.input==="keyboard"&&ie()})}i(document,"keydown",A=>{if(A.key==="Escape"&&l){A.preventDefault();let K=v||c.contains(document.activeElement);ie({restore:K})}}),i(document,"pointerdown",A=>{l&&!l.contains(A.target)&&!c.contains(A.target)&&ie()}),i(window,"scroll",A=>{c?.contains(A.target)||ie()},{capture:!0}),i(window,"resize",()=>ie()),i(document,"visibilitychange",()=>{document.hidden&&ie()}),i(window,"blur",()=>ie()),i(document.querySelector("#data-dialog"),"toggle",()=>ie()),i(document.querySelector("#language-menu"),"toggle",()=>ie()),i(window,"pagehide",()=>{ie(),r.abort()});function $t(A){ie(),t=A,n=t==="zh-CN";for(let K of e.querySelectorAll(".plugin-card"))K.querySelector(".preview-entry")?.setAttribute("aria-label",`${o("\u67E5\u770B\u6548\u679C","See how it works")} \xB7 ${K.querySelector(".plugin-name").textContent}`)}return{attach:Gt,close:ie,setLocale:$t}}var F$=Nr(()=>{V$()});function H$(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 J$=Nr(()=>{});async function gn(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 jv=Nr(()=>{});var kT={};function W$(){document.querySelector("#brand-slogan").textContent=$e==="zh-CN"?"\u8BA9 Codex \u66F4\u987A\u624B\u3002":"Make Codex work better for you.",document.querySelector("#brand-description").textContent=$e==="zh-CN"?"\u6309\u9700\u5F00\u542F\u4EA4\u4E92\u589E\u5F3A\uFF0C\u8BA9\u65E5\u5E38\u4F7F\u7528\u66F4\u9AD8\u6548\u3002":"Enable the enhancements you need for a smoother daily workflow.";let e=document.querySelector("#language-button"),t=$e==="zh-CN"?"\u8BED\u8A00 \xB7 \u4E2D\u6587":"Language \xB7 English";e.setAttribute("aria-label",t),e.setAttribute("data-minecodex-tooltip",t),q.languageToggle.setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language"),document.querySelector("#language-menu").setAttribute("aria-label",$e==="zh-CN"?"\u8BED\u8A00":"Language");for(let n of q.languageButtons)n.setAttribute("aria-pressed",String(n.dataset.languageChoice===$e));q.restartTitle.textContent=oe.restartTitle,q.restartCopy.textContent=oe.restartCopy,q.restartButton.querySelector(".button-label").textContent=oe.restart,q.pluginsHeading.textContent=oe.plugins,q.errorTitle.textContent=oe.loadError,q.errorCopy.textContent=oe.loadErrorCopy,q.retryButton.textContent=oe.retry,q.versionLabel.textContent=oe.version,q.diagnosticsButton.textContent=oe.copyDiagnostics,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}function bT(e){let t=e.state??(e.failure?"failed":e.healthy?"healthy":e.injected?"injected":e.applied?"launching":e.enabled?"restart-required":"stopped"),n=oe.states[t]??oe.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}: ${oe.failureDetail}`:n,className:o}}function Xe(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function yT(e){let t=Xe("article","plugin-card");t.dataset.featureId=e.id;let n=Xe("div","plugin-icon");n.setAttribute("aria-hidden","true");let o=Xe("img");o.alt="",o.width=24,o.height=24,n.append(o);let r=Xe("div","plugin-copy"),i=Xe("div","plugin-title-line"),a=Xe("h3","plugin-name");i.append(a);let s=Xe("p","plugin-description");r.append(i,s);let l=Xe("div","plugin-topline"),c=Xe("label","switch"),d=Xe("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 m=Xe("span","switch-track");m.setAttribute("aria-hidden","true"),c.append(d,m);let h=Xe("span","plugin-state"),f=Xe("span","status-dot");f.setAttribute("aria-hidden","true");let v=Xe("span","plugin-state-label");return v.id=`state-${e.id}`,h.append(f,v),l.append(n,c),t.append(l,r,h),Vi.attach(t),t}function Ud(e,t){for(let d of q.languageButtons)d.disabled=yt.size>0;let n=bT(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=yt.has(t.id),o.setAttribute("aria-label",t.label),s.className=`status-dot ${n.className}`,l.textContent=n.label,e.querySelector(".preview-entry")?.setAttribute("aria-label",`${$e==="zh-CN"?"\u67E5\u770B\u6548\u679C":"See how it works"} \xB7 ${t.label}`)}function Y$(e){return[...q.pluginList.querySelectorAll("[data-feature-id]")].find(t=>t.dataset.featureId===e)??null}function _T(e){e=e.filter(n=>!["unread-inbox","hide-upsell-banner"].includes(n.id));for(let n of[...q.pluginList.children])n.dataset.featureId||n.remove();let t=new Set(e.map(({id:n})=>n));for(let[n,o]of e.entries()){let r=Y$(o.id);r||(r=yT(o));let i=q.pluginList.children[n];i!==r&&q.pluginList.insertBefore(r,i??null),Ud(r,o)}for(let n of[...q.pluginList.querySelectorAll("[data-feature-id]")])n.dataset.featureId&&!t.has(n.dataset.featureId)&&(n.classList.contains("is-previewing")&&Vi.close(),n.remove());q.pluginList.setAttribute("aria-busy","false")}function X$(){q.versionValue.textContent=Qe?.version??"\u2014",q.restartNotice.hidden=!Qe?.pendingRestart}function $T(){X$(),_T(Qe?.features??[])}function zT(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 K$(e){if(!e?.input)return;Y$(e.featureId)?.querySelector('input[type="checkbox"]')?.focus()}function Dd(e){clearTimeout(B$),q.toast.textContent=e,q.toast.hidden=!1,B$=setTimeout(()=>{q.toast.hidden=!0},4200)}function Av(e,t){Qe.features=Qe.features.map(n=>n.id===e?{...n,...t}:n)}async function Tc(){q.loadError.hidden=!0;try{let e=await gn("/api/status",{headers:{"Accept-Language":$e}});if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();yt.size&&Qe&&(t.features=t.features.map(n=>yt.has(n.id)?Qe.features.find(o=>o.id===n.id)??n:n)),Qe=t,q.pluginList.hidden=!1,$T()}catch{Vi.close(),q.pluginList.hidden=!0,q.loadError.hidden=!1}}function Fi(){let e=window.minecodexHostTheme?window.minecodexHostTheme==="dark":Q$.matches,t=Zi==="dark"||Zi!=="light"&&e;document.documentElement.dataset.theme=t?"dark":"light",q.themeToggle.setAttribute("aria-label",$e==="zh-CN"?"\u5916\u89C2":"Appearance");for(let n of q.themeButtons){n.dataset.themeChoice=t?"dark":"light",n.querySelector(".ui-icon").className=`ui-icon ${t?"moon":"sun"}-icon`;let o=t?oe.darkAppearance:oe.lightAppearance,r=t?oe.lightAppearance:oe.darkAppearance,i=$e==="zh-CN"?`${o} \xB7 \u5207\u6362\u4E3A${r}`:`${o} \xB7 Switch to ${r.toLowerCase()}`;n.setAttribute("aria-label",i),n.setAttribute("data-minecodex-tooltip",i)}}async function wT(e){if(Uv)return;if(Vi.close(),Zi=document.documentElement.dataset.theme==="dark"?"light":"dark",!window.minecodexMcpApp)try{localStorage.setItem("minecodex-appearance",Zi)}catch{}if(!document.startViewTransition||matchMedia("(prefers-reduced-motion: reduce)").matches){Fi();return}let t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,r=Math.hypot(Math.max(n,innerWidth-n),Math.max(o,innerHeight-o)),i=document.startViewTransition(Fi);Uv=i;try{await i.ready,document.documentElement.animate({clipPath:[`circle(0px at ${n}px ${o}px)`,`circle(${r}px at ${n}px ${o}px)`]},{duration:420,easing:"cubic-bezier(0.23, 1, 0.32, 1)",pseudoElement:"::view-transition-new(root)"}),await i.finished}catch{i.skipTransition()}finally{Uv=null}}var Mv,$e,G$,oe,q,Qe,B$,yt,Vi,Q$,Zi,Uv,Dv,ez=Nr(()=>{F$();J$();jv();try{Mv=localStorage.getItem("minecodex-language")}catch{}$e=["en","zh-CN"].includes(Mv)?Mv:navigator.language.toLowerCase().startsWith("zh")?"zh-CN":"en";document.documentElement.lang=$e;G$={en:{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":{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"}},oe=G$[$e],q={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")},Qe=null,B$=null,yt=new Set,Vi=Z$(q.pluginList,$e);q.pluginList.addEventListener("change",async e=>{let t=e.target.closest('input[type="checkbox"]'),n=t?.closest("[data-feature-id]");if(!t||!n||!Qe)return;let o=n.dataset.featureId,r={...Qe.features.find(a=>a.id===o)},i=zT(o);yt.add(o),Av(o,{enabled:t.checked,state:"saved"}),Ud(n,Qe.features.find(a=>a.id===o)),q.saveState.textContent=oe.saving;try{let a=await gn(`/api/features/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json","Accept-Language":$e},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&&Av(o,l),Qe.pendingRestart=s.pendingRestart,yt.delete(o);let c=l??Qe.features.find(d=>d.id===o);c&&Ud(n,c),X$(),K$(i),q.saveState.textContent=yt.size?oe.saving:oe.saved}catch{yt.delete(o),Av(o,r),Ud(n,r),q.saveState.textContent=yt.size?oe.saving:"",K$(i),Dd(oe.changeFailed)}});q.restartButton.addEventListener("click",async()=>{q.restartButton.disabled=!0,q.restartButton.querySelector(".button-label").textContent=oe.restarting;try{let e=await gn("/api/restart",{method:"POST",headers:{"Content-Type":"application/json","Accept-Language":$e},body:"{}"});if(!e.ok)throw new Error(`HTTP ${e.status}`);await Tc()}catch{Dd(oe.restartFailed)}finally{q.restartButton.disabled=!1,q.restartButton.querySelector(".button-label").textContent=oe.restart}});q.retryButton.addEventListener("click",()=>{q.pluginList.hidden=!1,Tc()});q.diagnosticsButton.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(JSON.stringify(H$(Qe),null,2)),Dd(oe.diagnosticsCopied)}catch{Dd(oe.diagnosticsFailed)}});setInterval(()=>{!document.hidden&&!yt.size&&Tc()},5e3);q.updateButton.addEventListener("click",async()=>{q.updateButton.disabled=!0,q.updateButton.querySelector(".button-label").textContent=oe.checkingUpdates,q.updateResult.hidden=!0;try{let e=await gn("/api/update");if(!e.ok)throw new Error(`HTTP ${e.status}`);let t=await e.json();q.updateResult.textContent=t.available?oe.updateAvailable(t.latest):oe.current,q.updateResult.hidden=!1}catch{q.updateResult.textContent=oe.updateFailed,q.updateResult.hidden=!1}finally{q.updateButton.disabled=!1,q.updateButton.querySelector(".button-label").textContent=oe.checkUpdates}});Q$=matchMedia("(prefers-color-scheme: dark)"),Zi=null;if(!window.minecodexMcpApp)try{Zi=localStorage.getItem("minecodex-appearance")}catch{}Uv=null;q.themeToggle.addEventListener("click",e=>{let t=e.target.closest("[data-theme-choice]");t&&wT(t)});q.languageToggle.addEventListener("click",e=>{let t=e.target.closest("[data-language-choice]");if(!t||yt.size||q.restartButton.disabled)return;let n=t.dataset.languageChoice;if(n!==$e){try{localStorage.setItem("minecodex-language",n)}catch{return}if(Vi.close(),!window.minecodexMcpApp){location.reload();return}$e=n,oe=G$[$e],document.documentElement.lang=$e,Vi.setLocale($e),document.querySelector("#language-menu").hidePopover(),W$(),Fi(),q.updateResult.hidden=!0,q.toast.hidden=!0,window.dispatchEvent(new Event("minecodex-language")),Tc()}});Q$.addEventListener("change",Fi);window.addEventListener("minecodex-host-theme",()=>{Zi=null,Fi()});document.addEventListener("keydown",()=>{document.documentElement.dataset.input="keyboard"});document.addEventListener("pointerdown",()=>{document.documentElement.dataset.input="pointer"});W$();Fi();Tc();Dv=document.querySelector("#language-menu");Dv.addEventListener("toggle",e=>{if(document.querySelector("#language-button").setAttribute("aria-expanded",String(e.newState==="open")),e.newState!=="open")return;let t=document.querySelector("#language-button").getBoundingClientRect();Dv.style.left=`${Math.max(8,Math.min(t.right-140,innerWidth-148))}px`,Dv.style.top=`${t.bottom+8}px`})});function tz(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);
|
|
@@ -104,7 +104,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
104
104
|
- omitted: host decides border`)}),hj=p.object({method:p.literal("ui/request-display-mode"),params:p.object({mode:Pc.describe("The display mode being requested.")})}),dT=p.object({mode:Pc.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),mT=p.union([p.literal("model"),p.literal("app")]).describe("Tool visibility scope - who can access the tool."),gj=p.object({resourceUri:p.string().optional(),visibility:p.array(mT).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
105
105
|
- "model": Tool visible to and callable by the agent
|
|
106
106
|
- "app": Tool callable by the app from this server only`),csp:p.never().optional(),permissions:p.never().optional()}),vj=p.object({mimeTypes:p.array(p.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Sj=p.object({method:p.literal("ui/download-file"),params:p.object({contents:p.array(p.union([un,dn])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),bj=p.object({method:p.literal("ui/message"),params:p.object({role:p.literal("user").describe('Message role, currently only "user" is supported.'),content:p.array(Ct).describe("Message content blocks (text, image, etc.).")})}),yj=p.object({method:p.literal("ui/notifications/sandbox-resource-ready"),params:p.object({html:p.string().describe("HTML content to load into the inner iframe."),sandbox:p.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ov.optional().describe("CSP configuration from resource metadata."),permissions:Nv.optional().describe("Sandbox permissions from resource metadata.")})}),pT=p.object({method:p.literal("ui/notifications/tool-result"),params:yr.describe("Standard MCP tool execution result.")}),L$=p.object({toolInfo:p.object({id:bt.optional().describe("JSON-RPC id of the tools/call request."),tool:br.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:WP.optional().describe("Current color theme preference."),styles:aT.optional().describe("Style configuration for theming the app."),displayMode:Pc.optional().describe("How the UI is currently displayed."),availableDisplayModes:p.array(Pc).optional().describe("Display modes the host supports."),containerDimensions:p.union([p.object({height:p.number().describe("Fixed container height in pixels.")}),p.object({maxHeight:p.union([p.number(),p.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(p.union([p.object({width:p.number().describe("Fixed container width in pixels.")}),p.object({maxWidth:p.union([p.number(),p.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
107
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:p.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:p.string().optional().describe("User's timezone in IANA format."),userAgent:p.string().optional().describe("Host application identifier."),platform:p.union([p.literal("web"),p.literal("desktop"),p.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p.object({touch:p.boolean().optional().describe("Whether the device supports touch input."),hover:p.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p.object({top:p.number().describe("Top safe area inset in pixels."),right:p.number().describe("Right safe area inset in pixels."),bottom:p.number().describe("Bottom safe area inset in pixels."),left:p.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fT=p.object({method:p.literal("ui/notifications/host-context-changed"),params:L$.describe("Partial context update containing only changed fields.")}),_j=p.object({method:p.literal("ui/update-model-context"),params:p.object({content:p.array(Ct).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:p.record(p.string(),p.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),$j=p.object({method:p.literal("ui/initialize"),params:p.object({appInfo:Tt.describe("App identification (name and version)."),appCapabilities:uT.describe("Features and capabilities this app provides."),protocolVersion:p.string().describe("Protocol version this app supports.")})}),hT=p.object({protocolVersion:p.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Tt.describe("Host application identification and version."),hostCapabilities:lT.describe("Features and capabilities provided by the host."),hostContext:L$.describe("Rich context about the host environment.")}).passthrough(),gT={target:"draft-2020-12"};async function D$(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](gT);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function M$(e,t,n=""){let o=await e["~standard"].validate(t);if(o.issues){let r=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(n+r)}return o.value}function vT(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Ad=class e extends Pv{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Tv;_methods=new Ev;setRequestHandler=(...t)=>{let[n,...o]=A$("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=A$("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...o)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:rT,toolinputpartial:nT,toolresult:pT,toolcancelled:iT,hostcontextchanged:fT};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},o=>{let r=o;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,o){n&&o&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},o={autoResize:!0}){super(o),this._appInfo=t,this._appCapabilities=n,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval&&p.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=vT(this._appCapabilities,t)}registerTool(t,n,o){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(l){Object.assign(this,l),i()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],i())},handler:async(l,c)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let d;if(a){let m=s.inputSchema,h=m?await M$(m,l??{},`Invalid input for tool ${t}: `):l??{};d=await o(h,c)}else d=await o(c);return s.outputSchema&&!d.isError&&(d.structuredContent=await M$(s.outputSchema,d.structuredContent,`Invalid output for tool ${t}: `)),d}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let o=this._registeredTools[t.name];if(!o)throw Error(`Tool ${t.name} not found`);return o.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let i={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await D$(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await D$(r.outputSchema,"output")),r.annotations&&(i.annotations=r.annotations),r._meta&&(i._meta=r._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:sT.shape.params,result:cT},(n,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,o)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},tT,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Sr,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},QP,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},eT,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},dT,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,o=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let l=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let c=Math.ceil(window.innerWidth);(c!==n||l!==o)&&(n=c,o=l,this.sendSizeChanged({width:c,height:l}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Cv(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:KP}},hT,n);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var Oc=new Ad({name:"MineCodex",version:"2.0.52"});Oc.ontoolresult=()=>{};await Oc.connect();window.minecodexMcpApp=Oc;function cz(e){Object.hasOwn(e??{},"theme")&&(window.minecodexHostTheme=e?.theme,window.dispatchEvent(new Event("minecodex-host-theme")))}Oc.addEventListener("hostcontextchanged",cz);cz(Oc.getHostContext());await Promise.resolve().then(()=>(ez(),kT));await Promise.resolve().then(()=>(sz(),TT));
|
|
107
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:p.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:p.string().optional().describe("User's timezone in IANA format."),userAgent:p.string().optional().describe("Host application identifier."),platform:p.union([p.literal("web"),p.literal("desktop"),p.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p.object({touch:p.boolean().optional().describe("Whether the device supports touch input."),hover:p.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p.object({top:p.number().describe("Top safe area inset in pixels."),right:p.number().describe("Right safe area inset in pixels."),bottom:p.number().describe("Bottom safe area inset in pixels."),left:p.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fT=p.object({method:p.literal("ui/notifications/host-context-changed"),params:L$.describe("Partial context update containing only changed fields.")}),_j=p.object({method:p.literal("ui/update-model-context"),params:p.object({content:p.array(Ct).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:p.record(p.string(),p.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),$j=p.object({method:p.literal("ui/initialize"),params:p.object({appInfo:Tt.describe("App identification (name and version)."),appCapabilities:uT.describe("Features and capabilities this app provides."),protocolVersion:p.string().describe("Protocol version this app supports.")})}),hT=p.object({protocolVersion:p.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Tt.describe("Host application identification and version."),hostCapabilities:lT.describe("Features and capabilities provided by the host."),hostContext:L$.describe("Rich context about the host environment.")}).passthrough(),gT={target:"draft-2020-12"};async function D$(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](gT);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function M$(e,t,n=""){let o=await e["~standard"].validate(t);if(o.issues){let r=o.issues.map(i=>{let a=i.path?.map(s=>typeof s=="object"?s.key:s).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(n+r)}return o.value}function vT(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Ad=class e extends Pv{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Tv;_methods=new Ev;setRequestHandler=(...t)=>{let[n,...o]=A$("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...o)};setNotificationHandler=(...t)=>{let[n,...o]=A$("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...o)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:rT,toolinputpartial:nT,toolresult:pT,toolcancelled:iT,hostcontextchanged:fT};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},o=>{let r=o;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,o){n&&o&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},o={autoResize:!0}){super(o),this._appInfo=t,this._appCapabilities=n,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval&&p.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=vT(this._appCapabilities,t)}registerTool(t,n,o){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(l){Object.assign(this,l),i()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],i())},handler:async(l,c)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let d;if(a){let m=s.inputSchema,h=m?await M$(m,l??{},`Invalid input for tool ${t}: `):l??{};d=await o(h,c)}else d=await o(c);return s.outputSchema&&!d.isError&&(d.structuredContent=await M$(s.outputSchema,d.structuredContent,`Invalid output for tool ${t}: `)),d}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let o=this._registeredTools[t.name];if(!o)throw Error(`Tool ${t.name} not found`);return o.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let i={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await D$(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(i.outputSchema=await D$(r.outputSchema,"output")),r.annotations&&(i.annotations=r.annotations),r._meta&&(i._meta=r._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:sT.shape.params,result:cT},(n,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,o)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},tT,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Sr,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},QP,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},eT,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},dT,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,o=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let a=document.documentElement,s=a.style.height;a.style.height="max-content";let l=Math.ceil(a.getBoundingClientRect().height);a.style.height=s;let c=Math.ceil(window.innerWidth);(c!==n||l!==o)&&(n=c,o=l,this.sendSizeChanged({width:c,height:l}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Cv(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:KP}},hT,n);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}};var Oc=new Ad({name:"MineCodex",version:"2.0.54"});Oc.ontoolresult=()=>{};await Oc.connect();window.minecodexMcpApp=Oc;function cz(e){Object.hasOwn(e??{},"theme")&&(window.minecodexHostTheme=e?.theme,window.dispatchEvent(new Event("minecodex-host-theme")))}Oc.addEventListener("hostcontextchanged",cz);cz(Oc.getHostContext());await Promise.resolve().then(()=>(ez(),kT));await Promise.resolve().then(()=>(sz(),TT));
|
|
108
108
|
/*! Bundled license information:
|
|
109
109
|
|
|
110
110
|
@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
|
|
@@ -426,7 +426,7 @@ ${U.body}`.toLocaleLowerCase().includes(y)));if(!k.length){g.append(jn(!!y));ret
|
|
|
426
426
|
font-family:var(--mcx-font-sans-default);font-size:var(--mcx-text-sm);line-height:18px;
|
|
427
427
|
font-weight:var(--mcx-tooltip-compact-font-weight);letter-spacing:var(--mcx-tracking-tooltip);user-select:none; }
|
|
428
428
|
`,document.head.append(o);function r(m){return m.setAttribute("data-mcx-ui-tooltip",""),m}r(i),i.style.cssText=`zoom:var(--codex-window-zoom,1);max-width:min(320px,calc(100vw - 16px));
|
|
429
|
-
text-align:center;overflow-wrap:anywhere;`;let n=null,a,s,c=-1/0;function l(){if(clearTimeout(a),cancelAnimationFrame(s),n){let m=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(A=>A&&A!==i.id);m.length?n.setAttribute("aria-describedby",m.join(" ")):n.removeAttribute("aria-describedby")}i.hidden||(c=Date.now()),n=null,i.hidden=!0}function d(){if(!n?.isConnected||!n.getClientRects().length||n.getAttribute("aria-expanded")==="true")return l();let m=Number.parseFloat(getComputedStyle(i).zoom)||1,A=n.getBoundingClientRect(),x=i.offsetWidth,C=i.offsetHeight,M=n.getAttribute("data-minecodex-tooltip-side")||(n.closest("[data-app-navigation-rail]")?"right":getComputedStyle(n).getPropertyValue("--side-tooltip").trim()||"top"),T=2/m,Q=(A.left+A.width/2)/m-x/2,re=M==="bottom"?A.bottom/m+T:A.top/m-C-T;M==="right"||M==="left"?(Q=M==="right"?A.right/m+T:A.left/m-x-T,re=(A.top+A.height/2)/m-C/2,Q+x>innerWidth/m-8?Q=A.left/m-x-T:Q<8&&(Q=A.right/m+T)):re<8?re=A.bottom/m+T:re+C>innerHeight/m-8&&(re=A.top/m-C-T),i.style.left=`${Math.max(8,Math.min(Q,innerWidth/m-x-8))}px`,i.style.top=`${Math.max(8,Math.min(re,innerHeight/m-C-8))}px`,s=requestAnimationFrame(d)}function f(m,A=!1){!m||m===n||(l(),!(m.getAttribute("aria-expanded")==="true"||!m.getAttribute(t))&&(n=m,a=setTimeout(()=>{if(!n?.isConnected)return l();i.isConnected||document.body.append(i);let x=getComputedStyle(n);for(let M of["--radius-2xl","--codex-corner-shape","--color-background-tooltip","--color-text-tooltip","--color-border-tooltip","--shadow-tooltip","--tooltip-compact-font-weight","--tracking-tooltip","--spacing","--text-sm","--font-sans-default"]){let T=x.getPropertyValue(M).trim();T?i.style.setProperty(M,T):i.style.removeProperty(M)}i.textContent=n.getAttribute(t),i.hidden=!1;let C=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean);n.setAttribute("aria-describedby",[...new Set([...C,i.id])].join(" ")),d()},A||Date.now()-c<300?0:200)))}let h=m=>m.target instanceof Element?m.target.closest(`[${t}]`):null;return document.addEventListener("pointerover",m=>f(h(m)),{signal:e}),document.addEventListener("pointerout",m=>{n&&!n.contains(m.relatedTarget)&&l()},{signal:e}),document.addEventListener("focusin",m=>f(h(m),!0),{signal:e}),document.addEventListener("focusout",l,{signal:e}),document.addEventListener("pointerdown",l,{signal:e,capture:!0}),document.addEventListener("keydown",m=>{m.key==="Escape"&&l()},{signal:e}),window.addEventListener("blur",l,{signal:e}),e.addEventListener("abort",()=>{l(),i.remove(),o.remove()},{once:!0}),{tooltipSurface:r}}var Mo=new vd({name:"Prompt",version:"2.0.
|
|
429
|
+
text-align:center;overflow-wrap:anywhere;`;let n=null,a,s,c=-1/0;function l(){if(clearTimeout(a),cancelAnimationFrame(s),n){let m=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(A=>A&&A!==i.id);m.length?n.setAttribute("aria-describedby",m.join(" ")):n.removeAttribute("aria-describedby")}i.hidden||(c=Date.now()),n=null,i.hidden=!0}function d(){if(!n?.isConnected||!n.getClientRects().length||n.getAttribute("aria-expanded")==="true")return l();let m=Number.parseFloat(getComputedStyle(i).zoom)||1,A=n.getBoundingClientRect(),x=i.offsetWidth,C=i.offsetHeight,M=n.getAttribute("data-minecodex-tooltip-side")||(n.closest("[data-app-navigation-rail]")?"right":getComputedStyle(n).getPropertyValue("--side-tooltip").trim()||"top"),T=2/m,Q=(A.left+A.width/2)/m-x/2,re=M==="bottom"?A.bottom/m+T:A.top/m-C-T;M==="right"||M==="left"?(Q=M==="right"?A.right/m+T:A.left/m-x-T,re=(A.top+A.height/2)/m-C/2,Q+x>innerWidth/m-8?Q=A.left/m-x-T:Q<8&&(Q=A.right/m+T)):re<8?re=A.bottom/m+T:re+C>innerHeight/m-8&&(re=A.top/m-C-T),i.style.left=`${Math.max(8,Math.min(Q,innerWidth/m-x-8))}px`,i.style.top=`${Math.max(8,Math.min(re,innerHeight/m-C-8))}px`,s=requestAnimationFrame(d)}function f(m,A=!1){!m||m===n||(l(),!(m.getAttribute("aria-expanded")==="true"||!m.getAttribute(t))&&(n=m,a=setTimeout(()=>{if(!n?.isConnected)return l();i.isConnected||document.body.append(i);let x=getComputedStyle(n);for(let M of["--radius-2xl","--codex-corner-shape","--color-background-tooltip","--color-text-tooltip","--color-border-tooltip","--shadow-tooltip","--tooltip-compact-font-weight","--tracking-tooltip","--spacing","--text-sm","--font-sans-default"]){let T=x.getPropertyValue(M).trim();T?i.style.setProperty(M,T):i.style.removeProperty(M)}i.textContent=n.getAttribute(t),i.hidden=!1;let C=(n.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean);n.setAttribute("aria-describedby",[...new Set([...C,i.id])].join(" ")),d()},A||Date.now()-c<300?0:200)))}let h=m=>m.target instanceof Element?m.target.closest(`[${t}]`):null;return document.addEventListener("pointerover",m=>f(h(m)),{signal:e}),document.addEventListener("pointerout",m=>{n&&!n.contains(m.relatedTarget)&&l()},{signal:e}),document.addEventListener("focusin",m=>f(h(m),!0),{signal:e}),document.addEventListener("focusout",l,{signal:e}),document.addEventListener("pointerdown",l,{signal:e,capture:!0}),document.addEventListener("keydown",m=>{m.key==="Escape"&&l()},{signal:e}),window.addEventListener("blur",l,{signal:e}),e.addEventListener("abort",()=>{l(),i.remove(),o.remove()},{once:!0}),{tooltipSurface:r}}var Mo=new vd({name:"Prompt",version:"2.0.54"});Mo.ontoolresult=()=>{};await Mo.connect();uv(Mo.getHostContext());Mo.addEventListener("hostcontextchanged",uv);var bx=new AbortController,Ad=bx.signal,bi={};for(let e of[hx,gx,vx,Ax,yx])Object.assign(bi,e(Ad,bi));bi.page=e=>(bi.surface(e,"page"),bi.layer(e,"page"));bi.releasePage=()=>{};var j_=dx(Ad,{management:!0,ui:bi,resources:{icons:mx,previews:px,styles:fx},insertPrompt:e=>new Promise((t,i)=>{let o=new MessageChannel,r,n=s=>{clearTimeout(r),o.port1.close(),Ad.removeEventListener("abort",a),s?i(s):t()},a=()=>n(new Error("Prompt page closed"));Ad.addEventListener("abort",a,{once:!0}),r=setTimeout(()=>n(new Error("No available input in the focused window")),4500),o.port1.onmessage=({data:s})=>n(s.ok?null:new Error(s.error)),window.top.postMessage({type:"minecodex:insert-prompt",promptId:e,expiresAt:Date.now()+4e3},"*",[o.port2])}),requestHostAction:async(e,t)=>{let i=await Mo.callServerTool({name:t.method&&t.method!=="GET"?"minecodex_prompts_write":"minecodex_prompts_read",arguments:t});if(i.isError)throw new Error(i.content?.find(o=>o.type==="text")?.text??"Prompts request failed");return i.structuredContent.result}});Mo.onteardown=async()=>(bx.abort(),j_(),{});
|
|
430
430
|
/*! Bundled license information:
|
|
431
431
|
|
|
432
432
|
@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
|