minecodex 2.0.39 → 2.0.40
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 -0
- package/apps/dashboard/assets/preview-content.js +3 -0
- package/features/markdown-reading/codex-feature.json +1 -6
- package/features/markdown-reading/src/adapters/codex/lists.mjs +0 -26
- package/features/markdown-reading/src/adapters/codex/reading-runtime.mjs +5 -13
- package/features/markdown-reading/src/adapters/codex/rich-text.mjs +1 -1
- package/features/markdown-reading/src/adapters/codex/table-actions.mjs +1 -122
- package/features/markdown-reading/src/adapters/codex/toc.mjs +1 -1
- package/features/markdown-reading/src/injection-source.mjs +9 -26
- package/features/markdown-reading/src/markdown-reading.mjs +3 -2
- package/features/mermaid-diagrams/assets/workflow.svg +15 -0
- package/features/mermaid-diagrams/codex-feature.json +31 -0
- package/features/{markdown-reading → mermaid-diagrams}/src/adapters/codex/mermaid.mjs +1 -1
- package/features/mermaid-diagrams/src/adapters/codex/native.mjs +34 -0
- package/features/mermaid-diagrams/src/adapters/codex/runtime.mjs +42 -0
- package/features/mermaid-diagrams/src/injection-source.mjs +26 -0
- package/features/{markdown-reading → mermaid-diagrams}/src/mermaid/frame.mjs +1 -1
- package/features/mermaid-diagrams/src/mermaid-diagrams.mjs +85 -0
- package/features/mermaid-diagrams/vendor/lucide-LICENSE +43 -0
- package/package.json +9 -5
- package/packages/cli/src/config.mjs +2 -1
- package/packages/cli/src/control-server.mjs +1 -1
- package/packages/codex-adapter/src/markdown/block-actions.mjs +107 -0
- package/packages/codex-adapter/src/markdown/editor-api.mjs +26 -0
- package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/preview.mjs +2 -8
- package/packages/plugin/assets/app.js +2 -2
- /package/features/{markdown-reading → mermaid-diagrams}/assets/qv-dependencies.js +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/assets/qv-export.js +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/assets/qv-loading.css +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/assets/qv-template.json +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/src/adapters/codex/mermaid-viewer.mjs +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/src/mermaid/export.mjs +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/src/mermaid/loading.mjs +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/src/mermaid/theme.css +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/src/mermaid/viewport.mjs +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/vendor/qv/LICENSE +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/vendor/qv/THIRD_PARTY_NOTICES.txt +0 -0
- /package/features/{markdown-reading → mermaid-diagrams}/vendor/qv/provenance.json +0 -0
- /package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/markdown-native.mjs +0 -0
- /package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/providers.mjs +0 -0
- /package/{features/markdown-reading/src/adapters/codex → packages/codex-adapter/src/markdown}/toc-native.mjs +0 -0
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
| 额度环 | 查看五小时与每周剩余额度,点击打开用量详情。 |
|
|
16
16
|
| 会话状态 | 查看回复速度、Token 用量和上下文占用。 |
|
|
17
17
|
| Markdown 阅读增强 | 改善文档排版,支持章节目录、表格展开和代码复制。 |
|
|
18
|
+
| Mermaid 图表增强(实验性) | 独立开关,默认关闭;支持图表缩放与 PNG 下载。 |
|
|
18
19
|
| 文件级联浏览 | 点击文件路径,分列浏览目录并切换文件。 |
|
|
19
20
|
| 图片集合 | 浏览本机生成图片,查看提示词,收藏到 Library。 |
|
|
20
21
|
| 站点收藏 | 发现本地项目网页,收藏网址并快速打开。 |
|
|
@@ -15,6 +15,9 @@ const content = {
|
|
|
15
15
|
'markdown-reading': [
|
|
16
16
|
['Codex 的 Markdown 文件预览。', '长文阅读、脚注跳转和表格查看不够方便。', '在文件预览中阅读增强排版,使用目录、脚注和表格操作。'],
|
|
17
17
|
['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.']],
|
|
18
|
+
'mermaid-diagrams': [
|
|
19
|
+
['Markdown 文件预览中的 Mermaid 图表。', '实验性图表样式与交互仍在完善,默认关闭。', '按需开启图表增强,使用缩放和 PNG 下载;关闭后使用 Codex 原生图表。'],
|
|
20
|
+
['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.']],
|
|
18
21
|
'file-navigation': [
|
|
19
22
|
['Codex 文件预览上方的路径区域。', '浏览相邻目录和文件需要额外跳转。', '点击路径展开分列目录,逐级浏览并打开另一个文件。'],
|
|
20
23
|
['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.']],
|
|
@@ -15,12 +15,7 @@
|
|
|
15
15
|
"script": "src/markdown-reading.mjs",
|
|
16
16
|
"sourceFactory": "src/injection-source.mjs",
|
|
17
17
|
"resources": {
|
|
18
|
-
"styles": "src/reading.css"
|
|
19
|
-
"mermaidStyles": "src/mermaid/theme.css",
|
|
20
|
-
"qvLoadingStyles": "assets/qv-loading.css",
|
|
21
|
-
"qvExport": "assets/qv-export.js",
|
|
22
|
-
"qvTemplate": "assets/qv-template.json",
|
|
23
|
-
"qvDependencies": "assets/qv-dependencies.js"
|
|
18
|
+
"styles": "src/reading.css"
|
|
24
19
|
}
|
|
25
20
|
},
|
|
26
21
|
"icon": {
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
// 使用当前编辑器所属的原生 CodeMirror 实例,避免引入第二套编辑器依赖。
|
|
2
|
-
export async function loadMarkdownListAPI(view) {
|
|
3
|
-
const links = [...document.querySelectorAll('link[rel="modulepreload"]')];
|
|
4
|
-
for (const link of links) {
|
|
5
|
-
if (!/\/dist-[\w-]+\.js$/.test(link.href)) continue;
|
|
6
|
-
const exports = Object.values(await import(link.href));
|
|
7
|
-
if (!exports.includes(view.constructor)) continue;
|
|
8
|
-
const Decoration = exports.find((value) => value?.line && value?.replace && value?.mark);
|
|
9
|
-
const ViewPlugin = exports.find((value) => value?.fromClass && value?.define);
|
|
10
|
-
const StateEffect = exports.find((value) => value?.appendConfig && value?.reconfigure);
|
|
11
|
-
const Compartment = exports.find(
|
|
12
|
-
(value) => value?.prototype?.reconfigure && value?.prototype?.of && value?.prototype?.get,
|
|
13
|
-
);
|
|
14
|
-
const WidgetType = exports.find(
|
|
15
|
-
(value) => value?.prototype?.eq && value?.prototype?.ignoreEvent && value?.prototype?.updateDOM,
|
|
16
|
-
);
|
|
17
|
-
const StateField = exports.find(
|
|
18
|
-
(value) =>
|
|
19
|
-
value?.define && value?.prototype?.slot && value?.prototype?.init && value?.prototype?.create,
|
|
20
|
-
);
|
|
21
|
-
const Prec = exports.find((value) => value?.highest && value?.lowest && value?.high);
|
|
22
|
-
if (Decoration && ViewPlugin && StateEffect && Compartment && WidgetType && Prec && StateField)
|
|
23
|
-
return { Decoration, ViewPlugin, StateEffect, Compartment, WidgetType, Prec, StateField };
|
|
24
|
-
}
|
|
25
|
-
throw new Error('native-markdown-list-api-unavailable');
|
|
26
|
-
}
|
|
27
1
|
export function installMarkdownLists(view, api) {
|
|
28
2
|
const { Decoration, ViewPlugin, StateEffect, Compartment, WidgetType, Prec } = api;
|
|
29
3
|
class Marker extends WidgetType {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { loadMarkdownListAPI
|
|
1
|
+
import { loadMarkdownListAPI } from '../../../../../packages/codex-adapter/src/markdown/editor-api.mjs';
|
|
2
|
+
import { installMarkdownLists } from './lists.mjs';
|
|
2
3
|
import { loadNativeMarkdownLinks, installMarkdownLinks } from './links.mjs';
|
|
3
4
|
import { installMarkdownTables } from './tables.mjs';
|
|
4
|
-
import { loadNativeMarkdownToc } from '
|
|
5
|
+
import { loadNativeMarkdownToc } from '../../../../../packages/codex-adapter/src/markdown/toc-native.mjs';
|
|
5
6
|
import { installMarkdownToc } from './toc.mjs';
|
|
6
|
-
import { loadNativeMarkdownTableActions
|
|
7
|
+
import { loadNativeMarkdownTableActions } from '../../../../../packages/codex-adapter/src/markdown/block-actions.mjs';
|
|
8
|
+
import { installMarkdownTableActions } from './table-actions.mjs';
|
|
7
9
|
import { loadNativeMarkdownRichText, installMarkdownRichText } from './rich-text.mjs';
|
|
8
|
-
import { installMarkdownMermaid } from './mermaid.mjs';
|
|
9
10
|
|
|
10
11
|
// 每个 Preview 共用换行状态,虚拟滚动重挂载的块也读取当前值。
|
|
11
12
|
export function createMarkdownWrapState() {
|
|
@@ -39,10 +40,8 @@ export function createMarkdownReadingRuntime(
|
|
|
39
40
|
installMarkdownTableActions,
|
|
40
41
|
loadNativeMarkdownRichText,
|
|
41
42
|
installMarkdownRichText,
|
|
42
|
-
installMarkdownMermaid,
|
|
43
43
|
installMarkdownMetadataScroll,
|
|
44
44
|
},
|
|
45
|
-
resources = {},
|
|
46
45
|
) {
|
|
47
46
|
const cached = new Map();
|
|
48
47
|
function load(name, ...args) {
|
|
@@ -64,7 +63,6 @@ export function createMarkdownReadingRuntime(
|
|
|
64
63
|
['markdown-reading-toc', 'loading'],
|
|
65
64
|
['markdown-table-actions', 'loading'],
|
|
66
65
|
['markdown-reading-rich-text', 'loading'],
|
|
67
|
-
['markdown-reading-mermaid', 'loading'],
|
|
68
66
|
]);
|
|
69
67
|
const cleanups = [capabilities.installMarkdownMetadataScroll(editor, scroller)];
|
|
70
68
|
let disposed = false;
|
|
@@ -103,12 +101,6 @@ export function createMarkdownReadingRuntime(
|
|
|
103
101
|
if (!current()) return;
|
|
104
102
|
cleanups.push(capabilities.installMarkdownTableActions(view, actions, codex, tables.controller));
|
|
105
103
|
report('markdown-table-actions', true);
|
|
106
|
-
await stage('markdown-reading-mermaid', 'native-mermaid-adapter-unavailable', async () => {
|
|
107
|
-
const cleanup = capabilities.installMarkdownMermaid(view, api, actions, codex, resources,
|
|
108
|
-
available => report('markdown-reading-mermaid', available, available ? null : 'qv-renderer-not-ready'));
|
|
109
|
-
cleanups.push(cleanup);
|
|
110
|
-
report('markdown-reading-mermaid', cleanup.available?.() ?? true);
|
|
111
|
-
});
|
|
112
104
|
await installRichText(api, actions);
|
|
113
105
|
});
|
|
114
106
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { collectMarkdownFootnotes } from '../../domain/footnotes.mjs';
|
|
2
|
-
import { captureMarkdownProviders } from '
|
|
2
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
3
3
|
|
|
4
4
|
// 复用消息流的代码组件与 Markdown lexer;文件内容及编辑器仍由 Codex 持有。
|
|
5
5
|
export async function loadNativeMarkdownRichText(native) {
|
|
@@ -1,125 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { loadNativeMarkdownRenderer } from './markdown-native.mjs';
|
|
3
|
-
import { captureMarkdownProviders } from './providers.mjs';
|
|
4
|
-
|
|
5
|
-
export function markdownExportAlias(source, name) {
|
|
6
|
-
const start = source.lastIndexOf('export{');
|
|
7
|
-
if (start < 0) return undefined;
|
|
8
|
-
const entries = source.slice(start + 7).split('}')[0].split(',');
|
|
9
|
-
for (const entry of entries) {
|
|
10
|
-
const [local, alias = local] = entry.trim().split(/\s+as\s+/);
|
|
11
|
-
if (local === name) return alias;
|
|
12
|
-
}
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// 从 Chat Markdown 的公开组件发现悬浮操作栏和控件,不绑定构建 hash。
|
|
17
|
-
export async function loadNativeMarkdownTableActions(native) {
|
|
18
|
-
const url = [...document.querySelectorAll('link[rel="modulepreload"],script[src]')]
|
|
19
|
-
.map((n) => n.href || n.src)
|
|
20
|
-
.find((url) => /\/app-initial-[^/]+\.js/.test(url));
|
|
21
|
-
const response = await fetch(url);
|
|
22
|
-
if (!response.ok) throw new Error('native-table-actions-source-unavailable');
|
|
23
|
-
const source = await response.text();
|
|
24
|
-
const section = (marker) => {
|
|
25
|
-
const at = source.indexOf(marker),
|
|
26
|
-
start = source.lastIndexOf('function ', at),
|
|
27
|
-
end = source.indexOf('function ', at);
|
|
28
|
-
if (at < 0 || start < 0 || end < 0) throw new Error('native-table-actions-contract-changed');
|
|
29
|
-
return source.slice(start, end);
|
|
30
|
-
};
|
|
31
|
-
const actions = section('"data-block-actions":!0'),
|
|
32
|
-
table = section('id:`markdown.expandTable`');
|
|
33
|
-
const exported = source.slice(source.lastIndexOf('export{'));
|
|
34
|
-
const module = await import(url);
|
|
35
|
-
const publicBinding = (name) => {
|
|
36
|
-
const alias = markdownExportAlias(exported, name);
|
|
37
|
-
if (!alias || !module[alias]) throw new Error('native-table-actions-export-unavailable');
|
|
38
|
-
return module[alias];
|
|
39
|
-
};
|
|
40
|
-
// 初始化原生 lazy module,再使用其公开 React 组件。
|
|
41
|
-
const initializer = source
|
|
42
|
-
.slice(source.indexOf(table) + table.length)
|
|
43
|
-
.match(/^function ([\w$]+)\(\)\{return\(\1=/)?.[1];
|
|
44
|
-
if (!initializer) throw new Error('native-table-actions-initializer-unavailable');
|
|
45
|
-
publicBinding(initializer)();
|
|
46
|
-
const imports = new Map();
|
|
47
|
-
for (const match of source.matchAll(/import\{([^}]+)\}from["']([^"']+)["']/g))
|
|
48
|
-
for (const entry of match[1].split(',')) {
|
|
49
|
-
const parts = entry.trim().split(/\s+as\s+/);
|
|
50
|
-
imports.set(parts.at(-1), { name: parts[0], url: new URL(match[2], url).href });
|
|
51
|
-
}
|
|
52
|
-
const binding = async (name) => {
|
|
53
|
-
const item = imports.get(name);
|
|
54
|
-
if (!item) throw new Error('native-table-actions-dependency-unavailable');
|
|
55
|
-
return (await import(item.url))[item.name];
|
|
56
|
-
};
|
|
57
|
-
const sharedUrl = [...imports.values()].find((item) => /\/app-shared-[^/]+\.js/.test(item.url))?.url;
|
|
58
|
-
if (!sharedUrl) throw new Error('native-code-wrap-module-unavailable');
|
|
59
|
-
const sharedSource = await (await fetch(sharedUrl)).text(),
|
|
60
|
-
shared = await import(sharedUrl);
|
|
61
|
-
const wrapAt = sharedSource.indexOf('id:`codeSnippet.wrap.disable`');
|
|
62
|
-
const wrapSection = sharedSource.slice(
|
|
63
|
-
sharedSource.lastIndexOf('function ', wrapAt),
|
|
64
|
-
sharedSource.indexOf('function ', wrapAt),
|
|
65
|
-
);
|
|
66
|
-
const wrapPair = wrapSection.match(
|
|
67
|
-
/children:[\w$]+\?\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\):\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\)/,
|
|
68
|
-
);
|
|
69
|
-
if (wrapAt < 0 || !wrapPair) throw new Error('native-code-wrap-icons-unavailable');
|
|
70
|
-
const sharedExports = sharedSource.slice(sharedSource.lastIndexOf('export{'));
|
|
71
|
-
const sharedBinding = (name) => shared[markdownExportAlias(sharedExports, name)];
|
|
72
|
-
const assignment = sharedSource.indexOf(`${wrapPair[1]}=`);
|
|
73
|
-
const initialize = sharedSource
|
|
74
|
-
.slice(sharedSource.lastIndexOf('function ', assignment))
|
|
75
|
-
.match(/^function ([\w$]+)\(\)/)?.[1];
|
|
76
|
-
if (initialize && typeof sharedBinding(initialize) === 'function') sharedBinding(initialize)();
|
|
77
|
-
const wrapIcons = { disable: sharedBinding(wrapPair[1]), enable: sharedBinding(wrapPair[2]) };
|
|
78
|
-
if (!wrapIcons.disable || !wrapIcons.enable) throw new Error('native-code-wrap-icon-exports-unavailable');
|
|
79
|
-
const button = table.match(/jsx\)\(([\w$]+),\{"aria-label":[\w$]+,"aria-expanded"/)?.[1];
|
|
80
|
-
const copy = table.match(/jsx\)\(([\w$]+),\{ariaLabel:[\w$]+,buttonText:/)?.[1];
|
|
81
|
-
const tooltip = table.match(/jsx\)\(([\w$]+),\{tooltipContent:[\w$]+,delayOpen:!0/)?.[1];
|
|
82
|
-
if (!button || !copy || !tooltip) throw new Error('native-table-actions-controls-unavailable');
|
|
83
|
-
const [Button, CopyButton, Tooltip] = await Promise.all([binding(button), binding(copy), binding(tooltip)]);
|
|
84
|
-
const previewName = table.match(/jsx\)\(([\w$]+),\{src:``,alt:/)?.[1];
|
|
85
|
-
const tableName = table.match(/jsx\)\(([\w$]+),\{className:[\w$]+,children:[\w$]+\}/)?.[1];
|
|
86
|
-
const classesName = table.match(/([\w$]+)\.MarkdownTablePreview/)?.[1];
|
|
87
|
-
const icon = table.match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+),\{icon:\{16:([\w$]+),20:([\w$]+)\}\}\)/);
|
|
88
|
-
if (!previewName || !tableName || !classesName || !icon)
|
|
89
|
-
throw new Error('native-table-preview-contract-unavailable');
|
|
90
|
-
const [Icon, small, medium, renderer] = await Promise.all([
|
|
91
|
-
binding(icon[1]),
|
|
92
|
-
binding(icon[2]),
|
|
93
|
-
binding(icon[3]),
|
|
94
|
-
loadNativeMarkdownRenderer(source, url, module),
|
|
95
|
-
]);
|
|
96
|
-
const preview = section('id:`imagePreviewDialog.label`');
|
|
97
|
-
const downloadName = preview.match(/([\w$]+)\(\{downloadSrc:[\w$]+,onDownloaded:/)?.[1];
|
|
98
|
-
const downloadSection = preview.slice(preview.indexOf('suggestedFilename:', preview.indexOf('downloadSrc:')));
|
|
99
|
-
const downloadIcon = downloadSection.match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+),\{className:`icon-xs`\}/)?.[1];
|
|
100
|
-
if (!downloadName || !downloadIcon) throw new Error('native-diagram-download-unavailable');
|
|
101
|
-
const downloadSource = section('Failed to download image');
|
|
102
|
-
const requestName = downloadSource.match(/await ([\w$]+)\(`save-file`,/)?.[1];
|
|
103
|
-
if (!requestName) throw new Error('native-diagram-save-request-unavailable');
|
|
104
|
-
const [DownloadIcon, saveFile] = await Promise.all([binding(downloadIcon),binding(requestName)]);
|
|
105
|
-
return {
|
|
106
|
-
...native,
|
|
107
|
-
async downloadImage({downloadSrc,suggestedFilename}) {
|
|
108
|
-
return saveQvDiagram(downloadSrc,saveFile,markdownDownloadsDirectory,suggestedFilename);
|
|
109
|
-
},
|
|
110
|
-
DownloadIcon,
|
|
111
|
-
...renderer,
|
|
112
|
-
TablePreview: publicBinding(previewName),
|
|
113
|
-
Table: publicBinding(tableName),
|
|
114
|
-
tableClasses: publicBinding(classesName),
|
|
115
|
-
ExpandIcon: () => native.React.createElement(Icon, { icon: { 16: small, 20: medium } }),
|
|
116
|
-
Actions: publicBinding(actions.match(/^function ([\w$]+)/)[1]),
|
|
117
|
-
Button,
|
|
118
|
-
wrapIcons,
|
|
119
|
-
CopyButton,
|
|
120
|
-
Tooltip,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
1
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
123
2
|
|
|
124
3
|
export function installMarkdownTableActions(view, native, codex, controller) {
|
|
125
4
|
const {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { captureMarkdownProviders } from '
|
|
1
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
2
2
|
|
|
3
3
|
// Markdown 负责标题与导航;原生组件负责短线、动效、浮层材质与悬浮定位。
|
|
4
4
|
export function installMarkdownToc(view, api, native, codex) {
|
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { loadMarkdownListAPI } from '../../../packages/codex-adapter/src/markdown/editor-api.mjs';
|
|
2
|
+
import { markdownExportAlias, loadNativeMarkdownTableActions } from '../../../packages/codex-adapter/src/markdown/block-actions.mjs';
|
|
3
|
+
import { loadNativeMarkdownRenderer } from '../../../packages/codex-adapter/src/markdown/markdown-native.mjs';
|
|
2
4
|
import { collectMarkdownFootnotes } from './domain/footnotes.mjs';
|
|
3
|
-
import { captureMarkdownProviders } from '
|
|
5
|
+
import { captureMarkdownProviders } from '../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
4
6
|
import {
|
|
5
7
|
createMarkdownReadingRuntime,
|
|
6
8
|
createMarkdownWrapState,
|
|
7
9
|
installMarkdownMetadataScroll,
|
|
8
10
|
} from './adapters/codex/reading-runtime.mjs';
|
|
9
11
|
import { loadNativeMarkdownRichText, installMarkdownRichText } from './adapters/codex/rich-text.mjs';
|
|
10
|
-
import {
|
|
11
|
-
markdownExportAlias,
|
|
12
|
-
loadNativeMarkdownTableActions,
|
|
13
|
-
installMarkdownTableActions,
|
|
14
|
-
} from './adapters/codex/table-actions.mjs';
|
|
12
|
+
import { installMarkdownTableActions } from './adapters/codex/table-actions.mjs';
|
|
15
13
|
import { loadNativeMarkdownLinks, installMarkdownLinks } from './adapters/codex/links.mjs';
|
|
16
|
-
import { loadNativeMarkdownToc } from '
|
|
14
|
+
import { loadNativeMarkdownToc } from '../../../packages/codex-adapter/src/markdown/toc-native.mjs';
|
|
17
15
|
import { installMarkdownToc } from './adapters/codex/toc.mjs';
|
|
18
|
-
import { homedir } from 'node:os';
|
|
19
|
-
import { join } from 'node:path';
|
|
20
16
|
import { readFile } from 'node:fs/promises';
|
|
21
17
|
import { installMarkdownTables } from './adapters/codex/tables.mjs';
|
|
22
|
-
import {
|
|
23
|
-
import { createMarkdownPreviewAdapter } from '
|
|
24
|
-
import { createQvResources, createQvFrame, readQvTheme } from './mermaid/frame.mjs';
|
|
25
|
-
import { exportQvDiagram, saveQvDiagram } from './mermaid/export.mjs';
|
|
26
|
-
import { createQvLoading } from './mermaid/loading.mjs';
|
|
27
|
-
import { createMarkdownMermaidControls } from './adapters/codex/mermaid-viewer.mjs';
|
|
28
|
-
import { installMarkdownMermaid } from './adapters/codex/mermaid.mjs';
|
|
18
|
+
import { installMarkdownLists } from './adapters/codex/lists.mjs';
|
|
19
|
+
import { createMarkdownPreviewAdapter } from '../../../packages/codex-adapter/src/markdown/preview.mjs';
|
|
29
20
|
export async function createPageScriptSource() {
|
|
30
21
|
const bindings = [
|
|
31
|
-
exportQvDiagram,
|
|
32
|
-
saveQvDiagram,
|
|
33
|
-
createQvLoading,
|
|
34
|
-
createQvResources,
|
|
35
|
-
createQvFrame,
|
|
36
|
-
readQvTheme,
|
|
37
|
-
createMarkdownMermaidControls,
|
|
38
|
-
installMarkdownMermaid,
|
|
39
22
|
collectMarkdownFootnotes,
|
|
40
23
|
captureMarkdownProviders,
|
|
41
24
|
createMarkdownReadingRuntime,
|
|
@@ -58,5 +41,5 @@ export async function createPageScriptSource() {
|
|
|
58
41
|
];
|
|
59
42
|
const declarations = bindings.map((binding) => `const ${binding.name} = ${binding.toString()};`).join('\n');
|
|
60
43
|
const entry = await readFile(new URL('./markdown-reading.mjs', import.meta.url), 'utf8');
|
|
61
|
-
return
|
|
44
|
+
return `${declarations}\n${entry}`;
|
|
62
45
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const marker = 'data-minecodex-markdown-reading';
|
|
2
|
-
const
|
|
2
|
+
const runtime = createMarkdownReadingRuntime(config.codex);
|
|
3
|
+
const native = createMarkdownPreviewAdapter(config.codex, item => runtime.attach(item));
|
|
3
4
|
const styled = new Map();
|
|
4
5
|
const sessions = new Map();
|
|
5
6
|
const tokenNames = ['--font-content', '--text-document', '--leading-relaxed', '--font-weight-semibold',
|
|
@@ -7,7 +8,7 @@ const tokenNames = ['--font-content', '--text-document', '--leading-relaxed', '-
|
|
|
7
8
|
'--color-text-foreground-secondary', '--color-border'];
|
|
8
9
|
const style = document.createElement('style');
|
|
9
10
|
style.setAttribute('data-minecodex-markdown-reading-styles', '');
|
|
10
|
-
style.textContent =
|
|
11
|
+
style.textContent = config.resources.styles;
|
|
11
12
|
document.head.append(style);
|
|
12
13
|
let disposed = false;
|
|
13
14
|
let pending = null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3
|
+
width="24"
|
|
4
|
+
height="24"
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
fill="none"
|
|
7
|
+
stroke="currentColor"
|
|
8
|
+
stroke-width="2"
|
|
9
|
+
stroke-linecap="round"
|
|
10
|
+
stroke-linejoin="round"
|
|
11
|
+
>
|
|
12
|
+
<rect width="8" height="8" x="3" y="3" rx="2" />
|
|
13
|
+
<path d="M7 11v4a2 2 0 0 0 2 2h4" />
|
|
14
|
+
<rect width="8" height="8" x="13" y="13" rx="2" />
|
|
15
|
+
</svg>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "mermaid-diagrams",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"label": {
|
|
6
|
+
"en": "Mermaid Diagrams (Experimental)",
|
|
7
|
+
"zh-CN": "Mermaid 图表增强(实验性)"
|
|
8
|
+
},
|
|
9
|
+
"description": {
|
|
10
|
+
"en": "Opt in to enhanced Markdown diagrams with zoom and PNG download. Off by default.",
|
|
11
|
+
"zh-CN": "在 Markdown 预览中增强图表,支持缩放与 PNG 下载。实验性功能,默认关闭。"
|
|
12
|
+
},
|
|
13
|
+
"entry": {
|
|
14
|
+
"kind": "page-script",
|
|
15
|
+
"script": "src/mermaid-diagrams.mjs",
|
|
16
|
+
"sourceFactory": "src/injection-source.mjs",
|
|
17
|
+
"resources": {
|
|
18
|
+
"mermaidStyles": "src/mermaid/theme.css",
|
|
19
|
+
"qvLoadingStyles": "assets/qv-loading.css",
|
|
20
|
+
"qvExport": "assets/qv-export.js",
|
|
21
|
+
"qvTemplate": "assets/qv-template.json",
|
|
22
|
+
"qvDependencies": "assets/qv-dependencies.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"icon": {
|
|
26
|
+
"resource": "assets/workflow.svg"
|
|
27
|
+
},
|
|
28
|
+
"placement": {
|
|
29
|
+
"order": 91
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createQvResources, createQvFrame, readQvTheme } from '../../mermaid/frame.mjs';
|
|
2
2
|
import { exportQvDiagram } from '../../mermaid/export.mjs';
|
|
3
3
|
import { createQvLoading } from '../../mermaid/loading.mjs';
|
|
4
|
-
import { captureMarkdownProviders } from '
|
|
4
|
+
import { captureMarkdownProviders } from '../../../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
5
5
|
import { createMarkdownMermaidControls } from './mermaid-viewer.mjs';
|
|
6
6
|
|
|
7
7
|
export function installMarkdownMermaid(view, api, native, codex, resources, onStatus = () => {}) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { saveQvDiagram } from '../../mermaid/export.mjs';
|
|
2
|
+
|
|
3
|
+
// 图表下载协议只由实验性功能加载,阅读增强不依赖此能力。
|
|
4
|
+
export async function loadNativeMermaidActions(native) {
|
|
5
|
+
const url = [...document.querySelectorAll('link[rel="modulepreload"],script[src]')]
|
|
6
|
+
.map(node => node.href || node.src).find(url => /\/app-initial-[^/]+\.js/.test(url));
|
|
7
|
+
const response = await fetch(url);
|
|
8
|
+
if (!response.ok) throw new Error('native-diagram-source-unavailable');
|
|
9
|
+
const source = await response.text();
|
|
10
|
+
const section = marker => {
|
|
11
|
+
const at = source.indexOf(marker);
|
|
12
|
+
if (at < 0) throw new Error('native-diagram-contract-changed');
|
|
13
|
+
return source.slice(source.lastIndexOf('function ', at), source.indexOf('function ', at));
|
|
14
|
+
};
|
|
15
|
+
const preview = section('id:`imagePreviewDialog.label`');
|
|
16
|
+
const downloadSection = preview.slice(preview.indexOf('suggestedFilename:', preview.indexOf('downloadSrc:')));
|
|
17
|
+
const downloadIcon = downloadSection.match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+),\{className:`icon-xs`\}/)?.[1];
|
|
18
|
+
const requestName = section('Failed to download image').match(/await ([\w$]+)\(`save-file`,/)?.[1];
|
|
19
|
+
const imports = new Map();
|
|
20
|
+
for (const match of source.matchAll(/import\{([^}]+)\}from["']([^"']+)["']/g))
|
|
21
|
+
for (const entry of match[1].split(',')) {
|
|
22
|
+
const parts = entry.trim().split(/\s+as\s+/);
|
|
23
|
+
imports.set(parts.at(-1), { name:parts[0], url:new URL(match[2],url).href });
|
|
24
|
+
}
|
|
25
|
+
const binding = async name => {
|
|
26
|
+
const item = imports.get(name);
|
|
27
|
+
if (!item) throw new Error('native-diagram-save-request-unavailable');
|
|
28
|
+
return (await import(item.url))[item.name];
|
|
29
|
+
};
|
|
30
|
+
const [DownloadIcon, saveFile] = await Promise.all([binding(downloadIcon),binding(requestName)]);
|
|
31
|
+
return { ...native, DownloadIcon, downloadImage({downloadSrc,suggestedFilename}) {
|
|
32
|
+
return saveQvDiagram(downloadSrc,saveFile,markdownDownloadsDirectory,suggestedFilename);
|
|
33
|
+
} };
|
|
34
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { loadMarkdownListAPI } from '../../../../../packages/codex-adapter/src/markdown/editor-api.mjs';
|
|
2
|
+
import { loadNativeMarkdownToc } from '../../../../../packages/codex-adapter/src/markdown/toc-native.mjs';
|
|
3
|
+
import { loadNativeMarkdownTableActions } from '../../../../../packages/codex-adapter/src/markdown/block-actions.mjs';
|
|
4
|
+
import { loadNativeMermaidActions } from './native.mjs';
|
|
5
|
+
import { installMarkdownMermaid } from './mermaid.mjs';
|
|
6
|
+
|
|
7
|
+
export function createMermaidRuntime(codex, resources, capabilities = {
|
|
8
|
+
loadMarkdownListAPI, loadNativeMarkdownToc, loadNativeMarkdownTableActions,
|
|
9
|
+
loadNativeMermaidActions, installMarkdownMermaid,
|
|
10
|
+
}) {
|
|
11
|
+
let native;
|
|
12
|
+
function load() {
|
|
13
|
+
native ??= Promise.resolve().then(() => capabilities.loadNativeMarkdownToc())
|
|
14
|
+
.then(value => capabilities.loadNativeMarkdownTableActions(value))
|
|
15
|
+
.then(value => capabilities.loadNativeMermaidActions(value));
|
|
16
|
+
native.catch(() => { native = null; });
|
|
17
|
+
return native;
|
|
18
|
+
}
|
|
19
|
+
return { attach({editor, content}) {
|
|
20
|
+
const view = content.cmTile?.view;
|
|
21
|
+
let disposed = false, available = false, cleanup;
|
|
22
|
+
const current = () => !disposed && !view?.destroyed;
|
|
23
|
+
const report = value => {
|
|
24
|
+
if (!current()) return;
|
|
25
|
+
available = value;
|
|
26
|
+
codex.report('mermaid-diagrams-renderer', value, value ? null : 'mermaid-renderer-unavailable');
|
|
27
|
+
};
|
|
28
|
+
const ready = (async () => {
|
|
29
|
+
try {
|
|
30
|
+
if (!view || view.dom !== editor || !view.state.tree) throw new Error('native-markdown-view-unavailable');
|
|
31
|
+
const [api, actions] = await Promise.all([capabilities.loadMarkdownListAPI(view), load()]);
|
|
32
|
+
if (!current()) return;
|
|
33
|
+
cleanup = capabilities.installMarkdownMermaid(view,api,actions,codex,resources,report);
|
|
34
|
+
report(cleanup.available?.() ?? true);
|
|
35
|
+
} catch { report(false); }
|
|
36
|
+
})();
|
|
37
|
+
return { ready, checks: () => [{name:'mermaid-diagrams-renderer',available}], dispose() {
|
|
38
|
+
if (disposed) return;
|
|
39
|
+
disposed = true; cleanup?.();
|
|
40
|
+
} };
|
|
41
|
+
} };
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { createMarkdownPreviewAdapter } from '../../../packages/codex-adapter/src/markdown/preview.mjs';
|
|
5
|
+
import { loadMarkdownListAPI } from '../../../packages/codex-adapter/src/markdown/editor-api.mjs';
|
|
6
|
+
import { captureMarkdownProviders } from '../../../packages/codex-adapter/src/markdown/providers.mjs';
|
|
7
|
+
import { loadNativeMarkdownToc } from '../../../packages/codex-adapter/src/markdown/toc-native.mjs';
|
|
8
|
+
import { loadNativeMarkdownRenderer } from '../../../packages/codex-adapter/src/markdown/markdown-native.mjs';
|
|
9
|
+
import { markdownExportAlias, loadNativeMarkdownTableActions } from '../../../packages/codex-adapter/src/markdown/block-actions.mjs';
|
|
10
|
+
import { createQvResources, createQvFrame, readQvTheme } from './mermaid/frame.mjs';
|
|
11
|
+
import { exportQvDiagram, saveQvDiagram } from './mermaid/export.mjs';
|
|
12
|
+
import { createQvLoading } from './mermaid/loading.mjs';
|
|
13
|
+
import { createMarkdownMermaidControls } from './adapters/codex/mermaid-viewer.mjs';
|
|
14
|
+
import { installMarkdownMermaid } from './adapters/codex/mermaid.mjs';
|
|
15
|
+
import { loadNativeMermaidActions } from './adapters/codex/native.mjs';
|
|
16
|
+
import { createMermaidRuntime } from './adapters/codex/runtime.mjs';
|
|
17
|
+
|
|
18
|
+
export async function createPageScriptSource() {
|
|
19
|
+
const bindings = [createMarkdownPreviewAdapter, loadMarkdownListAPI, captureMarkdownProviders,
|
|
20
|
+
loadNativeMarkdownToc, loadNativeMarkdownRenderer, markdownExportAlias, loadNativeMarkdownTableActions,
|
|
21
|
+
createQvResources, createQvFrame, readQvTheme, exportQvDiagram, saveQvDiagram, createQvLoading,
|
|
22
|
+
createMarkdownMermaidControls, installMarkdownMermaid, loadNativeMermaidActions, createMermaidRuntime];
|
|
23
|
+
const declarations = bindings.map(binding => `const ${binding.name} = ${binding.toString()};`).join('\n');
|
|
24
|
+
const entry = await readFile(new URL('./mermaid-diagrams.mjs',import.meta.url),'utf8');
|
|
25
|
+
return `const markdownDownloadsDirectory=${JSON.stringify(join(homedir(),'Downloads'))};\n${declarations}\n${entry}`;
|
|
26
|
+
}
|
|
@@ -101,7 +101,7 @@ export function readQvTheme(element) {
|
|
|
101
101
|
const colors = ['#3b82f6','#10b981','#8b5cf6','#f59e0b','#ec4899','#06b6d4'];
|
|
102
102
|
colors.forEach((color, index) => tokens[`--viz-series-${index+1}`] = get(`--viz-series-${index+1}`) || color);
|
|
103
103
|
const probe = document.createElement('div');
|
|
104
|
-
probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;width:var(--mcx-reading-width);height:0';
|
|
104
|
+
probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;width:var(--mcx-reading-width, calc(var(--thread-content-max-width) - var(--padding-toolbar) * 2));height:0';
|
|
105
105
|
element.append(probe);
|
|
106
106
|
const readingWidth = probe.getBoundingClientRect().width;
|
|
107
107
|
probe.remove();
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const marker = 'data-minecodex-mermaid-diagrams';
|
|
2
|
+
const runtime = createMermaidRuntime(config.codex, config.resources);
|
|
3
|
+
const native = createMarkdownPreviewAdapter(config.codex, item => runtime.attach(item));
|
|
4
|
+
const styled = new Map();
|
|
5
|
+
const sessions = new Map();
|
|
6
|
+
const tokenNames = ['--font-content', '--text-document', '--leading-relaxed', '--font-weight-semibold',
|
|
7
|
+
'--color-token-main-surface-primary', '--color-token-bg-secondary', '--color-text-foreground',
|
|
8
|
+
'--color-text-foreground-secondary', '--color-border'];
|
|
9
|
+
const style = document.createElement('style');
|
|
10
|
+
style.setAttribute('data-minecodex-mermaid-diagrams-styles', '');
|
|
11
|
+
style.textContent = [config.resources.mermaidStyles, config.resources.qvLoadingStyles].join('\n');
|
|
12
|
+
document.head.append(style);
|
|
13
|
+
let disposed = false;
|
|
14
|
+
let pending = null;
|
|
15
|
+
|
|
16
|
+
function release(editor) {
|
|
17
|
+
const binding = styled.get(editor);
|
|
18
|
+
sessions.get(editor)?.dispose();
|
|
19
|
+
sessions.delete(editor);
|
|
20
|
+
editor.removeAttribute(marker);
|
|
21
|
+
binding?.();
|
|
22
|
+
styled.delete(editor);
|
|
23
|
+
}
|
|
24
|
+
function reconcile() {
|
|
25
|
+
pending = null;
|
|
26
|
+
if (disposed) return;
|
|
27
|
+
const previews = native.previews();
|
|
28
|
+
const editors = new Set(previews.map((item) => item.editor));
|
|
29
|
+
for (const editor of styled.keys()) if (!editors.has(editor)) release(editor);
|
|
30
|
+
for (const preview of previews) {
|
|
31
|
+
const { editor } = preview;
|
|
32
|
+
if (!styled.has(editor)) styled.set(editor, config.ui.theme.bindScope(editor, tokenNames));
|
|
33
|
+
if (!editor.hasAttribute(marker)) editor.setAttribute(marker, '');
|
|
34
|
+
if (!sessions.has(editor)) sessions.set(editor, native.attach(preview));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function schedule(records) {
|
|
39
|
+
// 忽略原生选区与逐行装饰更新;只在预览视图或其祖先变化时重新定位。
|
|
40
|
+
if (records.every((record) => record.target.closest?.('.cm-content, [data-mcx-reading-toc]'))) return;
|
|
41
|
+
if (!disposed && pending === null) pending = window.requestAnimationFrame(reconcile);
|
|
42
|
+
}
|
|
43
|
+
const observer = new MutationObserver(schedule);
|
|
44
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
45
|
+
reconcile();
|
|
46
|
+
config.registerSelfCheck?.(() => {
|
|
47
|
+
const previews = native.previews();
|
|
48
|
+
const styleAvailable =
|
|
49
|
+
style.isConnected && previews.length > 0 && previews.every(({ editor }) => editor.hasAttribute(marker));
|
|
50
|
+
const sessionChecks = previews.map(({ editor }) => sessions.get(editor)?.checks() ?? []);
|
|
51
|
+
const checks = previews.length
|
|
52
|
+
? [
|
|
53
|
+
{ name: 'mermaid-preview-styled', available: styleAvailable },
|
|
54
|
+
...(sessionChecks[0] ?? []).map((check) => ({
|
|
55
|
+
name: check.name,
|
|
56
|
+
available: sessionChecks.every((items) =>
|
|
57
|
+
items.some((item) => item.name === check.name && item.available),
|
|
58
|
+
),
|
|
59
|
+
})),
|
|
60
|
+
]
|
|
61
|
+
: [];
|
|
62
|
+
const available =
|
|
63
|
+
styleAvailable &&
|
|
64
|
+
sessionChecks.every((items) => items.length > 0) &&
|
|
65
|
+
checks.every((check) => check.available);
|
|
66
|
+
return {
|
|
67
|
+
state: previews.length ? (available ? 'available' : 'unavailable') : 'not-applicable',
|
|
68
|
+
reason: previews.length
|
|
69
|
+
? available
|
|
70
|
+
? null
|
|
71
|
+
: styleAvailable
|
|
72
|
+
? 'mermaid-diagrams-layout-unavailable'
|
|
73
|
+
: 'markdown-style-unavailable'
|
|
74
|
+
: 'no-markdown-preview',
|
|
75
|
+
checks,
|
|
76
|
+
scopes: previews.map(({ editor }) => ({ name: 'markdown-preview', element: editor })),
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
return () => {
|
|
80
|
+
disposed = true;
|
|
81
|
+
observer.disconnect();
|
|
82
|
+
if (pending !== null) window.cancelAnimationFrame(pending);
|
|
83
|
+
for (const editor of styled.keys()) release(editor);
|
|
84
|
+
style.remove();
|
|
85
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
The following Lucide icons are derived from the Feather project:
|
|
20
|
+
|
|
21
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
22
|
+
|
|
23
|
+
The MIT License (MIT) (for the icons listed above)
|
|
24
|
+
|
|
25
|
+
Copyright (c) 2013-present Cole Bemis
|
|
26
|
+
|
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
29
|
+
in the Software without restriction, including without limitation the rights
|
|
30
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
32
|
+
furnished to do so, subject to the following conditions:
|
|
33
|
+
|
|
34
|
+
The above copyright notice and this permission notice shall be included in all
|
|
35
|
+
copies or substantial portions of the Software.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecodex",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.40",
|
|
4
4
|
"description": "Lightweight, local-first plugins for the Codex desktop app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -77,16 +77,20 @@
|
|
|
77
77
|
"packages/plugin/src",
|
|
78
78
|
"packages/plugin/assets",
|
|
79
79
|
"packages/plugin/plugin.json",
|
|
80
|
-
"features/
|
|
81
|
-
"features/
|
|
82
|
-
"features/
|
|
80
|
+
"features/mermaid-diagrams/vendor/qv/LICENSE",
|
|
81
|
+
"features/mermaid-diagrams/vendor/qv/provenance.json",
|
|
82
|
+
"features/mermaid-diagrams/vendor/qv/THIRD_PARTY_NOTICES.txt",
|
|
83
|
+
"features/mermaid-diagrams/src",
|
|
84
|
+
"features/mermaid-diagrams/assets",
|
|
85
|
+
"features/mermaid-diagrams/codex-feature.json",
|
|
86
|
+
"features/mermaid-diagrams/vendor/lucide-LICENSE"
|
|
83
87
|
],
|
|
84
88
|
"engines": {
|
|
85
89
|
"node": ">=22.5.0"
|
|
86
90
|
},
|
|
87
91
|
"scripts": {
|
|
88
92
|
"start": "node packages/cli/bin/mcx.mjs serve",
|
|
89
|
-
"test": "node --test packages/cli/test/*.test.mjs packages/runtime-host/test/*.test.mjs features/model-slider/test/*.test.mjs features/notes/test/*.test.mjs features/images/test/*.test.mjs features/hide-upsell-banner/test/*.test.mjs features/session-status/test/*.test.mjs features/usage-meter/test/*.test.mjs apps/dashboard/test/*.test.mjs features/unread-inbox/test/*.test.mjs features/quick-chat/test/*.test.mjs features/sidebar-focus/test/*.test.mjs features/sites/test/*.test.mjs packages/ui/test/*.test.mjs packages/codex-adapter/test/*.test.mjs features/markdown-reading/test/*.test.mjs features/file-navigation/test/*.test.mjs packages/plugin/test/*.test.mjs",
|
|
93
|
+
"test": "node --test packages/cli/test/*.test.mjs packages/runtime-host/test/*.test.mjs features/model-slider/test/*.test.mjs features/notes/test/*.test.mjs features/images/test/*.test.mjs features/hide-upsell-banner/test/*.test.mjs features/session-status/test/*.test.mjs features/usage-meter/test/*.test.mjs apps/dashboard/test/*.test.mjs features/unread-inbox/test/*.test.mjs features/quick-chat/test/*.test.mjs features/sidebar-focus/test/*.test.mjs features/sites/test/*.test.mjs packages/ui/test/*.test.mjs packages/codex-adapter/test/*.test.mjs features/markdown-reading/test/*.test.mjs features/file-navigation/test/*.test.mjs packages/plugin/test/*.test.mjs features/mermaid-diagrams/test/*.test.mjs",
|
|
90
94
|
"test:cli": "node --test packages/cli/test/*.test.mjs",
|
|
91
95
|
"test:runtime": "node --test packages/runtime-host/test/*.test.mjs",
|
|
92
96
|
"check": "node scripts/check-syntax.mjs",
|
|
@@ -2,7 +2,7 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
-
export const FEATURE_IDS = Object.freeze(["model-slider", "notes", "images", "hide-upsell-banner", "session-status", "usage-meter", "sidebar-focus", "sites", "markdown-reading", "file-navigation", "quick-chat"]);
|
|
5
|
+
export const FEATURE_IDS = Object.freeze(["model-slider", "notes", "images", "hide-upsell-banner", "session-status", "usage-meter", "sidebar-focus", "sites", "markdown-reading", "mermaid-diagrams", "file-navigation", "quick-chat"]);
|
|
6
6
|
export const DEFAULT_CONFIG = Object.freeze({
|
|
7
7
|
schemaVersion: 1,
|
|
8
8
|
features: Object.freeze({
|
|
@@ -15,6 +15,7 @@ export const DEFAULT_CONFIG = Object.freeze({
|
|
|
15
15
|
"sidebar-focus": true,
|
|
16
16
|
sites: true,
|
|
17
17
|
"markdown-reading": true,
|
|
18
|
+
"mermaid-diagrams": false,
|
|
18
19
|
"file-navigation": true,
|
|
19
20
|
"quick-chat": true,
|
|
20
21
|
}),
|
|
@@ -14,7 +14,7 @@ import { createDataTransfer, MAX_TRANSFER_BYTES } from "./data-transfer/service.
|
|
|
14
14
|
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
15
15
|
const packageMetadata = JSON.parse(await readFile(path.join(packageRoot, "package.json"), "utf8"));
|
|
16
16
|
const MAX_BODY_BYTES = 64 * 1024;
|
|
17
|
-
const DASHBOARD_FEATURE_ORDER = ["model-slider", "notes", "usage-meter", "session-status", "markdown-reading", "file-navigation", "images", "sites", "quick-chat", "sidebar-focus", "hide-upsell-banner"];
|
|
17
|
+
const DASHBOARD_FEATURE_ORDER = ["model-slider", "notes", "usage-meter", "session-status", "markdown-reading", "mermaid-diagrams", "file-navigation", "images", "sites", "quick-chat", "sidebar-focus", "hide-upsell-banner"];
|
|
18
18
|
const CONTENT_TYPES = new Map([
|
|
19
19
|
[".css", "text/css; charset=utf-8"],
|
|
20
20
|
[".html", "text/html; charset=utf-8"],
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { loadNativeMarkdownRenderer } from './markdown-native.mjs';
|
|
2
|
+
|
|
3
|
+
export function markdownExportAlias(source, name) {
|
|
4
|
+
const start = source.lastIndexOf('export{');
|
|
5
|
+
if (start < 0) return undefined;
|
|
6
|
+
const entries = source.slice(start + 7).split('}')[0].split(',');
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
const [local, alias = local] = entry.trim().split(/\s+as\s+/);
|
|
9
|
+
if (local === name) return alias;
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 从 Chat Markdown 的公开组件发现悬浮操作栏和控件,不绑定构建 hash。
|
|
15
|
+
export async function loadNativeMarkdownTableActions(native) {
|
|
16
|
+
const url = [...document.querySelectorAll('link[rel="modulepreload"],script[src]')]
|
|
17
|
+
.map((n) => n.href || n.src)
|
|
18
|
+
.find((url) => /\/app-initial-[^/]+\.js/.test(url));
|
|
19
|
+
const response = await fetch(url);
|
|
20
|
+
if (!response.ok) throw new Error('native-table-actions-source-unavailable');
|
|
21
|
+
const source = await response.text();
|
|
22
|
+
const section = (marker) => {
|
|
23
|
+
const at = source.indexOf(marker),
|
|
24
|
+
start = source.lastIndexOf('function ', at),
|
|
25
|
+
end = source.indexOf('function ', at);
|
|
26
|
+
if (at < 0 || start < 0 || end < 0) throw new Error('native-table-actions-contract-changed');
|
|
27
|
+
return source.slice(start, end);
|
|
28
|
+
};
|
|
29
|
+
const actions = section('"data-block-actions":!0'),
|
|
30
|
+
table = section('id:`markdown.expandTable`');
|
|
31
|
+
const exported = source.slice(source.lastIndexOf('export{'));
|
|
32
|
+
const module = await import(url);
|
|
33
|
+
const publicBinding = (name) => {
|
|
34
|
+
const alias = markdownExportAlias(exported, name);
|
|
35
|
+
if (!alias || !module[alias]) throw new Error('native-table-actions-export-unavailable');
|
|
36
|
+
return module[alias];
|
|
37
|
+
};
|
|
38
|
+
// 初始化原生 lazy module,再使用其公开 React 组件。
|
|
39
|
+
const initializer = source
|
|
40
|
+
.slice(source.indexOf(table) + table.length)
|
|
41
|
+
.match(/^function ([\w$]+)\(\)\{return\(\1=/)?.[1];
|
|
42
|
+
if (!initializer) throw new Error('native-table-actions-initializer-unavailable');
|
|
43
|
+
publicBinding(initializer)();
|
|
44
|
+
const imports = new Map();
|
|
45
|
+
for (const match of source.matchAll(/import\{([^}]+)\}from["']([^"']+)["']/g))
|
|
46
|
+
for (const entry of match[1].split(',')) {
|
|
47
|
+
const parts = entry.trim().split(/\s+as\s+/);
|
|
48
|
+
imports.set(parts.at(-1), { name: parts[0], url: new URL(match[2], url).href });
|
|
49
|
+
}
|
|
50
|
+
const binding = async (name) => {
|
|
51
|
+
const item = imports.get(name);
|
|
52
|
+
if (!item) throw new Error('native-table-actions-dependency-unavailable');
|
|
53
|
+
return (await import(item.url))[item.name];
|
|
54
|
+
};
|
|
55
|
+
const sharedUrl = [...imports.values()].find((item) => /\/app-shared-[^/]+\.js/.test(item.url))?.url;
|
|
56
|
+
if (!sharedUrl) throw new Error('native-code-wrap-module-unavailable');
|
|
57
|
+
const sharedSource = await (await fetch(sharedUrl)).text(),
|
|
58
|
+
shared = await import(sharedUrl);
|
|
59
|
+
const wrapAt = sharedSource.indexOf('id:`codeSnippet.wrap.disable`');
|
|
60
|
+
const wrapSection = sharedSource.slice(
|
|
61
|
+
sharedSource.lastIndexOf('function ', wrapAt),
|
|
62
|
+
sharedSource.indexOf('function ', wrapAt),
|
|
63
|
+
);
|
|
64
|
+
const wrapPair = wrapSection.match(
|
|
65
|
+
/children:[\w$]+\?\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\):\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\)/,
|
|
66
|
+
);
|
|
67
|
+
if (wrapAt < 0 || !wrapPair) throw new Error('native-code-wrap-icons-unavailable');
|
|
68
|
+
const sharedExports = sharedSource.slice(sharedSource.lastIndexOf('export{'));
|
|
69
|
+
const sharedBinding = (name) => shared[markdownExportAlias(sharedExports, name)];
|
|
70
|
+
const assignment = sharedSource.indexOf(`${wrapPair[1]}=`);
|
|
71
|
+
const initialize = sharedSource
|
|
72
|
+
.slice(sharedSource.lastIndexOf('function ', assignment))
|
|
73
|
+
.match(/^function ([\w$]+)\(\)/)?.[1];
|
|
74
|
+
if (initialize && typeof sharedBinding(initialize) === 'function') sharedBinding(initialize)();
|
|
75
|
+
const wrapIcons = { disable: sharedBinding(wrapPair[1]), enable: sharedBinding(wrapPair[2]) };
|
|
76
|
+
if (!wrapIcons.disable || !wrapIcons.enable) throw new Error('native-code-wrap-icon-exports-unavailable');
|
|
77
|
+
const button = table.match(/jsx\)\(([\w$]+),\{"aria-label":[\w$]+,"aria-expanded"/)?.[1];
|
|
78
|
+
const copy = table.match(/jsx\)\(([\w$]+),\{ariaLabel:[\w$]+,buttonText:/)?.[1];
|
|
79
|
+
const tooltip = table.match(/jsx\)\(([\w$]+),\{tooltipContent:[\w$]+,delayOpen:!0/)?.[1];
|
|
80
|
+
if (!button || !copy || !tooltip) throw new Error('native-table-actions-controls-unavailable');
|
|
81
|
+
const [Button, CopyButton, Tooltip] = await Promise.all([binding(button), binding(copy), binding(tooltip)]);
|
|
82
|
+
const previewName = table.match(/jsx\)\(([\w$]+),\{src:``,alt:/)?.[1];
|
|
83
|
+
const tableName = table.match(/jsx\)\(([\w$]+),\{className:[\w$]+,children:[\w$]+\}/)?.[1];
|
|
84
|
+
const classesName = table.match(/([\w$]+)\.MarkdownTablePreview/)?.[1];
|
|
85
|
+
const icon = table.match(/children:\(0,[\w$]+\.jsx\)\(([\w$]+),\{icon:\{16:([\w$]+),20:([\w$]+)\}\}\)/);
|
|
86
|
+
if (!previewName || !tableName || !classesName || !icon)
|
|
87
|
+
throw new Error('native-table-preview-contract-unavailable');
|
|
88
|
+
const [Icon, small, medium, renderer] = await Promise.all([
|
|
89
|
+
binding(icon[1]),
|
|
90
|
+
binding(icon[2]),
|
|
91
|
+
binding(icon[3]),
|
|
92
|
+
loadNativeMarkdownRenderer(source, url, module),
|
|
93
|
+
]);
|
|
94
|
+
return {
|
|
95
|
+
...native,
|
|
96
|
+
...renderer,
|
|
97
|
+
TablePreview: publicBinding(previewName),
|
|
98
|
+
Table: publicBinding(tableName),
|
|
99
|
+
tableClasses: publicBinding(classesName),
|
|
100
|
+
ExpandIcon: () => native.React.createElement(Icon, { icon: { 16: small, 20: medium } }),
|
|
101
|
+
Actions: publicBinding(actions.match(/^function ([\w$]+)/)[1]),
|
|
102
|
+
Button,
|
|
103
|
+
wrapIcons,
|
|
104
|
+
CopyButton,
|
|
105
|
+
Tooltip,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// 使用当前编辑器所属的原生 CodeMirror 实例,避免引入第二套编辑器依赖。
|
|
2
|
+
export async function loadMarkdownListAPI(view) {
|
|
3
|
+
const links = [...document.querySelectorAll('link[rel="modulepreload"]')];
|
|
4
|
+
for (const link of links) {
|
|
5
|
+
if (!/\/dist-[\w-]+\.js$/.test(link.href)) continue;
|
|
6
|
+
const exports = Object.values(await import(link.href));
|
|
7
|
+
if (!exports.includes(view.constructor)) continue;
|
|
8
|
+
const Decoration = exports.find((value) => value?.line && value?.replace && value?.mark);
|
|
9
|
+
const ViewPlugin = exports.find((value) => value?.fromClass && value?.define);
|
|
10
|
+
const StateEffect = exports.find((value) => value?.appendConfig && value?.reconfigure);
|
|
11
|
+
const Compartment = exports.find(
|
|
12
|
+
(value) => value?.prototype?.reconfigure && value?.prototype?.of && value?.prototype?.get,
|
|
13
|
+
);
|
|
14
|
+
const WidgetType = exports.find(
|
|
15
|
+
(value) => value?.prototype?.eq && value?.prototype?.ignoreEvent && value?.prototype?.updateDOM,
|
|
16
|
+
);
|
|
17
|
+
const StateField = exports.find(
|
|
18
|
+
(value) =>
|
|
19
|
+
value?.define && value?.prototype?.slot && value?.prototype?.init && value?.prototype?.create,
|
|
20
|
+
);
|
|
21
|
+
const Prec = exports.find((value) => value?.highest && value?.lowest && value?.high);
|
|
22
|
+
if (Decoration && ViewPlugin && StateEffect && Compartment && WidgetType && Prec && StateField)
|
|
23
|
+
return { Decoration, ViewPlugin, StateEffect, Compartment, WidgetType, Prec, StateField };
|
|
24
|
+
}
|
|
25
|
+
throw new Error('native-markdown-list-api-unavailable');
|
|
26
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { createMarkdownReadingRuntime } from './reading-runtime.mjs';
|
|
2
|
-
|
|
3
1
|
// 当前原生 Markdown Preview 是 CodeMirror 视图;Source 与 Pages 不属于此契约。
|
|
4
|
-
export function createMarkdownPreviewAdapter(codex,
|
|
5
|
-
let runtime;
|
|
2
|
+
export function createMarkdownPreviewAdapter(codex, attach) {
|
|
6
3
|
function preview(editor) {
|
|
7
4
|
if (!editor.isConnected || !editor.closest('[data-editor-search-surface]')) return null;
|
|
8
5
|
const content = editor.querySelector('.cm-content[data-language="markdown"]');
|
|
@@ -30,9 +27,6 @@ export function createMarkdownPreviewAdapter(codex, resources) {
|
|
|
30
27
|
return {
|
|
31
28
|
preview,
|
|
32
29
|
previews,
|
|
33
|
-
attach(item) {
|
|
34
|
-
runtime ??= createMarkdownReadingRuntime(codex, undefined, resources);
|
|
35
|
-
return runtime.attach(item);
|
|
36
|
-
},
|
|
30
|
+
attach(item) { return attach(item); },
|
|
37
31
|
};
|
|
38
32
|
}
|
|
@@ -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."]],"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."]],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."]],"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","\u901A\u8FC7\u5FEB\u6377\u952E\u6253\u5F00 Quick Chat\uFF0C\u53D1\u9001\u540E\u5C55\u5F00\uFF0C\u6062\u590D\u6700\u5C0F\u5316\u8F93\u5165\u6846\u5E76\u56FA\u5B9A\u804A\u5929\u3002"],["The floating Quick Chat window.","Quick questions and continuing recent chats require window switching.","Open Quick Chat with a shortcut, expand after sending, restore a minimized composer and pin the chat."]],"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."]],"hide-upsell-banner":[["Codex \u7684\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\u533A\u57DF\u3002","\u63A8\u5E7F\u63D0\u793A\u5360\u7528\u65E5\u5E38\u64CD\u4F5C\u7A7A\u95F4\u3002","\u9690\u85CF\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\uFF0C\u4FDD\u7559\u771F\u5B9E\u989D\u5EA6\u4E0E\u8FD0\u884C\u9519\u8BEF\u53CD\u9988\u3002"],["Usage promotion banners in Codex.","Promotions take space during everyday tasks.","Hide usage promotions while retaining real usage and error feedback."]]}});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=>n.id!=="unread-inbox");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","\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."]],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."]],"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","\u901A\u8FC7\u5FEB\u6377\u952E\u6253\u5F00 Quick Chat\uFF0C\u53D1\u9001\u540E\u5C55\u5F00\uFF0C\u6062\u590D\u6700\u5C0F\u5316\u8F93\u5165\u6846\u5E76\u56FA\u5B9A\u804A\u5929\u3002"],["The floating Quick Chat window.","Quick questions and continuing recent chats require window switching.","Open Quick Chat with a shortcut, expand after sending, restore a minimized composer and pin the chat."]],"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."]],"hide-upsell-banner":[["Codex \u7684\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\u533A\u57DF\u3002","\u63A8\u5E7F\u63D0\u793A\u5360\u7528\u65E5\u5E38\u64CD\u4F5C\u7A7A\u95F4\u3002","\u9690\u85CF\u989D\u5EA6\u63A8\u5E7F\u63D0\u793A\uFF0C\u4FDD\u7559\u771F\u5B9E\u989D\u5EA6\u4E0E\u8FD0\u884C\u9519\u8BEF\u53CD\u9988\u3002"],["Usage promotion banners in Codex.","Promotions take space during everyday tasks.","Hide usage promotions while retaining real usage and error feedback."]]}});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=>n.id!=="unread-inbox");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.33"});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.39"});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:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/features/{markdown-reading → mermaid-diagrams}/src/adapters/codex/mermaid-viewer.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|